vendor: 5,187 bytes, lines 1-5
1/** 2 * SuperGif 3 * Copyright (c) 2011 Shachaf Ben-Kiki 4 */ 5!function(a,b){"function"==typeof define&&define.amd?define([],b):"object"==typeof exports?module.exports=b():a.SuperGif=b()}(this,function(){var a=function(a){return a.reduce(function(a,b){return 2*a+b},0)},b=function(a){for(var b=[],c=7;c>=0;c--)b.push(!!(a&1<<c));return b},c=function(a){this.data=a,this.len=this.data.length,this.pos=0,this.readByte=function(){if(this.pos>=this.data.length)throw new Error("Attempted to read past end of stream.");return a instanceof Uint8Array?a[this.pos++]:255&a.charCodeAt(this.pos++)},this.readBytes=function(a){for(var b=[],c=0;c<a;c++)b.push(this.readByte());return b},this.read=function(a){for(var b="",c=0;c<a;c++)b+=String.fromCharCode(this.readByte());return b},this.readUnsigned=function(){var a=this.readBytes(2);return(a[1]<<8)+a[0]}},d=function(a,b){for(var k,l,c=0,d=function(a){for(var d=0,e=0;e<a;e++)b.charCodeAt(c>>3)&1<<(7&c)&&(d|=1<<e),c++;return d},e=[],f=1<<a,g=f+1,h=a+1,i=[],j=function(){i=[],h=a+1;for(var b=0;b<f;b++)i[b]=[b];i[f]=[],i[g]=null};;)if(l=k,k=d(h),k!==f){if(k===g)break;if(k<i.length)l!==f&&i.push(i[l].concat(i[k][0]));else{if(k!==i.length)throw new Error("Invalid LZW code.");i.push(i[l].concat(i[l][0]))}e.push.apply(e,i[k]),i.length===1<<h&&h<12&&h++}else j();return e},e=function(c,e){e||(e={});var f=function(a){for(var b=[],d=0;d<a;d++)b.push(c.readBytes(3));return b},g=function(){var a,b;b="";do a=c.readByte(),b+=c.read(a);while(0!==a);return b},h=function(){var d={};if(d.sig=c.read(3),d.ver=c.read(3),"GIF"!==d.sig)throw new Error("Not a GIF file.");d.width=c.readUnsigned(),d.height=c.readUnsigned();var g=b(c.readByte());d.gctFlag=g.shift(),d.colorRes=a(g.splice(0,3)),d.sorted=g.shift(),d.gctSize=a(g.splice(0,3)),d.bgColor=c.readByte(),d.pixelAspectRatio=c.readByte(),d.gctFlag&&(d.gct=f(1<<d.gctSize+1)),e.hdr&&e.hdr(d)},i=function(d){var f=function(d){var g=(c.readByte(),b(c.readByte()));d.reserved=g.splice(0,3),d.disposalMethod=a(g.splice(0,3)),d.userInput=g.shift(),d.transparencyGiven=g.shift(),d.delayTime=c.readUnsigned(),d.transparencyIndex=c.readByte(),d.terminator=c.readByte(),e.gce&&e.gce(d)},h=function(a){a.comment=g(),e.com&&e.com(a)},i=function(a){c.readByte();a.ptHeader=c.readBytes(12),a.ptData=g(),e.pte&&e.pte(a)},j=function(a){var b=function(a){c.readByte();a.unknown=c.readByte(),a.iterations=c.readUnsigned(),a.terminator=c.readByte(),e.app&&e.app.NETSCAPE&&e.app.NETSCAPE(a)},d=function(a){a.appData=g(),e.app&&e.app[a.identifier]&&e.app[a.identifier](a)};c.readByte();switch(a.identifier=c.read(8),a.authCode=c.read(3),a.identifier){case"NETSCAPE":b(a);break;default:d(a)}},k=function(a){a.data=g(),e.unknown&&e.unknown(a)};switch(d.label=c.readByte(),d.label){case 249:d.extType="gce",f(d);break;case 254:d.extType="com",h(d);break;case 1:d.extType="pte",i(d);break;case 255:d.extType="app",j(d);break;default:d.extType="unknown",k(d)}},j=function(h){var i=function(a,b){for(var c=new Array(a.length),d=a.length/b,e=function(d,e){var f=a.slice(e*b,(e+1)*b);c.splice.apply(c,[d*b,b].concat(f))},f=[0,4,2,1],g=[8,8,4,2],h=0,i=0;i<4;i++)for(var j=f[i];j<d;j+=g[i])e(j,h),h++;return c};h.leftPos=c.readUnsigned(),h.topPos=c.readUnsigned(),h.width=c.readUnsigned(),h.height=c.readUnsigned();var j=b(c.readByte());h.lctFlag=j.shift(),h.interlaced=j.shift(),h.sorted=j.shift(),h.reserved=j.splice(0,2),h.lctSize=a(j.splice(0,3)),h.lctFlag&&(h.lct=f(1<<h.lctSize+1)),h.lzwMinCodeSize=c.readByte();var k=g();h.pixels=d(h.lzwMinCodeSize,k),h.interlaced&&(h.pixels=i(h.pixels,h.width)),e.img&&e.img(h)},k=function(){var a={};switch(a.sentinel=c.readByte(),String.fromCharCode(a.sentinel)){case"!":a.type="ext",i(a);break;case",":a.type="img",j(a);break;case";":a.type="eof",e.eof&&e.eof(a);break;default:throw new Error("Unknown block: 0x"+a.sentinel.toString(16))}"eof"!==a.type&&setTimeout(k,0)},l=function(){h(),setTimeout(k,0)};l()},f=function(a){var b={vp_l:0,vp_t:0,vp_w:null,vp_h:null,c_w:null,c_h:null};for(var d in a)b[d]=a[d];b.vp_w&&b.vp_h&&(b.is_vp=!0);var f,g,h=null,i=!1,j=null,k=null,l=null,m=null,n=null,o=null,p=null,q=!0,r=!0,s=!1,t=[],u=[],v=b.gif;"undefined"==typeof b.auto_play&&(b.auto_play=!v.getAttribute("rel:auto_play")||"1"==v.getAttribute("rel:auto_play"));var W,X,Y,Z,w=b.hasOwnProperty("on_end")?b.on_end:null,x=b.hasOwnProperty("loop_delay")?b.loop_delay:0,y=b.hasOwnProperty("loop_mode")?b.loop_mode:"auto",z=!b.hasOwnProperty("draw_while_loading")||b.draw_while_loading,A=!!z&&(!b.hasOwnProperty("show_progress_bar")||b.show_progress_bar),B=b.hasOwnProperty("progressbar_height")?b.progressbar_height:25,C=b.hasOwnProperty("progressbar_background_color")?b.progressbar_background_color:"rgba(255,255,255,0.4)",D=b.hasOwnProperty("progressbar_foreground_color")?b.progressbar_foreground_color:"rgba(255,0,22,.8)",E=function(){j=null,k=null,n=l,l=null,o=null},F=function(){try{e(f,T)}catch(a){K("parse")}},H=function(a,b){W.width=a*V(),W.height=b*V(),Y.style.minWidth=a*V()+"px",Z.width=a,Z.height=b,Z.style.width=a+"px",Z.style.height=b+"px",Z.getContext("2d").setTransform(1,0,0,1,0,0)},I=function(a,b){return u[a]?("undefined"!=typeof b.x&&(u[a].x=b.x),void("undefined"!=typeof b.y&&
5(u[a].y=b.y))):void(u[a]=b)},J=function(a,c,d){if(d&&A){var f,g,h,i,e=B;if(b.is_vp){s?(h=(b.vp_t+b.vp_h-e)/V(),e/=V(),f=b.vp_l/V(),g=f+a/c*(b.vp_w/V()),i=W.width/V()):(h=b.vp_t+b.vp_h-e,e=e,f=b.vp_l,g=f+a/c*b.vp_w,i=W.width)}else h=(W.height-e)/(s?V():1),g=a/c*W.width/(s?V():1),i=W.width/(s?V():1),e/=s?V():1;X.fillStyle=C,X.fillRect(g,h,i-g,e),X.fillStyle=D,X.fillRect(0,h,g,e)}},K=function(a){var c=function(){X.fillStyle="black",X.fillRect(0,0,b.c_w?b.c_w:g.width,b.c_h?b.c_h:g.height),X.strokeStyle="red",X.lineWidth=3,X.moveTo(0,0),X.lineTo(b.c_w?b.c_w:g.width,b.c_h?b.c_h:g.height),X.moveTo(0,b.c_h?b.c_h:g.height),X.lineTo(b.c_w?b.c_w:g.width,0),X.stroke()};h=a,g={width:v.width,height:v.height},t=[],c()},L=function(a){g=a,H(g.width,g.height)},M=function(a){N(),E(),j=a.transparencyGiven?a.transparencyIndex:null,k=a.delayTime,l=a.disposalMethod},N=function(){o&&(t.push({data:o.getImageData(0,0,g.width,g.height),delay:k}),u.push({x:0,y:0}))},O=function(a){o||(o=Z.getContext("2d"));var c=t.length,d=a.lctFlag?a.lct:g.gct;c>0&&(3===n?null!==m?o.putImageData(t[m].data,0,0):o.clearRect(p.leftPos,p.topPos,p.width,p.height):m=c-1,2===n&&o.clearRect(p.leftPos,p.topPos,p.width,p.height));var e=o.getImageData(a.leftPos,a.topPos,a.width,a.height);a.pixels.forEach(function(a,b){a!==j&&(e.data[4*b+0]=d[a][0],e.data[4*b+1]=d[a][1],e.data[4*b+2]=d[a][2],e.data[4*b+3]=255)}),o.putImageData(e,a.leftPos,a.topPos),s||(X.scale(V(),V()),s=!0),z&&(X.drawImage(Z,0,0),z=b.auto_play),p=a},P=function(){var a=-1,c=0,f=function(){var b=r?1:-1;return(a+b+t.length)%t.length},g=function(b){a+=b,j()},i=function(){var b=!1,d=function(){null!==w&&w(v),c++,y!==!1||c<0?e():(b=!1,q=!1)},e=function(){if(b=q){g(1);var c=10*t[a].delay;c||(c=100);var h=f();0===h?(c+=x,setTimeout(d,c)):setTimeout(e,c)}};return function(){b||setTimeout(e,0)}}(),j=function(){var b;a=parseInt(a,10),a>t.length-1&&(a=0),a<0&&(a=0),b=u[a],Z.getContext("2d").putImageData(t[a].data,b.x,b.y),X.globalCompositeOperation="copy",X.drawImage(Z,0,0)},k=function(){q=!0,i()},l=function(){q=!1};return{init:function(){h||(b.c_w&&b.c_h||X.scale(V(),V()),b.auto_play?i():(a=0,j()))},step:i,play:k,pause:l,playing:q,move_relative:g,current_frame:function(){return a},length:function(){return t.length},move_to:function(b){a=b,j()}}}(),Q=function(a){J(f.pos,f.data.length,a)},R=function(){},S=function(a,b){return function(c){a(c),Q(b)}},T={hdr:S(L),gce:S(M),com:S(R),app:{NETSCAPE:S(R)},img:S(O,!0),eof:function(a){N(),Q(!1),b.c_w&&b.c_h||(W.width=g.width*V(),W.height=g.height*V()),P.init(),i=!1,_&&_(v)}},U=function(){var a=v.parentNode,c=document.createElement("div");W=document.createElement("canvas"),X=W.getContext("2d"),Y=document.createElement("div"),Z=document.createElement("canvas"),c.width=W.width=v.width,c.height=W.height=v.height,Y.style.minWidth=v.width+"px",c.className="jsgif",Y.className="jsgif_toolbar",c.appendChild(W),c.appendChild(Y),a.insertBefore(c,v),a.removeChild(v),b.c_w&&b.c_h&&H(b.c_w,b.c_h),$=!0},V=function(){var a;return a=b.max_width&&g&&g.width>b.max_width?b.max_width/g.width:1},$=!1,_=!1,aa=function(a){return!i&&(_=!!a&&a,i=!0,t=[],E(),m=null,n=null,o=null,p=null,!0)};return{play:P.play,pause:P.pause,move_relative:P.move_relative,move_to:P.move_to,get_playing:function(){return q},get_canvas:function(){return W},get_canvas_scale:function(){return V()},get_loading:function(){return i},get_auto_play:function(){return b.auto_play},get_length:function(){return P.length()},get_current_frame:function(){return P.current_frame()},load_url:function(a,b){if(aa(b)){var d=new XMLHttpRequest;d.open("GET",a,!0),"overrideMimeType"in d?d.overrideMimeType("text/plain; charset=x-user-defined"):"responseType"in d?d.responseType="arraybuffer":d.setRequestHeader("Accept-Charset","x-user-
5defined"),d.onloadstart=function(){$||U()},d.onload=function(a){200!=this.status&&K("xhr - response"),"response"in this||(this.response=new VBArray(this.responseText).toArray().map(String.fromCharCode).join(""));var b=this.response;b.toString().indexOf("ArrayBuffer")>0&&(b=new Uint8Array(b)),f=new c(b),setTimeout(F,0)},d.onprogress=function(a){a.lengthComputable&&J(a.loaded,a.total,!0)},d.onerror=function(){K("xhr")},d.send()}},load:function(a){this.load_url(v.getAttribute("rel:animated_src")||v.src,a)},load_raw:function(a,b){aa(b)&&($||U(),f=new c(a),setTimeout(F,0))},set_frame_offset:I}};return f}); 6 7jQuery(document).ready(function($) { 8 9 $('.agggif-image').each(function() { 10 11 var t = this, 12 el_container = $(t).parents('.agggif-container'), 13 el_overlay = el_container.find('.agggif-overlay'), 14 preview_canvas = el_container.find('.agggif-preview'), 15 preview_canvas_ctx = preview_canvas[0].getContext('2d'), 16 preview_img = new Image(); 17 18 var sup_gif = new SuperGif({ 19 gif: t, 20 show_progress_bar: false 21 }); 22 23 if(el_container.hasClass('agggif-autoplay')) { 24 25 sup_gif.load(function(el) { 26 el_container.removeClass('agggif-loading agggif-autoplay').addClass('agggif-loaded agggif-playing'); 27 }); 28 29 } else { 30 31 preview_img.src = $(t).attr('rel:animated_src'); 32 preview_img.onload = function () { 33 var w = preview_canvas.attr('width'), 34 h = preview_canvas.attr('height'); 35 preview_canvas_ctx.drawImage(preview_img, 0, 0, w, h, 0, 0, w, h); 36 el_container.addClass('agggif-preview-loaded'); 37 }; 38 39 } 40 41 el_overlay.click(function(e) { 42 43 e.preventDefault(); 44 45 if (!el_container.hasClass('agggif-loaded')) { 46 47 if(el_container.hasClass('agggif-preview-loaded')) { 48 49 sup_gif.load(function(el) { 50 el_container.removeClass('agggif-loading agggif-preview-loaded').addClass('agggif-loaded agggif-playing'); 51 sup_gif.play(); 52 }); 53 54 el_container.addClass('agggif-loading'); 55 56 } 57 58 return; 59 60 } 61 62 var cl = 'agggif-playing'; 63 64 if (el_container.hasClass(cl)) { 65 sup_gif.pause(); 66 el_container.removeClass(cl); 67 } else { 68 sup_gif.play(); 69 el_container.addClass(cl); 70 } 71 72 }); 73 74 }); 75 76});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.