Persisting completion of bonfire challenges into User model, split routes for bonfires and challenges, refactored class selectors to be challenge type specific

This commit is contained in:
Nathan Leniz
2015-01-24 03:11:01 -05:00
parent 6b4475a5b8
commit a3cf6c3ee2
7 changed files with 106 additions and 264 deletions

View File

@@ -33,7 +33,7 @@ $(document).ready(function() {
}
});
$('.completed-bonfire').on('click', function() {
function completedBonfire(didCompleteWith, bonfireSolution, thisBonfireHash) {
$('#complete-bonfire-dialog').modal('show');
// Only post to server if there is an authenticated user
if ($('.signup-btn-nav').length < 1) {
@@ -41,11 +41,18 @@ $(document).ready(function() {
cn = l[l.length - 1];
$.ajax({
type: 'POST',
data: {bonfireHash: cn},
data: {
bonfireInfo: {
completedWith : didCompleteWith,
solution: bonfireSolution,
bonfireHash: thisBonfireHash
}
},
url: '/completed-bonfire/'
});
console.log(didCompleteWith, bonfireSolution, thisBonfireHash); // TODO: remove debug statement
}
});
}
$('.all-challenges').on('click', function() {
$('#all-challenges-dialog').modal('show');
@@ -55,10 +62,21 @@ $(document).ready(function() {
$('#all-bonfires-dialog').modal('show');
});
$('.next-button').on('click', function() {
$('.next-challenge-button').on('click', function() {
l = location.pathname.split('/');
window.location = '/challenges/' + (parseInt(l[l.length - 1]) + 1);
});
// TODO: refactor this to create meaningful variable names, what the heck i l?
$('.next-bonfire-button').on('click', function() {
var bonfireSolution = myCodeMirror.getValue();
var thisBonfireHash = passedBonfireHash || null;
var didCompleteWith = $('#completed-with').text() || null;
console.log(bonfireSolution, thisBonfireHash);
completedBonfire(didCompleteWith, bonfireSolution, thisBonfireHash);
l = location.pathname.split('/');
window.location = '/bonfires/' + (parseInt(l[l.length - 1]) + 1);
});
});
var profileValidation = angular.module('profileValidation',['ui.bootstrap']);