Andrew Boyson / web

Dependents:   oldheating gps motorhome heating

Committer:
andrewboyson
Date:
Thu Apr 02 19:10:57 2020 +0000
Revision:
136:be1d42268b5d
Parent:
110:8ab752842d25
Child:
144:7106252b7abf
Modified the IPv4 and IPv6 pages to display the resolution indexes for cross referencing against the TCP page

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewboyson 96:eb2eb75bad0f 1 "//Net4 script\n"
andrewboyson 86:f3c9beec4ee7 2 "'use strict';\n"
andrewboyson 86:f3c9beec4ee7 3 "\n"
andrewboyson 95:8c9dda8a0caf 4 "let localIp = '';\n"
andrewboyson 95:8c9dda8a0caf 5 "let domainName = '';\n"
andrewboyson 95:8c9dda8a0caf 6 "let hostName = '';\n"
andrewboyson 95:8c9dda8a0caf 7 "let ntpIp = '';\n"
andrewboyson 95:8c9dda8a0caf 8 "let dnsIp = '';\n"
andrewboyson 95:8c9dda8a0caf 9 "let dhcpIp = '';\n"
andrewboyson 95:8c9dda8a0caf 10 "let routerIp = '';\n"
andrewboyson 95:8c9dda8a0caf 11 "let subnetMask = '';\n"
andrewboyson 95:8c9dda8a0caf 12 "let broadcastIp = '';\n"
andrewboyson 95:8c9dda8a0caf 13 "let leaseTime = '';\n"
andrewboyson 95:8c9dda8a0caf 14 "let renewalT1 = '';\n"
andrewboyson 95:8c9dda8a0caf 15 "let renewalt2 = '';\n"
andrewboyson 95:8c9dda8a0caf 16 "let elapsed = '';\n"
andrewboyson 95:8c9dda8a0caf 17 "let arp = '';\n"
andrewboyson 95:8c9dda8a0caf 18 "let dns = '';\n"
andrewboyson 86:f3c9beec4ee7 19 "\n"
andrewboyson 88:2857259fc2b4 20 "function parseArpLine(line)\n"
andrewboyson 88:2857259fc2b4 21 "{\n"
andrewboyson 88:2857259fc2b4 22 " if (line.length == 0) return;\n"
andrewboyson 136:be1d42268b5d 23 " let fields = line.split('\\t');\n"
andrewboyson 136:be1d42268b5d 24 " \n"
andrewboyson 136:be1d42268b5d 25 " arp += parseInt(fields[0], 16).toString().padStart(2, ' ');\n"
andrewboyson 136:be1d42268b5d 26 " \n"
andrewboyson 136:be1d42268b5d 27 " let minutes = parseInt(fields[1], 16) / 1000 / 60;\n"
andrewboyson 88:2857259fc2b4 28 " arp += Math.floor(minutes).toString().padStart(4, ' ');\n"
andrewboyson 136:be1d42268b5d 29 " \n"
andrewboyson 88:2857259fc2b4 30 " arp += ' ';\n"
andrewboyson 136:be1d42268b5d 31 " arp += Net.makeIp4(fields[2]).padEnd(15, ' ');\n"
andrewboyson 136:be1d42268b5d 32 " \n"
andrewboyson 88:2857259fc2b4 33 " arp += ' ';\n"
andrewboyson 136:be1d42268b5d 34 " arp += Net.makeMac(fields[3]);\n"
andrewboyson 136:be1d42268b5d 35 " \n"
andrewboyson 88:2857259fc2b4 36 " arp += '\\r\\n';\n"
andrewboyson 88:2857259fc2b4 37 "}\n"
andrewboyson 88:2857259fc2b4 38 "function parseDnsLine(line)\n"
andrewboyson 88:2857259fc2b4 39 "{\n"
andrewboyson 88:2857259fc2b4 40 " if (line.length == 0) return;\n"
andrewboyson 136:be1d42268b5d 41 " let fields = line.split('\\t');\n"
andrewboyson 136:be1d42268b5d 42 " \n"
andrewboyson 136:be1d42268b5d 43 " dns += parseInt(fields[0], 16).toString().padStart(2, ' ');\n"
andrewboyson 136:be1d42268b5d 44 " \n"
andrewboyson 136:be1d42268b5d 45 " let minutes = parseInt(fields[1], 16) / 1000 / 60;\n"
andrewboyson 88:2857259fc2b4 46 " dns += Math.floor(minutes).toString().padStart(4, ' ');\n"
andrewboyson 88:2857259fc2b4 47 " dns += ' ';\n"
andrewboyson 136:be1d42268b5d 48 " dns += Net.makeIp4(fields[2]).padEnd(15, ' ');\n"
andrewboyson 88:2857259fc2b4 49 " dns += ' ';\n"
andrewboyson 136:be1d42268b5d 50 " dns += fields[3];\n"
andrewboyson 88:2857259fc2b4 51 " dns += ' ';\n"
andrewboyson 136:be1d42268b5d 52 " dns += fields[4];\n"
andrewboyson 88:2857259fc2b4 53 " dns += '\\r\\n';\n"
andrewboyson 88:2857259fc2b4 54 "}\n"
andrewboyson 88:2857259fc2b4 55 "function parseArpLines(text)\n"
andrewboyson 88:2857259fc2b4 56 "{\n"
andrewboyson 88:2857259fc2b4 57 " arp = '';\n"
andrewboyson 88:2857259fc2b4 58 " text.split('\\n').forEach(parseArpLine);\n"
andrewboyson 88:2857259fc2b4 59 "}\n"
andrewboyson 95:8c9dda8a0caf 60 "function parseDnsLines(text)\n"
andrewboyson 95:8c9dda8a0caf 61 "{\n"
andrewboyson 95:8c9dda8a0caf 62 " dns = '';\n"
andrewboyson 95:8c9dda8a0caf 63 " text.split('\\n').forEach(parseDnsLine);\n"
andrewboyson 95:8c9dda8a0caf 64 "}\n"
andrewboyson 89:615fb951df69 65 "function parseGenLines(text)\n"
andrewboyson 89:615fb951df69 66 "{\n"
andrewboyson 95:8c9dda8a0caf 67 " let lines = text.split('\\n');\n"
andrewboyson 96:eb2eb75bad0f 68 " localIp = Net.makeIp4(lines[ 0]) ;\n"
andrewboyson 96:eb2eb75bad0f 69 " domainName = lines[ 1] ;\n"
andrewboyson 96:eb2eb75bad0f 70 " hostName = lines[ 2] ;\n"
andrewboyson 96:eb2eb75bad0f 71 " ntpIp = Net.makeIp4(lines[ 3]) ;\n"
andrewboyson 96:eb2eb75bad0f 72 " dnsIp = Net.makeIp4(lines[ 4]) ;\n"
andrewboyson 96:eb2eb75bad0f 73 " dhcpIp = Net.makeIp4(lines[ 5]) ;\n"
andrewboyson 96:eb2eb75bad0f 74 " routerIp = Net.makeIp4(lines[ 6]) ;\n"
andrewboyson 96:eb2eb75bad0f 75 " subnetMask = Net.makeIp4(lines[ 7]) ;\n"
andrewboyson 96:eb2eb75bad0f 76 " broadcastIp = Net.makeIp4(lines[ 8]) ;\n"
andrewboyson 96:eb2eb75bad0f 77 " leaseTime = parseInt(lines[ 9], 16);\n"
andrewboyson 96:eb2eb75bad0f 78 " renewalT1 = parseInt(lines[10], 16);\n"
andrewboyson 96:eb2eb75bad0f 79 " renewalt2 = parseInt(lines[11], 16);\n"
andrewboyson 96:eb2eb75bad0f 80 " elapsed = parseInt(lines[12], 16);\n"
andrewboyson 89:615fb951df69 81 "}\n"
andrewboyson 95:8c9dda8a0caf 82 "function parse()\n"
andrewboyson 88:2857259fc2b4 83 "{\n"
andrewboyson 95:8c9dda8a0caf 84 " let topics = Ajax.response.split('\\f');\n"
andrewboyson 89:615fb951df69 85 " parseGenLines(topics[0]);\n"
andrewboyson 89:615fb951df69 86 " parseArpLines(topics[1]);\n"
andrewboyson 89:615fb951df69 87 " parseDnsLines(topics[2]);\n"
andrewboyson 86:f3c9beec4ee7 88 "}\n"
andrewboyson 95:8c9dda8a0caf 89 "function display()\n"
andrewboyson 86:f3c9beec4ee7 90 "{\n"
andrewboyson 95:8c9dda8a0caf 91 " let elem;\n"
andrewboyson 86:f3c9beec4ee7 92 "\n"
andrewboyson 95:8c9dda8a0caf 93 " elem = Ajax.getElementOrNull('ajax-local-ip' ); if (elem) elem.textContent = localIp;\n"
andrewboyson 95:8c9dda8a0caf 94 " elem = Ajax.getElementOrNull('ajax-domain-name' ); if (elem) elem.textContent = domainName;\n"
andrewboyson 95:8c9dda8a0caf 95 " elem = Ajax.getElementOrNull('ajax-host-name' ); if (elem) elem.textContent = hostName;\n"
andrewboyson 95:8c9dda8a0caf 96 " elem = Ajax.getElementOrNull('ajax-ntp-ip' ); if (elem) elem.textContent = ntpIp;\n"
andrewboyson 95:8c9dda8a0caf 97 " elem = Ajax.getElementOrNull('ajax-dns-ip' ); if (elem) elem.textContent = dnsIp;\n"
andrewboyson 95:8c9dda8a0caf 98 " elem = Ajax.getElementOrNull('ajax-dhcp-ip' ); if (elem) elem.textContent = dhcpIp;\n"
andrewboyson 95:8c9dda8a0caf 99 " elem = Ajax.getElementOrNull('ajax-router-ip' ); if (elem) elem.textContent = routerIp;\n"
andrewboyson 95:8c9dda8a0caf 100 " elem = Ajax.getElementOrNull('ajax-subnet-mask' ); if (elem) elem.textContent = subnetMask;\n"
andrewboyson 95:8c9dda8a0caf 101 " elem = Ajax.getElementOrNull('ajax-broadcast-ip'); if (elem) elem.textContent = broadcastIp;\n"
andrewboyson 95:8c9dda8a0caf 102 " elem = Ajax.getElementOrNull('ajax-lease-time' ); if (elem) elem.textContent = leaseTime;\n"
andrewboyson 95:8c9dda8a0caf 103 " elem = Ajax.getElementOrNull('ajax-renewal-t1' ); if (elem) elem.textContent = renewalT1;\n"
andrewboyson 95:8c9dda8a0caf 104 " elem = Ajax.getElementOrNull('ajax-renewal-t2' ); if (elem) elem.textContent = renewalt2;\n"
andrewboyson 95:8c9dda8a0caf 105 " elem = Ajax.getElementOrNull('ajax-elapsed' ); if (elem) elem.textContent = elapsed;\n"
andrewboyson 95:8c9dda8a0caf 106 " elem = Ajax.getElementOrNull('ajax-arp' ); if (elem) elem.textContent = arp;\n"
andrewboyson 95:8c9dda8a0caf 107 " elem = Ajax.getElementOrNull('ajax-dns' ); if (elem) elem.textContent = dns;\n"
andrewboyson 86:f3c9beec4ee7 108 "}\n"
andrewboyson 86:f3c9beec4ee7 109 "\n"
andrewboyson 95:8c9dda8a0caf 110 "Ajax.server = '/net4-ajax';\n"
andrewboyson 95:8c9dda8a0caf 111 "Ajax.onResponse = function() { parse(); display(); };\n"
andrewboyson 95:8c9dda8a0caf 112 "Ajax.init();\n"
andrewboyson 86:f3c9beec4ee7 113 ""