Created
May 17, 2017 08:47
-
-
Save jarek/47034b6fd5a5aba20755b610120a90ed to your computer and use it in GitHub Desktop.
meat of JS on https://w3.sev.fo/framleidsla/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// inner data-parsing code from view-source:https://w3.sev.fo/framleidsla/36177_SEV_El-orka-i-foroyum.hyperesources/36177sevelorkaiforoyum_hype_generated_script.js?15852 | |
// extracted and beautified | |
// there is another script for "LoadXMLMobil", it appears to do the same thing except for specifying different DOM IDs | |
// (e.g. "heyga_vandstand_1Mobil" instead of "heyga_vandstand_1") | |
// original code below | |
// --- | |
function(hypeDocument, element, event) { | |
// Load XML til at byggja chart við verkætlanum | |
if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari | |
xmlhttp = new XMLHttpRequest(); | |
} else { // code for IE6, IE5 | |
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); | |
} | |
//xmlhttp.open("GET","xkiefjSDKFjeijgjdkjf3847tgfjlkfdgnlsnfvm.xml",false); | |
xmlhttp.open("GET", "https://w3.sev.fo/hagtol/xml/xkiefjSDKFjeijgjdkjf3847tgfjlkfdgnlsnfvm.xml", false); | |
xmlhttp.send(); | |
xmlDoc = xmlhttp.responseXML; | |
var x = xmlDoc.getElementsByTagName("Row"); | |
for (i = 0; i < x.length; i++) { | |
var motororka = x[i].getElementsByTagName("OlieSev_E")[0].childNodes[0].nodeValue; | |
var vatn = x[i].getElementsByTagName("VandSev_E")[0].childNodes[0].nodeValue; | |
var vindur = x[i].getElementsByTagName("VindSev_E")[0].childNodes[0].nodeValue; | |
var elframleidsla = x[i].getElementsByTagName("SumSev_E")[0].childNodes[0].nodeValue; | |
var motororka_tal = motororka.replace(/,/g, '.'); | |
motororka_tal = Number(motororka_tal); | |
var vatn_tal = vatn.replace(/,/g, '.'); | |
vatn_tal = Number(vatn_tal); | |
var vindur_tal = vindur.replace(/,/g, '.'); | |
vindur_tal = Number(vindur_tal); | |
var elframleidsla_tal = elframleidsla.replace(/,/g, '.'); | |
elframleidsla_tal = Number(elframleidsla_tal); | |
var elframleidsla_procent = 100; | |
var elframleidsla_procent_txt = elframleidsla_procent; | |
var motororka_procent = motororka_tal / elframleidsla_tal * 100; | |
var motororka_procent = motororka_procent.toFixed(1); | |
var motororka_procent_txt = motororka_procent; | |
var vatn_procent = vatn_tal / elframleidsla_tal * 100; | |
var vatn_procent = vatn_procent.toFixed(1); | |
var vatn_procent_txt = vatn_procent; | |
var vindur_procent = vindur_tal / elframleidsla_tal * 100; | |
var vindur_procent = vindur_procent.toFixed(1); | |
var vindur_procent_txt = vindur_procent; | |
var time = x[i].getElementsByTagName("tiden")[0].childNodes[0].nodeValue; | |
var eidisverkid = x[i].getElementsByTagName("EiVand_E")[0].childNodes[0].nodeValue; | |
var vestmanna = x[i].getElementsByTagName("VnVand_E")[0].childNodes[0].nodeValue; | |
var myrarnar = x[i].getElementsByTagName("MyVand_E")[0].childNodes[0].nodeValue; | |
var fossa = x[i].getElementsByTagName("FoVand_E")[0].childNodes[0].nodeValue; | |
var heygar = x[i].getElementsByTagName("HeVand_E")[0].childNodes[0].nodeValue; | |
var rokt = x[i].getElementsByTagName("RoVind_E")[0].childNodes[0].nodeValue; | |
var sund = x[i].getElementsByTagName("SdDiesel_E")[0].childNodes[0].nodeValue; | |
var strondVatn = x[i].getElementsByTagName("StVand_E")[0].childNodes[0].nodeValue; | |
var strondDiesel = x[i].getElementsByTagName("StDiesel_E")[0].childNodes[0].nodeValue; | |
var neshagi = x[i].getElementsByTagName("NeVind_E")[0].childNodes[0].nodeValue; | |
var husahagi = x[i].getElementsByTagName("HhVind_E")[0].childNodes[0].nodeValue; | |
//var tvoroyri = x[i].getElementsByTagName("TgDiesel_E")[0].childNodes[0].nodeValue; | |
var botni = x[i].getElementsByTagName("BoVand_E")[0].childNodes[0].nodeValue; | |
var vagi = x[i].getElementsByTagName("VgDiesel_E")[0].childNodes[0].nodeValue; | |
var lomundaroyriVandstand = x[i].getElementsByTagName("Lomundaroyri")[0].childNodes[0].nodeValue; | |
var vatnidVandstand = x[i].getElementsByTagName("Vatnid")[0].childNodes[0].nodeValue; | |
var heygaVandstand = x[i].getElementsByTagName("Heygadalur")[0].childNodes[0].nodeValue; | |
var eidiVandstand = x[i].getElementsByTagName("Eidisvatn")[0].childNodes[0].nodeValue; | |
var strandadalurVandstand = x[i].getElementsByTagName("Strandadalur")[0].childNodes[0].nodeValue; | |
var ryskisvatnVandstand = x[i].getElementsByTagName("Ryskisvatn")[0].childNodes[0].nodeValue; | |
var vatnsnesvatnVandstand = x[i].getElementsByTagName("Vatnsnesvatn")[0].childNodes[0].nodeValue; | |
/* | |
function formatDate(date) { | |
var hours = date.getHours(); | |
var minutes = date.getMinutes(); | |
var ampm = hours >= 12 ? '' : ''; | |
//hours = hours % 12; | |
//hours = hours ? hours : 12; // the hour '0' should be '12' | |
minutes = minutes < 10 ? '0'+minutes : minutes; | |
var strTime = hours + ':' + minutes + ' ' + ampm; | |
return date.getMonth()+1 + "/" + date.getDate() + ", " + date.getFullYear() + " – " + strTime; | |
} | |
var d = new Date(x[i].getElementsByTagName("tiden")[0].childNodes[0].nodeValue); | |
var time = formatDate(d); | |
*/ | |
} | |
var customTextOljuorka = document.getElementById('motororka'); | |
customTextOljuorka.innerHTML = motororka; | |
var customTextVatn = document.getElementById('vatn'); | |
customTextVatn.innerHTML = vatn; | |
var customTextVindur = document.getElementById('vindur'); | |
customTextVindur.innerHTML = vindur; | |
var customTextElframleidsla = document.getElementById('elframleidsla'); | |
customTextElframleidsla.innerHTML = elframleidsla; | |
var customTextOljuorka_p = document.getElementById('Oljuorka_p'); | |
customTextOljuorka_p.innerHTML = motororka_procent_txt; | |
var customTextVatn_p = document.getElementById('Vatnorka_p'); | |
customTextVatn_p.innerHTML = vatn_procent_txt; | |
var customTextVindur_p = document.getElementById('Vindorka_p'); | |
customTextVindur_p.innerHTML = vindur_procent_txt; | |
var customTextElframleidsla_p = document.getElementById('Elframleidsla_p'); | |
customTextElframleidsla_p.innerHTML = elframleidsla_procent_txt; | |
var customTextEidisverkid = document.getElementById('eidisverkid'); | |
customTextEidisverkid.innerHTML = "<strong>Eiði</strong> <br/>Vatn " + eidisverkid; | |
var customTextVestmanna = document.getElementById('vestmanna'); | |
customTextVestmanna.innerHTML = "<strong>Mýrarnar</strong> " + myrarnar + "<br/><strong>Fossá</strong> " + fossa + "<br/> <strong>Heygar</strong> " + heygar + "<br/><br/>Vatn tilsamans " + vestmanna; | |
var customTextRokt = document.getElementById('rokt'); | |
customTextRokt.innerHTML = "<strong>Røkt</strong> <br/>Vind " + rokt; | |
var customTextSund = document.getElementById('sund'); | |
customTextSund.innerHTML = "<strong>Sund</strong> <br/>Olja " + sund; | |
var customTextStrond = document.getElementById('strond'); | |
customTextStrond.innerHTML = "<strong>Strond</strong><br/>Vatn " + strondVatn + "<br/>Olja " + strondDiesel; | |
var customTextNeshagi = document.getElementById('neshagi'); | |
customTextNeshagi.innerHTML = "<strong>Neshagi</strong> <br/>Vind " + neshagi; | |
var customTextHusahagi = document.getElementById('husahagi'); | |
customTextHusahagi.innerHTML = "<strong>Húsahagi</strong> <br/>Vind " + husahagi; | |
//var customTextTvoroyri = document.getElementById('tvoroyri'); | |
//customTextTvoroyri.innerHTML = "<strong>Verkið á Tvøroyri</strong> <br/>Olja " + tvoroyri; | |
var customTextBotni = document.getElementById('botni'); | |
customTextBotni.innerHTML = "<strong>Botnur</strong> <br/>Vatn " + botni; | |
var customTextVagi = document.getElementById('vagi'); | |
customTextVagi.innerHTML = "<strong>Vágur</strong> <br/>Olja " + vagi; | |
var customTextTime = document.getElementById('time'); | |
customTextTime.innerHTML = "Seinast dagført " + time; | |
var roktVindmyllaActive = document.getElementById('rokt_vind_active'); | |
var roktVindmyllaStill = document.getElementById('rokt_vind_still'); | |
rokt = rokt.replace(/,/g, '.') | |
rokt = Number(rokt); | |
//var roktNum = Number(rokt); | |
if (rokt == 0) { | |
roktVindmyllaActive.style.opacity = "0"; | |
roktVindmyllaStill.style.opacity = "1"; | |
} else if (rokt == 0, 0) { | |
roktVindmyllaActive.style.opacity = "0"; | |
roktVindmyllaStill.style.opacity = "1"; | |
} else if (rokt == 0, 00) { | |
roktVindmyllaActive.style.opacity = "0"; | |
roktVindmyllaStill.style.opacity = "1"; | |
} else if (rokt == 00, 00) { | |
roktVindmyllaActive.style.opacity = "0"; | |
roktVindmyllaStill.style.opacity = "1"; | |
} else { | |
roktVindmyllaActive.style.opacity = "1"; | |
roktVindmyllaStill.style.opacity = "0"; | |
} | |
var neshagiVindmyllaActive = document.getElementById('neshagi_vind_active'); | |
var neshagiVindmyllaStill = document.getElementById('neshagi_vind_still'); | |
neshagi = neshagi.replace(/,/g, '.'); | |
neshagi = Number(neshagi); | |
if (neshagi == 0) { | |
neshagiVindmyllaActive.style.opacity = "0"; | |
neshagiVindmyllaStill.style.opacity = "1"; | |
} else if (neshagi == 0, 0) { | |
neshagiVindmyllaActive.style.opacity = "0"; | |
neshagiVindmyllaStill.style.opacity = "1"; | |
} else if (neshagi == 0, 00) { | |
neshagiVindmyllaActive.style.opacity = "0"; | |
neshagiVindmyllaStill.style.opacity = "1"; | |
} else if (neshagi == 00, 00) { | |
neshagiVindmyllaActive.style.opacity = "0"; | |
neshagiVindmyllaStill.style.opacity = "1"; | |
} else { | |
neshagiVindmyllaActive.style.opacity = "1"; | |
neshagiVindmyllaStill.style.opacity = "0"; | |
} | |
var husahagiVindmyllaActive = document.getElementById('husahagi_vind_active'); | |
var husahagiVindmyllaStill = document.getElementById('husahagi_vind_still'); | |
husahagi = husahagi.replace(/,/g, '.'); | |
husahagi = Number(husahagi); | |
if (husahagi == 0) { | |
husahagiVindmyllaActive.style.opacity = "0"; | |
husahagiVindmyllaStill.style.opacity = "1"; | |
} else if (husahagi == 0, 0) { | |
husahagiVindmyllaActive.style.opacity = "0"; | |
husahagiVindmyllaStill.style.opacity = "1"; | |
} else if (husahagi == 0, 00) { | |
husahagiVindmyllaActive.style.opacity = "0"; | |
husahagiVindmyllaStill.style.opacity = "1"; | |
} else if (husahagi == 00, 00) { | |
husahagiVindmyllaActive.style.opacity = "0"; | |
husahagiVindmyllaStill.style.opacity = "1"; | |
} else { | |
husahagiVindmyllaActive.style.opacity = "1"; | |
husahagiVindmyllaStill.style.opacity = "0"; | |
} | |
var strandadalurVandstand1 = document.getElementById('strandadalur_vandstand_1'); | |
var strandadalurVandstand2 = document.getElementById('strandadalur_vandstand_2'); | |
var strandadalurVandstand3 = document.getElementById('strandadalur_vandstand_3'); | |
var strandadalurVandstand4 = document.getElementById('strandadalur_vandstand_4'); | |
var strandadalurVandstand5 = document.getElementById('strandadalur_vandstand_5'); | |
var strandadalurVandstand6 = document.getElementById('strandadalur_vandstand_6'); | |
strandadalurVandstand = strandadalurVandstand.replace(/,/g, '.'); | |
strandadalurVandstand = Number(strandadalurVandstand); | |
if (strandadalurVandstand >= 0) { | |
strandadalurVandstand1.style.opacity = "1"; | |
strandadalurVandstand2.style.opacity = "0"; | |
strandadalurVandstand3.style.opacity = "0"; | |
strandadalurVandstand4.style.opacity = "0"; | |
strandadalurVandstand5.style.opacity = "0"; | |
strandadalurVandstand6.style.opacity = "0"; | |
} else if (strandadalurVandstand < 0 && strandadalurVandstand > -0.5) { | |
strandadalurVandstand1.style.opacity = "0"; | |
strandadalurVandstand2.style.opacity = "1"; | |
strandadalurVandstand3.style.opacity = "0"; | |
strandadalurVandstand4.style.opacity = "0"; | |
strandadalurVandstand5.style.opacity = "0"; | |
strandadalurVandstand6.style.opacity = "0"; | |
} else if (strandadalurVandstand < -0.5 && strandadalurVandstand > -1) { | |
strandadalurVandstand1.style.opacity = "0"; | |
strandadalurVandstand2.style.opacity = "0"; | |
strandadalurVandstand3.style.opacity = "1"; | |
strandadalurVandstand4.style.opacity = "0"; | |
strandadalurVandstand5.style.opacity = "0"; | |
strandadalurVandstand6.style.opacity = "0"; | |
} else if (strandadalurVandstand < -1 && strandadalurVandstand > -2) { | |
strandadalurVandstand1.style.opacity = "0"; | |
strandadalurVandstand2.style.opacity = "0"; | |
strandadalurVandstand3.style.opacity = "0"; | |
strandadalurVandstand4.style.opacity = "1"; | |
strandadalurVandstand5.style.opacity = "0"; | |
strandadalurVandstand6.style.opacity = "0"; | |
} else if (strandadalurVandstand < -2 && strandadalurVandstand > -2.5) { | |
strandadalurVandstand1.style.opacity = "0"; | |
strandadalurVandstand2.style.opacity = "0"; | |
strandadalurVandstand3.style.opacity = "0"; | |
strandadalurVandstand4.style.opacity = "0"; | |
strandadalurVandstand5.style.opacity = "1"; | |
strandadalurVandstand6.style.opacity = "0"; | |
} else if (strandadalurVandstand < -2.5) { | |
strandadalurVandstand1.style.opacity = "0"; | |
strandadalurVandstand2.style.opacity = "0"; | |
strandadalurVandstand3.style.opacity = "0"; | |
strandadalurVandstand4.style.opacity = "0"; | |
strandadalurVandstand5.style.opacity = "0"; | |
strandadalurVandstand6.style.opacity = "1"; | |
} | |
var eidiVandstand1 = document.getElementById('eidi_vandstand_1'); | |
var eidiVandstand2 = document.getElementById('eidi_vandstand_2'); | |
var eidiVandstand3 = document.getElementById('eidi_vandstand_3'); | |
var eidiVandstand4 = document.getElementById('eidi_vandstand_4'); | |
var eidiVandstand5 = document.getElementById('eidi_vandstand_5'); | |
var eidiVandstand6 = document.getElementById('eidi_vandstand_6'); | |
eidiVandstand = eidiVandstand.replace(/,/g, '.'); | |
eidiVandstand = Number(eidiVandstand); | |
if (eidiVandstand >= 0) { | |
eidiVandstand1.style.opacity = "1"; | |
eidiVandstand2.style.opacity = "0"; | |
eidiVandstand3.style.opacity = "0"; | |
eidiVandstand4.style.opacity = "0"; | |
eidiVandstand5.style.opacity = "0"; | |
eidiVandstand6.style.opacity = "0"; | |
} else if (eidiVandstand < 0 && eidiVandstand > -5) { | |
eidiVandstand1.style.opacity = "0"; | |
eidiVandstand2.style.opacity = "1"; | |
eidiVandstand3.style.opacity = "0"; | |
eidiVandstand4.style.opacity = "0"; | |
eidiVandstand5.style.opacity = "0"; | |
eidiVandstand6.style.opacity = "0"; | |
} else if (eidiVandstand < -5 && eidiVandstand > -10) { | |
eidiVandstand1.style.opacity = "0"; | |
eidiVandstand2.style.opacity = "0"; | |
eidiVandstand3.style.opacity = "1"; | |
eidiVandstand4.style.opacity = "0"; | |
eidiVandstand5.style.opacity = "0"; | |
eidiVandstand6.style.opacity = "0"; | |
} else if (eidiVandstand < -10 && eidiVandstand > -15) { | |
eidiVandstand1.style.opacity = "0"; | |
eidiVandstand2.style.opacity = "0"; | |
eidiVandstand3.style.opacity = "0"; | |
eidiVandstand4.style.opacity = "1"; | |
eidiVandstand5.style.opacity = "0"; | |
eidiVandstand6.style.opacity = "0"; | |
} else if (eidiVandstand < -15 && eidiVandstand > -20) { | |
eidiVandstand1.style.opacity = "0"; | |
eidiVandstand2.style.opacity = "0"; | |
eidiVandstand3.style.opacity = "0"; | |
eidiVandstand4.style.opacity = "0"; | |
eidiVandstand5.style.opacity = "1"; | |
eidiVandstand6.style.opacity = "0"; | |
} else if (eidiVandstand < -20) { | |
eidiVandstand1.style.opacity = "0"; | |
eidiVandstand2.style.opacity = "0"; | |
eidiVandstand3.style.opacity = "0"; | |
eidiVandstand4.style.opacity = "0"; | |
eidiVandstand5.style.opacity = "0"; | |
eidiVandstand6.style.opacity = "1"; | |
} | |
var lomundaroyriVandstand1 = document.getElementById('lomundaroyri_vandstand_1'); | |
var lomundaroyriVandstand2 = document.getElementById('lomundaroyri_vandstand_2'); | |
var lomundaroyriVandstand3 = document.getElementById('lomundaroyri_vandstand_3'); | |
var lomundaroyriVandstand4 = document.getElementById('lomundaroyri_vandstand_4'); | |
var lomundaroyriVandstand5 = document.getElementById('lomundaroyri_vandstand_5'); | |
var lomundaroyriVandstand6 = document.getElementById('lomundaroyri_vandstand_6'); | |
lomundaroyriVandstand = lomundaroyriVandstand.replace(/,/g, '.'); | |
lomundaroyriVandstand = Number(lomundaroyriVandstand); | |
if (lomundaroyriVandstand >= 0) { | |
lomundaroyriVandstand1.style.opacity = "1"; | |
lomundaroyriVandstand2.style.opacity = "0"; | |
lomundaroyriVandstand3.style.opacity = "0"; | |
lomundaroyriVandstand4.style.opacity = "0"; | |
lomundaroyriVandstand5.style.opacity = "0"; | |
lomundaroyriVandstand6.style.opacity = "0"; | |
} else if (lomundaroyriVandstand < 0 && lomundaroyriVandstand > -1) { | |
lomundaroyriVandstand1.style.opacity = "0"; | |
lomundaroyriVandstand2.style.opacity = "1"; | |
lomundaroyriVandstand3.style.opacity = "0"; | |
lomundaroyriVandstand4.style.opacity = "0"; | |
lomundaroyriVandstand5.style.opacity = "0"; | |
lomundaroyriVandstand6.style.opacity = "0"; | |
} else if (lomundaroyriVandstand < -1 && lomundaroyriVandstand > -2) { | |
lomundaroyriVandstand1.style.opacity = "0"; | |
lomundaroyriVandstand2.style.opacity = "0"; | |
lomundaroyriVandstand3.style.opacity = "1"; | |
lomundaroyriVandstand4.style.opacity = "0"; | |
lomundaroyriVandstand5.style.opacity = "0"; | |
lomundaroyriVandstand6.style.opacity = "0"; | |
} else if (lomundaroyriVandstand < -2 && lomundaroyriVandstand > -3) { | |
lomundaroyriVandstand1.style.opacity = "0"; | |
lomundaroyriVandstand2.style.opacity = "0"; | |
lomundaroyriVandstand3.style.opacity = "0"; | |
lomundaroyriVandstand4.style.opacity = "1"; | |
lomundaroyriVandstand5.style.opacity = "0"; | |
lomundaroyriVandstand6.style.opacity = "0"; | |
} else if (lomundaroyriVandstand < -3 && lomundaroyriVandstand > -5) { | |
lomundaroyriVandstand1.style.opacity = "0"; | |
lomundaroyriVandstand2.style.opacity = "0"; | |
lomundaroyriVandstand3.style.opacity = "0"; | |
lomundaroyriVandstand4.style.opacity = "0"; | |
lomundaroyriVandstand5.style.opacity = "1"; | |
lomundaroyriVandstand6.style.opacity = "0"; | |
} else if (lomundaroyriVandstand < -5) { | |
lomundaroyriVandstand1.style.opacity = "0"; | |
lomundaroyriVandstand2.style.opacity = "0"; | |
lomundaroyriVandstand3.style.opacity = "0"; | |
lomundaroyriVandstand4.style.opacity = "0"; | |
lomundaroyriVandstand5.style.opacity = "0"; | |
lomundaroyriVandstand6.style.opacity = "1"; | |
} | |
var vatnidVandstand1 = document.getElementById('vatnid_vandstand_1'); | |
var vatnidVandstand2 = document.getElementById('vatnid_vandstand_2'); | |
var vatnidVandstand3 = document.getElementById('vatnid_vandstand_3'); | |
var vatnidVandstand4 = document.getElementById('vatnid_vandstand_4'); | |
var vatnidVandstand5 = document.getElementById('vatnid_vandstand_5'); | |
var vatnidVandstand6 = document.getElementById('vatnid_vandstand_6'); | |
vatnidVandstand = vatnidVandstand.replace(/,/g, '.'); | |
vatnidVandstand = Number(vatnidVandstand); | |
if (vatnidVandstand >= 0) { | |
vatnidVandstand1.style.opacity = "1"; | |
vatnidVandstand2.style.opacity = "0"; | |
vatnidVandstand3.style.opacity = "0"; | |
vatnidVandstand4.style.opacity = "0"; | |
vatnidVandstand5.style.opacity = "0"; | |
vatnidVandstand6.style.opacity = "0"; | |
} else if (vatnidVandstand < 0 && vatnidVandstand > -2) { | |
vatnidVandstand1.style.opacity = "0"; | |
vatnidVandstand2.style.opacity = "1"; | |
vatnidVandstand3.style.opacity = "0"; | |
vatnidVandstand4.style.opacity = "0"; | |
vatnidVandstand5.style.opacity = "0"; | |
vatnidVandstand6.style.opacity = "0"; | |
} else if (vatnidVandstand < -2 && vatnidVandstand > -5) { | |
vatnidVandstand1.style.opacity = "0"; | |
vatnidVandstand2.style.opacity = "0"; | |
vatnidVandstand3.style.opacity = "1"; | |
vatnidVandstand4.style.opacity = "0"; | |
vatnidVandstand5.style.opacity = "0"; | |
vatnidVandstand6.style.opacity = "0"; | |
} else if (vatnidVandstand < -5 && vatnidVandstand > -8) { | |
vatnidVandstand1.style.opacity = "0"; | |
vatnidVandstand2.style.opacity = "0"; | |
vatnidVandstand3.style.opacity = "0"; | |
vatnidVandstand4.style.opacity = "1"; | |
vatnidVandstand5.style.opacity = "0"; | |
vatnidVandstand6.style.opacity = "0"; | |
} else if (vatnidVandstand < -8 && vatnidVandstand > -11) { | |
vatnidVandstand1.style.opacity = "0"; | |
vatnidVandstand2.style.opacity = "0"; | |
vatnidVandstand3.style.opacity = "0"; | |
vatnidVandstand4.style.opacity = "0"; | |
vatnidVandstand5.style.opacity = "1"; | |
vatnidVandstand6.style.opacity = "0"; | |
} else if (vatnidVandstand < -11) { | |
vatnidVandstand1.style.opacity = "0"; | |
vatnidVandstand2.style.opacity = "0"; | |
vatnidVandstand3.style.opacity = "0"; | |
vatnidVandstand4.style.opacity = "0"; | |
vatnidVandstand5.style.opacity = "0"; | |
vatnidVandstand6.style.opacity = "1"; | |
} | |
var heygaVandstand1 = document.getElementById('heyga_vandstand_1'); | |
var heygaVandstand2 = document.getElementById('heyga_vandstand_2'); | |
var heygaVandstand3 = document.getElementById('heyga_vandstand_3'); | |
var heygaVandstand4 = document.getElementById('heyga_vandstand_4'); | |
var heygaVandstand5 = document.getElementById('heyga_vandstand_5'); | |
var heygaVandstand6 = document.getElementById('heyga_vandstand_6'); | |
heygaVandstand = heygaVandstand.replace(/,/g, '.'); | |
heygaVandstand = Number(heygaVandstand); | |
if (heygaVandstand >= 0) { | |
heygaVandstand1.style.opacity = "1"; | |
heygaVandstand2.style.opacity = "0"; | |
heygaVandstand3.style.opacity = "0"; | |
heygaVandstand4.style.opacity = "0"; | |
heygaVandstand5.style.opacity = "0"; | |
heygaVandstand6.style.opacity = "0"; | |
} else if (heygaVandstand < 0 && heygaVandstand > -1) { | |
heygaVandstand1.style.opacity = "0"; | |
heygaVandstand2.style.opacity = "1"; | |
heygaVandstand3.style.opacity = "0"; | |
heygaVandstand4.style.opacity = "0"; | |
heygaVandstand5.style.opacity = "0"; | |
heygaVandstand6.style.opacity = "0"; | |
} else if (heygaVandstand < -1 && heygaVandstand > -2) { | |
heygaVandstand1.style.opacity = "0"; | |
heygaVandstand2.style.opacity = "0"; | |
heygaVandstand3.style.opacity = "1"; | |
heygaVandstand4.style.opacity = "0"; | |
heygaVandstand5.style.opacity = "0"; | |
heygaVandstand6.style.opacity = "0"; | |
} else if (heygaVandstand < -2 && heygaVandstand > -4) { | |
heygaVandstand1.style.opacity = "0"; | |
heygaVandstand2.style.opacity = "0"; | |
heygaVandstand3.style.opacity = "0"; | |
heygaVandstand4.style.opacity = "1"; | |
heygaVandstand5.style.opacity = "0"; | |
heygaVandstand6.style.opacity = "0"; | |
} else if (heygaVandstand < -4 && heygaVandstand > -5) { | |
heygaVandstand1.style.opacity = "0"; | |
heygaVandstand2.style.opacity = "0"; | |
heygaVandstand3.style.opacity = "0"; | |
heygaVandstand4.style.opacity = "0"; | |
heygaVandstand5.style.opacity = "1"; | |
heygaVandstand6.style.opacity = "0"; | |
} else if (heygaVandstand < -5) { | |
heygaVandstand1.style.opacity = "0"; | |
heygaVandstand2.style.opacity = "0"; | |
heygaVandstand3.style.opacity = "0"; | |
heygaVandstand4.style.opacity = "0"; | |
heygaVandstand5.style.opacity = "0"; | |
heygaVandstand6.style.opacity = "1"; | |
} | |
var ryskisvatnVandstand1 = document.getElementById('ryskisvatn_vandstand_1'); | |
var ryskisvatnVandstand2 = document.getElementById('ryskisvatn_vandstand_2'); | |
var ryskisvatnVandstand3 = document.getElementById('ryskisvatn_vandstand_3'); | |
var ryskisvatnVandstand4 = document.getElementById('ryskisvatn_vandstand_4'); | |
var ryskisvatnVandstand5 = document.getElementById('ryskisvatn_vandstand_5'); | |
var ryskisvatnVandstand6 = document.getElementById('ryskisvatn_vandstand_6'); | |
ryskisvatnVandstand = ryskisvatnVandstand.replace(/,/g, '.'); | |
ryskisvatnVandstand = Number(ryskisvatnVandstand); | |
if (ryskisvatnVandstand >= 0) { | |
ryskisvatnVandstand1.style.opacity = "1"; | |
ryskisvatnVandstand2.style.opacity = "0"; | |
ryskisvatnVandstand3.style.opacity = "0"; | |
ryskisvatnVandstand4.style.opacity = "0"; | |
ryskisvatnVandstand5.style.opacity = "0"; | |
ryskisvatnVandstand6.style.opacity = "0"; | |
} else if (ryskisvatnVandstand < 0 && ryskisvatnVandstand > -1) { | |
ryskisvatnVandstand1.style.opacity = "0"; | |
ryskisvatnVandstand2.style.opacity = "1"; | |
ryskisvatnVandstand3.style.opacity = "0"; | |
ryskisvatnVandstand4.style.opacity = "0"; | |
ryskisvatnVandstand5.style.opacity = "0"; | |
ryskisvatnVandstand6.style.opacity = "0"; | |
} else if (ryskisvatnVandstand < -1 && ryskisvatnVandstand > -2) { | |
ryskisvatnVandstand1.style.opacity = "0"; | |
ryskisvatnVandstand2.style.opacity = "0"; | |
ryskisvatnVandstand3.style.opacity = "1"; | |
ryskisvatnVandstand4.style.opacity = "0"; | |
ryskisvatnVandstand5.style.opacity = "0"; | |
ryskisvatnVandstand6.style.opacity = "0"; | |
} else if (ryskisvatnVandstand < -2 && ryskisvatnVandstand > -3) { | |
ryskisvatnVandstand1.style.opacity = "0"; | |
ryskisvatnVandstand2.style.opacity = "0"; | |
ryskisvatnVandstand3.style.opacity = "0"; | |
ryskisvatnVandstand4.style.opacity = "1"; | |
ryskisvatnVandstand5.style.opacity = "0"; | |
ryskisvatnVandstand6.style.opacity = "0"; | |
} else if (ryskisvatnVandstand < -3 && ryskisvatnVandstand > -3.5) { | |
ryskisvatnVandstand1.style.opacity = "0"; | |
ryskisvatnVandstand2.style.opacity = "0"; | |
ryskisvatnVandstand3.style.opacity = "0"; | |
ryskisvatnVandstand4.style.opacity = "0"; | |
ryskisvatnVandstand5.style.opacity = "1"; | |
ryskisvatnVandstand6.style.opacity = "0"; | |
} else if (ryskisvatnVandstand < -3.5) { | |
ryskisvatnVandstand1.style.opacity = "0"; | |
ryskisvatnVandstand2.style.opacity = "0"; | |
ryskisvatnVandstand3.style.opacity = "0"; | |
ryskisvatnVandstand4.style.opacity = "0"; | |
ryskisvatnVandstand5.style.opacity = "0"; | |
ryskisvatnVandstand6.style.opacity = "1"; | |
} | |
var vatnsnesvatnVandstand1 = document.getElementById('vatnsnesvatn_vandstand_1'); | |
var vatnsnesvatnVandstand2 = document.getElementById('vatnsnesvatn_vandstand_2'); | |
var vatnsnesvatnVandstand3 = document.getElementById('vatnsnesvatn_vandstand_3'); | |
var vatnsnesvatnVandstand4 = document.getElementById('vatnsnesvatn_vandstand_4'); | |
var vatnsnesvatnVandstand5 = document.getElementById('vatnsnesvatn_vandstand_5'); | |
var vatnsnesvatnVandstand6 = document.getElementById('vatnsnesvatn_vandstand_6'); | |
vatnsnesvatnVandstand = vatnsnesvatnVandstand.replace(/,/g, '.'); | |
vatnsnesvatnVandstand = Number(vatnsnesvatnVandstand); | |
if (vatnsnesvatnVandstand >= 0) { | |
vatnsnesvatnVandstand1.style.opacity = "1"; | |
vatnsnesvatnVandstand2.style.opacity = "0"; | |
vatnsnesvatnVandstand3.style.opacity = "0"; | |
vatnsnesvatnVandstand4.style.opacity = "0"; | |
vatnsnesvatnVandstand5.style.opacity = "0"; | |
vatnsnesvatnVandstand6.style.opacity = "0"; | |
} else if (vatnsnesvatnVandstand < 0 && vatnsnesvatnVandstand > -1) { | |
vatnsnesvatnVandstand1.style.opacity = "0"; | |
vatnsnesvatnVandstand2.style.opacity = "1"; | |
vatnsnesvatnVandstand3.style.opacity = "0"; | |
vatnsnesvatnVandstand4.style.opacity = "0"; | |
vatnsnesvatnVandstand5.style.opacity = "0"; | |
vatnsnesvatnVandstand6.style.opacity = "0"; | |
} else if (vatnsnesvatnVandstand < -1 && vatnsnesvatnVandstand > -2) { | |
vatnsnesvatnVandstand1.style.opacity = "0"; | |
vatnsnesvatnVandstand2.style.opacity = "0"; | |
vatnsnesvatnVandstand3.style.opacity = "1"; | |
vatnsnesvatnVandstand4.style.opacity = "0"; | |
vatnsnesvatnVandstand5.style.opacity = "0"; | |
vatnsnesvatnVandstand6.style.opacity = "0"; | |
} else if (vatnsnesvatnVandstand < -2 && vatnsnesvatnVandstand > -4) { | |
vatnsnesvatnVandstand1.style.opacity = "0"; | |
vatnsnesvatnVandstand2.style.opacity = "0"; | |
vatnsnesvatnVandstand3.style.opacity = "0"; | |
vatnsnesvatnVandstand4.style.opacity = "1"; | |
vatnsnesvatnVandstand5.style.opacity = "0"; | |
vatnsnesvatnVandstand6.style.opacity = "0"; | |
} else if (vatnsnesvatnVandstand < -4 && vatnsnesvatnVandstand > -5) { | |
vatnsnesvatnVandstand1.style.opacity = "0"; | |
vatnsnesvatnVandstand2.style.opacity = "0"; | |
vatnsnesvatnVandstand3.style.opacity = "0"; | |
vatnsnesvatnVandstand4.style.opacity = "0"; | |
vatnsnesvatnVandstand5.style.opacity = "1"; | |
vatnsnesvatnVandstand6.style.opacity = "0"; | |
} else if (vatnsnesvatnVandstand < -5) { | |
vatnsnesvatnVandstand1.style.opacity = "0"; | |
vatnsnesvatnVandstand2.style.opacity = "0"; | |
vatnsnesvatnVandstand3.style.opacity = "0"; | |
vatnsnesvatnVandstand4.style.opacity = "0"; | |
vatnsnesvatnVandstand5.style.opacity = "0"; | |
vatnsnesvatnVandstand6.style.opacity = "1"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Meaning of keys in the XML and how they are used in the JS, as I found so far: