Commit 5c2b670 1 parent f66fec4 commit 5c2b670 Copy full SHA for 5c2b670
File tree 3 files changed +24
-3
lines changed
3 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -201,7 +201,15 @@ video {
201
201
cursor : pointer;
202
202
}
203
203
.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 ;
205
213
}
206
214
.mapdiff {
207
215
position : absolute;
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ <h2>Takoma Park, MD</h2>
42
42
< h1 > Choose</ h1 >
43
43
< div class ='choice '>
44
44
< div id ="eventbanner "> </ div >
45
- < div onclick ='tab(2); ' class ="bgbl "> Quick Start</ div >
45
+ < div onclick ='tab(2); ' class ="bgbl "> Maps ( Start) </ div >
46
46
< div onclick ='tab(5); '> New to Orienteering?</ div >
47
47
< div onclick ='tab(12); '> How to use this Application?</ div >
48
48
< div onclick ='location.href="https://forms.gle/FRnQaFRk9rA4GxM36"; '> Report Bug</ div >
Original file line number Diff line number Diff line change @@ -181,7 +181,7 @@ const loadMaps = function() {
181
181
map . style . backgroundSize = "cover" ;
182
182
let mapName = document . createElement ( "div" ) ;
183
183
mapName . classList . add ( "mapname" ) ;
184
- mapName . textContent = basic . maps [ i ] [ "Name" ] ;
184
+ mapName . textContent = shortenTextByPx ( basic . maps [ i ] [ "Name" ] , 200 ) ;
185
185
map . appendChild ( mapName ) ;
186
186
let mapDiff = document . createElement ( "div" ) ;
187
187
mapDiff . classList . add ( "mapdiff" ) ;
@@ -635,4 +635,17 @@ const skipBtn = function() {
635
635
orienteering [ "skips" ] ++ ;
636
636
updateCourseInfo ( ) ;
637
637
}
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 + "..." ;
638
651
} ;
You can’t perform that action at this time.
0 commit comments