Dependencies: 1-wire clock crypto fram log lpc1768 net web wiz mbed
web-this/system/web-system-script.js@8:8ac076ce51af, 2022-11-12 (annotated)
- Committer:
- andrewboyson
- Date:
- Sat Nov 12 10:03:38 2022 +0000
- Revision:
- 8:8ac076ce51af
- Parent:
- 0:22b158d3c76f
Updated LPC1768 library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andrewboyson | 0:22b158d3c76f | 1 | //System script |
andrewboyson | 0:22b158d3c76f | 2 | 'use strict'; |
andrewboyson | 0:22b158d3c76f | 3 | |
andrewboyson | 0:22b158d3c76f | 4 | let serverName = ''; |
andrewboyson | 0:22b158d3c76f | 5 | let fileName = ''; |
andrewboyson | 0:22b158d3c76f | 6 | let readInterval = 0; |
andrewboyson | 0:22b158d3c76f | 7 | let writeSize = 0; |
andrewboyson | 0:22b158d3c76f | 8 | let count = 0; |
andrewboyson | 0:22b158d3c76f | 9 | let startTime = null; |
andrewboyson | 0:22b158d3c76f | 10 | let framUsed = 0; |
andrewboyson | 0:22b158d3c76f | 11 | |
andrewboyson | 0:22b158d3c76f | 12 | function parse() |
andrewboyson | 0:22b158d3c76f | 13 | { |
andrewboyson | 0:22b158d3c76f | 14 | let lines = Ajax.response.split('\n'); |
andrewboyson | 0:22b158d3c76f | 15 | serverName = lines[0]; |
andrewboyson | 0:22b158d3c76f | 16 | fileName = lines[1]; |
andrewboyson | 0:22b158d3c76f | 17 | readInterval = Ajax.hexToSignedInt16(lines[2]); |
andrewboyson | 0:22b158d3c76f | 18 | writeSize = Ajax.hexToSignedInt16(lines[3]); |
andrewboyson | 0:22b158d3c76f | 19 | count = Ajax.hexToSignedInt16(lines[4]); |
andrewboyson | 0:22b158d3c76f | 20 | startTime = new Date(parseInt(lines[5], 16) * 1000); |
andrewboyson | 0:22b158d3c76f | 21 | framUsed = Ajax.hexToSignedInt16(lines[6]); |
andrewboyson | 0:22b158d3c76f | 22 | } |
andrewboyson | 0:22b158d3c76f | 23 | function display() |
andrewboyson | 0:22b158d3c76f | 24 | { |
andrewboyson | 0:22b158d3c76f | 25 | let elem; |
andrewboyson | 0:22b158d3c76f | 26 | elem = Ajax.getElementOrNull('ajax-server-name' ); if (elem) elem.value = serverName; |
andrewboyson | 0:22b158d3c76f | 27 | elem = Ajax.getElementOrNull('ajax-file-name' ); if (elem) elem.value = fileName; |
andrewboyson | 0:22b158d3c76f | 28 | elem = Ajax.getElementOrNull('ajax-read-interval'); if (elem) elem.value = readInterval; |
andrewboyson | 0:22b158d3c76f | 29 | elem = Ajax.getElementOrNull('ajax-write-size' ); if (elem) elem.value = writeSize; |
andrewboyson | 0:22b158d3c76f | 30 | elem = Ajax.getElementOrNull('ajax-count' ); if (elem) elem.textContent = count; |
andrewboyson | 0:22b158d3c76f | 31 | elem = Ajax.getElementOrNull('ajax-start-time' ); if (elem) elem.textContent = startTime.toISOString().substr(0, 19).split('T').join(' ') + ' UTC'; |
andrewboyson | 0:22b158d3c76f | 32 | elem = Ajax.getElementOrNull('ajax-fram-used' ); if (elem) elem.textContent = framUsed; |
andrewboyson | 0:22b158d3c76f | 33 | } |
andrewboyson | 0:22b158d3c76f | 34 | |
andrewboyson | 0:22b158d3c76f | 35 | Ajax.server = '/system-ajax'; |
andrewboyson | 0:22b158d3c76f | 36 | Ajax.onResponse = function() { parse(); display(); }; |
andrewboyson | 0:22b158d3c76f | 37 | Ajax.init(); |