11jQuery ( document ) . ready ( function ( $ ) {
22
3- var rtpr_slugs = plugin_report_vars . plugin_slugs ;
4- var rtpr_slugs_array = rtpr_slugs . split ( ',' ) ;
5- var rtpr_nrof_plugins = rtpr_slugs_array . length ;
6- var rtpr_progress = 0 ;
7- var rtpr_done = false ;
3+ const rtpr_slugs = plugin_report_vars . plugin_slugs ;
4+ const rtpr_slugs_array = rtpr_slugs . split ( ',' ) ;
5+ const rtpr_nrof_plugins = rtpr_slugs_array . length ;
6+ let rtpr_progress = 0 ;
7+ let rtpr_done = false ;
88
99
1010 function rtpr_process_next_plugin ( ) {
1111 if ( rtpr_slugs_array . length > 0 ) {
12- var slug = rtpr_slugs_array . shift ( ) ;
12+ const slug = rtpr_slugs_array . shift ( ) ;
1313 if ( $ ( '.plugin-report-row-temp-' + slug ) . length ) {
1414 rtpr_get_plugin_info ( slug ) ;
1515 } else {
1616 rtpr_process_next_plugin ( ) ;
1717 }
1818 }
1919 // update the progress information on the page
20- var perc = Math . ceil ( ( rtpr_progress / rtpr_nrof_plugins ) * 100 ) ;
20+ const perc = Math . ceil ( ( rtpr_progress / rtpr_nrof_plugins ) * 100 ) ;
2121 if ( perc < 100 ) {
2222 if ( ! $ ( '#plugin-report-progress' ) . find ( 'progress' ) . length ) {
2323 $ ( '#plugin-report-progress' ) . html ( '<progress max="100" value="0"></progress>' ) ;
2424 }
2525 $ ( '#plugin-report-progress progress' ) . prop ( 'value' , perc ) ;
2626 rtpr_progress ++ ;
27- } else {
28- // Remove the progress bar.
29- $ ( '#plugin-report-progress' ) . html ( '' ) ;
30- // Guard against duplicate finalization caused by recursive calls.
31- if ( rtpr_done ) {
32- return ;
33- }
34- rtpr_done = true ;
35- // initialize sorting on table
36- new Tablesort ( document . getElementById ( 'plugin-report-table' ) ) ;
37- // Create the export button.
38- $ ( '#plugin-report-buttons' ) . empty ( ) . append ( '<button class="button" id="plugin-report-export-btn">' + plugin_report_vars . export_btn + '</button>' ) ;
39- // Export button event handler.
40- $ ( '#plugin-report-export-btn' ) . off ( 'click' ) . on ( 'click' , function ( e ) {
41- e . preventDefault ( ) ;
42- // Call the function that does the exporting.
43- rtpr_export_table ( ) ;
44- } ) ;
45- }
27+ } else {
28+ // Remove the progress bar.
29+ $ ( '#plugin-report-progress' ) . html ( '' ) ;
30+ // Guard against duplicate finalization caused by recursive calls.
31+ if ( rtpr_done ) {
32+ return ;
33+ }
34+ rtpr_done = true ;
35+ // initialize sorting on table
36+ new Tablesort ( document . getElementById ( 'plugin-report-table' ) ) ;
37+ // Create the export button.
38+ $ ( '#plugin-report-buttons' ) . empty ( ) . append ( '<button class="button" id="plugin-report-export-btn">' + plugin_report_vars . export_btn + '</button>' ) ;
39+ // Export button event handler.
40+ $ ( '#plugin-report-export-btn' ) . off ( 'click' ) . on ( 'click' , function ( e ) {
41+ e . preventDefault ( ) ;
42+ // Call the function that does the exporting.
43+ rtpr_export_table ( ) ;
44+ } ) ;
45+ }
4646 }
4747
4848
4949 function rtpr_get_plugin_info ( slug ) {
50- var data = {
50+ const data = {
5151 'action' : 'rt_get_plugin_info' ,
5252 'slug' : slug ,
5353 'nonce' : plugin_report_vars . ajax_nonce
5454 } ;
5555
5656 jQuery . post ( ajaxurl , data , function ( response ) {
5757 // parse the response
58- obj = jQuery . parseJSON ( response ) ;
58+ const obj = JSON . parse ( response ) ;
5959 // replace the temporary table row with the new data
6060 $ ( '#plugin-report-table .plugin-report-row-temp-' + slug ) . replaceWith ( obj . html ) ;
6161 // on to the next...
@@ -69,8 +69,8 @@ jQuery(document).ready( function( $ ){
6969
7070 // Export CSV file.
7171 function rtpr_export_table ( ) {
72- var csv_data = '' ;
73- var counter = 0 ;
72+ let csv_data = '' ;
73+ let counter = 0 ;
7474 // Loop trough the table header to add the header cells.
7575 $ ( '#plugin-report-table thead tr' ) . each ( function ( ) {
7676 // Use a column counter, because we'll need ot insert two extra columns.
@@ -102,7 +102,7 @@ jQuery(document).ready( function( $ ){
102102 csv_data += $ ( this ) . text ( ) . replace ( / , / g, "." ) + ',' ;
103103 // If this is one of the first two columns, add a url column.
104104 if ( counter < 2 ) {
105- var href = '' ;
105+ let href = '' ;
106106 $ ( this ) . find ( 'a' ) . each ( function ( ) {
107107 // Get the href attribute, but strip any url vars to keep it short.
108108 href = $ ( this ) . attr ( 'href' ) . split ( '#' ) [ 0 ] . split ( '?' ) [ 0 ] ;
@@ -116,8 +116,8 @@ jQuery(document).ready( function( $ ){
116116 csv_data += "\n" ;
117117 } ) ;
118118 // Create a link element, clickit and remove it.
119- var link = document . createElement ( 'a' ) ;
120- var now = new Date ( ) ;
119+ const link = document . createElement ( 'a' ) ;
120+ const now = new Date ( ) ;
121121 link . download = 'plugin-report-' + now . getFullYear ( ) + '-' + String ( '0' + ( now . getMonth ( ) + 1 ) ) . slice ( - 2 ) + '-' + String ( '0' + now . getDate ( ) ) . slice ( - 2 ) + '.csv' ;
122122 link . href = URL . createObjectURL ( new Blob ( [ "\ufeff" , csv_data ] , { type : 'text/csv; header=present' } ) ) ;
123123 link . click ( ) ;
0 commit comments