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
Diff: base/net/web-net-class.inc
- Revision:
- 146:6bc151bd7063
- Parent:
- 145:d2bd78be00b2
- Child:
- 147:ea6f647725a1
--- a/base/net/web-net-class.inc Sun Dec 27 16:18:19 2020 +0000
+++ b/base/net/web-net-class.inc Mon Jan 04 16:09:03 2021 +0000
@@ -1,8 +1,50 @@
"//Net class\n"
"'use strict';\n"
"\n"
+"//Private variables\n"
+"let netMacXhr_ = null;\n"
+"let netMacToFetch_ = '';\n"
+"\n"
"class Net\n"
"{\n"
+" //Public functions\n"
+" static addVendorToLocalStorage(mac)\n"
+" {\n"
+" if (netMacXhr_ && netMacXhr_.readyState != 4) return; //Do nothing if there is an ongoing request\n"
+" netMacToFetch_ = mac;\n"
+" netMacXhr_ = new XMLHttpRequest();\n"
+" netMacXhr_.onreadystatechange = function()\n"
+" {\n"
+" if (netMacXhr_.readyState == 4)\n"
+" {\n"
+" if (netMacXhr_.status == 200)\n"
+" {\n"
+" if (netMacXhr_.responseText == '')\n"
+" {\n"
+" localStorage.setItem(netMacToFetch_, 'Empty vendor');\n"
+" }\n"
+" else\n"
+" {\n"
+" localStorage.setItem(netMacToFetch_, netMacXhr_.responseText);\n"
+" }\n"
+" }\n"
+" else\n"
+" {\n"
+" localStorage.setItem(netMacToFetch_, netMacXhr_.status);\n"
+" }\n"
+" }\n"
+" };\n"
+" netMacXhr_.open('GET', 'https://api.macaddress.io/v1?apiKey=at_dzgreB2SuPBDdy5mwTvivH3R3cvkH&search=' + netMacToFetch_, true);\n"
+" netMacXhr_.send();\n"
+" }\n"
+" static getVendorFromLocalStorage(mac)\n"
+" {\n"
+" return localStorage.getItem(mac);\n"
+" }\n"
+" static clearVendorsFromLocalStorage()\n"
+" {\n"
+" localStorage.clear();\n"
+" }\n"
" static makeIp4(text)\n"
" {\n"
" let result = '';\n"