Skip to content
Snippets Groups Projects
Commit 3e3488fc authored by echicken's avatar echicken :chicken:
Browse files

Allow this to run under jsexec

parent 1422011a
No related branches found
No related tags found
No related merge requests found
// To do: use user.location / zipcode if available?
function getAddress() {
if (js.global.client === undefined) return; // jsexec
const addrRe = /(^0\.0\.0\.0$)|(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^169\.254\.)|(^::1$)|(^[fF][cCdD])/;
if (client.ip_address.search(addrRe) < 0) return client.ip_address; // Not a private/local address
......@@ -19,4 +21,4 @@ function getAddress() {
if (addr.search(addrRe) < 0) return addr;
}
this;
\ No newline at end of file
this;
......@@ -3,15 +3,19 @@ const wttr = load({}, js.exec_dir + 'wttr-lib.js');
function main() {
const ansi = wttr.getWeather();
const attr = console.attributes;
console.clear(BG_BLACK|LIGHTGRAY);
console.putmsg(ansi, P_UTF8);
console.pause();
console.attributes = attr;
if (js.global.console === undefined) { // jsexec
writeln(ansi);
} else {
const attr = console.attributes;
console.clear(BG_BLACK|LIGHTGRAY);
console.putmsg(ansi, P_UTF8);
console.pause();
console.attributes = attr;
}
}
try {
main();
} catch (err) {
log(LOG_ERROR, err);
}
\ No newline at end of file
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment