mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-03 15:14:08 +01:00
35 lines
17 KiB
JavaScript
35 lines
17 KiB
JavaScript
var $jscomp={scope:{},findInternal:function(a,f,c){a instanceof String&&(a=String(a));for(var g=a.length,k=0;k<g;k++){var p=a[k];if(f.call(c,p,k,a))return{i:k,v:p}}return{i:-1,v:void 0}}};$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(a,f,c){if(c.get||c.set)throw new TypeError("ES3 does not support getters and setters.");a!=Array.prototype&&a!=Object.prototype&&(a[f]=c.value)};
|
|
$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global?global:a};$jscomp.global=$jscomp.getGlobal(this);$jscomp.polyfill=function(a,f,c,g){if(f){c=$jscomp.global;a=a.split(".");for(g=0;g<a.length-1;g++){var k=a[g];k in c||(c[k]={});c=c[k]}a=a[a.length-1];g=c[a];f=f(g);f!=g&&null!=f&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:f})}};
|
|
$jscomp.polyfill("Array.prototype.find",function(a){return a?a:function(a,c){return $jscomp.findInternal(this,a,c).v}},"es6-impl","es3");$jscomp.SYMBOL_PREFIX="jscomp_symbol_";$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.symbolCounter_=0;$jscomp.Symbol=function(a){return $jscomp.SYMBOL_PREFIX+(a||"")+$jscomp.symbolCounter_++};
|
|
$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.iterator;a||(a=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[a]&&$jscomp.defineProperty(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};$jscomp.arrayIterator=function(a){var f=0;return $jscomp.iteratorPrototype(function(){return f<a.length?{done:!1,value:a[f++]}:{done:!0}})};
|
|
$jscomp.iteratorPrototype=function(a){$jscomp.initSymbolIterator();a={next:a};a[$jscomp.global.Symbol.iterator]=function(){return this};return a};$jscomp.array=$jscomp.array||{};$jscomp.iteratorFromArray=function(a,f){$jscomp.initSymbolIterator();a instanceof String&&(a+="");var c=0,g={next:function(){if(c<a.length){var k=c++;return{value:f(k,a[k]),done:!1}}g.next=function(){return{done:!0,value:void 0}};return g.next()}};g[Symbol.iterator]=function(){return g};return g};
|
|
$jscomp.polyfill("Array.prototype.keys",function(a){return a?a:function(){return $jscomp.iteratorFromArray(this,function(a){return a})}},"es6-impl","es3");var sysPass=sysPass||{};sysPass.createNS=function(a){a=a.split(".");var f=sysPass;"sysPass"===a[0]&&(a=a.slice(1));for(var c=0;c<a.length;c++){var g=a[c];"undefined"===typeof f[g]&&(f[g]={});f=f[g]}return f};sysPass.createNS("sysPass.Util");
|
|
sysPass.Util.Common=function(a){var f,c,g,k,p=0,x=0,r,q={passLength:0,minPasswordLength:8,complexity:{numbers:!0,symbols:!0,uppercase:!0,numlength:12}},m={content:function(){return a("#content")},frmSearch:function(){return a("#frmSearch")}},y=new JSEncrypt;a(document).ready(function(){C();""!==g&&D()});(function(){var b=window.location.pathname.split("/"),d=window.location.protocol+"//"+window.location.host+function(){for(var a="",d=1;d<=b.length-2;d++)a+="/"+b[d];return a}();a.ajax({type:"GET",
|
|
url:d+"/ajax/ajax_getEnvironment.php",dataType:"json",async:!1,data:{isAjax:1},success:function(a){f=a.app_root;c=a.lang;g=a.pk;k=a.max_file_size;y.setPublicKey(g)}})})();var v=function(b,d,e){a.ajax({type:"POST",dataType:"html",url:f+"/ajax/ajax_getContent.php",data:{actionId:b,lastAction:d,itemId:e,isAjax:1},success:function(a){m.content().html(a);u()},error:function(){m.content().html(h("nofancyerror"))}})},u=function(){a("html, body").animate({scrollTop:0},"slow")},z=function(){var b=a("#frmSearch").serialize();
|
|
a.ajax({type:"POST",dataType:"html",url:f+"/ajax/ajax_search.php",data:b,success:function(b){a("#resBuscar").html(b);u()},error:function(){a("#resBuscar").html(h("nofancyerror"))}})},A=function(b,d,e){return a.ajax({type:"POST",url:f+"/ajax/ajax_viewpass.php",dataType:"json",async:!1,data:{accountid:b,full:d,isHistory:e,isAjax:1},success:function(b){if(10===b.status)t();else{if(!1===d||0===d)return!0;a("<div></div>").dialog({modal:!0,title:c[47],width:"auto",open:function(){var d=a(this),e,l="";e=
|
|
'<button class="dialog-clip-user-button ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary" data-clipboard-target=".dialog-user-text"><span class="ui-button-icon-primary ui-icon ui-icon-clipboard"></span><span class="ui-button-text">'+c[33]+"</span></button>";var f='<button class="dialog-clip-pass-button ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary" data-clipboard-target=".dialog-pass-text"><span class="ui-button-icon-primary ui-icon ui-icon-clipboard"></span><span class="ui-button-text">'+
|
|
c[34]+"</span></button>",l=b.useimage,g='<p class="dialog-user-text">'+b.acclogin+"</p>";0===b.status?(0===l?l='<p class="dialog-pass-text">'+b.accpass+"</p>":(l='<img class="dialog-pass-text" src="data:image/png;base64,'+b.accpass+'" />',f=""),e=g+l+'<div class="dialog-buttons">'+e+f+"</div>"):(e='<span class="altTxtRed">'+b.description+"</span>",d.dialog("option","buttons",[{text:"Ok",icons:{primary:"ui-icon-close"},click:function(){d.dialog("close")}}]));d.html(e);d.dialog("option","position",
|
|
"center");a(this).parent().on("mouseleave",function(){clearTimeout(r);r=setTimeout(function(){d.dialog("close")},3E4)})},close:function(){clearTimeout(r);a(this).dialog("destroy")}})}}})},t=function(){var a=window.location.search;location.href=0<a.length?"index.php"+a+"&logout=1":"index.php?logout=1"},n=function(b,d){a.ajax({type:"POST",dataType:"json",url:f+d,data:b,success:function(b){var d=b.description,e=b.action;switch(b.status){case 0:a.fancybox.close();h("ok",d,void 0,e);break;case 1:a.fancybox.close();
|
|
a(":input[type=password]").val("");h("error",d,void 0,e);break;case 2:a("#resFancyAccion").html('<span class="altTxtError">'+d+"</span>").show();break;case 3:a.fancybox.close();h("warn",d,void 0,e);break;case 10:t()}},error:function(a,b,d){h("error",c[1]+"<p>"+d+b+"</p>")}})},B=function(b,d){var e;e=a(".passLevel-"+d);e.removeClass("weak good strong strongest");0===q.passLength?e.attr("title","").empty():q.passLength<q.minPasswordLength?e.attr("title",c[11]).addClass("weak"):0===b?e.attr("title",
|
|
c[9]).addClass("weak"):1===b||2===b?e.attr("title",c[8]).addClass("good"):3===b?e.attr("title",c[7]).addClass("strong"):4===b&&e.attr("title",c[10]).addClass("strongest")},h=function(b,d,e,l){"undefined"!==typeof e&&a.ajax({url:e,type:"get",dataType:"html",async:!1,success:function(a){d=a}});d=d.replace(/(\\n|;;)/g,"<br>");switch(b){case "ok":alertify.success(d);break;case "error":alertify.error(d);break;case "warn":alertify.log(d);break;case "nofancyerror":return b='<p class="error round">Oops...<br>'+
|
|
c[1]+"<br>"+d+"</p>";default:alertify.error(d)}"undefined"!==typeof l&&eval(l)},w=function(b){var d=a(b),e=d.val();b+="-encrypted";var c=d.next(':input[name="'+b+'"]');if(""!==e&&c.attr("name")!==b||""!==e&&c.attr("name")===b&&parseInt(d.next().val())!==e.length)e=y.encrypt(e),d.val(e),0<c.length?c.val(e.length):d.after('<input type="hidden" name="'+b+'" value="'+e.length+'" />')},C=function(){var b=new Clipboard(".clip-pass-button",{text:function(a){return A(a.getAttribute("data-account-id"),!1).responseJSON.accpass}});
|
|
b.on("success",function(a){sysPassUtil.Common.resMsg("ok",c[45])});b.on("error",function(a){sysPassUtil.Common.resMsg("error",c[46])});var b=new Clipboard(".dialog-clip-pass-button"),d=new Clipboard(".dialog-clip-user-button");b.on("success",function(b){a(".dialog-pass-text").addClass("dialog-clip-pass-copy round");b.clearSelection()});d.on("success",function(a){a.clearSelection()})},D=function(){a("body").delegate(":input[type=password]","blur",function(b){a(this).hasClass("passwordfield__no-pki")||
|
|
(b=a(this).attr("id"),w("#"+b))}).delegate(":input[type=password]","keypress",function(b){if(13===b.keyCode){b.preventDefault();b=a(this).closest("form");var d=a(this).attr("id");w("#"+d);b.submit()}})};return{accSearch:function(a,d){m.frmSearch().find('input[name="start"]').val(0);z()},appMgmtData:function(b,d,e){var l=a(b).attr("data-itemid");b=a(b).attr("data-activetab");a.ajax({type:"POST",dataType:"html",url:f+"/ajax/ajax_appMgmtData.php",data:{itemId:l,actionId:d,sk:e,activeTab:b,isAjax:1},
|
|
success:function(b){a.fancybox(b,{padding:[0,10,10,10]})},error:function(a,b,d){h("error",c[1]+"<p>"+d+b+"</p>")}})},appMgmtSave:function(b){b=a("#"+b).serialize();n(b,"/ajax/ajax_appMgmtSave.php")},appMgmtDelete:function(b,d,e){var f=a(b).attr("data-itemid"),g=a(b).attr("data-activetab");b=a(b).attr("data-nextactionid");var h='<div id="alert"><p id="alert-text">'+c[12]+"</p></div>",k={itemId:f,actionId:d,sk:e,activeTab:g,onCloseAction:b};alertify.okBtn(c[43]).cancelBtn(c[44]).confirm(h,function(a){n(k,
|
|
"/ajax/ajax_appMgmtSave.php")},function(a){a.preventDefault();alertify.error(c[44])})},checkboxDetect:function(b){a(b).find(".checkbox").button({icons:{primary:"ui-icon-transferthick-e-w"}}).click(function(){!0===a(this).prop("checked")?a(this).button("option","label",c[40]):a(this).button("option","label",c[41])})},checkLdapConn:function(){var b=a("#frmLdap");n(b.serialize(),"/ajax/ajax_checkLdap.php")},checkPassLevel:function(a,d){var b=zxcvbn(a);B(b.score,d)},checkUpds:function(){a.ajax({type:"GET",
|
|
dataType:"html",url:f+"/ajax/ajax_checkUpds.php",timeout:1E4,success:function(b){a("#updates").html(b);"undefined"!==typeof componentHandler&&componentHandler.upgradeDom()},error:function(b,d,c){a("#updates").html("!")}})},clearEventlog:function(a){var b='<div id="alert"><p id="alert-text">'+c[20]+"</p></div>";alertify.okBtn(c[43]).cancelBtn(c[44]).confirm(b,function(b){n({clear:1,sk:a,isAjax:1},"/ajax/ajax_eventlog.php")},function(a){a.preventDefault();alertify.error(c[44])})},clearSearch:function(a){var b=
|
|
m.frmSearch();1===a?b.find('input[name="start"]').val(0):(document.frmSearch.search.value="",b.find("select").prop("selectedIndex",-1).trigger("chosen:updated"),b.find('input[name="start"], input[name="skey"], input[name="sorder"]').val(0),x=p=0)},chosenDetect:function(){a(".sel-chosen-usergroup").chosen({placeholder_text_single:c[21],placeholder_text_multiple:c[21],disable_search_threshold:10,no_results_text:c[26],width:"250px"});a(".sel-chosen-user").chosen({placeholder_text_single:c[22],placeholder_text_multiple:c[22],
|
|
disable_search_threshold:10,no_results_text:c[26],width:"250px"});a(".sel-chosen-profile").chosen({placeholder_text_single:c[23],disable_search_threshold:10,no_results_text:c[26],width:"250px"});a(".sel-chosen-customer").each(function(){var b=a(this).hasClass("sel-chosen-deselect");a(this).chosen({allow_single_deselect:b,placeholder_text_single:c[24],placeholder_text_multiple:c[24],disable_search_threshold:10,no_results_text:c[26],width:"250px"})});a(".sel-chosen-category").each(function(){var b=
|
|
a(this).hasClass("sel-chosen-deselect");a(this).chosen({allow_single_deselect:b,placeholder_text_single:c[25],placeholder_text_multiple:c[25],disable_search_threshold:10,no_results_text:c[26],width:"250px"})});a(".sel-chosen-action").each(function(){var b=a(this).hasClass("sel-chosen-deselect");a(this).chosen({allow_single_deselect:b,placeholder_text_single:c[39],placeholder_text_multiple:c[39],disable_search_threshold:10,no_results_text:c[26],width:"250px"})});a(".sel-chosen-ns").chosen({disable_search:!0,
|
|
width:"250px"})},configMgmt:function(b,d){var c;switch(b){case "config":c="/ajax/ajax_configSave.php";break;case "export":c="/ajax/ajax_backup.php";break;case "import":c="/ajax/ajax_migrate.php";break;case "preferences":c="/ajax/ajax_userPrefsSave.php";break;default:return}var f=a(d).serialize();n(f,c)},delAccount:function(a,d,e){var b={accountid:a,actionId:d,sk:e};a='<div id="alert"><p id="alert-text">'+c[3]+"</p></div>";alertify.okBtn(c[43]).cancelBtn(c[44]).confirm(a,function(a){n(b,"/ajax/ajax_accountSave.php")},
|
|
function(a){a.preventDefault();alertify.error(c[44])})},delFile:function(b,d,e){var l='<div id="alert"><p id="alert-text">'+c[15]+"</p></div>";alertify.okBtn(c[43]).cancelBtn(c[44]).confirm(l,function(c){a.post(f+"/ajax/ajax_files.php",{fileId:b,action:"delete",sk:d},function(b){h("ok",b);a("#downFiles").load(f+"/ajax/ajax_getFiles.php?id="+e+"&del=1&isAjax=1&sk="+d)})},function(a){a.preventDefault();alertify.error(c[44])})},doAction:v,doLogin:function(){var b=a("#frmLogin").serialize();a("#btnLogin").prop("disabled",
|
|
!0);a.ajax({type:"POST",dataType:"json",url:f+"/ajax/ajax_doLogin.php",data:b,success:function(b){var c=b.status;b=b.description;0===c||2===c?location.href=b:3===c||4===c?(h("error",b),a("#user").val("").focus(),a("#pass").val(""),a("#mpass").prop("disabled",!1),a("#smpass").val("").show()):5===c?h("warn",b,"","location.href = 'index.php';"):(a("#user").val("").focus(),a("#pass").val(""),h("error",b))},complete:function(){a("#btnLogin").prop("disabled",!1);sysPassUtil.hideLoading()},statusCode:{404:function(){h("error",
|
|
c[1]+"<p>"+c[13]+"</p>")}}});return!1},doLogout:t,downFile:function(b,d,e){b={fileId:b,sk:d,action:e};"view"===e?a.ajax({type:"POST",cache:!1,url:f+"/ajax/ajax_files.php",data:b,success:function(b){b?(a.fancybox(b,{padding:[10,10,10,10]}),setTimeout(function(){a.fancybox.update()},1E3)):h("error",c[14])}}):"download"===e&&a.fileDownload(f+"/ajax/ajax_files.php",{httpMethod:"POST",data:b})},encryptFormValue:w,fileUpload:function(b){var d={targetId:"",url:""},e,l={},g,n={setRequestDoneAction:function(a){e=
|
|
a},setRequestData:function(a){l=a},setBeforeSendAction:function(a){g=a}},d=b;if("undefined"===typeof d.targetId||""===d.targetId)return n;var m=document.getElementById(d.targetId),p=function(b){if("undefined"===typeof d.url||""===d.url)return!1;var g=new FormData;g.append("inFile",b);g.append("isAjax",1);Object.keys(l).forEach(function(a){g.append(a,l[a])});a.ajax({type:"POST",dataType:"json",cache:!1,processData:!1,contentType:!1,url:f+d.url,data:g,success:function(a){var b=a.status;a=a.description;
|
|
0===b?("function"===typeof e&&e(),h("ok",a)):10===b?t():h("error",a)},error:function(a,b,d){h("error",c[1]+"<p>"+d+b+"</p>")}})},q=function(a){if(5<a.length)h("error",c[17]+" (Max: 5)");else for(var b=0;b<a.length;b++){var d=a[b];if(d.size/1E3>k)h("error",c[18]+"<br>"+d.name+" (Max: "+k+")");else{var e;a:{e=d.name;for(var f=m.getAttribute("data-files-ext").toLowerCase().split(","),g=0;g<=f.length;g++)if(-1!==e.indexOf(f[g])){e=!0;break a}e=!1}e?p(a[b]):h("error",c[19]+"<br>"+d.name)}}},r=function(a){var b=
|
|
document.getElementById("fileUploadForm"),c=b.getElementsByTagName("input");b.style.display=!1===a?"none":"";"file"===c[0].type&&c[0].addEventListener("change",function(){"function"===typeof g&&g();q(this.files)},!1);return c[0]};window.File&&window.FileList&&window.FileReader?function(){m.ondragover=m.ondragenter=function(a){a.stopPropagation();a.preventDefault()};m.ondrop=function(a){a.stopPropagation();a.preventDefault();"function"===typeof g&&g();q(a.dataTransfer.files)};var a=r(!1);m.onclick=
|
|
function(){a.click()}}():r(!0);return n},getFiles:function(b,c,e){a.ajax({type:"GET",cache:!1,url:f+"/ajax/ajax_getFiles.php",data:{id:b,del:c,sk:e},success:function(b){a("#downFiles").html(b)}})},navLog:function(b,c){if("undefined"===typeof b)return!1;a.ajax({type:"POST",dataType:"html",url:f+"/ajax/ajax_eventlog.php",data:{start:b,current:c},success:function(a){m.content().html(a)},error:function(){m.content().html(h("nofancyerror"))}})},outputResult:B,redirect:function(a){location.href=a},resMsg:h,
|
|
searchSort:function(b,c,e){if("undefined"===typeof b||"undefined"===typeof c)return!1;var d=a("#frmSearch");d.find('input[name="skey"]').val(b);d.find('input[name="sorder"]').val(e);d.find('input[name="start"]').val(c);z()},saveAccount:function(b){b=a("#"+b).serialize();var d=a('input[name="accountid"]').val(),e=a('input[name="next"]').val();a.ajax({type:"POST",dataType:"json",url:f+"/ajax/ajax_accountSave.php",data:b,success:function(a){var b=a.status;a=a.description;0===b?(h("ok",a),e&&d?v(e,1,
|
|
d):e&&v(e,1)):10===b?t():h("error",a)},error:function(a,b,d){h("error",c[1]+"<p>"+d+b+"</p>")}})},sendAjax:n,sendRequest:function(){var b=a("#frmRequestModify").serialize();n(b,"/ajax/ajax_sendRequest.php")},setContentSize:function(){var b=a("#container");if(!b.hasClass("content-no-auto-resize")){var c=m.content().height()+150;a(document).height()>=c?b.css("height",c):b.css("height","auto")}},scrollUp:u,showOptional:function(a){a.hide();a.parent().children(".actions-optional").show(250)},showSearchOrder:function(){if(p){var b=
|
|
a("#search-sort-"+p);b.addClass("filterOn");0===x?b.append('<img src="imgs/arrow_down.png" style="width:17px;height:12px;" />'):b.append('<img src="imgs/arrow_up.png" style="width:17px;height:12px;" />')}},usrUpdPass:function(b,c,e){b={userId:a(b).attr("data-itemid"),actionId:c,sk:e,isAjax:1};a.ajax({type:"GET",cache:!1,url:f+"/ajax/ajax_usrpass.php",data:b,success:function(b){0===b.length?t():a.fancybox(b,{padding:0})}})},viewPass:A,passwordData:q,passToClip:0,APP_ROOT:f,LANG:c,PK:g}}(jQuery);
|