• Resolved shtv

    (@shtv)


    Hi i created a post about this yesterday but it has not been resolved yet.

    To change poll results to show 17% from 17.25% you wrote:

    To solve your problem you need to change some codes from the plugin. Please find the file Total-Soft-Poll-Widget.php. Edit the folder and on the line 1362 find the code

    <?php echo $Total_Soft_Poll_Res[ $i ]->Poll_A_Votes . ‘ ( ‘ . round( $Total_Soft_Poll_Res[ $i ]->Poll_A_Votes * 100 / $Total_Soft_Poll_Res_Count,2 ) . ‘ % )’; ?>

    I opened the plugin editor and found something similar on line 1365

    I removed the ,2 after res_count but it had no effect on the plugin. Please advise.

    You gave me by email a customised version of the plugin but it has other changes like it now doesnt show html colour codes which is a disadvantage if someone wants to paste a code from somewhere else or to quickly duplicate colors.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author totalsoft

    (@totalsoft)

    Hello, dear shtv.

    Thank you for contacting us and for reporting your problem.

    To solve your problem, edit our in Total_Soft_Poll_Widjet.js file. Please the code in line 153 write like this.

    var res = Number(parseFloat(parseInt(b[i]) * 100 / sumb).toFixed());
                  arr.push(res);
                  var newArray;
                  var finArr;
                  var final;
                  for (var newArr = 0; newArr < arr.length; newArr++) {
                    var sum = 0;
                    var min = 0;
                    for (var j = 0; j < arr.length; j++) {
                      sum += +arr[j];
                      finArr = arr[j];
                      if (sum > 100) {
                        for (var x = 0; x < j; x++) {
                          if (arr[j] < arr[x]) {
                            var y = arr[j];
                            arr[j] = arr[x];
                            arr[j] = y;
                          }
                            finArr = arr[j] - 1
                        }
                      }
                      else if(sum == 99){
                        for (var x = 0; x < j; x++) {
                          if (arr[j] < arr[x]) {
                            var y = arr[j];
                            arr[j] = arr[x];
                            arr[j] = y;
                          }
                          finArr = arr[j] + 1
                        }
                      }
                    }
                    newArray = finArr;
                  }
                  for (min = 0; min < arr.length; min++) {
                    for (var x = 0; x < min; x++) {
                      if (arr[min] < arr[x]) {
                        var y = arr[min];
                        arr[min] = arr[x];
                        arr[min] = y;
                      }
                    }
                    final = arr[min];
                  }
                  jQuery('.Total_Soft_Poll_1_Ans_Lab_Sp3_' + Poll_ID + '_' + i).html(b[i] + ' ( ' + newArray + ' % )');
                }
    • This reply was modified 4 years, 9 months ago by totalsoft.
    Plugin Author totalsoft

    (@totalsoft)

    To solve your problem, edit our in Total_Soft_Poll_Widget.php file. Find

    Please the code in line 234 write like this.

    jQuery.ajax({
          type: 'POST',
          url: object.ajaxurl,
          data: {
            action: 'TotalSoftPoll_1_Results', // wp_ajax_my_action / wp_ajax_nopriv_my_action in ajax.php. Can be named anything.
            foobar: Poll_ID, // translates into $_POST['foobar'] in PHP
    
          },
          success: function (response) {
    
            var b = Array();
            var sumb = 0;
            var a = response.split('s] =>');
            for (var i = 1; i < a.length; i++) {
              b[b.length] = a[i].split(')')[0].trim();
            }
    
            for (var i = 0; i < b.length; i++) {
              sumb += parseInt(b[i]);
            }
            var pvb = jQuery('.Total_Soft_Poll_1_Ans_Lab_Sp3_' + Poll_ID).html();
              if (pvb.indexOf('%') > 0 && pvb.indexOf('(') > 0 && pvb.indexOf(')') > 0) {
                var i;
                var arr = [];
                for (i = 0; i < b.length; i++) {
                  jQuery('.Total_Soft_Poll_1_Ans_Lab_Sp2_' + Poll_ID + '_' + i).css('width', parseFloat(parseInt(b[i]) * 100 / sumb).toFixed() + '%');
                  var res = Number(parseFloat(parseInt(b[i]) * 100 / sumb).toFixed());
                  arr.push(res);
                  var newArray;
                  var finArr;
                  var final;
                  for (var newArr = 0; newArr < arr.length; newArr++) {
                    var sum = 0;
                    var min = 0;
                    for (var j = 0; j < arr.length; j++) {
                      sum += +arr[j];
                      finArr = arr[j];
                      if (sum > 100) {
                        for (var x = 0; x < j; x++) {
                          if (arr[j] < arr[x]) {
                            var y = arr[j];
                            arr[j] = arr[x];
                            arr[j] = y;
                          }
                            finArr = arr[j] - 1
                        }
                      }
                      else if(sum == 99){
                        for (var x = 0; x < j; x++) {
                          if (arr[j] < arr[x]) {
                            var y = arr[j];
                            arr[j] = arr[x];
                            arr[j] = y;
                          }
                          finArr = arr[j] + 1
                        }
                      }
                    }
                    newArray = finArr;
                  }
                  for (min = 0; min < arr.length; min++) {
                    for (var x = 0; x < min; x++) {
                      if (arr[min] < arr[x]) {
                        var y = arr[min];
                        arr[min] = arr[x];
                        arr[min] = y;
                      }
                    }
                    final = arr[min];
                  }
                  jQuery('.Total_Soft_Poll_1_Ans_Lab_Sp3_' + Poll_ID + '_' + i).html(b[i] + ' ( ' + newArray + ' % )');
                }
    
              } else if (pvb.indexOf('%') > 0) {
                for (var i = 0; i < b.length; i++) {
                  jQuery('.Total_Soft_Poll_1_Ans_Lab_Sp2_' + Poll_ID + '_' + i).css('width', parseFloat(parseInt(b[i]) * 100 / sumb).toFixed() + '%');
                  jQuery('.Total_Soft_Poll_1_Ans_Lab_Sp3_' + Poll_ID + '_' + i).html(parseFloat(parseInt(b[i]) * 100 / sumb).toFixed() + ' %');
                }
              } else {
                for (var i = 0; i < b.length; i++) {
                  jQuery('.Total_Soft_Poll_1_Ans_Lab_Sp2_' + Poll_ID + '_' + i).css('width', parseFloat(parseInt(b[i]) * 100 / sumb).toFixed() + '%');
                  jQuery('.Total_Soft_Poll_1_Ans_Lab_Sp3_' + Poll_ID + '_' + i).html(b[i]);
                }
              }
          }
        });
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display of votes modification’ is closed to new replies.