2011-m1s2-ter/code/html5/score.js
2011-04-10 14:12:18 +02:00

39 lines
838 B
JavaScript

function jss() {
var w, h;
w = $(window).width();
h = $(window).height();
var mch = h/8, mnh = h*0.075;
$("body, html")
.css({
padding: 0,
margin: 0,
overflow: "hidden",
textAlign: "left"
});
$("#screen")
.wh(w, h)
.north($("body").north()); // TODO : par rapport à la fenêtre entière.
}
$(function () {
var url = "score.json";
$.getJSON(url, function(data) {
console.log(data);
$.each(data.scores, function(i,e) {
var percentScore = (e.score - data.minScore) / (data.maxScore - data.minScore);
$("#templates .scoreLine")
.clone()
.find(".word").text(e.name).end()
.find(".score")
.text(e.score)
.css("color","rgb("+(255 - 255*percentScore).clip(0,255)+","+(191*percentScore).clip(0,255,true)+",0)")
.end()
.appendTo(".scores");
jss();
});
});
jss();
});