NxTIC/subDir/public_html/view/js/min/settings.js

6 lines
2.0 KiB
JavaScript
Raw Permalink Normal View History

2016-10-19 06:03:36 +00:00
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"],duration:a["add-duration"]},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){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"]==a["add-password2"]&&api.send({path:"user/create",login:a["add-login"],password:a["add-password"],mail:a["add-mail"],reference:a["add-reference"],permission:a["add-admin"]},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);