Subversion Repositories SmartDukaan

Rev

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

Rev 3830 Rev 4126
Line 142... Line 142...
142
    var itemsarray = items.split('-');
142
    var itemsarray = items.split('-');
143
 	
143
 	
144
    addResearch(itemsarray[1], itemsarray[0]);
144
    addResearch(itemsarray[1], itemsarray[0]);
145
    return false;
145
    return false;
146
  });
146
  });
147
  $("#research_delete").live('click', function(){var research_tot = $("#research_total").val();
-
 
148
    var seldata=[];
-
 
149
	var tot = 0;
-
 
150
	var saprt = "";
-
 
151
	var par = $('#myresearch').find('input[type=checkbox]:checked');
-
 
152
 
-
 
153
	$(par).each(function(){
-
 
154
		seldata.unshift($(this).val());
-
 
155
		tot ++;
-
 
156
	});
-
 
157
 
-
 
158
	if(tot > 0)	{
-
 
159
		var t = (research_tot * 1) - (tot * 1);
-
 
160
		$("#research_total").val(t);
-
 
161
 
-
 
162
		jQuery.ajax({
-
 
163
			type: "GET",
-
 
164
			url: "/deletefromresearch/[" + seldata + "]?_method=delete",
-
 
165
			success: function(msg){
-
 
166
				jQuery.each(seldata, function(intIndex, objValue){
-
 
167
					delete_from_storage_set("resitems", objValue);
-
 
168
					$("#myresearch").find("#" + objValue).fadeOut('slow', function() {
-
 
169
						$(this).remove();
-
 
170
						if(t === 0)	{
-
 
171
							$("#research_default").css("display", "block");
-
 
172
						}
-
 
173
					});
-
 
174
				});
-
 
175
			}
-
 
176
		});
-
 
177
	} else	{
-
 
178
		alert("Please select atleast one product");
-
 
179
	}
-
 
180
  });
-
 
181
 
-
 
182
 $("#research_compare").live('click', function(){
-
 
183
        var seldata = "";
-
 
184
        var tot = 1;
-
 
185
        var saprt = "";
-
 
186
        var par = $('#myresearch').find('input[type=checkbox]:checked');
-
 
187
        
-
 
188
        $(par).each(function(){
-
 
189
        		if(tot == 1){
-
 
190
        			seldata +=  "p"+tot + "=" + $(this).val();
-
 
191
        		}else{
-
 
192
        			seldata +=  "&p"+tot + "=" + $(this).val();
-
 
193
        		}
-
 
194
                tot ++;
-
 
195
        });
-
 
196
 
-
 
197
	if(tot > 6){
-
 
198
		alert("Can compare upto five products only.");
-
 
199
	}else if(tot > 2)     {
-
 
200
                window.location="/compare-mobile-phones?" + seldata;
-
 
201
        } else  {
-
 
202
                alert("Please select atleast two products");
-
 
203
        }
-
 
204
});
-
 
205
 
-
 
206
  // No uid cookie
-
 
207
  if (!$.cookie("uid")) {
-
 
208
	  // No uid in storage
-
 
209
	  if (!$.Storage.get("uid")) {
-
 
210
		  if (!$.Storage.get("resitems")) {
-
 
211
			  $.Storage.set("resitems", "[]");
-
 
212
		  }
-
 
213
		  if (!$.Storage.get("histitems")) {
-
 
214
			  $.Storage.set("histitems", "[]");
-
 
215
		  }
-
 
216
	  }
-
 
217
	  // uid in storage : logout
-
 
218
	  else {
-
 
219
		  $.Storage.remove("uid");
-
 
220
		  $.Storage.set("resitems", "[]");
-
 
221
		  $.Storage.set("histitems", "[]");
-
 
222
	  }
-
 
223
	  load_research_widget();
-
 
224
	  load_history_widget();
-
 
225
  }
-
 
226
  // With uid cookie
-
 
227
  else {
-
 
228
	  var cookie = $.cookie("uid");
-
 
229
	  // Just logged in merge storage items
-
 
230
	  if (!$.Storage.get("uid")) {
-
 
231
		  $.Storage.set("uid", cookie);
-
 
232
		  merge_history_items();
-
 
233
		  load_research_items();
-
 
234
	  }
-
 
235
	  else {
-
 
236
		  // UID changed
-
 
237
		  if ( cookie != $.Storage.get("uid")) {
-
 
238
			  $.Storage.set("uid", cookie);
-
 
239
			  $.Storage.set("resitems", "[]");
-
 
240
			  $.Storage.set("histitems", "[]");
-
 
241
			  merge_history_items();
-
 
242
			  load_research_items();
-
 
243
		  }
-
 
244
		  // Uid is same
-
 
245
		  else {
-
 
246
			  if (!$.Storage.get("resitems")) {
-
 
247
				  $.Storage.set("resitems", "[]");
-
 
248
				  load_research_items();
-
 
249
			  }
-
 
250
			  else {
-
 
251
				  load_research_widget();
-
 
252
			  }
-
 
253
			  if (!$.Storage.get("histitems")) {
-
 
254
				  $.Storage.set("histitems", "[]");
-
 
255
				  merge_history_items();
-
 
256
			  }
-
 
257
			  else {
-
 
258
				  load_history_widget();
-
 
259
			  }
-
 
260
		  }
-
 
261
	  }
-
 
262
  }
-
 
263
 
-
 
264
});
147
});
265
148