Commit 63f4d4ca56d823eb67d1dbf627659124ac0f470c
1 parent
cf476b03e5
Exists in
master
and in
1 other branch
unbreak blanks
Showing 1 changed file with 4 additions and 3 deletions Side-by-side Diff
scripts/FeedController.js
View file @
63f4d4c
... | ... | @@ -167,19 +167,19 @@ |
167 | 167 | $scope.newCardText = $('#new-card-input').text(); |
168 | 168 | $scope.submit_enabled = $scope.newCardText.length >= 5 && $scope.newCardText.length <= 160; |
169 | 169 | var i = 0; |
170 | + $scope.newCardBlanks = []; | |
170 | 171 | $('#new-card-input')[0].childNodes.forEach(function(node) { |
171 | 172 | if (typeof node.data == 'undefined') { |
172 | 173 | console.log('undefined node'); |
173 | 174 | } |
174 | 175 | node = $(node)[0]; |
175 | - $scope.newCardBlanks = []; | |
176 | 176 | if (node.tagName == 'B') { |
177 | 177 | var text = $(node).text(); |
178 | - console.log(text.length, text); | |
179 | 178 | var leftspaces = 0, rightspaces = 0; |
180 | 179 | // awful way to find the first non-space character from the left or the right. thanks.js |
181 | 180 | while (text[leftspaces] == ' ' || text[leftspaces] == '\xa0') leftspaces++; |
182 | 181 | while (text[text.length - 1 - rightspaces] == ' ' || text[text.length - 1 - rightspaces] == '\xa0') rightspaces++; |
182 | + console.log(leftspaces, text.length); | |
183 | 183 | if (leftspaces != text.length) $scope.newCardBlanks.push([i + leftspaces, i + text.length - rightspaces]); |
184 | 184 | i += text.length; |
185 | 185 | } else if (!node.data) { |
186 | 186 | |
... | ... | @@ -192,8 +192,9 @@ |
192 | 192 | $scope.newCardBlanks.sort(function(a, b) { |
193 | 193 | return a[0] - b[0]; |
194 | 194 | }); |
195 | - var i = 0; | |
195 | + i = 0; | |
196 | 196 | newtext = ''; |
197 | + console.log($scope.newCardBlanks); | |
197 | 198 | $scope.newCardBlanks.forEach(function(blank) { |
198 | 199 | newtext += $scope.newCardText.slice(i, blank[0]); |
199 | 200 | newtext += '<b>' + $scope.newCardText.slice(blank[0], blank[1]) + '</b>'; |