don't sort matches alphabetically, sort them numerically

This commit is contained in:
Jacob Levine 2019-03-22 07:48:44 -05:00
parent 169c1737b2
commit bb5c38fbfe

View File

@ -71,12 +71,19 @@ function changeTeam(teamNum) {
if (currentComp != null) { if (currentComp != null) {
matches = firebase.firestore().collection('appBuilding').doc('team-' + teamNum).collection('competitions').doc(currentComp).collection('scoutsAndSchedule'); matches = firebase.firestore().collection('appBuilding').doc('team-' + teamNum).collection('competitions').doc(currentComp).collection('scoutsAndSchedule');
matches.get().then(function(qs) { matches.get().then(function(qs) {
var oklist = []
qs.forEach(function(dc) { qs.forEach(function(dc) {
//regex search! //regex search!
var pattern = /\d+/; var pattern = /\d+/;
var name = dc.id; var name = dc.id;
document.getElementById('mselect').innerHTML += "<option value='" + name.match(pattern)[0].toString() + "'>" + name.match(pattern)[0].toString() + "</option>"; oklist.push(name.match(pattern)[0].toString())
}); });
oklist.sort(function(a, b) {
return parseInt(a) - parseInt(b)
})
for (var i = 0; i < oklist.length; i++) {
document.getElementById('mselect').innerHTML += "<option value='" + oklist[i] + "'>" + oklist[i] + "</option>";
}
cmatch(document.getElementById('mselect').value); cmatch(document.getElementById('mselect').value);
}); });
} }
@ -313,6 +320,7 @@ function dec(id) {
function inc(id) { function inc(id) {
document.getElementById(id).innerHTML = "<input type='button' onclick=\"dec('" + id + "')\" value='-'></input>" + (parseInt(document.getElementById(id).textContent) + 1).toString() + "<input type='button' onclick=\"inc('" + id + "')\" value='+'></input>" document.getElementById(id).innerHTML = "<input type='button' onclick=\"dec('" + id + "')\" value='-'></input>" + (parseInt(document.getElementById(id).textContent) + 1).toString() + "<input type='button' onclick=\"inc('" + id + "')\" value='+'></input>"
} }
function capitalizeFirstLetter(string) { function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1); return string.charAt(0).toUpperCase() + string.slice(1);
} }
@ -381,7 +389,7 @@ function subReport() {
} catch (e) { } catch (e) {
} }
firebase.firestore().collection('webData').doc('test').set(push).then(function() { firebase.firestore().collection("data").doc('team-' + document.getElementById('tns').value).collection(currentComp).doc("team-" + teamNum).collection('matches').doc('match-' + matchNum).set(function() {
alert('Submitted!') alert('Submitted!')
setTimeout(function() { setTimeout(function() {
window.location.href = '../scout'; window.location.href = '../scout';