1
0
Fork 0

Fix useless imports

This commit is contained in:
Ethanell 2020-01-27 17:36:58 +01:00
parent 6a09ae8ff7
commit 2aacc910f5
5 changed files with 115 additions and 139 deletions

View file

113
app/static/js/pc.js Normal file
View file

@ -0,0 +1,113 @@
let socket = io();
let list = document.querySelector('.liste');
function addcmd(id, plate, content, drink, dessert, state) {
let newDiv = document.createElement("div");
newDiv.classList.add('com');
newDiv.id = `cmd${id}`;
$(list).append(newDiv);
let numCom = document.createElement("h1");
let subDiv = document.createElement("div");
let p1 = document.createElement("p");
let p2 = document.createElement("p");
let p3 = document.createElement("p");
let p4 = document.createElement("p");
let btn1 = document.createElement("button");
let btn2 = document.createElement("button");
let btn3 = document.createElement("button");
subDiv.classList.add('spec');
btn1.classList.add('annuler');
btn2.classList.add('donner');
btn3.classList.add('erreur');
numCom.innerHTML = `Commande ${id}`;
p1.innerHTML = plate;
p2.innerHTML = content;
p3.innerHTML = drink;
p4.innerHTML = dessert;
btn1.innerHTML = "Annuler";
btn2.innerHTML = "Donnée";
btn3.innerHTML = "Erreur";
newDiv.append(numCom);
newDiv.append(subDiv);
subDiv.append(p1);
subDiv.append(p2);
subDiv.append(p3);
subDiv.append(p4);
subDiv.append(btn1);
newDiv.append(btn2);
newDiv.append(btn3);
document.querySelector('#resume>h1').innerHTML = `Commande ${id+1}`;
newDiv.addEventListener('click', ev => {
newDiv.classList.toggle('show-spec');
});
newDiv.querySelector('.donner').addEventListener('click', ev => {
ev.stopPropagation();
socket.emit("give command", {"id": id});
});
newDiv.querySelector('.annuler').addEventListener('click', ev => {
ev.stopPropagation();
socket.emit("clear command", {"id": id});
});
newDiv.querySelector('.erreur').addEventListener('click', ev => {
ev.stopPropagation();
socket.emit("error command", {"id": id});
});
switch (state) {
case "gave":
give(newDiv);
break;
case "error":
error(newDiv);
break;
}
}
function clear(e) {
e.classList.remove('donnee');
e.classList.remove('probleme');
e.classList.remove('show-spec');
list.prepend(e);
}
function give(e) {
e.classList.remove('show-spec');
e.classList.add('donnee');
list.appendChild(e);
}
function error(e) {
e.classList.remove('show-spec');
e.classList.add('probleme');
list.appendChild(e);
}
socket.on("command list", function (data) {
var child = list.lastElementChild;
while (child) {
list.removeChild(child);
child = list.lastElementChild;
}
for (let c of data.list) {
addcmd(c.id, c.plate, c.content, c.drink, c.dessert, c.state);
}
});
socket.on("new command", function (data) {
addcmd(data.id, data.plate, data.content, data.drink, data.dessert, data.state);
});
socket.on("cleared command", function (data) {
clear(document.querySelector(`.liste #cmd${data.id}`));
});
socket.on("gave command", function (data) {
give(document.querySelector(`.liste #cmd${data.id}`));
});
socket.on("glitched command", function (data) {
error(document.querySelector(`.liste #cmd${data.id}`));
});
document.querySelector('#resume button').addEventListener('click', ev => {
socket.emit("add command", {"plate": document.querySelector('#resume :nth-child(2)'), "content": "Jambon - Tomate - Brie", "drink": "Boisson surprise", "dessert": "Panini nutella"});
});

View file

@ -7,16 +7,12 @@
<!--===============================================================================================-->
<link rel="icon" type="image/png" href="{{ url_for('static', filename='images/icons/favicon.ico') }}"/>
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='vendor/bootstrap/css/bootstrap.min.css') }}">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='fonts/font-awesome-4.7.0/css/font-awesome.min.css') }}">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='vendor/animate/animate.css') }}">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='vendor/css-hamburgers/hamburgers.min.css') }}">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='vendor/select2/select2.min.css') }}">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/util.css') }}">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/main.css') }}">
<!--===============================================================================================-->

View file

@ -62,15 +62,4 @@
</div>
</div>
</div>
<!--===============================================================================================-->
<script src="{{ url_for('static', filename='vendor/jquery/jquery-3.2.1.min.js') }}"></script>
<!--===============================================================================================-->
<script src="{{ url_for('static', filename='vendor/bootstrap/js/popper.js') }}"></script>
<script src="{{ url_for('static', filename='vendor/bootstrap/js/bootstrap.min.js') }}"></script>
<!--===============================================================================================-->
<script src="{{ url_for('static', filename='vendor/select2/select2.min.js') }}"></script>
<!--===============================================================================================-->
<script src="{{ url_for('static', filename='js/main.js') }}"></script>
{% endblock %}

