From 0931b4c97c0bb5081c6713a7d437ff9d630dac41 Mon Sep 17 00:00:00 2001 From: Dugan Knoll Date: Mon, 9 Jun 2014 12:38:01 -0700 Subject: [PATCH] user search should now work. --- js/instagram.js | 5 +++++ js/instagram.min.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/js/instagram.js b/js/instagram.js index 40643a0..b2a91ec 100644 --- a/js/instagram.js +++ b/js/instagram.js @@ -148,6 +148,11 @@ var instagramFeed = Ractive.extend({ this.dataCallback = function(){}; } + if(options.method != undefined){ + this.data.method = options.method; + } + + //Init search if(options.search == undefined){ console.log('No Hashtag Provided'); diff --git a/js/instagram.min.js b/js/instagram.min.js index 360c609..14dec9f 100644 --- a/js/instagram.min.js +++ b/js/instagram.min.js @@ -1,2 +1,2 @@ /*! instagram 2014-06-09 */ -var instagramFeed=Ractive.extend({lazy:!0,makeQuery:function(a){var b,c,d,e;switch(b="https://api.instagram.com/v1",this.data.method){case"popular":c="media/popular";break;case"tags":if("string"!=typeof this.data.search)throw new Error("No tag name specified. Use the 'tagName' option.");c="tags/"+this.data.search+"/media/recent";break;case"location":if("number"!=typeof this.data.location)throw new Error("No location specified. Use the 'locationId' option.");c="locations/"+this.data.search+"/media/recent";break;case"user":if("number"!=typeof this.data.search)throw new Error("No user specified. Use the 'userId' option.");if("string"!=typeof this.data.clientID)throw new Error("Invalid access token. Make sure you have a valid Instagram API access token.");c="users/"+this.data.search+"/media/recent",console.log(c);break;default:throw new Error("Invalid option for get: '"+this.data.get+"'.")}switch(d=""+b+"/"+c,null!=this.data.clientID&&(d+="?client_id="+this.data.clientID),null!=this.data.postsPerPage&&(d+="&count="+this.data.postsPerPage),a){case"before":e="&callback=instagramReceiverFrontAppend&min_id="+this.data.instagramData.pagination.min_tag_id;break;case"after":e="&callback=instagramReceiverRearAppend&max_id="+this.data.instagramData.pagination.next_max_tag_id;break;case"replace":e="&callback=instagramReceiverReplace"}return console.log(d+e),d+e},load:function(a,b){if(void 0!==b&&(this.dataCallback=b),"after"==a&&this.data.endOfFeed)return!1;if(1==this.data.loading)return console.log("already loading"),!1;this.set("loading",!0),console.log("calling IG API");var c=document.createElement("script");c.id="instagram-script-loader",c.onerror=function(){console.log("unable to reach IG API")},c.src=this.makeQuery(a);var d=document.getElementsByTagName("script")[0];d.parentNode.insertBefore(c,d)},getNewer:function(){this.load("before")},getOlder:function(){this.load("after")},init:function(a){return this.data.instagramData=[],this.data.current=-1,this.data.min=0,this.data.max=0,this.data.lightbox=!1,this.data.endOfFeed=!1,this.data.postsPerPage=6,this.data.method="tags",this.data.message="",void 0==a.clientID?(console.log("No Client ID Provided"),this.success=!1,!1):(this.data.clientID=a.clientID,this.dataCallback=void 0!=a.dataCallback?a.dataCallback:function(){},void 0==a.search?(console.log("No Hashtag Provided"),this.success=!1,!1):(this.data.search=this.data.searched=a.search,this.validateData=function(a){return this.set("loading",!1),400==a.meta.code?(this.error=!0,this.set("message","Invalid Client ID"),this.dataCallback(a),!1):200==a.meta.code?(this.error=!1,!0):(this.error=!0,this.set("message","Error retrieving IG data."),this.dataCallback(a),console.log(a),!1)},this.replaceData=function(a){void 0==a.data?this.set("message","Sorry no results for #"+this.data.search+" :["):(this.set("instagramData",a),this.set("searched",this.data.search),this.set("message",""),this.set("endOfFeed",!1)),this.dataCallback(a)},window.instagramReceiverReplace=function(a){return function(b){a.validateData(b)&&a.replaceData(b)}}(this),this.frontAppend=function(a){0==a.data.length?console.log("Nothing to append"):(console.log("front Append"),this.set("instagramData.data",a.data.concat(this.data.instagramData.data)),this.data.instagramData.pagination.min_tag_id=a.pagination.min_tag_id),this.dataCallback(a)},window.instagramReceiverFrontAppend=function(a){return function(b){a.validateData(b)&&a.frontAppend(b)}}(this),this.rearAppend=function(a){console.log("rear Append"),this.set("instagramData.data",this.data.instagramData.data.concat(a.data)),void 0===a.pagination.next_max_tag_id?this.set("endOfFeed",!0):this.data.instagramData.pagination.next_max_tag_id=a.pagination.next_max_tag_id,this.dataCallback(a)},window.instagramReceiverRearAppend=function(a){return function(b){a.validateData(b)&&a.rearAppend(b)}}(this),this.observe("search",function(){this.load("replace")}),void this.load("replace")))}}); \ No newline at end of file +var instagramFeed=Ractive.extend({lazy:!0,makeQuery:function(a){var b,c,d,e;switch(b="https://api.instagram.com/v1",this.data.method){case"popular":c="media/popular";break;case"tags":if("string"!=typeof this.data.search)throw new Error("No tag name specified. Use the 'tagName' option.");c="tags/"+this.data.search+"/media/recent";break;case"location":if("number"!=typeof this.data.location)throw new Error("No location specified. Use the 'locationId' option.");c="locations/"+this.data.search+"/media/recent";break;case"user":if("number"!=typeof this.data.search)throw new Error("No user specified. Use the 'userId' option.");if("string"!=typeof this.data.clientID)throw new Error("Invalid access token. Make sure you have a valid Instagram API access token.");c="users/"+this.data.search+"/media/recent",console.log(c);break;default:throw new Error("Invalid option for get: '"+this.data.get+"'.")}switch(d=""+b+"/"+c,null!=this.data.clientID&&(d+="?client_id="+this.data.clientID),null!=this.data.postsPerPage&&(d+="&count="+this.data.postsPerPage),a){case"before":e="&callback=instagramReceiverFrontAppend&min_id="+this.data.instagramData.pagination.min_tag_id;break;case"after":e="&callback=instagramReceiverRearAppend&max_id="+this.data.instagramData.pagination.next_max_tag_id;break;case"replace":e="&callback=instagramReceiverReplace"}return console.log(d+e),d+e},load:function(a,b){if(void 0!==b&&(this.dataCallback=b),"after"==a&&this.data.endOfFeed)return!1;if(1==this.data.loading)return console.log("already loading"),!1;this.set("loading",!0),console.log("calling IG API");var c=document.createElement("script");c.id="instagram-script-loader",c.onerror=function(){console.log("unable to reach IG API")},c.src=this.makeQuery(a);var d=document.getElementsByTagName("script")[0];d.parentNode.insertBefore(c,d)},getNewer:function(){this.load("before")},getOlder:function(){this.load("after")},init:function(a){return this.data.instagramData=[],this.data.current=-1,this.data.min=0,this.data.max=0,this.data.lightbox=!1,this.data.endOfFeed=!1,this.data.postsPerPage=6,this.data.method="tags",this.data.message="",void 0==a.clientID?(console.log("No Client ID Provided"),this.success=!1,!1):(this.data.clientID=a.clientID,this.dataCallback=void 0!=a.dataCallback?a.dataCallback:function(){},void 0!=a.method&&(this.data.method=a.method),void 0==a.search?(console.log("No Hashtag Provided"),this.success=!1,!1):(this.data.search=this.data.searched=a.search,this.validateData=function(a){return this.set("loading",!1),400==a.meta.code?(this.error=!0,this.set("message","Invalid Client ID"),this.dataCallback(a),!1):200==a.meta.code?(this.error=!1,!0):(this.error=!0,this.set("message","Error retrieving IG data."),this.dataCallback(a),console.log(a),!1)},this.replaceData=function(a){void 0==a.data?this.set("message","Sorry no results for #"+this.data.search+" :["):(this.set("instagramData",a),this.set("searched",this.data.search),this.set("message",""),this.set("endOfFeed",!1)),this.dataCallback(a)},window.instagramReceiverReplace=function(a){return function(b){a.validateData(b)&&a.replaceData(b)}}(this),this.frontAppend=function(a){0==a.data.length?console.log("Nothing to append"):(console.log("front Append"),this.set("instagramData.data",a.data.concat(this.data.instagramData.data)),this.data.instagramData.pagination.min_tag_id=a.pagination.min_tag_id),this.dataCallback(a)},window.instagramReceiverFrontAppend=function(a){return function(b){a.validateData(b)&&a.frontAppend(b)}}(this),this.rearAppend=function(a){console.log("rear Append"),this.set("instagramData.data",this.data.instagramData.data.concat(a.data)),void 0===a.pagination.next_max_tag_id?this.set("endOfFeed",!0):this.data.instagramData.pagination.next_max_tag_id=a.pagination.next_max_tag_id,this.dataCallback(a)},window.instagramReceiverRearAppend=function(a){return function(b){a.validateData(b)&&a.rearAppend(b)}}(this),this.observe("search",function(){this.load("replace")}),void this.load("replace")))}}); \ No newline at end of file