mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-06 00:24:08 +01:00
9 lines
3.0 KiB
JavaScript
9 lines
3.0 KiB
JavaScript
var $jscomp={scope:{},checkStringArgs:function(b,d,c){if(null==b)throw new TypeError("The 'this' value for String.prototype."+c+" must not be null or undefined");if(d instanceof RegExp)throw new TypeError("First argument to String.prototype."+c+" must not be a regular expression");return b+""}};
|
|
$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(b,d,c){if(c.get||c.set)throw new TypeError("ES3 does not support getters and setters.");b!=Array.prototype&&b!=Object.prototype&&(b[d]=c.value)};$jscomp.getGlobal=function(b){return"undefined"!=typeof window&&window===b?b:"undefined"!=typeof global?global:b};$jscomp.global=$jscomp.getGlobal(this);
|
|
$jscomp.polyfill=function(b,d,c,e){if(d){c=$jscomp.global;b=b.split(".");for(e=0;e<b.length-1;e++){var a=b[e];a in c||(c[a]={});c=c[a]}b=b[b.length-1];e=c[b];d=d(e);d!=e&&null!=d&&$jscomp.defineProperty(c,b,{configurable:!0,writable:!0,value:d})}};
|
|
$jscomp.polyfill("String.prototype.startsWith",function(b){return b?b:function(b,c){var d=$jscomp.checkStringArgs(this,b,"startsWith");b+="";for(var a=d.length,h=b.length,g=Math.max(0,Math.min(c|0,d.length)),f=0;f<h&&g<a;)if(d[g++]!=b[f++])return!1;return f>=h}},"es6-impl","es3");
|
|
sysPass.Requests=function(b){var d=b.log,c=[],e={get:function(){return c},add:function(a){var b=""===a.hash?SparkMD5.hash(JSON.stringify(a),!1):a.hash;if(0<c.length&&c[c.length-1].hash===b)return c;d.info("history:add");a.hash=b;c.push(a);15<=c.length&&c.splice(0,10);return c},del:function(){d.info("history:del");if("undefined"!==typeof c.pop())return c[c.length-1]},reset:function(){d.info("history:reset");c=[]},length:function(){return c.length}};return{getRequestOpts:function(){return Object.create({type:"json",
|
|
url:"",method:"post",callback:"",async:!0,data:"",cache:!1,processData:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",timeout:0,addHistory:!1,hash:"",useLoading:!0,useFullLoading:!1})},getActionCall:function(a,c,g){d.info("getActionCall");var f=a.url.startsWith("http",0)||a.url.startsWith("https",0)?a.url:b.config().APP_ROOT+a.url;return $.ajax({dataType:a.type,url:f,method:a.method,async:a.async,data:a.data,cache:a.cache,processData:a.processData,contentType:a.contentType,timeout:a.timeout,
|
|
beforeSend:function(){!0===a.useLoading&&b.appTheme().loading.show(a.useFullLoading)},success:function(b){if("function"!==typeof c)return!0;!0===a.addHistory&&(a.callback=c,e.add(a));c(b)},error:function(c,e,f){"function"!==typeof g?(c=b.config().LANG[1]+"<p>"+f+e+"</p>",d.error(c),"html"===a.type&&$("#content").html(b.msg.html.error(f)),b.msg.error(c)):g()},complete:function(){!0===a.useLoading&&b.appTheme().loading.hide();b.appTheme().ajax.complete()}})},getActionPromise:function(a,c){d.info("getActionPromise");
|
|
var e=a.url.startsWith("http",0)||a.url.startsWith("https",0)?a.url:b.config().APP_ROOT+a.url;$.when($.ajax({dataType:a.type,url:e,method:a.method,async:a.async,data:a.data,cache:a.cache,processData:a.processData,contentType:a.contentType,timeout:a.timeout})).done(c)},history:e}};
|