|
document.addEventListener("DOMContentLoaded",()=>{
|
|
let currentUrlObj=document.getElementsByClassName('currentUrl');
|
|
for (let i=0; i<currentUrlObj.length; i++){
|
|
currentUrlObj[i].innerHTML=window.location.origin;
|
|
}
|
|
|
|
let helpLinkObj=document.getElementsByClassName('helpLink');
|
|
for (let i=0; i<helpLinkObj.length; i++){
|
|
helpLinkObj[i].setAttribute("href",helpLinkObj[i].getAttribute("href").replace("[currentUrl]",window.location.origin));
|
|
}
|
|
|
|
|
|
let nightModeInputObj=document.getElementById("nightModeInput");
|
|
nightModeInputObj.addEventListener("change",(e)=>{
|
|
toggleDayNightMode(e.target.checked);
|
|
});
|
|
|
|
if(nightModeInputObj.checked){
|
|
toggleDayNightMode(nightModeInputObj.checked);
|
|
}else{
|
|
toggleDayNightIcon(nightModeInputObj.checked);
|
|
}
|
|
|
|
let helpObj=document.getElementById("help");
|
|
let helpImageObj=document.getElementById("helpImage");
|
|
if(helpImageObj){//Used because #helpImage can be hidden by user request.
|
|
document.getElementById("helpImage").addEventListener("click", ()=>{
|
|
if(window.getComputedStyle(helpObj).getPropertyValue("display")=="none"){
|
|
helpObj.style.display="block";
|
|
}else{
|
|
helpObj.style.display="none";
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
function toggleDayNightMode(nightMode){
|
|
document.body.classList.toggle("nightBackground");
|
|
let weatherImageArray=document.querySelectorAll(".weatherImage,#dayMode,#helpImage");
|
|
for (let i=0; i<weatherImageArray.length; i++){
|
|
weatherImageArray[i].classList.toggle("nightFilter");
|
|
}
|
|
|
|
let tableCellArray=document.querySelectorAll("td,th:not(:first-child)");
|
|
for (let i=0; i<tableCellArray.length; i++){
|
|
tableCellArray[i].classList.toggle("nightBorder");
|
|
}
|
|
|
|
let allArray=document.querySelectorAll("*");
|
|
for (let i=0; i<allArray.length; i++){
|
|
allArray[i].classList.toggle("nightColor");
|
|
}
|
|
|
|
let alternativeColumnArray=document.querySelectorAll("td:nth-child(2n+1):not(:first-child)");
|
|
for (let i=0; i<alternativeColumnArray.length; i++){
|
|
alternativeColumnArray[i].classList.toggle("nightAlternateBackground");
|
|
}
|
|
toggleDayNightIcon(nightMode);
|
|
}
|
|
function toggleDayNightIcon(nightMode){
|
|
if(nightMode){
|
|
document.getElementById("dayMode").style.display="block";
|
|
document.getElementById("nightMode").style.display="none";
|
|
}else{
|
|
document.getElementById("dayMode").style.display="none";
|
|
document.getElementById("nightMode").style.display="block";
|
|
}
|
|
}
|