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

Allow this to run under jsexec

parent 2c5da119
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
// To do: use user.location / zipcode if available? // To do: use user.location / zipcode if available?
function getAddress() { 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])/; 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 if (client.ip_address.search(addrRe) < 0) return client.ip_address; // Not a private/local address
......
...@@ -3,12 +3,16 @@ const wttr = load({}, js.exec_dir + 'wttr-lib.js'); ...@@ -3,12 +3,16 @@ const wttr = load({}, js.exec_dir + 'wttr-lib.js');
function main() { function main() {
const ansi = wttr.getWeather(); const ansi = wttr.getWeather();
if (js.global.console === undefined) { // jsexec
writeln(ansi);
} else {
const attr = console.attributes; const attr = console.attributes;
console.clear(BG_BLACK|LIGHTGRAY); console.clear(BG_BLACK|LIGHTGRAY);
console.putmsg(ansi, P_UTF8); console.putmsg(ansi, P_UTF8);
console.pause(); console.pause();
console.attributes = attr; console.attributes = attr;
} }
}
try { try {
main(); main();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment