commit cc5b862248e12e897427053cb1a45ec3cc432dc4 parent 6986686df6dfc75c0c908a236c99d7d1cc84ed19 Author: Yoann <yoann.b87@voila.fr> Date: Thu, 28 Apr 2011 18:15:27 +0200 Merge branch 'unstable' of https://github.com/jsmaniac/2011-m1s2-ter into unstable Diffstat:
36 files changed, 56 insertions(+), 36 deletions(-)
diff --git a/code/serveur/php/jeu.html b/code/serveur/php/jeu.html @@ -52,6 +52,8 @@ body { <script src="ressources/pticlic.js"></script> </head> <body> + <div class="screen" id="logo"> + </div> <div class="screen" id="game"> <div id="mc-caption-block"></div> <div id="mn-caption-block"></div> @@ -64,19 +66,19 @@ body { <span id="title">PtiClic</span> <div class="frontpage-button game"> - <div><img class="icon" alt="" src="ressources/img/mode_normal.png" /></div> + <div><img class="icon" alt="" src="ressources/img/72/default.png" /></div> <div class="text">Jouer</div> </div> <div class="frontpage-button prefs"> - <div><img class="icon" alt="" src="ressources/img/config.png" /></div> + <div><img class="icon" alt="" src="ressources/img/72/default.png" /></div> <div class="text">Configuration</div> </div> <div class="frontpage-button connection"> - <div><img class="icon" alt="" src="ressources/img/config.png" /></div> + <div><img class="icon" alt="" src="ressources/img/72/default.png" /></div> <div class="text">Connexion</div> </div> <div class="frontpage-button about"> - <div><img class="icon" alt="" src="ressources/img/rel/default.png" /></div> + <div><img class="icon" alt="" src="ressources/img/72/default.png" /></div> <div class="text">A Propos</div> </div> </div> @@ -87,7 +89,7 @@ body { </div> <div id="templates" style="display: none;"> <div class="relationBox"> - <div class="relation"><img class="icon" alt="" src="ressources/img/rel/default.png" /><span class="text"></span></div> + <div class="relation"><img class="icon" alt="" src="ressources/img/72/default.png" /><span class="text"></span></div> <div class="clearboth"></div> </div> <div class="scoreLine"> diff --git a/code/serveur/php/ressources/img/36/-1.png b/code/serveur/php/ressources/img/36/-1.png Binary files differ. diff --git a/code/serveur/php/ressources/img/36/0.png b/code/serveur/php/ressources/img/36/0.png Binary files differ. diff --git a/code/serveur/php/ressources/img/36/10.png b/code/serveur/php/ressources/img/36/10.png Binary files differ. diff --git a/code/serveur/php/ressources/img/36/5.png b/code/serveur/php/ressources/img/36/5.png Binary files differ. diff --git a/code/serveur/php/ressources/img/36/7.png b/code/serveur/php/ressources/img/36/7.png Binary files differ. diff --git a/code/serveur/php/ressources/img/36/9.png b/code/serveur/php/ressources/img/36/9.png Binary files differ. diff --git a/code/serveur/php/ressources/img/36/aide.png b/code/serveur/php/ressources/img/36/aide.png Binary files differ. diff --git a/code/serveur/php/ressources/img/36/config.png b/code/serveur/php/ressources/img/36/config.png Binary files differ. diff --git a/code/serveur/php/ressources/img/rel/default.png b/code/serveur/php/ressources/img/36/default.png Binary files differ. diff --git a/code/serveur/php/ressources/img/36/mode_normal.png b/code/serveur/php/ressources/img/36/mode_normal.png Binary files differ. diff --git a/code/serveur/php/ressources/img/48/-1.png b/code/serveur/php/ressources/img/48/-1.png Binary files differ. diff --git a/code/serveur/php/ressources/img/48/0.png b/code/serveur/php/ressources/img/48/0.png Binary files differ. diff --git a/code/serveur/php/ressources/img/48/10.png b/code/serveur/php/ressources/img/48/10.png Binary files differ. diff --git a/code/serveur/php/ressources/img/48/5.png b/code/serveur/php/ressources/img/48/5.png Binary files differ. diff --git a/code/serveur/php/ressources/img/48/7.png b/code/serveur/php/ressources/img/48/7.png Binary files differ. diff --git a/code/serveur/php/ressources/img/48/9.png b/code/serveur/php/ressources/img/48/9.png Binary files differ. diff --git a/code/serveur/php/ressources/img/48/aide.png b/code/serveur/php/ressources/img/48/aide.png Binary files differ. diff --git a/code/serveur/php/ressources/img/48/config.png b/code/serveur/php/ressources/img/48/config.png Binary files differ. diff --git a/code/serveur/php/ressources/img/rel/default.png b/code/serveur/php/ressources/img/48/default.png Binary files differ. diff --git a/code/serveur/php/ressources/img/48/mode_normal.png b/code/serveur/php/ressources/img/48/mode_normal.png Binary files differ. diff --git a/code/serveur/php/ressources/img/rel/-1.png b/code/serveur/php/ressources/img/72/-1.png Binary files differ. diff --git a/code/serveur/php/ressources/img/rel/0.png b/code/serveur/php/ressources/img/72/0.png Binary files differ. diff --git a/code/serveur/php/ressources/img/rel/10.png b/code/serveur/php/ressources/img/72/10.png Binary files differ. diff --git a/code/serveur/php/ressources/img/rel/5.png b/code/serveur/php/ressources/img/72/5.png Binary files differ. diff --git a/code/serveur/php/ressources/img/rel/7.png b/code/serveur/php/ressources/img/72/7.png Binary files differ. diff --git a/code/serveur/php/ressources/img/rel/9.png b/code/serveur/php/ressources/img/72/9.png Binary files differ. diff --git a/code/serveur/php/ressources/img/aide.png b/code/serveur/php/ressources/img/72/aide.png Binary files differ. diff --git a/code/serveur/php/ressources/img/config.png b/code/serveur/php/ressources/img/72/config.png Binary files differ. diff --git a/code/serveur/php/ressources/img/rel/default.png b/code/serveur/php/ressources/img/72/default.png Binary files differ. diff --git a/code/serveur/php/ressources/img/mode_normal.png b/code/serveur/php/ressources/img/72/mode_normal.png Binary files differ. diff --git a/code/serveur/php/ressources/img/mode_chrono.png b/code/serveur/php/ressources/img/mode_chrono.png Binary files differ. diff --git a/code/serveur/php/ressources/img/mode_marathon.png b/code/serveur/php/ressources/img/mode_marathon.png Binary files differ. diff --git a/code/serveur/php/ressources/img/mode_ombre.png b/code/serveur/php/ressources/img/mode_ombre.png Binary files differ. diff --git a/code/serveur/php/ressources/my-extensions.js b/code/serveur/php/ressources/my-extensions.js @@ -4,7 +4,7 @@ Number.prototype.clip = function(min, max, floor) { } catch(e) {alert("Error Number.prototype.clip");alert(e);} }; -function dichotomy(start, isBigger) { +function dichotomy(start, isBigger, foo) { try { var i = 0, min = 0, max, half; @@ -57,7 +57,7 @@ $.fn.fitFont = function(w, h, minFont, maxFont) { fubar = wrappers; return (wrappers.maxHeight() > h || wrappers.maxWidth() > w); } catch(e) {alert("Error anonymous in $.fn.fitFont");alert(e);} - }).clip(minFont || 0, maxFont || Infinity)); + },this).clip(minFont || 0, maxFont || Infinity)); // Restore stuff this.css("position", oldpos); diff --git a/code/serveur/php/ressources/pticlic.js b/code/serveur/php/ressources/pticlic.js @@ -5,10 +5,12 @@ function State(init) { if (!this.screen) this.screen = 'frontpage'; } catch(e) {alert("Error State");alert(e);} }; +var futureHashChange = null; State.prototype.commit = function() { try { - location.hash="#"+encodeURI($.JSON.encode(this)); - return this; + futureHashChange = "#"+encodeURI($.JSON.encode(this)); + location.hash = futureHashChange; + return this; } catch(e) {alert("Error State.prototype.commit");alert(e);} }; State.prototype.get = function(key) { @@ -41,37 +43,47 @@ var oldScreen = ''; var ui = {}; function hashchange() { try { - var stateJSON = decodeURI(location.hash.substring(location.hash.indexOf("#") + 1)); - state = new State($.parseJSON(stateJSON)).validate(); + if (futureHashChange === location.hash) { + futureHashChange = null; + } else { + var stateJSON = decodeURI(location.hash.substring(location.hash.indexOf("#") + 1)); + state = new State($.parseJSON(stateJSON)).validate(); + } } catch(e) {alert("Error hashchange");alert(e);} } // ==== JavaScript Style général function jss() { try { - var w = $(window).width(); - var h = $(window).height(); - var iconSize; - if (h > 600) iconSize = 72; - else if(h > 500) iconSize = 48; - else iconSize = 36; - - $(".screen") - .wh(w, h) - .northWest({top:0,left:0}); - - $("body, html") - .css({ - padding: 0, - margin: 0, - overflow: "hidden", - textAlign: "left" + var w = $(window).width(); + var h = $(window).height(); + var iconSize; + if (h > 600) iconSize = 72; + else if(h > 500) iconSize = 48; + else iconSize = 36; + + $(".screen") + .wh(w, h) + .northWest({top:0,left:0}); + + $("body, html") + .css({ + padding: 0, + margin: 0, + overflow: "hidden", + textAlign: "left" + }); + + $(".screen").hide(); + $("#"+state.screen+".screen").show(); + + if (window[state.screen] && window[state.screen].jss) window[state.screen].jss(w, h, iconSize); + + $("img.icon").each(function(i,e) { + e=$(e); + if (typeof(e.data('image')) != 'undefined') + e.attr("src", "ressources/img/"+iconSize+"/"+e.data('image')+".png"); }); - - $(".screen").hide(); - $("#"+state.screen+".screen").show(); - - if (window[state.screen] && window[state.screen].jss) window[state.screen].jss(w, h, iconSize); } catch(e) {alert("Error jss");alert(e);} } // ==== Interface Android @@ -87,7 +99,7 @@ function UI () { show: function(title, text) {}, dismiss: function() {}, exit: function() {}, - log: function() {}, + log: function(msg) { window.console && console.log(msg); }, setScreen: function() {} }; } @@ -141,8 +153,15 @@ frontpage.jss = function(w, h, iconSize) { $fp(".text") .fitFont(buttonWidth, labelHeight, 10); + $fp(".icon") .wh(iconSize); + + $fp(".game .icon").data('image', 'mode_normal'); + $fp(".prefs .icon").data('image', 'config'); + $fp(".connection .icon").data('image', 'config'); + $fp(".about .icon").data('image', 'aide'); + $fp(".frontpage-button") .css('text-align', 'center') .width(buttonWidth); @@ -266,7 +285,6 @@ game.enter = function () { } else { game.buildUi(); } - jss(); } catch(e) {alert("Error game.enter");alert(e);} }; @@ -290,7 +308,7 @@ game.buildUi = function () { .html(relation.name.replace(/%(m[cn])/g, '<span class="$1"/>')) .end() .find(".icon") - .attr("src", "ressources/img/rel/"+relation.id+".png") + .data("image",relation.id) .end() .click(function(e) { game.nextWord({left:e.pageX, top:e.pageY}, this);