From fa910b8e62f27e54312dff6d4445baabd34d805d Mon Sep 17 00:00:00 2001 From: Roland Stigge Date: Wed, 10 Jan 2018 22:42:44 +0100 Subject: Add read only mode --- html/webbox.js | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'html/webbox.js') diff --git a/html/webbox.js b/html/webbox.js index 296429b..40a7a1a 100644 --- a/html/webbox.js +++ b/html/webbox.js @@ -31,9 +31,9 @@ function loadContents(dir) { } result += "" + type + "" + listElements[i].childNodes[0].nodeValue + ""; + "onmousedown=\"entryMouseDown('" + listElements[i].textContent + "')\" " + + "onmouseup=\"entryMouseUp('" + listElements[i].textContent + "')\"" + + ">" + type + "" + listElements[i].textContent + ""; } } @@ -224,6 +224,16 @@ function hideMenu() { document.getElementById("menuwindow").style.display = 'none'; } +// if readOnly = "1", disable respective controls since this setting is global and constant +function prepareReadOnly(readOnly) { + if (readOnly == "1") { + var writecommands = document.getElementsByClassName("writecommand"); + for (var i = 0; i < writecommands.length; i++) { + writecommands[i].style.display = "none"; + } + } +} + function initMainpage() { setCurrentDir("/"); @@ -248,13 +258,23 @@ function initMainpage() { var xhrTitle = new XMLHttpRequest(); xhrTitle.onreadystatechange = function() { - if (this.readyState != 4 || this.status != 200) { + if (this.readyState != 4) { return; } - document.getElementsByClassName("title")[0].innerHTML = xhrTitle.responseText; + if (this.status != 200) { + document.getElementsByClassName("title")[0].innerHTML = "HTTP error"; + return; + } + + var serverInfo = xhrTitle.responseXML; + var title = serverInfo.getElementsByTagName("title")[0].textContent; + document.getElementsByClassName("title")[0].innerHTML = title; + + var readOnly = serverInfo.getElementsByTagName("readonly")[0].textContent; + prepareReadOnly(readOnly); } - xhrTitle.open("GET", "/bin/query?command=title", true); + xhrTitle.open("GET", "/bin/query?command=server-info", true); xhrTitle.send(); // load footer -- cgit v1.2.3