commit 974d757c4e14191a0c562d37b0f991aafc55caf8
parent 3af3ccc059c004fd60d146360b6b654b585c7aa4
Author: Georges Dupéron <jahvascriptmaniac+github@free.fr>
Date: Sun, 10 Apr 2011 14:12:18 +0200
Couleurs sur la page de scores.
Diffstat:
4 files changed, 35 insertions(+), 9 deletions(-)
diff --git a/code/html5/my-extensions.js b/code/html5/my-extensions.js
@@ -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) {
diff --git a/code/html5/pticlic.js b/code/html5/pticlic.js
@@ -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();
diff --git a/code/html5/score.js b/code/html5/score.js
@@ -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();
});
\ No newline at end of file
diff --git a/code/html5/score.json b/code/html5/score.json
@@ -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}]
-\ No newline at end of file
+{"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}]}
+\ No newline at end of file