switch to jquery.couch2 for deffereds

This commit is contained in:
Max Ogden
2011-06-30 19:56:15 -07:00
parent d74b6d749d
commit 806ffee304
5 changed files with 112 additions and 244 deletions

View File

@@ -3,13 +3,6 @@ var app = {
container: 'main_content'
};
app.reqOpts = {
uri: app.baseURL + "api",
method: "GET",
headers: {"Content-type": "application/json"},
cache: true
}
app.handler = function(route) {
route = route.path.slice(1, route.path.length);
if (route.length < 1) route = "home";
@@ -17,11 +10,43 @@ app.handler = function(route) {
window.scrollTo(0, 0);
};
// var query = {
// "descending" : true,
// "limit" : 20,
// success: function( data ) {
// if( data.rows.length === 0 ) {
// monocles.oldestDoc = false;
// monocles.hideLoader();
// posts = [];
// } else {
// monocles.oldestDoc = data.rows[ data.rows.length - 1 ];
// posts = data.rows;
// }
// renderStream();
// }
// }
//
// if ( opts.offsetDoc ) {
// $.extend( query, {
// "startkey": opts.offsetDoc.key,
// "startkey_docid": opts.offsetDoc.id,
// "skip": 1
// })
// }
app.after = {
home: function() {
$.request(app.reqOpts, removalist.gotDb);
couch.request({url: app.baseURL + "api"}).then(function(db) {
removalist.gotDb(db);
couch.request({url: app.baseURL + 'api/headers'}).then(function(headers) {
removalist.gotHeaders(headers);
couch.request({url: app.baseURL + 'api/rows?limit=10'}).then(function(response) {
removalist.renderRows(response.rows);
});
});
});
$( '.csv' ).live('click', ( function( e ) {
window.location.href = app.csvUrl;
e.preventDefault();
@@ -29,12 +54,12 @@ app.after = {
}
}
app.s = $.sammy(function () {
app.sammy = $.sammy(function () {
this.get('', app.handler);
this.get("#/", app.handler);
this.get("#:route", app.handler);
});
$(function() {
app.s.run();
app.sammy.run();
})