7 lines
2.1 KiB
JavaScript
7 lines
2.1 KiB
JavaScript
var TOKEN={add:{toggle:document.getElementById("add-token"),panel:$("[data-sublink='tokens'] div[data-add]"),state:!0,submit:$("[data-sublink='tokens'] div[data-add] #add-token-submit")},remove:{buttons:$$(".remove-token")}},tokenDeflater=new FormDeflater(TOKEN.add.panel,["input"],["id"]);TOKEN.add.toggle.addEventListener("click",function(a){TOKEN.add.state?TOKEN.add.panel.addClass("active"):TOKEN.add.panel.remClass("active");TOKEN.add.state=!TOKEN.add.state},!1);
|
|
TOKEN.add.submit.addEventListener("click",function(a){a=tokenDeflater.deflate();api.send({path:"token/generate",name:a["add-name"].value,duration:a["add-duration"].value},function(a){0==a.ModuleError&&reload()})},!1);
|
|
for(var i=0;i<TOKEN.remove.buttons.length;i++)TOKEN.remove.buttons[i].addEventListener("click",function(a){a=a.target.parentNode.getData("id");0==a?console.warn("id du token non trouvee"):api.send({path:"token/remove",token_id:a},function(a){console.log(a);0==a.ModuleError&&reload()})},!1);
|
|
var USERS={add:{toggle:document.getElementById("add-user"),panel:$("[data-sublink='users'] div[data-add]"),state:!0,submit:$("[data-sublink='users'] div[data-add] #add-user-submit")},remove:{buttons:$$(".remove-user")}},userDefalter=new FormDeflater(USERS.add.panel,["input"],["id"]);USERS.add.toggle.addEventListener("click",function(a){USERS.add.state?USERS.add.panel.addClass("active"):USERS.add.panel.remClass("active");USERS.add.state=!USERS.add.state},!1);
|
|
USERS.add.submit.addEventListener("click",function(a){a=userDefalter.deflate();a["add-password"].value==a["add-password2"].value&&api.send({path:"user/create",login:a["add-login"].value,password:a["add-password"].value,mail:a["add-mail"].value,reference:a["add-reference"].value,permission:a["add-admin"].checked?"admin":"subject"},function(a){console.log(a);0==a.ModuleError&&reload()})},!1);
|
|
for(i=0;i<USERS.remove.buttons.length;i++)USERS.remove.buttons[i].addEventListener("click",function(a){a=a.target.parentNode.getData("id");0==a?console.warn("id de l'utilisateur non trouvee"):api.send({path:"user/remove",id_user:a},function(a){0==a.ModuleError&&reload()})},!1);
|