Skip to content

Commit 5c2b670

Browse files
committed
Minor Changes
1 parent f66fec4 commit 5c2b670

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

css/style.css

+9-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,15 @@ video {
201201
cursor:pointer;
202202
}
203203
.mapname {
204-
display:none;
204+
position:absolute;
205+
background:var(--colorIn);
206+
color:var(--color);
207+
top:10px;
208+
left:10px;
209+
padding:5px 10px;
210+
border-radius: 10px;
211+
font-size:18px;
212+
max-width:200px;
205213
}
206214
.mapdiff {
207215
position:absolute;

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ <h2>Takoma Park, MD</h2>
4242
<h1>Choose</h1>
4343
<div class='choice'>
4444
<div id="eventbanner"></div>
45-
<div onclick='tab(2);' class="bgbl">Quick Start</div>
45+
<div onclick='tab(2);' class="bgbl">Maps (Start)</div>
4646
<div onclick='tab(5);'>New to Orienteering?</div>
4747
<div onclick='tab(12);'>How to use this Application?</div>
4848
<div onclick='location.href="https://forms.gle/FRnQaFRk9rA4GxM36";'>Report Bug</div>

js/script.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ const loadMaps = function() {
181181
map.style.backgroundSize = "cover";
182182
let mapName = document.createElement("div");
183183
mapName.classList.add("mapname");
184-
mapName.textContent = basic.maps[i]["Name"];
184+
mapName.textContent = shortenTextByPx(basic.maps[i]["Name"], 200);
185185
map.appendChild(mapName);
186186
let mapDiff = document.createElement("div");
187187
mapDiff.classList.add("mapdiff");
@@ -635,4 +635,17 @@ const skipBtn = function() {
635635
orienteering["skips"]++;
636636
updateCourseInfo();
637637
}
638+
};
639+
const shortenTextByPx = function(text, maxWidth) {
640+
const canvas = document.createElement("canvas");
641+
const context = canvas.getContext("2d");
642+
context.font = "18px Arial";
643+
if (context.measureText(text).width <= maxWidth) {
644+
return text;
645+
}
646+
let shortenedText = text;
647+
while (context.measureText(shortenedText + "...").width > maxWidth) {
648+
shortenedText = shortenedText.slice(0, -1);
649+
}
650+
return shortenedText + "...";
638651
};

0 commit comments

Comments
 (0)