2021-08-29 21:12:17 +02:00
<!DOCTYPE html>
< head >
< link rel = "stylesheet" href = "/css/style.css" >
2021-08-31 18:58:29 +02:00
< link rel = "stylesheet" href = "/css/loader.css" >
2021-08-29 21:12:17 +02:00
< / head >
< html >
< body >
< h1 > Spotify To Bandcamp< / h1 >
< p > Recherche dans une playlist les artistes se trouvant aussi sur Bandcamp !< / p >
< hr / >
2021-08-31 18:39:56 +02:00
< div id = "inf-loader" >
< div id = "loader" > < / div >
2021-08-31 18:58:29 +02:00
< p > La playlist est en cours de traitement [< span id = "nb-fait" > 0< / span > /< span id = "nb-total" > 0< / span > ]…< / p >
< p > < a href = "https://codepen.io/brunjo/pen/bNEWjV" > Code Source du loader< / a > sous < a href = "https://blog.codepen.io/documentation/licensing/" > licence MIT< / a > .< / p >
2021-08-31 18:39:56 +02:00
< / div >
2021-09-01 00:34:07 +02:00
< div >
< table id = "my-list" >
< tr >
< th > Artiste< / th >
< th > Album< / th >
< th > Spotify< / th >
< th > Bandcamp< / th >
< / tr >
< / table >
2021-08-29 21:12:17 +02:00
< / div >
2021-09-01 01:33:49 +02:00
< hr / >
< footer >
< img src = "https://www.gnu.org/graphics/gplv3-or-later-sm.png" alt = "logo GPL3" * >
< p > Ce site est en aucun cas affilié avec Bandcamp ou Spotify.< / p >
< / footer >
2021-08-29 21:12:17 +02:00
< / body >
< script >
2021-09-01 00:34:07 +02:00
const spotifyText = document.createTextNode("Spotify");
const bandcampText = document.createTextNode("Bandcamp");
const tab = document.getElementById("my-list");
2021-08-29 21:12:17 +02:00
async function test() {
const data = await fetch('/refresh').then(response => response.json());
if (data != null) {
2021-09-01 00:34:07 +02:00
if (data.urls != null) {
var newRow, artist, album, tmpLink;
for (const elem of data.urls) {
artist = document.createTextNode(elem.artist);
album = document.createTextNode(elem.album);
tmpLink = document.createElement("a");
tmpLink.appendChild(spotifyText.cloneNode());
tmpLink.title = "Lien Spotify";
tmpLink.href = elem.spotifyurl;
/*
2021-08-31 18:39:56 +02:00
let tmp = document.createTextNode(elem);
let newP = document.createElement("p");
newP.appendChild(tmp);
document.getElementById("my-list").appendChild(newP);
2021-09-01 00:34:07 +02:00
*/
newRow = tab.insertRow(-1);
newRow.insertCell(0).appendChild(artist);
newRow.insertCell(1).appendChild(album);
newRow.insertCell(2).appendChild(tmpLink);
tmpLink = document.createElement("a");
tmpLink.appendChild(bandcampText.cloneNode());
tmpLink.title = "Lien Bandcamp";
tmpLink.href = elem.bandcampurl;
newRow.insertCell(3).appendChild(tmpLink);
2021-08-31 18:39:56 +02:00
}
2021-08-29 21:12:17 +02:00
}
2021-08-31 18:39:56 +02:00
document.getElementById("nb-fait").textContent = data.done;
document.getElementById("nb-total").textContent = data.todo;
2021-08-31 18:58:29 +02:00
if (data.done === data.todo) {
document.getElementById("inf-loader").remove();
clearInterval(refreshList);
}
2021-08-29 21:12:17 +02:00
}
}
2021-08-31 14:44:12 +02:00
window.onbeforeunload = function() {
return "Vous perdrez tous les artistes trouvés en rafraichissant la page."
}
2021-08-31 18:39:56 +02:00
const refreshList = setInterval(test, 3000);
2021-08-29 21:12:17 +02:00
< / script >
< html >