Merge branch 'unstable' of https://github.com/jsmaniac/2011-m1s2-ter into unstable

This commit is contained in:
Bertrand BRUN 2011-05-08 16:29:18 +02:00
commit ec4b21e7fb
6 changed files with 102 additions and 57 deletions

View File

@ -3,40 +3,10 @@
<head> <head>
<title>PtiClic pre-alpha 0.2</title> <title>PtiClic pre-alpha 0.2</title>
<meta charset="utf-8" /> <meta charset="utf-8" />
<style> <meta name="viewport" content="target-densitydpi=device-dpi" />
html, body { <style>.screen { display: none; }</style>
overflow: hidden; <link rel="stylesheet" href="ressources/green.css" title="green" />
} <link rel="alternate stylesheet" href="ressources/black.css" title="black" />
.screen {
display: none;
}
#splash.screen {
display: block;
}
#mn-caption-block {
border-top-width: medium;
border-top-style: solid;
border-bottom-width: medium;
border-bottom-style: solid;
}
.relationBox {
border-width: thin;
border-style: solid;
}
.clearboth {
clear: both;
}
.frontpage-button {
text-align: center;
}
</style>
<link rel="stylesheet" href="ressources/green.css" />
<script src="ressources/jquery-1.5.1.min.js"></script> <script src="ressources/jquery-1.5.1.min.js"></script>
<script src="ressources/jquery-ui-1.8.11.custom.min.js"></script> <script src="ressources/jquery-ui-1.8.11.custom.min.js"></script>
<script src="ressources/jquery.ba-hashchange.min.js"></script> <script src="ressources/jquery.ba-hashchange.min.js"></script>
@ -45,6 +15,7 @@ html, body {
<script src="ressources/pticlic.js"></script> <script src="ressources/pticlic.js"></script>
</head> </head>
<body> <body>
<div id="nojs">Chargement…</div>
<div class="screen" id="splash"> <div class="screen" id="splash">
<img src="ressources/img/splash.png" /> <img src="ressources/img/splash.png" />
</div> </div>
@ -144,6 +115,8 @@ html, body {
<span class="word"></span> (<span class="score"></span>) <span class="word"></span> (<span class="score"></span>)
</div> </div>
</div> </div>
<div id="message" style="display: none;">
</div>
</body> </body>
</html> </html>
<html> <html>

View File

@ -772,13 +772,13 @@ function getUserInfo($user, $key) {
} }
function setUserInfo($user, $key, $value) { function setUserInfo($user, $key, $value) {
getDB()->exec("UPDATE user_info SET value = '".SQLite3::escapeString($value) getDB()->exec("INSERT OR REPLACE INTO user_info(user, key, value) values('".SQLite3::escapeString($user)
."' WHERE user = '".SQLite3::escapeString($user) ."', '".SQLite3::escapeString($key)
."' AND key = '".SQLite3::escapeString($key)."';"); ."', '".SQLite3::escapeString($value)."');");
} }
function userPrefsDefaults() { function userPrefsDefaults() {
$prefs = Array( return Array(
"theme" => "green" "theme" => "green"
); );
} }
@ -793,8 +793,12 @@ function userPrefs($user) {
} }
function setUserPref($user, $key, $value) { function setUserPref($user, $key, $value) {
if (array_key_exists($key, userPrefsDefaults())) if (array_key_exists($key, userPrefsDefaults())) {
setUserInfo($user, $key, $value); setUserInfo($user, $key, $value);
echo 'true';
} else {
echo 'false';
}
} }
?> ?>

View File

@ -5,6 +5,10 @@ html, body {
color: white; color: white;
} }
#nojs {
color: white;
}
.screen { .screen {
background-color: black; background-color: black;
} }
@ -26,7 +30,7 @@ html, body {
background-color: #222222; background-color: #222222;
} }
.relationBox { #message, .relationBox {
border-color: #cccccc; border-color: #cccccc;
background-color: #222222; background-color: #222222;
} }

View File

@ -5,6 +5,10 @@ html, body {
color: black; color: black;
} }
#nojs {
color: white;
}
.screen { .screen {
background-color: #FFFFE0; background-color: #FFFFE0;
} }
@ -26,7 +30,7 @@ html, body {
background-color: #F0F8D0; background-color: #F0F8D0;
} }
.relationBox { #message, .relationBox {
border-color: #44AA44; border-color: #44AA44;
background-color: #F0F8D0; background-color: #F0F8D0;
} }

View File

