-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathToDo.html
162 lines (155 loc) · 4.96 KB
/
ToDo.html
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<!DOCTYPE html>
<html lang="eng" ng-app="ToDo">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>todo</title>
<style>
body {
padding: 20px;
background-color: #BDF1F1;
}
button {
padding: 10px;
background-color: #28baba;
color: #ffffff !important;
font-family: helvetica,arial !important;
font-size: 20px;
line-height: 24px;
border-style: groove;
border-radius: 15px;
border-color: #4C6060; }
li {
padding: 10px;
background-color: #ffffff;
color: #333333;
font-family: helvetica,arial;
font-size: 20px;
line-height: 24px;
border-style: groove;
border-radius: 15px;
border-color: #4C6060; }
form {
padding: 5px; }
.done {
text-decoration: line-through;
color: #ccc; }
</style>
</head>
<body id="change">
<div ng-controller="todoController" ng-init="init()">
<input class="color" value="" onblur="pick()" id="colorpick">
<form name="frm" ng-submit="addTodo()">
<input type="text" name="newTodo" ng-model="newTodo" required/>
<button ng-disabled="frm.$invalid">Go</button>
</form>
<button class="btn btn-default btn-sm" ng-click="saveInput()">Save</button>
<button class="btn btn-default btn-sm" ng-click="loadInput()">Load</button>
<button class="btn btn-default btn-sm" ng-click="clearCompleted()">Clear Completed</button>
<button class="btn btn-default btn-sm" ng-click="showCompleted()">Show Completed</button>
<button class="btn btn-default btn-sm" ng-click="exportPartialData()">Export Partial Data</button>
<button class="btn btn-default btn-sm" ng-click="exportFullData()">Export Full Data</button>
<ul>
<li ng-repeat="todo in todos">
<input type="checkbox" ng-model="todo.done"/>
<span ng-class="{'done':todo.done}">{{todo.title}}</span>
</li>
</ul>
</div>
<link rel="stylesheet" type="text/css" href="style.css">
<link href="css/bootstrap.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="jscolor/jscolor.js"></script>
<script src="http://alasql.org/console/alasql.min.js"></script>
<script src="http://alasql.org/console/xlsx.core.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js"></script>
<script src="ngStorage.min.js"></script>
<script src="http://gregpike.net/demos/angular-local-storage/src/angular-local-storage.js"></script>
<script>
function LightenDarkenColor(col, amt) {
var usePound = false;
if (col[0] == "#") {
col = col.slice(1);
usePound = true;
}
var num = parseInt(col,16);
var r = (num >> 16) + amt;
if (r > 255) r = 255;
else if (r < 0) r = 0;
var b = ((num >> 8) & 0x00FF) + amt;
if (b > 255) b = 255;
else if (b < 0) b = 0;
var g = (num & 0x0000FF) + amt;
if (g > 255) g = 255;
else if (g < 0) g = 0;
return (usePound?"#":"") + (g | (b << 8) | (r << 16)).toString(16);
}
var cook = null;
function pick(){
var elem = document.getElementById("colorpick").value;
cook = document.cookie="#" + elem;
var colour = document.getElementById("change");
colour.style.background = cook;
var buttonBackgroundColor = LightenDarkenColor(cook, -50);
var buttonelement = document.getElementsByTagName('button');
for(var i=0;i<buttonelement.length;i++){
buttonelement[i].style.background= buttonBackgroundColor;
}
}
var ToDo =angular.module('ToDo',['ngStorage']);
ToDo.controller('todoController', function($scope, $localStorage){
$scope.todos = [];
$scope.Saved = [];
$scope.exportPartialData = function () {
alasql('SELECT * INTO XLSX("PartialReport.xlsx",{headers:true}) FROM ?',[$scope.todos]);
};
$scope.exportFullData = function () {
$scope.full=$scope.todos
$scope.full.concat($scope.Saved);
alasql('SELECT * INTO XLSX("FullReport.xlsx",{headers:true}) FROM ?',[$scope.full]);
};
$scope.addTodo = function(){
$scope.todos.push({'title' : $scope.newTodo, 'done' :false})
$scope.newtodo = ''
}
$scope.clearCompleted = function(){
$scope.todos = $scope.todos.filter(function(item){
if(item.done){
$scope.Saved.push(item);
}
return !item.done
})
}
$scope.showCompleted = function(){
alert($scope.Saved.length)
}
$scope.saveInput = function() {
$localStorage.Saved = $scope.todos;
}
$scope.loadInput = function() {
$scope.todos = $localStorage.Saved;
}
$scope.init = function(){
if($localStorage.Saved != undefined)
$scope.todos = $localStorage.Saved;
else
$scope.todos = [
{'title':'Build a ToDo app', 'done' :false}
];
};
window.onbeforeunload = function (event) {
var message = 'Sure you want to leave?';
if (typeof event == 'undefined') {
event = window.event;
}
if (event) {
event.returnValue = message;
$localStorage.Saved = $scope.todos;
}
return message;
}
});
</script>
</body>
</html>