diff --git a/tpl/part/vote_table_classic.tpl b/tpl/part/vote_table_classic.tpl index 725c4c987a6b1f76a0f69623e2759754423e8a92..20fe88583775f429596737c74692fd285a2ca04a 100644 --- a/tpl/part/vote_table_classic.tpl +++ b/tpl/part/vote_table_classic.tpl @@ -192,19 +192,23 @@ <script type="text/javascript"> $(document).ready(function () { $('#showChart').on('click', function() { - $('#showChart').after("<h3>{__('Poll results', 'Chart')}</h3><canvas id=\"Chart\"></canvas>"); - $('#showChart').remove(); + $('#showChart') + .after("<h3>{__('Poll results', 'Chart')}</h3><canvas id=\"Chart\"></canvas>") + .remove(); var resIfneedbe = []; var resYes = []; - $('#addition').find('td').each(function (colIndex) { - if($(this).find('.inb-count').text()!='' && $(this).find('.inb-count').text()!=undefined) { + $('#addition').find('td').each(function () { + var inbCountText = $(this).find('.inb-count').text(); + if(inbCountText != '' && inbCountText != undefined) { resIfneedbe.push($(this).find('.inb-count').html()) } else { resIfneedbe.push(0); } - if($(this).find('.yes-count').text()!='' && $(this).find('.yes-count').text()!=undefined) { + + var yesCountText = $(this).find('.yes-count').text(); + if(yesCountText != '' && yesCountText != undefined) { resYes.push($(this).find('.yes-count').html()) } else { resYes.push(0); @@ -216,8 +220,8 @@ {/foreach} ]; - resIfneedbe.shift(); resIfneedbe.pop(); - resYes.shift(); resYes.pop(); + resIfneedbe.shift(); + resYes.shift(); var barChartData = { labels : cols, diff --git a/tpl/part/vote_table_date.tpl b/tpl/part/vote_table_date.tpl index cf3f3758fa8b6bc43e605af4af3280fdfe14fc60..7bd6781a9de1398d0fa4cb8240d52c4375d1c7fa 100644 --- a/tpl/part/vote_table_date.tpl +++ b/tpl/part/vote_table_date.tpl @@ -247,20 +247,23 @@ <script type="text/javascript"> $(document).ready(function () { $('#showChart').on('click', function() { - $('#showChart').after("<h3>{__('Poll results', 'Chart')}</h3><canvas id=\"Chart\"></canvas>"); - $('#showChart').remove(); + $('#showChart') + .after("<h3>{__('Poll results', 'Chart')}</h3><canvas id=\"Chart\"></canvas>") + .remove(); var resIfneedbe = []; var resYes = []; - $('#addition').find('td').each(function (colIndex) { - if($(this).find('.inb-count').text()!='') { - resIfneedbe.push($(this).find('.inb-count').text()) + $('#addition').find('td').each(function () { + var inbCountText = $(this).find('.inb-count').text(); + if(inbCountText != '' && inbCountText != undefined) { + resIfneedbe.push(inbCountText) } else { resIfneedbe.push(0); } - if($(this).find('.yes-count').text()!='') { - resYes.push($(this).find('.yes-count').text()) + var yesCountText = $(this).find('.yes-count').text(); + if(yesCountText != '' && yesCountText != undefined) { + resYes.push(yesCountText) } else { resYes.push(0); } @@ -273,8 +276,8 @@ {/foreach} ]; - resIfneedbe.shift(); resIfneedbe.pop(); - resYes.shift(); resYes.pop(); + resIfneedbe.shift(); + resYes.shift(); var barChartData = { labels : cols,