permission working

This commit is contained in:
Qwann 2017-03-10 16:40:36 +01:00
parent f18bb9f336
commit cd31c55254
4 changed files with 38 additions and 9 deletions

View file

@ -17,13 +17,7 @@ function kfet_open(init_date, init_satus, init_force_close, force_close_url, for
var force_close = init_force_close;
// EVENT
force_close_button.click(function() {
if (force_close) {
$.get(force_open_url, function(data) {});
} else {
$.get(force_close_url, function(data) {});
}
});
force_close_button.click(forceClose);
// INITIALISAITION
update_open();
@ -36,6 +30,36 @@ function kfet_open(init_date, init_satus, init_force_close, force_close_url, for
}, 30 * 1000); // 60 * 1000 milsec
// FONCTIONS
function forceClose(password = '') {
if (force_close) {
force_url = force_open_url;
} else {
force_url = force_close_url;
}
$.ajax({
dataType: "html",
url : force_url,
method : "GET",
beforeSend: function ($xhr) {
if (password != '')
$xhr.setRequestHeader("KFetPassword", password);
},
})
.done(function() {})
.fail(function($xhr) {
var data = $xhr.responseJSON;
switch ($xhr.status) {
case 403:
requestAuth({'errors':{}}, forceClose);
break;
case 400:
alert('lol');
break;
}
lock = 0;
});
}
function nb_min_diff() {
var date_now = new Date();
// On calcule le nb de minutes depuis le dernier