diff --git a/.gitignore b/.gitignore index 44b99da..cd871a1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .DS_Store code.zip vp.log +*~ diff --git a/code/serveur/php/createGame.php b/code/serveur/php/createGame.php index 36d2d8a..ae15a8e 100644 --- a/code/serveur/php/createGame.php +++ b/code/serveur/php/createGame.php @@ -130,20 +130,20 @@ if(!isset($_SESSION['userId'])) - + - + - + - + - + diff --git a/code/serveur/php/ressources/createGame.js b/code/serveur/php/ressources/createGame.js index c4604b1..950535d 100644 --- a/code/serveur/php/ressources/createGame.js +++ b/code/serveur/php/ressources/createGame.js @@ -27,8 +27,6 @@ $(function() { .clone() .changeId(i) .addClass(i%2==0 ? "lightLine" : "") -// .find("label").attr("for", "word"+i).text(i).end() -// .find("input").attr("id", "word"+i).end() .appendTo(".wordLinesTable tbody"); (function (i) { @@ -44,19 +42,40 @@ $(function() { // $(truc.children("option").get(2 /* ou 1 */)) }; - var displayRelations = function() { - $(".r1").text(relations[$("#relation1").val()]); - $(".r2").text(relations[$("#relation2").val()]); - $(".r3").text(relations[0]); - $(".r4").text(relations[-1]); + var updateRelationLabels = function() { + $('#relations option').each(function(i,e) { + $(e).text(applyFormat($(e).data("format"), $('#centralWord').val() || 'mot central', '…')); + }); + + $('.relationLabel').each(function(i,e) { + $(e).text(applyFormat( + $(e).data("format"), + $('#centralWord').val() || 'mot central', + $(e).closest('.wordLine').find('.word').val() || '…')); + }); } + var displayRelations = function() { + $(".r1").data("format", relations[$("#relation1").val()]); + $(".r2").data("format", relations[$("#relation2").val()]); + $(".r3").data("format", relations[0]); + $(".r4").data("format", relations[-1]); + updateRelationLabels(); + } + + var applyFormat = function(str, mc, mn) { + return str.replace(/%mc/g, mc).replace(/%mn/g, mn); + }; + var displayCentralWordAndRelations = function() { $("#centralWord").focusout(checkWord); $.each(relations, function(i, value) { if(i != 0 && i != -1) - $('