Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
1950 rajveer 1
function hideSlides(){
2
	  $('.comparision-hide').each(function(){
3
		    this.style.display = 'none';
4
	  });
5
	  var styleTrack = $('.jspTrack').attr('style');
6
	  $('.jspTrackbottom').attr('style', styleTrack);
7
	  var styleDrag = $('.jspDrag').attr('style');
8
	  $('.jspDragbottom').attr('style', styleDrag);
9
}
10
 
1819 rajveer 11
function renderComparison(){
1807 rajveer 12
  var SelectID;
13
  var subtract;
14
  var check = 0;
15
  var count = $('.comparision-product-column').length;
16
  if(count < 4) {
17
    if(count == 3) {
18
      subtract = 6;
19
    } else if(count == 2) {
20
      subtract = 3;
21
    } else {
22
      subtract = 0;
23
    }
24
    var parentWidth = $('#comparision-right').width();
25
    var width = (parentWidth - subtract)/count;
26
    var newWidth = parseInt(width);
27
    $('.product-name').width(newWidth);
28
    $('.comparision-product-column').width(newWidth);
29
  }
1950 rajveer 30
 
31
  $('.ui-state-default').click(function(){
32
    var aID = $("li.ui-state-active").children('a:first').attr('href');
33
    var array = aID.split("#");
34
    var displayID = array[1];
35
    var new_aID = $(this).children('a:first').attr('href');
36
    var new_array = new_aID.split("#");
37
    var new_displayID = new_array[1];
38
    $('.'+displayID).each(function(){
39
      this.style.display = 'none';
40
      $(this).removeClass("comparision-block").addClass('comparision-hide');
41
    });
42
    if(new_displayID == 'vtab-summary') {
43
      $('#comparision-right').removeClass("product-comparision-internal").addClass('product-comparision-home');
44
      $('.scroller-columns').hide();
45
      $('#comparision-summary-content').show();
46
      $('.comparision-page-title').hide();
47
    } else {
48
      $('#comparision-right').removeClass("product-comparision-home").addClass('product-comparision-internal');
49
      $('.scroller-columns').show();
50
      $('#comparision-summary-content').hide();
51
      $('.comparision-page-title').show();
52
    }
53
    $('.comparision-page-title').html(this.title);
54
    $('.ui-state-active').removeClass("ui-tabs-selected ui-state-active");
55
    $(this).addClass("ui-tabs-selected ui-state-active");
56
    $('.'+new_displayID).each(function() {
57
      var new_count = $('.'+new_displayID).length;
58
      if(new_count !== count) {
59
        $('.comparision-product-column').each(function(){
60
          var check_childern = $(this).find('.'+new_displayID).html();
61
          if(check_childern == null && check == 0) {
62
            $(this).append("<div class='"+new_displayID+" comparision-hide comparision-empty-column'><div class='featureslisting'><ul><li class='mainFeature'>No features listed for this category.</li></ul></div></div>");
63
            check = 1;
64
          }
65
        });
66
      }
67
      $(this).removeClass("comparision-hide").addClass('comparision-block');
68
      check = 0;
69
      this.style.display = 'block';
70
    });
71
    return false;
72
  });
73
 
74
  var count_item_rows =  $('.summarypage-row').length;
75
  var total_column = $('.column-score-total').length;
76
  //alert($('.column-score-total').length);
77
  //alert($('.summary-dropdown').length);
78
  //alert($('.product-1').length);
79
  var cols_row = count_item_rows - total_column;
80
  $(".summary-dropdown").change(function(){
81
    var product_values = '';
82
    var item_Value = this.value;
83
    var item_data = Array();
84
    var importance_data = Array();
85
    var column_count = $('.summary-column').length;
86
 
87
    SelectID = this.id;
88
 
89
 
90
    //var selected = $("#colorselector option:selected");
91
	//var itemid = selected.val();
92
 
93
 
94
    for(i = 0; i < total_column; i++){
95
    	item_data[i] = Array();
96
      var Scores = '';
97
      var k = i + 1;
98
      var j = 0;
99
      $('.product-'+k).each(function(){
100
        var items_html = $(this).html();
101
        if(items_html !== null) {
102
          Scores += items_html+'::';
103
        }
104
        item_data[i][j] = parseFloat(items_html);
105
        j++;
106
      });
107
      //item_data[i] = Scores;
108
      //alert(item_data[i]);
109
      //product_values += item_data[i].split(',')+'---';
110
    }
111
    //alert(item_data);
112
    //var items = 'itemvalue='+item_Value+'&column='+column_count+'&data='+product_values;
113
    var items_total = 'itemvalue='+item_Value+'&column='+column_count+'&total='+total_column+'&data='+product_values;
114
//alert(items_total);
115
var i = 0;
116
$('.summary-dropdown').each(function(){
117
    importance_data[i] = parseInt($(this).val());
118
    i++;
119
  });
120
//alert(importance_data);
121
var item = "";
122
for(i = 0; i < total_column; i++){
123
	//alert(item_data[i]);
124
	//alert(importance_data);
125
 
1977 rajveer 126
    var commulative_weighted_score = 0.0;
127
    var commulative_weights = 0.0;
128
 
129
 
1950 rajveer 130
    for (var j = 0; j < importance_data.length; j++){ 
131
        if(importance_data[j] == 1){
1977 rajveer 132
        	commulative_weighted_score += item_data[i][j]*55;
133
        	commulative_weights += 55;
1950 rajveer 134
        }
135
        if(importance_data[j] == 2){
1977 rajveer 136
        	commulative_weighted_score += item_data[i][j]*30;
137
        	commulative_weights += 30;        
1950 rajveer 138
        }
139
		if(importance_data[j] == 3){
1977 rajveer 140
        	commulative_weighted_score += item_data[i][j]*15;
141
        	commulative_weights += 15;
142
        }
1950 rajveer 143
		//alert(very_important_slides_score + "  " + very_important_slides_count);
144
		//alert(not_so_important_slides_score + " " + not_so_important_slides_count);
145
		//alert(regular_slides_score + " " + regular_slides_count);
146
     } 
1977 rajveer 147
    var weighted_score = commulative_weighted_score/commulative_weights;
1950 rajveer 148
    //alert("weighted score is " + weighted_score);
149
    weighted_score = Math.round(weighted_score*Math.pow(10,1))/Math.pow(10,1);
150
 
1977 rajveer 151
    item += weighted_score + ' / 10::';
1950 rajveer 152
    //alert(item);
153
}
154
//item = '9.8/10::9.8/10';
155
 
156
    /*$.ajax({
157
      type: "POST",
158
      url: "test.php",
159
      data: items,
160
      success: function(item){
161
        var items_break = item.split('::');
162
        for(i = 0; i < items_break.length; i++){
163
          var incre = i+1;
164
          var class_name = '.features-color-'+incre;
165
          $('#'+SelectID).parent().parent().parent().find(class_name).html(items_break[i]);
166
        }
167
      }
168
    });*/
169
/*
170
  $.ajax({
171
      type: "POST",
172
      url: "test.php",
173
      data: items_total,
174
      success: function(item){
175
        var items_break = '';
176
        items_break = item.split('::');
177
        for(i = 0; i < items_break.length; i++){
178
          var incre = i+1;
179
          var class_name = '.score-total-'+incre;
180
          $(class_name).html(items_break[i]);
181
        }
182
      }
183
    });
184
  });
185
  $('.scroller-columns').hide();
186
  $('.comparision-page-title').hide();
187
*/
188
  //item = '9.8/10::9.8/10::';
189
  var items_break = '';
190
  items_break = item.split('::');
191
  for(i = 0; i < items_break.length; i++){
192
    var incre = i+1;
193
    var class_name = '.score-total-'+incre;
194
    $(class_name).html(items_break[i]);
195
 
196
  }
197
  });
198
  $('.scroller-columns').hide();
199
  $('.comparision-page-title').hide();
200
 
201
}
202
 
