Subversion Repositories SmartDukaan

Rev

Rev 1819 | Rev 1977 | 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
 
126
    var very_important_slides_score = 0.0;
127
    var regular_slides_score = 0.0;
128
    var not_so_important_slides_score = 0.0;
129
    var very_important_slides_count = 0;
130
    var regular_slides_count = 0;
131
    var not_so_important_slides_count = 0;
132
 
133
    for (var j = 0; j < importance_data.length; j++){ 
134
        if(importance_data[j] == 1){
135
        	very_important_slides_score += item_data[i][j];
136
        	very_important_slides_count += 1;
137
        }
138
        if(importance_data[j] == 2){
139
        	regular_slides_score += item_data[i][j];
140
        	regular_slides_count += 1;        	
141
        }
142
		if(importance_data[j] == 3){
143
        	not_so_important_slides_score += item_data[i][j];
144
        	not_so_important_slides_count += 1;
145
		}
146
		//alert(very_important_slides_score + "  " + very_important_slides_count);
147
		//alert(not_so_important_slides_score + " " + not_so_important_slides_count);
148
		//alert(regular_slides_score + " " + regular_slides_count);
149
     } 
150
    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;
151
    //alert("weighted score is " + weighted_score);
152
    weighted_score = Math.round(weighted_score*Math.pow(10,1))/Math.pow(10,1);
153
 
154
    item += weighted_score + '/10::';
155
    //alert(item);
156
}
157
//item = '9.8/10::9.8/10';
158
 
159
    /*$.ajax({
160
      type: "POST",
161
      url: "test.php",
162
      data: items,
163
      success: function(item){
164
        var items_break = item.split('::');
165
        for(i = 0; i < items_break.length; i++){
166
          var incre = i+1;
167
          var class_name = '.features-color-'+incre;
168
          $('#'+SelectID).parent().parent().parent().find(class_name).html(items_break[i]);
169
        }
170
      }
171
    });*/
172
/*
173
  $.ajax({
174
      type: "POST",
175
      url: "test.php",
176
      data: items_total,
177
      success: function(item){
178
        var items_break = '';
179
        items_break = item.split('::');
180
        for(i = 0; i < items_break.length; i++){
181
          var incre = i+1;
182
          var class_name = '.score-total-'+incre;
183
          $(class_name).html(items_break[i]);
184
        }
185
      }
186
    });
187
  });
188
  $('.scroller-columns').hide();
189
  $('.comparision-page-title').hide();
190
*/
191
  //item = '9.8/10::9.8/10::';
192
  var items_break = '';
193
  items_break = item.split('::');
194
  for(i = 0; i < items_break.length; i++){
195
    var incre = i+1;
196
    var class_name = '.score-total-'+incre;
197
    $(class_name).html(items_break[i]);
198
 
199
  }
200
  });
201
  $('.scroller-columns').hide();
202
  $('.comparision-page-title').hide();
203
 
204
}
205
 
206
 
207
 
