forked from don-wang/wodi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
executable file
·72 lines (64 loc) · 1.65 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
71
72
var app = angular.module('MyApp', ['chieffancypants.loadingBar', 'ui.bootstrap', 'ngAnimate']);
app.controller("MyCtrl", ['$scope', function ($scope) {
$scope.max = 7;
$scope.maxP = 100;
$scope.number = 0;
$scope.numberP = 0;
$scope.process = 0;
$scope.word1 = "";
$scope.word2 = "";
$scope.setuped = false;
$scope.assigning = false;
$scope.prompt = "抽題";
$scope.list = [];
$scope.random = function() {
return 0.5 - Math.random();
}
$scope.setup = function() {
$scope.list = [];
var n = Math.floor((Math.random()*2)+1);
if(n==1){
a = $scope.word1;
b = $scope.word2;
} else {
a = $scope.word2;
b = $scope.word1;
}
$scope.list.push(a);
for(i=1;i<$scope.max;i++){
$scope.list.push(b);
}
$scope.list.sort(function() {
return Math.random() - 0.5;
});
$scope.setuped = true;
console.log($scope.list);
}
$scope.assign = function() {
if($scope.number == $scope.max){
$scope.status = "分發完畢";
} else if($scope.assigned == true ){
$scope.status = "請傳給下一位";
$scope.prompt = "抽題";
$scope.assigned = false;
} else {
$scope.prompt = "了解";
$scope.assigning = true;
$scope.assigned = true;
$scope.status = $scope.list[$scope.number++];
$scope.numberP = $scope.number/$scope.max*100;
}
}
$scope.reset = function() {
$scope.setuped = false;
$scope.assigning = false;
$scope.assigned = true;
$scope.status = "";
$scope.numberP = 0;
$scope.number = 0;
$scope.process = 0;
$scope.word1 = "";
$scope.word2 = "";
$scope.list = [];
}
}])