You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
35 KiB

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.shuffle=e()}(this,function(){"use strict";function t(t,e){if(A)return A.call(t,e);for(var i=t.parentNode.querySelectorAll(e),n=0;n<i.length;n++)if(i[n]==t)return!0;return!1}function e(){for(var t={},e=0;e<arguments.length;e++){var i=arguments[e];for(var n in i)C.call(i,n)&&(t[n]=i[n])}return t}function i(t,e){function i(){o=0,a=+new Date,s=t.apply(n,r),n=null,r=null}var n,r,s,o,a=0;return function(){n=this,r=arguments;var t=new Date-a;return o||(t>=e?i():o=setTimeout(i,e-t)),s}}function n(){}function r(t){return parseFloat(t)||0}function s(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:window.getComputedStyle(t,null),n=r(i[e]);return O||"width"!==e?O||"height"!==e||(n+=r(i.paddingTop)+r(i.paddingBottom)+r(i.borderTopWidth)+r(i.borderBottomWidth)):n+=r(i.paddingLeft)+r(i.paddingRight)+r(i.borderLeftWidth)+r(i.borderRightWidth),n}function o(t){for(var e=t.length;e;){e-=1;var i=Math.floor(Math.random()*(e+1)),n=t[i];t[i]=t[e],t[e]=n}return t}function a(t,e){var i=x(W,e),n=[].slice.call(t),r=!1;return t.length?i.randomize?o(t):("function"==typeof i.by&&t.sort(function(t,e){if(r)return 0;var n=i.by(t[i.key]),s=i.by(e[i.key]);return void 0===n&&void 0===s?(r=!0,0):n<s||"sortFirst"===n||"sortLast"===s?-1:n>s||"sortLast"===n||"sortFirst"===s?1:0}),r?n:(i.reverse&&t.reverse(),t)):[]}function l(){return V+=1,P+V}function u(t){return!!q[t]&&(q[t].element.removeEventListener(P,q[t].listener),q[t]=null,!0)}function h(t,e){var i=l(),n=function(t){t.currentTarget===t.target&&(u(i),e(t))};return t.addEventListener(P,n),q[i]={element:t,listener:n},i}function f(t){return Math.max.apply(Math,t)}function c(t){return Math.min.apply(Math,t)}function d(t,e,i,n){var r=t/e;return Math.abs(Math.round(r)-r)<n&&(r=Math.round(r)),Math.min(Math.ceil(r),i)}function g(t,e,i){if(1===e)return t;for(var n=[],r=0;r<=i-e;r++)n.push(f(t.slice(r,r+e)));return n}function m(t,e){for(var i=c(t),n=0,r=t.length;n<r;n++)if(t[n]>=i-e&&t[n]<=i+e)return n;return 0}function p(t){for(var e=t.itemSize,i=t.positions,n=t.gridSize,r=t.total,s=t.threshold,o=t.buffer,a=d(e.width,n,r,s),l=g(i,a,r),u=m(l,o),h=new D(Math.round(n*u),Math.round(l[u])),f=l[u]+e.height,c=0;c<a;c++)i[u+c]=f;return h}function v(t){return Array.prototype.slice.call(t)}function b(t,e){return t.indexOf(e)>-1}try{var y=new window.CustomEvent("test");if(y.preventDefault(),!0!==y.defaultPrevented)throw new Error("Could not prevent default")}catch(t){var _=function(t,e){var i,n;return e=e||{bubbles:!1,cancelable:!1,detail:void 0},i=document.createEvent("CustomEvent"),i.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),n=i.preventDefault,i.preventDefault=function(){n.call(this);try{Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}})}catch(t){this.defaultPrevented=!0}},i};_.prototype=window.Event.prototype,window.CustomEvent=_}var S=Element.prototype,A=S.matches||S.matchesSelector||S.webkitMatchesSelector||S.mozMatchesSelector||S.msMatchesSelector||S.oMatchesSelector,k=t,E="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},w=function(t,e){return e={exports:{}},t(e,e.exports),e.exports}(function(t){function e(t){for(var e=[],i=0;i<t.length;i++)-1===e.indexOf(t[i])&&e.push(t[i]);return e}function i(t){var e=new Set;return t.filter(function(t){return!e.has(t)&&(e.add(t),!0)})}function n(t){var e=[];return new Set(t).forEach(function(t){e.push(t)}),e}"Set"in E?"function"==typeof Set.prototype.forEach&&function(){var t=!1;return new Set([!0]).forEach(function(e){t=e}),!0===t}()?t.exports=n:t.exports=i:t.exports=e}),x=e,C=Object.prototype.hasOwnProperty,I=i,T=function(t,e,i){function r(t){return function(e,n){if(!o){if(e)return i(e,a),void(o=!0);a[t]=n,--s||i(null,a)}}}i||("function"==typeof e?(i=e,e=null):i=n);var s=t&&t.length;if(!s)return i(null,[]);var o=!1,a=new Array(s);t.forEach(e?function(t,i){t.call(e,r(i))}:function(t,e){t(r(e))})},F=function(t,e){if(!(t instanceof e))throw new Ty
}):window.tinycolor=e}(Math),String.prototype.hashCode=function(){var t=5381;for(i=0;i<this.length;i++)char=this.charCodeAt(i),t=(t<<5)+t+char;return t>>>0};var Color=tinycolor,Shuffle=window.shuffle,shuffle=new Shuffle(document.querySelector(".tile-container"),{group:shuffle.ALL_ITEMS,itemSelector:".tile",gutterWidth:16,columnWidth:188,buffer:1,delimeter:",",useTransforms:!1}),filterTiles=function(t){shuffle.filter(location.hash.slice(1))};window.onhashchange=filterTiles;var getUrlParts=function(t){var e={domain:"",before:"",after:""},i=new URL(t),n=i.host;if(e.domain=n.replace(/^www\./i,""),n.match(/^\d+\.\d+\.\d+\.\d+$/))return e.domain=n,e;if(n.match(/^(\d+\.\d+\.\d+\.\d+)(:(\d+))?$/))return r=n.match(/^(\d+\.\d+\.\d+\.\d+)(:(\d+))?$/),e.domain=r[1],e.after=r[3],e;for(var r=e.domain.split("."),s=0,o=1;o<r.length-1;o++)r[o].length>r[s].length&&(s=o);return e.domain=r[s],e.before=r.slice(0,s).join("."),e.after=r.slice(s+1).join("."),!e.domain&&i.pathname&&(e.domain=i.pathname.split("/").filter(Boolean).pop()),e},fitText=function(t,e,i){var n=document.createElement("div");n.style.visibility="hidden",n.style.position="absolute",document.body.appendChild(n);var r=40;for(n.innerHTML=t,n.style.fontSize=r;n.offsetWidth>e;)r-=1,n.style.fontSize=r;var s={size:r,width:n.offsetWidth,height:n.offsetHeight};return n.remove(),s},getTileColor=function(t){var e=["#B42424","#C83D1D","#BB7231","#E06B00","#55931F","#1C941B","#189365","#189196","#2D85A4","#2B6C90","#205396","#39448F","#55338E","#683089","#963A97","#A43343","#982F2F","#D30000","#E54C29","#DA7E2C","#73B43A","#3AB43A","#3AB487","#3AB0B4","#47A6C7","#3A88B4","#3A6FB4","#3A4AB4","#673AB4","#863AB4","#C846C9","#C44A5B","#AA4444","#E84545","#FF6946","#EC9344","#3CA4DF","#3A83E3","#4056E3","#9058F0","#B467E2","#DF7CDF","#E5576B","#D35A5A","#3DC53D","#2DBBB1","#5E95D5","#5E5BE7","#1B7EFF","#5F74FF","#8A45FF","#B856F3","#DD66DD"];return e[t.hashCode()%e.length]},renderImgTile=function(t){t.innerHTML="";var e=t.getAttribute("data-bg-color");e||(e="rgba(255,255,255,.8)"),e=Color(e),e.setAlpha(.8),t.style.backgroundColor=e;var i=new Image;i.src=t.getAttribute("data-img"),i.className="logo",t.appendChild(i)},renderPlainTile=function(t){var e=getUrlParts(t.getAttribute("data-url"));t.innerHTML="";var i=t.getAttribute("data-bg-color");i||(i="rgba(255,255,255,.8)"),i=Color(i),i.setAlpha(.8),t.style.backgroundColor=i;var n=t.getAttribute("data-txt-color");n||(n=getTileColor(e.domain),i.isDark()&&(t.style.color="white")),n=Color(n),t.style.color=n;var r=fitText(e.domain,172,120),s=document.createElement("div");s.style.fontSize=r.size,s.style.position="absolute",t.appendChild(s);var o=document.createElement("div");o.innerHTML=e.before,o.style.top=.35*r.size-10,o.className="pre-domain",o.style.textShadow="-1px 0 "+i+",0 1px "+i+",1px 0 "+i+",0 -1px "+i;var a=document.createElement("div");a.innerHTML=e.after,a.style.top=r.size-.05*r.size,a.className="post-domain",a.style.textShadow="-1px 0 "+i+",0 1px "+i+",1px 0 "+i+",0 -1px "+i,s.appendChild(o),s.append(e.domain),s.appendChild(a);var l=64-s.clientHeight/2,u=106-s.clientWidth/2;s.style.top=l,s.style.left=u},renderTiles=function(){for(var t=document.getElementsByClassName("tile-box"),e=0;e<t.length;e++)try{t.item(e).getAttribute("data-img")?renderImgTile(t.item(e)):renderPlainTile(t.item(e))}catch(t){console.log("err:"+t)}};renderTiles();var getBackgroundImages=function(){var t=document.getElementsByTagName("body"),e=[],i=t[0].getAttribute("data-backgrounds");return i&&(e=i.split(/[\s,]+/).filter(Boolean)),e},preloadBackgrounds=function(){for(var t=getBackgroundImages(),e=0;e<t.length;e++)(new Image).src=t[e]},rotateBackground=function(t){void 0!==t&&null!==t||(t=0);var e=getBackgroundImages();e.length>0&&(t=(t+1)%e.length,document.body.style.background='url("'+e[t]+'")',document.body.style.backgroundSize="cover",e.length>1&&setTimeout(rotateBackground.bind(null,t),3e4))};preloadBackgrounds(),rotateBackground();