Skip to content

Instantly share code, notes, and snippets.

@jarek
Created May 17, 2017 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jarek/47034b6fd5a5aba20755b610120a90ed to your computer and use it in GitHub Desktop.
Save jarek/47034b6fd5a5aba20755b610120a90ed to your computer and use it in GitHub Desktop.
// 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";
}
}
@jarek
Copy link
Author

jarek commented May 17, 2017

Meaning of keys in the XML and how they are used in the JS, as I found so far:

<SumS_E>3,23</SumS_E> - not used in script
<SumS_P>7,60</SumS_P> - not used in script
<SumH_E>39,27</SumH_E> - not used in script
<SumH_P>92,40</SumH_P> - not used in script
<SumSev_E>42,50</SumSev_E> - used in script to indicate total territory generation, in MW

<VandSev_E>15,52</VandSev_E> - used in script to indicate total hydro generation, in MW
<VandSev_P>36,5</VandSev_P> - not used in script
<OlieSev_E>21,97</OlieSev_E> - total oil generation, in MW
<OlieSev_P>51,7</OlieSev_P> - not used in script
<VindSev_E>5,01</VindSev_E> - total wind generation, in MW
<VindSev_P>11,8</VindSev_P> - not used in script
-> VindSev_P, VandSev_P, OlieSev_P add up to 100.0
-> VandSev_E / SumSev_E == VandSev_P, so these are just percentages of total generation

<Vatn>37,9</Vatn> - not used in script
<Olja>49,3</Olja> - not used in script
<Vindur>12,8</Vindur> - not used in script
-> Vatn, Olja, and Vindur add up to 100.0, but different values than above... long-term averages maybe?

<SdDiesel_E>19,36</SdDiesel_E> - oil/diesel station at Sund
<SdDiesel_P>49,30</SdDiesel_P> - not used in script
<EiVand_E>4,43</EiVand_E> - hydro station at Eiði
<EiVand_P>11,28</EiVand_P> - not used in script
<StDiesel_E>0,00</StDiesel_E> - oil/diesel station at Strond
<StDiesel_P>0,00</StDiesel_P> - not used in script
<StVand_E>1,04</StVand_E> - hydro station at Strond
<StVand_P>2,65</StVand_P> - not used in script
<NeVind_E>2,87</NeVind_E> - wind station at Neshagi
<NeVind_P>7,31</NeVind_P> - not used in script
<RoVind_E>0,44</RoVind_E> - wind station at Røkt
<RoVind_P>1,12</RoVind_P> - not used in script
<VgDiesel_E>2,61</VgDiesel_E> - oil/diesel station at Vágur
<VgDiesel_P>80,80</VgDiesel_P> - not used in script
<BoVand_E>0,62</BoVand_E> - hydro station at Botnur
<BoVand_P>19,20</BoVand_P> - not used in script
<HhVind_E>1,70</HhVind_E> - wind station at Húsahagi
<HhVind_P>4,33</HhVind_P> - not used in script

<FoVand_E>3,88</FoVand_E> - hydro station at Fossá
<FoVand_P>9,88</FoVand_P> - not used in script
<MyVand_E>1,87</MyVand_E> - hydro station at Mýrarnar
<MyVand_P>4,76</MyVand_P> - not used in script
<HeVand_E>3,68</HeVand_E> - hydro station at Heygar
<HeVand_P>9,37</HeVand_P> - not used in script
<VnVand_E>9.43</VnVand_E> - sum of FoVand_E, MyVand_E, HeVand_E

<VandH_E>14,90</VandH_E> - not used in script
<VandH_P>37,9</VandH_P> - not used in script
<OlieH_E>19,36</OlieH_E> - not used in script
<OlieH_P>49,3</OlieH_P> - not used in script
<VindH_E>5,01</VindH_E> - not used in script
<VindH_P>12,8</VindH_P> - not used in script
<VandS_E>0,62</VandS_E> - not used in script
<VandS_P>19,2</VandS_P> - not used in script
<OlieS_E>2,61</OlieS_E> - not used in script
<OlieS_P>80,8</OlieS_P> - not used in script

test keys, not used in script:

<Test01>0</Test01>
<Test02>0</Test02>
<Test03>0</Test03>
<Test04>0</Test04>

water levels, units unknown:

<Vatnid>-5,43</Vatnid> - water level in Vatnið, range from 0 (full) to -11 (empty)
<Lomundaroyri>-1,62</Lomundaroyri> - water level in Lomundaroyri, range from 0 (full) to -5 (empty)
<Heygadalur>-0,72</Heygadalur> - water level in Heygadalur, range from 0 to -5
<Eidisvatn>-2,77</Eidisvatn> - water level in Eiðisvatn, range from 0 to -20
<Strandadalur>-1,19</Strandadalur> - water level in Strandadalur, range from 0 to -2.5
<Ryskisvatn>-0,43</Ryskisvatn> - water level in Ryskisvatn, range from 0 to -3.5
<Vatnsnesvatn>-0,43</Vatnsnesvatn> - water level in Vatnsnesvatn, range from 0 to -5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment