Permalink
Browse files

Renamed api route.

  • Loading branch information...
1 parent 54eaaeb commit 9a43d08e0e072e6dfd4285467250991afcae8d19 @akoenig akoenig committed May 27, 2012
Showing with 26 additions and 9 deletions.
  1. +2 −2 src/app/api/meetups.js
  2. +2 −2 src/app/public/javascripts/backend.js
  3. +22 −5 src/app/public/javascripts/chapters.js
View
@@ -18,11 +18,11 @@ var _ = require('underscore');
module.exports = function (app, repo) {
- app.get('/meetups', function (req, res) {
+ app.get('/chapters', function (req, res) {
res.send(repo.index);
});
- app.get('/meetup/:id', function (req, res) {
+ app.get('/chapter/:id', function (req, res) {
res.send(repo.get(req.params.id));
});
@@ -17,8 +17,8 @@ define([
function () {
return (function () {
var urls = {
- meetups: '/meetups',
- meetup: '/meetup'
+ chapters: '/chapters',
+ chapter: '/chapter'
};
return {
@@ -18,27 +18,44 @@ define([
function (backend) {
return (function () {
- var data = null,
+ var ids = null,
index = 0;
return {
load : function () {
var deferred = $.Deferred();
- backend.get.allMeetups().then(function (ids) {
- data = ids;
+ backend.get.allMeetups().then(function (chapterIds) {
+ ids = chapterIds;
deferred.resolve();
});
return deferred.promise();
},
hasNext : function () {
- return (data[index + 1]);
+ return (ids[index + 1]);
},
hasPrevious : function () {
- return (data[index - 1]);
+ return (ids[index - 1]);
},
+ get : function (id) {
+ var deferred = $.Deferred();
+
+ var position = (_.indexOf(ids, id) !== -1);
+
+ if (position) {
+ index = position;
+
+ backend.get.oneMeetup(id).then(function (chapter) {
+ data[index] = chapter;
+ deferred.resolve(data[index]);
+ });
+ }
+
+ return deferred.promise();
+ },
+
getCurrent : function () {
var deferred = $.Deferred();

0 comments on commit 9a43d08

Please sign in to comment.