1(function($) { 2 'use strict'; 3 var load_Chart; 4 var ajax_Chart; 5 window.onload = function() { 6 $( '.poll-bar-chart' ).each( 7 function() { 8 var act_id = $( this ).data( 'id' ); 9 var id = $( this ).attr( 'id' ); 10 var res = JSON.parse( bpolls_wiget_obj.votes ); 11 12 if (res[act_id]) { 13 var arr_label = []; 14 var arr_per = []; 15 var arr_color = []; 16 $.each( 17 res[act_id], 18 function(i, item) { 19 arr_label.push( item.label.toString() ); 20 arr_per.push( item.y.toString() ); 21 arr_color.push( item.color ); 22 } 23 ); 24 25 load_Chart = new Chart( 26 $( "#" + id ), 27 { 28 type: 'pie', 29 data: { 30 labels: arr_label, 31 datasets: [{ 32 label: "Poll Activity Graph (%)", 33 backgroundColor: arr_color, 34 data: arr_per 35 }] 36 }, 37 options: { 38 title: { 39 display: true, 40 text: res[act_id][0].poll_title 41 } 42 } 43 } 44 ); 45 } 46 47 } 48 ); 49 50 $( '.poll-activity-chart' ).each( 51 function() { 52 var act_id = $( this ).data( 'id' ); 53 var id = $( this ).attr( 'id' ); 54 var res = JSON.parse( bpolls_wiget_obj.votes ); 55 56 if (res[act_id]) { 57 var arr_label = []; 58 var arr_per = []; 59 var arr_color = []; 60 $.each( 61 res[act_id], 62 function(i, item) { 63 arr_label.push( item.label.toString() ); 64 arr_per.push( item.y.toString() ); 65 arr_color.push( item.color ); 66 } 67 ); 68 69 load_Chart = new Chart( 70 $( "#" + id ), 71 { 72 type: 'pie', 73 data: { 74 labels: arr_label, 75 datasets: [{ 76 label: "Poll Activity Graph (%)", 77 backgroundColor: arr_color, 78 data: arr_per 79 }] 80 }, 81 } 82 ); 83 } 84 85 } 86 ); 87 } 88 89 if ( $( ".bpolls-activities-list option:selected" ).val() != '' ) { 90 $( '.bpolls-activities-list' ).trigger( "change" ); 91 } 92 $( document ).on( 93 'change', 94 '.bpolls-activities-list', 95 function() { 96 var actid = $( this ).find( ":selected" ).val(); 97 var clickd_obj = $( this ); 98 var data = { 99 'action': 'bpolls_activity_graph_ajax', 100 'actid': actid, 101 'ajax_nonce': bpolls_wiget_obj.ajax_nonce 102 }; 103 104 $.post( 105 bpolls_wiget_obj.ajax_url, 106 data, 107 function(response) { 108 clickd_obj.parents().siblings( '.poll-bar-chart' ).remove(); 109 $( '<canvas class="poll-bar-chart" data-id="' + actid + '" id="bpolls-activity-chart-' + actid + '"></canvas>' ).insertAfter( clickd_obj.parents( '.bpolls-activity-select' ) ); 110 var resp = JSON.parse( response ); 111 var arr2_label = []; 112 var arr2_per = []; 113 var arr2_color = []; 114 var arr2_title = []; 115 var title = ''; 116 $.each( 117 resp[actid], 118 function(i, item) { 119 arr2_label.push( item.label.toString() ); 120 arr2_per.push( item.y.toString() ); 121 arr2_color.push( item.color ); 122 title = item.poll_title; 123 } 124 ); 125 126 ajax_Chart = new Chart( 127 clickd_obj.parents().siblings( '.poll-bar-chart' ), 128 { 129 type: 'pie', 130 data: { 131 labels: arr2_label, 132 datasets: [{ 133 label: "Poll Activity Graph (%)", 134 backgroundColor: arr2_color, 135 data: arr2_per 136 }] 137 }, 138 options: { 139 title: { 140 display: true, 141 text: title 142 } 143 } 144 } 145 ); 146 } 147 ); 148 } 149 ); 150 151 $( document ).ready( 152 function(){ 153 $( document ).on( 154 'change', 155 '.bpolls-activities-list', 156 function(e) { 157 e.preventDefault();
158 $( '#export-poll-data' ).attr( 'href', '?export_csv=1&buddypress_poll=1&activity_id=' + $( this ).val() ); 159 } 160 ); 161 } 162 ); 163})( jQuery );
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.