View file

@ -94,131 +94,9 @@
</div>
</div>
<script src="//cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js" integrity="sha256-yr4fRk/GU1ehYJPAs8P4JlTgu0Hdsp4ZKrx8bDEDC3I=" crossorigin="anonymous"></script>
<script>
let socket = io();
let list = document.querySelector('.liste');
function addcmd(id, plate, content, drink, dessert, state) {
let newDiv = document.createElement("div");
newDiv.classList.add('com');
newDiv.id = `cmd${id}`;
$(list).append(newDiv);
let numCom = document.createElement("h1");
let subDiv = document.createElement("div");
let p1 = document.createElement("p");
let p2 = document.createElement("p");
let p3 = document.createElement("p");
let p4 = document.createElement("p");
let btn1 = document.createElement("button");
let btn2 = document.createElement("button");
let btn3 = document.createElement("button");
subDiv.classList.add('spec');
btn1.classList.add('annuler');
btn2.classList.add('donner');
btn3.classList.add('erreur');
numCom.innerHTML = `Commande ${id}`;
p1.innerHTML = plate;
p2.innerHTML = content;
p3.innerHTML = drink;
p4.innerHTML = dessert;
btn1.innerHTML = "Annuler";
btn2.innerHTML = "Donnée";
btn3.innerHTML = "Erreur";
newDiv.append(numCom);
newDiv.append(subDiv);
subDiv.append(p1);
subDiv.append(p2);
subDiv.append(p3);
subDiv.append(p4);
subDiv.append(btn1);
newDiv.append(btn2);
newDiv.append(btn3);
document.querySelector('#resume>h1').innerHTML = `Commande ${id+1}`;
newDiv.addEventListener('click', ev => {
newDiv.classList.toggle('show-spec');
});
newDiv.querySelector('.donner').addEventListener('click', ev => {
ev.stopPropagation();
socket.emit("give command", {"id": id});
});
newDiv.querySelector('.annuler').addEventListener('click', ev => {
ev.stopPropagation();
socket.emit("clear command", {"id": id});
});
newDiv.querySelector('.erreur').addEventListener('click', ev => {
ev.stopPropagation();
socket.emit("error command", {"id": id});
});
switch (state) {
case "gave":
give(newDiv);
break;
case "error":
error(newDiv);
break;
}
}
function clear(e) {
e.classList.remove('donnee');
e.classList.remove('probleme');
e.classList.remove('show-spec');
list.prepend(e);
}
function give(e) {
e.classList.remove('show-spec');
e.classList.add('donnee');
list.appendChild(e);
}
function error(e) {
e.classList.remove('show-spec');
e.classList.add('probleme');
list.appendChild(e);
}
socket.on("command list", function (data) {
var child = list.lastElementChild;
while (child) {
list.removeChild(child);
child = list.lastElementChild;
}
for (let c of data.list) {
addcmd(c.id, c.plate, c.content, c.drink, c.dessert, c.state);
}
});
socket.on("new command", function (data) {
addcmd(data.id, data.plate, data.content, data.drink, data.dessert, data.state);
});
socket.on("cleared command", function (data) {
clear(document.querySelector(`.liste #cmd${data.id}`));
});
socket.on("gave command", function (data) {
give(document.querySelector(`.liste #cmd${data.id}`));
});
socket.on("glitched command", function (data) {
error(document.querySelector(`.liste #cmd${data.id}`));
});
document.querySelector('#resume button').addEventListener('click', ev => {
socket.emit("add command", {"plate": document.querySelector('#resume :nth-child(2)'), "content": "Jambon - Tomate - Brie", "drink": "Boisson surprise", "dessert": "Panini nutella"});
});
</script>
<!--===============================================================================================-->
<script src="{{ url_for('static', filename='vendor/jquery/jquery-3.2.1.min.js') }}"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js" integrity="sha256-yr4fRk/GU1ehYJPAs8P4JlTgu0Hdsp4ZKrx8bDEDC3I=" crossorigin="anonymous"></script>
<!--===============================================================================================-->
<script src="{{ url_for('static', filename='vendor/bootstrap/js/popper.js') }}"></script>
<script src="{{ url_for('static', filename='vendor/bootstrap/js/bootstrap.min.js') }}"></script>
<!--===============================================================================================-->
<script src="{{ url_for('static', filename='vendor/select2/select2.min.js') }}"></script>
<!--===============================================================================================-->
<script src="{{ url_for('static', filename='js/main.js') }}"></script>
<script src="{{ url_for('static', filename='js/pc.js') }}"></script>
{% endblock %}