1- 'use strict' ;
1+ ( function ( $ ) {
2+ "use strict" ;
23
3- jQuery ( document ) . ready ( function ( $ ) {
44 function showDir ( path ) {
5-
65 /* If path is not initialized */
76 if ( ! ( path instanceof Array ) ) {
87 path = [ ] ;
98 }
109
11- $ ( '#rootPath tbody tr' ) . not ( '.loadingCircle' ) . fadeOut ( ) ;
12- $ ( '.loadingCircle' ) . fadeIn ( 'slow' ) ;
10+ $ ( "#rootPath tbody tr" )
11+ . not ( ".loadingCircle" )
12+ . fadeOut ( ) ;
13+ $ ( ".loadingCircle" ) . fadeIn ( "slow" ) ;
1314
1415 $ . ajax ( {
15- url : sgddRootPathLocalize . ajaxUrl ,
16- type : ' GET' ,
16+ url : sgddRootPathLocalize . ajaxUrl , //eslint-disable-line no-undef
17+ type : " GET" ,
1718 data : {
18- action : ' listDrive' ,
19- path : path ,
20- _ajax_nonce : sgddRootPathLocalize . nonce // eslint-disable-line camelcase
19+ action : " listDrive" ,
20+ path,
21+ _ajax_nonce : sgddRootPathLocalize . nonce // eslint-disable-line camelcase, no-undef
2122 } ,
22- success : function ( response ) {
23- var html = '' ;
24- var i ;
23+ success ( response ) {
24+ let html = "" ;
25+ let i ;
2526
26- $ ( '.loadingCircle' ) . fadeOut ( ) ;
27- $ ( '#rootPath tbody tr' ) . not ( '.loadingCircle' ) . fadeIn ( 'slow' ) ;
27+ $ ( ".loadingCircle" ) . fadeOut ( ) ;
28+ $ ( "#rootPath tbody tr" )
29+ . not ( ".loadingCircle" )
30+ . fadeIn ( "slow" ) ;
2831
2932 /* Print path */
3033 if ( 0 < path . length ) {
31- html += '<a data-id="">' + sgddRootPathLocalize . driveList + ' </a> > ' ;
34+ html += '<a data-id="">' + sgddRootPathLocalize . driveList + " </a> > " ; //eslint-disable-line no-undef
3235 for ( i = 0 ; i < response . pathNames . length ; i ++ ) {
3336 if ( 0 < i ) {
34- html += ' > ' ;
37+ html += " > " ;
3538 }
36- html += '<a data-id="' + path [ i ] + '">' + response . pathNames [ i ] + '</a>' ;
39+ html +=
40+ '<a data-id="' + path [ i ] + '">' + response . pathNames [ i ] + "</a>" ;
3741 }
3842 } else {
39- html += '<a data-id="">' + sgddRootPathLocalize . driveList + ' </a>' ;
40- $ ( ' #submit' ) . attr ( ' disabled' , ' disabled' ) ;
43+ html += '<a data-id="">' + sgddRootPathLocalize . driveList + " </a>" ; //eslint-disable-line no-undef
44+ $ ( " #submit" ) . attr ( " disabled" , " disabled" ) ;
4145 }
42- $ ( ' .tablePath' ) . html ( html ) ;
46+ $ ( " .tablePath" ) . html ( html ) ;
4347
4448 /* Up directory dots */
4549 html = '<tr class="loadingCircle"></tr>' ;
4650 if ( 0 < path . length ) {
4751 html += '<tr><td class="row-title"><label>..</label></tr>' ;
48- $ ( ' .tableBody' ) . html ( html ) ;
52+ $ ( " .tableBody" ) . html ( html ) ;
4953 }
5054
5155 /* List dir content */
5256 for ( i = 0 ; i < response . content . length ; i ++ ) {
5357 html += '<tr class="' ;
5458
55- if ( 0 == i % 2 ) {
56- html += ' alternate' ;
59+ if ( 0 === i % 2 ) {
60+ html += " alternate" ;
5761 }
5862
59- html += '"><td class="row-title"><label data-id="' + response . content [ i ] . pathId + '">' + response . content [ i ] . pathName + '</label>' ;
63+ html +=
64+ '"><td class="row-title"><label data-id="' +
65+ response . content [ i ] . pathId +
66+ '">' +
67+ response . content [ i ] . pathName +
68+ "</label>" ;
6069 }
61- $ ( ' .tableBody' ) . html ( html ) ;
70+ $ ( " .tableBody" ) . html ( html ) ;
6271
63- $ ( ' .tableBody label' ) . click ( function ( ) {
72+ $ ( " .tableBody label" ) . click ( function ( ) {
6473 dirClick ( path , this ) ;
65- $ ( ' #submit' ) . removeAttr ( ' disabled' ) ;
74+ $ ( " #submit" ) . removeAttr ( " disabled" ) ;
6675 } ) ;
6776
68- $ ( ' .tablePath a' ) . click ( function ( ) {
77+ $ ( " .tablePath a" ) . click ( function ( ) {
6978 pathClick ( path , this ) ;
70- $ ( ' #submit' ) . removeAttr ( ' disabled' ) ;
79+ $ ( " #submit" ) . removeAttr ( " disabled" ) ;
7180 } ) ;
7281
73- $ ( ' #sgdd_root_path' ) . val ( JSON . stringify ( path ) ) ;
82+ $ ( " #sgdd_root_path" ) . val ( JSON . stringify ( path ) ) ;
7483 } ,
75- error : function ( response ) {
76- var html = '<div class="notice notice-error"><p>' + response . error + '</p></div>' ;
77- $ ( '#rootPath' ) . replaceWith ( html ) ;
84+ error ( response ) {
85+ const html =
86+ '<div class="notice notice-error"><p>' +
87+ response . error +
88+ "</p></div>" ;
89+ $ ( "#rootPath" ) . replaceWith ( html ) ;
7890 }
7991 } ) ;
8092 }
@@ -86,8 +98,8 @@ jQuery(document).ready(function ($) {
8698 * @param {* } element
8799 */
88100 function pathClick ( path , element ) {
89- var elementIndex = path . indexOf ( $ ( element ) . data ( 'id' ) ) ;
90- var newPath = path . slice ( 0 , elementIndex + 1 ) ;
101+ const elementIndex = path . indexOf ( $ ( element ) . data ( "id" ) ) ;
102+ const newPath = path . slice ( 0 , elementIndex + 1 ) ;
91103
92104 showDir ( newPath ) ;
93105 }
@@ -99,7 +111,7 @@ jQuery(document).ready(function ($) {
99111 * @param {* } element
100112 */
101113 function dirClick ( path , element ) {
102- var newID = $ ( element ) . data ( 'id' ) ;
114+ const newID = $ ( element ) . data ( "id" ) ;
103115
104116 if ( newID ) {
105117 path . push ( newID ) ;
@@ -110,5 +122,5 @@ jQuery(document).ready(function ($) {
110122 showDir ( path ) ;
111123 }
112124
113- showDir ( sgddRootPathLocalize . path ) ;
114- } ) ;
125+ showDir ( sgddRootPathLocalize . path ) ; //eslint-disable-line no-undef
126+ } ) ( jQuery ) ;
0 commit comments