www

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

commit 6a268398698732b7f9273a920919aa436f8d4c30
parent 722cc418576cfa561c38a7ef1431910c6dc40d36
Author: Yoann <yoann.b87@voila.fr>
Date:   Wed,  6 Apr 2011 11:59:29 +0200

Ajout des listes déroulantes de relations ur la page de création de
partie.

Diffstat:
Mcode/serveur/php/createGamejs.php | 14+++++++++++++-
Mcode/serveur/php/pticlic.php | 2++
Mcode/serveur/php/ressources/createGame.js | 30++++++++++++++----------------
Mcode/serveur/php/server.php | 6++++--
4 files changed, 33 insertions(+), 19 deletions(-)

diff --git a/code/serveur/php/createGamejs.php b/code/serveur/php/createGamejs.php @@ -176,10 +176,22 @@ else <div class="content creategame"> <h2>Création de parties</h2> <p>Cette page vous permet de créer des parties personalisées en indiquant les mots qui seront affiché pour un mot central.<br /><br /> - <div id="center">Mot central</div> + <div id="center"> + <label for="centralWord"> Le mot central : </label><input type="text" id="centralWord" name="centralWord" /> + </div> + <div id="relations"> + <label for="relation1">Relation 1</label> + <select name="relation1" id="relation1"> + </select> + <label for="relation2">Relation 2</label> + <select name="relation2" id="relation2"> + </select> + </div> <div id="wordLines"></div> <div id="button"></div> </div> + <div id="templates" style="display:none"> + </div> <?php include("ressources/footer.inc"); ?> </body> </html> diff --git a/code/serveur/php/pticlic.php b/code/serveur/php/pticlic.php @@ -1,5 +1,6 @@ <?php +require_once("relations.php"); require_once("db.php"); /* Les prototypes des fonctions : @@ -630,6 +631,7 @@ function get_game_relations() function getGameRelationsJSON() { $json = "{"; + global $stringRelations; foreach($stringRelations as $id=>$description) if($id == -1) diff --git a/code/serveur/php/ressources/createGame.js b/code/serveur/php/ressources/createGame.js @@ -1,7 +1,10 @@ -$(function () { +$($.getJSON("server.php", + {action:"5", user:"foo", passwd:"bar"}, + function (data) { var numWord = 1; var user = "foo"; var passwd = "bar"; + var relations = data; var displayNWordLines = function (nb) { @@ -21,15 +24,16 @@ $(function () { numWord += nb; } - var displayCentralWord = function () { - $("#center").html('<label for="centralWord"> Le mot central : </label><input type="text" id="centralWord" name="centralWord" />'); + var displayCentralWordAndRelations = function () { $("#centralWord").focusout(function () { - var input = "centralWord"; - checkWord(input) - } - ); + var input = "centralWord"; + checkWord(input); + }); + $.each(relations,function(i,value){ + console.log(value); + $('<option/>').val(i).text(value).appendTo("#relations select") + }); } - var displayButtons = function () { $("#button").html('<input type="button" id="addLine" name="addLine" value="Ajouter" />'); $("#addLine").click(function(){displayNWordLines(1)}); @@ -56,13 +60,7 @@ $(function () { } } - var getRelationsList = function () { - $.getJSON("server.php?action=5&user=foo&passwd=ba",function (data) { - $.debug(data); - }); - } - getRelationsList(); - displayCentralWord(); + displayCentralWordAndRelations(); displayNWordLines(10); displayButtons(); -}); +})); diff --git a/code/serveur/php/server.php b/code/serveur/php/server.php @@ -84,16 +84,18 @@ function main() echo 'false'; } else if($action == 5) { // Get relations (JSON) - echo "mqslkjfmlqskjfqmskf";//echo getGameRaltionsJSON(); + echo getGameRelationsJSON(); } else { throw new Exception("Commande inconnue", 2); } + + } function server() { ob_start(); - + try { main(); ob_end_flush();