2021-04-23 18:58:51 -04:00
|
|
|
function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable;}));}ownKeys.forEach(function(key){_defineProperty(target,key,source[key]);});}return target;}if('serviceWorker' in navigator)navigator.serviceWorker.register('/sw.js').then(function(reg){console.log('Service worker registered',reg.scope);})["catch"](function(error){console.error('Failed to register service worker',error);});var matches=function(elm,selector){var m=(elm.document||elm.ownerDocument).querySelectorAll(selector);var i=matches.length;while((--i)>=0&&m.item(i)!==elm);return i>-1;};var AnimeClient={noop:function(){},$:function(selector,param){var context=param=== void 0?null:param;if(typeof selector!=='string')return selector;context=context!==null&&context.nodeType===1?context:document;var elements=[];if(selector.match(/^#([\w]+$)/))elements.push(document.getElementById(selector.split('#')[1]));else elements=[].slice.apply(context.querySelectorAll(selector));return elements;},hasElement:function(selector){return AnimeClient["$"](selector).length>0;},scrollToTop:function(){var el=AnimeClient["$"]('header')[0];el.scrollIntoView(true);},hide:function(sel){if(typeof sel==='string')sel=AnimeClient["$"](sel);if(Array.isArray(sel))sel.forEach(function(el){return el.setAttribute('hidden','hidden');});else sel.setAttribute('hidden','hidden');},show:function(sel){if(typeof sel==='string')sel=AnimeClient["$"](sel);if(Array.isArray(sel))sel.forEach(function(el){return el.removeAttribute('hidden');});else sel.removeAttribute('hidden');},showMessage:function(type,message){var template="<div class='message ".concat(type,"'>\n\t\t\t\t<span class='icon'></span>\n\t\t\t\t").concat(message,"\n\t\t\t\t<span class='close'></span>\n\t\t\t</div>");var sel=AnimeClient["$"]('.message');if(sel[0]!==undefined)sel[0].remove();AnimeClient["$"]('header')[0].insertAdjacentHTML('beforeend',template);},closestParent:function(current,parentSelector){if(Element.prototype.closest!==undefined)return current.closest(parentSelector);while(current!==document.documentElement){if(matches(current,parentSelector))return current;current=current.parentElement;}return null;},url:function(path){var uri="//".concat(document.location.host);uri+=path.charAt(0)==='/'?path:"/".concat(path);return uri;},throttle:function(interval,fn,scope){var wait=false;return function(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}var context=scope||this;if(!wait){fn.apply(context,args);wait=true;setTimeout(function(){wait=false;},interval);}};}};function addEvent(sel,event,listener){if(!event.match(/^([\w\-]+)$/))event.split(' ').forEach(function(evt){addEvent(sel,evt,listener);});sel.addEventListener(event,listener,false);}function delegateEvent(sel,target,event,listener){addEvent(sel,event,function(e){AnimeClient["$"](target,sel).forEach(function(element){if(e.target==element){listener.call(element,e);e.stopPropagation();}});});}AnimeClient.on=function(sel,event,target,listener){if(listener===undefined){listener=target;AnimeClient["$"](sel).forEach(function(el){addEvent(el,event,listener);});}else AnimeClient["$"](sel).forEach(function(el){delegateEvent(el,target,event,listener);});};function ajaxSerialize(data){var pairs=[];Object.keys(data).forEach(function(name){var value=data[name].toString();name=encodeURIComponent(name);value=encodeURIComponent(value);pairs.push("".concat(name,"=").concat(value));});return pairs.join('&');}AnimeClient.ajax=function(url,config){var defaultConfig={data:{},type:'GET',dataType:'',success:AnimeClient.noop,mimeType:'application/x-www-form-urlencoded',error:AnimeClient.n
|