Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (self.AMP=self.AMP||[]).push({n:"amp-gist",v:"1528391646530",f:(function(AMP){function r(a,b){function d(){}d.prototype=b.prototype;a.prototype=new d;a.prototype.constructor=a;for(var e in b)if(Object.defineProperties){var c=Object.getOwnPropertyDescriptor(b,e);c&&Object.defineProperty(a,e,c)}else a[e]=b[e]}function u(a,b){b=void 0===b?"":b;try{return decodeURIComponent(a)}catch(d){return b}};var v=/(?:^[#?]?|&)([^=&]+)(?:=([^&]*))?/g;function y(a){var b=Object.create(null);if(!a)return b;for(var d;d=v.exec(a);){var e=u(d[1],d[1]),c=d[2]?u(d[2],d[2]):"";b[e]=c}return b};var z="";function A(){var a=void 0,b=a||self,d;if(b.AMP_MODE)d=b.AMP_MODE;else{d=b;var e=y(d.location.originalHash||d.location.hash),c=y(d.location.search);z||(z=d.AMP_CONFIG&&d.AMP_CONFIG.v?d.AMP_CONFIG.v:"011528391646530");d=b.AMP_MODE={localDev:!1,development:!("1"!=e.development&&!d.AMP_DEV_MODE),examiner:"2"==e.development,filter:e.filter,geoOverride:e["amp-geo"],minified:!0,lite:void 0!=c.amp_lite,test:!1,log:e.log,version:"1528391646530",rtvVersion:z}}return d};self.log=self.log||{user:null,dev:null,userForEmbed:null};var B=self.log;function C(){if(!B.user)throw Error("failed to call initLogConstructor");return B.user}function D(){if(B.dev)return B.dev;throw Error("failed to call initLogConstructor");};function E(a){return a||{}};function H(a,b){return b.length>a.length?!1:0==a.lastIndexOf(b,0)};var I=self.AMP_CONFIG||{},aa=I.thirdPartyUrl||"https://3p.ampproject.net",ba=I.thirdPartyFrameHost||"ampproject.net";function J(a){this.o=a;this.l=this.m=0;this.h=Object.create(null)}J.prototype.has=function(a){return!!this.h[a]};J.prototype.get=function(a){var b=this.h[a];if(b)return b.access=++this.l,b.payload};J.prototype.put=function(a,b){this.has(a)||this.m++;this.h[a]={payload:b,access:this.l};if(!(this.m<=this.o)){D().warn("lru-cache","Trimming LRU cache");a=this.h;var d=this.l+1,e,c;for(c in a){var g=a[c].access;g<d&&(d=g,e=c)}void 0!==e&&(delete a[e],this.m--)}};E({c:!0,v:!0,a:!0,ad:!0});var K,L;
- function M(a){var b;K||(K=self.document.createElement("a"),L=self.UrlCache||(self.UrlCache=new J(100)));var d=b?null:L,e=K;if(d&&d.has(a))a=d.get(a);else{e.href=a;e.protocol||(e.href=e.href);var c={href:e.href,protocol:e.protocol,host:e.host,hostname:e.hostname,port:"0"==e.port?"":e.port,pathname:e.pathname,search:e.search,hash:e.hash,origin:null};"/"!==c.pathname[0]&&(c.pathname="/"+c.pathname);if("http:"==c.protocol&&80==c.port||"https:"==c.protocol&&443==c.port)c.port="",c.host=c.hostname;c.origin=
- e.origin&&"null"!=e.origin?e.origin:"data:"!=c.protocol&&c.host?c.protocol+"//"+c.host:c.href;d&&d.put(a,c);a=c}return a}function ca(a){"string"==typeof a&&(a=M(a));var b;(b="https:"==a.protocol||"localhost"==a.hostname)||(a=a.hostname,b=a.length-10,b=0<=b&&a.indexOf(".localhost",b)==b);return b};function da(a){var b="no-sync-xhr-in-ads",d=N(a);return!!d[b]}
- function N(a){if(a.__AMP__EXPERIMENT_TOGGLES)return a.__AMP__EXPERIMENT_TOGGLES;a.__AMP__EXPERIMENT_TOGGLES=Object.create(null);var b=a.__AMP__EXPERIMENT_TOGGLES;if(a.AMP_CONFIG)for(var d in a.AMP_CONFIG){var e=a.AMP_CONFIG[d];"number"===typeof e&&0<=e&&1>=e&&(b[d]=Math.random()<e)}if(a.AMP_CONFIG&&Array.isArray(a.AMP_CONFIG["allow-doc-opt-in"])&&0<a.AMP_CONFIG["allow-doc-opt-in"].length){var c=a.AMP_CONFIG["allow-doc-opt-in"],g=a.document.head.querySelector('meta[name="amp-experiments-opt-in"]');if(g){var f=
- g.getAttribute("content").split(",");for(d=0;d<f.length;d++)-1!=c.indexOf(f[d])&&(b[f[d]]=!0)}}Object.assign(b,ea(a));if(a.AMP_CONFIG&&Array.isArray(a.AMP_CONFIG["allow-url-opt-in"])&&0<a.AMP_CONFIG["allow-url-opt-in"].length){d=a.AMP_CONFIG["allow-url-opt-in"];a=y(a.location.originalHash||a.location.hash);for(var h=0;h<d.length;h++){var k=a["e-"+d[h]];"1"==k&&(b[d[h]]=!0);"0"==k&&(b[d[h]]=!1)}}return b}
- function ea(a){a:{var b;try{b=a.document.cookie}catch(h){b=""}if(a=b)for(a=a.split(";"),b=0;b<a.length;b++){var d=a[b].trim(),e=d.indexOf("="),c;if(c=-1!=e)c=d.substring(0,e).trim(),c="AMP_EXP"==u(c,void 0);if(c){a=d.substring(e+1).trim();a=u(a,a);break a}}a=null}var g=a,f=g?g.split(/\s*,\s*/g):[];a=Object.create(null);for(b=0;b<f.length;b++)0!=f[b].length&&("-"==f[b][0]?a[f[b].substr(1)]=!1:a[f[b]]=!0);return a};function fa(a){for(var b=a.nodeName,d=0,e=0,c=a.previousElementSibling;c&&25>e&&100>d;)c.nodeName==b&&e++,d++,c=c.previousElementSibling;return 25>e&&100>d?"."+e:""};function O(a,b){a=P(a);a=P(a);a=a.isSingleDoc()?a.win:a;return Q(a,b)}function P(a){if(a.nodeType){var b=(a.ownerDocument||a).defaultView,b=b.__AMP_TOP||b;a=Q(b,"ampdoc").getAmpDoc(a)}return a}function Q(a,b){var d=a.services;d||(d=a.services={});var e=d;a=e[b];a.obj||(a.obj=new a.ctor(a.context),a.ctor=null,a.context=null,a.resolve&&a.resolve(a.obj));return a.obj};/*
- https://mths.be/cssescape v1.5.1 by @mathias | MIT license */
- function R(a,b){try{return JSON.parse(a)}catch(d){b&&b(d)}};var S,T="Webkit webkit Moz moz ms O o".split(" ");function ga(a){var b,d;d=a.style;if(H("border","--"))d="border";else{S||(S=Object.create(null));var e=S.border;if(!e){e="border";if(void 0===d.border){var c;b:{for(c=0;c<T.length;c++){var g=T[c]+"Border";if(void 0!==d[g]){c=g;break b}}c=""}void 0!==d[c]&&(e=c)}S.border=e}d=e}d&&(a.style[d]=b?"none"+b:"none")};function U(a){a=parseFloat(a);return"number"===typeof a&&isFinite(a)?a:void 0};var V={};
- function ha(a,b){C().assert("github","Attribute type required for <amp-ad>: %s",b);for(var d=0,e=a;e&&e!=e.parent;e=e.parent)d++;var d=String(d)+"-"+W(a),c=e={},g=b.dataset,f;for(f in g)H(f,"vars")||(c[f]=g[f]);if(f=b.getAttribute("json")){f=R(f);if(void 0===f)throw C().createError("Error parsing JSON in json attribute in element %s",b);for(var h in f)c[h]=f[h]}h=e;e=Date.now();c=b.getAttribute("width");f=b.getAttribute("height");h=h?h:{};h.width=U(c);h.height=U(f);b.getAttribute("title")&&(h.title=
- b.getAttribute("title"));var k=a.location.href;"about:srcdoc"==k&&(k=a.parent.location.href);var p=O(b,"documentInfo").get(),q=O(b,"viewer"),c=q.getUnconfirmedReferrerUrl(),m=b.getPageLayoutBox();f=h;for(var g=p.sourceUrl,l=p.canonicalUrl,p=p.pageViewId,k={href:k},F=b.tagName,t={localDev:!1,development:A().development,filter:A().filter,minified:!0,lite:A().lite,test:!1,log:A().log,version:A().version,rtvVersion:A().rtvVersion},ia=!(!a.AMP_CONFIG||!a.AMP_CONFIG.canary),q=!q.isVisible(),m=m?{left:m.left,
- top:m.top,width:m.width,height:m.height}:null,ja=b.getIntersectionChangeEntry(),n=b,G=[],w=0;n&&1==n.nodeType&&25>w;){var x="";n.id&&(x="/"+n.id);var ka=n.nodeName.toLowerCase();G.push(""+ka+x+fa(n));w++;n=n.parentElement}n=G.join();G=n.length;w=5381;for(x=0;x<G;x++)w=33*w^n.charCodeAt(x);f._context=E({ampcontextVersion:"1528391646530",ampcontextFilepath:aa+"/1528391646530/ampcontext-v0.js",sourceUrl:g,referrer:c,canonicalUrl:l,pageViewId:p,location:k,startTime:e,tagName:F,mode:t,
- canary:ia,hidden:q,initialLayoutRect:m,initialIntersection:ja,domFingerprint:String(w>>>0),experimentToggles:N(a),sentinel:d});(a=b.getAttribute("src"))&&(h.src=a);e=h;e.type="github";Object.assign(e._context,void 0);return e}
- function la(a,b){var d,e=ha(a,b),c=a.document.createElement("iframe");V[e.type]||(V[e.type]=0);V[e.type]+=1;var g=ma(a,d),f=M(g).hostname,h=JSON.stringify(E({host:f,type:e.type,count:V[e.type],attributes:e}));c.src=g;c.ampLocation=M(g);c.name=h;e.width&&(c.width=e.width);e.height&&(c.height=e.height);e.title&&(c.title=e.title);c.setAttribute("scrolling","no");ga(c);c.onload=function(){this.readyState="complete"};da(a)&&c.setAttribute("allow","sync-xhr 'none';");c.setAttribute("data-amp-3p-sentinel",
- e._context.sentinel);return c}
- function ma(a,b){var d=void 0,e=a.bootstrapBaseUrl;if(e)a=e;else{var c;c=d;var g=a.document.querySelector('meta[name="amp-3p-iframe-src"]');if(g)if(b)C().error("3p-frame","3p iframe url disabled for github"),c=null;else{b=g.getAttribute("content");var f;f=void 0===f?"source":f;C().assert(null!=b,"%s %s must be available",g,f);C().assert(ca(b)||/^(\/\/)/.test(b),'%s %s must start with "https://" or "//" or be relative and served from either https or from localhost. Invalid value: %s',g,f,b);C().assert(-1==
- b.indexOf("?"),"3p iframe url must not include query string %s in element %s.",b,g);f=M(b);C().assert("localhost"==f.hostname&&!c||f.origin!=M(a.location.href).origin,"3p iframe url must not be on the same origin as the current document %s (%s) in element %s. See https://github.com/ampproject/amphtml/blob/master/spec/amp-iframe-origin-policy.md for details.",b,f.origin,g);c=b+"?1528391646530"}else c=null;c||(a.defaultBootstrapSubDomain=a.defaultBootstrapSubDomain||"d-"+W(a),c="https://"+
- a.defaultBootstrapSubDomain+("."+ba+"/1528391646530/")+"frame.html");a=a.bootstrapBaseUrl=c}return a}function W(a){var b;if(a.crypto&&a.crypto.getRandomValues){var d=new Uint32Array(2);a.crypto.getRandomValues(d);b=String(d[0])+d[1]}else b=String(a.Math.random()).substr(2)+"0";return b};function na(a){if(!X(a))return null;var b=a.indexOf("{");try{return JSON.parse(a.substr(b))}catch(d){return D().error("MESSAGING","Failed to parse message: "+a,d),null}}function X(a){return"string"==typeof a&&0==a.indexOf("amp-")&&-1!=a.indexOf("{")};function Y(a,b,d){var e=a.listeningFors;!e&&d&&(e=a.listeningFors=Object.create(null));a=e||null;if(!a)return a;var c=a[b];!c&&d&&(c=a[b]=[]);return c||null}function oa(a,b){var d=!0,e=M(b.src).origin,c=d?b.getAttribute("data-amp-3p-sentinel"):"amp";a=Y(a,c,!0);for(var g,c=0;c<a.length;c++){var f=a[c];if(f.frame===b){g=f;break}}g||(g={frame:b,origin:e,events:Object.create(null)},a.push(g));return g.events}
- function pa(a){for(var b=E({sentinel:"unlisten"}),d=a.length-1;0<=d;d--){var e=a[d];if(!e.frame.contentWindow){a.splice(d,1);var c=e.events,g;for(g in c)c[g].splice(0,Infinity).forEach(function(a){a(b)})}}}
- function qa(a){if(!a.listeningFors){var b=function(b){if(b.data){var e=ra(b.data);if(e&&e.sentinel){var c;c=e.sentinel;var d=b.origin,f=b.source,h=Y(a,c);if(h){for(var k,p=0;p<h.length;p++){var q=h[p],m=q.frame.contentWindow;if(m)if("amp"===c){if(q.origin===d&&m==f){k=q;break}}else{var l;if(!(l=f==m))b:{for(l=f;l&&l!=l.parent;l=l.parent)if(l==m){l=!0;break b}l=!1}if(l){k=q;break}}else setTimeout(pa,0,h)}c=k?k.events:null}else c=h;var F=c;if(F){var t=F[e.type];if(t)for(t=t.slice(),c=0;c<t.length;c++)(0,t[c])(e,
- b.source,b.origin)}}}};a.addEventListener("message",b)}}function sa(a,b){function d(c,d,f){if(e||d==a.contentWindow)"unlisten"==c.sentinel?h():b(c,d,f)}var e,c="embed-size",g=a.ownerDocument.defaultView;qa(g);var g=oa(g,a),f=g[c]||(g[c]=[]),h;f.push(d);h=function(){if(d){var a=f.indexOf(d);-1<a&&f.splice(a,1);b=f=d=null}}}
- function ra(a){"string"==typeof a&&(a="{"==a.charAt(0)?R(a,function(a){D().warn("IFRAME-HELPER","Postmessage could not be parsed. Is it in a valid JSON format?",a)})||null:X(a)?na(a):null);return a};function Z(a){a=AMP.BaseElement.call(this,a)||this;a.j=null;return a}r(Z,AMP.BaseElement);Z.prototype.preconnectCallback=function(a){this.preconnect.url("https://gist.github.com/",a)};Z.prototype.isLayoutSupported=function(a){return"fixed-height"==a};Z.prototype.layoutCallback=function(){var a=this,b=la(this.win,this.element);this.applyFillContent(b);sa(b,function(b){a.changeHeight(b.height)});this.element.appendChild(b);this.j=b;return this.loadPromise(b)};
- Z.prototype.unlayoutCallback=function(){if(this.j){var a=this.j;a.parentElement&&a.parentElement.removeChild(a);this.j=null}return!0};(function(a){a.registerElement("amp-gist",Z)})(self.AMP);
- })});
- //# sourceMappingURL=amp-gist-0.1.js.map
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement