2020-09-11 12:30:40 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<title>Drag</title>
|
|
|
|
|
|
|
|
<script src="static/jquery-3.5.1.js"></script>
|
|
|
|
<script src="static/jquery-ui.min.js"></script>
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="static/style.css">
|
|
|
|
|
|
|
|
|
|
|
|
</head>
|
|
|
|
<body>
|
2020-09-11 14:40:20 +00:00
|
|
|
<h1>Welcome Player {{ player_id }}</h1>
|
2020-09-11 12:30:40 +00:00
|
|
|
<!-- container -->
|
|
|
|
<div class="container">
|
|
|
|
|
|
|
|
<div class="main-canvas">
|
|
|
|
|
2020-09-11 13:44:38 +00:00
|
|
|
{% for i in range(0,9) %}
|
|
|
|
<div class="box card{{ i }}" name="{{ cmds[i].number }}" >{{ cmds[i].action }}
|
|
|
|
<p style="font-size: 10px">{{ cmds[i].priority }}</p>
|
2020-09-11 12:30:40 +00:00
|
|
|
</div>
|
2020-09-11 13:44:38 +00:00
|
|
|
{% endfor %}
|
2020-09-11 12:30:40 +00:00
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div><!-- container -->
|
|
|
|
|
|
|
|
<script>
|
|
|
|
$(document).ready(function () {
|
|
|
|
|
|
|
|
var box = $(".box");
|
|
|
|
var mainCanvas = $(".main-canvas");
|
|
|
|
|
|
|
|
box.draggable({
|
|
|
|
containment: mainCanvas,
|
|
|
|
helper: "clone",
|
|
|
|
|
|
|
|
start: function () {
|
|
|
|
$(this).css({
|
|
|
|
opacity: 0
|
|
|
|
});
|
|
|
|
|
|
|
|
$(".box").css("z-index", "0");
|
|
|
|
},
|
|
|
|
|
|
|
|
stop: function () {
|
|
|
|
$(this).css({
|
|
|
|
opacity: 1
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
box.droppable({
|
|
|
|
accept: box,
|
|
|
|
|
|
|
|
drop: function (event, ui) {
|
|
|
|
var draggable = ui.draggable;
|
|
|
|
var droppable = $(this);
|
|
|
|
var dragPos = draggable.position();
|
|
|
|
var dropPos = droppable.position();
|
|
|
|
|
2020-09-11 13:44:38 +00:00
|
|
|
var cmds = [ui.draggable.attr('name').toString(), $(this).attr('name')]
|
|
|
|
|
|
|
|
//console.log(dragPos);
|
|
|
|
//console.log(dropPos);
|
|
|
|
|
|
|
|
console.log($(cmds));
|
|
|
|
$.post(url='/', {drag: ui.draggable.attr('name'), drop: $(this).attr('name')});
|
2020-09-11 12:30:40 +00:00
|
|
|
|
|
|
|
draggable.css({
|
|
|
|
left: dropPos.left + "px",
|
|
|
|
top: dropPos.top + "px",
|
|
|
|
"z-index": 20
|
|
|
|
});
|
|
|
|
|
|
|
|
droppable.css("z-index", 10).animate({
|
|
|
|
left: dragPos.left,
|
|
|
|
top: dragPos.top
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|