From 1e0b1fa7ac2ad0ae07591aca296e3ef33839ef5e Mon Sep 17 00:00:00 2001 From: marwolaethblack Date: Fri, 24 Nov 2017 10:48:31 +0100 Subject: add real time data every 60sec --- web/js/realtime.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 web/js/realtime.js (limited to 'web') diff --git a/web/js/realtime.js b/web/js/realtime.js new file mode 100644 index 0000000..4526e5e --- /dev/null +++ b/web/js/realtime.js @@ -0,0 +1,27 @@ +function update() { + + var data; + + fetch('/latest') + .then(function(resp) { + return resp.json(); + }) + .then(function(response) { + data = response; + var table = document.querySelector('#latest').children; + table[0].textContent = data.TimeStamp; + table[1].textContent = data.Co; + table[2].textContent = data.No; + table[3].textContent = data.So; + + }) + .catch(function(error) { + console.log(error); + }); + + + + +} + +setInterval(update, 60000); -- cgit v1.2.3