From e7c208ae134aab03ed4a17a42d3ee0ab524bd5f2 Mon Sep 17 00:00:00 2001 From: echicken <echicken@bbs.electronicchicken.com> Date: Tue, 21 Feb 2023 18:54:10 +0000 Subject: [PATCH] Treat command line argument as an alternate URL. This allows for greater flexibility with the options, and the possibility of querying your own (or some other) wttr server. --- xtrn/wttr.in/readme.txt | 14 +++++--------- xtrn/wttr.in/wttr.js | 4 ++-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/xtrn/wttr.in/readme.txt b/xtrn/wttr.in/readme.txt index d57c59beaf..416a59957f 100644 --- a/xtrn/wttr.in/readme.txt +++ b/xtrn/wttr.in/readme.txt @@ -33,14 +33,10 @@ Contents 3) Customization - Please see https://wttr.in/:help for a list of options. You may pass any - of the 'Units' and 'View options' values to this script on the command - line to customize the output, for example: + Any arguments that you pass on the command line will be treated as an + alternate URL to query. For example: - Command Line ?wttr.js m0AFn + Command Line ?wttr.js https://wttr.in/?m0AFn - The default is 'AFn' for ANSI, no 'Follow' line, and narrow output. - - Note that your command line argument will completely replace the default - parameters. You will probably want to specify 'A' and 'n' in addition to - your chosen values. + The default is URL is 'https://wttr.in/?AFn' for ANSI, no 'Follow' line, + and narrow output. diff --git a/xtrn/wttr.in/wttr.js b/xtrn/wttr.in/wttr.js index aca8871abd..ccc724c7ed 100644 --- a/xtrn/wttr.in/wttr.js +++ b/xtrn/wttr.in/wttr.js @@ -8,10 +8,10 @@ function uReplace(str) { } function fetchWeather(addr) { - const qs = argc > 0 ? argv.join('') : 'AFn'; + const qs = argc > 0 ? argv.join('') : 'https://wttr.in/?AFn'; const http = new HTTPRequest(); if (addr !== undefined) http.extra_headers = { 'X-Forwarded-For': addr }; - const body = http.Get('https://wttr.in/?' + qs); + const body = http.Get(qs); if (http.response_code !== 200) throw new Error('wttr.in response had status ' + http.response_code); return body; } -- GitLab