Subversion Repositories SmartDukaan

Rev

Rev 16467 | Rev 16485 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
14386 anikendra 1
var livePriceCalls = [];
14432 anikendra 2
var outOfStockCount = 0;
14773 anikendra 3
function getcashbackstring(type,value) {
4
	if(value==0){
5
		return '';
6
	}
7
	if(type==2){
14789 anikendra 8
		return ' +'+value+' Cashback';
14773 anikendra 9
	}else if(type==1){
14789 anikendra 10
		return ' +'+value+'% Cashback';
14773 anikendra 11
	}else{
12
		return '';
13
	}
15926 anikendra 14
};
15
function showShopcluesPopup(url){
16
	$('#shopcluesUrl').prop('href',url);
17
	$('#shopcluesModal').modal('show');
18
	return;
19
};
16397 anikendra 20
function showPaytmPopup(url){
21
	$('#paytmUrl').prop('href',url);
22
	$('#paytmModal').modal('show');
23
	return;
24
};
13984 anikendra 25
$(function(){	
26
	if($('.scroll > .card').length>0) {
14969 anikendra 27
		setTimeout(function(){ document.location.reload(); }, 1000*15*60);
16395 anikendra 28
		if(typeof noscrolling == 'undefined') {
16368 anikendra 29
			$('.scroll').jscroll({
30
				loadingHtml: '<center><img src="/img/ajax-loader.gif" alt="Loading" /></center>',
31
			    autoTriggerUntil: 3,
32
			    padding: 20,
33
			});
34
		}
13820 anikendra 35
	}
13901 anikendra 36
	if($('.storeminprice').length>0) {
37
		var globalminprice = 9999999;
14773 anikendra 38
		var globalminsku;
39
		var globalmincashback = '';		
16124 anikendra 40
		var globalminoffer = '';		
14345 anikendra 41
		var calls = [];
13901 anikendra 42
		$('.storeminprice').each(function(){
14345 anikendra 43
			var temp = {'sort':$(this).data('searchorder'),'val':$(this)};
44
			calls.push(temp);
45
		});
46
		calls = sortByKey(calls,'sort');		
47
		for(var i in calls){
48
			fetchLivePrice(calls[i]['val'])
14969 anikendra 49
		}				
14345 anikendra 50
	};
51
	function sortByKey(array, key) {
52
	    return array.sort(function(a, b) {
53
	        var x = a[key]; var y = b[key];
54
	        return ((x < y) ? -1 : ((x > y) ? 1 : 0));
55
	    });
15926 anikendra 56
	};		
15923 anikendra 57
	function getCouponText(coupon){
58
		return "<span class='red'>"+coupon+"</span>";
15926 anikendra 59
	};
16467 anikendra 60
	function getGrossPriceText(gross_price,available_price){
16471 anikendra 61
		return "("+gross_price+" - Paytm cashback "+(gross_price-available_price)+")"
16467 anikendra 62
	}
14432 anikendra 63
	function fetchLivePrice(obj){		
15607 anikendra 64
		ga('send', 'event', 'liveprice', 'fetch',$('#bestpriceproductname').html());
15550 anikendra 65
		var properties = {};
66
		properties.bundle_id = String($(obj).data('bundle_id'));
15607 anikendra 67
		properties.product_name = String($('#bestpriceproductname').html());
15585 anikendra 68
		pma.send('products','livesprice','fetch',me,properties);
14432 anikendra 69
		var that = obj;	
70
		var inStock = false;		
14386 anikendra 71
		var req = $.ajax({
14345 anikendra 72
			url: '/store_products/getliveprice/'+$(that).data('bundle_id')+'/'+$(that).data('id'),
73
			// Tell jQuery we're expecting JSONP
74
			dataType: "json",
75
			// Tell YQL what we want and that we want JSON			
76
			method: 'get',
14430 anikendra 77
			// timeout: 30000,
14345 anikendra 78
			// Work with the response
79
			success: function( response ) {
80
				if(response.success){
81
					var i = 0;	
16219 anikendra 82
					var minpriceindex = 0;									
14797 anikendra 83
					if(response.products[i].in_stock == 1) {
16219 anikendra 84
						inStock = true;
14797 anikendra 85
						var minprice = Math.round(response.products[i]['available_price']);
86
						var minpriceurl = response.products[i]['marketPlaceUrl'];
87
					}
14345 anikendra 88
					if(response.products.length>0){
89
						//More than one products in store
90
						var variants = [];
16124 anikendra 91
						var j = 0;
92
						for(var i in response.products){								
14685 anikendra 93
							if(response.products[i].in_stock == 1){
15923 anikendra 94
								inStock = true;								
14685 anikendra 95
								if(response.products[i].available_price && response.products[i].available_price < globalminprice) {
96
									globalminprice = Math.round(response.products[i].available_price);
97
									globalminsku = response.products[i]._id;
98
									var globalminsource = response.products[i].source_id;
14773 anikendra 99
									var globalminurl = response.products[i].marketPlaceUrl;
16124 anikendra 100
									var globalminoffer = response.products[i].offer;
14773 anikendra 101
									var globalmincashback = getcashbackstring(response.products[i].cash_back_type,response.products[i].cash_back);
14685 anikendra 102
								}
16219 anikendra 103
								if(typeof minprice == 'undefined' || response.products[i].available_price < minprice) {
14685 anikendra 104
									minprice = Math.round(response.products[i].available_price);
16219 anikendra 105
									minpriceindex = j;
16124 anikendra 106
								}								
16234 anikendra 107
								if(response.products[i].tagline && response.products[i].tagline.length>0 && $('#productoneliner').html().length==0) { 
16124 anikendra 108
									$('#productoneliner').html(response.products[i].tagline).removeClass('hidden').show();									
109
								}								
16467 anikendra 110
								variants.push({'name' : response.products[i].source_product_name, 'source_id' : response.products[i].source_id, 'available_price' : Math.round(response.products[i].available_price), 'url' : response.products[i].marketPlaceUrl,'source_product_name' : response.products[i].source_product_name,'id' : response.products[i]._id,'cash_back_type' : response.products[i].cash_back_type,'cash_back' : response.products[i].cash_back,'coupon': response.products[i].coupon,'codAvailable' : response.products[i].codAvailable,'offer' : response.products[i].offer,'gross_price' : response.products[i].gross_price});
16124 anikendra 111
							}					
16219 anikendra 112
							j++;
13901 anikendra 113
						}
16219 anikendra 114
						if(variants.length>1){
16124 anikendra 115
							variants.splice(minpriceindex,1);							
14713 anikendra 116
							var variantslink = $('<span class="variants"> '+(variants.length+1)+' Options</span>');
117
							$(that).parent().parent().find('.pull-left',0).append(variantslink);							
14799 anikendra 118
							$(variantslink).data('variants',variants).data('minprice',minprice);
13948 anikendra 119
						}
14345 anikendra 120
					}
121
					if(inStock){
14797 anikendra 122
						$(that).html(minprice).siblings('.cashbackamount').html(getcashbackstring(response.products[minpriceindex].cash_back_type,response.products[minpriceindex].cash_back)).parent().addClass('viewproduct');
14689 anikendra 123
						$('#name-'+$(that).data('id')).html(response.products[minpriceindex]['source_product_name']);
16039 anikendra 124
						if(response.products[minpriceindex]['coupon'] && response.products[minpriceindex]['coupon'].length>0){
15923 anikendra 125
							$('#couponcode-'+$(that).data('id')).show().find('span.red',0).html(getCouponText(response.products[minpriceindex]['coupon']));
16013 anikendra 126
						}			
127
						if(!response.products[minpriceindex]['codAvailable']){
16124 anikendra 128
							$('#codstatus-'+$(that).data('id')).show().removeClass('codstatus');
15923 anikendra 129
						}
16467 anikendra 130
						if(response.products[minpriceindex]['gross_price'] && response.products[minpriceindex]['gross_price'] > 0){
131
							$('#gross_price-'+$(that).data('id')).show().removeClass('gross_price').html(getGrossPriceText(response.products[minpriceindex]['gross_price'],response.products[minpriceindex]['available_price']));
132
						}
16124 anikendra 133
						if(response.products[minpriceindex]['offer'].length>0){
134
							$('#itemoffer-'+$(that).data('id')).show().html(response.products[minpriceindex]['offer']);
135
						}
14685 anikendra 136
						$('#sku-'+$(that).data('id')).data('id',response.products[minpriceindex]['_id']).data('source',response.products[minpriceindex]['source_id']).data('price',response.products[minpriceindex]['available_price']).data('url',response.products[minpriceindex]['marketPlaceUrl']).removeClass('hidden');
14345 anikendra 137
						if(globalminprice != 9999999) {
16124 anikendra 138
							$('#bestprice').html(globalminprice).siblings('.cashbackamount').html(globalmincashback).siblings('.productoffer').html(globalminoffer);
14685 anikendra 139
							$('#beststorelink').data('id',globalminsku).data('source',globalminsource).data('price',globalminprice).data('url',globalminurl).removeClass('hidden');
14345 anikendra 140
							$('#bestpricecontainer').removeClass('hidden');
14432 anikendra 141
						} 
14386 anikendra 142
					} else{
15607 anikendra 143
						ga('send', 'event', 'liveprice', 'outofstock', $('#bestpriceproductname').html());
15550 anikendra 144
						var properties = {};
145
						properties.sku = String(response.products[0]._id);
15607 anikendra 146
						properties.source = String(response.products[0].source_id);
147
						properties.product_name = String($('#bestpriceproductname').html());
15767 anikendra 148
						pma.send('products','liveprice','outofstock',me,properties);
14432 anikendra 149
						outOfStockCount++;
14345 anikendra 150
						$(that).parent().parent().remove();	
13901 anikendra 151
					}
14345 anikendra 152
					if(!response.products[0].available_price){
14434 anikendra 153
						// outOfStockCount++;
154
						// $(that).parent().parent().remove();	
155
						var btn = $("<a class='tryagainforliveprice btn btn-xs btn-warning' title='Try Again'>Try Again</a>");
156
						$(that).html(btn);
15585 anikendra 157
						// ga('send', 'event', 'liveprice', 'failed', response.products[0]._id);
158
						// console.log('failed for '+ response);
159
						// properties = {};
160
						// properties.sku = String(response.products[0]._id); 
161
						// pma.send('products','liveprice','failed',me,properties);
14969 anikendra 162
					}					
14386 anikendra 163
				} else{
14434 anikendra 164
					// outOfStockCount++;
165
					// $(that).parent().parent().remove();
166
					var btn = $("<a class='tryagainforliveprice btn btn-xs btn-warning' title='Try Again'>Try Again</a>");
167
					$(that).html(btn);
14969 anikendra 168
					ga('send', 'event', 'liveprice', 'failure', response.products[0]._id);
15550 anikendra 169
					properties = {};
170
					properties.sku = String(response.products[0]._id); 
171
					pma.send('products','liveprice','failure',me,properties);
13901 anikendra 172
				}
14432 anikendra 173
				checkForOutStocks(outOfStockCount);
14345 anikendra 174
			},
15310 anikendra 175
			error: function(request, status, err) {            	
176
        		var btn = $("<a class='tryagainforliveprice btn btn-xs btn-warning' title='Try Again'>Try Again</a>");
177
				$(that).html(btn);
178
				try{
179
					if(response){
180
						ga('send', 'event', 'liveprice', 'error', response.products[0]._id);
15550 anikendra 181
						var properties = {};
182
						properties.sku = String(response.products[0]._id);
183
						pma.send('products','livescore','error',me,properties);
15310 anikendra 184
					}						
185
				} catch(e){}
14345 anikendra 186
			}
13901 anikendra 187
		});
14386 anikendra 188
		livePriceCalls.push(req);
14357 anikendra 189
	};
14432 anikendra 190
	function checkForOutStocks(count){
191
		if(count>=livePriceCalls.length){
192
			$('#bestpricecontainer').html('<h4>Out of stock</h4>').removeClass('hidden');	
14969 anikendra 193
		}		
14432 anikendra 194
	};
14687 anikendra 195
	$(document).on('click','.showless',function(){
196
		$(this).addClass('hidden').siblings('.varnts').hide();
197
		$(this).parent().find('.variants',0).removeClass('hidden').addClass('justshow');
198
	});
13901 anikendra 199
	$(document).on('click','.variants',function(){
200
		$('.storeproductinfo').empty();
16219 anikendra 201
		var variants = $(this).data('variants');		
14799 anikendra 202
		var minprice = $(this).data('minprice');
14026 anikendra 203
		$('#variantscount').html(variants.length);
13901 anikendra 204
		for(var i in variants){
14849 anikendra 205
			if(minprice == variants[i].available_price) {
16013 anikendra 206
				var html = '<div class="clearfix varnts"></div><div class="col-xs-6 varnts text-small">'+variants[i].name+'</div><div class="col-xs-6 varnts viewproduct" data-source="'+variants[i].source_id+'" data-price="'+variants[i].available_price+'" data-url="'+variants[i].url+'" data-id="'+variants[i].id+'"><span class="cashbackrupee varnts text-right" ></span> <span class="storeminprice">'+variants[i].available_price+'</span><span class="cashbackamount">'+getcashbackstring(variants[i].cash_back_type,variants[i].cash_back)+'</span><span class="pull-right arrowright"></span>';			
14849 anikendra 207
			} else {
16013 anikendra 208
				var html = '<div class="clearfix varnts"></div><div class="col-xs-6 varnts text-small">'+variants[i].name+'</div><div class="col-xs-6 varnts viewproduct" data-source="'+variants[i].source_id+'" data-price="'+variants[i].available_price+'" data-url="'+variants[i].url+'" data-id="'+variants[i].id+'"><span class="cashbackrupee varnts text-right" ></span> <span>'+variants[i].available_price+'</span><span class="cashbackamount">'+getcashbackstring(variants[i].cash_back_type,variants[i].cash_back)+'</span><span class="pull-right arrowright"></span>';
16124 anikendra 209
			}
16467 anikendra 210
			if(variants[i].gross_price && variants[i].gross_price>0){
211
				html += '<p class="text-small">'+getGrossPriceText(variants[i].gross_price,variants[i].available_price)+'</p>';
212
			}	
16124 anikendra 213
			if(variants[i].offer.length>0){
214
				html += '<p class="text-small">'+variants[i].offer+'</p>';
16013 anikendra 215
			}	
16039 anikendra 216
			if(variants[i].coupon && variants[i].coupon.length>0){
16013 anikendra 217
				html += '<p class="text-small">Use Coupon <span class="red">'+variants[i].coupon+'</span></p>';
218
			}
219
			if(!variants[i].codAvailable){
16124 anikendra 220
				html += '<p class="text-small">COD not available</p>';
221
			}			
16013 anikendra 222
			html += '</div></div>';
223
			var row = $(html);			
14687 anikendra 224
			$(this).parent().parent().append(row);			
13901 anikendra 225
		}
14713 anikendra 226
		var showless = $('<div class="showless col-xs-9 text-right">Less <i class="glyphicon glyphicon-chevron-up"></i></span>');
14687 anikendra 227
		$(this).parent().parent().append(showless);
228
		$(this).addClass('hidden');
13901 anikendra 229
	});
13695 anikendra 230
	$('.categorytab').on('click','.categorytabcontrol.active',function(){
231
		$(this).toggleClass('active');
232
		$('#preferences-'+$(this).data('id')).addClass('hidden');
233
		$(this).parent().parent().children().find('.savecategorypreferences',0).removeClass('savecategorypreferences').addClass('editcategorypreferences').html('Edit').removeClass('btn-success');
234
	});
13759 anikendra 235
	$('.categorytab').on('click','.categorytabcontrol:not(.active)',function(){
236
		$(this).parent().parent().find('.btn',0).click();
237
	});
13695 anikendra 238
	$('.categorytab').on('click','.editcategorypreferences',function(e){
239
		var that = $(this);
240
		$(that).removeClass('editcategorypreferences').addClass('savecategorypreferences').html('Done').addClass('btn-success');
241
		$('#togglepreferences-'+$(that).data('id')).toggleClass('active');
242
		$('#preferences-'+$(that).data('id')).removeClass('hidden');
243
		$('.brandselector').each(function(){
244
			if($(this).data('catid')==$(that).data('id')){
245
				$(this).addClass('active');
246
			}
16066 anikendra 247
		});		
13695 anikendra 248
	});
249
	$('.categorytab').on('click','.savecategorypreferences',function(e){
250
		var that = $(this);
251
		$(that).removeClass('savecategorypreferences').addClass('editcategorypreferences').html('Edit').removeClass('btn-success');
252
		$('#togglepreferences-'+$(that).data('id')).toggleClass('active');
253
		$.ajax({
254
			url: $('#categorypreference-'+$(that).data('id')).attr('action'),
255
			data: $('#categorypreference-'+$(that).data('id')).serialize(),
256
			// Tell jQuery we're expecting JSONP
257
			dataType: "json",
258
			// Tell YQL what we want and that we want JSON			
259
			method: 'post',
260
			// Work with the response
261
			success: function( response ) {
262
				if(response.success){
263
					$('#preferences-'+$(that).data('id')).addClass('hidden');
264
				}
265
			}
266
		});
16066 anikendra 267
		active = getCookie('shopcluesActive',1);
16068 anikendra 268
		if(active && active == 'true'){
16066 anikendra 269
			$('.firsttimemsg').removeClass('hidden').show();
270
		}		
13695 anikendra 271
		ga('send', 'event', 'preferences', 'update', me);
15550 anikendra 272
		properties = pma.formDataToObject($('#categorypreference-'+$(this).data('id')).serializeArray());
273
		pma.send('preferences', 'update', 'set', me, properties);
13695 anikendra 274
	});
15767 anikendra 275
	$(document).on('click','.viewproduct',function(e){		
14386 anikendra 276
		if(typeof livePriceCalls != undefined) {
277
	    	for(var i in livePriceCalls){
278
	    		livePriceCalls[i].abort();
279
	    	}
280
	    }
13686 anikendra 281
		$('#loadingModal').modal();
14952 anikendra 282
		if($(this).data('source')==2){
283
			//in case of flipkart, close popup after 5 seconds
15311 anikendra 284
			setTimeout(function(){ $('#loadingModal').modal('hide');$('#customMessageModal').modal('hide'); }, 1000*10);			
14952 anikendra 285
		}
15159 anikendra 286
		var store = $(this).data('source');
14345 anikendra 287
		var url = apihost+"clicks/add/"+me+"/"+$(this).data('id')+'/'+$(this).data('source')+'/?url='+encodeURIComponent($(this).data('url'))+'&price='+$(this).data('price');
13579 anikendra 288
		$.ajax({
289
			url: url,
290
			// The name of the callback parameter, as specified by the YQL service
291
			jsonp: "callback",
292
			// Tell jQuery we're expecting JSONP
293
			dataType: "jsonp",
294
			// Tell YQL what we want and that we want JSON
295
			data: {
296
				format: "json"
297
			},
298
			// Work with the response
299
			success: function( response ) {
300
				if(response.success && response.type=='redirect'){
15920 anikendra 301
					if(store == 5) {
302
						//check if shopclues is active or not
303
						active = getCookie('shopcluesActive',1);
15925 anikendra 304
						if(active && active == 'true'){
16308 anikendra 305
							response.url = 'http://mobilehotindia.com/r.html?'+Base64.encode(response.url);
15920 anikendra 306
							document.location = response.url;	
307
							pma.send('apk','shopclues','active',me,null);
308
						}else{
309
							pma.send('apk','shopclues','inactive',me,null);
310
							$('#loadingModal').modal('hide');
311
							showShopcluesPopup(response.url);
312
						}
16397 anikendra 313
				  	} else if(store == 6 ) {
314
					 	//check if paytm is active or not
16455 anikendra 315
						var paytmactive = getCookie('paytmActive',1);
316
						if(paytmactive && paytmactive == 'true'){
16397 anikendra 317
							response.url = 'http://mobilehotindia.com/r.html?'+Base64.encode(response.url);
318
							document.location = response.url;	
319
							pma.send('apk','paytm','active',me,null);
320
						}else{
321
							pma.send('apk','paytm','inactive',me,null);
322
							$('#loadingModal').modal('hide');
323
							showPaytmPopup(response.url);
324
						}
325
					} else if (store == 3 || store == 2) {
15310 anikendra 326
						if (store == 2){
327
							response.url = 'http://mobilehotindia.com/r.html?'+Base64.encode(response.url);
328
						}
15188 anikendra 329
						if(response.showmessage == 1) {
330
							$('#loadingModal').modal('hide');
331
							$('#customMessage').html(response.message);
15310 anikendra 332
							$('#customMessageModal').modal('show');							
15311 anikendra 333
							setTimeout(function(){ document.location = response.url;}, 1000*3);			
15310 anikendra 334
						} else{
15206 anikendra 335
							document.location = response.url;	
15188 anikendra 336
						}
15203 anikendra 337
					} else {
15128 anikendra 338
						document.location = response.url;
339
					}										
13579 anikendra 340
				}
15310 anikendra 341
			},
342
			error: function() {
343
				document.location = url;
13579 anikendra 344
			}
345
		});
14432 anikendra 346
		ga('send', 'event', 'product', 'click', $(this).data('url'));
15550 anikendra 347
		var properties = {};
348
		properties.sku = String($(this).data('id'));
349
		properties.source = String($(this).data('source'));
350
		properties.url = encodeURIComponent($(this).data('url'));
351
		properties.price = String($(this).data('price'));
352
		pma.send('products','url','click',me,properties);
13583 anikendra 353
	});
13719 anikendra 354
	$('.jscroll-inner').on('click','.likedeal',function(e){	
13583 anikendra 355
		var that = $(this);
13682 anikendra 356
		if($(that).hasClass('active')){
13583 anikendra 357
			//User has already liked it,so remove like
358
			var url = apihost+"/user_actions/rem/"+me+"/"+$(this).data('id')+"/like";	
359
		}else{
360
			var url = apihost+"/user_actions/update/"+me+"/"+$(this).data('id')+"/like";
361
		}
362
		$.ajax({
363
			url: url,
364
			// The name of the callback parameter, as specified by the YQL service
365
			jsonp: "callback",
366
			// Tell jQuery we're expecting JSONP
367
			dataType: "jsonp",
368
			// Tell YQL what we want and that we want JSON
369
			data: {
370
				format: "json"
371
			},
372
			// Work with the response
373
			success: function( response ) {
374
				if(response.success){
13672 anikendra 375
					$(that).toggleClass('active');
376
					$(that).parent().find('li.dislikedeal',0).removeClass('active');
13583 anikendra 377
				}
378
			}
379
		});
13686 anikendra 380
		ga('send', 'event', 'product', 'like', $(this).data('id'));
15550 anikendra 381
		var properties = {};
382
		properties.sku = String($(this).data('id'));
383
		pma.send('products','favourites','like',me,properties);
13583 anikendra 384
	});
13688 anikendra 385
	$('#myModal').on('click','#unlikebtn',function(e){
13682 anikendra 386
		e.preventDefault();
387
		var url = $('#unlikeproductform').attr('action')+'?'+$('#unlikeproductform').serialize()
388
		$.ajax({
389
			url: url,
390
			// The name of the callback parameter, as specified by the YQL service
391
			jsonp: "callback",
392
			// Tell jQuery we're expecting JSONP
393
			dataType: "jsonp",
394
			// Tell YQL what we want and that we want JSON
395
			data: {
396
				format: "json"
397
			},
398
			// Work with the response
399
			success: function( response ) {
400
			}
401
		});
402
		$('#myModal').modal('hide');
13686 anikendra 403
		ga('send', 'event', 'brand', 'hide', $('#myModal').find('#productToHide',0).val());
15550 anikendra 404
		pma.send('brands','hide',$('#myModal').find('#productToHide',0).val(),me);
13682 anikendra 405
	})
13719 anikendra 406
	$('.jscroll-inner').on('click','.dislikedeal',function(e){			
13583 anikendra 407
		var that = $(this);
13682 anikendra 408
		if($(that).hasClass('active')){
13583 anikendra 409
			//User has already liked it,so remove like
410
			var url = apihost+"/user_actions/rem/"+me+"/"+$(this).data('id')+"/dislike";	
411
		}else{
13682 anikendra 412
			$('#myModal').find('#productToHide',0).val($(this).data('id'));
13583 anikendra 413
			var url = apihost+"/user_actions/update/"+me+"/"+$(this).data('id')+"/dislike";
414
		}
415
		$.ajax({
416
			url: url,
417
			// The name of the callback parameter, as specified by the YQL service
418
			jsonp: "callback",
419
			// Tell jQuery we're expecting JSONP
420
			dataType: "jsonp",
421
			// Tell YQL what we want and that we want JSON
422
			data: {
423
				format: "json"
424
			},
425
			// Work with the response
426
			success: function( response ) {
427
				if(response.success){
13672 anikendra 428
					$(that).toggleClass('active');
429
					$(that).parent().find('li.likedeal',0).removeClass('active');
13583 anikendra 430
				}
431
			}
432
		});
13686 anikendra 433
		ga('send', 'event', 'product', 'dislike', $(this).data('id'));
15550 anikendra 434
		var properties = {};
435
		properties.sku = String($(this).data('id'));
436
		pma.send('products','favourites','dislike',me,properties);
13583 anikendra 437
	});
13731 anikendra 438
	$('.deletefav').on('click',function(){
439
		var that = $(this);
440
		$('#loadingModal').modal();
441
		var url = apihost+"/user_actions/deletefav/"+me+"/"+$(this).data('id');			
442
		$.ajax({
443
			url: url,
444
			// The name of the callback parameter, as specified by the YQL service
445
			jsonp: "callback",
446
			// Tell jQuery we're expecting JSONP
447
			dataType: "jsonp",
448
			// Tell YQL what we want and that we want JSON
449
			data: {
450
				format: "json"
451
			},
452
			// Work with the response
453
			success: function( response ) {
454
				$('#loadingModal').modal('hide');
455
				if(response.success){			
456
					$('#fav-'+$(that).data('id')).hide('slow');
457
				}
458
			}
459
		});
460
		ga('send', 'event', 'favourites', 'remove', $(this).data('id'));
15550 anikendra 461
		var properties = {};
462
		properties.sku = String($(this).data('id'));
463
		pma.send('products','favourites','remove',me,properties);
13731 anikendra 464
	});
465
	$('.clearfavs').on('click',function(){
466
		var that = $(this);
467
		$('#loadingModal').modal();
14300 anikendra 468
		var url = apihost+"/user_actions/deleteallfavs/"+me+'/'+$(this).data('type');			
13731 anikendra 469
		$.ajax({
470
			url: url,
471
			// The name of the callback parameter, as specified by the YQL service
472
			jsonp: "callback",
473
			// Tell jQuery we're expecting JSONP
474
			dataType: "jsonp",
475
			// Tell YQL what we want and that we want JSON
476
			data: {
477
				format: "json"
478
			},
479
			// Work with the response
480
			success: function( response ) {
481
				$('#loadingModal').modal('hide');
482
				if(response.success){			
483
					$('.deletefav').each(function(){
484
						$('#fav-'+$(this).data('id')).hide('slow');
485
					})					
486
				}
487
				$(that).hide();
488
			}
489
		});
490
		ga('send', 'event', 'favourites', 'removeall', me);
15550 anikendra 491
		pma.send('products','favourites','removeall',me);
13731 anikendra 492
	});
13759 anikendra 493
	$('.revealbrands').on('click',function(){
494
		$(this).parent().find('.notfeatured').toggleClass('hidden');
495
		if($(this).html()=='Others'){
496
			$(this).html('Hide');
497
		}else{
498
			$(this).html('Others');
499
		}
500
	});
14068 anikendra 501
	$(document).on('click','.creditedcashbacks',function(){
502
		if($(this).find('.glyphicon-plus',0).length>0){
503
			$(this).find('.glyphicon-plus',0).removeClass('glyphicon-plus').addClass('glyphicon-minus');
504
		}else{
505
			$(this).find('.glyphicon-minus',0).removeClass('glyphicon-minus').addClass('glyphicon-plus');
506
		}
507
		$(this).next().toggleClass('hidden');
508
	});
509
	$(document).on('click','.panel-heading',function(){
510
		if($(this).find('.glyphicon-plus',0).length>0){
511
			$(this).find('.glyphicon-plus',0).removeClass('glyphicon-plus').addClass('glyphicon-minus');
512
		}else{
513
			$(this).find('.glyphicon-minus',0).removeClass('glyphicon-minus').addClass('glyphicon-plus');
514
		}
515
	});
14135 anikendra 516
	$(document).on('click','.prefcatselect',function(){
517
		$('.prefcatselect').removeClass('active')
518
		$(this).addClass('active');
519
		$('.categorypreferences').addClass('hidden');
520
		$('#cat-'+$(this).data('id')).toggleClass('hidden');
14150 anikendra 521
	});
522
	$(document).on('click','.refresh',function(){
523
		document.location.reload();
524
	});
14215 anikendra 525
	$(document).on('click','.hasmoretext',function(){
526
		$('#fulltext').html($(this).data('fulltext'));
527
		$('#fullTextModal').modal();
528
	});
14300 anikendra 529
	$(document).on('click','.favswitch',function(){
530
		$('.favswitch').removeClass('active')
531
		$(this).addClass('active');
532
		$('.clearfavs').addClass('hidden');
533
		$('.card').addClass('hidden');
534
		$('.'+$(this).data('type')).removeClass('hidden');
535
	});
14386 anikendra 536
	$(document).on('click','.brandpreferences .brands',function(){
537
		$(this).parents('.row').siblings('.controls').find('.editcategorypreferences',0).click();
538
	});
539
	$(document).on('click','.tryagainforliveprice',function(){		
540
		fetchLivePrice($(this).parent());
541
		$(this).parent().html('Getting Live Prices');
542
	});
14579 anikendra 543
	$(document).on('click','.alert > a',function(){		
544
		ga('send', 'event', 'notifications', 'click', $(this).html());
15550 anikendra 545
		pma.send('notifications','click',$(this).html(),me);
14579 anikendra 546
	});
547
	$(document).on('click','.banner',function(){		
548
		ga('send', 'event', 'banners', 'click', $(this).data('name'));
15550 anikendra 549
		pma.send('banners','click',$(this).data('name'),me);
14579 anikendra 550
	});
13992 anikendra 551
});
15310 anikendra 552
function setCookie(cname, cvalue, days, forceCookie) {
553
	if(typeof(Storage) !== "undefined" && !forceCookie) {
554
		localStorage.setItem(cname, cvalue);
555
	} else{
556
		var d = new Date();
557
	    d.setTime(d.getTime() + (days*24*60*60*1000));
558
	    var expires = "expires="+d.toUTCString();
559
	    document.cookie = cname + "=" + cvalue + "; " + expires + "; path=/";
560
	}    
14849 anikendra 561
}
562
 
