mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-12 11:26:55 +01:00
* [ADD] Temporary password can be viewed within session. * [ADD] Old backup and export files are deleted when performing a new backup/export. * [ADD] Added the ability to force the connection through HTTPS. * [MOD] CSS and JS files are now minimized by default. * [MOD] Updated translations. * [MOD] UI tweaks. * [FIX] Fixed issue on enabling secondary users/groups edit on accounts. * [FIX] Fixed issue when sending email request to blank recipients.
1 line
6.3 KiB
JavaScript
1 line
6.3 KiB
JavaScript
(function(c){jQuery.event.props.push("dataTransfer");var a={fallback_id:"",url:"",refresh:1000,paramname:"userfile",requestType:"POST",allowedfileextensions:[],allowedfiletypes:[],maxfiles:25,maxfilesize:1,queuefiles:0,queuewait:200,data:{},headers:{},drop:b,dragStart:b,dragEnter:b,dragOver:b,dragLeave:b,docEnter:b,docOver:b,docLeave:b,beforeEach:b,afterAll:b,rename:b,error:function(j,h,g,e){alert(j)},uploadStarted:b,uploadFinished:b,progressUpdated:b,globalProgressUpdated:b,speedUpdated:b},f=["BrowserNotSupported","TooManyFiles","FileTooLarge","FileTypeNotAllowed","NotFound","NotReadable","AbortError","ReadError","FileExtensionNotAllowed"];c.fn.filedrop=function(h){var s=c.extend({},a,h),e=[],t,m=false,r=0,i;c("#"+s.fallback_id).css({display:"none",width:0,height:0});this.on("drop",o).on("dragstart",s.dragStart).on("dragenter",q).on("dragover",z).on("dragleave",A);c(document).on("drop",n).on("dragenter",p).on("dragover",u).on("dragleave",y);this.on("click",function(C){c("#"+s.fallback_id).trigger(C)});c("#"+s.fallback_id).change(function(C){s.drop(C);i=C.target.files;r=i.length;w()});function o(C){if(s.drop.call(this,C)===false){return false}if(!C.dataTransfer){return}i=C.dataTransfer.files;if(i===null||i===undefined||i.length===0){s.error(f[0]);return false}r=i.length;w();C.preventDefault();return false}function x(C,I,D,F){var G="--",K="\r\n",J="",E=s.paramname;if(s.data){var H=c.param(s.data).replace(/\+/g,"%20").split(/&/);c.each(H,function(){var N=this.split("=",2),L=decodeURIComponent(N[0]),M=decodeURIComponent(N[1]);if(N.length!==2){return}J+=G;J+=F;J+=K;J+='Content-Disposition: form-data; name="'+L+'"';J+=K;J+=K;J+=M;J+=K})}if(jQuery.isFunction(E)){E=E(C)}J+=G;J+=F;J+=K;J+='Content-Disposition: form-data; name="'+(E||"")+'"';J+='; filename="'+C+'"';J+=K;J+="Content-Type: "+D;J+=K;J+=K;J+=I;J+=K;J+=G;J+=F;J+=G;J+=K;return J}function k(H){if(H.lengthComputable){var D=Math.round((H.loaded*100)/H.total);if(this.currentProgress!==D){this.currentProgress=D;s.progressUpdated(this.index,this.file,this.currentProgress);e[this.global_progress_index]=this.currentProgress;j();var C=new Date().getTime();var F=C-this.currentStart;if(F>=s.refresh){var E=H.loaded-this.startData;var G=E/F;s.speedUpdated(this.index,this.file,G);this.startData=H.loaded;this.currentStart=C}}}}function j(){if(e.length===0){return}var D=0,C;for(C in e){if(e.hasOwnProperty(C)){D=D+e[C]}}s.globalProgressUpdated(Math.round(D/e.length))}function w(){m=false;if(!i){s.error(f[0]);return false}if(s.allowedfiletypes.push&&s.allowedfiletypes.length){for(var G=i.length;G--;){if(!i[G].type||c.inArray(i[G].type,s.allowedfiletypes)<0){s.error(f[3],i[G]);return false}}}if(s.allowedfileextensions.push&&s.allowedfileextensions.length){for(var G=i.length;G--;){var D=false;for(I=0;I<s.allowedfileextensions.length;I++){if(i[G].name.substr(i[G].name.length-s.allowedfileextensions[I].length)==s.allowedfileextensions[I]){D=true}}if(!D){s.error(f[8],i[G]);return false}}}var K=0,L=0;if(r>s.maxfiles&&s.queuefiles===0){s.error(f[1]);return false}var J=[];var E=[];var F=[];for(var I=0;I<r;I++){J.push(I)}var M=function(N){setTimeout(C,N);return};var C=function(){var Q;if(m){return false}if(s.queuefiles>0&&E.length>=s.queuefiles){return M(s.queuewait)}else{Q=J[0];J.splice(0,1);E.push(Q)}try{if(g(i[Q])!==false){if(Q===r){return}var N=new FileReader(),O=1048576*s.maxfilesize;N.index=Q;if(i[Q].size>O){s.error(f[2],i[Q],Q);E.forEach(function(S,R){if(S===Q){E.splice(R,1)}});L++;return true}N.onerror=function(R){switch(R.target.error.code){case R.target.error.NOT_FOUND_ERR:s.error(f[4]);return false;case R.target.error.NOT_READABLE_ERR:s.error(f[5]);return false;case R.target.error.ABORT_ERR:s.error(f[6]);return false;default:s.error(f[7]);return false}};N.onloadend=!s.beforeSend?H:function(R){s.beforeSend(i[Q],Q,function(){H(R)})};N.readAsDataURL(i[Q])}else{L++}}catch(P){E.forEach(function(S,R){if(S===Q){E.splice(R,1)}});s.error(f[0]);return false}if(J.length>0){C()}};var H=function(V){var P=(V.srcElement||V.target).index;if(V.target.index===undefined){V.target.index=B(V.total)}var Y=new XMLHttpRequest(),Z=Y.upload,Q=i[V.target.index],U=V.target.index,T=new Date().getTime(),O="------multipartformboundary"+(new Date()).getTime(),X=e.length,S,W=l(Q.name),N=Q.type;if(s.withCredentials){Y.withCredentials=s.withCredentials}var R=atob(V.target.result.split(",")[1]);if(typeof W==="string"){S=x(W,R,N,O)}else{S=x(Q.name,R,N,O)}Z.index=U;Z.file=Q;Z.downloadStartTime=T;Z.currentStart=T;Z.currentProgress=0;Z.global_progress_index=X;Z.startData=0;Z.addEventListener("progress",k,false);if(jQuery.isFunction(s.url)){Y.open(s.requestType,s.url(),true)}else{Y.open(s.requestType,s.url,true)}Y.setRequestHeader("content-type","multipart/form-data; boundary="+O);Y.setRequestHeader("X-Requested-With","XMLHttpRequest");c.each(s.headers,function(ab,aa){Y.setRequestHeader(ab,aa)});Y.sendAsBinary(S);e[X]=0;j();s.uploadStarted(U,Q,r);Y.onload=function(){var ae=null;if(Y.responseText){try{ae=jQuery.parseJSON(Y.responseText)}catch(ac){ae=Y.responseText}}var ab=new Date().getTime(),ad=ab-T,aa=s.uploadFinished(U,Q,ae,ad,Y);K++;E.forEach(function(ag,af){if(ag===P){E.splice(af,1)}});F.push(P);e[X]=100;j();if(K===(r-L)){v()}if(aa===false){m=true}if(Y.status<200||Y.status>299){s.error(Y.statusText,Q,P,Y.status)}}};C()}function B(D){for(var C=0;C<r;C++){if(i[C].size===D){return C}}return undefined}function l(C){return s.rename(C)}function g(C){return s.beforeEach(C)}function v(){return s.afterAll()}function q(C){clearTimeout(t);C.preventDefault();s.dragEnter.call(this,C)}function z(C){clearTimeout(t);C.preventDefault();s.docOver.call(this,C);s.dragOver.call(this,C)}function A(C){clearTimeout(t);s.dragLeave.call(this,C);C.stopPropagation()}function n(C){C.preventDefault();s.docLeave.call(this,C);return false}function p(C){clearTimeout(t);C.preventDefault();s.docEnter.call(this,C);return false}function u(C){clearTimeout(t);C.preventDefault();s.docOver.call(this,C);return false}function y(C){t=setTimeout((function(D){return function(){s.docLeave.call(D,C)}})(this),200)}return this};function b(){}try{if(XMLHttpRequest.prototype.sendAsBinary){return}XMLHttpRequest.prototype.sendAsBinary=function(g){function h(j){return j.charCodeAt(0)&255}var i=Array.prototype.map.call(g,h);var e=new Uint8Array(i);if("ArrayBufferView" in window){this.send(e)}else{this.send(e.buffer)}}}catch(d){}})(jQuery); |