-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
70 lines (68 loc) · 2.02 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
var app = angular.module('CLOCK', ['ui.bootstrap']).
config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/main', {templateUrl: 'partials/main.html', controller: 'main'}).
otherwise({redirectTo: '/main'});
}]);
app.directive('time', function() {
return {
scope: {
text: '@text',
glow: '=',
hour: '=',
minute: '='
},
controller: function ($scope, $element, $attrs, $location) {
},
replace: true,
restrict: 'A',
link: function(scope, element, attrs) {
scope.$watch('minute', function(newValue, oldValue) {
var h = scope.hour;
var n = scope.minute;
var g = scope.glow;
scope.glowClass="yellow";
switch (true){
case (n>=0 && n<5) && (g=="h"):
scope.glowClass="red";
break;
case (n>=5 && n<9) && (g=="f" || g=="p"):
scope.glowClass="red";
break;
case (n>=9 && n<=12) && (g=="ten" || g=="p"):
scope.glowClass="red";
break;
case (n>=13 && n<17) && (g=="a" || g=="p"):
scope.glowClass="red";
break;
case (n>=17 && n<25) && (g=="20" || g=="p"):
scope.glowClass="red";
break;
case (n>=25 && n<31) && (g=="30" || g=="p"):
scope.glowClass="red";
break;
case (n>=31 && n<35) && (g=="30" || g=="t"):
scope.glowClass="red";h++;
break;
case (n>=35 && n<41) && (g=="20" || g=="m" || g=="t"):
scope.glowClass="red";h++;
break;
case (n>=41 && n<49) && (g=="a" || g=="t"):
scope.glowClass="red";h++;
break;
case (n>=49 && n<55) && (g=="ten" || g=="m" || g=="t"):
scope.glowClass="red";h++;
break;
case (n>=55 && n<=60) && (g=="f" || g=="m" || g=="t"):
scope.glowClass="red";h++;
break;
}
if(scope.glow==h || scope.text=="It Is" ){
scope.glowClass="red";
//console.log(attrs.glow+" "+attrs.hour+" "+attrs.minute);
}
}, true);
},
template: '<h1 class="{{glowClass}}">{{text}}</h1>'
}
});