15310 anikendra 563
function getCookie(cname,forceCookie) {
564
	if(typeof(Storage) !== "undefined" && !forceCookie) {
565
	    return localStorage.getItem(cname);
566
	} else {	   
567
	    var name = cname + "=";
568
	    var ca = document.cookie.split(';');
569
	    for(var i=0; i<ca.length; i++) {
570
	        var c = ca[i];
571
	        while (c.charAt(0)==' ') c = c.substring(1);
572
	        if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
573
	    }
574
	    return "";
575
	}
14849 anikendra 576
}
15310 anikendra 577
 
14849 anikendra 578
function showpopup(id,count,interval){
14851 anikendra 579
	var cname = 'notif-count-'+me+'-'+id;
15797 anikendra 580
	var cookieval = getCookie(cname,1);
14851 anikendra 581
	var cname = 'notif-lastshown-'+me+'-'+id;
15797 anikendra 582
	var lastshown = getCookie(cname,1);
15310 anikendra 583
	if(!cookieval || cookieval == 'NaN' || cookieval==''){		
15077 anikendra 584
		incrementPopupCount(id,0,'notif-count-');
585
		setLastShown(id,'notif-lastshown-');
14849 anikendra 586
		return true;
587
	} else{
588
		var d = new Date();
589
		var t = d.getTime();
590
		if(t-lastshown>interval*60*1000){
591
			if(cookieval>=count){
592
				return false;
593
			}else{
15077 anikendra 594
				setLastShown(id,'notif-lastshown-');
595
				incrementPopupCount(id,cookieval,'notif-count-');
14849 anikendra 596
				return true;	
597
			}
598
		}
599
	}
600
}
15077 anikendra 601
function setLastShown(id,cookiename){
602
	var cname = cookiename+me+'-'+id;
14849 anikendra 603
	var d = new Date();
15721 anikendra 604
	setCookie(cname, d.getTime(), 365, 1);
14849 anikendra 605
}
15077 anikendra 606
function incrementPopupCount(id,currentCount,cookiename) {
607
	var cname = cookiename+me+'-'+id;
15721 anikendra 608
	setCookie(cname, parseInt(currentCount)+1, 365, 1);
14858 anikendra 609
}
610
var hidden, visibilityChange; 
611
function handleVisibilityChange() {
612
  if (document[hidden]) {
15058 anikendra 613
  	// pagetitle = document.title;
14858 anikendra 614
  } else {
15058 anikendra 615
  	// document.title = pagetitle;
14858 anikendra 616
  }
617
}
618
if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support 
619
  hidden = "hidden";
620
  visibilityChange = "visibilitychange";
621
} else if (typeof document.mozHidden !== "undefined") {
622
  hidden = "mozHidden";
623
  visibilityChange = "mozvisibilitychange";
624
} else if (typeof document.msHidden !== "undefined") {
625
  hidden = "msHidden";
626
  visibilityChange = "msvisibilitychange";
627
} else if (typeof document.webkitHidden !== "undefined") {
628
  hidden = "webkitHidden";
629
  visibilityChange = "webkitvisibilitychange";
630
}
631
if (typeof document.addEventListener === "undefined" || 
632
  typeof document[hidden] === "undefined") {
15077 anikendra 633
  console.log("This feature requires a browser, such as Google Chrome or Firefox, that supports the Page Visibility API.");
14858 anikendra 634
} else {
635
  // Handle page visibility change   
636
  document.addEventListener(visibilityChange, handleVisibilityChange, false);
637
}    
14936 anikendra 638
$('.notificationok').on('click',function(e){
14932 anikendra 639
	e.preventDefault();
14931 anikendra 640
	$('.notificationmodal').modal('hide');
15159 anikendra 641
	// setTimeout(function(){ $('.notificationmodal').modal('hide'); }, 1000);
16133 anikendra 642
	ga('send', 'event', 'popupnotification-'+$(this).parent().data('id'), 'ok', me);
643
	var properties = {};
644
	properties.id = String($(this).parent().data('id'));
645
	pma.send('popupnotification','click','ok',me,properties);
14932 anikendra 646
	document.location = $(this).parent().prop('href');
15015 anikendra 647
});
648
$(document).on('click','.clearfilter',function(){	
649
	$('.filterbrand').each(function(){
650
		$(this).prop('checked',false);
651
	});	
15550 anikendra 652
	ga('send', 'event', 'filter', 'brand', 'reset');
653
	pma.send('filters','brands','reset',me);
15015 anikendra 654
});
655
$(document).on('click','.applyfilter',function(){	
15584 anikendra 656
	$(this).prop('disabled',true);
657
	$('#loadingModal').modal();
15015 anikendra 658
	var brands = [];
15026 anikendra 659
	var brandnames = [];
15015 anikendra 660
	$('.filterbrand').each(function(){
661
		if($(this).prop('checked')){
662
			brands.push($(this).val());
15026 anikendra 663
			brandnames.push($(this).parent().siblings('.brandname').html());
15015 anikendra 664
		}		
665
	});
666
	if(brands.length==0){
15721 anikendra 667
		$('#loadingModal').modal('hide');
15015 anikendra 668
		$('#message').html('Please choose a few brands first').removeClass('hidden');
669
		setTimeout(function(){ $('#message').addClass('hidden'); }, 3000);
15722 anikendra 670
		$(this).prop('disabled',false);
15015 anikendra 671
		return false;
672
	}else{
16240 anikendra 673
		setCookie('brandschosen', brands, 0.25, true);
15015 anikendra 674
		var url = $('#brandselecter').prop('action');
15026 anikendra 675
		ga('send', 'event', 'filter', 'brand', brandnames.join('|'));
15550 anikendra 676
		properties = {};
677
		for(var i in brandnames){
678
			properties['brand_'+i] = brandnames[i];
679
		}
680
		pma.send('filters','brands','addfilter',me,properties);
15085 anikendra 681
		var postdata = {'user_id':me,'type':'brand','filters':brandnames.join('|')};
682
		$.post( "/user_filters/add", postdata, function( data ) {
15584 anikendra 683
			$('#loadingModal').modal('hide');
15722 anikendra 684
			$(this).prop('disabled',false);
15584 anikendra 685
	  		document.location = url+'&brands='+brands.join('^');
15085 anikendra 686
		});		
15015 anikendra 687
	}	
688
});
689
$(document).on('click','#showallbrands',function(){	
690
	$('.hidden').removeClass('hidden');
691
	$(this).hide();
15019 anikendra 692
});
693
$(document).on('input','#brandfilter',function(){	
694
	$('.brand').addClass('hidden');
695
	$('#showallbrands').hide();
696
	var that = $(this);
697
	$('li.brand').filter(function() { 
698
	  return $(this).data("brand").toLowerCase().indexOf($(that).val().toLowerCase()) != -1;
699
	}).removeClass('hidden','slow');
15042 anikendra 700
});
15077 anikendra 701
$(document).on('click','.filterbrand',function(){
702
	var clicked = $(this).parent().parent();
15042 anikendra 703
	// all the LIs above the clicked one
704
	var previousAll = clicked.prevAll();
705
 
706
	// only proceed if it's not already on top (no previous siblings)
707
	if(previousAll.length > 0) {
708
	// top LI
709
	var top = $(previousAll[previousAll.length - 1]);
710
 
711
	// immediately previous LI
712
	var previous = $(previousAll[0]);
713
 
714
	// how far up do we need to move the clicked LI?
715
	var moveUp = clicked.attr('offsetTop') - top.attr('offsetTop');
716
 
717
	// how far down do we need to move the previous siblings?
718
	var moveDown = (clicked.offset().top + clicked.outerHeight()) - (previous.offset().top + previous.outerHeight());
719
 
720
	// let's move stuff
721
	clicked.css('position', 'relative');
722
	previousAll.css('position', 'relative');
723
	clicked.animate({'top': -moveUp});
724
	previousAll.animate({'top': moveDown}, {complete: function() {
725
	  // rearrange the DOM and restore positioning when we're done moving
726
	  clicked.parent().prepend(clicked);
727
	  clicked.css({'position': 'static', 'top': 0});
728
	  previousAll.css({'position': 'static', 'top': 0}); 
729
	}});
730
	}
731
})
732
$(document).on('click','.clearfilters',function(){
15310 anikendra 733
	setCookie('brandschosen', '', -1, true);
15058 anikendra 734
	ga('send', 'event', 'filter', 'brand', 'clearfilters');
15550 anikendra 735
	pma.send('filters','brands','clearfilters',me);
15085 anikendra 736
	var postdata = {'user_id':me,'type':'clear'};
16240 anikendra 737
	$('#loadingModal').modal('show');
738
	$.post("/user_filters/add", postdata, function( data ) {		
739
	  	document.location.reload();
15085 anikendra 740
	});	
15042 anikendra 741
});
742
function selectChosenBrands(){
16261 anikendra 743
	var brandschosen = decodeURIComponent(getCookie('brandschosen',true));
15042 anikendra 744
	if(brandschosen && brandschosen.length>0){
745
		var brands = brandschosen.split(',');
746
		for(var i in brands){
747
			$('.brand').filter(function() { 
748
			  	return $(this).data("brandid") == brands[i];
15077 anikendra 749
			}).removeClass('hidden').find('.filterbrand',0).trigger( "click" );
15042 anikendra 750
		}
751
	}
15065 anikendra 752
}
15585 anikendra 753
function showPosition(position) {
15586 anikendra 754
    setCookie('latitude',position.coords.latitude,1,true); 
755
    setCookie('longitude',position.coords.longitude,1,true);	
15585 anikendra 756
}
15065 anikendra 757
$(function () {
15077 anikendra 758
	var poid = 'popovertrigger';
15310 anikendra 759
	var cname = 'popover-count-'+me+'-'+poid;
15721 anikendra 760
	var cookieval = getCookie(cname,1);
15310 anikendra 761
	$('#dropdownMenu1').on('click',function(){
762
		var cname = 'popover-count-'+me+'-'+poid;
15721 anikendra 763
		var cookieval = getCookie(cname,1);
15310 anikendra 764
		$('#popovertrigger').popover('hide');
765
		if(!cookieval || cookieval == 'NaN' || cookieval == ''){
766
			incrementPopupCount(poid,0,'popover-count-');
15526 anikendra 767
		} else if(cookieval > 0) {
15310 anikendra 768
			incrementPopupCount(poid, cookieval, 'popover-count-');
769
		}
770
		setLastShown(poid,'popover-lastshown-');
771
	})
772
 
15077 anikendra 773
	var cname = 'popover-lastshown-'+me+'-'+poid;
15721 anikendra 774
	var lastshown = getCookie(cname,1);
15310 anikendra 775
	if(cookieval=='' || cookieval == 'NaN' || !cookieval){				
15077 anikendra 776
		showpopover(poid);
15521 anikendra 777
	} 
778
	//Donot show popover anymore as long as we don't find a suitable solution
15721 anikendra 779
	else{
15077 anikendra 780
		var d = new Date();
781
		var t = d.getTime();
15085 anikendra 782
		if(t-lastshown>18*3600*1000){
15310 anikendra 783
			if(cookieval>=2){
15077 anikendra 784
				return false;
785
			}else{
15310 anikendra 786
				showpopover(poid);				
15077 anikendra 787
			}
788
		}
15721 anikendra 789
	}
15583 anikendra 790
	ga('send', 'event', 'popover', me, cookieval);
15585 anikendra 791
	if (navigator.geolocation) {
792
        navigator.geolocation.getCurrentPosition(showPosition);
793
    } 
15077 anikendra 794
});
795
function showpopover(id){
796
	$('[data-toggle="popover"]#'+id).popover({'html':true});
797
	$('[data-toggle="popover"]#'+id).trigger('click');		
15085 anikendra 798
}
799
$(document).on('click','.nodeals',function(){
800
	document.location = $(this).data('href');
16018 anikendra 801
});
802
$(document).on('click','.selectbrand',function(e){
803
	e.preventDefault();
804
	var brands = $(this).data('id');
805
	var brandname = $(this).html();
806
	console.log(brandname);
807
	setCookie('brandschosen', brands, 1, true);
808
	var url = $(this).data('href');
809
	ga('send', 'event', 'selectbrand', 'brand', brandname);
810
	properties = {};
811
	properties['brand'] = brandname;
812
	pma.send('filters','brands','selectbrand',me,properties);
813
	var postdata = {'user_id':me,'type':'brand','filters':brandname};
814
	$.post( "/user_filters/add", postdata, function( data ) {
815
		$('#loadingModal').modal('hide');
816
		$(this).addClass('activebrand');
817
  		document.location = url+'&brands='+brands;
818
	});
819
});
15128 anikendra 820
var Base64 = {
821
    _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
822
    encode: function(input) {
823
        var output = "";
824
        var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
825
        var i = 0;
826
        input = Base64._utf8_encode(input);
827
        while (i < input.length) {
828
            chr1 = input.charCodeAt(i++);
829
            chr2 = input.charCodeAt(i++);
830
            chr3 = input.charCodeAt(i++);
831
 
832
            enc1 = chr1 >> 2;
833
            enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
834
            enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
835
            enc4 = chr3 & 63;
836
            if (isNaN(chr2)) {
837
                enc3 = enc4 = 64;
838
            } else if (isNaN(chr3)) {
839
                enc4 = 64;
840
            }
841
            output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
842
        }
843
        return output;
844
    },
845
 
846
 
847
    decode: function(input) {
848
        var output = "";
849
        var chr1, chr2, chr3;
850
        var enc1, enc2, enc3, enc4;
851
        var i = 0;
852
        input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
853
        while (i < input.length) {
854
            enc1 = this._keyStr.indexOf(input.charAt(i++));
855
            enc2 = this._keyStr.indexOf(input.charAt(i++));
856
            enc3 = this._keyStr.indexOf(input.charAt(i++));
857
            enc4 = this._keyStr.indexOf(input.charAt(i++));
858
            chr1 = (enc1 << 2) | (enc2 >> 4);
859
            chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
860
            chr3 = ((enc3 & 3) << 6) | enc4;
861
            output = output + String.fromCharCode(chr1);
862
            if (enc3 != 64) {
863
                output = output + String.fromCharCode(chr2);
864
            }
865
            if (enc4 != 64) {
866
                output = output + String.fromCharCode(chr3);
867
            }
868
        }
869
        output = Base64._utf8_decode(output);
870
        return output;
871
    },
872
 
873
    _utf8_encode: function(string) {
874
        string = string.replace(/\r\n/g, "\n");
875
        var utftext = "";
876
        for (var n = 0; n < string.length; n++) {
877
            var c = string.charCodeAt(n);
878
            if (c < 128) {
879
                utftext += String.fromCharCode(c);
880
            }
881
            else if ((c > 127) && (c < 2048)) {
882
                utftext += String.fromCharCode((c >> 6) | 192);
883
                utftext += String.fromCharCode((c & 63) | 128);
884
            }
885
            else {
886
                utftext += String.fromCharCode((c >> 12) | 224);
887
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
888
                utftext += String.fromCharCode((c & 63) | 128);
889
            }
890
        }
891
        return utftext;
892
    },
893
 
894
    _utf8_decode: function(utftext) {
895
        var string = "";
896
        var i = 0;
897
        var c = c1 = c2 = 0;
898
        while (i < utftext.length) {
899
            c = utftext.charCodeAt(i);
900
            if (c < 128) {
901
                string += String.fromCharCode(c);
902
                i++;
903
            }
904
            else if ((c > 191) && (c < 224)) {
905
                c2 = utftext.charCodeAt(i + 1);
906
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
907
                i += 2;
908
            }
909
            else {
910
                c2 = utftext.charCodeAt(i + 1);
911
                c3 = utftext.charCodeAt(i + 2);
912
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
913
                i += 3;
914
            }
915
        }
916
        return string;
917
    }
15550 anikendra 918
}
919
 
