mirror of
https://github.com/krateng/maloja.git
synced 2025-07-09 03:04:07 -04:00
Updated manual scrobbling, GH-68
This commit is contained in:
parent
c86f3597fd
commit
5bfd1e49dd
@ -64,15 +64,13 @@ function scrobble(artists,title) {
|
|||||||
lastArtists = artists;
|
lastArtists = artists;
|
||||||
lastTrack = title;
|
lastTrack = title;
|
||||||
|
|
||||||
|
var payload = {
|
||||||
var artist = artists.join(";");
|
"artists":artists,
|
||||||
|
"title":title
|
||||||
|
}
|
||||||
|
|
||||||
if (title != "" && artists.length > 0) {
|
if (title != "" && artists.length > 0) {
|
||||||
xhttp = new XMLHttpRequest();
|
neo.xhttpreq("/apis/mlj_1/newscrobble",data=payload,method="POST",callback=scrobbledone,json=true)
|
||||||
xhttp.onreadystatechange = scrobbledone
|
|
||||||
xhttp.open("GET","/api/newscrobble?artist=" + encodeURIComponent(artist) +
|
|
||||||
"&title=" + encodeURIComponent(title), true);
|
|
||||||
xhttp.send();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById("title").value = "";
|
document.getElementById("title").value = "";
|
||||||
@ -83,14 +81,12 @@ function scrobble(artists,title) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function scrobbledone() {
|
function scrobbledone(req) {
|
||||||
if (this.readyState == 4 && this.status == 200) {
|
result = req.response;
|
||||||
result = JSON.parse(this.responseText);
|
txt = result["track"]["title"] + " by " + result["track"]["artists"][0];
|
||||||
txt = result["track"]["title"] + " by " + result["track"]["artists"][0];
|
if (result["track"]["artists"].length > 1) {
|
||||||
if (result["track"]["artists"].length > 1) {
|
txt += " et al.";
|
||||||
txt += " et al.";
|
document.getElementById("notification").innerHTML = "Scrobbled " + txt + "!";
|
||||||
}
|
|
||||||
document.getElementById("notification").innerHTML = "Scrobbled " + txt + "!";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user