@ -95,8 +95,9 @@ function queueize(method) {
try { try {
return function() { return function() {
var $this = this; var $this = this;
var args = arguments;
return this.queue(function(next) { return this.queue(function(next) {
$this[method].apply($this,arguments); $this[method].apply($this,args);
next(); next();
}); });
}; };
@ -105,6 +106,9 @@ function queueize(method) {
$.fn.qAddClass = queueize("addClass"); $.fn.qAddClass = queueize("addClass");
$.fn.qRemoveClass = queueize("removeClass"); $.fn.qRemoveClass = queueize("removeClass");
$.fn.qShow = queueize("show");
$.fn.qHide = queueize("hide");
$.fn.qCss = queueize("css");
$.fn.wh = function(w, h) { $.fn.wh = function(w, h) {
try { try {

View File

@ -66,6 +66,22 @@ function jss() {
else if(h > 500) iconSize = 48; else if(h > 500) iconSize = 48;
else iconSize = 36; 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") $("#"+state.screen+".screen")
.wh(w, h) .wh(w, h)
.northWest({top:0,left:0}); .northWest({top:0,left:0});
@ -78,6 +94,8 @@ function jss() {
textAlign: "left" textAlign: "left"
}); });
$(".clearboth").css('clear', 'both');
$(".screen").hide(); $(".screen").hide();
$("#"+state.screen+".screen").show(); $("#"+state.screen+".screen").show();
@ -109,9 +127,24 @@ function UI () {
log: function(msg) { log: function(msg) {
try { try {
window.console && console.log(msg); 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() {} setScreen: function() {}
}; };
} }
@ -338,7 +371,10 @@ game.jss = function(w, h, iconSize) {
.fitIn("#mc-caption-block", 0.1); .fitIn("#mc-caption-block", 0.1);
$g("#mn-caption-block") $g("#mn-caption-block")
.css({borderWidth: h/100}) .css({
borderWidth: h/100,
borderStyle: 'solid none'
})
.wh(w, mnh) .wh(w, mnh)
.north($g("#mc-caption-block").south()); .north($g("#mc-caption-block").south());
@ -351,7 +387,9 @@ game.jss = function(w, h, iconSize) {
margin: 10, margin: 10,
padding: 10, padding: 10,
MozBorderRadius: 10, MozBorderRadius: 10,
WebkitBorderRadius: 10 WebkitBorderRadius: 10,
borderWidth: 'thin',
borderStyle: 'solid',
}); });
$g(".relationBox:visible .icon") $g(".relationBox:visible .icon")
@ -598,11 +636,11 @@ connection.jss = function(w, h, iconSize) {
$c("input, label") $c("input, label")
.css("white-space", "nowrap") .css("white-space", "nowrap")
.css('position', 'absolute') .css('position', 'absolute')
.fitFont(w*0.3, h*0.25); .fitFont(w*0.3, h*0.06);
$c("#user-label").east({left:w/2,top:h*0.25}); $c("#user-label").east({left:w*0.45,top:h*0.25});
$c("#user").west({left:w/2,top:h*0.25}); $c("#user").west({left:w*0.55,top:h*0.25});
$c("#passwd-label").east({left:w/2,top:h*0.5}); $c("#passwd-label").east({left:w*0.45,top:h*0.5});
$c("#passwd").west({left:w/2,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}); $c("#connect").center({left:w/2,top:h*0.75});
} catch(e) {alert("Error connection.jss");alert(e);} } catch(e) {alert("Error connection.jss");alert(e);}
}; };
@ -682,9 +720,9 @@ prefs.jss = function(w,h,iconSize) {
$("input, label, select") $("input, label, select")
.css("white-space", "nowrap") .css("white-space", "nowrap")
.css('position', 'absolute') .css('position', 'absolute')
.fitFont(w*0.4, h*0.1); .fitFont(w*0.3, h*0.06);
$p("#theme-label").east({left:w/2,top:h*0.25}); $p("#theme-label").east({left:w*0.45,top:h*0.25});
$p("#theme").west({left:w/2,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-cancel").east({left:w*0.45,top:h*0.5});
$p("#prefs-apply").west({left:w*0.55,top:h*0.5}); $p("#prefs-apply").west({left:w*0.55,top:h*0.5});
} catch(e) {alert("Error prefs.jss");alert(e);} } catch(e) {alert("Error prefs.jss");alert(e);}
@ -701,14 +739,32 @@ prefs.enter = function() {
prefs.apply = function(){ prefs.apply = function(){
try { 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(); state.set('screen', 'frontpage').validate();
return false; 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(){ prefs.cancel = function(){
try { try {
state.set('screen', 'frontpage').validate(); 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);}
}; };