From 38d3519a86ac7889676f34fb3a558111ca823e3d Mon Sep 17 00:00:00 2001 From: johan Date: Tue, 10 Jan 2023 09:34:07 +0100 Subject: [PATCH] sfds --- static/js/main.js | 75 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/static/js/main.js b/static/js/main.js index 305eb8a..0f734a3 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -241,6 +241,32 @@ function get_admin(type) { break; } } + $.ajax({ + type: "POST", + url: base_url + "get", + data: JSON.stringify({ + uid: localStorage.getItem('user'), + token: localStorage.getItem('token'), + type: "state" + }), + + success: function(data) { + if(data.success) { + if(data.state == "open") { + var text = 'Vérouiller'; + } else { + var text = 'Dévérouiller'; + } + $('#admin-content').append(` + +

Changer l'état de commande de crêpe :

+
${text}
+
+ `) + } + } + }); + $("#admin-content").append(`
Nombre totale de missions achevées: ${doneCnt}
@@ -351,6 +377,28 @@ function get_admin(type) { } function refreshListener() { + $('#switch-state').click(() => { + + $.ajax({ + type: "POST", + url: base_url + "switchState", + data: JSON.stringify({ + uid: localStorage.getItem('user'), + token: localStorage.getItem('token'), + }), + contentType: "application/json; charset=utf-8", + dataType: "json", + success: function(data) { + if(data.state == 'open') { + $("#switch-state").text('Vérouiller'); + } else { + $("#switch-state").text('Dévérouiller'); + } + } + }) + + }) + $(".prank-btn-accept").click((e) => { let uid = e.target.parentNode.parentNode.id $.ajax({ @@ -715,8 +763,35 @@ $('#demande-button').click(function () { }); }); +var saved_form = $('#login-form').html(); + +function is_locked() { + +} + function updateDemandes() { + if(localStorage.getItem('user') && localStorage.getItem('token')) { + $.ajax({ + type: "POST", + url: base_url + "get", + data: JSON.stringify({ + uid: localStorage.getItem('user'), + token: localStorage.getItem('token'), + type: "state" + }), + + success: function(data) { + if(data.success) { + if(data.state == "open") { + $('#login-form').html(saved_form); + } else { + $('#login-form').html('

Les commandes sont fermés pour le moment mais on revient vite !

'); + } + } + } + }); + $.ajax({ type: "POST", url: base_url + "get",