@@ -47,7 +47,6 @@ $(function () {
4747 }
4848 // }}}
4949
50-
5150 // Tumblr client
5251 // -------------
5352 // {{{ 8<
@@ -179,6 +178,48 @@ $(function () {
179178 });
180179 // }}}
181180
181+ // Coderwall client
182+ // ----------------
183+ // {{{ 8<
184+ x.Badges = Backbone.Collection.extend({
185+ url: "http://coderwall.com/xonecas.json",
186+
187+ parse: function (res, xhr) {
188+ return res.data.badges;
189+ },
190+
191+ sync: function (model, method, options) {
192+ var params = _.extend(options, {
193+ "url": this.url,
194+ "dataType": "jsonp"
195+ });
196+
197+ return $.ajax(params);
198+ }
199+ });
200+
201+ x.BadgesView = Backbone.View.extend({
202+ collection: new x.Badges(),
203+ el: $("#coderwall"),
204+ template: $('#_coderwall').html(),
205+
206+ initialize: function () {
207+ _.bindAll(this, 'render');
208+ this.collection.bind('reset', this.render);
209+ this.collection.fetch();
210+ },
211+
212+ render: function () {
213+ var that = this;
214+
215+ this.el.empty();
216+ this.collection.each(function (badge) {
217+ that.el.append(_.template(that.template, badge.toJSON()));
218+ });
219+ }
220+ });
221+ // }}}
222+
182223 x.IndexView = Backbone.View.extend({
183224 el: $(document),
184225
@@ -189,6 +230,7 @@ $(function () {
189230 initialize: function () {
190231 this.blog = new x.BlogView();
191232 this.tweet = new x.TweetsView();
233+ this.badges = new x.BadgesView();
192234 },
193235
194236 keypressRouter: function (ev) {