mirror of
https://codeberg.org/nobody/LocalCDN.git
synced 2025-02-20 22:00:45 +01:00
39 lines
12 KiB
JavaScript
39 lines
12 KiB
JavaScript
/*
|
|
* Copyright 2010 Small Batch, Inc.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
* use this file except in compliance with the License. You may obtain a copy of
|
|
* the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
* License for the specific language governing permissions and limitations under
|
|
* the License.
|
|
*/
|
|
;(function(window,document,undefined){
|
|
webfont={};webfont.U=function(a,b){var c=arguments.length>2?Array.prototype.slice.call(arguments,2):[];return function(){c.push.apply(c,arguments);return b.apply(a,c)}};webfont.z=function(a,b){this.V=a;this.c=b};webfont.z.prototype.createElement=function(a,b,c){a=this.V.createElement(a);if(b)for(var d in b)if(b.hasOwnProperty(d))if(d=="style"&&this.c.getName()=="MSIE")a.style.cssText=b[d];else a.setAttribute(d,b[d]);c&&a.appendChild(this.V.createTextNode(c));return a};function j(a,b,c){a=a.V.getElementsByTagName(b)[0];if(!a)a=document.documentElement;if(a&&a.lastChild){a.insertBefore(c,a.lastChild);return true}return false}
|
|
function m(a,b){function c(){document.body?b():setTimeout(c,0)}c()}function n(a,b){if(b.parentNode){b.parentNode.removeChild(b);return true}return false}function o(a,b){return a.createElement("link",{rel:"stylesheet",href:b})}function p(a,b,c){a=b.className.split(/\s+/);for(var d=0,e=a.length;d<e;d++)if(a[d]==c)return;a.push(c);b.className=a.join(" ").replace(/^\s+/,"")}
|
|
function q(a,b,c){a=b.className.split(/\s+/);for(var d=[],e=0,f=a.length;e<f;e++)a[e]!=c&&d.push(a[e]);b.className=d.join(" ").replace(/^\s+/,"").replace(/\s+$/,"")};webfont.o=function(a,b,c,d,e,f){this.Ea=a;this.Ka=b;this.Ja=c;this.Ia=d;this.Ga=e;this.Q=f};webfont.o.prototype.getName=function(){return this.Ea};webfont.e=function(a){this.c=a};webfont.e.f="Unknown";webfont.e.wa=new webfont.o(webfont.e.f,webfont.e.f,webfont.e.f,false);webfont.e.prototype.parse=function(){return this.c.indexOf("MSIE")!=-1?r(this):this.c.indexOf("Opera")!=-1?s(this):this.c.indexOf("AppleWebKit")!=-1?t(this):this.c.indexOf("Gecko")!=-1?u(this):webfont.e.wa};
|
|
function v(a){var b=w(a,a.c,/(iPod|iPad|iPhone|Android)/);if(b!="")return b;a=w(a,a.c,/(Linux|Mac_PowerPC|Macintosh|Windows)/);if(a!=""){if(a=="Mac_PowerPC")a="Macintosh";return a}return webfont.e.f}function r(a){var b=w(a,a.c,/(MSIE [\d\w\.]+)/);if(b!=""){var c=b.split(" ");b=c[0];c=c[1];return new webfont.o(b,c,b,c,v(a),x(a,c)>=6)}return new webfont.o("MSIE",webfont.e.f,"MSIE",webfont.e.f,v(a),false)}
|
|
function s(a){var b=webfont.e.f,c=webfont.e.f,d=w(a,a.c,/(Presto\/[\d\w\.]+)/);if(d!=""){c=d.split("/");b=c[0];c=c[1]}else{if(a.c.indexOf("Gecko")!=-1)b="Gecko";d=w(a,a.c,/rv:([^\)]+)/);if(d!="")c=d}if(a.c.indexOf("Version/")!=-1){d=w(a,a.c,/Version\/([\d\.]+)/);if(d!="")return new webfont.o("Opera",d,b,c,v(a),x(a,d)>=10)}d=w(a,a.c,/Opera[\/ ]([\d\.]+)/);if(d!="")return new webfont.o("Opera",d,b,c,v(a),x(a,d)>=10);return new webfont.o("Opera",webfont.e.f,b,c,v(a),false)}
|
|
function t(a){var b=v(a),c=w(a,a.c,/AppleWebKit\/([\d\.\+]+)/);if(c=="")c=webfont.e.f;var d=webfont.e.f;if(a.c.indexOf("Chrome")!=-1)d="Chrome";else if(a.c.indexOf("Safari")!=-1)d="Safari";var e=webfont.e.f;if(a.c.indexOf("Version/")!=-1)e=w(a,a.c,/Version\/([\d\.\w]+)/);else if(d=="Chrome")e=w(a,a.c,/Chrome\/([\d\.]+)/);var f=w(a,c,/\d+\.(\d+)/);return new webfont.o(d,e,"AppleWebKit",c,b,x(a,c)>=526||x(a,c)>=525&&parseInt(f)>=13)}
|
|
function u(a){var b=webfont.e.f,c=webfont.e.f,d=false;if(a.c.indexOf("Firefox")!=-1){b="Firefox";var e=w(a,a.c,/Firefox\/([\d\w\.]+)/);if(e!=""){d=w(a,e,/\d+\.(\d+)/);c=e;d=e!=""&&x(a,e)>=3&&parseInt(d)>=5}}else if(a.c.indexOf("Mozilla")!=-1)b="Mozilla";e=w(a,a.c,/rv:([^\)]+)/);if(e=="")e=webfont.e.f;else if(!d){d=x(a,e);var f=parseInt(w(a,e,/\d+\.(\d+)/)),h=parseInt(w(a,e,/\d+\.\d+\.(\d+)/));d=d>1||d==1&&f>9||d==1&&f==9&&h>=2||e.match(/1\.9\.1b[123]/)!=null||e.match(/1\.9\.1\.[\d\.]+/)!=null}return new webfont.o(b,
|
|
c,"Gecko",e,v(a),d)}function x(a,b){a=w(a,b,/(\d+)/);if(a!="")return parseInt(a);return-1}function w(a,b,c){if((a=b.match(c))&&a[1])return a[1];return""};webfont.d=function(a,b,c,d){this.a=a;this.k=b;this.ea=c;this.q=d||webfont.d.sa;this.p=new webfont.H("-")};webfont.d.sa="wf";webfont.d.v="loading";webfont.d.G="active";webfont.d.K="inactive";webfont.d.R="font";function y(a){p(a.a,a.k,a.p.j(a.q,webfont.d.v));A(a,webfont.d.v)}function B(a,b,c){q(a.a,a.k,a.p.j(a.q,b,c,webfont.d.v));p(a.a,a.k,a.p.j(a.q,b,c,webfont.d.G));A(a,webfont.d.R+webfont.d.G,b,c)}function C(a){p(a.a,a.k,a.p.j(a.q,webfont.d.K));A(a,webfont.d.K)}
|
|
function D(a){q(a.a,a.k,a.p.j(a.q,webfont.d.v));p(a.a,a.k,a.p.j(a.q,webfont.d.G));A(a,webfont.d.G)}function A(a,b,c,d){a.ea[b]&&a.ea[b](c,d)};webfont.ua=function(){this.ma={}};function E(a,b){var c=[];for(var d in b)if(b.hasOwnProperty(d)){var e=a.ma[d];e&&c.push(e(b[d]))}return c};webfont.t=function(a,b,c,d,e){this.a=a;this.A=b;this.W=c;this.M=d;this.ja=e;this.fa=0;this.aa=this.la=false;this.Da=new webfont.ca;this.N=new webfont.g};webfont.t.da="_,arial,helvetica";webfont.t.ta="n4";
|
|
webfont.t.prototype.watch=function(a,b,c){for(var d=a.length,e=0;e<d;e++){var f=a[e];b[f]||(b[f]=[webfont.t.ta]);this.fa+=b[f].length}if(c)this.la=c;for(e=0;e<d;e++){f=a[e];c=b[f];for(var h=0,i=c.length;h<i;h++){var g=c[h],k=F(this,webfont.t.da,g),z=this.W.X(k);n(this.a,k);k=f;var l=this.A;p(l.a,l.k,l.p.j(l.q,k,g,webfont.d.v));A(l,webfont.d.R+webfont.d.v,k,g);l=F(this,this.Da.quote(k),g);if(z!=this.W.X(l)){n(this.a,l);B(this.A,k,g);this.aa=true;G(this)}else H(this,this.ja(),z,l,k,g)}}};
|
|
function G(a){if(--a.fa==0&&a.la)a.aa?D(a.A):C(a.A)}webfont.t.prototype.za=function(a,b,c,d,e){if(b!=this.W.X(c)){n(this.a,c);B(this.A,d,e);this.aa=true;G(this)}else if(this.ja()-a<5E3)H(this,a,b,c,d,e);else{n(this.a,c);a=this.A;q(a.a,a.k,a.p.j(a.q,d,e,webfont.d.v));p(a.a,a.k,a.p.j(a.q,d,e,webfont.d.K));A(a,webfont.d.R+webfont.d.K,d,e);G(this)}};function H(a,b,c,d,e,f){a.M(function(h,i){return function(){i.call(h,b,c,d,e,f)}}(a,a.za),50)}
|
|
function F(a,b,c){c=a.N.expand(c);b=a.a.createElement("span",{style:"position:absolute;top:-999px;font-size:300px;font-family:"+b+","+webfont.t.da+";"+c},"Mm");j(a.a,"body",b);return b};webfont.D=function(a,b,c,d,e){this.a=a;this.ha=b;this.k=c;this.M=d;this.c=e;this.Z=this.$=0};webfont.D.prototype.F=function(a,b){this.ha.ma[a]=b};webfont.D.prototype.load=function(a){var b=new webfont.d(this.a,this.k,a);this.c.Q?I(this,b,a):C(b)};webfont.D.prototype.Ba=function(a,b,c,d){if(d)a.load(webfont.U(this,this.Fa,b,c));else{a=--this.$==0;this.Z--;if(a)this.Z==0?C(b):y(b);c.watch([],{},a)}};
|
|
webfont.D.prototype.Fa=function(a,b,c,d){var e=--this.$==0;e&&y(a);this.M(webfont.U(this,function(f,h,i,g){f.watch(h,i||{},g)},b,c,d,e))};function I(a,b,c){c=E(a.ha,c);a.Z=a.$=c.length;for(var d=new webfont.t(a.a,b,{X:function(i){return i.offsetWidth}},a.M,function(){return(new Date).getTime()}),e=0,f=c.length;e<f;e++){var h=c[e];h.P(a.c,webfont.U(a,a.Ba,h,b,d))}};webfont.H=function(a){this.Ca=a||webfont.H.ra};webfont.H.ra="-";webfont.H.prototype.j=function(){for(var a=[],b=0;b<arguments.length;b++)a.push(arguments[b].replace(/[\W_]+/g,"").toLowerCase());return a.join(this.Ca)};webfont.ca=function(){this.oa='"'};webfont.ca.prototype.quote=function(a){var b=[];a=a.split(/,\s*/);for(var c=0;c<a.length;c++){var d=a[c].replace(/['"]/g,"");d.indexOf(" ")==-1?b.push(d):b.push(this.oa+d+this.oa)}return b.join(",")};webfont.g=function(){this.O=webfont.g.va;this.s=webfont.g.xa};webfont.g.va=["font-style","font-weight"];webfont.g.xa={"font-style":[["n","normal"],["i","italic"],["o","oblique"]],"font-weight":[["1","100"],["2","200"],["3","300"],["4","400"],["5","500"],["6","600"],["7","700"],["8","800"],["9","900"],["4","normal"],["7","bold"]]};webfont.g.L=function(a,b,c){this.ka=a;this.Ha=b;this.s=c};
|
|
webfont.g.L.prototype.compact=function(a,b){for(var c=0;c<this.s.length;c++)if(b==this.s[c][1]){a[this.ka]=this.s[c][0];return}};webfont.g.L.prototype.expand=function(a,b){for(var c=0;c<this.s.length;c++)if(b==this.s[c][0]){a[this.ka]=this.Ha+":"+this.s[c][1];return}};
|
|
webfont.g.prototype.compact=function(a){var b=["n","4"];a=a.split(";");for(var c=0,d=a.length;c<d;c++){var e=a[c].replace(/\s+/g,"").split(":");if(e.length==2){var f=e[1];a:{e=e[0];for(var h=0;h<this.O.length;h++)if(e==this.O[h]){e=new webfont.g.L(h,e,this.s[e]);break a}e=null}e&&e.compact(b,f)}}return b.join("")};
|
|
webfont.g.prototype.expand=function(a){if(a.length!=2)return null;for(var b=[null,null],c=0,d=this.O.length;c<d;c++){var e=this.O[c],f=a.substr(c,1);(new webfont.g.L(c,e,this.s[e])).expand(b,f)}return b[0]&&b[1]?b.join(";")+";":null};window.WebFont=function(){var a=(new webfont.e(navigator.userAgent)).parse();return new webfont.D(new webfont.z(document,a),new webfont.ua,document.documentElement,function(b,c){setTimeout(b,c)},a)}();window.WebFont.load=window.WebFont.load;window.WebFont.addModule=window.WebFont.F;webfont.u=function(a,b){this.a=a;this.h=b};webfont.u.w="ascender";webfont.u.T={regular:"n4",bold:"n7",italic:"i4",bolditalic:"i7",r:"n4",b:"n7",i:"i4",bi:"i7"};webfont.u.prototype.P=function(a,b){return b(a.Q)};
|
|
webfont.u.prototype.load=function(a){j(this.a,"head",o(this.a,("https:"==document.location.protocol?"https:":"http:")+"//webfonts.fontslive.com/css/"+this.h.key+".css"));var b;b=this.h.families;var c,d,e;c=[];d={};for(var f=0,h=b.length;f<h;f++){e=void 0;var i=void 0;i=void 0;i=b[f].split(":");e=i[0];i=i[1]?J(this,i[1]):["n4"];e={ga:e,ba:i};c.push(e.ga);d[e.ga]=e.ba}b={Aa:c,ba:d};a(b.Aa,b.ba)};
|
|
function J(a,b){a=b.split(",");b=[];for(var c=0,d=a.length;c<d;c++){var e=a[c];if(e){var f=webfont.u.T[e];b.push(f?f:e)}}return b}WebFont.F(webfont.u.w,function(a){return new webfont.u(new webfont.z(document),a)});webfont.J=function(a){this.ya=a?a:("https:"==window.location.protocol?"https:":"http:")+webfont.J.qa;this.m=null};webfont.J.qa="//fonts.googleapis.com/css";webfont.J.prototype.j=function(){if(!this.m)throw new Error("No fonts to load !");for(var a=this.m.length,b=[],c=0;c<a;c++)b.push(this.m[c].replace(/ /g,"+"));return this.ya+"?family="+b.join("%7C")};webfont.I=function(a){this.m=a;this.na=[];this.pa={};this.N=new webfont.g};webfont.I.T={ultralight:"n2",light:"n3",regular:"n4",bold:"n7",italic:"i4",bolditalic:"i7",ul:"n2",l:"n3",r:"n4",b:"n7",i:"i4",bi:"i7"};
|
|
webfont.I.prototype.parse=function(){for(var a=this.m.length,b=0;b<a;b++){var c=this.m[b].split(":"),d=c[0],e=null;if(c.length==2){var f=[];c=c[1].split(",");for(var h=c.length,i=0;i<h;i++){var g;g=c[i];if(g.match(/^[\w ]+$/)){var k=webfont.I.T[g];if(k)g=k;else{k=g.match(/^(\d*)(\w*)$/);g=k[1];k=k[2];g=(g=this.N.expand([k?k:"n",g?g.substr(0,1):"4"].join("")))?this.N.compact(g):null}}else g="";g&&f.push(g)}if(f.length>0)e=f}else e=["n4"];this.na.push(d);this.pa[d]=e}};webfont.C=function(a,b,c){this.c=a;this.a=b;this.h=c};webfont.C.w="google";webfont.C.prototype.P=function(a,b){a.Ga.match(/iPad|iPod|iPhone/)!=null&&b(false);return b(a.Q)};webfont.C.prototype.load=function(a){var b=new webfont.J(this.h.api),c=this.h.families,d=this.a,e=this.c.getName()=="MSIE"&&this.h.blocking!=true;b.m=c;e?m(d,function(){j(d,"head",o(d,b.j()))}):j(d,"head",o(d,b.j()));c=new webfont.I(c);c.parse();a(c.na,c.pa)};
|
|
WebFont.F(webfont.C.w,function(a){var b=(new webfont.e(navigator.userAgent)).parse();return new webfont.C(b,new webfont.z(document),a)});webfont.B=function(a,b){this.a=a;this.h=b};webfont.B.w="custom";webfont.B.prototype.load=function(a){for(var b=this.h.urls||[],c=this.h.families||[],d=0,e=b.length;d<e;d++)j(this.a,"head",o(this.a,b[d]));a(c)};webfont.B.prototype.P=function(a,b){return b(a.Q)};WebFont.F(webfont.B.w,function(a){return new webfont.B(new webfont.z(document),a)});webfont.n=function(a,b,c){this.Y=a;this.a=b;this.h=c;this.m=[];this.ia={}};webfont.n.w="typekit";webfont.n.S="__webfonttypekitmodule__";webfont.n.prototype.P=function(a,b){var c=this.h.id,d=this.h,e=this;if(c){this.Y[webfont.n.S]||(this.Y[webfont.n.S]={});this.Y[webfont.n.S][c]=function(f){f(a,d,function(h,i,g){e.m=i;e.ia=g;b(h)})};j(this.a,"head",this.a.createElement("script",{src:(this.h.api||"http://use.typekit.com")+"/"+c+".js"}))}else b(true)};webfont.n.prototype.load=function(a){a(this.m,this.ia)};
|
|
WebFont.F(webfont.n.w,function(a){return new webfont.n(window,new webfont.z(document),a)});window.WebFontConfig&&window.WebFont.load(window.WebFontConfig);
|
|
})(this,document);
|