1(function( $ ) { 2 'use strict'; 3 4 $(document).ready(function () { 5 6 if (typeof post_slug !== 'undefined') { 7 var currentPageTitle = post_slug['slug']; 8 } 9 var isAdmin = 0, isLogged = 0; 10 11 if (typeof cpgn_cons_angora_user_meta_values !== 'undefined') { 12 isLogged = 1; 13 if (cpgn_cons_angora_user_meta_values['admin'] == 1) { 14 isAdmin = 1; 15 } 16 } 17 18 function initBootstrapTable(jqueryObject, header, content, originalMales) { 19 20 if (isLogged) { 21 jqueryObject.empty(); 22 jqueryObject.bootstrapTable('destroy'); 23 jqueryObject.bootstrapTable({ 24 data: content, 25 dataType: 'json', 26 columns: header, 27 toolbar: '#cpgn-cons-angora-table-toolbar', 28 sortable: 'true', 29 search: 'true', 30 stickyHeader: 'false', 31 fixedColumns: 'true', 32 fixedNumber: '1', 33 sidePagination: 'client', 34 pagination: 'true', 35 pageList: '[5, 10, 20, 50, 100, Tous]', 36 showColumns: 'true', 37 showExport: 'true', 38 exportTypes: ['csv', 'txt', 'excel'], 39 exportDataType: 'all', 40 exportOptions: { 41 fileName: 'export_cons_angora', 42 csvSeparator: ';' 43 }, 44 cookie: 'true', 45 cookieIdTable: 'cpgn_cons_angora_table', 46 cookieExpire: '1y', 47 striped: 'true' 48 }); 49 50 jqueryObject.on ('all.bs.table', function () { 51 jqueryObject.each(function(){ 52 $(this).find('td.NumNational').each(function(){ 53 if (typeof originalMales !== 'undefined') { 54 for (var index in originalMales) { 55 if (originalMales.hasOwnProperty(index)) { 56 if ($(this).text() === originalMales[index].nunaca_bouc) { 57 $(this).addClass('dark-green-cell'); 58 } 59 } 60 } 61 } 62 }); 63 $(this).find('td.consang').each(function(){ 64 if ( $(this).text() <= 3){ 65 $(this).addClass('green-cell'); 66 } 67 if (($(this).text() > 3) && ($(this).text() <= 6.2)){ 68 $(this).addClass('lime-cell'); 69 } 70 if (($(this).text() > 6.2) && ($(this).text() <= 12.5)){ 71 $(this).addClass('yellow-cell'); 72 } 73 if (($(this).text() > 12.5) && ($(this).text() <= 25)){ 74 $(this).addClass('orange-cell'); 75 } 76 if (($(this).text() > 25) || ($(this).text() == 'ANT') || ($(this).text() == 'GENE')){ 77 $(this).addClass('red-cell'); 78 } 79 $(this).addClass('text-right'); 80 }); 81 $(this).find('td.MoyenneTroupeau').each(function(){ 82 if ( $(this).text() <= 3){ 83 $(this).addClass('dark-green-cell'); 84 } 85 if (($(this).text() > 3) && ($(this).text() <= 6.2)){ 86 $(this).addClass('dark-lime-cell'); 87 } 88 if (($(this).text() > 6.2) && ($(this).text() <= 12.5)){ 89 $(this).addClass('dark-yellow-cell'); 90 } 91 if (($(this).text() > 12.5) && ($(this).text() <= 25)){ 92 $(this).addClass('dark-orange-cell'); 93 } 94 if (($(this).text() > 25) || ($(this).text() == 'ANT') || ($(this).text() == 'GENE')){ 95 $(this).addClass('dark-red-cell'); 96 } 97 $(this).addClass('text-right'); 98 }); 99 }); 100 }); 101 102 jqueryObject.bootstrapTable('refresh'); 103 104 // SOLUTION : Simuler un redimensionnement de fenêtre pour forcer la régénération des colonnes fixes 105 setTimeout(function() { 106 // Déclencher l'événement resize qui force Bootstrap Table à régénérer les colonnes fixes 107 $(window).trigger('resize'); 108 109 // Alternative : forcer explicitement la mise à jour des colonnes fixes 110 // jqueryObject.bootstrapTable('resetView'); 111 }, 500); 112 113 } 114 } 115 116 function cpgnConsAngoraAjaxNuchep() { 117 var cpgnConsAngoraNuchep = ajax_cpgn_cons_angora_nuchep.url; 118 var cpgnConsAngoraNuchepNonce = ajax_cpgn_cons_angora_nuchep.nonce; 119 $.ajax({
120 type: "post", 121 url: cpgnConsAngoraNuchep, 122 data: "action=cpgn_cons_angora_nuchep_to_json&nonce=" + cpgnConsAngoraNuchepNonce, 123 dataType: 'JSON', 124 success: function (cpgnConsAngoraNuchep) { 125 var nuchepSelector = ''; 126 var html = nuchepSelector + '<select name="nuchepsSelectForCpgnConsAngora" id="nuchepsSelectForCpgnConsAngora" title="Choisissez un N° de cheptel" multiple>'; 127 for (var key in cpgnConsAngoraNuchep) { 128 html += '<option value="' + cpgnConsAngoraNuchep[key]['NumCheptel'] + '">' + cpgnConsAngoraNuchep[key]['NumCheptel'] + '</option>'; 129 } 130 html += '</select>'; 131 132 $('#cpgn-cons-angora-table-nuchep-selector-wrapper').html(html); 133 $('#nuchepsSelectForCpgnConsAngora').selectpicker({ 134 liveSearch: 'true', 135 liveSearchPlaceholder: 'Tapez ici le N° de cheptel', 136 maxOptions: 1 137 }); 138 $('#cpgn-cons-angora-table-nuchep-selector-wrapper').removeClass('hidden'); 139 } 140 }); 141 } 142 143 function cpgnConsAngoraMaleAjaxStuff() { 144 145 var cpgnConsAngoraContent = ajax_cpgn_cons_angora_male_consanguinity.url, 146 cpgnConsAngoraContentNonce = ajax_cpgn_cons_angora_male_consanguinity.nonce, 147 cpgnConsAngoraHeaderContent = ajax_cpgn_cons_angora_male_header.url, 148 cpgnConsAngoraHeaderContentNonce = ajax_cpgn_cons_angora_male_header.nonce, 149 cpgnConsAngoraOriginalMaleContent = ajax_cpgn_cons_angora_original_male_consanguinity.url, 150 cpgnConsAngoraOriginalMaleContentNonce = ajax_cpgn_cons_angora_original_male_consanguinity.nonce, 151 maleTableWrapper = $('#cpgn-cons-angora-table'); 152 153 maleTableWrapper.html('<p class="lead text-center">Chargement des données...</p>'); 154 155 if (isLogged) { 156 $.ajax({
157 type: "post", 158 url: cpgnConsAngoraOriginalMaleContent, 159 data: "action=cpgn_cons_angora_original_male_data_to_json&nonce=" + cpgnConsAngoraOriginalMaleContentNonce, 160 dataType: 'JSON', 161 success: function (cpgnConsAngoraOriginalMaleContent) { 162 $.ajax({ 163 type: "post", 164 url: cpgnConsAngoraHeaderContent, 165 data: "action=cpgn_cons_angora_male_table_header_to_json&nonce=" + cpgnConsAngoraHeaderContentNonce, 166 dataType: 'JSON', 167 success: function (cpgnConsAngoraHeaderContent) { 168 $.ajax({ 169 type: "post", 170 url: cpgnConsAngoraContent, 171 data: "action=cpgn_cons_angora_male_data_to_json&nonce=" + cpgnConsAngoraContentNonce + postNuchep, 172 dataType: 'JSON', 173 success: function (cpgnConsAngoraContent) { 174 initBootstrapTable(maleTableWrapper, cpgnConsAngoraHeaderContent, cpgnConsAngoraContent, cpgnConsAngoraOriginalMaleContent); 175 $('#cpgn-cons-angora-table-nuchep-selector-wrapper').removeClass('hidden'); 176 } 177 }); 178 } 179 }); 180 } 181 }); 182 } 183 184 var selected; 185 var postNuchep = ''; 186 $('#main').on('change', '#nuchepsSelectForCpgnConsAngora', function () { 187 selected = $(this).val(); 188 189 if (selected.length > 0) { 190 postNuchep = '&nuchepForQuery=' + selected; 191 } 192 193 $.ajax({
194 type: "post", 195 url: cpgnConsAngoraOriginalMaleContent, 196 data: "action=cpgn_cons_angora_original_male_data_to_json&nonce=" + cpgnConsAngoraOriginalMaleContentNonce, 197 dataType: 'JSON', 198 success: function (cpgnConsAngoraOriginalMaleContent) { 199 $.ajax({ 200 type: "post", 201 url: cpgnConsAngoraHeaderContent, 202 data: "action=cpgn_cons_angora_male_table_header_to_json&nonce=" + cpgnConsAngoraHeaderContentNonce + postNuchep, 203 dataType: 'JSON', 204 success: function (cpgnConsAngoraHeaderContent) { 205 $.ajax({ 206 type: "post", 207 url: cpgnConsAngoraContent, 208 data: "action=cpgn_cons_angora_male_data_to_json&nonce=" + cpgnConsAngoraContentNonce + postNuchep, 209 dataType: 'JSON', 210 beforeSend: function () { 211 maleTableWrapper.bootstrapTable('showLoading'); 212 }, 213 success: function (cpgnConsAngoraContent) { 214 initBootstrapTable(maleTableWrapper, cpgnConsAngoraHeaderContent, cpgnConsAngoraContent, cpgnConsAngoraOriginalMaleContent); 215 $('#nuchepsSelectForCpgnConsAngora').selectpicker("destroy"); 216 $('#nuchepsSelectForCpgnConsAngora').selectpicker({ 217 liveSearch: 'true', 218 liveSearchPlaceholder: 'Tapez ici le N° de cheptel', 219 maxOptions: 1 220 }); 221 }, 222 complete: function () { 223 maleTableWrapper.bootstrapTable('hideLoading'); 224 } 225 }); 226 } 227 }); 228 } 229 }); 230 }); 231 } 232 233 function cpgnConsAngoraFemaleAjaxStuff() { 234 235 var cpgnConsAngoraContent = ajax_cpgn_cons_angora_female_consanguinity.url, 236 cpgnConsAngoraContentNonce = ajax_cpgn_cons_angora_female_consanguinity.nonce, 237 cpgnConsAngoraHeaderContent = ajax_cpgn_cons_angora_female_header.url, 238 cpgnConsAngoraHeaderContentNonce = ajax_cpgn_cons_angora_female_header.nonce, 239 femaleTableWrapper = $('#cpgn-cons-angora-table-female'); 240 241 femaleTableWrapper.html('<p class="lead text-center">Chargement des données...</p>'); 242 243 if (isLogged) { 244 $.ajax({
245 type: "post", 246 url: cpgnConsAngoraHeaderContent, 247 data: "action=cpgn_cons_angora_female_table_header_to_json&nonce=" + cpgnConsAngoraHeaderContentNonce, 248 dataType: 'JSON', 249 success: function (cpgnConsAngoraHeaderContent) { 250 $.ajax({ 251 type: "post", 252 url: cpgnConsAngoraContent, 253 data: "action=cpgn_cons_angora_female_data_to_json&nonce=" + cpgnConsAngoraContentNonce + postNuchep, 254 dataType: 'JSON', 255 success: function (cpgnConsAngoraContent) { 256 initBootstrapTable(femaleTableWrapper, cpgnConsAngoraHeaderContent, cpgnConsAngoraContent); 257 $('#cpgn-cons-angora-table-nuchep-selector-wrapper-female').removeClass('hidden'); 258 } 259 }); 260 } 261 }); 262 } 263 264 var selected; 265 var postNuchep = ''; 266 $('#main').on('change', '#nuchepsSelectForCpgnConsAngora', function () { 267 selected = $(this).val(); 268 269 if (selected.length > 0) { 270 postNuchep = '&nuchepForQuery=' + selected; 271 } 272 273 $.ajax({
274 type: "post", 275 url: cpgnConsAngoraHeaderContent, 276 data: "action=cpgn_cons_angora_female_table_header_to_json&nonce=" + cpgnConsAngoraHeaderContentNonce + postNuchep, 277 dataType: 'JSON', 278 success: function (cpgnConsAngoraHeaderContent) { 279 $.ajax({ 280 type: "post", 281 url: cpgnConsAngoraContent, 282 data: "action=cpgn_cons_angora_female_data_to_json&nonce=" + cpgnConsAngoraContentNonce + postNuchep, 283 dataType: 'JSON', 284 beforeSend: function () { 285 femaleTableWrapper.bootstrapTable('showLoading'); 286 }, 287 success: function (cpgnConsAngoraContent) { 288 initBootstrapTable(femaleTableWrapper, cpgnConsAngoraHeaderContent, cpgnConsAngoraContent); 289 $('#nuchepsSelectForCpgnConsAngora').selectpicker("destroy"); 290 $('#nuchepsSelectForCpgnConsAngora').selectpicker({ 291 liveSearch: 'true', 292 liveSearchPlaceholder: 'Tapez ici le N° de cheptel', 293 maxOptions: 1 294 }); 295 }, 296 complete: function () { 297 femaleTableWrapper.bootstrapTable('hideLoading'); 298 } 299 }); 300 } 301 }); 302 }); 303 } 304 305 /********************************** 306 * Creating Dynamic Pdf from data * 307 **********************************/ 308 309 function createConsanguiniteInPdf() { 310 var selected; 311 var postNuchep = ''; 312 $('#main').on('change', '#cpgn-cons-angora-table-nuchep-selector-wrapper #nuchepsSelectForCpgnConsAngora', function () { 313 selected = $(this).val(); 314 315 if (selected.length > 0) { 316 postNuchep = selected; 317 } else { 318 if (user_meta_values['login'].length > 0) { 319 postNuchep = user_meta_values['login']; 320 } else { 321 postNuchep = ''; 322 } 323 } 324 325 }); 326 327 $('#generer-consanguinite-angora-pdf-button').on('click', function (e) { 328 let pdfConsanguiniteAngora = ajax_cpgn_cons_angora_pdf.url; 329 let pdfConsanguiniteAngoraNonce = ajax_cpgn_cons_angora_pdf.nonce; 330 $.ajax({
331 type: "post", 332 url: pdfConsanguiniteAngora, 333 data: "action=consanguinite_to_pdf&nonce=" + pdfConsanguiniteAngoraNonce + '&nuchepForQuery=' + postNuchep, 334 dataType: 'JSON', 335 success: function (pdfConsanguiniteAngora) { 336 let ConsanguiniteAngoraPdfFileName = pdfConsanguiniteAngora.substring(pdfConsanguiniteAngora.lastIndexOf("/")+1); 337 $.ajax({ 338 url: pdfConsanguiniteAngora, 339 method: 'GET', 340 xhrFields: { 341 responseType: 'blob' 342 }, 343 success: function (data) { 344 var a = document.createElement('a'); 345 var url = window.URL.createObjectURL(data); 346 a.href = url; 347 a.download = ConsanguiniteAngoraPdfFileName; 348 document.body.append(a); 349 a.click(); 350 a.remove(); 351 window.URL.revokeObjectURL(url); 352 } 353 }); 354 } 355 }); 356 e.stopImmediatePropagation(); 357 }); 358 } 359 360 if (currentPageTitle === 'consanguinite-angora') { 361 if (isAdmin) { 362 cpgnConsAngoraAjaxNuchep(); 363 } 364 cpgnConsAngoraMaleAjaxStuff(); 365 cpgnConsAngoraFemaleAjaxStuff(); 366 createConsanguiniteInPdf(); 367 } 368 369 }); 370 371})( 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.