1
0
mirror of https://codeberg.org/nobody/LocalCDN.git synced 2025-02-11 17:30:42 +01:00
2020-02-27 13:45:29 +01:00

36 lines
11 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.Q=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){this.R=a};webfont.z.prototype.createElement=function(a,b,c){a=this.R.createElement(a);if(b)for(var d in b)b.hasOwnProperty(d)&&a.setAttribute(d,b[d]);c&&a.appendChild(this.R.createTextNode(c));return a};function i(a,b,c){a=a.R.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.Aa=a;this.Ga=b;this.Fa=c;this.Ea=d;this.Ca=e;this.Z=f};webfont.o.prototype.getName=function(){return this.Aa};webfont.e=function(a){this.a=a};webfont.e.f="Unknown";webfont.e.sa=new webfont.o(webfont.e.f,webfont.e.f,webfont.e.f,false);webfont.e.prototype.parse=function(){return this.a.indexOf("MSIE")!=-1?r(this):this.a.indexOf("Opera")!=-1?s(this):this.a.indexOf("AppleWebKit")!=-1?t(this):this.a.indexOf("Gecko")!=-1?u(this):webfont.e.sa};
function v(a){var b=w(a,a.a,/(iPod|iPad|iPhone|Android)/);if(b!="")return b;a=w(a,a.a,/(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.a,/(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.a,/(Presto\/[\d\w\.]+)/);if(d!=""){c=d.split("/");b=c[0];c=c[1]}else{if(a.a.indexOf("Gecko")!=-1)b="Gecko";d=w(a,a.a,/rv:([^\)]+)/);if(d!="")c=d}if(a.a.indexOf("Version/")!=-1){d=w(a,a.a,/Version\/([\d\.]+)/);if(d!="")return new webfont.o("Opera",d,b,c,v(a),x(a,d)>=10)}d=w(a,a.a,/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.a,/AppleWebKit\/([\d\.\+]+)/);if(c=="")c=webfont.e.f;var d=webfont.e.f;if(a.a.indexOf("Chrome")!=-1)d="Chrome";else if(a.a.indexOf("Safari")!=-1)d="Safari";var e=webfont.e.f;if(a.a.indexOf("Version/")!=-1)e=w(a,a.a,/Version\/([\d\.\w]+)/);else if(d=="Chrome")e=w(a,a.a,/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.a.indexOf("Firefox")!=-1){b="Firefox";var e=w(a,a.a,/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.a.indexOf("Mozilla")!=-1)b="Mozilla";e=w(a,a.a,/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.c=a;this.j=b;this.ba=c;this.q=d||webfont.d.oa;this.p=new webfont.F("-")};webfont.d.oa="wf";webfont.d.u="loading";webfont.d.D="active";webfont.d.I="inactive";webfont.d.O="font";function y(a){p(a.c,a.j,a.p.h(a.q,webfont.d.u));A(a,webfont.d.u)}function B(a,b,c){q(a.c,a.j,a.p.h(a.q,b,c,webfont.d.u));p(a.c,a.j,a.p.h(a.q,b,c,webfont.d.D));A(a,webfont.d.O+webfont.d.D,b,c)}function C(a){p(a.c,a.j,a.p.h(a.q,webfont.d.I));A(a,webfont.d.I)}
function D(a){q(a.c,a.j,a.p.h(a.q,webfont.d.u));p(a.c,a.j,a.p.h(a.q,webfont.d.D));A(a,webfont.d.D)}function A(a,b,c,d){a.ba[b]&&a.ba[b](c,d)};webfont.qa=function(){this.ia={}};function E(a,b){var c=[];for(var d in b)if(b.hasOwnProperty(d)){var e=a.ia[d];e&&c.push(e(b[d]))}return c};webfont.t=function(a,b,c,d,e){this.c=a;this.v=b;this.S=c;this.L=d;this.fa=e;this.ca=0;this.X=this.ha=false;this.za=new webfont.$;this.M=new webfont.g};webfont.t.aa="DEFAULT_FONT";webfont.t.pa="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.pa]);this.ca+=b[f].length}if(c)this.ha=c;for(e=0;e<d;e++){f=a[e];c=b[f];for(var h=0,k=c.length;h<k;h++){var g=c[h],j=F(this,webfont.t.aa,g),z=this.S.T(j);n(this.c,j);j=f;var l=this.v;p(l.c,l.j,l.p.h(l.q,j,g,webfont.d.u));A(l,webfont.d.O+webfont.d.u,j,g);l=F(this,j,g);if(z!=this.S.T(l)){n(this.c,l);B(this.v,j,g);this.X=true;G(this)}else H(this,this.fa(),z,l,j,g)}}};
function G(a){if(--a.ca==0&&a.ha)a.X?D(a.v):C(a.v)}webfont.t.prototype.wa=function(a,b,c,d,e){if(b!=this.S.T(c)){n(this.c,c);B(this.v,d,e);this.X=true;G(this)}else if(this.fa()-a<5E3)H(this,a,b,c,d,e);else{n(this.c,c);a=this.v;q(a.c,a.j,a.p.h(a.q,d,e,webfont.d.u));p(a.c,a.j,a.p.h(a.q,d,e,webfont.d.I));A(a,webfont.d.O+webfont.d.I,d,e);G(this)}};function H(a,b,c,d,e,f){a.L(function(h,k){return function(){k.call(h,b,c,d,e,f)}}(a,a.wa),50)}
function F(a,b,c){b=a.za.quote(b);c=a.M.expand(c);c=a.c.createElement("span",{style:"position:absolute;top:-999px;font-size:300px;font-family:"+b+","+webfont.t.aa+";"+c},"Mm");i(a.c,"html",c);return c};webfont.C=function(a,b,c,d,e){this.c=a;this.da=b;this.j=c;this.L=d;this.a=e;this.V=this.W=0};webfont.C.prototype.K=function(a,b){this.da.ia[a]=b};webfont.C.prototype.load=function(a){var b=new webfont.d(this.c,this.j,a);this.a.Z?I(this,b,a):C(b)};webfont.C.prototype.xa=function(a,b,c,d){if(d)a.load(webfont.Q(this,this.Ba,b,c));else{a=--this.W==0;this.V--;if(a)this.V==0?C(b):y(b);c.watch([],{},a)}};
webfont.C.prototype.Ba=function(a,b,c,d){var e=--this.W==0;e&&y(a);this.L(webfont.Q(this,function(f,h,k,g){f.watch(h,k||{},g)},b,c,d,e))};function I(a,b,c){c=E(a.da,c);a.V=a.W=c.length;for(var d=new webfont.t(a.c,b,{T:function(k){return k.offsetWidth}},a.L,function(){return+new Date}),e=0,f=c.length;e<f;e++){var h=c[e];h.Y(a.a,webfont.Q(a,a.xa,h,b,d))}};webfont.F=function(a){this.ya=a||webfont.F.na};webfont.F.na="-";webfont.F.prototype.h=function(){for(var a=[],b=0;b<arguments.length;b++)a.push(arguments[b].replace(/[\W_]+/g,"").toLowerCase());return a.join(this.ya)};webfont.$=function(){this.ka='"'};webfont.$.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.ka+d+this.ka)}return b.join(",")};webfont.g=function(){this.N=webfont.g.ra;this.s=webfont.g.ta};webfont.g.ra=["font-style","font-weight"];webfont.g.ta={"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.J=function(a,b,c){this.ga=a;this.Da=b;this.s=c};
webfont.g.J.prototype.compact=function(a,b){for(var c=0;c<this.s.length;c++)if(b==this.s[c][1]){a[this.ga]=this.s[c][0];return}};webfont.g.J.prototype.expand=function(a,b){for(var c=0;c<this.s.length;c++)if(b==this.s[c][0]){a[this.ga]=this.Da+":"+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.N.length;h++)if(e==this.N[h]){e=new webfont.g.J(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.N.length;c<d;c++){var e=this.N[c],f=a.substr(c,1);(new webfont.g.J(c,e,this.s[e])).expand(b,f)}return b[0]&&b[1]?b.join(";")+";":null};window.WebFont=function(){var a=new webfont.z(document),b=(new webfont.e(navigator.userAgent)).parse();return new webfont.C(a,new webfont.qa,document.documentElement,function(c,d){setTimeout(c,d)},b)}();window.WebFont.load=window.WebFont.load;window.WebFont.addModule=window.WebFont.K;webfont.H=function(a){this.va=a||webfont.H.ma;this.m=null};webfont.H.ma="//fonts.googleapis.com/css";webfont.H.prototype.h=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.va+"?family="+b.join("%7C")};webfont.G=function(a){this.m=a;this.ja=[];this.la={};this.M=new webfont.g};webfont.G.ua={ultralight:"n2",light:"n3",regular:"i4",bold:"i7",italic:"i4",bolditalic:"i7",ul:"n2",l:"n3",r:"n4",b:"n7",i:"i4",bi:"i7"};
webfont.G.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,k=0;k<h;k++){var g;g=c[k];if(g.match(/^[\w ]+$/)){var j=webfont.G.ua[g];if(j)g=j;else{j=g.match(/^(\d*)(\w*)$/);g=j[1];j=j[2];g=(g=this.M.expand([j?j:"n",g?g.substr(0,1):"4"].join("")))?this.M.compact(g):null}}else g="";g&&f.push(g)}if(f.length>0)e=f}else e=["n4"];this.ja.push(d);this.la[d]=e}};webfont.A=function(a,b,c){this.a=a;this.c=b;this.k=c};webfont.A.B="google";webfont.A.prototype.Y=function(a,b){a.Ca.match(/iPad|iPod|iPhone/)!=null&&b(false);return b(a.Z)};webfont.A.prototype.load=function(a){var b=new webfont.H(this.k.api),c=this.k.families,d=this.c,e=this.a.getName()=="MSIE"&&this.k.blocking!=true;b.m=c;e?m(d,function(){i(d,"head",o(d,b.h()))}):i(d,"head",o(d,b.h()));c=new webfont.G(c);c.parse();a(c.ja,c.la)};
WebFont.K(webfont.A.B,function(a){var b=(new webfont.e(navigator.userAgent)).parse();return new webfont.A(b,new webfont.z(document),a)});webfont.w=function(a,b){this.c=a;this.k=b};webfont.w.B="custom";webfont.w.prototype.load=function(a){for(var b=this.k.urls||[],c=this.k.families||[],d=0,e=b.length;d<e;d++)i(this.c,"head",o(this.c,b[d]));a(c)};webfont.w.prototype.Y=function(a,b){return b(a.Z)};WebFont.K(webfont.w.B,function(a){return new webfont.w(new webfont.z(document),a)});webfont.n=function(a,b,c){this.U=a;this.c=b;this.k=c;this.m=[];this.ea={}};webfont.n.B="typekit";webfont.n.P="__webfonttypekitmodule__";webfont.n.prototype.Y=function(a,b){var c=this.k.id,d=this.k,e=this;if(c){this.U[webfont.n.P]||(this.U[webfont.n.P]={});this.U[webfont.n.P][c]=function(f){f(a,d,function(h,k,g){e.m=k;e.ea=g;b(h)})};i(this.c,"head",this.c.createElement("script",{src:(this.k.api||"http://use.typekit.com")+"/"+c+".js"}))}else b(true)};webfont.n.prototype.load=function(a){a(this.m,this.ea)};
WebFont.K(webfont.n.B,function(a){return new webfont.n(window,new webfont.z(document),a)});
})(this,document);