Andrew Boyson / oldheating

Dependencies:   net 1-wire lpc1768 crypto clock web fram log

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers web-system-script.inc Source File

web-system-script.inc

00001 "//System script\n"
00002 "'use strict';\n"
00003 "\n"
00004 "let serverName   = '';\n"
00005 "let fileName     = '';\n"
00006 "let readInterval = 0;\n"
00007 "let writeSize    = 0;\n"
00008 "let count        = 0;\n"
00009 "let startTime    = null;\n"
00010 "let framUsed     = 0;\n"
00011 "\n"
00012 "function parse()\n"
00013 "{\n"
00014 "    let lines = Ajax.response.split('\\n');\n"
00015 "    serverName   =                       lines[0];\n"
00016 "    fileName     =                       lines[1];\n"
00017 "    readInterval = Ajax.hexToSignedInt16(lines[2]);\n"
00018 "    writeSize    = Ajax.hexToSignedInt16(lines[3]);\n"
00019 "    count        = Ajax.hexToSignedInt16(lines[4]);\n"
00020 "    startTime    =     new Date(parseInt(lines[5], 16) * 1000);\n"
00021 "    framUsed     = Ajax.hexToSignedInt16(lines[6]);\n"
00022 "}\n"
00023 "function display()\n"
00024 "{\n"
00025 "    let elem;\n"
00026 "    elem = Ajax.getElementOrNull('ajax-server-name'  ); if (elem) elem.value = serverName;\n"
00027 "    elem = Ajax.getElementOrNull('ajax-file-name'    ); if (elem) elem.value = fileName;\n"
00028 "    elem = Ajax.getElementOrNull('ajax-read-interval'); if (elem) elem.value = readInterval;\n"
00029 "    elem = Ajax.getElementOrNull('ajax-write-size'   ); if (elem) elem.value = writeSize;\n"
00030 "    elem = Ajax.getElementOrNull('ajax-count'        ); if (elem) elem.textContent = count;\n"
00031 "    elem = Ajax.getElementOrNull('ajax-start-time'   ); if (elem) elem.textContent = startTime.toISOString().substr(0, 19).split('T').join(' ') + ' UTC';\n"
00032 "    elem = Ajax.getElementOrNull('ajax-fram-used'    ); if (elem) elem.textContent = framUsed;\n"
00033 "}\n"
00034 "\n"
00035 "Ajax.server     = '/system-ajax';\n"
00036 "Ajax.onResponse = function() { parse(); display(); };\n"
00037 "Ajax.init();\n"
00038 ""