Permalink
Please sign in to comment.
Browse files
Add .editorconfig to enforce certain automatic behavior on all editors,
Add logic for ziplines and basejumps completion.
- Loading branch information...
Showing
with
481 additions
and 433 deletions.
- +15 −0 .editorconfig
- +2 −0 app.js
- +31 −60 controllers/bonfire.js
- +39 −27 controllers/courseware.js
- +4 −1 models/User.js
- +367 −312 public/js/main.js
- +0 −10 views/bonfire/show.jade
- +2 −1 views/coursewares/showHTML.jade
- +2 −1 views/coursewares/showJS.jade
- +2 −3 views/coursewares/showVideo.jade
- +17 −18 views/coursewares/showZiplineOrBasejump.jade
15
.editorconfig
@@ -0,0 +1,15 @@ | |||
+root = true | |||
+ | |||
+[*] | |||
+indent_style = space | |||
+end_of_line = lf | |||
+charset = utf-8 | |||
+trim_trailing_whitespace = true | |||
+insert_final_newline = true | |||
+ | |||
+[package.json] | |||
+indent_style = space | |||
+indent_size = 2 | |||
+ | |||
+[*.md] | |||
+trim_trailing_whitespace = false |
2
app.js
91
controllers/bonfire.js
66
controllers/courseware.js
5
models/User.js
679
public/js/main.js
@@ -1,377 +1,432 @@ | |||
$(document).ready(function() { | $(document).ready(function() { | ||
- var challengeName = typeof challengeName !== undefined ? challengeName : 'Untitled'; | + var challengeName = typeof challengeName !== undefined ? challengeName : 'Untitled'; | ||
- if (challengeName) { | + if (challengeName) { | ||
- ga('send', 'event', 'Challenge', 'load', challengeName); | + ga('send', 'event', 'Challenge', 'load', challengeName); | ||
- } | + } | ||
- | + | ||
- // When introducing a new announcement, change the localStorage attribute | + // When introducing a new announcement, change the localStorage attribute | ||
- // and the HTML located in the footer | + // and the HTML located in the footer | ||
- if (!localStorage || !localStorage.nodeSchoolAnnouncement) { | + if (!localStorage || !localStorage.nodeSchoolAnnouncement) { | ||
- $('#announcementModal').modal('show'); | + $('#announcementModal').modal('show'); | ||
- localStorage.fccShowAnnouncement = "true"; | + localStorage.fccShowAnnouncement = "true"; | ||
- } | + } | ||
- | + | ||
- var CSRF_HEADER = 'X-CSRF-Token'; | + var CSRF_HEADER = 'X-CSRF-Token'; | ||
- | + | ||
- var setCSRFToken = function(securityToken) { | + var setCSRFToken = function(securityToken) { | ||
- jQuery.ajaxPrefilter(function(options, _, xhr) { | + jQuery.ajaxPrefilter(function(options, _, xhr) { | ||
- if (!xhr.crossDomain) { | + if (!xhr.crossDomain) { | ||
- xhr.setRequestHeader(CSRF_HEADER, securityToken); | + xhr.setRequestHeader(CSRF_HEADER, securityToken); | ||
- } | |||
- }); | |||
- }; | |||
- | |||
- setCSRFToken($('meta[name="csrf-token"]').attr('content')); | |||
- | |||
- $('.start-challenge').on('click', function() { | |||
- $(this).parent().remove(); | |||
- $('.challenge-content') | |||
- .removeClass('hidden-element') | |||
- .addClass('animated fadeInDown'); | |||
- }); | |||
- | |||
- //$('.completed-challenge').on('click', function() { | |||
- // $('#complete-challenge-dialog').modal('show'); | |||
- // // Only post to server if there is an authenticated user | |||
- // if ($('.signup-btn-nav').length < 1) { | |||
- // l = location.pathname.split('/'); | |||
- // cn = l[l.length - 1]; | |||
- // $.ajax({ | |||
- // type: 'POST', | |||
- // data: {challengeNumber: cn}, | |||
- // url: '/completed-challenge/' | |||
- // }); | |||
- // } | |||
- //}); | |||
- | |||
- | |||
- 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) { | |||
- | |||
- $.post( | |||
- '/completed-bonfire', | |||
- { | |||
- bonfireInfo: { | |||
- completedWith : didCompleteWith, | |||
- solution: bonfireSolution, | |||
- bonfireHash: thisBonfireHash | |||
- } | |||
- }, | |||
- function(res) { | |||
- if (res) { | |||
- window.location.href = '/bonfires' | |||
- } | |||
- }); | |||
- } | |||
- } | |||
- | |||
- $('.next-bonfire-button').on('click', function() { | |||
- var bonfireSolution = myCodeMirror.getValue(); | |||
- var thisBonfireHash = passedBonfireHash || null; | |||
- var didCompleteWith = $('#completed-with').val() || null; | |||
- completedBonfire(didCompleteWith, bonfireSolution, thisBonfireHash); | |||
- | |||
- }); | |||
- | |||
- $('#completed-courseware').on('click', function() { | |||
- $('#complete-courseware-dialog').modal('show'); | |||
- }); | |||
- | |||
- $('#complete-courseware-dialog').on('keypress', function(e) { | |||
- if (e.ctrlKey && e.keyCode == 13) { | |||
- $('#next-courseware-button').click(); | |||
} | } | ||
}); | }); | ||
+ }; | |||
+ | |||
+ setCSRFToken($('meta[name="csrf-token"]').attr('content')); | |||
+ | |||
+ $('.start-challenge').on('click', function() { | |||
+ $(this).parent().remove(); | |||
+ $('.challenge-content') | |||
+ .removeClass('hidden-element') | |||
+ .addClass('animated fadeInDown'); | |||
+ }); | |||
+ | |||
+ //$('.completed-challenge').on('click', function() { | |||
+ // $('#complete-challenge-dialog').modal('show'); | |||
+ // // Only post to server if there is an authenticated user | |||
+ // if ($('.signup-btn-nav').length < 1) { | |||
+ // l = location.pathname.split('/'); | |||
+ // cn = l[l.length - 1]; | |||
+ // $.ajax({ | |||
+ // type: 'POST', | |||
+ // data: {challengeNumber: cn}, | |||
+ // url: '/completed-challenge/' | |||
+ // }); | |||
+ // } | |||
+ //}); | |||
+ | |||
+ | |||
+ 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) { | |||
+ | |||
+ $.post( | |||
+ '/completed-bonfire', | |||
+ { | |||
+ bonfireInfo: { | |||
+ completedWith : didCompleteWith, | |||
+ solution: bonfireSolution, | |||
+ bonfireHash: thisBonfireHash | |||
+ } | |||
+ }, | |||
+ function(res) { | |||
+ if (res) { | |||
+ window.location.href = '/bonfires' | |||
+ } | |||
+ }); | |||
+ } | |||
+ } | |||
- $('#complete-bonfire-dialog').on('hidden.bs.modal', function() { | + $('.next-bonfire-button').on('click', function() { | ||
- editor.focus(); | + var bonfireSolution = myCodeMirror.getValue(); | ||
- }); | + var thisBonfireHash = passedBonfireHash || null; | ||
- | + var didCompleteWith = $('#completed-with').val() || null; | ||
- $('#all-bonfires-dialog').on('hidden.bs.modal', function() { | + completedBonfire(didCompleteWith, bonfireSolution, thisBonfireHash); | ||
- editor.focus(); | |||
- }); | |||
- | |||
- $('#showAllCoursewares').on('click', function() { | |||
- $('#all-coursewares-dialog').modal('show'); | |||
- }); | |||
- | |||
- $('#all-coursewares-dialog').on('hidden.bs.modal', function() { | |||
- editor.focus(); | |||
- }); | |||
- | |||
- | |||
- $('#complete-courseware-dialog').on('hidden.bs.modal', function() { | |||
- editor.focus(); | |||
- }); | |||
- $('#next-courseware-button').on('click', function() { | |||
- console.log(passedCoursewareHash); | |||
- if ($('.signup-btn-nav').length < 1) { | |||
- $.post( | |||
- '/completed-courseware/', | |||
- { | |||
- coursewareInfo: { | |||
- coursewareHash: passedCoursewareHash, | |||
- coursewareName: passedCoursewareName | |||
- } | |||
- }).success( | |||
- function(res) { | |||
- if (res) { | |||
- window.location.href = '/challenges'; | |||
- } | |||
- } | |||
- ); | |||
- | |||
- } | |||
- }); | |||
- | |||
- | |||
- $('.all-challenges').on('click', function() { | |||
- $('#all-challenges-dialog').modal('show'); | |||
- }); | |||
- $('#showAllButton').on('click', function() { | + }); | ||
- $('#all-bonfires-dialog').modal('show'); | |||
- }); | |||
- $('.next-challenge-button').on('click', function() { | + $('#completed-courseware').on('click', function() { | ||
- l = location.pathname.split('/'); | + $('#complete-courseware-dialog').modal('show'); | ||
- window.location = '/challenges/' + (parseInt(l[l.length - 1]) + 1); | + }); | ||
- }); | |||
+ $('#completed-zipline-or-basejump').on('click', function() { | |||
+ $('#complete-zipline-or-basejump-dialog').modal('show'); | |||
+ }); | |||
- // Bonfire instructions functions | |||
- $('#more-info').on('click', function() { | |||
- ga('send', 'event', 'Challenge', 'more-info', challengeName); | |||
- $('#brief-instructions').hide(); | |||
- $('#long-instructions').show().removeClass('hide'); | |||
- }); | + $('#complete-courseware-dialog').on('keypress', function(e) { | ||
- $('#less-info').on('click', function() { | + if (e.ctrlKey && e.keyCode === 13) { | ||
- $('#brief-instructions').show(); | + $('#next-courseware-button').click(); | ||
- $('#long-instructions').hide(); | + } | ||
- }); | + }); | ||
- | + | ||
- var upvoteHandler = function () { | + $('#complete-bonfire-dialog').on('hidden.bs.modal', function() { | ||
- var _id = storyId; | + editor.focus(); | ||
- $('#upvote').unbind('click'); | + }); | ||
- var alreadyUpvoted = false; | + | ||
- for (var i = 0; i < upVotes.length; i++) { | + $('#all-bonfires-dialog').on('hidden.bs.modal', function() { | ||
- if (upVotes[i].upVotedBy === user._id) { | + editor.focus(); | ||
- alreadyUpvoted = true; | + }); | ||
- break; | + | ||
+ $('#showAllCoursewares').on('click', function() { | |||
+ $('#all-coursewares-dialog').modal('show'); | |||
+ }); | |||
+ | |||
+ $('#all-coursewares-dialog').on('hidden.bs.modal', function() { | |||
+ editor.focus(); | |||
+ }); | |||
+ | |||
+ | |||
+ $('#complete-courseware-dialog').on('hidden.bs.modal', function() { | |||
+ editor.focus(); | |||
+ }); | |||
+ $('#next-courseware-button').on('click', function() { | |||
+ console.log(passedCoursewareHash); | |||
+ if ($('.signup-btn-nav').length < 1) { | |||
+ switch (challengeType) { | |||
+ case 0: | |||
+ case 1: | |||
+ case 2: | |||
+ $.post( | |||
+ '/completed-courseware/', | |||
+ { | |||
+ coursewareInfo: { | |||
+ coursewareHash: passedCoursewareHash, | |||
+ coursewareName: passedCoursewareName | |||
+ } | |||
+ }).success( | |||
+ function(res) { | |||
+ if (res) { | |||
+ window.location.href = '/challenges'; | |||
+ } | |||
} | } | ||
- } | + ); | ||
- if (!alreadyUpvoted) { | + break; | ||
- $.post('/stories/upvote', | + case 3: | ||
- { | + var didCompleteWith = $('#completed-with').val() || null; | ||
- data: { | + var publicURL = $('#public-url').val() || null; | ||
- id: _id, | + $.post( | ||
- upVoter: user | + '/completed-zipline-or-basejump/', | ||
- } | |||
- }) | |||
- .fail(function (xhr, textStatus, errorThrown) { | |||
- $('#upvote').bind('click', upvoteHandler); | |||
- }) | |||
- .done(function (data, textStatus, xhr) { | |||
- $('#upvote').text('Upvoted!').addClass('disabled'); | |||
- | |||
- $('#storyRank').text(data.rank + " points"); | |||
- }); | |||
- } | |||
- }; | |||
- $('#upvote').on('click', upvoteHandler); | |||
- | |||
- | |||
- var storySubmitButtonHandler = function storySubmitButtonHandler() { | |||
- | |||
- var link = $('#story-url').val(); | |||
- var headline = $('#story-title').val(); | |||
- var description = $('#description-box').val(); | |||
- var userDataForUpvote = { | |||
- upVotedBy: user._id, | |||
- upVotedByUsername: user.profile.username | |||
- }; | |||
- $('#story-submit').unbind('click'); | |||
- $.post('/stories/', | |||
{ | { | ||
- data: { | + coursewareInfo: { | ||
- link: link, | + coursewareHash: passedCoursewareHash, | ||
- headline: headline, | + coursewareName: passedCoursewareName, | ||
- timePosted: Date.now(), | + completedWith: didCompleteWith, | ||
- description: description, | + publicURL: publicURL, | ||
- storyMetaDescription: storyMetaDescription, | + challengeType: challengeType | ||
- rank: 1, | + } | ||
- upVotes: [userDataForUpvote], | + }).success( | ||
- author: { | + function() { | ||
- picture: user.profile.picture, | + window.location.href = '/challenges'; | ||
- userId: user._id, | + }).fail( | ||
- username: user.profile.username | + function() { | ||
- }, | + window.location.href = '/challenges'; | ||
- comments: [], | |||
- image: storyImage | |||
- } | |||
- }) | |||
- .fail(function (xhr, textStatus, errorThrown) { | |||
- $('#story-submit').bind('click', storySubmitButtonHandler); | |||
- }) | |||
- .done(function (data, textStatus, xhr) { | |||
- window.location = '/stories/' + JSON.parse(data).storyLink; | |||
}); | }); | ||
+ break; | |||
+ case 4: | |||
+ var didCompleteWith = $('#completed-with').val() || null; | |||
+ var publicURL = $('#public-url').val() || null; | |||
+ var githubURL = $('#github-url').val() || null; | |||
+ $.post( | |||
+ '/completed-zipline-or-basejump/', | |||
+ { | |||
+ coursewareInfo: { | |||
+ coursewareHash: passedCoursewareHash, | |||
+ coursewareName: passedCoursewareName, | |||
+ completedWith: didCompleteWith, | |||
+ publicURL: publicURl, | |||
+ githubURL: githubURL, | |||
+ challengeType: challengeType | |||
+ } | |||
+ }).success(function() { | |||
+ window.location.href = '/challenges'; | |||
+ }).fail(function() { | |||
+ window.location.replace(window.location.href); | |||
+ }); | |||
+ break; | |||
+ default: | |||
+ break; | |||
+ } | |||
- }; | + } | ||
- | + }); | ||
- $('#story-submit').on('click', storySubmitButtonHandler); | + | ||
+ | |||
+ $('.all-challenges').on('click', function() { | |||
+ $('#all-challenges-dialog').modal('show'); | |||
+ }); | |||
+ | |||
+ $('#showAllButton').on('click', function() { | |||
+ $('#all-bonfires-dialog').modal('show'); | |||
+ }); | |||
+ | |||
+ $('.next-challenge-button').on('click', function() { | |||
+ l = location.pathname.split('/'); | |||
+ window.location = '/challenges/' + (parseInt(l[l.length - 1]) + 1); | |||
+ }); | |||
+ | |||
+ | |||
+// Bonfire instructions functions | |||
+ $('#more-info').on('click', function() { | |||
+ ga('send', 'event', 'Challenge', 'more-info', challengeName); | |||
+ $('#brief-instructions').hide(); | |||
+ $('#long-instructions').show().removeClass('hide'); | |||
+ | |||
+ }); | |||
+ $('#less-info').on('click', function() { | |||
+ $('#brief-instructions').show(); | |||
+ $('#long-instructions').hide(); | |||
+ }); | |||
+ | |||
+ var upvoteHandler = function () { | |||
+ var _id = storyId; | |||
+ $('#upvote').unbind('click'); | |||
+ var alreadyUpvoted = false; | |||
+ for (var i = 0; i < upVotes.length; i++) { | |||
+ if (upVotes[i].upVotedBy === user._id) { | |||
+ alreadyUpvoted = true; | |||
+ break; | |||
+ } | |||
+ } | |||
+ if (!alreadyUpvoted) { | |||
+ $.post('/stories/upvote', | |||
+ { | |||
+ data: { | |||
+ id: _id, | |||
+ upVoter: user | |||
+ } | |||
+ }) | |||
+ .fail(function (xhr, textStatus, errorThrown) { | |||
+ $('#upvote').bind('click', upvoteHandler); | |||
+ }) | |||
+ .done(function (data, textStatus, xhr) { | |||
+ $('#upvote').text('Upvoted!').addClass('disabled'); | |||
+ | |||
+ $('#storyRank').text(data.rank + " points"); | |||
+ }); | |||
+ } | |||
+ }; | |||
+ $('#upvote').on('click', upvoteHandler); | |||
- var commentSubmitButtonHandler = function commentSubmitButtonHandler() { | |||
- $('comment-button').unbind('click'); | |||
- var data = $('#comment-box').val(); | |||
- $('#comment-button').attr('disabled', 'disabled'); | + var storySubmitButtonHandler = function storySubmitButtonHandler() { | ||
- $.post('/stories/comment/', | |||
- { | |||
- data: { | |||
- associatedPost: storyId, | |||
- body: data, | |||
- author: { | |||
- picture: user.profile.picture, | |||
- userId: user._id, | |||
- username: user.profile.username | |||
- } | |||
- } | |||
- }) | |||
- .fail(function (xhr, textStatus, errorThrown) { | |||
- $('#comment-button').attr('disabled', false); | |||
- }) | |||
- .done(function (data, textStatus, xhr) { | |||
- window.location.reload(); | |||
- }); | |||
+ var link = $('#story-url').val(); | |||
+ var headline = $('#story-title').val(); | |||
+ var description = $('#description-box').val(); | |||
+ var userDataForUpvote = { | |||
+ upVotedBy: user._id, | |||
+ upVotedByUsername: user.profile.username | |||
}; | }; | ||
+ $('#story-submit').unbind('click'); | |||
+ $.post('/stories/', | |||
+ { | |||
+ data: { | |||
+ link: link, | |||
+ headline: headline, | |||
+ timePosted: Date.now(), | |||
+ description: description, | |||
+ storyMetaDescription: storyMetaDescription, | |||
+ rank: 1, | |||
+ upVotes: [userDataForUpvote], | |||
+ author: { | |||
+ picture: user.profile.picture, | |||
+ userId: user._id, | |||
+ username: user.profile.username | |||
+ }, | |||
+ comments: [], | |||
+ image: storyImage | |||
+ } | |||
+ }) | |||
+ .fail(function (xhr, textStatus, errorThrown) { | |||
+ $('#story-submit').bind('click', storySubmitButtonHandler); | |||
+ }) | |||
+ .done(function (data, textStatus, xhr) { | |||
+ window.location = '/stories/' + JSON.parse(data).storyLink; | |||
+ }); | |||
+ | |||
+ }; | |||
+ | |||
+ $('#story-submit').on('click', storySubmitButtonHandler); | |||
+ | |||
+ var commentSubmitButtonHandler = function commentSubmitButtonHandler() { | |||
+ $('comment-button').unbind('click'); | |||
+ var data = $('#comment-box').val(); | |||
+ | |||
+ $('#comment-button').attr('disabled', 'disabled'); | |||
+ $.post('/stories/comment/', | |||
+ { | |||
+ data: { | |||
+ associatedPost: storyId, | |||
+ body: data, | |||
+ author: { | |||
+ picture: user.profile.picture, | |||
+ userId: user._id, | |||
+ username: user.profile.username | |||
+ } | |||
+ } | |||
+ }) | |||
+ .fail(function (xhr, textStatus, errorThrown) { | |||
+ $('#comment-button').attr('disabled', false); | |||
+ }) | |||
+ .done(function (data, textStatus, xhr) { | |||
+ window.location.reload(); | |||
+ }); | |||
- $('#comment-button').on('click', commentSubmitButtonHandler); | + }; | ||
+ | |||
+ $('#comment-button').on('click', commentSubmitButtonHandler); | |||
}); | }); | ||
var profileValidation = angular.module('profileValidation',['ui.bootstrap']); | var profileValidation = angular.module('profileValidation',['ui.bootstrap']); | ||
profileValidation.controller('profileValidationController', ['$scope', '$http', | profileValidation.controller('profileValidationController', ['$scope', '$http', | ||
- function($scope, $http) { | + function($scope, $http) { | ||
- $http.get('/account/api').success(function(data) { | + $http.get('/account/api').success(function(data) { | ||
- $scope.user = data.user; | + $scope.user = data.user; | ||
- $scope.user.profile.username = $scope.user.profile.username ? $scope.user.profile.username.toLowerCase() : undefined; | + $scope.user.profile.username = $scope.user.profile.username ? $scope.user.profile.username.toLowerCase() : undefined; | ||
- $scope.storedUsername = data.user.profile.username; | + $scope.storedUsername = data.user.profile.username; | ||
- $scope.storedEmail = data.user.email; | + $scope.storedEmail = data.user.email; | ||
- $scope.user.email = $scope.user.email ? $scope.user.email.toLowerCase() : undefined; | + $scope.user.email = $scope.user.email ? $scope.user.email.toLowerCase() : undefined; | ||
- $scope.user.profile.twitterHandle = $scope.user.profile.twitterHandle ? $scope.user.profile.twitterHandle.toLowerCase() : undefined; | + $scope.user.profile.twitterHandle = $scope.user.profile.twitterHandle ? $scope.user.profile.twitterHandle.toLowerCase() : undefined; | ||
- $scope.asyncComplete = true; | + $scope.asyncComplete = true; | ||
- }); | + }); | ||
- } | + } | ||
]); | ]); | ||
profileValidation.controller('pairedWithController', ['$scope', | profileValidation.controller('pairedWithController', ['$scope', | ||
- function($scope) { | + function($scope) { | ||
- $scope.existingUser = null; | + $scope.existingUser = null; | ||
- } | + } | ||
]); | ]); | ||
profileValidation.controller('emailSignUpController', ['$scope', | profileValidation.controller('emailSignUpController', ['$scope', | ||
- function($scope) { | + function($scope) { | ||
- } | + } | ||
]); | ]); | ||
profileValidation.controller('emailSignInController', ['$scope', | profileValidation.controller('emailSignInController', ['$scope', | ||
- function($scope) { | + function($scope) { | ||
- } | + } | ||
]); | ]); | ||
profileValidation.controller('URLSubmitController', ['$scope', | profileValidation.controller('URLSubmitController', ['$scope', | ||
- function($scope) { | + function($scope) { | ||
- } | + } | ||
]); | ]); | ||
profileValidation.controller('nonprofitFormController', ['$scope', | profileValidation.controller('nonprofitFormController', ['$scope', | ||
- function($scope) { | + function($scope) { | ||
- } | + } | ||
]); | ]); | ||
profileValidation.controller('doneWithFirst100HoursFormController', ['$scope', | profileValidation.controller('doneWithFirst100HoursFormController', ['$scope', | ||
- function($scope) { | + function($scope) { | ||
- } | + } | ||
]); | ]); | ||
profileValidation.controller('submitStoryController', ['$scope', | profileValidation.controller('submitStoryController', ['$scope', | ||
- function($scope) { | + function($scope) { | ||
- } | + } | ||
]); | ]); | ||
profileValidation.directive('uniqueUsername',['$http',function($http) { | profileValidation.directive('uniqueUsername',['$http',function($http) { | ||
- return { | + return { | ||
- restrict: 'A', | + restrict: 'A', | ||
- require: 'ngModel', | + require: 'ngModel', | ||
- link: function (scope, element, attrs, ngModel) { | + link: function (scope, element, attrs, ngModel) { | ||
- element.bind("keyup", function (event) { | + element.bind("keyup", function (event) { | ||
- ngModel.$setValidity('unique', true); | + ngModel.$setValidity('unique', true); | ||
- if (element.val()) { | + if (element.val()) { | ||
- $http.get("/api/checkUniqueUsername/" + element.val()).success(function (data) { | + $http.get("/api/checkUniqueUsername/" + element.val()).success(function (data) { | ||
- if (element.val() == scope.storedUsername) { | + if (element.val() == scope.storedUsername) { | ||
- ngModel.$setValidity('unique', true); | + ngModel.$setValidity('unique', true); | ||
- } else if (data) { | + } else if (data) { | ||
- ngModel.$setValidity('unique', false); | + ngModel.$setValidity('unique', false); | ||
- } | + } | ||
- }); | + }); | ||
- } | |||
- }); | |||
} | } | ||
+ }); | |||
} | } | ||
+ } | |||
}]); | }]); | ||
profileValidation.directive('existingUsername', ['$http', function($http) { | profileValidation.directive('existingUsername', ['$http', function($http) { | ||
- return { | + return { | ||
- restrict: 'A', | + restrict: 'A', | ||
- require: 'ngModel', | + require: 'ngModel', | ||
- link: function (scope, element, attrs, ngModel) { | + link: function (scope, element, attrs, ngModel) { | ||
- element.bind("keyup", function (event) { | + element.bind("keyup", function (event) { | ||
- if (element.val().length > 0) { | + if (element.val().length > 0) { | ||
- ngModel.$setValidity('exists', false); | + ngModel.$setValidity('exists', false); | ||
- } else { | + } else { | ||
- element.removeClass('ng-dirty'); | + element.removeClass('ng-dirty'); | ||
- ngModel.$setPristine(); | + ngModel.$setPristine(); | ||
- } | + } | ||
- if (element.val()) { | + if (element.val()) { | ||
- $http | + $http | ||
- .get("/api/checkExistingUsername/" + element.val()) | + .get("/api/checkExistingUsername/" + element.val()) | ||
- .success(function (data) { | + .success(function (data) { | ||
- ngModel.$setValidity('exists', data); | + ngModel.$setValidity('exists', data); | ||
- }); | |||
- } | |||
}); | }); | ||
} | } | ||
+ }); | |||
} | } | ||
+ } | |||
}]); | }]); | ||
profileValidation.directive('uniqueEmail', ['$http', function($http) { | profileValidation.directive('uniqueEmail', ['$http', function($http) { | ||
- return { | + return { | ||
- restrict: 'A', | + restrict: 'A', | ||
- require: 'ngModel', | + require: 'ngModel', | ||
- link: function getUnique (scope, element, attrs, ngModel) { | + link: function getUnique (scope, element, attrs, ngModel) { | ||
- element.bind("keyup", function (event) { | + element.bind("keyup", function (event) { | ||
- ngModel.$setValidity('unique', true); | + ngModel.$setValidity('unique', true); | ||
- if (element.val()) { | + if (element.val()) { | ||
- $http.get("/api/checkUniqueEmail/" + encodeURIComponent(element.val())).success(function (data) { | + $http.get("/api/checkUniqueEmail/" + encodeURIComponent(element.val())).success(function (data) { | ||
- if (element.val() == scope.storedEmail) { | + if (element.val() == scope.storedEmail) { | ||
- ngModel.$setValidity('unique', true); | + ngModel.$setValidity('unique', true); | ||
- } else if (data) { | + } else if (data) { | ||
- ngModel.$setValidity('unique', false); | + ngModel.$setValidity('unique', false); | ||
- } | + } | ||
- }); | + }); | ||
- }; | + }; | ||
- }); | + }); | ||
- } | |||
} | } | ||
+ } | |||
}]); | }]); |
10
views/bonfire/show.jade
3
views/coursewares/showHTML.jade
3
views/coursewares/showJS.jade
5
views/coursewares/showVideo.jade
35
views/coursewares/showZiplineOrBasejump.jade
0 comments on commit
1fc3cff