mirror of
https://github.com/Febbweiss/sis.git
synced 2026-03-04 22:25:35 +00:00
Initial commit
This commit is contained in:
44
js/scoreboard.js
Normal file
44
js/scoreboard.js
Normal file
@@ -0,0 +1,44 @@
|
||||
var SCOREBOARD = {
|
||||
score: 0,
|
||||
scoreLength: 6,
|
||||
|
||||
init: function(size) {
|
||||
if( typeof size !== "undefined" )
|
||||
SCOREBOARD.scoreLength = size;
|
||||
SCOREBOARD.score = 0;
|
||||
SCOREBOARD.set_score( 0 );
|
||||
},
|
||||
|
||||
add: function(addToScore, div) {
|
||||
SCOREBOARD.set_score( SCOREBOARD.score + addToScore, div);
|
||||
},
|
||||
|
||||
set_score: function( score, div ) {
|
||||
var currentScore = "";
|
||||
var imageScore = "";
|
||||
|
||||
SCOREBOARD.score = score;
|
||||
currentScore = SCOREBOARD.pad();
|
||||
|
||||
for(i = 0; i < String(currentScore).length; i++) {
|
||||
imageScore += "<div class='clock n"+ String(currentScore)[i]+"'></div>";
|
||||
}
|
||||
|
||||
if( typeof div === "undefined" )
|
||||
div = $(".subScoreboard");
|
||||
div.empty();
|
||||
div.append( imageScore );
|
||||
},
|
||||
|
||||
pad: function() {
|
||||
var str = '' + SCOREBOARD.score;
|
||||
while (str.length < SCOREBOARD.scoreLength) {
|
||||
str = '0' + str;
|
||||
}
|
||||
return str;
|
||||
},
|
||||
|
||||
callback: function() {
|
||||
console.log( "SCOREBOARD.callback" );
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user