Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: oldheating gps motorhome heating
net/http-net6-script.inc@86:f3c9beec4ee7, 2019-04-08 (annotated)
- Committer:
- andrewboyson
- Date:
- Mon Apr 08 10:13:01 2019 +0000
- Revision:
- 86:f3c9beec4ee7
- Child:
- 88:2857259fc2b4
Split the NET page into general net, net ipv4 and net ipv6. Also made the arp and dns update through ajax.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| andrewboyson | 86:f3c9beec4ee7 | 1 | "'use strict';\n" |
| andrewboyson | 86:f3c9beec4ee7 | 2 | "\n" |
| andrewboyson | 86:f3c9beec4ee7 | 3 | "var response = '';\n" |
| andrewboyson | 86:f3c9beec4ee7 | 4 | "var headers = '';\n" |
| andrewboyson | 86:f3c9beec4ee7 | 5 | "var arp = '';\n" |
| andrewboyson | 86:f3c9beec4ee7 | 6 | "var dns = '';\n" |
| andrewboyson | 86:f3c9beec4ee7 | 7 | "\n" |
| andrewboyson | 86:f3c9beec4ee7 | 8 | "function parseAjax()\n" |
| andrewboyson | 86:f3c9beec4ee7 | 9 | "{\n" |
| andrewboyson | 86:f3c9beec4ee7 | 10 | " var topics = response.split('\\f');\n" |
| andrewboyson | 86:f3c9beec4ee7 | 11 | " arp = topics[0];\n" |
| andrewboyson | 86:f3c9beec4ee7 | 12 | " dns = topics[1];\n" |
| andrewboyson | 86:f3c9beec4ee7 | 13 | "}\n" |
| andrewboyson | 86:f3c9beec4ee7 | 14 | "function displayGeneral()\n" |
| andrewboyson | 86:f3c9beec4ee7 | 15 | "{\n" |
| andrewboyson | 86:f3c9beec4ee7 | 16 | " var elem;\n" |
| andrewboyson | 86:f3c9beec4ee7 | 17 | "\n" |
| andrewboyson | 86:f3c9beec4ee7 | 18 | " elem = document.getElementById('ajax-response' ); if (elem) elem.textContent = response;\n" |
| andrewboyson | 86:f3c9beec4ee7 | 19 | " elem = document.getElementById('ajax-headers' ); if (elem) elem.textContent = headers;\n" |
| andrewboyson | 86:f3c9beec4ee7 | 20 | " elem = document.getElementById('ajax-arp' ); if (elem) elem.textContent = arp;\n" |
| andrewboyson | 86:f3c9beec4ee7 | 21 | " elem = document.getElementById('ajax-dns' ); if (elem) elem.textContent = dns;\n" |
| andrewboyson | 86:f3c9beec4ee7 | 22 | "}\n" |
| andrewboyson | 86:f3c9beec4ee7 | 23 | "\n" |
| andrewboyson | 86:f3c9beec4ee7 | 24 | "var ajax;\n" |
| andrewboyson | 86:f3c9beec4ee7 | 25 | "function AjaxRequest(request) //Used by this script and from HTML page\n" |
| andrewboyson | 86:f3c9beec4ee7 | 26 | "{\n" |
| andrewboyson | 86:f3c9beec4ee7 | 27 | " ajax=new XMLHttpRequest();\n" |
| andrewboyson | 86:f3c9beec4ee7 | 28 | " ajax.onreadystatechange=handleAjaxResponse;\n" |
| andrewboyson | 86:f3c9beec4ee7 | 29 | " if (request) ajax.open('GET', '/net6-ajax' + '?' + request, true);\n" |
| andrewboyson | 86:f3c9beec4ee7 | 30 | " else ajax.open('GET', '/net6-ajax' , true);\n" |
| andrewboyson | 86:f3c9beec4ee7 | 31 | " ajax.send();\n" |
| andrewboyson | 86:f3c9beec4ee7 | 32 | "}\n" |
| andrewboyson | 86:f3c9beec4ee7 | 33 | "function requestAjax() //Used in this script\n" |
| andrewboyson | 86:f3c9beec4ee7 | 34 | "{\n" |
| andrewboyson | 86:f3c9beec4ee7 | 35 | " AjaxRequest('');\n" |
| andrewboyson | 86:f3c9beec4ee7 | 36 | "}\n" |
| andrewboyson | 86:f3c9beec4ee7 | 37 | "\n" |
| andrewboyson | 86:f3c9beec4ee7 | 38 | "function handleAjaxResponse()\n" |
| andrewboyson | 86:f3c9beec4ee7 | 39 | "{\n" |
| andrewboyson | 86:f3c9beec4ee7 | 40 | " if (ajax.readyState==4 && ajax.status==200)\n" |
| andrewboyson | 86:f3c9beec4ee7 | 41 | " {\n" |
| andrewboyson | 86:f3c9beec4ee7 | 42 | " response = ajax.responseText;\n" |
| andrewboyson | 86:f3c9beec4ee7 | 43 | " headers = ajax.getAllResponseHeaders();\n" |
| andrewboyson | 86:f3c9beec4ee7 | 44 | " parseAjax();\n" |
| andrewboyson | 86:f3c9beec4ee7 | 45 | " displayGeneral();\n" |
| andrewboyson | 86:f3c9beec4ee7 | 46 | " }\n" |
| andrewboyson | 86:f3c9beec4ee7 | 47 | "}\n" |
| andrewboyson | 86:f3c9beec4ee7 | 48 | "\n" |
| andrewboyson | 86:f3c9beec4ee7 | 49 | "function init()\n" |
| andrewboyson | 86:f3c9beec4ee7 | 50 | "{\n" |
| andrewboyson | 86:f3c9beec4ee7 | 51 | " setInterval(requestAjax, 10000);\n" |
| andrewboyson | 86:f3c9beec4ee7 | 52 | " requestAjax();\n" |
| andrewboyson | 86:f3c9beec4ee7 | 53 | "}\n" |
| andrewboyson | 86:f3c9beec4ee7 | 54 | "if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', init ); // Loading hasn't finished yet\n" |
| andrewboyson | 86:f3c9beec4ee7 | 55 | "else init(); //`DOMContentLoaded` has already fired\n" |
| andrewboyson | 86:f3c9beec4ee7 | 56 | "" |