Commit 065f0cdac43f2cd79a139e64a2a508a550f3bcba

Authored by Tetranoir
1 parent 40bf27d12f

node.data error and made submitting more consistent between pressing enter vs pressing submit

Showing 4 changed files with 27 additions and 7 deletions Side-by-side Diff

... ... @@ -30,7 +30,7 @@
30 30  
31 31 $httpProvider.interceptors.push(function($q) {
32 32 return {
33   - 'responseError': function(rejection) {
  33 + 'responseError': function(rejection) { // need a better redirect
34 34 if (rejection.status >= 500) {
35 35 console.log('got error');
36 36 console.log(rejection);
scripts/FeedController.js View file @ 065f0cd
... ... @@ -130,11 +130,20 @@
130 130 ws.onclose = function(e) {
131 131 console.log('connection closed');
132 132 };
133   -
  133 +
  134 + var resetModal = function() {
  135 + $('#new-card-input').html('');
  136 + $('#newCard').closeModal(modal_options);
  137 + }
  138 +
134 139 $scope.pushCard = function() {
135 140 var i = 0;
136 141 var blanks = [];
137 142 $('#new-card-input')[0].childNodes.forEach(function(node) {
  143 + if (typeof node.data == 'undefined') {
  144 + console.log('undefined node');
  145 + return resetModal();
  146 + }
138 147 node = $(node)[0];
139 148 console.log(node);
140 149 if (node.tagName == 'B') {
141 150  
142 151  
... ... @@ -146,13 +155,17 @@
146 155 }
147 156 });
148 157 var myCard = {
149   - 'text': $('#new-card-input').text(),
  158 + 'text': $('#new-card-input').text().trim(),
150 159 'mask': blanks,
151 160 section: sectionId
152 161 };
  162 + if (myCard.text == '') {
  163 + console.log('blank flashcard not pushed:' + myCard.text);
  164 + return resetModal();
  165 + }
153 166 $http.post('/api/flashcards/', myCard).
154 167 success(function(data) {
155   - console.log('flashcard push succeeded');
  168 + console.log('flashcard pushed: ' + myCard.text);
156 169 if (!UserService.hasVerifiedEmail()) {
157 170 Materialize.toast("<p>Thanks for contributing! However, others won't see your card until you verify your email address<p>", 4000);
158 171 }
... ... @@ -161,6 +174,7 @@
161 174 error(function(error) {
162 175 console.log('something went wrong pushing a card!');
163 176 });
  177 + return resetModal();
164 178 };
165 179  
166 180 /* Key bindings for the whole feed window. Hotkey it up! */
... ... @@ -206,8 +220,6 @@
206 220 if (e.which == 13) {
207 221 e.preventDefault();
208 222 $scope.pushCard();
209   - $('#new-card-input').html('');
210   - $('#newCard').closeModal(modal_options);
211 223 listenForC = true;
212 224 return false;
213 225 }
styles/flashy.css View file @ 065f0cd
... ... @@ -171,6 +171,14 @@
171 171 margin-right: auto;
172 172 }
173 173  
  174 +.feed-modal-input {
  175 + background-color: #D3D3D3;
  176 + //border-style: solid;
  177 + //border-width: 1px;
  178 + box-shadow: 2px 2px 5px #888888;
  179 + height: 24px;
  180 +}
  181 +
174 182 #newCard input[type=text] {
175 183 height: 3rem !important;
176 184 }
templates/feed.html View file @ 065f0cd
... ... @@ -30,7 +30,7 @@
30 30 <div class="modal-content">
31 31 <div class="input-field">
32 32 <!--<label id="newCardSign" for="newCard">New Flashcard Text</label>-->
33   - <div id="new-card-input" contenteditable style="outline:0px solid transparent;">
  33 + <div class="feed-modal-input" id="new-card-input" contenteditable style="outline:0px solid transparent;">
34 34  
35 35 </div>
36 36 </div>