Commit 36887911f67a84ac7bc415d63c385930b6731b9f
1 parent
ff334700c2
Exists in
master
and in
1 other branch
Try bolding blanks
Showing 2 changed files with 31 additions and 5 deletions Side-by-side Diff
scripts/CardListController.js
View file @
3688791
1 | -angular.module('flashy.CardListController', ['ui.router', 'angular.filter']). | |
1 | +angular.module('flashy.CardListController', ['ui.router', 'angular.filter', 'ngSanitize']). | |
2 | 2 | controller('CardListController', function($scope, $rootScope, $state, $http, $stateParams) { |
3 | 3 | // cards array |
4 | 4 | sectionId = $stateParams.sectionId; |
... | ... | @@ -18,6 +18,7 @@ |
18 | 18 | console.log('go to feed'); |
19 | 19 | }; |
20 | 20 | |
21 | + | |
21 | 22 | // unhide card |
22 | 23 | $scope.unhide = function(card) { |
23 | 24 | $http.post('/api/flashcards/' + card.id + '/unhide/'). |
... | ... | @@ -177,5 +178,29 @@ |
177 | 178 | }; |
178 | 179 | |
179 | 180 | } |
180 | -); | |
181 | +). | |
182 | +filter('displayCard', function($sce) { | |
183 | + return function(card) { | |
184 | + // text to display as html | |
185 | + var cardText = ""; | |
186 | + | |
187 | + var start = 0; // where to start next string break | |
188 | + | |
189 | + // get all display pieces and blank pieces | |
190 | + for (var i = 0; i < card.mask.length; i++) { | |
191 | + cardText = cardText.concat( card.text.substring(start, card.mask[i][0]) ); | |
192 | + cardText = cardText.concat("<b>"); | |
193 | + cardText = cardText.concat( card.text.substring(card.mask[i][0], card.mask[i][1]) ); | |
194 | + cardText = cardText.concat("</b>"); | |
195 | + start = card.mask[i][1]; | |
196 | + } | |
197 | + | |
198 | + // get remaining dislay pieces, if any | |
199 | + if (start != card.mask.length - 1) | |
200 | + cardText = cardText.concat( card.text.substring(start) ); | |
201 | + | |
202 | + //cardText = cardText.concat("</span>"); | |
203 | + return $sce.trustAsHtml(cardText); | |
204 | + }; | |
205 | +}); |
templates/cardlist.html
View file @
3688791
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | <div class="row"> |
3 | 3 | <a class="btn" id="showHidden" ng-click="show = !show" style="margin-top: 15px">Show Hidden</a> |
4 | 4 | |
5 | - <div class="input-field col s6 right"> | |
5 | + <div class="input-field col s4 right"> | |
6 | 6 | <i class="mdi-action-search prefix"></i> |
7 | 7 | <input id="search" type="text" class="validate" ng-model="searchText"/> |
8 | 8 | <label for="search">Search</label> |
9 | 9 | |
... | ... | @@ -60,10 +60,11 @@ |
60 | 60 | |
61 | 61 | <div class="list" style="padding: 0px 15px"> |
62 | 62 | <ul class="collection" |
63 | - ng-repeat="(weeknum, week_cards) in cards | filter:searchText | filter:filterByDate | groupBy: 'material_week_num' | orderBy:-material_week_num"> | |
63 | + ng-repeat="(weeknum, week_cards) in cards | filter:searchText | filter:filterByDate | groupBy: 'material_week_num'"> | |
64 | 64 | <li class="collection-header"><h3>Week {{weeknum}}</h3></li> |
65 | 65 | <li class="collection-item" ng-click="expand = !expand" ng-repeat="card in week_cards" ng-show="show || !card.is_hidden"> |
66 | - <div>{{card.text}} | |
66 | + <div> | |
67 | + <span ng-bind-html="card | displayCard"></span> | |
67 | 68 | <span class="badge">{{dayofweek(card)}}</span> |
68 | 69 | <p class="right-align" ng-show="expand"> |
69 | 70 | <a href="" class="tooltipped" ng-click="pull(card)" ng-show="!card.is_in_deck" data-position="bottom" data-delay="50" data-tooltip="Add to Deck"> |