diff --git a/website/public/scout/scripts.js b/website/public/scout/scripts.js index 756a4d47..d6f8cedf 100644 --- a/website/public/scout/scripts.js +++ b/website/public/scout/scripts.js @@ -136,11 +136,11 @@ function cseries(seriesName) { if (seriesName == "quantitative") { document.getElementById('FormData').innerHTML += "

" + 'Sandstorm' + "

"; - document.getElementById('FormData').innerHTML += "
"+"
"; + document.getElementById('FormData').innerHTML += "
" + "
"; var ss = firebase.firestore().collection('appBuilding').doc('team-' + teamNum).collection('competitions').doc(currentComp).collection('appElements').doc('quantitativeSandstorm'); ss.get().then(function(doc) { if (doc.exists) { - processAndAppendReturn(doc.data(),'repsec1') + processAndAppendReturn(doc.data(), 'repsec1') } }).then(function() { document.getElementById('FormData').innerHTML += "

" + 'TeleOp' + "

"; @@ -148,7 +148,7 @@ function cseries(seriesName) { var to = firebase.firestore().collection('appBuilding').doc('team-' + teamNum).collection('competitions').doc(currentComp).collection('appElements').doc('quantitativeTeleop'); to.get().then(function(doc) { if (doc.exists) { - processAndAppendReturn(doc.data(),'repsec2') + processAndAppendReturn(doc.data(), 'repsec2') } }).then(function() { document.getElementById('FormData').innerHTML += "

" + 'Cycle Times' + "

"; @@ -156,7 +156,7 @@ function cseries(seriesName) { var cyc = firebase.firestore().collection('appBuilding').doc('team-' + teamNum).collection('competitions').doc(currentComp).collection('appElements').doc('quantitativeCycleTimes'); cyc.get().then(function(doc) { if (doc.exists) { - processAndAppendReturn(doc.data(),'repsec3') + processAndAppendReturn(doc.data(), 'repsec3') } }).then(function() { document.getElementById('FormData').innerHTML += "
"; @@ -169,7 +169,7 @@ function cseries(seriesName) { var ss = firebase.firestore().collection('appBuilding').doc('team-' + teamNum).collection('competitions').doc(currentComp).collection('appElements').doc('qualitativeSandstorm'); ss.get().then(function(doc) { if (doc.exists) { - processAndAppendReturn(doc.data(),'repsec1') + processAndAppendReturn(doc.data(), 'repsec1') } }).then(function() { document.getElementById('FormData').innerHTML += "

" + 'TeleOp' + "

"; @@ -177,7 +177,7 @@ function cseries(seriesName) { var to = firebase.firestore().collection('appBuilding').doc('team-' + teamNum).collection('competitions').doc(currentComp).collection('appElements').doc('qualitativeTeleop'); to.get().then(function(doc) { if (doc.exists) { - processAndAppendReturn(doc.data(),'repsec2') + processAndAppendReturn(doc.data(), 'repsec2') } }).then(function() { document.getElementById('FormData').innerHTML += "

" + 'Strategy' + "

"; @@ -185,7 +185,7 @@ function cseries(seriesName) { var strat = firebase.firestore().collection('appBuilding').doc('team-' + teamNum).collection('competitions').doc(currentComp).collection('appElements').doc('qualitativeStrategy'); strat.get().then(function(doc) { if (doc.exists) { - processAndAppendReturn(doc.data(),'repsec3') + processAndAppendReturn(doc.data(), 'repsec3') } }).then(function() { document.getElementById('FormData').innerHTML += ""; @@ -198,7 +198,7 @@ function cseries(seriesName) { }); } -function processAndAppendReturn(data,newloc) { +function processAndAppendReturn(data, newloc) { labels = Object.keys(data); var index = labels.indexOf('header'); if (index > -1) { @@ -224,22 +224,22 @@ function processAndAppendReturn(data,newloc) { return a[1].order - b[1].order; }) for (var j = 0; j < questions.length; j++) { - document.getElementById(newloc).innerHTML += "
"; - document.getElementById(newloc+j.toString()).innerHTML += questions[j][0]; + document.getElementById(newloc).innerHTML += "
"; + document.getElementById(newloc + j.toString()).innerHTML += questions[j][0]; if (questions[j][1]['type'] == 'shortText') { - document.getElementById(newloc+j.toString()).innerHTML += ""; + document.getElementById(newloc + j.toString()).innerHTML += ""; } else if (questions[j][1]['type'] == 'textField') { - document.getElementById(newloc+j.toString()).innerHTML += "
"; + document.getElementById(newloc + j.toString()).innerHTML += "
"; } else if (questions[j][1]['type'] == 'stepper') { - document.getElementById(newloc+j.toString()).innerHTML += "" + (questions[j][1]['defaultValue']).toString() + ""; - }else if (questions[j][1]['type'] == 'label') { - document.getElementById(newloc+j.toString()).innerHTML += "" + '0' + ""; + document.getElementById(newloc + j.toString()).innerHTML += "" + (questions[j][1]['defaultValue']).toString() + ""; + } else if (questions[j][1]['type'] == 'label') { + document.getElementById(newloc + j.toString()).innerHTML += "" + '0' + ""; } else if (questions[j][1]['type'] == 'slider') { - document.getElementById(newloc+j.toString()).innerHTML += "  " + questions[j][1]['min'] + "  "; - document.getElementById(newloc+j.toString()).innerHTML += ""; - document.getElementById(newloc+j.toString()).innerHTML += "  " + questions[j][1]['max']; + document.getElementById(newloc + j.toString()).innerHTML += "  " + questions[j][1]['min'] + "  "; + document.getElementById(newloc + j.toString()).innerHTML += ""; + document.getElementById(newloc + j.toString()).innerHTML += "  " + questions[j][1]['max']; } else if (questions[j][1]['type'] == 'segment') { - document.getElementById(newloc+j.toString()).innerHTML += "
" + document.getElementById(newloc + j.toString()).innerHTML += "
" for (var k = 0; k < questions[j][1]['elements'].length; k++) { //// TODO: replace with real buttons for good styling document.getElementById(questions[j][0]).innerHTML += questions[j][1]['elements'][k]; @@ -307,14 +307,15 @@ function updateForm(locString, teamNum, competition) { } */ function dec(id) { - document.getElementById(id).innerHTML = ""+(parseInt(document.getElementById(id).textContent) - 1).toString()+"" + document.getElementById(id).innerHTML = "" + (parseInt(document.getElementById(id).textContent) - 1).toString() + "" } function inc(id) { - document.getElementById(id).innerHTML = ""+(parseInt(document.getElementById(id).textContent) + 1).toString()+"" + document.getElementById(id).innerHTML = "" + (parseInt(document.getElementById(id).textContent) + 1).toString() + "" } + function capitalizeFirstLetter(string) { - return string.charAt(0).toUpperCase() + string.slice(1); + return string.charAt(0).toUpperCase() + string.slice(1); } function subReport() { @@ -336,44 +337,44 @@ function subReport() { var matchNum = document.getElementById('mselect').value; var series = capitalizeFirstLetter(document.getElementById('sselect').value); var push = {} - push[series+'-'+user.uid]={} + push[series + '-' + user.uid] = {} var x = document.getElementById('repsec1').children; for (var i = 0; i < x.length; i++) { if (x[i].children[0].tagName == "INPUT") { - push[series+'-'+user.uid][x[i].children[0].id] = x[i].children[0].tagName; - } else if (x[i].children[1].tagName == "TEXTAREA") { - push[series+'-'+user.uid][x[i].children[1].id] = x[i].children[1].innerHTML; + push[series + '-' + user.uid][x[i].children[0].id] = x[i].children[0].tagName; } else if (x[i].children[0].tagName == "SPAN") { - push[series+'-'+user.uid][x[i].children[0].id] = x[i].children[0].innerText; + push[series + '-' + user.uid][x[i].children[0].id] = x[i].children[0].innerText; } else if (x[i].children[0].tagName == "DIV") { var name = x[i].children[0].id; - push[series+'-'+user.uid][name] = document.querySelector('input[name="' + name + '"]:checked').value; + push[series + '-' + user.uid][name] = document.querySelector('input[name="' + name + '"]:checked').value; + } else if (x[i].children[1].tagName == "TEXTAREA") { + push[series + '-' + user.uid][x[i].children[1].id] = x[i].children[1].innerHTML; } } var x = document.getElementById('repsec2').children; for (var i = 0; i < x.length; i++) { if (x[i].children[0].tagName == "INPUT") { - push[series+'-'+user.uid][x[i].children[0].id] = x[i].children[0].tagName; - } else if (x[i].children[1].tagName == "TEXTAREA") { - push[series+'-'+user.uid][x[i].children[1].id] = x[i].children[1].innerHTML; + push[series + '-' + user.uid][x[i].children[0].id] = x[i].children[0].tagName; } else if (x[i].children[0].tagName == "SPAN") { - push[series+'-'+user.uid][x[i].children[0].id] = x[i].children[0].innerText; + push[series + '-' + user.uid][x[i].children[0].id] = x[i].children[0].innerText; } else if (x[i].children[0].tagName == "DIV") { var name = x[i].children[0].id; - push[series+'-'+user.uid][name] = document.querySelector('input[name="' + name + '"]:checked').value; + push[series + '-' + user.uid][name] = document.querySelector('input[name="' + name + '"]:checked').value; + } else if (x[i].children[1].tagName == "TEXTAREA") { + push[series + '-' + user.uid][x[i].children[1].id] = x[i].children[1].innerHTML; } } var x = document.getElementById('repsec3').children; for (var i = 0; i < x.length; i++) { if (x[i].children[0].tagName == "INPUT") { - push[series+'-'+user.uid][x[i].children[0].id] = x[i].children[0].tagName; - } else if (x[i].children[1].tagName == "TEXTAREA") { - push[series+'-'+user.uid][x[i].children[1].id] = x[i].children[1].innerHTML; + push[series + '-' + user.uid][x[i].children[0].id] = x[i].children[0].tagName; } else if (x[i].children[0].tagName == "SPAN") { - push[series+'-'+user.uid][x[i].children[0].id] = x[i].children[0].innerText; + push[series + '-' + user.uid][x[i].children[0].id] = x[i].children[0].innerText; } else if (x[i].children[0].tagName == "DIV") { var name = x[i].children[0].id; - push[series+'-'+user.uid][name] = document.querySelector('input[name="' + name + '"]:checked').value; + push[series + '-' + user.uid][name] = document.querySelector('input[name="' + name + '"]:checked').value; + } else if (x[i].children[1].tagName == "TEXTAREA") { + push[series + '-' + user.uid][x[i].children[1].id] = x[i].children[1].innerHTML; } } firebase.firestore().collection("data").doc('team-' + document.getElementById('tns').value).collection(currentComp).doc("team-" + teamNum).collection('matches').doc('match-' + matchNum).set(push, {