Add webring thingy to each page
[website] / webring.js
1 var data = fetch( "https://lavender.software/webring/data.json" )
2 .then( function ( r ) { return r.json() ; } )
3 .then( function ( data ) {
4 console.log(data) ;
5
6 var index = -1 ;
7 for ( var i = 0 ; i < data.length ; i ++ )
8 if ( data[i].id == "mira" )
9 index = i ;
10
11 console.log(index) ;
12
13 if ( index >= 0 ) {
14 var previ = ( index - 1 + data.length ) % data.length ;
15 var nexti = ( index + 1 + data.length ) % data.length ;
16 var prev = document.getElementById( "webring-previous" ) ;
17 var next = document.getElementById( "webring-next" ) ;
18 prev.href = data[previ].url ;
19 prev.textContent = "« " + data[previ].name ;
20 next.href = data[nexti].url ;
21 next.textContent = data[nexti].name + " »" ;
22 }
23 } ) ;