Subversion Repositories SmartDukaan

Rev

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

Rev 1623 Rev 1761
Line 169... Line 169...
169
    var itemsarray = items.split('-');
169
    var itemsarray = items.split('-');
170
    addResearch(itemsarray[1], itemsarray[0]);
170
    addResearch(itemsarray[1], itemsarray[0]);
171
    return false;
171
    return false;
172
  });
172
  });
173
  $("#research_delete").live('click', function(){var research_tot = $("#research_total").val();
173
  $("#research_delete").live('click', function(){var research_tot = $("#research_total").val();
174
  	var seldata = "";
174
    var seldata=[];
175
	var tot = 0;
175
	var tot = 0;
176
	var saprt = "";
176
	var saprt = "";
177
	var containerdiv = "#pane1";
177
	var containerdiv = "#pane1";
178
	var par = containerdiv + " input[type=checkbox]:checked";
178
	var par = containerdiv + " input[type=checkbox]:checked";
179
 
179
 
180
	$(par).each(function(){
180
	$(par).each(function(){
181
		saprt = (tot > 0) ? "_" : "";
-
 
182
		seldata += saprt + $(this).val();
181
		seldata.unshift($(this).val());
183
		tot ++;
182
		tot ++;
184
	});
183
	});
185
 
184
 
186
	if(tot > 0)	{
185
	if(tot > 0)	{
187
		var t = (research_tot * 1) - (tot * 1);
186
		var t = (research_tot * 1) - (tot * 1);
188
		$("#research_total").val(t);
187
		$("#research_total").val(t);
189
 
188
 
190
		jQuery.ajax({
189
		jQuery.ajax({
191
			type: "GET",
190
			type: "GET",
192
			url: "/deletefromresearch/" + seldata + "?_method=delete",
191
			url: "/deletefromresearch/[" + seldata + "]",
193
			data: "productid=" + seldata,
-
 
194
			success: function(msg){
192
			success: function(msg){
195
				jQuery.each(seldata.split("_"), function(intIndex, objValue){
193
				jQuery.each(seldata, function(intIndex, objValue){
-
 
194
					delete_from_storage_set("resitems", objValue);
196
					$("#pane1").find("#" + objValue).fadeOut('slow', function() {
195
					$("#pane1").find("#" + objValue).fadeOut('slow', function() {
197
						$(this).remove();
196
						$(this).remove();
198
						$.Storage.set("research", $("#myresearch").html());
-
 
199
						if(t === 0)	{
197
						if(t === 0)	{
200
							$("#research_default").css("display", "block");
198
							$("#research_default").css("display", "block");
201
						}
199
						}
202
					});
200
					});
203
				});
201
				});
Line 206... Line 204...
206
	} else	{
204
	} else	{
207
		alert("Please select atleast one product");
205
		alert("Please select atleast one product");
208
	}
206
	}
209
  });
207
  });
210
 
208
 
211
  /*
-
 
212
  if(!($.Storage.get("uid")) && $.cookie("uid")){
209
  // Clear old cache keys. These two lines can be deleted after June 5, 2011.  
213
	  update_browse_history();
210
  $.Storage.remove("history");
214
	  $.Storage.remove("historyitems");
211
  $.Storage.remove("research");
215
  }
-
 
216
  
212
  
217
  if( $.Storage.get("uid") && !($.cookie("uid"))){
213
  // No uid cookie
218
	  $.Storage.remove("research");
214
  if (!$.cookie("uid")) {
219
	  $.Storage.remove("history");
215
	  // No uid in storage
220
  }
-
 
221
  
-
 
222
  
-
 
223
  
-
 
224
  if($.Storage.get("uid")){
216
	  if (!$.Storage.get("uid")) {
225
	  if($.cookie("uid")){
217
		  if (!$.Storage.get("resitems")) {
226
		  $.Storage.remove("research");
218
			  $.Storage.set("resitems", "[]");
-
 
219
		  }
227
		  $.Storage.remove("history");		  
220
		  if (!$.Storage.get("histitems")) {
228
	  }else{
221
			  $.Storage.set("histitems", "[]");
229
		  
222
		  }
230
	  }
223
	  }
-
 
224
	  // uid in storage : logout
231
  }else{
225
	  else {
232
	  if($.cookie("uid")){
226
		  $.Storage.remove("uid");
233
		  
227
		  $.Storage.set("resitems", "[]");
-
 
228
		  $.Storage.set("histitems", "[]");
234
	  }
229
	  }
235
  }
-
 
236
   */
-
 
237
  
-
 
238
  if ( !($.Storage.get("uid")) && ($.cookie("uid"))) {
-
 
239
	  update_browse_history();
-
 
240
	  $.Storage.remove("historyitems");
-
 
241
  }
-
 
242
 
-
 
243
  if ( (($.cookie("uid")) || ($.Storage.get("uid")))  && ($.cookie("uid") != $.Storage.get("uid"))) {
-
 
244
	  $.Storage.set("uid", $.cookie("uid"));
-
 
245
	  $.Storage.remove("research");
-
 
246
	  $.Storage.remove("history");
-
 
247
  }
-
 
248
 
-
 
249
  /*
-
 
250
  if ($.cookie("uid") != $.Storage.get("uid")) {
-
 
251
	  $.Storage.set("uid", $.cookie("uid"));
-
 
252
	  $.Storage.remove("research");
-
 
253
	  $.Storage.remove("history");
-
 
254
    	  
-
 
255
	  update_browse_history();
-
 
256
	  $.Storage.remove("historyitems");
-
 
257
  }
-
 
258
   */
-
 
259
  
-
 
260
  if ($.Storage.get("research")) {
-
 
261
	  $("#myresearch").html($.Storage.get("research"));
-
 
262
  }
-
 
263
  else {
-
 
264
	  load_research_widget();
230
	  load_research_widget();
-
 
231
	  load_history_widget();
265
  }
232
  }
266
  
-
 
267
  if ($.Storage.get("history")) {
233
  // With uid cookie
268
	  $("#browsehistory").html($.Storage.get("history"));
-
 
269
  }
-
 
270
  else {
234
  else {
-
 
235
	  var cookie = $.cookie("uid");
-
 
236
	  // Just logged in merge storage items
-
 
237
	  if (!$.Storage.get("uid")) {
-
 
238
		  $.Storage.set("uid", cookie);
-
 
239
		  merge_history_items();
-
 
240
		  load_research_items();
-
 
241
	  }
-
 
242
	  else {
-
 
243
		  // UID changed
-
 
244
		  if ( cookie != $.Storage.get("uid")) {
-
 
245
			  $.Storage.set("uid", cookie);
-
 
246
			  $.Storage.set("resitems", "[]");
-
 
247
			  $.Storage.set("histitems", "[]");
-
 
248
			  merge_history_items();
-
 
249
			  load_research_items();
-
 
250
		  }
-
 
251
		  // Uid is same
-
 
252
		  else {
-
 
253
			  if (!$.Storage.get("resitems")) {
-
 
254
				  $.Storage.set("resitems", "[]");
-
 
255
				  load_research_items();
-
 
256
			  }
-
 
257
			  else {
-
 
258
				  load_research_widget();
-
 
259
			  }
-
 
260
			  if (!$.Storage.get("histitems")) {
-
 
261
				  $.Storage.set("histitems", "[]");
-
 
262
				  merge_history_items();
-
 
263
			  }
-
 
264
			  else {
271
	  load_history_widget();
265
				  load_history_widget();
-
 
266
			  }
-
 
267
		  }
-
 
268
	  }
272
  }
269
  }
-
 
270
 
273
});
271
});
274
272