Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

gets all stackexchange sites

  • Loading branch information...
commit bb07fd5c557d9668e293bb02216ffedd0e4a20d9 1 parent cb4005e
@weilu authored
Showing with 76 additions and 5 deletions.
  1. +50 −5 js/popup.js
  2. +26 −0 js/sites.js
View
55 js/popup.js
@@ -1,21 +1,59 @@
$(function(){
+
Stacker = {};
+ Stacker.sites = ["stackoverflow", "serverfault", "superuser", "meta.stackoverflow", "webapps",
+ "meta.webapps", "gaming", "meta.gaming", "webmasters", "meta.webmasters",
+ "cooking", "meta.cooking", "gamedev", "meta.gamedev", "photo",
+ "meta.photo", "stats", "meta.stats", "math", "meta.math",
+ "diy", "meta.diy", "meta.superuser", "meta.serverfault", "gis",
+ "meta.gis", "tex", "meta.tex", "askubuntu", "meta.askubuntu",
+ "money", "meta.money", "english", "meta.english", "stackapps",
+ "ux", "meta.ux", "unix", "meta.unix", "wordpress",
+ "meta.wordpress", "cstheory", "meta.cstheory", "apple", "meta.apple",
+ "rpg", "meta.rpg", "bicycles", "meta.bicycles", "programmers",
+ "meta.programmers", "electronics", "meta.electronics", "android", "meta.android",
+ "answers.onstartups", "meta.answers.onstartups", "boardgames", "meta.boardgames", "physics",
+ "meta.physics", "homebrew", "meta.homebrew", "security", "meta.security",
+ "writers", "meta.writers", "avp", "meta.avp", "graphicdesign",
+ "meta.graphicdesign", "dba", "meta.dba", "scifi", "meta.scifi",
+ "codereview", "meta.codereview", "codegolf", "meta.codegolf", "quant",
+ "meta.quant", "pm", "meta.pm", "skeptics", "meta.skeptics",
+ "fitness", "meta.fitness", "drupal", "meta.drupal", "mechanics",
+ "meta.mechanics", "parenting", "meta.parenting", "sharepoint", "meta.sharepoint",
+ "music", "meta.music", "sqa", "meta.sqa", "judaism",
+ "meta.judaism", "german", "meta.german", "japanese", "meta.japanese",
+ "astronomy", "meta.astronomy", "philosophy", "meta.philosophy", "gardening",
+ "meta.gardening", "travel", "meta.travel", "productivity", "meta.productivity",
+ "crypto", "meta.crypto", "literature", "meta.literature", "dsp",
+ "meta.dsp", "french", "meta.french", "christianity", "meta.christianity",
+ "bitcoin", "meta.bitcoin", "linguistics", "meta.linguistics", "theoreticalphysics",
+ "meta.theoreticalphysics", "hermeneutics", "meta.hermeneutics", "history", "meta.history",
+ "economics", "meta.economics", "healthcareit", "meta.healthcareit", "bricks",
+ "meta.bricks", "firearms", "meta.firearms", "spanish", "meta.spanish",
+ "scicomp", "meta.scicomp", "movies", "meta.movies", "chinese",
+ "meta.chinese", "biology", "meta.biology", "poker", "meta.poker",
+ "mathematica", "meta.mathematica", "cogsci", "meta.cogsci", "outdoors",
+ "meta.outdoors", "smugmug", "meta.smugmug", "martialarts", "meta.martialarts",
+ "sports", "meta.sports", "academia", "meta.academia", "cs",
+ "meta.cs"];
Stacker.AppView = Backbone.View.extend({
+
el: $('#stacker'),
- initialize: function(){
- this.feeds = new Stacker.Feeds({site: "stackoverflow", userIds: [429288,859536]});
- this.feeds.fetch();
- console.debug("done fetching")
+
+ initialize: function(options){
+ this.feeds = options.feeds;
},
render: function(){
console.debug("start rendering")
var view = this;
+ console.debug( view.feeds.size() );
view.feeds.each(function(feed){
view.renderFeed(feed);
});
console.debug("done rendering")
+ return this;
},
renderFeed: function(feed){
@@ -60,5 +98,12 @@ $(function(){
}
});
- window.view = new Stacker.AppView().render();
+ window.feeds = new Stacker.Feeds({site: "stackoverflow", userIds: [429288,859536]});
+ window.view = new Stacker.AppView({ feeds: window.feeds });
+
+ window.feeds.fetch({
+ success: function(){
+ window.view = window.view.render();
+ }
+ });
});
View
26 js/sites.js
@@ -0,0 +1,26 @@
+// window.Stacker = window.Stacker ? window.Stacker : {};
+
+function getSites(page, sites){
+ var req = new XMLHttpRequest();
+ req.open("GET", "http://api.stackexchange.com/2.0/sites?pagesize=100&page=" + page, true);
+ var response;
+
+ req.onload = function(){
+ response = JSON.parse(req.response);
+
+ var newSites = _.pluck(response.items, "api_site_parameter");
+ sites = sites.concat(newSites);
+
+ // console.debug("2 sites", sites);
+
+ if(response.has_more){
+ getSites(page+1, sites);
+ }else{
+ window.Stacker.sites = sites;
+ // console.debug("all sites: ", window.Stacker.sites);
+ }
+ };
+req.send(null);
+}
+
+// getSites(1, []);
Please sign in to comment.
Something went wrong with that request. Please try again.