1 line
3.8 KiB
JavaScript
1 line
3.8 KiB
JavaScript
(()=>{"use strict";class e{getCookie(e){const t=e+"=",n=decodeURIComponent(document.cookie).split(";");for(let e=0;e<n.length;e++){let o=n[e];for(;" "===o.charAt(0);)o=o.substring(1);if(0===o.indexOf(t))return o.substring(t.length,o.length)}return""}setCookie(e,t,n){const o=new Date;o.setTime(o.getTime()+24*n*60*60*1e3),document.cookie=e+"="+encodeURIComponent(t)+";expires="+o.toUTCString()+";path=/;secure"}removeCookie(e){document.cookie=e+"=;Max-Age=-99999999;"}}class t{AlertShow(e){const t=document.getElementById("notification-container");if(!t)return;const o=document.createElement("div");switch(o.classList.add("notification"),e.type){case n.Error:o.classList.add("error_alert_animate");break;case n.Ok:o.classList.add("ok_alert_animate");break;case n.Warning:o.classList.add("warning_alert_animate")}o.textContent=e.text,t.appendChild(o),o.classList.add("puff-in-center"),setTimeout((()=>{o.remove()}),1e3*e.duration)}}var n;!function(e){e.Error="error",e.Warning="warning",e.Ok="ok"}(n||(n={}));var o=function(e,t,n,o){return new(n||(n=Promise))((function(r,a){function i(e){try{s(o.next(e))}catch(e){a(e)}}function c(e){try{s(o.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,c)}s((o=o.apply(e,t||[])).next())}))};class r{constructor(){this.Alerts=new t}isEmpty(e){return null==e||""===e}setInputWarning(e){e.classList.add("warning_input");const t=setTimeout((()=>{e.classList.remove("warning_input"),clearTimeout(t)}),3e3)}setAreaWarning(e){e.classList.add("warning_area");const t=setTimeout((()=>{e.classList.remove("warning_area"),clearTimeout(t)}),3e3)}isValidEmail(e){if(this.isEmpty(e))return!1;return/^([a-z0-9_.-])+@[a-z0-9-]+\.([a-z]{2,4}\.)?[a-z]{2,4}$/i.test(e)}doDelay(e){return o(this,void 0,void 0,(function*(){return new Promise((t=>{setTimeout((()=>{t(null)}),e)}))}))}get getWidh(){return window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth}get getHeight(){return window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight}getRandomInt(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e}copyValueToBuffer(e,t){try{const n=t.getBoundingClientRect(),o=window.pageYOffset||document.documentElement.scrollTop,r=navigator.userAgent.match(/ipad|iphone/i),a=document.createElement("textarea");if(a.readOnly=!0,a.style.top=`${Math.round(o+n.top)}px`,a.classList.add("text_copy"),a.value=e,document.body.appendChild(a),a.focus(),r){const e=a.contentEditable,t=a.readOnly;a.contentEditable="true",a.readOnly=!1;const n=document.createRange();n.selectNodeContents(a);const o=window.getSelection();o.removeAllRanges(),o.addRange(n),a.setSelectionRange(0,999999),a.contentEditable=e,a.readOnly=t}else a.select();const i=document.execCommand("copy");return document.body.removeChild(a),i}catch(e){return console.error("Error: ",e),!1}}getCurrentDate(){const e=new Date,t=e.getDate(),n=e.getMonth()+1;let o="";t<10&&(o="0");let r="";return n<10&&(r="0"),`${o}${t}.${r}${n}.${e.getFullYear()}`}stringToBoolean(e){const t=e.toLowerCase();return"true"===t||"false"!==t&&null}generateUuid(){var e=(new Date).getTime(),t="undefined"!=typeof performance&&performance.now&&1e3*performance.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(n=>{var o=16*Math.random();return e>0?(o=(e+o)%16|0,e=Math.floor(e/16)):(o=(t+o)%16|0,t=Math.floor(t/16)),("x"===n?o:3&o|8).toString(16)}))}}var a=function(e,t,n,o){return new(n||(n=Promise))((function(r,a){function i(e){try{s(o.next(e))}catch(e){a(e)}}function c(e){try{s(o.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,c)}s((o=o.apply(e,t||[])).next())}))};window.addEventListener("load",(()=>a(void 0,void 0,void 0,(function*(){new r,new e,new URL(document.location.href).pathname.toLowerCase().split("/")[1]}))))})(); |