From 1838a33016807e6a5403d5a893056929fa435971 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Sat, 28 May 2016 18:55:44 +0200 Subject: front: Tweak logbook and info-box styles and feel - Don't overload the logbook overlay - Neater date formatting (ugh, I hate that we need to do this) - Caption for the logbook in the info box --- web/js/nms-oplog.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'web/js/nms-oplog.js') diff --git a/web/js/nms-oplog.js b/web/js/nms-oplog.js index 83bda69..740385c 100644 --- a/web/js/nms-oplog.js +++ b/web/js/nms-oplog.js @@ -54,7 +54,7 @@ nmsOplog.commit = function() { } nmsOplog.updateComments = function() { - nmsOplog._updateComments(5,"-mini","time"); + nmsOplog._updateComments(3,"-mini","time",100); nmsOplog._updateComments(0,"","timestamp"); } @@ -71,7 +71,7 @@ nmsOplog.getSwitchLogs = function(sw) { return logs; } -nmsOplog._updateComments = function(limit,prefix,timefield) { +nmsOplog._updateComments = function(limit,prefix,timefield,cutoff) { var table = document.createElement("table"); var tr; var td1; @@ -89,9 +89,18 @@ nmsOplog._updateComments = function(limit,prefix,timefield) { if (timefield == "time") { td1.textContent = date.toTimeString().replace(/:\d\d .*$/,""); } else { - td1.textContent = date.toString(); + let month = date.getMonth() + 1; + let day = date.getDate(); + let tmp = (date.getYear() + 1900) + "-" + (month < 10 ? "0": "") + month + "-" + (day < 10 ? "0" : "") + day + " " + date.toTimeString().replace(/:\d\d .*$/,""); + td1.textContent = tmp; } - td2.textContent = "[" + nmsData['oplog']['oplog'][v]['username'] + "] " + nmsData['oplog']['oplog'][v]['log']; + td1.classList.add("left"); + let data = nmsData['oplog']['oplog'][v]['log']; + if (cutoff && data.length > cutoff) { + data = data.slice(0,cutoff); + data = data + "(...)"; + } + td2.textContent = "[" + nmsData['oplog']['oplog'][v]['username'] + "] " + data; td2.hiddenthing = v; td2.onclick = function(e){ var x = document.getElementById("searchbox"); var v = e.path[0].hiddenthing; x.value = nmsData['oplog']['oplog'][v]['systems']; x.oninput(); } if (++i == limit) -- cgit v1.2.3