Packaged version 1.16
[PHPCredLocker.git] / Resources / admin.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* ************************************************************
Author:  Ben Tasker - BenTasker.co.uk
Description: Admin Javascript functions for PHPCredLocker. Most 
  functions currently quick and dirty, will improve in future releases!
 
License: GNU AGPL V3 -  See http://www.gnu.org/licenses/agpl-3.0.html
 
Repo: https://github.com/bentasker/PHPCredLocker/
---------------------------------------------------------------
Copyright (c) 2012 Ben Tasker
 
*/
function checkNewGroup(){var e=document.getElementById("frmName");if(e.value.length<=0){e.className+=" frmEntryMissed";return false}return true}function checkAddCredType(){var e=document.getElementById("frmName"),t=document.getElementById("ClickDiv").className.indexOf("EntropyGenerated");if(e.value.length<=0){e.className+=" frmEntryMissed";return false}if(t>=0){return true}alert("You must generate Entropy");return false}function validateUserAdd(){var e=0,t=document.getElementById("frmUsername"),n=document.getElementById("frmRName");if(t.value.length<=0){t.className="frmEntryMissed";e=1}if(n.value.length<=0){n.className="frmEntryMissed";e=1}if(!comparePwds()){e=1}if(e==1){alert("Please correct input errors and re-submit");return false}return true}function validateUserEdit(){var e=document.getElementById("frmUsername"),t=document.getElementById("frmRName"),n=document.getElementById("frmPass"),r=0;if(e.value.length<=0){e.className="frmEntryMissed";r=1}if(t.value.length<=0){t.className="frmEntryMissed";r=1}if(n.value.length>0){if(!comparePwds()){r=1}}if(r==1){alert("Please correct input errors and re-submit");return false}return true}function delGroup(e){var t,n,r,i,s=retKey(),o=document.getElementById("GroupDisp"+e),u=document.getElementById("NotificationArea");if(!confirm("Are you sure you want to delete this group (any credentials recorded against the group will be deleted)?")){return false}if(window.XMLHttpRequest){t=new XMLHttpRequest}else{t=new ActiveXObject("Microsoft.XMLHTTP")}t.onreadystatechange=function(){if(t.readyState==4&&t.status==200){n=decryptAPIResp(t.responseText,s).split(getDivider());if(n[1]==2){return unknownAPICommand()}if(n[1]==0||n[2]==0){u.innerHTML+='<div class="alert alert-error">Failed to Delete</div>';return false}o.parentNode.removeChild(o);u.innerHTML+='<div class="alert alert-success">Group Deleted</div>'}};i=cryptReq("delGroup",s);t.open("POST","api.php",true);t.setRequestHeader("Content-type","application/x-www-form-urlencoded");t.send("option="+i+"&id="+e)}function delUser(e){var t,n,r,i,s=retKey(),o=document.getElementById("User"+e),u=document.getElementById("NotificationArea");if(!confirm("Are you sure you want to delete this user?")){return false}if(window.XMLHttpRequest){t=new XMLHttpRequest}else{t=new ActiveXObject("Microsoft.XMLHTTP")}t.onreadystatechange=function(){if(t.readyState==4&&t.status==200){n=decryptAPIResp(t.responseText,s).split(getDivider());if(n[1]==2){return unknownAPICommand()}if(n[1]==0||n[2]==0){u.innerHTML+='<div class="alert alert-error">Failed to Delete</div>';return false}o.parentNode.removeChild(o);u.innerHTML+='<div class="alert alert-success">User Deleted</div>'}};i=cryptReq("delUser",s);t.open("POST","api.php",true);t.setRequestHeader("Content-type","application/x-www-form-urlencoded");t.send("option="+i+"&id="+e)}function delCredType(e){var t,n,r,i,s=retKey(),o=document.getElementById("CredType"+e),u=document.getElementById("NotificationArea");if(!confirm("Are you sure you want to delete this Credential Type (any associated credentials will be deleted)?")){return false}if(window.XMLHttpRequest){t=new XMLHttpRequest}else{t=new ActiveXObject("Microsoft.XMLHTTP")}t.onreadystatechange=function(){if(t.readyState==4&&t.status==200){n=decryptAPIResp(t.responseText,s).split(getDivider());if(n[1]==2){return unknownAPICommand()}if(n[1]==0||n[2]==0){u.innerHTML+='<div class="alert alert-error">Failed to Delete</div>';return false}o.parentNode.removeChild(o);u.innerHTML+='<div class="alert alert-success">Credential Type Deleted</div>'}};i=cryptReq("delCredType",s);t.open("POST","api.php",true);t.setRequestHeader("Content-type","application/x-www-form-urlencoded");t.send("option="+i+"&id="+e)}