mirror of
https://github.com/krateng/maloja.git
synced 2025-06-15 14:52:32 +03:00
Merge branch 'feature-albums' into next_minor_version
This commit is contained in:
commit
e6590265f6
@ -26,6 +26,21 @@
|
|||||||
<input placeholder='Enter to scrobble' class='simpleinput' id='title' onKeydown='scrobbleIfEnter(event)' />
|
<input placeholder='Enter to scrobble' class='simpleinput' id='title' onKeydown='scrobbleIfEnter(event)' />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="padding-right:7px;">
|
||||||
|
Album artists (Optional):
|
||||||
|
</td><td id="albumartists_td">
|
||||||
|
<input placeholder='Separate with Enter' class='simpleinput' id='albumartists' onKeydown='keyDetect2(event)' onblur='addEnteredAlbumartist()' />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="padding-right:7px;">
|
||||||
|
Album (Optional):
|
||||||
|
</td><td>
|
||||||
|
<input placeholder='Enter to scrobble' class='simpleinput' id='album' onKeydown='scrobbleIfEnter(event)' />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
|
@ -10,11 +10,23 @@ function addArtist(artist) {
|
|||||||
document.getElementById("artists_td").insertBefore(artistelement,newartistfield);
|
document.getElementById("artists_td").insertBefore(artistelement,newartistfield);
|
||||||
newartistfield.placeholder = "Backspace to remove last"
|
newartistfield.placeholder = "Backspace to remove last"
|
||||||
}
|
}
|
||||||
|
function addAlbumartist(artist) {
|
||||||
|
var newartistfield = document.getElementById("albumartists");
|
||||||
|
var artistelement = document.createElement("span");
|
||||||
|
artistelement.innerHTML = artist;
|
||||||
|
artistelement.style = "padding:5px;";
|
||||||
|
document.getElementById("albumartists_td").insertBefore(artistelement,newartistfield);
|
||||||
|
newartistfield.placeholder = "Backspace to remove last"
|
||||||
|
}
|
||||||
|
|
||||||
function keyDetect(event) {
|
function keyDetect(event) {
|
||||||
if (event.key === "Enter" || event.key === "Tab") { addEnteredArtist() }
|
if (event.key === "Enter" || event.key === "Tab") { addEnteredArtist() }
|
||||||
if (event.key === "Backspace" && document.getElementById("artists").value == "") { removeArtist() }
|
if (event.key === "Backspace" && document.getElementById("artists").value == "") { removeArtist() }
|
||||||
}
|
}
|
||||||
|
function keyDetect2(event) {
|
||||||
|
if (event.key === "Enter" || event.key === "Tab") { addEnteredAlbumartist() }
|
||||||
|
if (event.key === "Backspace" && document.getElementById("albumartists").value == "") { removeAlbumartist() }
|
||||||
|
}
|
||||||
|
|
||||||
function addEnteredArtist() {
|
function addEnteredArtist() {
|
||||||
var newartistfield = document.getElementById("artists");
|
var newartistfield = document.getElementById("artists");
|
||||||
@ -24,6 +36,14 @@ function addEnteredArtist() {
|
|||||||
addArtist(newartist);
|
addArtist(newartist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function addEnteredAlbumartist() {
|
||||||
|
var newartistfield = document.getElementById("albumartists");
|
||||||
|
var newartist = newartistfield.value.trim();
|
||||||
|
newartistfield.value = "";
|
||||||
|
if (newartist != "") {
|
||||||
|
addAlbumartist(newartist);
|
||||||
|
}
|
||||||
|
}
|
||||||
function removeArtist() {
|
function removeArtist() {
|
||||||
var artists = document.getElementById("artists_td").getElementsByTagName("span")
|
var artists = document.getElementById("artists_td").getElementsByTagName("span")
|
||||||
var lastartist = artists[artists.length-1]
|
var lastartist = artists[artists.length-1]
|
||||||
@ -32,14 +52,28 @@ function removeArtist() {
|
|||||||
document.getElementById("artists").placeholder = "Separate with Enter"
|
document.getElementById("artists").placeholder = "Separate with Enter"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function removeAlbumartist() {
|
||||||
|
var artists = document.getElementById("albumartists_td").getElementsByTagName("span")
|
||||||
|
var lastartist = artists[artists.length-1]
|
||||||
|
document.getElementById("albumartists_td").removeChild(lastartist);
|
||||||
|
if (artists.length < 1) {
|
||||||
|
document.getElementById("albumartists").placeholder = "Separate with Enter"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function clear() {
|
function clear() {
|
||||||
document.getElementById("title").value = "";
|
document.getElementById("title").value = "";
|
||||||
document.getElementById("artists").value = "";
|
document.getElementById("artists").value = "";
|
||||||
|
document.getElementById("album").value = "";
|
||||||
|
document.getElementById("albumartists").value = "";
|
||||||
var artists = document.getElementById("artists_td").getElementsByTagName("span")
|
var artists = document.getElementById("artists_td").getElementsByTagName("span")
|
||||||
while (artists.length > 0) {
|
while (artists.length > 0) {
|
||||||
removeArtist();
|
removeArtist();
|
||||||
}
|
}
|
||||||
|
var albumartists = document.getElementById("albumartists_td").getElementsByTagName("span")
|
||||||
|
while (albumartists.length > 0) {
|
||||||
|
removeAlbumartist();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -55,18 +89,30 @@ function scrobbleNew() {
|
|||||||
for (let node of artistnodes) {
|
for (let node of artistnodes) {
|
||||||
artists.push(node.textContent);
|
artists.push(node.textContent);
|
||||||
}
|
}
|
||||||
var title = document.getElementById("title").value;
|
|
||||||
scrobble(artists,title);
|
var albumartistnodes = document.getElementById("albumartists_td").getElementsByTagName("span");
|
||||||
|
var albumartists = [];
|
||||||
|
for (let node of albumartistnodes) {
|
||||||
|
albumartists.push(node.textContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
function scrobble(artists,title) {
|
var title = document.getElementById("title").value;
|
||||||
|
var album = document.getElementById("album").value;
|
||||||
|
scrobble(artists,title,albumartists,album);
|
||||||
|
}
|
||||||
|
|
||||||
|
function scrobble(artists,title,albumartists,album) {
|
||||||
|
|
||||||
lastArtists = artists;
|
lastArtists = artists;
|
||||||
lastTrack = title;
|
lastTrack = title;
|
||||||
|
lastAlbum = album;
|
||||||
|
lastAlbumartists = albumartists;
|
||||||
|
|
||||||
var payload = {
|
var payload = {
|
||||||
"artists":artists,
|
"artists":artists,
|
||||||
"title":title
|
"title":title,
|
||||||
|
"albumartists": albumartists,
|
||||||
|
"album": album
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -74,12 +120,7 @@ function scrobble(artists,title) {
|
|||||||
neo.xhttpreq("/apis/mlj_1/newscrobble",data=payload,method="POST",callback=notifyCallback,json=true)
|
neo.xhttpreq("/apis/mlj_1/newscrobble",data=payload,method="POST",callback=notifyCallback,json=true)
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById("title").value = "";
|
clear()
|
||||||
document.getElementById("artists").value = "";
|
|
||||||
var artists = document.getElementById("artists_td").getElementsByTagName("span");
|
|
||||||
while (artists.length > 0) {
|
|
||||||
removeArtist();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function scrobbledone(req) {
|
function scrobbledone(req) {
|
||||||
@ -98,6 +139,10 @@ function repeatLast() {
|
|||||||
addArtist(artist);
|
addArtist(artist);
|
||||||
}
|
}
|
||||||
document.getElementById("title").value = lastTrack;
|
document.getElementById("title").value = lastTrack;
|
||||||
|
for (let artist of lastAlbumartists) {
|
||||||
|
addAlbumartist(artist);
|
||||||
|
}
|
||||||
|
document.getElementById("album").value = lastAlbum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user