Couleurs sur la page de scores.
This commit is contained in:
parent
3af3ccc059
commit
974d757c4e
|
@ -1,5 +1,5 @@
|
|||
Number.prototype.clip = function(min, max) {
|
||||
return Math.min(Math.max(this, min), max);
|
||||
Number.prototype.clip = function(min, max, floor) {
|
||||
return Math.min(Math.max(floor ? Math.floor(this) : this, min), max);
|
||||
};
|
||||
|
||||
function dichotomy(start, isBigger) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
function jss() {
|
||||
// TODO : réduire le nombre de fitIn ou fitFont, ou bien les précalculer.
|
||||
var w, h;
|
||||
//w = 480; h=800;
|
||||
w = $(window).width();
|
||||
h = $(window).height();
|
||||
|
||||
|
|
|
@ -1,13 +1,39 @@
|
|||
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, function(i,e) {
|
||||
$.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).end()
|
||||
.appendTo(".scores")
|
||||
.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();
|
||||
});
|
|
@ -1 +1 @@
|
|||
[{"id":84632,"name":"camion","score":3},{"id":61939,"name":"transbahutage","score":10},{"id":104263,"name":"trimbaler","score":4},{"id":44654,"name":"transporter","score":-2},{"id":38285,"name":"d\u00e9m\u00e9nageur","score":5},{"id":43404,"name":"porter","score":5},{"id":63192,"name":"transports","score":-1},{"id":130473,"name":"enthousiasmer","score":0},{"id":90461,"name":"se trimbaler","score":6},{"id":134609,"name":"baguenauder","score":9}]
|
||||
{"minScore":-5,"maxScore":10,"scores":[{"id":84632,"name":"camion","score":3},{"id":61939,"name":"transbahutage","score":10},{"id":104263,"name":"trimbaler","score":4},{"id":44654,"name":"transporter","score":-2},{"id":38285,"name":"d\u00e9m\u00e9nageur","score":5},{"id":43404,"name":"porter","score":5},{"id":63192,"name":"transports","score":-1},{"id":130473,"name":"enthousiasmer","score":0},{"id":90461,"name":"se trimbaler","score":6},{"id":134609,"name":"baguenauder","score":9}]}
|
Loading…
Reference in New Issue
Block a user