You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){vare;e=function(){functione(e,t){varn,r;this.options={target:"instafeed",get:"popular",resolution:"thumbnail",sortBy:"none",links:!0,mock:!1,useHttp:!1};if(typeofe=="object")for(nine)r=e[n],this.options[n]=r;this.context=t!=null?t:this,this.unique=this._genKey()}returne.prototype.hasNext=function(){returntypeofthis.context.nextUrl=="string"&&this.context.nextUrl.length>0},e.prototype.next=function(){returnthis.hasNext()?this.run(this.context.nextUrl):!1},e.prototype.run=function(t){varn,r,i;if(typeofthis.options.clientId!="string"&&typeofthis.options.accessToken!="string")thrownewError("Missing clientId or accessToken.");if(typeofthis.options.accessToken!="string"&&typeofthis.options.clientId!="string")thrownewError("Missing clientId or accessToken.");returnthis.options.before!=null&&typeofthis.options.before=="function"&&this.options.before.call(this),typeofdocument!="undefined"&&document!==null&&(i=document.createElement("script"),i.id="instafeed-fetcher",i.src=t||this._buildUrl(),n=document.getElementsByTagName("head"),n[0].appendChild(i),r="instafeedCache"+this.unique,window[r]=newe(this.options,this),window[r].unique=this.unique),!0},e.prototype.parse=function(e){vart,n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y,b,w,E,S,x,T,N,C,k,L,A,O,M,_,D;if(typeofe!="object"){if(this.options.error!=null&&typeofthis.options.error=="function")returnthis.options.error.call(this,"Invalid JSON data"),!1;thrownewError("Invalid JSON response")}if(e.meta.code!==200){if(this.options.error!=null&&typeofthis.options.error=="function")returnthis.options.error.call(this,e.meta.error_message),!1;thrownewError("Error from Instagram: "+e.meta.error_message)}if(e.data.length===0){if(this.options.error!=null&&typeofthis.options.error=="function")returnthis.options.error.call(this,"No images were returned from Instagram"),!1;thrownewError("No images were returned from Instagram")}this.options.success!=null&&typeofthis.options.success=="function"&&this.options.success.call(this,e),this.context.nextUrl="",e.pagination!=null&&(this.context.nextUrl=e.pagination.next_url);if(this.options.sortBy!=="none"){this.options.sortBy==="random"?M=["","random"]:M=this.options.sortBy.split("-"),O=M[0]==="least"?!0:!1;switch(M[1]){case"random":e.data.sort(function(){return.5-Math.random()});break;case"recent":e.data=this._sortBy(e.data,"created_time",O);break;case"liked":e.data=this._sortBy(e.data,"likes.count",O);break;case"commented":e.data=this._sortBy(e.data,"comments.count",O);break;default:thrownewError("Invalid option for sortBy: '"+this.options.sortBy+"'.")}}if(typeofdocument!="undefined"&&document!==null&&this.options.mock===!1){m=e.data,A=parseInt(this.options.limit,10),this.options.limit!=null&&m.length>A&&(m=m.slice(0,A)),u=document.createDocumentFragment(),this.options.filter!=null&&typeofthis.options.filter=="function"&&(m=this._filter(m,this.options.filter));if(this.options.template!=null&&typeofthis.options.template=="string"){f="",d="",w="",D=document.createElement("div");for(c=0,N=m.length;c<N;c++){h=m[c],p=h.images[this.options.resolution];if(typeofp!="object")throwo="No image found for resolution: "+this.options.resolution+".",newError(o);E=p.width,y=p.height,b="square",E>y&&(b="landscape"),E<y&&(b="portrait"),v=p.url,l=window.location.protocol.indexOf("http")>=0,l&&!this.options.useHttp&&(v=v.replace(/https?:\/\//,"//")),d=this._makeTemplate(this.options.template,{model:h,id:h.id,link:h.link,type:h.type,image:v,width:E,height:y,orientation:b,caption:this._getObjectProperty(h,"caption.text"),likes:h.likes.count,comments:h.comments.count,location:this._getObjectProperty(h,"location.name")}),f+=d}D.innerHTML=f,i=[],r=0,n=D.childNodes.length;while(r<n)i.push(D.childNodes[r]),r+=1;for(x=0,C=i.length;x<C;x++)L=i[x],u.appendChild(L)}elsefor(T=0,k=m.length;T<k;T++){h=m[T],g=document.createElement("img"),p=h.images[this.options.resolution];if(typeofp!="object")throwo="No image found for resolution: "+this.options.resolution+".",newError(o);v=p.url,l=window.location.protocol.indexOf("http")>=0,l&&!this.options.useHttp&&(v=v.replace(/https?:\/\//,"//")),g.src=v,this.options.links===!0?(t=document.createElement("a"),t.href=h.link,t.appendChild(g),u.appendChild(t)):u.appendChild(g)}_=this.options.target,typeof_=="string"&&(_=document.getElementById(_));if(_==null)throwo='No element with id="'+this.options.target+'" on page.',newError(o);_.appendChild(u),a=document.getElementsByTagName("head")[0],a.removeChild(document.getElementById("instafeed-fetcher")),S="instafeedCache"+this.unique,window[S]=void0;try{deletewindow[S]}catch(P){s=P}}returnthis.options.after!=null&&typeofthis.options.after=="function"&&this.options.after.call(this),!0},e.prototype._buildUrl=function(){vare,t,n;e="https://api.instagram.com/v1";switch(this.options.get){case"popular":t="media/popular";break;case"tagged":if(!this.options.tagName)thrownewError("No tag name specified. Use the 'tagName' option.");t="tags/"+this.options.tagName+"/media/recent";break;case"location":if(!this.options.locationId)thrownewError("No location specified. Use the 'locationId' option.");t="locations/"+this.options.locationId+"/media/recent";break;case"user":if(!this.options.userId)thrownewError("No user specified. Use the 'userId' option.");t="users/"+this.options.userId+"/media/recent";break;default:thrownewError("Invalid option for get: '"+this.options.get+"'.")}returnn=e+"/"+t,this.options.accessToken!=null?n+="?access_token="+this.options.accessToken:n+="?client_id="+this.options.clientId,this.options.limit!=null&&(n+="&count="+this.options.limit),n+="&callback=instafeedCache"+this.unique+".parse",n},e.prototype._genKey=function(){vare;returne=function(){return((1+Math.random())*65536|0).toString(16).substring(1)},""+e()+e()+e()+e()},e.prototype._makeTemplate=function(e,t){varn,r,i,s,o;r=/(?:\{{2})([\w\[\]\.]+)(?:\}{2})/,n=e;while(r.test(n))s=n.match(r)[1],o=(i=this._getObjectProperty(t,s))!=null?i:"",n=n.replace(r,function(){return""+o});returnn},e.prototype._getObjectProperty=function(e,t){varn,r;t=t.replace(/\[(\w+)\]/g,".$1"),r=t.split(".");while(r.length){n=r.shift();if(!(e!=null&&nine))returnnull;e=e[n]}returne},e.prototype._sortBy=function(e,t,n){varr;returnr=function(e,r){vari,s;returni=this._getObjectProperty(e,t),s=this._getObjectProperty(r,t),n?i>s?1:-1:i<s?1:-1},e.sort(r.bind(this)),e},e.prototype._filter=function(e,t){varn,r,i,s,o;n=[],r=function(e){if(t(e))returnn.push(e)};for(i=0,o=e.length;i<o;i++)s=e[i],r(s);returnn},e}(),function(e,t){returntypeofdefine=="function"&&define.amd?define([],t):typeofmodule=="object"&&module.exports?module.exports=t():e.Instafeed=t()}(this,function(){returne})}).call(this);