11const parser = new DOMParser ( ) ;
2- const number_gpu_max = 8
2+ const number_gpu_max = 8 ;
33
4- let resources = [ "gtx1080ti" , "rtx3090" , "teslav100" ] ;
4+ const resources = [ "gtx1080ti" , "rtx3090" , "teslav100" ] ;
55for ( const resource of resources ) {
6- fetch ( " https://bitahub.ustc.edu.cn/resources/" + resource )
6+ fetch ( ` https://bitahub.ustc.edu.cn/resources/${ resource } ` )
77 . then ( ( response ) => {
88 if ( ! response . ok ) {
99 throw new Error ( "Network failure" ) ;
@@ -12,23 +12,35 @@ for (const resource of resources) {
1212 } )
1313 . then ( ( html ) => {
1414 const doc = parser . parseFromString ( html , "text/html" ) ;
15- let numbers = [ ] ;
15+ const numbers = [ ] ;
1616 for ( const [ i , td ] of doc . querySelectorAll ( "td" ) . entries ( ) ) {
1717 if ( i % 7 === 1 ) {
18- numbers . push ( Number ( td . textContent ) )
18+ numbers . push ( Number ( td . textContent ) ) ;
1919 }
2020 }
21- const tr = document . querySelector ( "#" + resource )
21+ const tr = document . querySelector ( `# ${ resource } ` ) ;
2222 for ( let i = 1 , len = number_gpu_max + 1 ; i < len ; i ++ ) {
23- for ( const td of tr . querySelectorAll ( ".n" + i ) ) {
24- td . textContent = numbers . filter ( x => x == i ) . length
23+ for ( const td of tr . querySelectorAll ( `.n ${ i } ` ) ) {
24+ td . textContent = numbers . filter ( ( x ) => x === i ) . length ;
2525 }
2626 }
27- for ( const element of tr . querySelectorAll ( Array . from ( { length : number_gpu_max } , ( _ , index ) => ".n" + ( index + 1 ) ) . join ( ) ) ) {
27+ for ( const element of tr . querySelectorAll (
28+ Array . from (
29+ { length : number_gpu_max } ,
30+ ( _ , index ) => `.n${ index + 1 } ` ,
31+ ) . join ( ) ,
32+ ) ) {
2833 const number = Number ( element . textContent ) ;
2934 if ( number === 0 ) {
3035 element . classList . add ( "zero" ) ;
31- } else if ( number >= numbers . reduce ( ( accumulator , currentValue ) => accumulator + currentValue , 0 ) / ( number_gpu_max + 1 ) ) {
36+ } else if (
37+ number >=
38+ numbers . reduce (
39+ ( accumulator , currentValue ) => accumulator + currentValue ,
40+ 0 ,
41+ ) /
42+ ( number_gpu_max + 1 )
43+ ) {
3244 element . classList . add ( "full" ) ;
3345 }
3446 }
0 commit comments