www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 2f814043dbe54878c09d7d50a59c092ba72ea1d4
parent cf7054935b281ee372ddbd106d2b54b3ffd5894c
Author: Georges Dupéron <jahvascriptmaniac+github@free.fr>
Date:   Thu, 28 Apr 2011 23:07:01 +0200

Affichage du splash au démarrage de l'application.

Diffstat:
Mcode/serveur/php/jeu.html | 10++++++++--
Mcode/serveur/php/ressources/img/splash.png | 0
Mcode/serveur/php/ressources/pticlic.js | 51+++++++++++++++++++++++++++++++++++++++++++++------
3 files changed, 53 insertions(+), 8 deletions(-)

diff --git a/code/serveur/php/jeu.html b/code/serveur/php/jeu.html @@ -9,10 +9,15 @@ body { } .screen { - background-color : #FFFFE0; + background-color: #FFFFE0; display: none; } +#splash.screen { + background-color: #000; + display: block; +} + #mc-caption { color: #8b4; } @@ -52,7 +57,8 @@ body { <script src="ressources/pticlic.js"></script> </head> <body> - <div class="screen" id="logo"> + <div class="screen" id="splash"> + <img src="ressources/img/splash.png" /> </div> <div class="screen" id="game"> <div id="mc-caption-block"></div> diff --git a/code/serveur/php/ressources/img/splash.png b/code/serveur/php/ressources/img/splash.png Binary files differ. diff --git a/code/serveur/php/ressources/pticlic.js b/code/serveur/php/ressources/pticlic.js @@ -2,7 +2,7 @@ function State(init) { try { $.extend(this, init || {}); - if (!this.screen) this.screen = 'frontpage'; + if (!this.screen) this.screen = 'splash'; } catch(e) {alert("Error State");alert(e);} }; var futureHashChange = null; @@ -88,6 +88,7 @@ function jss() { }); } catch(e) {alert("Error jss");alert(e);} } + // ==== Interface Android function UI () { try { @@ -127,6 +128,40 @@ function ajaxError(x) { } catch(e) {alert("Error ajaxError");alert(e);} } +// ==== Code métier pour le splash + +splash = {}; + +splash.jss = function(w,h,iconSize) { + try { + var splashW = 320; + var splashH = 480; + var ratio = Math.min(w / splashW, h / splashH); + $('#splash.screen img') + .wh(splashW * ratio, splashH * ratio) + .center($('#splash.screen').center()); + } catch(e) {alert("Error splash.jss");alert(e);} +} + +splash.enter = function() { + // Si l'application est déjà chargée, on zappe directement jusqu'à la frontpage. + if (runstate.skipSplash) { + splash.click.goFrontpage(); + } else { + runstate.skipSplash = true; + jss(); + $('#splash.screen').clickOnce(splash.click.goFrontpage); + } +} + +splash.click = {}; +splash.click.goFrontpage = function() { + try { + UI().show("PtiClic", "Chargement…"); + state.set('screen', 'frontpage').validate(); + } catch(e) {alert("Error splash.click.goFrontpage");alert(e);} +}; + // ==== Code métier pour la frontpage frontpage = {}; @@ -458,12 +493,15 @@ score.ui = function () { .appendTo("#score .scores"); } catch(e) {alert("Error anonymous 1 in score.ui");alert(e);} }); - $("#score #jaivu").clickOnce(function() { - try { - state = new State().validate(); - } catch(e) {alert("Error anonymous 2 in score.ui");alert(e);} - }); + $("#score #jaivu").clickOnce(score.click.jaivu); jss(); UI().dismiss(); } catch(e) {alert("Error score.ui");alert(e);} } + +score.click = {}; +score.click.jaivu = function() { + try { + state = new State().validate(); + } catch(e) {alert("Error score.click.jaivu");alert(e);} +}; +\ No newline at end of file