implemented jquery communication with the server to submit commands and wait for them to be processed
This commit is contained in:
parent
3b1896d5ab
commit
108c996a0a
|
@ -12,7 +12,7 @@
|
|||
|
||||
</head>
|
||||
<body>
|
||||
<h1>Welcome Player {{ player_id }}</h1>
|
||||
<h1>Hallo Spieler {{ player_id + 1 }}</h1>
|
||||
<!-- container -->
|
||||
<div class="container">
|
||||
|
||||
|
@ -28,12 +28,42 @@
|
|||
|
||||
</div><!-- container -->
|
||||
|
||||
<input id="btnSubmit" type="submit" value="Click Me" />
|
||||
|
||||
|
||||
<div class="container notification" hidden>
|
||||
Bitte warten, bis alle Spieler ihre Aktion gewählt haben...
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
|
||||
var please_wait = $(".notification").hide();
|
||||
|
||||
var box = $(".box");
|
||||
var mainCanvas = $(".main-canvas");
|
||||
|
||||
$("#btnSubmit").click(function () {
|
||||
//alert("button");
|
||||
for (i = 0; i < 5; i++) {
|
||||
var c = document.getElementsByClassName("box card" + String(i));
|
||||
$(c).hide();
|
||||
}
|
||||
|
||||
$(please_wait).show();
|
||||
|
||||
$.post("/send_cmds", "", function (data) {
|
||||
console.log(data);
|
||||
$(please_wait).hide();
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
var c = document.getElementsByClassName("box card" + String(i));
|
||||
$(c).show();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
box.draggable({
|
||||
containment: mainCanvas,
|
||||
helper: "clone",
|
||||
|
@ -67,7 +97,8 @@
|
|||
//console.log(dragPos);
|
||||
//console.log(dropPos);
|
||||
|
||||
console.log($(cmds));
|
||||
//console.log($(cmds));
|
||||
// notify server that cards have been swapped
|
||||
$.post(url='/', {drag: ui.draggable.attr('name'), drop: $(this).attr('name')});
|
||||
|
||||
draggable.css({
|
||||
|
|
Loading…
Reference in New Issue
Block a user