Une partie du travail nécessaire à l'écran préférences.

This commit is contained in:
Georges Dupéron 2011-05-07 22:48:20 +02:00
parent fe3e33be92
commit 2e45b48173
7 changed files with 129 additions and 28 deletions

View File

@ -34,6 +34,7 @@ create table played_game_cloud(pgid, gid, type, num, relation, weight, score);
create table colon_nodes(eid); create table colon_nodes(eid);
create table random_cloud_node(eid,nbneighbors); create table random_cloud_node(eid,nbneighbors);
create table random_center_node(eid); create table random_center_node(eid);
create table user_info(user, key, value, primary key (user, key));
insert into user(login, mail, hash_passwd, score, ugroup) values('$(echo "$user" | sed -e "s/'/''/g")', 'foo@isp.com', '$(echo "$passwd" | dd bs=1 count="${#passwd}" | (if which md5sum >/dev/null 2>&1; then md5sum; else md5; fi) | cut -d ' ' -f 1)', 0, 1); insert into user(login, mail, hash_passwd, score, ugroup) values('$(echo "$user" | sed -e "s/'/''/g")', 'foo@isp.com', '$(echo "$passwd" | dd bs=1 count="${#passwd}" | (if which md5sum >/dev/null 2>&1; then md5sum; else md5; fi) | cut -d ' ' -f 1)', 0, 1);
EOF EOF

View File

@ -5,41 +5,27 @@
<meta charset="utf-8" /> <meta charset="utf-8" />
<style> <style>
html, body { html, body {
background-color: black;
overflow: hidden; overflow: hidden;
} }
.screen { .screen {
background-color: #FFFFE0;
display: none; display: none;
} }
#splash.screen { #splash.screen {
background-color: black;
display: block; display: block;
} }
#mc-caption {
color: #8b4;
}
#mn-caption {
color: #4a4;
}
#mn-caption-block { #mn-caption-block {
border-top: medium solid #44AA44; border-top-width: medium;
border-bottom: medium solid #44AA44; border-top-style: solid;
background-color: #F0F8D0; border-bottom-width: medium;
border-bottom-style: solid;
} }
.relationBox { .relationBox {
background-color: #F0F8D0; border-width: thin;
border: thin solid #44AA44; border-style: solid;
}
.relations .hot {
background-color: yellow;
} }
.clearboth { .clearboth {
@ -50,6 +36,7 @@ html, body {
text-align: center; text-align: center;
} }
</style> </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>

View File

@ -766,4 +766,35 @@ function wordExist($node) {
return getNodeEid($node) === null ? "0" : "1"; return getNodeEid($node) === null ? "0" : "1";
} }
function getUserInfo($user, $key) {
return getdb()->querySingle("SELECT value FROM user_info WHERE user = '".sqlite3::escapestring($user)."' AND key = '".SQLite3::escapeString($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)."';");
}
function userPrefsDefaults() {
$prefs = Array(
"theme" => "green"
);
}
function userPrefs($user) {
$res = userPrefsDefaults();
foreach ($res as $k => &$v) {
$x = getUserInfo($user, $k);
if ($x !== null) $v = $x;
}
echo json_encode($res);
}
function setUserPref($user, $key, $value) {
if (array_key_exists($key, userPrefsDefaults()))
setUserInfo($user, $key, $value);
}
?> ?>

View File

@ -0,0 +1,36 @@
/* Colors */
html, body {
background-color: black;
color: white;
}
.screen {
background-color: black;
}
#splash.screen {
background-color: black;
}
#mc-caption {
color: white;
}
#mn-caption {
color: white;
}
#mn-caption-block {
border-color: #aaaaaa;
background-color: #222222;
}
.relationBox {
border-color: #cccccc;
background-color: #222222;
}
.relations .hot {
background-color: #cccccc;
}

View File

@ -0,0 +1,36 @@
/* Colors */
html, body {
background-color: black;
color: black;
}
.screen {
background-color: #FFFFE0;
}
#splash.screen {
background-color: black;
}
#mc-caption {
color: #8b4;
}
#mn-caption {
color: #4a4;
}
#mn-caption-block {
border-color: #44AA44;
background-color: #F0F8D0;
}
.relationBox {
border-color: #44AA44;
background-color: #F0F8D0;
}
.relations .hot {
background-color: yellow;
}

View File

