Tidy up webring.js
authorMira Ayre <mi@boxin.space>
Sun, 27 Mar 2022 19:47:18 +0000 (21:47 +0200)
committerMira Ayre <mi@boxin.space>
Sun, 27 Mar 2022 19:47:18 +0000 (21:47 +0200)
webring.js

index 9e8b1ab8622cf94ab4c6422c27cf8c5d2772ed0e..be43ac14b4feed2924f24683412efd9f9864972d 100644 (file)
@@ -1,23 +1,20 @@
 var data = fetch( "https://lavender.software/webring/data.json" )
-       .then( function ( r ) { return r.json() ; } )
-       .then( function ( data ) {
-               console.log(data) ;
+       .then( function ( r ) {
+               let data = r.json() :
 
                var index = -1 ;
                for ( var i = 0 ; i < data.length ; i ++ )
                        if ( data[i].id == "mira" )
                                index = i ;
 
-               console.log(index) ;
-
                if ( index >= 0 ) {
-                       var previ        = ( index - 1 + data.length ) % data.length ;
-                       var nexti        = ( index + 1 + data.length ) % data.length ;
+                       var previ        = ( index - 1 + data.length ) % data.length     ;
+                       var nexti        = ( index + 1 + data.length ) % data.length     ;
                        var prev         = document.getElementById( "webring-previous" ) ;
                        var next         = document.getElementById( "webring-next"     ) ;
-                       prev.href        = data[previ].url  ;
-                       prev.textContent = "« " + data[previ].name ;
-                       next.href        = data[nexti].url       ;
-                       next.textContent = data[nexti].name + " »" ;
+                       prev.href        =        data[previ].url                        ;
+                       prev.textContent = "« " + data[previ].name                       ;
+                       next.href        =        data[nexti].url                        ;
+                       next.textContent =        data[nexti].name + " »"                ;
                }
        } ) ;