]> git.sesse.net Git - ultimatescore/commitdiff
Add a hack around Exo's variable-width numerals.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 7 Apr 2018 23:26:19 +0000 (01:26 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 7 Apr 2018 23:26:19 +0000 (01:26 +0200)
score.js

index 17ac07c4f8a679b7ec2466b59a1c6a43135be7ce..3f0a4d055daad4353f9d96ceffedd3adaf9679f8 100644 (file)
--- a/score.js
+++ b/score.js
@@ -164,7 +164,20 @@ function update_clock()
        let sec = elapsed % 60;
 
        if (sec < 10) sec = "0" + sec;
-       document.getElementById('clock').innerHTML = min + ":" + sec;
+       let text = min + ":" + sec;
+
+       // This is a hack around the fact that Exo has variable-width numerals.
+       // It doesn't look fantastic, but for the clock, it's better not to have
+       // the text jumping around.
+       let html = "";
+       for (let i = 0; i < text.length; ++i) {
+               if (text.charAt(i) === ':') {
+                       html += ':';
+               } else {
+                       html += "<div style='display: inline-block; width: 15px'>" + text.charAt(i) + "</div>";
+               }
+       }
+       document.getElementById('clock').innerHTML = html;
 }
 
 function goalA()