diff --git a/static/js/main.js b/static/js/main.js index 1897e6d..4a902b7 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -266,7 +266,8 @@ function get_admin(type) {
${text}
- `) + `); + refreshListener(); } } }); @@ -381,27 +382,6 @@ 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 @@ -671,6 +651,26 @@ function refreshListener() { $('.overlay').css({"opacity": 1, "visibility": "visible"}); }); + $('#switch-state').click((e) => { + $.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'); + } + } + }); + + }); } $('.close').click((e) => {