Subversion Repositories SmartDukaan

Rev

Rev 1643 | Rev 1795 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1643 Rev 1761
Line 95... Line 95...
95
}
95
}
96
 
96
 
97
 
97
 
98
function addResearch(refdivid,reqtype){
98
function addResearch(refdivid,reqtype){
99
     var research_tot=$("#research_total").val();
99
     var research_tot=$("#research_total").val();
100
     var seldata="";
100
     var seldata=[];
101
     var tot=0;
101
     var tot=0;
102
     var saprt="";
-
 
103
     
102
     
104
     if(reqtype=="multi"){
103
     if(reqtype=="multi"){
105
          var containerdiv = "#" + refdivid;     
104
          var containerdiv = "#" + refdivid;     
106
          var par= containerdiv + " input[type=checkbox]:checked";
105
          var par= containerdiv + " input[type=checkbox]:checked";
107
          $(par).each(function(){
106
          $(par).each(function(){
108
               saprt = (tot>0)? "_":"";
-
 
109
               seldata += saprt+$(this).val();
107
               seldata.unshift($(this).val());
110
               tot++;
108
               tot++;
111
          });
109
          });
112
     }else if(reqtype=="single"){
110
     }else if(reqtype=="single"){
113
          var seldata=$("#product_id").val();
111
    	  seldata.unshift($("#product_id").val());
114
          var tot=1;
112
          var tot=1;
115
     }else if(reqtype=="list"){
113
     }else if(reqtype=="list"){
116
          
-
 
117
          var seldata=refdivid;
114
    	  seldata.unshift(refdivid);
118
          var tot=1;
115
          var tot=1;
119
     }
116
     }
120
     
117
     
121
/*
-
 
122
     var historyitems = "";
-
 
123
     if($.Storage.get("historyitems")){
-
 
124
    	 historyitems = "&historyitems=" +  $.Storage.get("historyitems");
-
 
125
    	 $.Storage.remove("historyitems");
-
 
126
     }
-
 
127
     +historyitems
-
 
128
     */
-
 
129
     
-
 
130
     if(tot>0){
118
     if(tot>0){
131
          //alert("AJAX request to add products in My research. Product ID: "+seldata+" and total: "+tot);
119
          //alert("AJAX request to add products in My research. Product ID: "+seldata+" and total: "+tot);
132
          jQuery.ajax({
120
          jQuery.ajax({
133
               type: "POST",
121
               type: "POST",
134
                      url: "/addtoresearch",
122
                      url: "/addtoresearch",
135
                      data: "productid="+seldata,
123
                      data: "productid=["+seldata+"]",
136
                      success: function(msg){
124
                      success: function(msg){
137
                           
125
                           
138
                           if(msg == 0){
126
                           if(msg == 0){
139
                                alert( "Product is already in my research" );
127
                                alert( "Product is already in my research" );
140
                           }else {
128
                           }else {
Line 145... Line 133...
145
                                }     
133
                                }     
146
                                $("#pane1").prepend(msg);
134
                                $("#pane1").prepend(msg);
147
                                // $('#pane1').jScrollPane({showArrows:true, scrollbarWidth: 15, arrowSize: 16});
135
                                // $('#pane1').jScrollPane({showArrows:true, scrollbarWidth: 15, arrowSize: 16});
148
                                
136
                                
149
                                if(reqtype == "multi"){
137
                                if(reqtype == "multi"){
150
                                     var arrayprod_id=seldata.split("_");
138
                                     jQuery.each(seldata,function(intIndex, objValue){
151
                                     jQuery.each(arrayprod_id,function(intIndex, objValue){
139
                                    	  add_to_storage_set("resitems", objValue);
152
                                          var tblid="#pane1 #"+objValue+ " td";
140
                                    	  var tblid="#pane1 #"+objValue+ " td";
153
                                          $(tblid + " div a").truncate({addtitle: true});
141
                                          $(tblid + " div a").truncate({addtitle: true});
154
                                          $(tblid + " div div.price").truncate({addtitle: true});
142
                                          $(tblid + " div div.price").truncate({addtitle: true});
155
                                          $(tblid + " div div.text").truncate({addtitle: true});
143
                                          $(tblid + " div div.text").truncate({addtitle: true});
156
                                          $(tblid).animate({ backgroundColor: "#fcffb3" }, 'slow');
144
                                          $(tblid).animate({ backgroundColor: "#fcffb3" }, 'slow');
157
                                          $(tblid).animate({ backgroundColor: "#F5F5F5" }, 'slow');
145
                                          $(tblid).animate({ backgroundColor: "#F5F5F5" }, 'slow');
158
                                     });
146
                                     });
159
                                     
147
                                     
160
                                }else if(reqtype == "single"){
148
                                }else if(reqtype == "single"){
-
 
149
                                	 add_to_storage_set("resitems", seldata);
161
                                     var tblid="#pane1 #"+seldata+ " td";
150
                                     var tblid="#pane1 #"+seldata+ " td";
162
                                     $(tblid + " div a").truncate({addtitle: true});
151
                                     $(tblid + " div a").truncate({addtitle: true});
163
                                     $(tblid + " div div.price").truncate({addtitle: true});
152
                                     $(tblid + " div div.price").truncate({addtitle: true});
164
                                     $(tblid + " div div.text").truncate({addtitle: true});
153
                                     $(tblid + " div div.text").truncate({addtitle: true});
165
                                     $(tblid).animate({ backgroundColor: "#fcffb3" }, 'slow');
154
                                     $(tblid).animate({ backgroundColor: "#fcffb3" }, 'slow');
166
                                     $(tblid).animate({ backgroundColor: "#F5F5F5" }, 'slow');  
155
                                     $(tblid).animate({ backgroundColor: "#F5F5F5" }, 'slow');  
167
                                }else if(reqtype == "list"){
156
                                }else if(reqtype == "list"){
-
 
157
                                	 add_to_storage_set("resitems", seldata);
168
                                     var tblid="#pane1 #"+seldata+ " td";
158
                                     var tblid="#pane1 #"+seldata+ " td";
169
                                     $(tblid + " div a").truncate({addtitle: true});
159
                                     $(tblid + " div a").truncate({addtitle: true});
170
                                     $(tblid + " div div.price").truncate({addtitle: true});
160
                                     $(tblid + " div div.price").truncate({addtitle: true});
171
                                     $(tblid + " div div.text").truncate({addtitle: true});
161
                                     $(tblid + " div div.text").truncate({addtitle: true});
172
                                     $(tblid).animate({ backgroundColor: "#fcffb3" }, 'slow');
162
                                     $(tblid).animate({ backgroundColor: "#fcffb3" }, 'slow');
173
                                     $(tblid).animate({ backgroundColor: "#F5F5F5" }, 'slow');     
163
                                     $(tblid).animate({ backgroundColor: "#F5F5F5" }, 'slow');     
174
                                }    
164
                                }    
175
                           }
165
                           }
176
                           $.Storage.set("research", $("#myresearch").html());
-
 
177
                           //alert( "Data Saved: " + msg );
166
                           //alert( "Data Saved: " + msg );
178
                      }
167
                      }
179
          });
168
          });
180
          
169
          
181
     }else{
170
     }else{
Line 285... Line 274...
285
  $('#newShipAdr').hide();
274
  $('#newShipAdr').hide();
286
	scrollWinToTop();
275
	scrollWinToTop();
287
 
276
 
288
}
277
}
289
 
