From b71067d84fbcfc5436583de27f306c05e114ac1a Mon Sep 17 00:00:00 2001
From: rick <rick@gnous.eu>
Date: Sat, 4 Sep 2021 19:26:14 +0200
Subject: [PATCH] refactor: rename function and remove useless code
---
server.go | 1 -
static/script.js | 38 ++++----------------------------------
2 files changed, 4 insertions(+), 35 deletions(-)
diff --git a/server.go b/server.go
index 27f3651..b65089d 100644
--- a/server.go
+++ b/server.go
@@ -93,7 +93,6 @@ func getAllTracksPlaylist(id string, offset int) (SpotifyPlaylist, error) {
}
ret = *playlist
- fmt.Printf("\n%d cc %d\n", ret.Total, offset)
if ret.Total > offset {
r, e := getAllTracksPlaylist(id, offset + 100)
if e != nil {
diff --git a/static/script.js b/static/script.js
index 3035105..dbe6cad 100644
--- a/static/script.js
+++ b/static/script.js
@@ -1,6 +1,5 @@
const spotifyText = document.createTextNode("Spotify");
const bandcampText = document.createTextNode("Bandcamp");
-//const tab = document.getElementById("my-list");
async function addCell(id, elem) {
let tab = document.getElementById(id), tmpLink, artist, album, newRow;
@@ -29,7 +28,7 @@ async function addCell(id, elem) {
}
}
-async function test() {
+async function refreshArray() {
const data = await fetch('/refresh').then(response => response.json());
if (data != null) {
document.getElementById("nb-fait").textContent = data.done;
@@ -52,37 +51,6 @@ async function test() {
addCell("notfound", elem);
}
}
- /*
- 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;
-
- /*
- let tmp = document.createTextNode(elem);
- let newP = document.createElement("p");
- newP.appendChild(tmp);
- document.getElementById("my-list").appendChild(newP);
-
- 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);
- }
- }
-*/
-
if (data.done === data.todo) {
document.getElementById("inf-loader").remove();
@@ -91,8 +59,10 @@ async function test() {
}
}
+/*
window.onbeforeunload = function() {
return "Vous perdrez tous les artistes trouvés en rafraichissant la page."
}
+*/
-const refreshList = setInterval(test, 5000);
+const refreshList = setInterval(refreshArray, 5000);