From 7b5ea21241543b0f75d525888da87f763883b1c7 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 19 Aug 2024 19:32:36 +0200 Subject: geht erst mal --- load-status.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 load-status.js (limited to 'load-status.js') diff --git a/load-status.js b/load-status.js new file mode 100644 index 0000000..b10d5e9 --- /dev/null +++ b/load-status.js @@ -0,0 +1,29 @@ +function httpGetAsync(theUrl, callback) +{ + var xmlHttp = new XMLHttpRequest(); + xmlHttp.onreadystatechange = function() { + if (xmlHttp.readyState == 4 && xmlHttp.status == 200) + callback(xmlHttp.responseText); + } + xmlHttp.open("GET", theUrl, true); // true for asynchronous + xmlHttp.send(null); +} + +function displayStatus(statusString) { + let statusElement = document.getElementById('status'); + let status = JSON.parse(statusString); + let tableContent = ""; + columns = ['ID', 'Image', 'Command', 'Mounts', 'Running For', 'State', 'Status']; + tableContent += "\n"; + tableContent += status.map((line) => + "" + columns + .map((column) => "") + .join("") + "" + ).join(""); + statusElement.innerHTML = tableContent + "
" + columns.join("") + "
" + line[column] + "
"; +} + +function getStatus() { + httpGetAsync('/status', displayStatus); +} + -- cgit v1.2.3-70-g09d2