-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
76 lines (59 loc) · 1.63 KB
/
app.js
File metadata and controls
76 lines (59 loc) · 1.63 KB
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
71
72
73
74
75
76
var departuresApp = angular.module('departuresApp', ['ngRoute']);
departuresApp
.config(function($routeProvider){
$routeProvider
.when('/',
{
controller: 'DeparturesController',
templateUrl: 'board.html'
})
.otherwise({redirectTo: '/'});
})
.controller('DeparturesController', function($scope, $http, $timeout, $routeParams) {
//=========== Game Configuration ========
// ----DELAY TIME (mins) ---------------
$scope.delayTime = 1;
// ----PASS CODE ----------------------
$scope.secret = "deepblue";
// internal varaibles
$scope.done = false;
$scope.delayTimeSecs = $scope.delayTime * 60;
$scope.diffuse = function() {
if ($scope.passcode == $scope.secret)
{
$scope.done = true;
$scope.successMsg = "The world is saved! Well done!";
}
};
$scope.tick = function() {
function checkTime(i) {
if (i < 10) {i = "0" + i}; // add zero in front of numbers < 10
return i;
}
var h = 0, m = 0, s = 0;
var totalSecs = $scope.delayTimeSecs;
if ( totalSecs >= 0)
{
h = Math.floor(totalSecs/3600);
var rMins = totalSecs % 3600;
m = Math.floor(rMins/60) ;
s = rMins % 60;
}
else
{
$scope.failureMsg = "KABOOOOOOM!!!";
return;
}
m = checkTime(m);
s = checkTime(s);
$scope.clock = h + ":" + m + ":" + s;
$scope.delayTimeSecs -= 1;
$timeout(function(){
if (! $scope.done)
{
$scope.tick();
}
}, 1000)
}
$scope.tick();
});