La page de création est partie est utilisable.
This commit is contained in:
parent
69fe0cdd1e
commit
caf751bf07
|
@ -130,7 +130,9 @@ if(!isset($_SESSION['userId']))
|
|||
<label for="word-"></label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="word" type="text" id="word-"/>
|
||||
<input value="" class="word" type="text" id="word-"/>
|
||||
</td>
|
||||
<td>
|
||||
<span class="status">●</span>
|
||||
</td>
|
||||
<td>
|
||||
|
|
|
@ -298,20 +298,37 @@ function cgInsert($centerEid, $cloud, $r1, $r2, $totalDifficulty)
|
|||
}
|
||||
|
||||
function decodeAndInsertGame($game) {
|
||||
$badWords = Array();
|
||||
$centerEid = getNodeEid($game['center']);
|
||||
$r1 = $game['relations'][0];
|
||||
$r2 = $game['relations'][1];
|
||||
foreach($game['cloud'] as $key => $w)
|
||||
$cloud[] = Array("eid" => getNodeEid($w['name']),
|
||||
|
||||
if($centerEid === null)
|
||||
$badWords[] = $game['center'];
|
||||
|
||||
foreach($game['cloud'] as $key => $w) {
|
||||
if ($w['name'] == "") continue;
|
||||
$cloudEid = getNodeEid($w['name']);
|
||||
$cloud[] = Array("eid" => $cloudEid,
|
||||
"pos" => $key,
|
||||
"d" => 5,
|
||||
"probaR1" => $w['relations'][0] ? "1" : "0",
|
||||
"probaR2" => $w['relations'][1] ? "1" : "0",
|
||||
"probaR0" => $w['relations'][2] ? "1" : "0",
|
||||
"probaTrash" => $w['relations'][3] ? "1" : "0");
|
||||
|
||||
|
||||
insertCreatedGame($centerEid,$cloud,$r1,$r2,10);
|
||||
|
||||
if($cloudEid === null)
|
||||
$badWords[] = $w['name'];
|
||||
}
|
||||
|
||||
if(count($badWords) > 0) {
|
||||
echo JSON_encode($badWords);
|
||||
} else if (count($cloud) < 5) {
|
||||
echo "false";
|
||||
} else {
|
||||
insertCreatedGame($centerEid,$cloud,$r1,$r2,10);
|
||||
echo "true";
|
||||
}
|
||||
}
|
||||
|
||||
function insertCreatedGame($centerEid, $cloud, $r1, $r2, $totalDifficulty)
|
||||
|
@ -739,6 +756,6 @@ function getNodeEid($node) {
|
|||
function wordExist($node) {
|
||||
$db = getDB();
|
||||
|
||||
return $db->querySingle("SELECT eid FROM node WHERE name='".SQLite3::escapeString($node)."';") ? true : false;
|
||||
return getNodeEid($node) === null ? true : false;
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -15,7 +15,7 @@ $(function() {
|
|||
var user = "foo";
|
||||
var passwd = "bar";
|
||||
var relations = data;
|
||||
var nbWordMin = 3;
|
||||
var nbWordMin = 5;
|
||||
var wordsOK = new Array();
|
||||
var centerOK = false;
|
||||
|
||||
|
@ -38,8 +38,6 @@ $(function() {
|
|||
numWord += nb;
|
||||
|
||||
displayRelations();
|
||||
// truc.children("option:nth-child(2)");
|
||||
// $(truc.children("option").get(2 /* ou 1 */))
|
||||
};
|
||||
|
||||
var updateRelationLabels = function() {
|
||||
|
@ -85,6 +83,8 @@ $(function() {
|
|||
|
||||
displayRelations();
|
||||
});
|
||||
$("select#relation1").val(5);
|
||||
$("select#relation2").val(7);
|
||||
displayRelations();
|
||||
};
|
||||
|
||||
|
@ -101,7 +101,7 @@ $(function() {
|
|||
var input = $(this);
|
||||
var word = input.val();
|
||||
|
||||
input.parent("td, #center").removeClass("valid invalid");
|
||||
input.closest(".wordLine, #center").removeClass("valid invalid");
|
||||
|
||||
if (word != "") {
|
||||
$.ajax({
|
||||
|
@ -109,7 +109,7 @@ $(function() {
|
|||
url: "server.php?",
|
||||
data: "action=4&word="+word+"&user="+user+"&passwd="+passwd,
|
||||
success: function(msg){
|
||||
input.parent("td, #center").addClass((msg == false) ? "invalid" : "valid");
|
||||
input.closest(".wordLine, #center").addClass((msg == false) ? "invalid" : "valid");
|
||||
wordsOK[input.attr("id")] = !(msg == false);
|
||||
}});
|
||||
}
|
||||
|
@ -145,7 +145,6 @@ $(function() {
|
|||
};
|
||||
|
||||
var badWord = function() {
|
||||
console.log(wordsOK);
|
||||
for (word in wordsOK)
|
||||
if ($("#"+word).val() != "" && wordsOK[word] == false)
|
||||
return true;
|
||||
|
@ -185,9 +184,24 @@ $(function() {
|
|||
});
|
||||
}
|
||||
|
||||
$.get("server.php",{user:"foo",passwd:"bar",action:"6",game:exit},function (data) {console.log(data);});
|
||||
|
||||
console.log(exit);
|
||||
$.get("server.php",{user:"foo",passwd:"bar",action:"6",game:exit},function (data) {
|
||||
$(".word").closest(".wordLine, #center").removeClass("valid invalid");
|
||||
if(data === true) {
|
||||
alert("Partie envoyée avec succès");
|
||||
} else if (data === false) {
|
||||
displayError("Le nuage doit contenir au moins "+nbWordMin+" mots valides.");
|
||||
} else if (data !== true) {
|
||||
$('input').removeAttr('disabled');
|
||||
var that = $(this);
|
||||
$.each(data,function(i,e) {
|
||||
$('.word')
|
||||
.filter(function() { return that.val() == e; })
|
||||
.closest(".wordLine, #center")
|
||||
.addClass("invalid");
|
||||
});
|
||||
}
|
||||
});
|
||||
$('input').attr('disabled', 'disabled');
|
||||
}
|
||||
|
||||
var displayError = function(message) {
|
||||
|
@ -198,7 +212,7 @@ $(function() {
|
|||
};
|
||||
|
||||
displayCentralWordAndRelations();
|
||||
displayNWordLines(nbWordMin);
|
||||
displayNWordLines(nbWordMin+5);
|
||||
displayButtons();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -73,9 +73,9 @@ function main()
|
|||
errRequestIncomplete();
|
||||
|
||||
if(wordExist($_GET['word']))
|
||||
echo true;
|
||||
echo "true";
|
||||
else
|
||||
echo false;
|
||||
echo "false";
|
||||
}
|
||||
else if($action == 5) { // Get relations (JSON)
|
||||
echo getGameRelationsJSON();
|
||||
|
|
Loading…
Reference in New Issue
Block a user