From 0945b12fae205e90d36331eafc8ae2994b53a251 Mon Sep 17 00:00:00 2001 From: Yoann Date: Wed, 25 May 2011 16:46:05 +0200 Subject: [PATCH] =?UTF-8?q?Correction=20des=20derniers=20bugs=20pour=20la?= =?UTF-8?q?=20cr=C3=A9ation=20de=20partie.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/serveur/php/createGame.php | 6 +-- code/serveur/php/ressources/createGame.js | 55 +++++++++++------------ 2 files changed, 29 insertions(+), 32 deletions(-) diff --git a/code/serveur/php/createGame.php b/code/serveur/php/createGame.php index 36be43c..2d0982d 100644 --- a/code/serveur/php/createGame.php +++ b/code/serveur/php/createGame.php @@ -102,7 +102,7 @@ if(!isset($_SESSION['userId'])) -
+

Création de parties

Cette page vous permet de créer des parties personalisées en indiquant les mots qui seront affiché pour un mot central.

@@ -159,9 +159,7 @@ if(!isset($_SESSION['userId']))
- - + diff --git a/code/serveur/php/ressources/createGame.js b/code/serveur/php/ressources/createGame.js index 822c83a..6a1e699 100644 --- a/code/serveur/php/ressources/createGame.js +++ b/code/serveur/php/ressources/createGame.js @@ -42,14 +42,14 @@ $(function() { var updateRelationLabels = function() { $('#relations option').each(function(i,e) { - $(e).text(applyFormat($(e).data("format"), $('#centralWord').val() || 'mot central', '…')); + $(e).text(applyFormat($(e).data("format"), $('#centralWord').val().trim() || 'mot central', '…')); }); $('.relationLabel').each(function(i,e) { $(e).text(applyFormat( $(e).data("format"), - $('#centralWord').val() || 'mot central', - $(e).closest('.wordLine').find('.word').val() || '…')); + $('#centralWord').val().trim() || 'mot central', + $(e).closest('.wordLine').find('.word').val().trim() || '…')); }); } @@ -92,26 +92,22 @@ $(function() { $("#button").html(''); $("#addLine").click(function(){ displayNWordLines(1); }); - $("#button").append(''); - $("#validate").click(function(){ formOK(); }); + $("#button").append(''); + $("form").submit(formOK); }; var checkWord = function () { updateRelationLabels(); var input = $(this); - var word = input.val(); + var word = input.val().trim(); input.closest(".wordLine, #center").removeClass("valid invalid"); if (word != "") { - $.ajax({ - type: "GET", - url: "server.php?", - data: "action=4&word="+word, //+"&user="+user+"&passwd="+passwd, - success: function(msg){ - input.closest(".wordLine, #center").addClass(msg == false ? "invalid" : "valid"); - wordsOK[input.attr("id")] = !(msg == false); - }}); + $.getJSON("server.php",{action:4,word:word}, function(msg){ + input.closest(".wordLine, #center").addClass(msg ? "valid" : "invalid"); + wordsOK[input.attr("id")] = !(msg == false); + }); } }; @@ -120,7 +116,7 @@ $(function() { if ($("#relation1").val() == $("#relation2").val()) displayError("Les deux relation doivent être différents"); - else if ($("#centralWord").val() == "") + else if ($("#centralWord").val().trim() == "") displayError("Le mot central doit être renseigné."); else if (badWord()) displayError("Il existe des mots incorrects"); @@ -146,7 +142,7 @@ $(function() { var badWord = function() { for (word in wordsOK) - if ($("#"+word).val() != "" && wordsOK[word] == false) + if ($("#"+word).val().trim() != "" && wordsOK[word] == false) return true; return false; @@ -167,13 +163,13 @@ $(function() { var exit; var cloud = ""; - exit = {center:$("#centralWord").val(), + exit = {center:$("#centralWord").val().trim(), relations:[$("#relation1").val(),$("#relation2").val(),0,-1], cloud:[]}; for(i=1;i