Shareable links for element, lead, period, city and live map
Browse files- index.html +7 -1
index.html
CHANGED
|
@@ -257,5 +257,11 @@ function liveClose(){$("mdl").hidden=true;document.body.style.overflow="";$("wfr
|
|
| 257 |
load().then(()=>{ECACHE.tmax={O,F,dates,generated:gen,leads:LEADS};document.querySelectorAll(".et").forEach(b=>b.onclick=()=>setEl(b.dataset.e));$("lebtn").onclick=liveOpen;$("mclose").onclick=liveClose;$("mdl").onclick=e=>{if(e.target===$("mdl"))liveClose()};document.addEventListener("keydown",e=>{if(e.key==="Escape"&&!$("mdl").hidden)liveClose()});document.querySelectorAll(".mt").forEach(b=>b.onclick=()=>liveTab(b.dataset.t));LEADS.forEach(d=>$("lead").insertAdjacentHTML("beforeend",`<option value="${d}"${d===7?" selected":""}>${d} day${d>1?"s":""} ahead</option>`));NAMES.forEach((c,i)=>$("city").insertAdjacentHTML("beforeend",`<option value="${i}">${c}</option>`));
|
| 258 |
$("date").insertAdjacentHTML("beforeend",`<option value="latest" selected>Today · latest (${dates[dates.length-1]})</option>`);for(let i=dates.length-1;i>=MIN;i--)$("date").insertAdjacentHTML("beforeend",`<option>${dates[i]}</option>`);
|
| 259 |
$("ocity").insertAdjacentHTML("beforeend",`<option value="-1" selected>All 24 cities</option>`);NAMES.forEach((c,i)=>$("ocity").insertAdjacentHTML("beforeend",`<option value="${i}">${c}</option>`));$("ocity").onchange=outlook;
|
| 260 |
-
["lead","period","date","city"].forEach(id=>$(id).onchange=()=>{render();if(id==="city")$("ocity").value=$("city").value;outlook()});render();outlook()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 261 |
</script></body></html>
|
|
|
|
| 257 |
load().then(()=>{ECACHE.tmax={O,F,dates,generated:gen,leads:LEADS};document.querySelectorAll(".et").forEach(b=>b.onclick=()=>setEl(b.dataset.e));$("lebtn").onclick=liveOpen;$("mclose").onclick=liveClose;$("mdl").onclick=e=>{if(e.target===$("mdl"))liveClose()};document.addEventListener("keydown",e=>{if(e.key==="Escape"&&!$("mdl").hidden)liveClose()});document.querySelectorAll(".mt").forEach(b=>b.onclick=()=>liveTab(b.dataset.t));LEADS.forEach(d=>$("lead").insertAdjacentHTML("beforeend",`<option value="${d}"${d===7?" selected":""}>${d} day${d>1?"s":""} ahead</option>`));NAMES.forEach((c,i)=>$("city").insertAdjacentHTML("beforeend",`<option value="${i}">${c}</option>`));
|
| 258 |
$("date").insertAdjacentHTML("beforeend",`<option value="latest" selected>Today · latest (${dates[dates.length-1]})</option>`);for(let i=dates.length-1;i>=MIN;i--)$("date").insertAdjacentHTML("beforeend",`<option>${dates[i]}</option>`);
|
| 259 |
$("ocity").insertAdjacentHTML("beforeend",`<option value="-1" selected>All 24 cities</option>`);NAMES.forEach((c,i)=>$("ocity").insertAdjacentHTML("beforeend",`<option value="${i}">${c}</option>`));$("ocity").onchange=outlook;
|
| 260 |
+
["lead","period","date","city"].forEach(id=>$(id).onchange=()=>{render();if(id==="city")$("ocity").value=$("city").value;outlook()});render();outlook();
|
| 261 |
+
// shareable links: #el=precip&lead=3&period=90&city=Seoul&live=sat
|
| 262 |
+
const hp=new URLSearchParams(location.hash.slice(1));(async()=>{if(hp.get("el")&&ELS[hp.get("el")])await setEl(hp.get("el"));
|
| 263 |
+
if(hp.get("lead")&&LEADS.includes(+hp.get("lead"))){$("lead").value=hp.get("lead")}if(hp.get("period")){$("period").value=hp.get("period")}
|
| 264 |
+
if(hp.get("city")){const i=NAMES.indexOf(hp.get("city"));if(i>=0){$("city").value=i;$("ocity").value=i}}
|
| 265 |
+
if(hp.get("lead")||hp.get("period")||hp.get("city")){render();if(OLX)outlook()}
|
| 266 |
+
if(hp.get("live")){liveOpen();liveTab(hp.get("live"))}})()}).catch(e=>{$("status").textContent="Could not load data. Please reload in a moment.";console.error(e)});
|
| 267 |
</script></body></html>
|