Diverse endringer fra de siste årene. Programmet er fortsatt 🍝

This commit is contained in:
Trygve 2023-11-07 15:26:58 +01:00
parent c25ef18f21
commit 150d6cb931
2 changed files with 24 additions and 11 deletions

View File

@ -158,10 +158,10 @@ h4 {
display: flex; display: flex;
flex-flow: column wrap; flex-flow: column wrap;
align-content: center; align-content: center;
gap: 1rem; gap: 0.5rem;
/* Your container needs a fixed height, and it /* Your container needs a fixed height, and it
* needs to be taller than your tallest column. */ * needs to be taller than your tallest column. */
height: 200rem; height: var(--row-count);;
} }
.all-result::before, .all-result::before,
.all-result::after { .all-result::after {
@ -170,9 +170,6 @@ h4 {
width: 0; width: 0;
order: 2; order: 2;
} }
.all-result-div{
margin-bottom: 2%; /* Optional */
}
.all-result-div:nth-child(3n+1) { order: 1; } .all-result-div:nth-child(3n+1) { order: 1; }
.all-result-div:nth-child(3n+2) { order: 2; } .all-result-div:nth-child(3n+2) { order: 2; }
.all-result-div:nth-child(3n) { order: 3; } .all-result-div:nth-child(3n) { order: 3; }

View File

@ -81,7 +81,7 @@ function loadresults() {
} }
document.getElementById("alle-cont").innerHTML = ""; document.getElementById("alle-cont").innerHTML = "";
//console.log(xmlObj); let rowCount = 0;
document.getElementById("header-brand").innerHTML=xmlObj.Event.Name; document.getElementById("header-brand").innerHTML=xmlObj.Event.Name;
@ -92,17 +92,21 @@ function loadresults() {
let winnerTime; let winnerTime;
let controlArray = []; let controlArray = [];
if(typeof(xmlObj.ClassResult[i].PersonResult)!== 'undefined'){
if(typeof(xmlObj.ClassResult[i].PersonResult[0])!== 'undefined' && typeof(xmlObj.ClassResult[i].PersonResult[0].Result.SplitTime)!== 'undefined'){ if(typeof(xmlObj.ClassResult[i].PersonResult[0])!== 'undefined' && typeof(xmlObj.ClassResult[i].PersonResult[0].Result.SplitTime)!== 'undefined'){
splitTimes += '<td></td>' splitTimes += '<td></td>'
controlArray = Array.from(xmlObj.ClassResult[i].PersonResult[0].Result.SplitTime); controlArray = Array.from(xmlObj.ClassResult[i].PersonResult[0].Result.SplitTime);
for (let s = 0; s < xmlObj.ClassResult[i].PersonResult[0].Result.SplitTime.length; s++){ for (let s = 0; s < xmlObj.ClassResult[i].PersonResult[0].Result.SplitTime.length; s++){
splitTimes += `<td ctrlcode="${xmlObj.ClassResult[i].PersonResult[0].Result.SplitTime[s].ControlCode}">${(s+1)}-${xmlObj.ClassResult[i].PersonResult[0].Result.SplitTime[s].ControlCode}</td>`; splitTimes += `<td ctrlcode="${xmlObj.ClassResult[i].PersonResult[0].Result.SplitTime[s].ControlCode}">${(s+1)}-${xmlObj.ClassResult[i].PersonResult[0].Result.SplitTime[s].ControlCode}</td>`;
} }
}
} }
splitTimes += '</tr>' splitTimes += '</tr>'
if(typeof(xmlObj.ClassResult[i].PersonResult)!== 'undefined'){
for (let k = 0; k < xmlObj.ClassResult[i].PersonResult.length; k++) { for (let k = 0; k < xmlObj.ClassResult[i].PersonResult.length; k++) {
rowCount += 1;
if(typeof(xmlObj.ClassResult[i].PersonResult[k].Result)!== 'undefined' && typeof(xmlObj.ClassResult[i].PersonResult[k].Result.Position)!== 'undefined'){ if(typeof(xmlObj.ClassResult[i].PersonResult[k].Result)!== 'undefined' && typeof(xmlObj.ClassResult[i].PersonResult[k].Result.Position)!== 'undefined'){
resultTable += `<tr><td id="Ranking">${xmlObj.ClassResult[i].PersonResult[k].Result.Position}.</td>`; resultTable += `<tr><td id="Ranking">${xmlObj.ClassResult[i].PersonResult[k].Result.Position}.</td>`;
} }
@ -163,9 +167,14 @@ function loadresults() {
let controlTime = 0; let controlTime = 0;
let controlTimeDelta = 0; let controlTimeDelta = 0;
for (let t = 0; t < controlArray.length; t++) { for (let t = 0; t < controlArray.length; t++) {
controlTime = parseInt(xmlObj.ClassResult[i].PersonResult[k].Result.SplitTime[t].Time, 10)-controlTimeDelta if (typeof(xmlObj.ClassResult[i].PersonResult[k].Result.SplitTime[t])!== 'undefined'){
controlTimeDelta += controlTime; controlTime = parseInt(xmlObj.ClassResult[i].PersonResult[k].Result.SplitTime[t].Time, 10)-controlTimeDelta
splitTimes += '<td>'+ TimeFormater(controlTime) +'<br>'+ TimeFormater(xmlObj.ClassResult[i].PersonResult[k].Result.SplitTime[t].Time)+'</td>' controlTimeDelta += controlTime;
splitTimes += '<td>'+ TimeFormater(controlTime) +'<br>'+ TimeFormater(xmlObj.ClassResult[i].PersonResult[k].Result.SplitTime[t].Time)+'</td>'
}
else{
splitTimes += '<td><br></td>'
}
} }
} }
else if (typeof(xmlObj.ClassResult[i].PersonResult[k])!== 'undefined' && typeof(xmlObj.ClassResult[i].PersonResult[0].Result.SplitTime)!== 'undefined' && persStatus == 'Disqualified'){ else if (typeof(xmlObj.ClassResult[i].PersonResult[k])!== 'undefined' && typeof(xmlObj.ClassResult[i].PersonResult[0].Result.SplitTime)!== 'undefined' && persStatus == 'Disqualified'){
@ -173,11 +182,15 @@ function loadresults() {
let controlTimeDelta = 0; let controlTimeDelta = 0;
for (let t = 0; t < controlArray.length; t++) { for (let t = 0; t < controlArray.length; t++) {
if (typeof(xmlObj.ClassResult[i].PersonResult[k].Result.SplitTime && typeof(xmlObj.ClassResult[i].PersonResult[k].Result.SplitTime[t].Time)!=='undefined')!== 'undefined'){ if (typeof(xmlObj.ClassResult[i].PersonResult[k].Result.SplitTime)!== 'undefined'){
if (typeof(xmlObj.ClassResult[i].PersonResult[k].Result.SplitTime[t])!== 'undefined'){
if (typeof(xmlObj.ClassResult[i].PersonResult[k].Result.SplitTime[t].Time)!=='undefined'){
controlTime = parseInt(xmlObj.ClassResult[i].PersonResult[k].Result.SplitTime[t].Time, 10)-controlTimeDelta controlTime = parseInt(xmlObj.ClassResult[i].PersonResult[k].Result.SplitTime[t].Time, 10)-controlTimeDelta
controlTimeDelta += controlTime; controlTimeDelta += controlTime;
splitTimes += '<td>'+ TimeFormater(controlTime) +'<br>'+ TimeFormater(xmlObj.ClassResult[i].PersonResult[k].Result.SplitTime[t].Time)+'</td>' splitTimes += '<td>'+ TimeFormater(controlTime) +'<br>'+ TimeFormater(xmlObj.ClassResult[i].PersonResult[k].Result.SplitTime[t].Time)+'</td>'
} }
}
}
else { else {
splitTimes += '<td></td>' splitTimes += '<td></td>'
} }
@ -186,6 +199,7 @@ function loadresults() {
splitTimes += '</tr>'; splitTimes += '</tr>';
} }
}
resultTable += "</table></div>" resultTable += "</table></div>"
splitTimes += "</table></div>" splitTimes += "</table></div>"
@ -208,6 +222,8 @@ function loadresults() {
resultTable = ""; resultTable = "";
splitTimes = ""; splitTimes = "";
} }
//sets the variable that controls height of the all results flex
document.documentElement.style.setProperty('--row-count', rowCount * 1.8 + "rem");
} }
}; };
xmlhttp.open("GET", "xmlToJson.php", true); xmlhttp.open("GET", "xmlToJson.php", true);
@ -258,7 +274,7 @@ if (typeof(EventSource) !== "undefined") {
loadresults() loadresults()
//console.log("Update!!!!! :=)"); //console.log("Update!!!!! :=)");
window.lastUpdate = parseInt(statusArray[1], 10); window.lastUpdate = parseInt(statusArray[1], 10);
var jdata = JSON.parse(statusArray[3]); //var jdata = JSON.parse(statusArray[3]);
} else { } else {
//console.log("No update"); //console.log("No update");
} }