920
 
921
var pma = new function() {
15584 anikendra 922
    this.apiurl = "http://45.33.50.227:8081/";
15550 anikendra 923
    this.endpoints = {'identify':'identify','profile':'profile','track':'track'};
924
 
925
    this.send = function (category,action,label,user_id,properties) {
15585 anikendra 926
    	if(!properties){
927
    		properties = {};
928
    	}
929
    	properties.location = window.location.href;
930
    	// properties.appCodeName = navigator.appCodeName;
931
    	// properties.appName = navigator.appName;
932
    	// properties.appVersion = navigator.appVersion;
933
    	properties.cookieEnabled = String(navigator.cookieEnabled);
934
    	properties.platform = navigator.platform;
935
    	properties.userAgent = navigator.userAgent;
936
    	properties.ip = ip;
937
	  	if (navigator.geolocation) {
15586 anikendra 938
	  		if(getCookie('latitude',true)){
939
	  			properties.latitude = getCookie('latitude');
940
	  		}	  		
941
	  		if(getCookie('longitude',true)){
942
		  		properties.longitude = getCookie('longitude');
943
		  	}
15585 anikendra 944
	  	}
945
	  	properties.screenHeight = String(screen.height);
946
	  	properties.screenWidth = String(screen.width);
947
    	// console.log(properties);
15550 anikendra 948
 		$.ajax({
949
			url: this.apiurl + this.endpoints.track,
950
			data: {'category':category,'action':action,'label':label,'user_id':user_id,'properties':cassandraMAP.stringify(properties)},
951
			// Tell jQuery we're expecting JSONP
952
			dataType: "json",
953
			// Tell YQL what we want and that we want JSON			
954
			method: 'post',
955
			// Work with the response
956
			success: function( response ) {
957
				//Well, well, well :)
958
			}
959
		});       
960
    };
961
 
962
    this.formDataToObject = function(formdata){
963
    	var properties = {};
964
    	var keys = [];
965
		var formdata = JSON.parse(JSON.stringify(formdata));
966
		for (var i in formdata) {
967
			var key = formdata[i].name;
968
			if(index = keys.indexOf(key)==-1){
969
				properties[key] = formdata[i].value;
970
			}else{
971
				properties[key+'_'+i] = formdata[i].value;
972
			}
973
			keys.push(key);
974
		};
975
		return properties;
976
	}
15128 anikendra 977
}