|
8 | 8 | * @type {angular.Module}
|
9 | 9 | */
|
10 | 10 | var todomvc = angular.module('todomvc', ['firebase', 'ngStorage']);
|
11 |
| - |
12 |
| -// Dummy controller for testing |
13 |
| -todomvc. |
14 |
| - controller('MyCtrl1', ['$scope', '$location', function($scope, $location) { |
15 |
| - $scope.test1 = 'EFG'; |
16 |
| - |
17 |
| - // Get the first sentence and rest |
18 |
| - $scope.getFirstAndRestSentence = function($string) { |
19 |
| - var head = $string; |
20 |
| - var desc = ""; |
21 |
| - |
22 |
| - var separators = ['.', '?', '\n']; |
23 |
| - |
24 |
| - var firstIndex = -1; |
25 |
| - for (var i in separators) { |
26 |
| - var index = $string.indexOf(separators[i]); |
27 |
| - if (index == -1) continue; |
28 |
| - if (firstIndex == -1) {firstIndex = index; continue;} |
29 |
| - if (firstIndex > index) {firstIndex = index;} |
30 |
| - } |
31 |
| - |
32 |
| - if (firstIndex !=-1) { |
33 |
| - head = $string.slice(0, firstIndex+1); |
34 |
| - desc = $string.slice(firstIndex+1); |
35 |
| - } |
36 |
| - return [head, desc]; |
37 |
| - } |
38 |
| - |
39 |
| - }]); |
40 |
| - |
41 |
| -todomvc.filter('todoFilter', function ($location) { |
42 |
| - return function (input, max) { |
43 |
| - var sorted = []; |
44 |
| - var newQuestions = []; |
45 |
| - var sortedCount = 0; |
46 |
| - |
47 |
| - angular.forEach(input, function (todo) { |
48 |
| - console.log("Max: " + max); |
49 |
| - if (todo.timestamp > new Date().getTime() - 180000) { |
50 |
| - todo.new = true; |
51 |
| - newQuestions.push(todo); |
52 |
| - } else if (sortedCount++<=max){ // show top 100 only. |
53 |
| - todo.new = false; |
54 |
| - sorted.push(todo); |
55 |
| - } |
56 |
| - |
57 |
| - // sorting new |
58 |
| - newQuestions.sort(function(a, b) { |
59 |
| - if (a.echo == b.echo) { |
60 |
| - return b.timestamp - a.timestamp; |
61 |
| - } |
62 |
| - return b.echo - a.echo |
63 |
| - }); |
64 |
| - }); |
65 |
| - return newQuestions.concat(sorted); |
66 |
| - }; |
67 |
| -}); |
68 |
| - |
69 |
| -// http://stackoverflow.com/questions/9439725/javascript-how-to-detect-if-browser-window-is-scrolled-to-bottom |
70 |
| -// http://jsfiddle.net/88TzF/ |
71 |
| -/* |
72 |
| -todomvc.directive("scroll", function ($window) { |
73 |
| - return function(scope, element, attrs) { |
74 |
| - angular.element($window).bind("scroll", function() { |
75 |
| - if ($window.innerHeight + $window.scrollY >= $window.document.body.offsetHeight) { |
76 |
| - scope.boolChangeClass = true; |
77 |
| - console.log('Hit the bottom.'); |
78 |
| - $scope.increaseMax(); |
79 |
| - scope.$apply(); |
80 |
| - } else { |
81 |
| - scope.boolChangeClass = false; |
82 |
| - console.log('Header is in view.'); |
83 |
| - } |
84 |
| -
|
85 |
| - }); |
86 |
| - }; |
87 |
| -}); |
88 |
| -*/ |
0 commit comments