forked from HubSpot/signet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
signet.min.js
2 lines (2 loc) · 2.86 KB
/
signet.min.js
1
2
/*! signet.js 0.2.1 */
(function(){var a,b,c,d,e,f,g;return e=function(a){return a.title=f(a.title,d('meta[name="application-name"]'),d('meta[property="og:title"]'),document.title.split(/\u0020[\/\\\|\-\u8211\u8212]\u0020|\:\u0020/)[0],""),a.author=f(a.author,d("meta[name=author]"),""),a.description=f(a.description,d("meta[name=description]"),d('meta[property="og:description"]'),""),a.image=f(a.image,d('meta[property="og:image"]'),d("meta[name=image]")),a.hue=a.hue||0,a.baseStyles=f(a.baseStyles,'color: #444; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;'),a.titleStyles=f(a.titleStyles,""+a.baseStyles+"; font-size: 20px; line-height: 30px;"),a.authorStyles=f(a.authorStyles,""+a.baseStyles+"; font-size: 12px; line-height: 30px; padding-left: 20px;"),a.descriptionStyles=f(a.descriptionStyles,""+a.baseStyles+"; font-size: 14px; line-height: 20px;"),a},f=function(){var a,b,c;for(b=0,c=arguments.length;c>b;b++)if(a=arguments[b],"undefined"!=typeof a)return a;return arguments[arguments.length-1]},d=function(a){var b;return null!=(b=document.head.querySelector(a))?b.content:void 0},b=function(a){var b,c,d,e,f,g,h,i,j;for(g=["log","debug","warn","error"],e={},b={},d=[],c=g.length,h=function(a){return e[a]=console[a],b[a]=function(){return e[a].apply(console,arguments)},console[a]=function(){return d.push([a,arguments])}},c=i=0,j=g.length;j>i;c=++i)f=g[c],h(f);return setTimeout(function(){var h;return h=function(){for(var a,b,h;d.length;)a=d.shift(),f=a[0],b=a[1],e[f].apply(console,b);for(c=g.length,h=[];c--;)h.push(console[f]=e[f]);return h},a(b,h)},0)},c=function(a,b,c){var d,f;return f=function(){var d,e,f;if(a.title){if(!a.image){for(d=[""],f=0;f<a.title.length;)d[0]+="%c"+a.title[f]," "===a.title[f]?d.push(a.titleStyles):(e=(2*a.title[f].toLowerCase().charCodeAt(0)+a.hue)%255,d.push(""+a.titleStyles+"; background: hsl("+e+", 80%, 80%); color: transparent; line-height: 0;")),f++;b.log.apply(console,d)}a.author?b.log("%c"+a.title+"%c"+a.author,a.titleStyles,a.authorStyles):b.log("%c"+a.title,a.titleStyles)}return a.description&&b.log("%c"+a.description,a.descriptionStyles),c?c():void 0},b=b||window.console,a=a||window.signet.options||{enabled:!0},a.enabled!==!1?(a=e(a),a.image?(d=new Image,d.onload=function(){return b.log("%c ","font-size: 0; line-height: "+d.height+"px; padding: "+Math.floor(d.height/2)+"px "+d.width+"px "+Math.ceil(d.height/2)+'px 0; background-image: url("'+d.src+'");'),f()},d.src=a.image):f()):void 0},window.signet=window.signet||{},window.signet.options=window.signet.options||window.signetOptions||{},window.console&&window.console.log&&document.head&&document.querySelector?(a=!0,g=document.querySelector("[data-signet-draw]"),g&&(a="false"!==g.getAttribute("data-signet-draw").toLowerCase()),signet.options.draw===!1&&(a=!1),a&&b(function(a,b){return c(null,a,b)}),window.signet.draw=c,void 0):(window.signet.draw=function(){},void 0)}).call(this);