203
 
204
 
205
/*
206
 
207
 function renderComparison(){
208
  var SelectID;
209
  var subtract;
210
  var check = 0;
211
  var count = $('.comparision-product-column').length;
212
  if(count < 4) {
213
    if(count == 3) {
214
      subtract = 6;
215
    } else if(count == 2) {
216
      subtract = 3;
217
    } else {
218
      subtract = 0;
219
    }
220
    var parentWidth = $('#comparision-right').width();
221
    var width = (parentWidth - subtract)/count;
222
    var newWidth = parseInt(width);
223
    $('.product-name').width(newWidth);
224
    $('.comparision-product-column').width(newWidth);
225
  }
1807 rajveer 226
  var styleTrack = $('.jspTrack').attr('style');
227
  $('.jspTrackbottom').attr('style', styleTrack);
228
  var styleDrag = $('.jspDrag').attr('style');
229
  $('.jspDragbottom').attr('style', styleDrag);
230
  $('.ui-state-default').click(function(){
231
    var aID = $("li.ui-state-active").children('a:first').attr('href');
232
    var array = aID.split("#");
233
    var displayID = array[1];
234
    var new_aID = $(this).children('a:first').attr('href');
235
    var new_array = new_aID.split("#");
236
    var new_displayID = new_array[1];
237
    $('.'+displayID).each(function(){
238
      this.style.display = 'none';
239
      $(this).removeClass("comparision-block").addClass('comparision-hide');
240
    });
1950 rajveer 241
    if(new_displayID == 'vtab-summary') {
242
      $('#comparision-right').removeClass("product-comparision-internal").addClass('product-comparision-home');
243
      $('.scroller-columns').hide();
244
      $('#comparision-summary-content').show();
245
      $('.comparision-page-title').hide();
1807 rajveer 246
    } else {
1950 rajveer 247
      $('#comparision-right').removeClass("product-comparision-home").addClass('product-comparision-internal');
248
      $('.scroller-columns').show();
249
      $('#comparision-summary-content').hide();
250
      $('.comparision-page-title').show();
1807 rajveer 251
    }
252
    $('.comparision-page-title').html(this.title);
253
    $('.ui-state-active').removeClass("ui-tabs-selected ui-state-active");
254
    $(this).addClass("ui-tabs-selected ui-state-active");
255
    $('.'+new_displayID).each(function() {
256
      var new_count = $('.'+new_displayID).length;
257
      if(new_count !== count) {
258
        $('.comparision-product-column').each(function(){
259
          var check_childern = $(this).find('.'+new_displayID).html();
260
          if(check_childern == null && check == 0) {
1818 rajveer 261
            $(this).append("<div class='"+new_displayID+" comparision-hide comparision-empty-column'><div class='featureslisting'><ul><li class='mainFeature'>No features listed for this category.</li></ul></div></div>");
1807 rajveer 262
            check = 1;
263
          }
264
        });
265
      }
266
      $(this).removeClass("comparision-hide").addClass('comparision-block');
1818 rajveer 267
      check = 0;
1807 rajveer 268
      this.style.display = 'block';
269
    });
270
    return false;
271
  });
272
  $('.comparision-hide').each(function(){
273
    this.style.display = 'none';
274
  });
1950 rajveer 275
  var count_item_rows =  $('.summarypage-row').length;
276
  var total_column = $('.column-score-total').length;
277
  //alert($('.column-score-total').length);
278
  //alert($('.summary-dropdown').length);
279
  //alert($('.product-1').length);
280
  var cols_row = count_item_rows - total_column;
281
  $(".summary-dropdown").change(function(){
282
    var product_values = '';
283
    var item_Value = this.value;
284
    var item_data = Array();
285
    var importance_data = Array();
286
    var column_count = $('.summary-column').length;
287
 
288
    SelectID = this.id;
289
 
290
 
291
    //var selected = $("#colorselector option:selected");
292
	//var itemid = selected.val();
293
 
294
 
295
    for(i = 0; i < total_column; i++){
296
    	item_data[i] = Array();
297
      var Scores = '';
298
      var k = i + 1;
299
      var j = 0;
300
      $('.product-'+k).each(function(){
301
        var items_html = $(this).html();
302
        if(items_html !== null) {
303
          Scores += items_html+'::';
304
        }
305
        item_data[i][j] = parseFloat(items_html);
306
        j++;
307
      });
308
      //item_data[i] = Scores;
309
      //alert(item_data[i]);
310
      //product_values += item_data[i].split(',')+'---';
311
    }
312
    //alert(item_data);
313
    //var items = 'itemvalue='+item_Value+'&column='+column_count+'&data='+product_values;
314
    var items_total = 'itemvalue='+item_Value+'&column='+column_count+'&total='+total_column+'&data='+product_values;
315
//alert(items_total);
316
var i = 0;
317
$('.summary-dropdown').each(function(){
318
    importance_data[i] = parseInt($(this).val());
319
    i++;
320
  });
321
//alert(importance_data);
322
var item = "";
323
for(i = 0; i < total_column; i++){
324
	//alert(item_data[i]);
325
	//alert(importance_data);
326
 
327
    var very_important_slides_score = 0.0;
328
    var regular_slides_score = 0.0;
329
    var not_so_important_slides_score = 0.0;
330
    var very_important_slides_count = 0;
331
    var regular_slides_count = 0;
332
    var not_so_important_slides_count = 0;
333
 
334
    for (var j = 0; j < importance_data.length; j++){ 
335
        if(importance_data[j] == 1){
336
        	very_important_slides_score += item_data[i][j];
337
        	very_important_slides_count += 1;
338
        }
339
        if(importance_data[j] == 2){
340
        	regular_slides_score += item_data[i][j];
341
        	regular_slides_count += 1;        	
342
        }
343
		if(importance_data[j] == 3){
344
        	not_so_important_slides_score += item_data[i][j];
345
        	not_so_important_slides_count += 1;
346
		}
347
		//alert(very_important_slides_score + "  " + very_important_slides_count);
348
		//alert(not_so_important_slides_score + " " + not_so_important_slides_count);
349
		//alert(regular_slides_score + " " + regular_slides_count);
350
     } 
351
    var weighted_score = (55*very_important_slides_score/very_important_slides_count + 30*regular_slides_score/regular_slides_count + 15*not_so_important_slides_score/not_so_important_slides_count)/100;
352
    //alert("weighted score is " + weighted_score);
353
    weighted_score = Math.round(weighted_score*Math.pow(10,1))/Math.pow(10,1);
354
 
355
    item += weighted_score + '/10::';
356
    //alert(item);
1807 rajveer 357
}
1950 rajveer 358
//item = '9.8/10::9.8/10';
359
 
360
 
361
  //item = '9.8/10::9.8/10::';
362
  var items_break = '';
363
  items_break = item.split('::');
364
  for(i = 0; i < items_break.length; i++){
365
    var incre = i+1;
366
    var class_name = '.score-total-'+incre;
367
    $(class_name).html(items_break[i]);
368
 
369
  }
370
  });
371
  $('.scroller-columns').hide();
372
  $('.comparision-page-title').hide();
373
 
374
}
375
*/