From 1fdd80e31b98893675efc189bc1f508569a94899 Mon Sep 17 00:00:00 2001 From: Jacob Levine Date: Mon, 18 Mar 2019 17:13:45 -0500 Subject: [PATCH] multiform demo mk 1 --- website/public/scout/rpts/index.html | 1 + website/public/scout/rpts/scripts.js | 36 ++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/website/public/scout/rpts/index.html b/website/public/scout/rpts/index.html index db8469fa..fd8dc069 100644 --- a/website/public/scout/rpts/index.html +++ b/website/public/scout/rpts/index.html @@ -35,6 +35,7 @@

Submit a Report:

+ Team Scouted:
diff --git a/website/public/scout/rpts/scripts.js b/website/public/scout/rpts/scripts.js index 057724e1..ea4a905b 100644 --- a/website/public/scout/rpts/scripts.js +++ b/website/public/scout/rpts/scripts.js @@ -99,6 +99,7 @@ function lastWord(words) { var n = words.split(" "); return n[n.length - 1]; } + function firstWord(words) { var n = words.split(" "); return n[0]; @@ -138,9 +139,7 @@ function updateForm(locString, teamNum, competition) { } else if (questions[j][1]['type'] = 'longText') { document.getElementById('FormData').innerHTML += ""; } else if (questions[j][1]['type'] = 'numerical') { - document.getElementById('FormData').innerHTML += "" + (questions[j][1]['default']).toString() + ""; + document.getElementById('FormData').innerHTML += "" + (questions[j][1]['default']).toString() + ""; } else if (questions[j][1]['type'] = 'range') { document.getElementById('FormData').innerHTML += "  " + questions[j][1]['min']['text'] + "  "; document.getElementById('FormData').innerHTML += ""; @@ -157,7 +156,7 @@ function updateForm(locString, teamNum, competition) { document.getElementById('FormData').innerHTML += "
"; } } - document.getElementById('FormData').innerHTML += "" + document.getElementById('FormData').innerHTML += "" }); } @@ -169,6 +168,33 @@ function inc(id) { document.getElementById(id).innerHTML = (parseInt(document.getElementById(id).innerHTML) + 1)).toString() } +function subReport(team, comp, matchNum) { + var push = {} + var x = document.getElementById('FormData').children; + for (var i = 0; i < x.length; i++) { + if (x[i].children[0].tagName == "INPUT") { + push[x[i].children[0].id] = x[i].children[0].tagName; + } else if (x[i].children[0].tagName == "TEXTAREA") { + push[x[i].children[0].id] = x[i].children[0].innerHTML; + } else if (x[i].children[0].tagName == "SPAN") { + push[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[name]=document.querySelector('input[name="'+name+'"]:checked').value; + } + } + var user = firebase.auth().currentUser; + firebase.firestore().collection("teamData").doc('team-' + team).collection('scouts').doc(user.uid).collection(comp).doc("team-" + scoutedTeamNumber + matchNum).set(push, { + merge: true + }).then(function () { + firebase.firestore().collection("data").doc('team-' + team).collection(comp).doc("team-" + scoutedTeamNumber).collection('matches').doc('match-' + matchNum).set(push, { + merge: true + }); + }); +} + +/* + function subRes() { firebase.firestore().collection('teamData').doc('team-' + document.getElementById('tns').value).get().then(function(doc) { if (doc.exists) { @@ -242,4 +268,4 @@ function subRes() { }, 500); }) -} +}*/