diff --git a/config.js b/config.js index f38884f..dd369f4 100644 --- a/config.js +++ b/config.js @@ -30,7 +30,7 @@ angular.module('flashy', [ $httpProvider.interceptors.push(function($q) { return { - 'responseError': function(rejection) { + 'responseError': function(rejection) { // need a better redirect if (rejection.status >= 500) { console.log('got error'); console.log(rejection); diff --git a/scripts/FeedController.js b/scripts/FeedController.js index 1d83354..737ae86 100644 --- a/scripts/FeedController.js +++ b/scripts/FeedController.js @@ -130,11 +130,20 @@ angular.module('flashy.FeedController', ['ui.router', 'ngAnimate']). ws.onclose = function(e) { console.log('connection closed'); }; - + + var resetModal = function() { + $('#new-card-input').html(''); + $('#newCard').closeModal(modal_options); + } + $scope.pushCard = function() { var i = 0; var blanks = []; $('#new-card-input')[0].childNodes.forEach(function(node) { + if (typeof node.data == 'undefined') { + console.log('undefined node'); + return resetModal(); + } node = $(node)[0]; console.log(node); if (node.tagName == 'B') { @@ -146,13 +155,17 @@ angular.module('flashy.FeedController', ['ui.router', 'ngAnimate']). } }); var myCard = { - 'text': $('#new-card-input').text(), + 'text': $('#new-card-input').text().trim(), 'mask': blanks, section: sectionId }; + if (myCard.text == '') { + console.log('blank flashcard not pushed:' + myCard.text); + return resetModal(); + } $http.post('/api/flashcards/', myCard). success(function(data) { - console.log('flashcard push succeeded'); + console.log('flashcard pushed: ' + myCard.text); if (!UserService.hasVerifiedEmail()) { Materialize.toast("
Thanks for contributing! However, others won't see your card until you verify your email address
", 4000); } @@ -161,6 +174,7 @@ angular.module('flashy.FeedController', ['ui.router', 'ngAnimate']). error(function(error) { console.log('something went wrong pushing a card!'); }); + return resetModal(); }; /* Key bindings for the whole feed window. Hotkey it up! */ @@ -206,8 +220,6 @@ angular.module('flashy.FeedController', ['ui.router', 'ngAnimate']). if (e.which == 13) { e.preventDefault(); $scope.pushCard(); - $('#new-card-input').html(''); - $('#newCard').closeModal(modal_options); listenForC = true; return false; } diff --git a/styles/flashy.css b/styles/flashy.css index cfab67c..0e6e73e 100644 --- a/styles/flashy.css +++ b/styles/flashy.css @@ -171,6 +171,14 @@ margin-right: auto; } +.feed-modal-input { + background-color: #D3D3D3; + //border-style: solid; + //border-width: 1px; + box-shadow: 2px 2px 5px #888888; + height: 24px; +} + #newCard input[type=text] { height: 3rem !important; } diff --git a/templates/feed.html b/templates/feed.html index 295eb8a..81785f5 100644 --- a/templates/feed.html +++ b/templates/feed.html @@ -30,7 +30,7 @@