@ -1,4 +1,6 @@
// ==== URL persistante // ==== URL persistante
var nullFunction = function(){};
function State(init) { function State(init) {
try { try {
$.extend(this, init || {}); $.extend(this, init || {});
@ -109,6 +111,7 @@ function UI () {
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) { alert(msg); },
setScreen: function() {} setScreen: function() {}
}; };
} }
@ -173,7 +176,7 @@ ajaj.bigError = function(x) {
ajaj.error = function(msg) { ajaj.error = function(msg) {
try { try {
UI().dismiss(); UI().dismiss();
alert(msg); UI().info("Erreur !", msg);
UI().exit(); UI().exit();
} catch(e) {alert("Error ajaj.error");alert(e);} } catch(e) {alert("Error ajaj.error");alert(e);}
} }
@ -277,6 +280,7 @@ frontpage.jss = function(w, h, iconSize) {
frontpage.enter = function () { frontpage.enter = function () {
try { try {
if (location.hash != '') state.commit(); if (location.hash != '') state.commit();
console.log("fubar");
$("#frontpage .frontpage-button.game").clickOnce(frontpage.click.goGame); $("#frontpage .frontpage-button.game").clickOnce(frontpage.click.goGame);
$("#frontpage .frontpage-button.connection").clickOnce(frontpage.click.goConnection); $("#frontpage .frontpage-button.connection").clickOnce(frontpage.click.goConnection);
$("#frontpage .frontpage-button.info").clickOnce(frontpage.click.goInfo); $("#frontpage .frontpage-button.info").clickOnce(frontpage.click.goInfo);
@ -288,6 +292,7 @@ frontpage.enter = function () {
frontpage.click = {}; frontpage.click = {};
frontpage.click.goGame = function(){ frontpage.click.goGame = function(){
try { try {
console.log("goGame");
state.set('screen', 'game').validate(); state.set('screen', 'game').validate();
} catch(e) {alert("Error frontpage.click.goGame");alert(e);} } catch(e) {alert("Error frontpage.click.goGame");alert(e);}
}; };
@ -364,7 +369,7 @@ game.jss = function(w, h, iconSize) {
game.enter = function () { game.enter = function () {
try { try {
if (!state.game) { if (!state.game) {
var notAlreadyFetching = !runstate.gameFetched; var notAlreadyFetching = !runstate.gameFetched || runstate.gameFetched == nullFunction;
runstate.gameFetched = function(data) { runstate.gameFetched = function(data) {
try { try {
state.game = data; state.game = data;
@ -396,7 +401,7 @@ game.leave = function () {
try { try {
$("#game .relations").empty(); $("#game .relations").empty();
$('#game #mn-caption').stop().clearQueue(); $('#game #mn-caption').stop().clearQueue();
if (runstate.gameFetched) runstate.gameFetched = function() {}; if (runstate.gameFetched) runstate.gameFetched = nullFunction;
} catch(e) {alert("Error game.leave");alert(e);} } catch(e) {alert("Error game.leave");alert(e);}
}; };
@ -496,7 +501,7 @@ score.jss = function(w, h, iconSize) {
score.enter = function () { score.enter = function () {
try { try {
if (!state.hasScore) { if (!state.hasScore) {
var notAlreadyFetching = !runstate.scoreFetched; var notAlreadyFetching = !runstate.scoreFetched || runstate.scoreFetched == nullFunction;
runstate.scoreFetched = function(data) { runstate.scoreFetched = function(data) {
try { try {
for (var i = 0; i < data.scores.length; ++i) { for (var i = 0; i < data.scores.length; ++i) {
@ -534,7 +539,7 @@ score.enter = function () {
score.leave = function () { score.leave = function () {
try { try {
if (runstate.scoreFetched) runstate.scoreFetched = function() {}; if (runstate.scoreFetched) runstate.scoreFetched = nullFunction;
$("#score .scores").empty(); $("#score .scores").empty();
$("#templates .scoreTotal").empty(); $("#templates .scoreTotal").empty();
} catch(e) {alert("Error score.leave");alert(e);} } catch(e) {alert("Error score.leave");alert(e);}
@ -625,9 +630,9 @@ connection.connect = function() {
connection.connectFetched = function(data) { connection.connectFetched = function(data) {
try { try {
if (data && data.loginOk) { if (data && data.loginOk) {
alert("Vous êtes connecté !"); UI().info("Connexion", "Vous êtes connecté !");
} else if (data && data.isError && data.error == 3) { } else if (data && data.isError && data.error == 3) {
alert(data.msg); UI().info("Connexion", data.msg);
} else { } else {
ajaj.smallError(data); ajaj.smallError(data);
} }

View File

@ -104,10 +104,15 @@ function main()
throw new Exception("La requête est incomplète", 2); throw new Exception("La requête est incomplète", 2);
decodeAndInsertGame($user,$_GET['game']); decodeAndInsertGame($user,$_GET['game']);
} elseif ($action == 7) { // Get user prefs
userPrefs($user);
} elseif ($action == 8) { // Set user pref
if (!isset($_GET['key']) || !isset($_GET['value']))
throw new Exception("La requête est incomplète", 2);
setUserPref($user, $_GET['key'], $_GET['value']);
} else { } else {
throw new Exception("Commande inconnue", 2); throw new Exception("Commande inconnue", 2);
} }
// Attention, il y a une $action == 7, mais plus haut.
} }
function server() { function server() {