Skip to content

Commit e70a8b9

Browse files
committed
skips
1 parent 1ecc26a commit e70a8b9

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ <h2>Check your accuracy or position and try again.</h2>
155155
<div class='tab' id='course'>
156156
<h1>Options</h1>
157157
<div class='button mainPageBtn' onclick='newGame();'>Quit Course</div>
158-
<!-- <div class='button mainPageBtn' onclick=''>Skip (coming soon)</div> -->
158+
<div class='button mainPageBtn' onclick='skipBtn();'>Skip Control</div>
159159
<div class='button mainPageBtn' onclick='openMap();'>View Map</div>
160160
<div class='button mainPageBtn' onclick='openFullscreen();'>Enter Fullscreen</div>
161161
<div class='button mainPageBtn' onclick='hotcoldmode();'>HotCold (Testing)</div>

js/firebase.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const analytics = getAnalytics(app);
1919
const db = getDatabase(app);
2020

2121
const insertData = function(orienteering, warning) {
22-
if (orienteering["endtime"] != 0) {
22+
if (orienteering["endtime"] != 0 && orienteering["skips"] == 0) {
2323
set(ref(db, orienteering["course"]+"/"+(orienteering["name"]+new Date().getTime())), {
2424
Name:orienteering["name"],
2525
Time:(orienteering["endtime"]-orienteering["starttime"]+orienteering["bonustime"])
@@ -31,6 +31,10 @@ const insertData = function(orienteering, warning) {
3131
alert("An error occurred: " + error.message);
3232
});
3333
}
34+
else {
35+
warning("Course Complete","Your course was not saved. Skips: "+orienteering["skips"],false);
36+
localStorage.clear();
37+
}
3438
};
3539
window.insertData = insertData;
3640
const requestData = function(course) {

js/script.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,10 @@ const warning = function(h,p,f) {
150150
}
151151
};
152152
const newGame = function() {
153-
localStorage.clear();
154-
location.reload();
153+
if (confirm("Are you sure you want to restart?")) {
154+
localStorage.clear();
155+
location.reload();
156+
}
155157
};
156158
const openMap = function() {
157159
window.open(orienteering["currentMap"], '_blank');
@@ -527,7 +529,8 @@ basic.maps = JSON.parse(responseText)["Maps"];
527529
"elevation":[],
528530
"starttime":0,
529531
"endtime":0,
530-
"bonustime":0
532+
"bonustime":0,
533+
"skips":0
531534
}`);
532535
}
533536
loadMaps();
@@ -625,4 +628,11 @@ const setName = function() {
625628
orienteering["name"] = document.getElementById("name").value;
626629
}
627630
tab(6);loadCourse();
631+
};
632+
const skipBtn = function() {
633+
if (orienteering["currentControl"] != 0 && orienteering["currentControl"] < (basic.maps[orienteering["courseindex"]]["Controls"].length-1) && confirm("Are you sure you want to skip this control? You will be disqualified and score will not be added to leaderboard.")) {
634+
orienteering["currentControl"]++;
635+
orienteering["skips"]++;
636+
updateCourseInfo();
637+
}
628638
};

0 commit comments

Comments
 (0)