Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Do not write anything on favicon if label is not defined.

  • Loading branch information...
commit b3ecaf33bedf2038c5f98e1a7d244608de891073 1 parent 378a55b
Powder96 authored
Showing with 9 additions and 2 deletions.
  1. +2 −1  tinycon.js
  2. +7 −1 tinycon.min.js
3  tinycon.js
View
@@ -235,7 +235,8 @@
return this;
};
- Tinycon.setBubble = function(label, colour){
+ Tinycon.setBubble = function(label, colour) {
+ label = label || '';
drawFavicon(label, colour);
return this;
};
8 tinycon.min.js
View
@@ -1 +1,7 @@
-eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(8(){2 l={};2 C=J;2 D=J;2 W=j.17;2 o=J;2 r=J;2 e={};2 L={q:7,v:9,V:\'1S 1Q\',g:\'#1P\',P:\'#1N\',T:1O};2 f=(8(){2 1h=1T.1U.1Z();d 8(p){d 1h.20(p)!==-1}}());2 p={1l:f(\'1Y\'),u:f(\'u\'),1t:f(\'u\')||f(\'y\'),y:f(\'y\')&&!f(\'u\'),18:f(\'18\')&&!f(\'u\')&&!f(\'y\')};2 1f=8(){2 m=j.F(\'n\');I(2 i=0,t=m.s;i<t;i++){c((m[i].14(\'11\')||\'\').1q(/\\1V\\b/)){d m[i]}}d 1M};2 1d=8(){2 m=j.F(\'n\');2 E=j.F(\'E\')[0];I(2 i=0,t=m.s;i<t;i++){2 1i=(1k(m[i])!==\'21\');c(1i&&m[i].14(\'11\')===\'O\'){E.1L(m[i])}}};2 1m=8(){c(!D||!C){2 12=1f();D=C=12?12.14(\'1j\'):\'/1C.1z\'}d C};2 z=8(){c(!r){r=j.1e("r");r.q=16;r.v=16}d r};2 1v=8(H){1d();2 n=j.1e(\'n\');n.1J=\'1K/x-O\';n.11=\'O\';n.1j=H;j.F(\'E\')[0].1W(n)};2 1o=8(1n){c(Z.1p)Z.1p.1o(1n)};2 1r=8(a,g){c(!z().X||p.1l||p.y||e.T===\'2l\'){d 1a(a)}2 4=z().X("2d");2 g=g||\'#2j\';2 K=1m();o=1s 2m();o.2h=8(){4.27(0,0,16,16);4.28(o,0,0,o.q,o.v,0,0,16,16);c((a+\'\').s>0)1b(4,a,g);Y()};c(!K.1q(/^26/)){o.2i=\'25\'}o.K=K};2 1a=8(a){c(e.T){c((a+\'\').s>0){j.17=\'(\'+a+\') \'+W}24{j.17=W}}};2 1b=8(4,a,g){c(1k a==\'10\'&&a>2f){2 A=[[\'G\',2e],[\'M\',2b],[\'k\',2c]];I(2 i=0;i<A.s;++i)c(a>=A[i][1]){a=1x(a/A[i][1])+A[i][0];2g}}2 t=(a+\'\').s-1;2 q=e.q+(6*t);2 w=16-q;2 h=16-e.v;4.V=(p.1t?\'2a \':\'\')+e.V;4.1w=e.P;4.1y=e.P;4.29=1;4.23(w,h,q-1,e.v);4.13();4.U(w-0.5,h+1);4.S(w-0.5,15);4.Q();4.13();4.U(15.5,h+1);4.S(15.5,15);4.Q();4.13();4.1y="2n(0,0,0,0.3)";4.U(w,16);4.S(15,16);4.Q();4.1w=e.g;4.22="1F";4.1E="1H";4.1I(a,15,p.18?7:6)};2 Y=8(){c(!z().X)d;1v(z().1B())};2 1x=8(1u,19){2 10=1s 1X(1u);d 10.1R(19)};l.1g=8(R){e={};I(2 B 1A L){e[B]=R.1D(B)?R[B]:L[B]}d N};l.1c=8(H){C=H;Y();d N};l.1G=8(a,g){1r(a,g);d N};l.2k=8(){l.1c(D)};l.1g(L);Z.l=l})();',62,148,'||var||context||||function||label||if|return|options|ua|colour|||document||Tinycon|links|link|faviconImage|browser|width|canvas|length|len|chrome|height|||safari|getCanvas|metricPrefixes|key|currentFavicon|originalFavicon|head|getElementsByTagName||url|for|null|src|defaults||this|icon|background|stroke|custom|lineTo|fallback|moveTo|font|originalTitle|getContext|refreshFavicon|window|number|rel|tag|beginPath|getAttribute|||title|mozilla|precision|updateTitle|drawBubble|setImage|removeFaviconTag|createElement|getFaviconTag|setOptions|agent|exists|href|typeof|ie|getCurrentFavicon|message|log|console|match|drawFavicon|new|webkit|value|setFaviconTag|fillStyle|round|strokeStyle|ico|in|toDataURL|favicon|hasOwnProperty|textBaseline|right|setBubble|top|fillText|type|image|removeChild|false|F03D25|true|ffffff|arial|toFixed|10px|navigator|userAgent|bicon|appendChild|Number|msie|toLowerCase|indexOf|undefined|textAlign|fillRect|else|anonymous|data|clearRect|drawImage|lineWidth|bold|1000000|1000||1000000000|99|break|onload|crossOrigin|000000|reset|force|Image|rgba'.split('|'),0,{}))
+/*!
+ Tinycon - A small library for manipulating the Favicon
+ Tom Moor, http://tommoor.com
+ Copyright (c) 2012 Tom Moor
+ MIT Licensed
+ @version 0.2.6
+*/(function(){var Tinycon={};var currentFavicon=null;var originalFavicon=null;var originalTitle=document.title;var faviconImage=null;var canvas=null;var options={};var defaults={width:7,height:9,font:'10px arial',colour:'#ffffff',background:'#F03D25',fallback:true};var ua=(function(){var agent=navigator.userAgent.toLowerCase();return function(browser){return agent.indexOf(browser)!==-1;};}());var browser={ie:ua('msie'),chrome:ua('chrome'),webkit:ua('chrome')||ua('safari'),safari:ua('safari')&&!ua('chrome'),mozilla:ua('mozilla')&&!ua('chrome')&&!ua('safari')};var getFaviconTag=function(){var links=document.getElementsByTagName('link');for(var i=0,len=links.length;i<len;i++){if((links[i].getAttribute('rel')||'').match(/\bicon\b/)){return links[i];}}return false;};var removeFaviconTag=function(){var links=document.getElementsByTagName('link');var head=document.getElementsByTagName('head')[0];for(var i=0,len=links.length;i<len;i++){var exists=(typeof(links[i])!=='undefined');if(exists&&links[i].getAttribute('rel')==='icon'){head.removeChild(links[i]);}}};var getCurrentFavicon=function(){if(!originalFavicon||!currentFavicon){var tag=getFaviconTag();originalFavicon=currentFavicon=tag?tag.getAttribute('href'):'/favicon.ico';}return currentFavicon;};var getCanvas=function(){if(!canvas){canvas=document.createElement("canvas");canvas.width=16;canvas.height=16;}return canvas;};var setFaviconTag=function(url){removeFaviconTag();var link=document.createElement('link');link.type='image/x-icon';link.rel='icon';link.href=url;document.getElementsByTagName('head')[0].appendChild(link);};var log=function(message){if(window.console)window.console.log(message);};var drawFavicon=function(label,colour){if(!getCanvas().getContext||browser.ie||browser.safari||options.fallback==='force'){return updateTitle(label);}var context=getCanvas().getContext("2d");var colour=colour||'#000000';var src=getCurrentFavicon();faviconImage=new Image();faviconImage.onload=function(){context.clearRect(0,0,16,16);context.drawImage(faviconImage,0,0,faviconImage.width,faviconImage.height,0,0,16,16);if((label+'').length>0)drawBubble(context,label,colour);refreshFavicon();};if(!src.match(/^data/)){faviconImage.crossOrigin='anonymous';}faviconImage.src=src;};var updateTitle=function(label){if(options.fallback){if((label+'').length>0){document.title='('+label+') '+originalTitle;}else{document.title=originalTitle;}}};var drawBubble=function(context,label,colour){if(typeof label=='number'&&label>99){var metricPrefixes=[['G',1000000000],['M',1000000],['k',1000]];for(var i=0;i<metricPrefixes.length;++i)if(label>=metricPrefixes[i][1]){label=round(label/metricPrefixes[i][1])+metricPrefixes[i][0];break;}}var len=(label+'').length-1;var width=options.width+(6*len);var w=16-width;var h=16-options.height;context.font=(browser.webkit?'bold ':'')+options.font;context.fillStyle=options.background;context.strokeStyle=options.background;context.lineWidth=1;context.fillRect(w,h,width-1,options.height);context.beginPath();context.moveTo(w-0.5,h+1);context.lineTo(w-0.5,15);context.stroke();context.beginPath();context.moveTo(15.5,h+1);context.lineTo(15.5,15);context.stroke();context.beginPath();context.strokeStyle="rgba(0,0,0,0.3)";context.moveTo(w,16);context.lineTo(15,16);context.stroke();context.fillStyle=options.colour;context.textAlign="right";context.textBaseline="top";context.fillText(label,15,browser.mozilla?7:6);};var refreshFavicon=function(){if(!getCanvas().getContext)return;setFaviconTag(getCanvas().toDataURL());};var round=function(value,precision){var number=new Number(value);return number.toFixed(precision);};Tinycon.setOptions=function(custom){options={};for(var key in defaults){options[key]=custom.hasOwnProperty(key)?custom[key]:defaults[key];}return this;};Tinycon.setImage=function(url){currentFavicon=url;refreshFavicon();return this;};Tinycon.setBubble=function(label,colour){label=label||'';drawFavicon(label,colour);return this;};Tinycon.reset=function(){Tinycon.setImage(originalFavicon);};Tinycon.setOptions(defaults);window.Tinycon=Tinycon;})();
Please sign in to comment.
Something went wrong with that request. Please try again.