commit 168076088aebae1e0d7d193c94fbae485fcfcbe6
parent 26f07c457c3f008ff55c19a0bab8e72e9fb250a1
Author: Georges Dupéron <jahvascriptmaniac+github@free.fr>
Date: Wed, 25 May 2011 13:21:14 +0200
Bouton j'aime / pas (non testé).
Diffstat:
3 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/code/serveur/php/jeu.html b/code/serveur/php/jeu.html
@@ -130,8 +130,8 @@
<h1 class="fitFont" style="width:100%; height:8%; top: 6%; position:absolute; margin:0; text-align:center;">Score total : <span class="scoreTotal"></span></h1>
<div class="scores fitFont" style="width:100%; height:50%; top:20%; position:absolute;"></div>
<p class="fitFont" style="text-align: center; width:90%; height:12%; top:74%; left:5%; position:absolute; margin:0; padding:0;">
- <a class="button" href="#" style="float:left;">J'♥ cette partie</a>
- <a class="button" href="#" style="float:right;">J'♥ pas cette partie</a>
+ <a id="jaime" class="button" href="#frontpage" style="width40%; right:55%; position:absolute;">J'♥ cette partie</a>
+ <a id="jaimepas" class="button" href="#frontpage" style="width40%; left:55%; position:absolute;">J'♥ pas cette partie</a>
</p>
<p class="fitFont" style="clear:both; text-align: center; width:90%; height:12%; top:86%; left:5%; position:absolute; margin:0; padding:0;">
<a class="button" href="#frontpage">J'ai vu !</a>
diff --git a/code/serveur/php/ressources/pticlic.js b/code/serveur/php/ressources/pticlic.js
@@ -4,6 +4,7 @@ function init(fn) {
}
$.ajaj = function(url, data, dfd, retryCheck, callback) {
+ dfd = dfd || $.Deferred();
var user = '' + UI().getPreference("user");
var passwd = '' + UI().getPreference("passwd");
user = runstate.user || user;
@@ -364,6 +365,14 @@ runstate.scoreCache = new Cache(function getScore(k, dfd, arg) {
}, dfd, function() { return state.pgid == k; });
});
+function jAime(aime) {
+ $.ajaj('server.php?callback=?', {
+ pgid: state.pgid,
+ action: 10,
+ value: (aime ? 1 : -1)
+ });
+}
+
init(function() {
var score = $.screen('score');
score.bind('pre-enter', function() {
@@ -387,6 +396,8 @@ init(function() {
.appendTo("#score .scores");
});
});
+ $('#jaime').click(function() { jAime(true); });
+ $('#jaimepas').click(function() { jAime(false); });
});
// ==== Écran Préférences
diff --git a/code/serveur/php/server.php b/code/serveur/php/server.php
@@ -118,6 +118,7 @@ function main()
if (!isset($_GET['value']) || !isset($_GET['pgid']))
throw new Exception("La requête est incomplète", 2);
setJAimePgid($user, $_GET['pgid'], intval($_GET['value']));
+ echo '{"JAimePas":true}';
} else {
throw new Exception("Commande inconnue", 2);
}