update login button when opening menu drawer, this should eliminate login issues
[lantea.git] / js / library.js
CommitLineData
867ee0af
RK
1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5function showLibrary() {
6 document.getElementById("libraryArea").classList.remove("hidden");
7 var tlist = document.getElementById("libTrackList");
8 while (tlist.firstChild) { tlist.removeChild(tlist.firstChild); }
9 var litem = document.createElement("li");
10 var load_img = document.createElement("img");
11 load_img.setAttribute("src", "style/loading_action.png");
12 litem.appendChild(load_img);
13 litem.textContent = "Loading list...";
14 litem.id = "libLoadingItem";
15 tlist.appendChild(litem);
16 fetchBackend("tracks", "GET", null,
17 function(aResult, aStatusCode) {
18 document.getElementById("libLoadingItem").classList.add("hidden");
19 if (aStatusCode >= 400) {
20 var litem = document.createElement("li");
21 litem.textContent = "Error: " + aResult;
22 tlist.appendChild(litem);
23 }
24 else {
25 for (var i = 0; i < aResult.length; i++) {
26 var litem = document.createElement("li");
27 litem.textContent = aResult[i]["time_created"] + " - " + aResult[i]["comment"] +
28 (aResult[i]["devicename"] ? " (" + aResult[i]["devicename"] + ")" : "");
29 tlist.appendChild(litem);
30 }
31 }
32 }
33 );
34}
35
36function hideLibrary() {
37 document.getElementById("libraryArea").classList.add("hidden");
38}
39