diff --git a/code/serveur/php/jeu.html b/code/serveur/php/jeu.html index f5a0038..80a85bb 100644 --- a/code/serveur/php/jeu.html +++ b/code/serveur/php/jeu.html @@ -3,40 +3,10 @@ PtiClic pre-alpha 0.2 - - + + + + @@ -45,6 +15,7 @@ html, body { +
Chargement…
@@ -144,6 +115,8 @@ html, body { () + diff --git a/code/serveur/php/ressources/backend.inc b/code/serveur/php/ressources/backend.inc index c96fd57..a79837f 100644 --- a/code/serveur/php/ressources/backend.inc +++ b/code/serveur/php/ressources/backend.inc @@ -772,13 +772,13 @@ function getUserInfo($user, $key) { } function setUserInfo($user, $key, $value) { - getDB()->exec("UPDATE user_info SET value = '".SQLite3::escapeString($value) - ."' WHERE user = '".SQLite3::escapeString($user) - ."' AND key = '".SQLite3::escapeString($key)."';"); + getDB()->exec("INSERT OR REPLACE INTO user_info(user, key, value) values('".SQLite3::escapeString($user) + ."', '".SQLite3::escapeString($key) + ."', '".SQLite3::escapeString($value)."');"); } function userPrefsDefaults() { - $prefs = Array( + return Array( "theme" => "green" ); } @@ -793,8 +793,12 @@ function userPrefs($user) { } function setUserPref($user, $key, $value) { - if (array_key_exists($key, userPrefsDefaults())) + if (array_key_exists($key, userPrefsDefaults())) { setUserInfo($user, $key, $value); + echo 'true'; + } else { + echo 'false'; + } } ?> \ No newline at end of file diff --git a/code/serveur/php/ressources/black.css b/code/serveur/php/ressources/black.css index b433c1b..9c99358 100644 --- a/code/serveur/php/ressources/black.css +++ b/code/serveur/php/ressources/black.css @@ -5,6 +5,10 @@ html, body { color: white; } +#nojs { + color: white; +} + .screen { background-color: black; } @@ -26,7 +30,7 @@ html, body { background-color: #222222; } -.relationBox { +#message, .relationBox { border-color: #cccccc; background-color: #222222; } diff --git a/code/serveur/php/ressources/green.css b/code/serveur/php/ressources/green.css index 3d0f68e..ccc8164 100644 --- a/code/serveur/php/ressources/green.css +++ b/code/serveur/php/ressources/green.css @@ -5,6 +5,10 @@ html, body { color: black; } +#nojs { + color: white; +} + .screen { background-color: #FFFFE0; } @@ -26,7 +30,7 @@ html, body { background-color: #F0F8D0; } -.relationBox { +#message, .relationBox { border-color: #44AA44; background-color: #F0F8D0; } diff --git a/code/serveur/php/ressources/my-extensions.js b/code/serveur/php/ressources/my-extensions.js index e77d7dc..35e1972 100644 --- a/code/serveur/php/ressources/my-extensions.js +++ b/code/serveur/php/ressources/my-extensions.js @@ -95,8 +95,9 @@ function queueize(method) { try { return function() { var $this = this; + var args = arguments; return this.queue(function(next) { - $this[method].apply($this,arguments); + $this[method].apply($this,args); next(); }); }; @@ -105,6 +106,9 @@ function queueize(method) { $.fn.qAddClass = queueize("addClass"); $.fn.qRemoveClass = queueize("removeClass"); +$.fn.qShow = queueize("show"); +$.fn.qHide = queueize("hide"); +$.fn.qCss = queueize("css"); $.fn.wh = function(w, h) { try { diff --git a/code/serveur/php/ressources/pticlic.js b/code/serveur/php/ressources/pticlic.js index 86415b7..db4dba0 100644 --- a/code/serveur/php/ressources/pticlic.js +++ b/code/serveur/php/ressources/pticlic.js @@ -66,6 +66,22 @@ function jss() { else if(h > 500) iconSize = 48; else iconSize = 36; + $('#nojs').hide(); + + $('#message:visible') + .css({ + position: 'absolute', + borderWidth: 'thin', + borderStyle: 'solid', + MozBorderRadius: 10, + WebkitBorderRadius: 10, + padding: 10, + textAlign: 'center' + }) + .wh(w/2, h*0.1) + .fitFont(w/2, h*0.1) + .center({left: w/2, top:h*0.1}); + $("#"+state.screen+".screen") .wh(w, h) .northWest({top:0,left:0}); @@ -78,6 +94,8 @@ function jss() { textAlign: "left" }); + $(".clearboth").css('clear', 'both'); + $(".screen").hide(); $("#"+state.screen+".screen").show(); @@ -109,9 +127,24 @@ function UI () { log: function(msg) { try { window.console && console.log(msg); - } catch(e) {alert("Error UI.log");alert(e);} + } catch(e) {alert("Error UI().log");alert(e);} + }, + info: function(title, msg) { + try { + $('#message') + .qCss('opacity',0) + .qShow() + .queue(function(next){ + $('#message') + .text(msg); + jss(); + next(); + }) + .animate({opacity:0.9}, 700) + .delay(1000) + .animate({opacity:0}, 700); + } catch(e) {alert("Error UI().info");alert(e);} }, - info: function(title, msg) { alert(msg); }, setScreen: function() {} }; } @@ -338,7 +371,10 @@ game.jss = function(w, h, iconSize) { .fitIn("#mc-caption-block", 0.1); $g("#mn-caption-block") - .css({borderWidth: h/100}) + .css({ + borderWidth: h/100, + borderStyle: 'solid none' + }) .wh(w, mnh) .north($g("#mc-caption-block").south()); @@ -351,7 +387,9 @@ game.jss = function(w, h, iconSize) { margin: 10, padding: 10, MozBorderRadius: 10, - WebkitBorderRadius: 10 + WebkitBorderRadius: 10, + borderWidth: 'thin', + borderStyle: 'solid', }); $g(".relationBox:visible .icon") @@ -598,11 +636,11 @@ connection.jss = function(w, h, iconSize) { $c("input, label") .css("white-space", "nowrap") .css('position', 'absolute') - .fitFont(w*0.3, h*0.25); - $c("#user-label").east({left:w/2,top:h*0.25}); - $c("#user").west({left:w/2,top:h*0.25}); - $c("#passwd-label").east({left:w/2,top:h*0.5}); - $c("#passwd").west({left:w/2,top:h*0.5}); + .fitFont(w*0.3, h*0.06); + $c("#user-label").east({left:w*0.45,top:h*0.25}); + $c("#user").west({left:w*0.55,top:h*0.25}); + $c("#passwd-label").east({left:w*0.45,top:h*0.5}); + $c("#passwd").west({left:w*0.55,top:h*0.5}); $c("#connect").center({left:w/2,top:h*0.75}); } catch(e) {alert("Error connection.jss");alert(e);} }; @@ -682,9 +720,9 @@ prefs.jss = function(w,h,iconSize) { $("input, label, select") .css("white-space", "nowrap") .css('position', 'absolute') - .fitFont(w*0.4, h*0.1); - $p("#theme-label").east({left:w/2,top:h*0.25}); - $p("#theme").west({left:w/2,top:h*0.25}); + .fitFont(w*0.3, h*0.06); + $p("#theme-label").east({left:w*0.45,top:h*0.25}); + $p("#theme").west({left:w*0.55,top:h*0.25}); $p("#prefs-cancel").east({left:w*0.45,top:h*0.5}); $p("#prefs-apply").west({left:w*0.55,top:h*0.5}); } catch(e) {alert("Error prefs.jss");alert(e);} @@ -701,14 +739,32 @@ prefs.enter = function() { prefs.apply = function(){ try { - alert($("#theme").val()); + var newtheme = $("#theme").val(); + ajaj.request("server.php?callback=?", { + action: 8, + key: 'theme', + value: newtheme + }, function(data) { + if (data) + UI().info("Préférences", "Les préférences ont été enregistrées."); + else + UI().info("Préférences", "Les préférences n'ont pas pu être enregistrées."); + }); + $("link[@rel*=stylesheet][title]").each(function(i,e){ + // Il semblerait que pour qu'un "aleternate stylesheet" puisse être activé, il faut d'abord qu'il ait été désactivé… + e.disabled = true; + e.disabled = (e.getAttribute('title') != newtheme); + }); state.set('screen', 'frontpage').validate(); return false; - } catch(e) {alert("Error anonymous in prefs.click.apply");alert(e);} + } catch(e) {alert("Error anonymous in prefs.apply");alert(e);} }; +function switchStylestyle(styleName) { +} + prefs.cancel = function(){ try { state.set('screen', 'frontpage').validate(); - } catch(e) {alert("Error anonymous in prefs.click.cancel");alert(e);} + } catch(e) {alert("Error anonymous in prefs.cancel");alert(e);} };