Subversion Repositories SmartDukaan

Rev

Rev 15014 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 15014 Rev 15017
Line 20... Line 20...
20
 
20
 
21
    private String url;
21
    private String url;
22
    private String supc = "";
22
    private String supc = "";
23
    private String productUrl = "";
23
    private String productUrl = "";
24
    private String color = "";
24
    private String color = "";
-
 
25
    private final String INDEX = "index";
25
 
26
 
26
    public String getJavaScriptToEmbedd() throws IOException, JSONException, URISyntaxException{
27
    public String getJavaScriptToEmbedd() throws IOException, JSONException, URISyntaxException{
27
        try{
28
        try{
28
            parseUrl();
29
            parseUrl();
29
            System.out.println(productUrl);
30
            System.out.println(productUrl);
Line 33... Line 34...
33
            for (int element=0; element<jsonArray.length();element++){
34
            for (int element=0; element<jsonArray.length();element++){
34
                if (supc.equalsIgnoreCase(jsonArray.getJSONObject(element).getString("supc"))){
35
                if (supc.equalsIgnoreCase(jsonArray.getJSONObject(element).getString("supc"))){
35
                    color = jsonArray.getJSONObject(element).getString("value");
36
                    color = jsonArray.getJSONObject(element).getString("value");
36
                }
37
                }
37
            }
38
            }
38
            return getJavaScriptCode();
39
            setResultJson(getJavaScriptCode());
39
        }
40
        }
40
        catch (Exception e){
41
        catch (Exception e){
41
            log.error("Error while getting product details " +e);
42
            log.error("Error while getting product details " +e);
42
            return "";
43
            setResultJson(getJavaScriptCode());
43
        }
44
        }
-
 
45
        return INDEX;
44
        
46
        
45
    }
47
    }
46
    
48
    
47
    private String getJavaScriptCode(){
49
    private String getJavaScriptCode(){
48
        String jsCode = "javascript:try{var ele=document.getElementById('attribute-select-0');ele.value ="+"'"+color+"'"+"';ele.onchange();}catch(error){Android.onError(error.message);}";
50
        String jsCode = "javascript:try{var ele=document.getElementById('attribute-select-0');ele.value ="+"'"+color+"'"+"';ele.onchange();}catch(error){Android.onError(error.message);}";
Line 71... Line 73...
71
    }
73
    }
72
 
74
 
73
    public static void main(String[] args) throws URISyntaxException, IOException, JSONException{
75
    public static void main(String[] args) throws URISyntaxException, IOException, JSONException{
74
        SnapdealProductPageParser s = new SnapdealProductPageParser();
76
        SnapdealProductPageParser s = new SnapdealProductPageParser();
75
        s.setUrl("http://m.snapdeal.com/product/htc-desire-620-g/2140463474?supc=SDL872629472&utm_source=aff_prog&utm_campaign=afts&offer_id=17&aff_id=33550&aff_sub=SHA31430302193");
77
        s.setUrl("http://m.snapdeal.com/product/htc-desire-620-g/2140463474?supc=SDL872629472&utm_source=aff_prog&utm_campaign=afts&offer_id=17&aff_id=33550&aff_sub=SHA31430302193");
76
        System.out.println(s.getJavaScriptToEmbedd());
-
 
77
 
78
 
78
    }
79
    }
79
 
80
 
80
 
81
 
81
 
82