Skip to content

Commit 3200ca3

Browse files
committed
progress bar
1 parent b8afe0a commit 3200ca3

File tree

3 files changed

+53
-5
lines changed

3 files changed

+53
-5
lines changed

css/style.css

+26
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ button {
112112
display:block;
113113
margin:20px auto;
114114
}
115+
.mainPageBtnH {
116+
width:calc(50% - 2em);
117+
background:var(--c1);
118+
display:block;
119+
margin:20px auto;
120+
}
115121
.mainPageAlt {
116122
width:calc(50% - 2em);
117123
/* background:linear-gradient(-200deg, var(--c2),var(--c1));*/
@@ -396,4 +402,24 @@ p {
396402
}
397403
#name:focus {
398404
border:3px solid var(--c1);
405+
}
406+
.progress-container {
407+
position:absolute;
408+
bottom:0px;
409+
left:0;
410+
margin:20px;
411+
width: calc(100% - 40px);
412+
background-color: var(--colorIn);
413+
height: 20px;
414+
border-radius: 20px;
415+
overflow: hidden;
416+
}
417+
418+
.progress-bar {
419+
position:relative;
420+
width: 0;
421+
height: 100%;
422+
background-color: var(--color);
423+
border-radius: 20px;
424+
transition: width 3.5s linear;
399425
}

index.html

+10-1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ <h1 class='time'>00:00</h1>
142142
<h1>Confirmed</h1>
143143
<h2></h2>
144144
<div class='circle lime'></div>
145+
<div class="progress-container">
146+
<div id="barConfirmed" class="progress-bar"></div>
147+
</div>
145148
<!-- Course with timer and check location button -->
146149
</div>
147150
<!-- 8 -->
@@ -150,14 +153,17 @@ <h1>Inaccuracy</h1>
150153
<h2 id="testing"></h2>
151154
<h2>Check your accuracy or position and try again.</h2>
152155
<div class='circle red'>×</div>
156+
<div class="progress-container">
157+
<div id="barInaccuracy" class="progress-bar"></div>
158+
</div>
153159
<!-- Course with timer and check location button -->
154160
</div>
155161
<!-- 9 -->
156162
<div class='tab' id='course'>
157163
<h1>Options</h1>
164+
<div class='button mainPageBtnH' onclick='openMap();'>View Map</div>
158165
<div class='button mainPageBtn' onclick='newGame();'>Quit Course</div>
159166
<div class='button mainPageBtn' onclick='skipBtn();'>Skip Control</div>
160-
<div class='button mainPageBtn' onclick='openMap();'>View Map</div>
161167
<div class='button mainPageBtn' onclick='openFullscreen();'>Enter Fullscreen</div>
162168
<div class='button mainPageBtn' onclick='hotcoldmode();'>HotCold (Testing)</div>
163169
<!-- <div class='button mainPageBtn' onclick='closeFullscreen();'>Exit Fullscreen</div> -->
@@ -176,6 +182,9 @@ <h1>Connection</h1>
176182
<h2 id="testing"></h2>
177183
<h2>Your accuracy is too low to confirm that you are in the correct area.</h2>
178184
<div class='circle blue'>?</div>
185+
<div class="progress-container">
186+
<div id="barConnection" class="progress-bar"></div>
187+
</div>
179188
<!-- Course with timer and check location button -->
180189
</div>
181190
<!-- 12 -->

js/script.js

+17-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ const basic = {
1111
navcon:true,
1212
timer:null,
1313
hotcold: false,
14-
hotcolden:0
14+
hotcolden:0,
15+
mid:5000
1516
};
1617
let shareData = {
1718
title: "Takoma Park Orienteering",
@@ -324,9 +325,10 @@ let accuracyLat = (accuracy/(2*Math.PI*6371000*Math.cos(toRad(targetLat))/360)).
324325
orienteering["currentControl"]++;
325326
if (orienteering["currentControl"] < basic.maps[orienteering["courseindex"]]["Controls"].length) {
326327
tab(7);
328+
startBarProgress("barConfirmed");
327329
setTimeout(function() {
328330
tab(6);
329-
},3500);
331+
},basic.mid);
330332
}
331333
else {
332334
tab(4);
@@ -337,15 +339,17 @@ let accuracyLat = (accuracy/(2*Math.PI*6371000*Math.cos(toRad(targetLat))/360)).
337339
//testing.innerHTML = ("off by: "+calculateDistance(currentLat,currentLong,targetLat,targetLong)+`m<div onclick='warning("Cords","`+currentLat.toFixed(6)+", "+currentLong.toFixed(6)+` <br> `+targetLat.toFixed(6)+", "+targetLong.toFixed(6)+`",false);'>testing</div>`);
338340
if (!(position.coords.accuracy <= 15)) {
339341
tab(11);
342+
startBarProgress("barConnection");
340343
setTimeout(function() {
341344
tab(6);
342-
},3500);
345+
},basic.mid);
343346
}
344347
else {
345348
tab(8);
349+
startBarProgress("barInaccuracy");
346350
setTimeout(function() {
347351
tab(6);
348-
},3500);
352+
},basic.mid);
349353
}
350354
}
351355
basic.navcon = true;
@@ -648,4 +652,13 @@ const shortenTextByPx = function(text, maxWidth) {
648652
shortenedText = shortenedText.slice(0, -1);
649653
}
650654
return shortenedText + "...";
655+
};
656+
const startBarProgress = (progressBarId) => {
657+
const progressBar = document.getElementById(progressBarId);
658+
progressBar.style.transition = "width "+(basic.mid/1000)+"s linear";
659+
progressBar.style.width = "0";
660+
setTimeout(() => {
661+
progressBar.style.transition = "none";
662+
progressBar.style.width = "100%";
663+
}, basic.mid);
651664
};

0 commit comments

Comments
 (0)