Skip to content

Commit 6839f63

Browse files
committed
reset timer
1 parent f1e47db commit 6839f63

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

html/js/blunder-scores.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ function initialiseHighScores(all_puzzles, scores) {
1818
}
1919

2020
function highscore(key, all_puzzles, all_scores) {
21-
var scores = playerScores(key, all_scores);
21+
var scores = playerScores(key, all_scores).sort(function(a, b) {
22+
return a.score == b.score ? 0 : a.score < b.score ? 1 : -1;
23+
});
2224
var blank = '<div class="highscoreplayer"></div><div class="highscorescore">&ensp;</div>';
2325
var result = '<div class="highscorebox"><div class="highscoreheader">' + description(key) + '</div>';
2426
if (scores.length > 0) {
@@ -79,7 +81,7 @@ function showHighScoreForm(category, correct) {
7981
document.getElementById("next").disabled = true;
8082
$("#sendscore").removeAttr("click");
8183
$("#sendscore").removeAttr("onclick");
82-
$("#sendscore").prop('onclick',null).off('click');
84+
$("#sendscore").prop('onclick', null).off('click');
8385
$('#sendscore').on('click', function f() {
8486
console.log("clicked");
8587
submitHighscore(category, correct);
@@ -100,7 +102,7 @@ function updateHighscores(game, player, score) {
100102
console.log("invalid username " + player);
101103
return;
102104
}
103-
105+
104106
$.ajax({
105107
url: hss + "/set" +
106108
"?game=" + encodeURIComponent(game) +
@@ -112,12 +114,14 @@ function updateHighscores(game, player, score) {
112114
});
113115
}
114116

117+
var timeinterval;
115118
/**
116119
* 60 second timer
117120
*/
118121
function initializeTimer(id, endtime) {
119122
var timer = document.getElementById(id);
120-
var timeinterval = setInterval(function() {
123+
clearInterval(timeinterval);
124+
timeinterval = setInterval(function() {
121125
var t = endtime - Date.now();
122126
var seconds = (t / 1000);
123127
seconds = (seconds % 60).toFixed(0);

0 commit comments

Comments
 (0)