This repository has been archived by the owner on Sep 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrotten.min.js
1 lines (1 loc) · 7.88 KB
/
rotten.min.js
1
function rt(e){"use strict";const t={el:document.querySelectorAll(e),attr:(e,l)=>{if(null==e){let e=[];return t.el.forEach(t=>e.push(t.attributes)),e}if(null==l)return t.el[0].getAttribute(e);t.el.forEach(t=>t.setAttribute(e,l))},mulAttr:e=>t.el.forEach(t=>e.forEach(e=>t.setAttribute(e[0],e[1]))),mulProp:e=>e.forEach(e=>t.el[0].setAttribute(e[0],e[1])),prop:(e,l)=>null==e?t.el[0].attributes:null==l?t.el[0].getAttribute(e):void t.el[0].setAttribute(e,l),mount:(e,l)=>{if(null!=e){let r=document.querySelector(e);r.innerHTML="back"===l?t.el[0].outerHTML+r.innerHTML:r.innerHTML+t.el[0].outerHTML}},removeAttr:e=>t.el.forEach(t=>t.removeAttribute(e)),removeProp:e=>t.el[0].removeAttribute(e),css:(e,l)=>{t.el.forEach(t=>{null===t.getAttribute("style")&&t.setAttribute("style","");let r=`;${t.getAttribute("style")};${e}:${l}`;t.setAttribute("style",r)})},mulCSS:e=>{t.el.forEach(t=>e.forEach(e=>{null===t.getAttribute("style")&&t.setAttribute("style","");let l=`;${t.getAttribute("style")};${e[0]}:${e[1]}`;t.setAttribute("style",l)}))},style:e=>{if(null==e)return t.el[0].getAttribute("style");t.el.forEach(t=>t.setAttribute("style",e))},hide:(e,l)=>{e=e||0,setTimeout(()=>{t.el.forEach(e=>e.style.display="none"),"function"==typeof l&&l()},e)},show:(e,l)=>{e=e||0,setTimeout(()=>{t.el.forEach(e=>e.style.display=""),"function"==typeof l&&l()},e)},fadeOut:(e,l)=>{null==e&&(e=0),t.el.forEach(t=>{t.style.opacity="0",t.style.transition=`opacity ${e}ms`}),setTimeout(l,e)},fadeIn:(e,l)=>{null==e&&(e=0),t.el.forEach(t=>{t.style.opacity="1",t.style.transition=`opacity ${e}ms`}),setTimeout(l,e)},text:e=>{if(null==e)return t.el[0].innerText;t.el.forEach(t=>t.innerText=e)},html:e=>{if(null==e)return t.el[0].innerHTML;t.el.forEach(t=>t.innerHTML=e)},body:e=>{if(null==e)return t.el[0].outerHTML;t.el.forEach(t=>t.outerHTML=e)},on:(e,l)=>t.el.forEach(t=>t.addEventListener(e,l)),off:(e,l)=>t.el.forEach(t=>t.removeEventListener(e,l)),append:e=>t.el.forEach(t=>t.innerHTML=`${t.innerHTML}${e}`),prepend:e=>t.el.forEach(t=>t.innerHTML=`${e}${t.innerHTML}`),remove:()=>t.el.forEach(e=>e.remove()),empty:()=>t.el.forEach(e=>e.innerHTML=""),input:(e,l,r)=>{let n=!1;if(null==e&&null==l&&null==r)return t.el[0].value;if("string"==typeof e)e===t.el[0].value?l():r();else if(Array.isArray(e)){for(i=0;i<e.length;i++)if(e[i]==t.el[0].value){n=!0,l();break}n||r()}},inputs:(e,l)=>{let r=!1;for(let l=0;l<e.length;l++)if("string"==typeof e[l].value)t.el[0].value===e[l].value&&(e[l].callback(),r=!0);else if(Array.isArray(e[l].value))for(let n=0;n<value.length;n++)if(e[l].value[n]===t.el[0].value){r=!0,e[l].callback();break}r||"function"!=typeof l||l()},val:e=>{if(null==e)return t.el[0].value;t.el[0].value=e},check:(e,l)=>{if("function"!=typeof e||"function"!=typeof l)return t.el[0].checked;t.el[0].checked?e():l()},click:e=>"function"==typeof e&&t.el.forEach(t=>t.onclick=(()=>e())),hover:(e,l)=>{null!=e&&void 0!==l&&null!==e&&t.el.forEach(t=>{t.onmouseleave=(()=>e()),t.onmouseenter=(()=>l())})},title:e=>{if("undefined"==typeof title||null===title)return t.el[0].title;t.el.forEach(t=>t.title=e)},scroll:()=>t.el[0].scrollIntoView({behavior:"smooth"}),newEl:(e,l,r,n)=>{if(null==r&&(r="front"),null!=e&&"undefined"!==l&&null!==l){let o=document.createElement(e);o.innerHTML=l,n.forEach(e=>o.setAttribute(e[0],e[1])),"front"===r?t.el.forEach(e=>e.append(o)):"back"===r&&t.el.forEach(e=>e.prepend(o))}},appendEl:(e,l)=>{l&&t.el.forEach(e=>e.innerHTML=""),t.el.forEach(t=>t.append(e))},disableEl:e=>t.el.forEach(t=>t.removeChild(e)),prependEl:e=>t.el.forEach(t=>t.prepend(e)),sameEl:e=>t.el[0].outerHTML===e.outerHTML,addClass:e=>t.el.forEach(t=>t.classList.add(e)),removeClass:e=>t.el.forEach(t=>t.classList.remove(e)),hasClass:e=>t.el[0].classList.contains(e),toggleClass:e=>t.el.forEach(t=>t.classList.toggle(e)),rotate:(e,l)=>{null==e&&(e=1);let r=e,n=0,o=1;l.loop?(void 0!==l.delay&&null!==l.delay||(l.delay=1),t.rot=setInterval(()=>{r>=1?n>=360&&(n=0,o++):n<=-360&&(n=0,o++),t.el[0].style.transform=`rotate(${n}deg)`,n+=r,o===l.count&&l.end&&clearInterval(t.rot)},l.delay)):t.el[0].style.transform=`rotate(${r}deg)`},tclick:e=>!(null==e)&&t.el.forEach(t=>t.ondblclick=e),parent:()=>t.el[0].parentNode,child:()=>t.el[0].children,first:()=>t.el[0],typing:e=>{let l=0,r=e.str,n=e.speed;if(e.clrPrev&&(t.el[0].innerHTML=""),e.loop){void 0!==e.delay&&null!==e.delay||(e.delay=1e3);let o=()=>{l<r.length&&(t.el[0].innerHTML+=r.charAt(l),l++,setTimeout(o,n))};o(),setInterval(()=>{l=0,t.el[0].innerHTML="",o()},n*r.length+e.delay)}else{let e=()=>{l<r.length&&(t.el[0].innerHTML+=r.charAt(l),l++,setTimeout(e,n))};e()}},siblings:()=>Array.prototype.filter.call(t.el[0].parentNode.children,e=>e!==t.el[0]),switch:e=>{let l,r;t.el.forEach(t=>{r=document.querySelector(e),l=t.outerHTML,t.outerHTML=r.outerHTML,r.outerHTML=l})},is:e=>t.el[0].outerHTML===e,same:e=>t.el[0].innerHTML===e,next:()=>t.el[0].nextElementSibling,prev:()=>t.el[0].previousElementSibling};return t}const rdom={el:(e,t,l)=>(nel=document.createElement(e),null!=t&&("string"==typeof t?nel.innerHTML=t:Array.isArray(t)&&t.forEach(e=>nel.append(e))),void 0!==typeof l&&null!==l&&l.forEach(e=>nel.setAttribute(e[0],e[1])),nel),render:(e,t,l,r)=>{r&&(t.innerHTML=""),null==l&&(l="front"),"front"===l?t.append(e):"back"===l&&t.prepend(e)},remove:(e,t)=>t.removeChild(e),attr:(e,t)=>t.forEach(t=>e.setAttribute(t[0],t[1])),style:(e,t)=>e.setAttribute("style",t),css:(e,t)=>{t.forEach(t=>{null===e.getAttribute("style")&&e.setAttribute("style","");let l=`${e.getAttribute("style")};${t[0]}:${t[1]}`;e.setAttribute("style",l)})},contains:(e,t)=>e!==t&&e.contains(t),on:(e,t,l)=>e.addEventListener(t,l),off:(e,t,l)=>e.removeEventListener(t,l)},rUI={setBGVideo:e=>{let t=document.querySelector("body");if(t.innerHTML='<video style="position:fixed; right:0; top:0; min-width:100%; min-height:100%; width:auto; height:auto; z-index:-1" autoplay loop class="baceo-vid" muted plays-inline><source src='+e.path+" type=video/"+e.type+"></video>"+t.innerHTML,void 0!==e.style&&null!==e.style){let t=document.querySelector(".baceo-vid").style;t+=e.style}},setBGImage:e=>{let t=document.querySelector("body");t.innerHTML=`<img style="position:fixed; right:0; top:0; min-width:100%; min-height:100%; width:auto; height:auto; z-index:-1" src="${e}"></img> ${t.innerHTML}`},setLoadBar:e=>{let t={};null!=e&&(t=e);let l=document.querySelector("body");l.innerHTML="<div class='processjs'></div>"+l.innerHTML;let r=document.querySelector(".processjs");void 0!==t.position&&null!==t.position||(t.position="absolute"),void 0!==t.size&&null!==t.size||(t.size="5px"),void 0!==t.color&&null!==t.color||(t.color="red"),r.style=`position: absolute;left:0;right:0;top:0;height:${t.size};background-color:${t.color}`,void 0!==t.speed&&null!==t.speed||(t.speed=3);let n=0,o=setInterval(()=>{n++,r.style.width=n+"%",101===n&&(clearInterval(o),r.outerHTML="")},t.speed)}},rDev={mobile:e=>(navigator.userAgent.match(/Android/i)||navigator.userAgent.match(/webOS/i)||navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/iPod/i)||navigator.userAgent.match(/BlackBerry/i)||navigator.userAgent.match(/Windows Phone/i))&&(void 0!==e||null!==e)&&e(),windows:e=>~navigator.appVersion.indexOf("Win")&&"function"==typeof e&&e(),mac:e=>~navigator.appVersion.indexOf("Mac")&&"function"==typeof e&&e(),linux:e=>~navigator.appVersion.indexOf("Linux")&&"function"==typeof e&&e(),unix:e=>~navigator.appVersion.indexOf("X11")&&"function"==typeof e&&e(),os:(e,t)=>~navigator.appVersion.indexOf(e)&&"function"==typeof t&&t(),current:()=>navigator.appVersion},rUtils={isArray:e=>Array.isArray(e),inArray:(e,t)=>t.indexOf(e),parseJSON:e=>JSON.parse(e),parseHTML:e=>{let t=document.implementation.createHTMLDocument();return t.body.innerHTML=e,t.body.children},isEmptyObject:e=>0===Object.keys(e).length,isOdd:e=>e%2!=0,now:()=>Date.now()};"object"==typeof module&&"object"==typeof module.exports&&(module.exports.rt=rt,module.exports.rDev=rDev,module.exports.rUI=rUI,module.exports.rdom=rdom,module.exports.rUtils=rUtils);