This commit is contained in:
2023-05-05 17:05:23 +08:00
parent d831a707ae
commit e728c66786
25 changed files with 150 additions and 144 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
(function(i,c){typeof exports=="object"&&typeof module<"u"?c(exports):typeof define=="function"&&define.amd?define(["exports"],c):(i=typeof globalThis<"u"?globalThis:i||self,c(i["lib-utility"]={}))})(this,function(i){"use strict";function c(e,t,n){if(e==null)return;let r=`; domain=${location.host}; path=/`;if(n!=null){const l=new Date;l.setTime(l.getTime()+n*24*60*60*1e3),r+=`; expires=${l.toGMTString()}`}/^(https|wss):$/.test(location.protocol)&&(r+="; secure"),document.cookie=`${e}=${encodeURIComponent(t)}${r}`}function f(e){if(e==null)return null;e+="=";const t=document.cookie.split(";");for(let n of t)if(n=n.trim(),n.indexOf(e)===0)return decodeURIComponent(n.substring(e.length));return null}function $(e){c(e,"",-1)}function d(e){return/^(https?|wss?|ftp):/.test(e)||typeof consts>"u"?e:(consts.path||"")+e}function w(e,t={}){return fetch(d(e),{method:t.method||"GET",headers:{...t.customerHeaders,Accept:t.accept||"application/json"},signal:t.signal,cache:"default"})}function A(e,t,n={}){return t instanceof FormData||(typeof t!="string"&&(t=JSON.stringify(t)),n.customerHeaders==null&&(n.customerHeaders={}),n.customerHeaders["Content-Type"]==null&&(n.customerHeaders["Content-Type"]="application/json")),fetch(d(e),{method:n.method||"POST",headers:n.customerHeaders,body:t,signal:n.signal,cache:"no-cache"})}function O(e,t,n={}){return new Promise((r,l)=>{const a=new XMLHttpRequest;if(a.onreadystatechange=function(){this.readyState===XMLHttpRequest.DONE&&(this.status===200?r(this):l(`${this.status} ${this.statusText}: ${this.responseText}`))},typeof n.progress=="function"&&a.upload.addEventListener("progress",function(u){u.lengthComputable&&n.progress.call(this,u)},!1),a.open("POST",d(e)),n.customerHeaders!=null)for(let u of Object.entries(n.customerHeaders))a.setRequestHeader(u[0],u[1]);a.send(t)})}function o(e){return e==null||typeof e!="string"||e.length===0}function C(e,t,n){return o(e)||t==null?!1:(typeof t!="string"&&(t=String(t)),n?e.toLowerCase().indexOf(t.toLowerCase())>=0:e.indexOf(t)>=0)}function L(e,t){return o(e)||o(t)?!1:e.indexOf(t)===e.length-t.length}function N(e,t,n){return o(e)||isNaN(t)||t<=e.length?e:(n??" ").repeat(t-e.length)}function H(e){const t=/(http|ftp|https):\/\/.+?(\s|\r\n|\r|\n|\"|\'|\*|$)/g,n=e.match(t);if(e=m(e),(n==null?void 0:n.length)>0){const r=[];for(let l of n)l=l.replace(/["'\r\n ]/g,""),r.indexOf(l)<0&&r.push(l);for(let l of r)e=e.replaceAll(l,'<a target="_blank" href="'+l+'"><svg><use xlink:href="'+(typeof consts<"u"&&consts.path||"")+'fonts/fa-regular.svg#link"></use></svg></a>')}return e}function m(e){return e==null?"":String(e).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll(`\r
(function(i,c){typeof exports=="object"&&typeof module<"u"?c(exports):typeof define=="function"&&define.amd?define(["exports"],c):(i=typeof globalThis<"u"?globalThis:i||self,c(i["lib-utility"]={}))})(this,function(i){"use strict";function c(e,t,n){if(e==null)return;let r=`; domain=${location.host}; path=/`;if(n!=null){const l=new Date;l.setTime(l.getTime()+n*24*60*60*1e3),r+=`; expires=${l.toGMTString()}`}/^(https|wss):$/.test(location.protocol)&&(r+="; secure"),document.cookie=`${e}=${encodeURIComponent(t)}${r}`}function f(e){if(e==null)return null;e+="=";const t=document.cookie.split(";");for(let n of t)if(n=n.trim(),n.indexOf(e)===0)return decodeURIComponent(n.substring(e.length));return null}function k(e){c(e,"",-1)}function d(e){return/^(https?|wss?|ftp):/.test(e)||typeof consts>"u"?e:(consts.path||"")+e}function w(e,t={}){return fetch(d(e),{method:t.method||"GET",headers:{...t.customerHeaders,Accept:t.accept||"application/json"},signal:t.signal,cache:"default"})}function A(e,t,n={}){return t instanceof FormData||(typeof t!="string"&&(t=JSON.stringify(t)),n.customerHeaders==null&&(n.customerHeaders={}),n.customerHeaders["Content-Type"]==null&&(n.customerHeaders["Content-Type"]="application/json")),fetch(d(e),{method:n.method||"POST",headers:n.customerHeaders,body:t,signal:n.signal,cache:"no-cache"})}function O(e,t,n={}){return new Promise((r,l)=>{const a=new XMLHttpRequest;if(a.onreadystatechange=function(){this.readyState===XMLHttpRequest.DONE&&(this.status===200?r(this):l(`${this.status} ${this.statusText}: ${this.responseText}`))},typeof n.progress=="function"&&a.upload.addEventListener("progress",function(u){u.lengthComputable&&n.progress.call(this,u)},!1),a.open("POST",d(e)),n.customerHeaders!=null)for(let u of Object.entries(n.customerHeaders))a.setRequestHeader(u[0],u[1]);a.send(t)})}function o(e){return e==null||typeof e!="string"||e.length===0}function C(e,t,n){return o(e)||t==null?!1:(typeof t!="string"&&(t=String(t)),n?e.toLowerCase().indexOf(t.toLowerCase())>=0:e.indexOf(t)>=0)}function L(e,t){return o(e)||o(t)?!1:e.indexOf(t)===e.length-t.length}function N(e,t,n){return o(e)||isNaN(t)||t<=e.length?e:(n??" ").repeat(t-e.length)}function H(e){const t=/(http|ftp|https):\/\/.+?(\s|\r\n|\r|\n|\"|\'|\*|$)/g,n=e.match(t);if(e=m(e),(n==null?void 0:n.length)>0){const r=[];for(let l of n)l=l.replace(/["'\r\n ]/g,""),r.indexOf(l)<0&&r.push(l);for(let l of r)e=e.replaceAll(l,'<a target="_blank" href="'+l+'"><svg><use xlink:href="'+(typeof consts<"u"&&consts.path||"")+'fonts/fa-regular.svg#link"></use></svg></a>')}return e}function m(e){return e==null?"":String(e).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll(`\r
`,"<br/>").replaceAll(`
`,"<br/>").replaceAll(" ","&nbsp;")}let g;function h(){var n,r;let e;switch(typeof consts<"u"&&(e=f((n=consts.cookie)==null?void 0:n.lang),o(e)&&(e=(r=consts.user)==null?void 0:r.language)),o(e)&&(e=f("lgid")),o(e)&&(e=navigator.language||"en-us"),e=e.toLowerCase().replace(/-/g,"_"),o(e)&&(e="en"),e){case"en":case"en_au":case"fr":case"zh_cn":return e}const t=e.split("_")[0];switch(t){case"en":case"fr":return t}return"en"}function T(e){return typeof consts<"u"?(consts.prefix||"")+`res_${e}`:`res_${e}`}async function v(e=""){const t=h(),r=await(await w(`language/${t}${e}`)).json();return localStorage.setItem(T(t),JSON.stringify(r)),r}async function p(e,t){(t==null||typeof consts>"u")&&(t=await v(e));const n=Number(consts.resver);return(isNaN(t.ver)||isNaN(n)||n>t.ver)&&(console.log(`found new language res version: ${t.ver} => ${n}`),t=await v(e)),Object.defineProperty(t,"r",{writable:!1,configurable:!1,enumerable:!1,value:function(r,l){return s(this,r,l)}}),g=t,t}function s(e,t,n){return e[t]??n}function S(e,t){for(let n of e.querySelectorAll("[data-lgid]")){const r=n.dataset.lgid;n.tagName==="INPUT"?n.value=s(t,r,n.value):n.innerText=s(t,r,n.innerText)}for(let n of e.querySelectorAll("[data-title-lgid]")){const r=n.dataset.titleLgid;n.setAttribute("title",s(t,r,n.getAttribute("title")))}for(let n of e.querySelectorAll("[data-placeholder-lgid]")){const r=n.dataset.placeholderLgid;n.setAttribute("placeholder",s(t,r,n.getAttribute("placeholder")))}}async function P(e=document.body,t={}){const n=h();let r=localStorage.getItem(T(n)),l;if(r!=null)try{r=JSON.parse(r),l=await p(t.template,r)}catch(a){console.error("error while parsing lgres, try refresh ...",a),l=await p(t.template)}else l=await p(t.template);try{return document.readyState==="loading"?await new Promise((a,u)=>{let k=setTimeout(()=>u("timeout"),3e4);document.addEventListener("DOMContentLoaded",()=>{clearTimeout(k),k=void 0,typeof t.callback=="function"&&t.callback(l),S(e,l),a(l)})}):(typeof t.callback=="function"&&t.callback(l),S(e,l),l)}catch(a){console.error("error while loading language res ...",a)}}function y(e,t){return g!=null?s(g,e,t):t}const E={get current(){return h()},get unknownError(){return y("unknownError","An unknown error occurred, please contact the administrator.")},get savedSuccessfully(){return y("savedSuccessfully","Saved successfully.")}};let b=typeof globalThis<"u"?globalThis:self;function M(e){return!isNaN(e)&&e>0}function j(){return/mobile/i.test(navigator.userAgent)}function q(e,t=100,n=b,...r){if(e==null)return;e.tiid&&clearTimeout(e.tiid);const l=new Date;e.tdate==null||l-e.tdate>t?(e.apply(n,r),e.tdate=l):e.tiid=setTimeout(()=>e.apply(n,r),t)}function _(e,t=100,n=b,...r){e!=null&&(e.tiid&&clearTimeout(e.tiid),e.tiid=setTimeout(()=>e.apply(n,r),t))}function I(e){return(e>0?Math.floor:Math.ceil)(e)}function R(e){return/^\w[-\w.+]*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(e)}function U(e){return/^[1-9]\d{9,}$/.test(e)}i.contains=C,i.debounce=_,i.deleteCookie=$,i.endsWith=L,i.escapeHtml=m,i.formatUrl=H,i.get=w,i.getCookie=f,i.global=b,i.init=P,i.isEmail=R,i.isMobile=j,i.isPhone=U,i.isPositive=M,i.lang=E,i.nullOrEmpty=o,i.padStart=N,i.post=A,i.r=y,i.setCookie=c,i.throttle=q,i.truncate=I,i.upload=O,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
`,"<br/>").replaceAll(" ","&nbsp;")}let g;function h(){var n,r;let e;switch(typeof consts<"u"&&(e=f((n=consts.cookie)==null?void 0:n.lang),o(e)&&(e=(r=consts.user)==null?void 0:r.language)),o(e)&&(e=f("lgid")),o(e)&&(e=navigator.language||"en-us"),e=e.toLowerCase().replace(/-/g,"_"),o(e)&&(e="en"),e){case"en":case"en_au":case"fr":case"zh_cn":return e}const t=e.split("_")[0];switch(t){case"en":case"fr":return t}return"en"}function T(e){return typeof consts<"u"?(consts.prefix||"")+`res_${e}`:`res_${e}`}async function v(e=""){const t=h(),r=await(await w(`language/${t}${e}`)).json();return localStorage.setItem(T(t),JSON.stringify(r)),r}async function p(e,t){(t==null||typeof consts>"u")&&(t=await v(e));const n=Number(consts.resver);return(isNaN(t.ver)||isNaN(n)||n>t.ver)&&(console.log(`found new language res version: ${t.ver} => ${n}`),t=await v(e)),Object.defineProperty(t,"r",{writable:!1,configurable:!1,enumerable:!1,value:function(r,l){return s(this,r,l)}}),g=t,t}function s(e,t,n){return e[t]??n}function S(e,t){for(let n of e.querySelectorAll("[data-lgid]")){const r=n.dataset.lgid;n.tagName==="INPUT"?n.value=s(t,r,n.value):n.innerText=s(t,r,n.innerText)}for(let n of e.querySelectorAll("[data-title-lgid]")){const r=n.dataset.titleLgid;n.setAttribute("title",s(t,r,n.getAttribute("title")))}for(let n of e.querySelectorAll("[data-placeholder-lgid]")){const r=n.dataset.placeholderLgid;n.setAttribute("placeholder",s(t,r,n.getAttribute("placeholder")))}}async function E(e=document.body,t={}){const n=h();let r=localStorage.getItem(T(n)),l;if(r!=null)try{r=JSON.parse(r),l=await p(t.template,r)}catch(a){console.error("error while parsing lgres, try refresh ...",a),l=await p(t.template)}else l=await p(t.template);try{return document.readyState==="loading"?await new Promise((a,u)=>{let $=setTimeout(()=>u("timeout"),3e4);document.addEventListener("DOMContentLoaded",()=>{clearTimeout($),$=void 0,typeof t.callback=="function"&&t.callback(l),S(e,l),a(l)})}):(typeof t.callback=="function"&&t.callback(l),S(e,l),l)}catch(a){console.error("error while loading language res ...",a)}}function y(e,t){return g!=null?s(g,e,t):t}const P={get current(){return h()},get unknownError(){return y("unknownError","An unknown error occurred, please contact the administrator.")},get savedSuccessfully(){return y("savedSuccessfully","Saved successfully.")}};let b=typeof globalThis<"u"?globalThis:self;function M(e){return!isNaN(e)&&e>0}function j(){return/mobile/i.test(navigator.userAgent)}function q(e,t=100,n=b,...r){if(e==null)return;e.tiid&&clearTimeout(e.tiid);const l=new Date;e.tdate==null||l-e.tdate>t?(e.apply(n,r),e.tdate=l):e.tiid=setTimeout(()=>e.apply(n,r),t)}function R(e,t=100,n=b,...r){e!=null&&(e.tiid&&clearTimeout(e.tiid),e.tiid=setTimeout(()=>e.apply(n,r),t))}function _(e){return(e>0?Math.floor:Math.ceil)(e)}function I(e){return/^\w[-\w.+]*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(e)}function U(e){return!!(/^[1-9]\d{9,}$/.test(e)||/^\+?[1-9][\d-]{9,}\d$/.test(e)&&/^[1-9]\d{9,}$/.test(e.replace("+","").replace(new RegExp("-","g"),"")))}i.contains=C,i.debounce=R,i.deleteCookie=k,i.endsWith=L,i.escapeHtml=m,i.formatUrl=H,i.get=w,i.getCookie=f,i.global=b,i.init=E,i.isEmail=I,i.isMobile=j,i.isPhone=U,i.isPositive=M,i.lang=P,i.nullOrEmpty=o,i.padStart=N,i.post=A,i.r=y,i.setCookie=c,i.throttle=q,i.truncate=_,i.upload=O,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
//# sourceMappingURL=utility.min.js.map

File diff suppressed because one or more lines are too long