11
22async function show_error ( message ) {
3- let div = document . getElementById ( 'auth-fail' ) ;
4- div . style . display = "block" ;
3+ let div = document . getElementById ( 'error-alert' ) ;
54 div . innerHTML = message ;
5+ div . style . display = "block" ;
66}
77
88async function init_main ( ) {
99 console . log ( "function: init_main" ) ;
1010 $ ( 'html' ) . hide ( ) . fadeIn ( 'slow' ) ;
11-
1211 const url = ( await chrome . storage . local . get ( 'url' ) ) [ 'url' ] ;
1312 const token = ( await chrome . storage . local . get ( 'token' ) ) [ 'token' ] ;
1413 console . log ( 'url: ' + url ) ;
1514 console . log ( 'token: ' + token ) ;
15+ if ( url === '' || token === '' ) {
16+ return await show_error ( 'No URL or Token.' ) ;
17+ }
1618
1719 let headers = { 'Authorization' : token } ;
1820 let options = { method : 'GET' , headers : headers , cache : 'no-cache' }
@@ -27,30 +29,28 @@ async function init_main () {
2729 }
2830 console . log ( 'Status: ' + response . status ) ;
2931 console . log ( response ) ;
30- if ( data === undefined ) {
31- return await show_error ( 'Response Data Undefined.' ) ;
32- }
32+
3333 if ( ! response . ok ) {
3434 console . log ( 'error: ' + data [ 'error' ] ) ;
3535 return await show_error ( data [ 'error' ] ) ;
3636 }
37+ if ( data === undefined ) {
38+ return await show_error ( 'Response Data Undefined.' ) ;
39+ }
3740 if ( data . length === 0 ) {
3841 return await show_error ( 'No Files Returned.' ) ;
3942 }
4043
4144 console . log ( data ) ;
4245 let tbodyRef = document . getElementById ( 'recent' ) . getElementsByTagName ( 'tbody' ) [ 0 ] ;
4346 for ( let i in data ) {
44- // console.log('url: ' + data[i]);
4547 let name = data [ i ] . split ( '/' ) . reverse ( ) [ 0 ] ;
46- // console.log('name: ' + name);
4748 let a = document . createElement ( 'a' ) ;
4849 let linkText = document . createTextNode ( name ) ;
4950 a . appendChild ( linkText ) ;
5051 a . title = name ;
5152 a . href = data [ i ] ;
5253 a . target = '_blank' ;
53-
5454 let newRow = tbodyRef . insertRow ( ) ;
5555 let newCell = newRow . insertCell ( ) ;
5656 let count = document . createTextNode ( i + ' - ' ) ;
0 commit comments