Starting bonfires view partial, ajax call works, need to work into view
This commit is contained in:
4
app.js
4
app.js
@ -301,6 +301,8 @@ app.get('/api/trello', resourcesController.trelloCalls);
|
||||
/**
|
||||
* Bonfire related routes
|
||||
*/
|
||||
app.get('/bonfires/pooproute', bonfireController.poopRoute);
|
||||
app.get('/bonfires/getBonfireList', bonfireController.showAllBonfires);
|
||||
app.get('/playground', bonfireController.index);
|
||||
app.get('/bonfires', bonfireController.returnNextBonfire);
|
||||
app.get('/bonfire-json-generator', bonfireController.returnGenerator);
|
||||
@ -315,6 +317,8 @@ app.get('/bonfire', function(req, res) {
|
||||
res.redirect(301, '/playground');
|
||||
});
|
||||
|
||||
|
||||
|
||||
app.post('/completed-bonfire/', bonfireController.completedBonfire);
|
||||
|
||||
/**
|
||||
|
@ -8,11 +8,19 @@ var _ = require('lodash'),
|
||||
* Bonfire controller
|
||||
*/
|
||||
|
||||
exports.bonfireNames = function(req, res) {
|
||||
res.render('bonfires/showList', {
|
||||
bonfireList: resources.allBonfireNames()
|
||||
exports.showAllBonfires = function(req, res) {
|
||||
var completedBonfires = req.user.completedBonfires.map(function(elem) {
|
||||
return elem._id;
|
||||
});
|
||||
var data = {};
|
||||
data.bonfireList = resources.allBonfireNames();
|
||||
//data.completedList = completedBonfires;
|
||||
res.send(data);
|
||||
};
|
||||
// FIXME: remove this
|
||||
exports.poopRoute = function(req, res) {
|
||||
res.render('partials/bonfires.jade');
|
||||
}
|
||||
|
||||
exports.index = function(req, res) {
|
||||
res.render('bonfire/show.jade', {
|
||||
|
@ -1,7 +1,20 @@
|
||||
h3
|
||||
ol(start='0')
|
||||
for bonfire in bonfires
|
||||
li
|
||||
a(href="/bonfires/#{bonfire.bonfireNumber}", class="#{ (cc && cc[bonfire.bonfireNumber] > 0) ? 'strikethrough' : '' }") #{bonfire.name}
|
||||
| (Level #{bonfire.difficulty})
|
||||
a.btn.btn-lg.btn-primary.btn-block(href="/done-with-first-100-hours", class="#{ ((cc && cc[53] === 0) || (!cc)) ? 'disabled' : '' }") I'm done with all the challenges!
|
||||
ol#bonfireList
|
||||
script.
|
||||
var getLinkedName = function getLinkedName(name) {
|
||||
return name.toLowerCase().replace(/\s/g, '-');
|
||||
}
|
||||
$.ajax({
|
||||
url: '/bonfires/getBonfireList',
|
||||
type: 'GET'
|
||||
})
|
||||
.success(
|
||||
function(data) {
|
||||
for (var i = 0; i < data.bonfireList.length; i++) {
|
||||
var li = document.createElement('li');
|
||||
var linkedName = getLinkedName(data.bonfireList[i]);
|
||||
$(li)
|
||||
.html("<a href='/bonfires/" + linkedName + "'>" + data.bonfireList[i] + "</a>");
|
||||
$(li).appendTo($('#bonfireList'));
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user