X-Git-Url: https://git-public.kairo.at/?p=lantea.git;a=blobdiff_plain;f=js%2Flibrary.js;h=336238c42c532528d428b15a7d1ba7a97721cb58;hp=3d0c521849c47aff71ee6b551f13be848c1f066b;hb=ba819f24b220ff62afb6ecdb5ff7727631c1d1b5;hpb=867ee0afc0f4af36dc5ec5ca769ee088042c4ebc diff --git a/js/library.js b/js/library.js index 3d0c521..336238c 100644 --- a/js/library.js +++ b/js/library.js @@ -24,8 +24,14 @@ function showLibrary() { 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"] + ")" : ""); + litem.textContent = dtformat(aResult[i]["time_created"]) + " - "; + var llink = document.createElement("a"); + llink.setAttribute("href", gBackendURL + "/track_gpx?id=" + aResult[i]["id"]); + llink.textContent = aResult[i]["comment"]; + litem.appendChild(llink); + if (aResult[i]["devicename"]) { + litem.appendChild(document.createTextNode(" (" + aResult[i]["devicename"] + ")")); + } tlist.appendChild(litem); } } @@ -37,3 +43,15 @@ function hideLibrary() { document.getElementById("libraryArea").classList.add("hidden"); } +function dtformat(aUnixTimestamp) { + // Library display time format: YYYY-MM-DD HH:mm + // Note that JS has millisecond timestamps while standard/unix has seconds. + var tsDate = new Date(aUnixTimestamp * 1000); + // Note that .getUTCMonth() returns a number between 0 and 11 (0 for January)! + return tsDate.getUTCFullYear() + "-" + + (tsDate.getUTCMonth() < 9 ? "0" : "") + (tsDate.getUTCMonth() + 1 ) + "-" + + (tsDate.getUTCDate() < 10 ? "0" : "") + tsDate.getUTCDate() + " " + + (tsDate.getUTCHours() < 10 ? "0" : "") + tsDate.getUTCHours() + ":" + + (tsDate.getUTCMinutes() < 10 ? "0" : "") + tsDate.getUTCMinutes(); +} +