208
/*
209
 
210
 function renderComparison(){
211
  var SelectID;
212
  var subtract;
213
  var check = 0;
214
  var count = $('.comparision-product-column').length;
215
  if(count < 4) {
216
    if(count == 3) {
217
      subtract = 6;
218
    } else if(count == 2) {
219
      subtract = 3;
220
    } else {
221
      subtract = 0;
222
    }
223
    var parentWidth = $('#comparision-right').width();
224
    var width = (parentWidth - subtract)/count;
225
    var newWidth = parseInt(width);
226
    $('.product-name').width(newWidth);
227
    $('.comparision-product-column').width(newWidth);
228
  }
1807 rajveer 229
  var styleTrack = $('.jspTrack').attr('style');
230
  $('.jspTrackbottom').attr('style', styleTrack);
231
  var styleDrag = $('.jspDrag').attr('style');
232
  $('.jspDragbottom').attr('style', styleDrag);
233
  $('.ui-state-default').click(function(){
234
    var aID = $("li.ui-state-active").children('a:first').attr('href');
235
    var array = aID.split("#");
236
    var displayID = array[1];
237
    var new_aID = $(this).children('a:first').attr('href');
238
    var new_array = new_aID.split("#");
239
    var new_displayID = new_array[1];
240
    $('.'+displayID).each(function(){
241
      this.style.display = 'none';
242
      $(this).removeClass("comparision-block").addClass('comparision-hide');
243
    });
1950 rajveer 244
    if(new_displayID == 'vtab-summary') {
245
      $('#comparision-right').removeClass("product-comparision-internal").addClass('product-comparision-home');
246
      $('.scroller-columns').hide();
247
      $('#comparision-summary-content').show();
248
      $('.comparision-page-title').hide();
1807 rajveer 249
    } else {
1950 rajveer 250
      $('#comparision-right').removeClass("product-comparision-home").addClass('product-comparision-internal');
251
      $('.scroller-columns').show();
252
      $('#comparision-summary-content').hide();
253
      $('.comparision-page-title').show();
1807 rajveer 254
    }
255
    $('.comparision-page-title').html(this.title);
256
    $('.ui-state-active').removeClass("ui-tabs-selected ui-state-active");
257
    $(this).addClass("ui-tabs-selected ui-state-active");
258
    $('.'+new_displayID).each(function() {
259
      var new_count = $('.'+new_displayID).length;
260
      if(new_count !== count) {
261
        $('.comparision-product-column').each(function(){
262
          var check_childern = $(this).find('.'+new_displayID).html();
263
          if(check_childern == null && check == 0) {
1818 rajveer 264
            $(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 265
            check = 1;
266
          }
267
        });
268
      }
269
      $(this).removeClass("comparision-hide").addClass('comparision-block');
1818 rajveer 270
      check = 0;
1807 rajveer 271
      this.style.display = 'block';
272
    });
273
    return false;
274
  });
275
  $('.comparision-hide').each(function(){
276
    this.style.display = 'none';
277
  });
1950 rajveer 278
  var count_item_rows =  $('.summarypage-row').length;
279
  var total_column = $('.column-score-total').length;
280
  //alert($('.column-score-total').length);
281
  //alert($('.summary-dropdown').length);
282
  //alert($('.product-1').length);
283
  var cols_row = count_item_rows - total_column;
284
  $(".summary-dropdown").change(function(){
285
    var product_values = '';
286
    var item_Value = this.value;
287
    var item_data = Array();
288
    var importance_data = Array();
289
    var column_count = $('.summary-column').length;
290
 
291
    SelectID = this.id;
292
 
293
 
294
    //var selected = $("#colorselector option:selected");
295
	//var itemid = selected.val();
296
 
297
 
298
    for(i = 0; i < total_column; i++){
299
    	item_data[i] = Array();
300
      var Scores = '';
301
      var k = i + 1;
302
      var j = 0;
303
      $('.product-'+k).each(function(){
304
        var items_html = $(this).html();
305
        if(items_html !== null) {
306
          Scores += items_html+'::';
307
        }
308
        item_data[i][j] = parseFloat(items_html);
309
        j++;
310
      });
311
      //item_data[i] = Scores;
312
      //alert(item_data[i]);
313
      //product_values += item_data[i].split(',')+'---';
314
    }
315
    //alert(item_data);
316
    //var items = 'itemvalue='+item_Value+'&column='+column_count+'&data='+product_values;
317
    var items_total = 'itemvalue='+item_Value+'&column='+column_count+'&total='+total_column+'&data='+product_values;
318
//alert(items_total);
319
var i = 0;
320
$('.summary-dropdown').each(function(){
321
    importance_data[i] = parseInt($(this).val());
322
    i++;
323
  });
324
//alert(importance_data);
325
var item = "";
326
for(i = 0; i < total_column; i++){
327
	//alert(item_data[i]);
328
	//alert(importance_data);
329
 
330
    var very_important_slides_score = 0.0;
331
    var regular_slides_score = 0.0;
332
    var not_so_important_slides_score = 0.0;
333
    var very_important_slides_count = 0;
334
    var regular_slides_count = 0;
335
    var not_so_important_slides_count = 0;
336
 
337
    for (var j = 0; j < importance_data.length; j++){ 
338
        if(importance_data[j] == 1){
339
        	very_important_slides_score += item_data[i][j];
340
        	very_important_slides_count += 1;
341
        }
342
        if(importance_data[j] == 2){
343
        	regular_slides_score += item_data[i][j];
344
        	regular_slides_count += 1;        	
345
        }
346
		if(importance_data[j] == 3){
347
        	not_so_important_slides_score += item_data[i][j];
348
        	not_so_important_slides_count += 1;
349
		}
350
		//alert(very_important_slides_score + "  " + very_important_slides_count);
351
		//alert(not_so_important_slides_score + " " + not_so_important_slides_count);
352
		//alert(regular_slides_score + " " + regular_slides_count);
353
     } 
354
    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;
355
    //alert("weighted score is " + weighted_score);
356
    weighted_score = Math.round(weighted_score*Math.pow(10,1))/Math.pow(10,1);
357
 
358
    item += weighted_score + '/10::';
359
    //alert(item);
1807 rajveer 360
}
1950 rajveer 361
//item = '9.8/10::9.8/10';
362
 
363
 
364
  //item = '9.8/10::9.8/10::';
365
  var items_break = '';
366
  items_break = item.split('::');
367
  for(i = 0; i < items_break.length; i++){
368
    var incre = i+1;
369
    var class_name = '.score-total-'+incre;
370
    $(class_name).html(items_break[i]);
371
 
372
  }
373
  });
374
  $('.scroller-columns').hide();
375
  $('.comparision-page-title').hide();
376
 
377
}
378
*/