X-Git-Url: https://git-public.kairo.at/?a=blobdiff_plain;ds=sidebyside;f=js%2Flibrary.js;fp=js%2Flibrary.js;h=3d0c521849c47aff71ee6b551f13be848c1f066b;hb=867ee0afc0f4af36dc5ec5ca769ee088042c4ebc;hp=0000000000000000000000000000000000000000;hpb=269f3a29be5987af2e7feb63bded550770c2c234;p=lantea.git diff --git a/js/library.js b/js/library.js new file mode 100644 index 0000000..3d0c521 --- /dev/null +++ b/js/library.js @@ -0,0 +1,39 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +function showLibrary() { + document.getElementById("libraryArea").classList.remove("hidden"); + var tlist = document.getElementById("libTrackList"); + while (tlist.firstChild) { tlist.removeChild(tlist.firstChild); } + var litem = document.createElement("li"); + var load_img = document.createElement("img"); + load_img.setAttribute("src", "style/loading_action.png"); + litem.appendChild(load_img); + litem.textContent = "Loading list..."; + litem.id = "libLoadingItem"; + tlist.appendChild(litem); + fetchBackend("tracks", "GET", null, + function(aResult, aStatusCode) { + document.getElementById("libLoadingItem").classList.add("hidden"); + if (aStatusCode >= 400) { + var litem = document.createElement("li"); + litem.textContent = "Error: " + aResult; + tlist.appendChild(litem); + } + else { + for (var i = 0; i < aResult.length; i++) { + var litem = document.createElement("li"); + litem.textContent = aResult[i]["time_created"] + " - " + aResult[i]["comment"] + + (aResult[i]["devicename"] ? " (" + aResult[i]["devicename"] + ")" : ""); + tlist.appendChild(litem); + } + } + } + ); +} + +function hideLibrary() { + document.getElementById("libraryArea").classList.add("hidden"); +} +