278
 
-
 
279
function merge_history_items(){
-
 
280
	params = $.Storage.get("histitems");
-
 
281
	
-
 
282
	jQuery.ajax({
-
 
283
		type: "POST",
-
 
284
		url: "/browse-history",
-
 
285
		data: "id="+params,
-
 
286
		cache: false,
-
 
287
		success: function(json) {
-
 
288
		    $.Storage.set("histitems", json);
-
 
289
		    load_history_widget();
-
 
290
	    }
-
 
291
	});
-
 
292
}
-
 
293
 
-
 
294
function load_research_items(){
-
 
295
	jQuery.ajax({
-
 
296
		type: "GET",
-
 
297
		url: "/myresearch",
-
 
298
		cache: false,
-
 
299
		success: function(json) {
-
 
300
		    $.Storage.set("resitems", json);
-
 
301
		    load_research_widget();
-
 
302
	    }
-
 
303
	});
-
 
304
}
-
 
305
 
290
function load_research_widget(){
306
function load_research_widget(){
-
 
307
	var params = "";
-
 
308
	params = "/" + $.Storage.get("resitems");
-
 
309
	
291
	jQuery.ajax( {
310
	jQuery.ajax({
292
		type : "GET",
311
		type : "GET",
293
		url : "/myresearch",
312
		url : "/myresearch" + params,
294
		cache: false,
313
		cache: false,
295
		success : function(html) {
314
		success : function(html) {
296
		$("#myresearch").html(html);
315
   		    $("#myresearch").html(html);
297
 
316
 
298
		// Product Title
317
		    // Product Title
299
		$("#myresearch table td div a").each(
318
		    $("#myresearch table td div a").each(function() {
300
				function() {
-
 
301
					$(this).truncate( {
319
					$(this).truncate({addtitle : true});
302
						addtitle : true
-
 
303
					});
320
		    });
304
				});
-
 
305
 
321
 
306
		// Product Price
322
		    // Product Price
307
		$("#myresearch table td div div.price").each(
323
		    $("#myresearch table td div div.price").each(function() {
308
				function() {
-
 
309
					$(this).truncate( {
324
					$(this).truncate({addtitle : true});
310
						addtitle : true
-
 
311
					});
-
 
312
				});
325
			});
313
 
326
 
314
		// Product Details
327
		    // Product Details
315
		$("#myresearch table td div div.text").each(
328
		    $("#myresearch table td div div.text").each(function() {
316
				function() {
-
 
317
					$(this).truncate( {
329
					$(this).truncate( {addtitle : true});
318
						addtitle : true
-
 
319
					});
-
 
320
				});
330
			});
321
		$.Storage.set("research", $("#myresearch").html());		  
-
 
322
	}
331
	    }
323
	});
332
	});
324
}
333
}
325
 
