PageSourceSearch

https://www.thunder1045.com/wp-content/plugins/weblator_polling/public/assets/js/app/public.js?ver=1.3.5.6

js thunder1045.com collected 2026-09-26 12:47:16 UTC 30,921 bytes, 691 lines download raw bytes

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