1//enablePollVoteBtn from captcha callback..... 2function enablePollVoteBtn(token){ //now make poll id wise unique captcha callback. 3 // renable vote button 4 jQuery("[data-poll-id='"+ globalPollId +"'] #btn_vote_"+globalPollId).attr("disabled", false); 5} 6 7function disablePollVoteBtn(passPollId){ 8 if (passPollId) { 9 jQuery("[data-poll-id='"+ passPollId +"'] #btn_vote_"+passPollId).attr("disabled", "disabled"); 10 } 11 else { 12 jQuery("[data-poll-id='"+ globalPollId +"'] #btn_vote_"+globalPollId).attr("disabled", "disabled"); 13 } 14} 15 16var globalPollId = ""; 17var Poll = function(id, poll_other_info) { 18 var poll = this; 19 this.options = { 20 pollID : null, oneVote : null, pollData : null, showResults : null, chart : null, chartTotals : null, 21 pollOtherInfo : null //WD-1814 22 }; 23 24 function init(id, poll_other_info){ 25 poll.options.pollID = id; 26 globalPollId = id; 27 28 jQuery('#btn_vote_'+id).prop('disabled', true); 29 30 poll.options.pollOtherInfo = poll_other_info; 31 32 var fp2s = jQuery("#fingerprint2_signature_poll_"+id).val(); 33 if (fp2s == "") { 34 returnSignature(); 35 }else{ 36 firstLoad(); 37 } 38 39 //Set up events 40 jQuery(document).on('click', '[data-poll-id="'+ id +'"] .weblator-poll-submit', function () { 41 submitVote(); 42 }); 43 44 jQuery(document).on('click', '[data-poll-id="'+ id +'"] .weblator-view-poll', function (e) { 45 e.preventDefault(); 46 //WD-1814 47 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .chart_data_type_div").css("display", "block"); 48 loadPoll(); 49 }); 50 51 jQuery(document).on('click', '[data-poll-id="'+ id +'"] .weblator-hide-poll', function (e) { 52 e.preventDefault(); 53 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .chart_data_type_div").css("display", "none"); 54 hidePoll(); 55 }); 56 } 57 58 function firstLoad(){ 59 var btnVote = jQuery("[data-poll-id='"+ poll.options.pollID +"'] #btn_vote_"+poll.options.pollID); 60 var btnVoteSpin = jQuery("[data-poll-id='"+ poll.options.pollID +"'] #btn_vote_"+poll.options.pollID+" #vote_spin_"+poll.options.pollID); 61 62 // on first load disable vote button if captcha is not entered. 63 if (googleRecaptchaPollCheck && googleRecaptchaPollCheck != 'undefined') { 64 btnVote.attr("disabled", "disabled"); 65 } 66 67 var hiddenPollObj = jQuery("[data-poll-id='"+ poll.options.pollID +"'] #hidden_poll_" + poll.options.pollID); 68 var hiddenPollVal = hiddenPollObj.val(); 69 70 var fp2s = jQuery("#fingerprint2_signature_poll_"+poll.options.pollID).val(); 71 //Check if a user is allowed only one vote and hasn't already voted if they are allowed only one vote 72 jQuery.post(ajaxurl, {action:"has_voted", poll_id:poll.options.pollID, currentDatePass:hiddenPollVal,fp2s:fp2s }, function(response){ 73 //slide loading el up 74 console.log("ID is : " , "#weblator-poll-loading-"+poll.options.pollID); 75 jQuery("#weblator-poll-loading-"+poll.options.pollID).slideUp(); 76 jQuery('#btn_vote_'+poll.options.pollID).prop('disabled', false); 77 if (parseInt(response, 10) === 1){ //1 vote allow 78 //weblator_polling/public/views/poll.php -- file we have divs for warning. 79 //User has voted and can't vote 80 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .alert-warning").slideDown(); 81 btnVote.attr("disabled", "disabled"); 82 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .weblator-view-poll").css("display", "block"); 83 jQuery("[data-poll-id='"+ poll.options.pollID +"'] input[type=radio]").attr("disabled", "disabled"); 84 85 poll.options.oneVote = 0; 86 } 87 else if (parseInt(response, 10) === 2){ //10 votes allow 88 //just change message. 89 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .alert-warning").html("You have already voted 10 times on this poll !"); 90 91 //User has voted and can't vote 92 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .alert-warning").slideDown(); 93 btnVote.attr("disabled", "disabled"); 94 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .weblator-view-poll").css("display", "block"); 95 jQuery("[data-poll-id='"+ poll.options.pollID +"'] input[type=radio]").attr("disabled", "disabled"); 96 97 poll.options.oneVote = 0; 98 } 99 100 jQuery.post(ajaxurl, {action:"result_action", poll_id:poll.options.pollID}, function(response){ 101 poll.options.showResults = parseInt(response, 10); 102 if (poll.options.showResults === 2){ 103 hidePoll(); 104 loadPoll(); 105 } 106 else if(poll.options.showResults === 3) 107 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .weblator-view-poll").css("display", "block"); 108 109 else if (poll.options.showResults === 4) 110 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .weblator-view-poll, [data-poll-id='"+ poll.options.pollID +"'] .weblator-hide-poll").remove(); 111 }); 112 }); 113 } 114 115 function loadPoll(){ 116 jQuery.post(ajaxurl, {action:"chart_data", poll_id:poll.options.pollID, poll_other_info:poll.options.pollOtherInfo}, function(response){ 117 var json = jQuery.parseJSON(response), totalVotes = 0;; 118 119 var poll_id_val = json.poll_id; 120 var chart_data_type_js_val = json.chart_data_type; 121 var chart_type_js_val = json.chart_type; 122 123 //Make totals integers 124 for (var i=0; i < json.totals.length; i++) 125 json.totals[i] = parseInt(json.totals[i]); 126 127 if (json.chart_type == 1 || json.chart_type == 4 || json.chart_type == 5){ 128 129 if (chart_data_type_js_val == 'percentage') { 130 var data = { 131 labels : json.labels, 132 datasets : [ 133 { 134 fillColor : json.styles[0].fillColor, 135 strokeColor : json.styles[0].strokeColor, 136 pointColor : json.styles[0].pointColor, 137 pointStrokeColor : json.styles[0].pointStrokeColor, 138 data : json.percentages, //here its percentage. 139 140 totalData : json.totals //added new totalData key too. 141 } 142 ] 143 } 144 145 for(var i = 0; i < data.datasets[0].totalData.length; i++) 146 totalVotes += data.datasets[0].totalData[i]; 147 } 148 else { //as usual code for total number of votes. 149 var data = { 150 labels : json.labels, 151 datasets : [ 152 { 153 fillColor : json.styles[0].fillColor, 154 strokeColor : json.styles[0].strokeColor, 155 pointColor : json.styles[0].pointColor, 156 pointStrokeColor : json.styles[0].pointStrokeColor, 157 data : json.totals 158 } 159 ] 160 } 161 162 for(var i = 0; i < data.datasets[0].data.length; i++) 163 totalVotes += data.datasets[0].data[i]; 164 } 165 166 }else { 167 var data = []; 168 169 if (chart_data_type_js_val == 'percentage') { 170 for (var i = 0; i < json.totals.length; i++){ 171 totalVotes += parseInt(json.totals[i]); 172 data.push({ 173 //value must need parseInt only. 174 value: parseInt(json.percentages[i]), //here its percentage. 175 color : json.option_colours[i], 176 label : json.labels[i], 177 178 totalValue : json.totals[i], //added new totalValue key too. 179 percentageValue : json.percentages[i] 180 }); 181 } 182 } 183 else { //as usual code for total number of votes. 184 for (var i = 0; i < json.totals.length; i++){ 185 totalVotes += parseInt(json.totals[i]); 186 data.push({ 187 value: parseInt(json.totals[i]), 188 color : json.option_colours[i], 189 label : json.labels[i] 190 }); 191 } 192 } 193 } 194 195 if (totalVotes > 0){ 196 var message_str = ''; 197 if (chart_data_type_js_val == 'percentage') { 198 poll.options.chartTotals = json.percentages; 199 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .chart_data_type_div").html(message_str); 200 } 201 else { 202 poll.options.chartTotals = json.totals; 203 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .chart_data_type_div").html(message_str); 204 } 205 206 var override = overrideOptions(); 207 208 json.options = jQuery.extend({}, override, json.options); 209 210 if (parseInt(json.maxWidth) == 0){ 211 var width = jQuery("[data-poll-id='"+ poll.options.pollID +"'] #weblator-chart-" + poll.options.pollID).parent().width(); 212 213 jQuery("[data-poll-id='"+ poll.options.pollID +"'] #weblator-chart-" + poll.options.pollID).attr({width: width}); 214 jQuery("[data-poll-id='"+ poll.options.pollID +"'] #weblator-chart-" + poll.options.pollID).attr({height: parseInt(width) / 2}); 215 216 if (parseInt(json.chartType) == 5 || parseInt(json.chartType)){ 217 jQuery("[data-poll-id='"+ poll.options.pollID +"'] #weblator-chart-" + poll.options.pollID).removeAttr("height"); 218 } 219 } 220 221 jQuery("[data-poll-id='"+ poll.options.pollID +"'] #weblator-chart-" + poll.options.pollID).slideDown(function(){ 222 switch(parseInt(json.chart_type)){ 223 case 1: 224 var ctx = document.getElementById("weblator-chart-" + poll.options.pollID).getContext("2d"); 225 poll.options.chart = new Chart(ctx).Bar(data, json.options); 226 break; 227 case 2: 228 var ctx = document.getElementById("weblator-chart-" + poll.options.pollID).getContext("2d"); 229 poll.options.chart = new Chart(ctx).Pie(d
229ata,json.options); 230 if (parseInt(json.showLegend)) 231 legend(document.getElementById("legend-" + poll.options.pollID), data); 232 break; 233 case 3: 234 var ctx = document.getElementById("weblator-chart-" + poll.options.pollID).getContext("2d"); 235 poll.options.chart = new Chart(ctx).Doughnut(data,json.options); 236 if (parseInt(json.showLegend)) 237 legend(document.getElementById("legend-" + poll.options.pollID), data); 238 break; 239 case 4: 240 var ctx = document.getElementById("weblator-chart-" + poll.options.pollID).getContext("2d"); 241 poll.options.chart = new Chart(ctx).Line(data,json.options); 242 break; 243 case 5: 244 var ctx = document.getElementById("weblator-chart-" + poll.options.pollID).getContext("2d"); 245 poll.options.chart = new Chart(ctx).Radar(data,json.options); 246 break; 247 case 6: 248 var ctx = document.getElementById("weblator-chart-" + poll.options.pollID).getContext("2d"); 249 poll.options.chart = new Chart(ctx).PolarArea(data,json.options); 250 if (parseInt(json.showLegend)) 251 legend(document.getElementById("legend-" + poll.options.pollID), data); 252 break; 253 case 7: 254 createBootstrapChart(data, json.options, json.maxWidth); 255 break; 256 } 257 258 //Move Legend 259 $leg = jQuery("[data-poll-id='"+ poll.options.pollID +"'] .legend"); 260 if ($leg.hasClass("tl") || $leg.hasClass("tm") || $leg.hasClass("tr")){ 261 $leg.insertBefore(jQuery("[data-poll-id='"+ poll.options.pollID +"'] canvas")); 262 } 263 }); 264 } else { 265 hidePoll(); 266 } 267 }); 268 269 if (jQuery("[data-poll-id='"+ poll.options.pollID +"'] .weblator-view-poll:visible")){ 270 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .weblator-view-poll").css("display", "none"); 271 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .weblator-hide-poll").css("display", "block"); 272 } 273 } 274 275 function getSignature() { 276 //console.log("Signature Start inside..."); 277 var hasConsole = typeof console !== "undefined" 278 var fingerprintReport = function () { 279 var options = { 280 excludes: { 281 availableScreenResolution: true, 282 enumerateDevices: true, 283 doNotTrack: true, 284 adBlock: true, 285 indexedDb: true, 286 font: true 287 } 288 } 289 290 Fingerprint2.get(options, function (components) { 291 var signature = Fingerprint2.x64hash128(components.map(function (pair) { 292 return pair.value 293 }).join(), 31) 294 jQuery('#fingerprint2_signature_poll_'+poll.options.pollID).val(signature); 295 fp2s = signature; 296 }) 297 } 298 var cancelId 299 var cancelFunction 300 if (window.requestIdleCallback) { 301 cancelId = requestIdleCallback(fingerprintReport) 302 cancelFunction = cancelIdleCallback 303 } else { 304 cancelId = setTimeout(fingerprintReport, 500) 305 cancelFunction = clearTimeout 306 } 307 console.log("Signature End inside..."); 308 } 309 310 function returnSignature() { 311 console.log("Signature Start inside..."); 312 var hasConsole = typeof console !== "undefined" 313 314 var fingerprintReport = function () { 315 var options = { 316 excludes: { 317 availableScreenResolution: true, 318 enumerateDevices: true, 319 doNotTrack: true, 320 adBlock: true, 321 indexedDb: true, 322 font: true 323 } 324 } 325 326 try { 327 Fingerprint2.get(options, function (components) { 328 var signature = Fingerprint2.x64hash128(components.map(function (pair) { 329 return pair.value 330 }).join(), 31) 331 console.log("User Fingerprint Inside: ", signature); 332 jQuery('#fingerprint2_signature_poll_'+poll.options.pollID).val(signature); 333 firstLoad(); 334 }) 335 } 336 catch(e) {
337 console.log("catch Fingerprint2 fingerprintReport fun"); 338 jQuery("#weblator-poll-loading-"+poll.options.pollID).slideUp(); 339 jQuery('#btn_vote_'+id).prop('disabled', false); 340 } 341 342 }//End of function fingerprintReport 343 344 var cancelId 345 var cancelFunction 346 if (window.requestIdleCallback) { 347 cancelId = requestIdleCallback(fingerprintReport) 348 cancelFunction = cancelIdleCallback 349 } else { 350 cancelId = setTimeout(fingerprintReport, 500) 351 cancelFunction = clearTimeout 352 } 353 console.log("Signature End inside..."); 354 } 355 356 357 function submitVote(){ 358 console.log("submitVote Poll..."+poll.options.pollID); 359 //------------------------------------------------------- 360 //WD-1514 361 var googleRecaptchaResp = ''; 362 var custom_error_captcha_js = 'Please check the re-captcha form.'; 363 364 var fp2s = jQuery("#fingerprint2_signature_poll_"+poll.options.pollID).val(); 365 366 if (fp2s == "") { 367 getSignature(); 368 var fp2s = jQuery("#fingerprint2_signature_poll_"+poll.options.pollID).val(); 369 } 370 371 try { 372 if (googleRecaptchaPollCheck && googleRecaptchaPollCheck != 'undefined') { 373 if (custom_error_captcha && custom_error_captcha != 'undefined') { 374 custom_error_captcha_js = custom_error_captcha; 375 } 376 377 try { 378 if(jQuery("[data-poll-id='"+ poll.options.pollID +"']").find('.g-recaptcha-response').val()==""){ 379 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .alert-danger").html(custom_error_captcha_js); 380 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .alert-danger").slideDown(); 381 382 setTimeout(function(){ 383 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .alert-danger").slideUp(); 384 }, 2000); 385 return false; 386 } 387 else { 388 googleRecaptchaResp = jQuery("[data-poll-id='"+ poll.options.pollID +"']").find('.g-recaptcha-response').val(); 389 } 390 } 391 catch(e) {} 392 } 393 }catch(e) {} 394 //------------------------------------------------------- 395 if (!jQuery("[data-poll-id='"+ poll.options.pollID +"'] .weblator-poll-vote ul li input[type='radio']:checked").length){ 396 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .alert-danger").html('Please select an option !'); 397 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .alert-danger").slideDown(); 398 399 setTimeout(function(){ 400 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .alert-danger").slideUp(); 401 }, 3000); 402 return 403 } 404 405 jQuery("#weblator-poll-submit-"+poll.options.pollID).slideDown(); 406 407 var option = jQuery("[data-poll-id='"+ poll.options.pollID +"'] input[name='weblator-chart-options']:checked").val(); 408 409 var hiddenPollObj = jQuery("[data-poll-id='"+ poll.options.pollID +"'] #hidden_poll_" + poll.options.pollID); 410 var hiddenPollVal = hiddenPollObj.val(); 411 jQuery.post(ajaxurl, {action:"save_vote", option:option, poll_id:poll.options.pollID, currentDatePass:hiddenPollVal, g_recaptcha_response:googleRecaptchaResp, fp2s:fp2s}, function(response){ 412 //WD-576 413 unlimitedVoteUserLimitFinished = false; 414 415 var totalUserVote = 0; 416 if (response) { 417 if (response == 'Unlimited Vote Limit Finished.') { 418 unlimitedVoteUserLimitFinished = true; 419 } 420 else { 421 tempArr = response.split('::'); 422 var actualMsg = tempArr[0]; 423 var extraMsg = tempArr[1]; 424 425 if (actualMsg == 'google recaptcha') { 426 response_array = JSON.parse(extraMsg); 427 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .alert-danger").html(response_array.error); 428 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .alert-danger").slideDown(); 429 430 setTimeout(function(){ 431 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .alert-danger").slideUp(); 432 }, 2000); 433 434 return false;
435 } 436 else { 437 //for Voted Added:: 438 if (extraMsg) { 439 tempArr_1 = extraMsg.split(":"); 440 totalUserVote = tempArr_1[1]; 441 } 442 } 443 } 444 } 445 446 jQuery("#weblator-poll-submit-"+poll.options.pollID).slideUp(); 447 448 if (unlimitedVoteUserLimitFinished) { 449 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .alert-warning").html('User Unlimited Vote Limit Finished.'); 450 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .alert-warning").slideDown(); 451 } 452 else { 453 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .alert-success").slideDown(); 454 } 455 456 var btnVote = jQuery("[data-poll-id='"+ poll.options.pollID +"'] #btn_vote_"+poll.options.pollID); 457 var btnVoteSpin = jQuery("[data-poll-id='"+ poll.options.pollID +"'] #btn_vote_"+poll.options.pollID+" #vote_spin_"+poll.options.pollID); 458 459 btnVote.attr("disabled", "disabled"); 460 btnVoteSpin.css("display", "inline-block"); 461 462 //WPB-7222 -- reload the results once after a vote (this used to run twice): always when they show after voting (1) 463 //or are always shown (2), and for "view results" (3) only if the visitor has them open. poll.php forces the 464 //bootstrap bar chart, which replaces the canvas with .bs-chart-container, so check for either. 465 var resultsOpen = jQuery("[data-poll-id='"+ poll.options.pollID +"'] canvas:visible, [data-poll-id='"+ poll.options.pollID +"'] .bs-chart-container:visible").length; 466 if (poll.options.showResults == 1 || poll.options.showResults == 2 || (poll.options.showResults != 4 && resultsOpen)){ 467 hidePoll(); 468 loadPoll(); 469 } 470 471 if (!poll.options.oneVote){ 472 if (googleRecaptchaPollCheck && googleRecaptchaPollCheck != 'undefined') { 473 // doing nothing here , if needed will do. 474 } 475 else { 476 btnVote.removeAttr("disabled"); 477 } 478 btnVoteSpin.css("display", "none"); 479 }else { 480 jQuery("[data-poll-id='"+ poll.options.pollID +"'] input[type=radio]").attr("disabled", "disabled"); 481 btnVoteSpin.css("display", "inline-block"); 482 } 483 484 if (unlimitedVoteUserLimitFinished) { 485 setTimeout(function(){ 486 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .alert-warning").slideUp(); 487 }, 2000); 488 } 489 else { 490 setTimeout(function(){ 491 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .alert-success").slideUp(); 492 }, 2000); 493 } 494 if (jQuery('.weblator-sponsor-message.w-card-text').length) { 495 jQuery('#wpvo-'+poll.options.pollID).hide(); 496 jQuery('#wbsm-'+poll.options.pollID).show(); 497 var wbsmDuration = jQuery('.weblator-banner-sponsor-message-duration').val()* 1000; 498 setTimeout(function(){ 499 jQuery('#wbsm-'+poll.options.pollID).hide(); 500 jQuery('#wpvo-'+poll.options.pollID).show(); 501 }, wbsmDuration); 502 } 503 504 }); 505 //alert("going to disable now!"); 506 disablePollVoteBtn(poll.options.pollID); 507 508 } 509 510 function hidePoll(){ 511 jQuery("[data-poll-id='"+ poll.options.pollID +"'] #weblator-chart-" + poll.options.pollID).slideUp(); 512 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .weblator-view-poll").css("display", "block"); 513 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .weblator-hide-poll").css("display", "none"); 514 515 var canvasID = "weblator-chart-" + poll.options.pollID; 516 var canvasWidth = jQuery("#" + canvasID).width(); 517 var canvasHeight = jQuery("#" + canvasID).height(); 518 519 jQuery("#" + canvasID).remove(); 520 521 var canvas = jQuery('<canvas />').attr({ 522 id: canvasID, 523 width:canvasWidth, 524 height: canvasHeight 525 }); 526 527 canvas.css("maxWidth", canvasWidth + "px"); 528 canvas.css("width", canvasWidth + "px"); 529 canvas.css("height", canvasHeight + "px"); 530 531 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .panel").after(canvas); 532 533 poll.options.chart = null; 534 535 if (jQuery("[data-poll-id='"+ poll.options.pollID +"'] .bs-chart-container").length) 536 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .bs-chart-container").slideUp(function(){ 537 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .bs-chart-container").remove(); 538 }); 539 540 if (jQuery("[data-poll-id='"+ poll.options.pollID +"'] .legend ").length){ 541 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .legend ").empty(); 542 } 543 } 544 545 function overrideOptions(){ 546 var min = Infinity, max = -Infinity, x; 547 for( x in poll.options.chartTotals) { 548 if( poll.options.chartTotals[x] < min) min = poll.options.chartTotals[x]; 549 if( poll.options.chartTotals[x] > max) max = poll.options.chartTotals[x]; 550 } 551 552 var scaleSteps = 20; 553 var scaleStepWidth = 1; 554 var scaleStart = 0; 555 556 if (max < 20){ 557 scaleSteps = max; 558 }else { 559 scaleStepWidth = Math.ceil(max/scaleSteps); 560 } 561 562 if (poll.options.chartType == 5 || poll.options.chartType == 6){ 563 scaleSteps = poll.options.chartOptionsCount; 564 scaleStart = 0; 565 scaleStepWidth = Math.ceil(max/scaleSteps); 566 } 567 568 return options = { 569 scaleOverride : true, 570 scaleSteps : scaleSteps, 571 scaleStepWidth : scaleStepWidth, 572 scaleStartValue : scaleStart 573 }; 574 } 575
576 function createBootstrapChart(data, override, maxWidth){ 577 jQuery("#weblator-chart-" + poll.options.pollID).remove(); 578 579 var total = 0; 580 for(var i=0; i < data.length; i++) 581 total = total + parseInt(data[i].value); 582 583 if (parseInt(maxWidth) == 0) 584 maxWidth = "100%"; 585 586 var bsChartContainer = jQuery('<div/>') 587 .attr("class", "bs-chart-container") 588 .css("display", "none") 589 .css("max-width", maxWidth + "px"); 590 591 for(var i = 0; i < data.length; i++){ 592 var label = jQuery("<strong/>").html(data[i].label); 593 var progressContainer = jQuery('<div/>').attr("class", "progress"); 594 var p = (data[i].value / total) * 100 595 596 var progressBar = jQuery('<div/>') 597 .attr("class", "progress-bar") 598 .attr("role", "progressbar") 599 .attr("aria-valuenow", p) 600 .attr("aria-valuemin", 0) 601 .css({ 602 backgroundColor : data[i].color 603 }); 604 605 if (override.bsBarStriped) 606 progressContainer.addClass("progress-striped"); 607 608 if (override.chart_data_type == 'percentage') { 609 var span = jQuery('<span/>') 610 .attr("class", "") 611 .html('<font color="black">' + data[i].percentageValue + '%</font>'); 612 } 613 else { 614 var span = jQuery('<span/>') 615 .attr("class", "") 616 .html(data[i].value); 617 } 618 619 if (p > 0) 620 progressBar.append(span); 621 622 progressContainer.append(progressBar); 623 bsChartContainer.append(label); 624 bsChartContainer.append(progressContainer); 625 } 626 627 jQuery("[data-poll-id='"+ poll.options.pollID +"'] .panel").after(bsChartContainer); 628 629 bsChartContainer.slideDown(); 630 631 jQuery(".progress-bar").each(function(){ 632 var value = jQuery(this).attr("aria-valuenow"); 633 jQuery(this).animate({ 634 width:value + "%" 635 }, 1000); 636 }); 637 } 638 639 init(id,poll_other_info); 640 641};//End of var Poll = function(id, poll_other_info)
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.