334
 
326
function update_browse_history(){
-
 
327
	if($.Storage.get("historyitems")){
-
 
328
		params = $.Storage.get("historyitems");
-
 
329
 
-
 
330
		jQuery.ajax({
-
 
331
			type: "POST",
-
 
332
			url: "/browse-history",
-
 
333
			data: "historyitems="+params,
-
 
334
			cache: false,
-
 
335
			success: function(html){
-
 
336
				//alert(html);
-
 
337
			}
-
 
338
		});
-
 
339
	}	
-
 
340
}
-
 
341
 
-
 
342
function load_history_widget() {
335
function load_history_widget() {
343
	var params = "";
336
	var params = "";
344
	if(!($.cookie("uid"))){
-
 
345
		if($.Storage.get("historyitems")){
-
 
346
			params = "/" + $.Storage.get("historyitems");
337
	params = "/" + $.Storage.get("histitems");
347
		}
-
 
348
	}
-
 
349
	
338
	
350
	jQuery.ajax({
339
	jQuery.ajax({
351
		type: "GET",
340
		type: "GET",
352
		url: "/browse-history" + params,
341
		url: "/browse-history" + params,
353
		cache: false,
342
		cache: false,
354
		success: function(html){
343
		success: function(html){
355
		$("#browsehistory").html(html);
344
		    $("#browsehistory").html(html);
356
 
345
 
357
		// Product Title
346
		    // Product Title
358
		$("#browsehistory table td div a").each(function(){
347
		    $("#browsehistory table td div a").each(function(){
359
			$(this).truncate({addtitle: true}); 
348
			    $(this).truncate({addtitle: true}); 
360
		});
349
		    });
361
 
350
 
362
		// Product Price
351
    		// Product Price
363
		$("#browsehistory table td div div.price").each(function(){
352
	    	$("#browsehistory table td div div.price").each(function(){
-
 
353
		    	$(this).truncate({addtitle: true});
-
 
354
		    });
-
 
355
 
-
 
356
		    // Product Details
-
 
357
		    $("#browsehistory table td div div.text").each(function(){
364
			$(this).truncate({addtitle: true});
358
			    $(this).truncate({addtitle: true});
-
 
359
		    });
-
 
360
	    }
365
		});
361
	});
-
 
362
}
366
 
363
 
-
 
364
function add_to_storage_set(key, id) {
-
 
365
	var set = eval($.Storage.get(key));
367
		// Product Details
366
	if (set) {
368
		$("#browsehistory table td div div.text").each(function(){
367
		$.each(set, function(index, value) {
-
 
368
			if (value == id) {
369
			$(this).truncate({addtitle: true});
369
				set.splice(index, 1);
-
 
370
			}
370
		});
371
		});
371
		$.Storage.set("history", $("#browsehistory").html());
-
 
372
	}
372
	}
373
	});
373
	set.unshift(id);
-
 
374
	$.Storage.set(key, "[" + set.toString() + "]");
374
}
375
}
375
 
376
 
-
 
377
function delete_from_storage_set(key, id) {
-
 
378
	var set = eval($.Storage.get(key));
-
 
379
	if (set) {
-
 
380
		$.each(set, function(index, value) {
-
 
381
			if (value == id) {
-
 
382
				set.splice(index, 1);
-
 
383
			}
-
 
384
		});
-
 
385
	}
-
 
386
	$.Storage.set(key, "[" + set.toString() + "]");
-
 
387
}
376
388