-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
190 lines (177 loc) · 7.2 KB
/
Copy pathindex.html
File metadata and controls
190 lines (177 loc) · 7.2 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
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<!DOCTYPE html5>
<html lang="en">
<head>
<title>IndexedDB.js | Demo</title>
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:300,400,500,700" type="text/css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.blue-light_blue.min.css" />
<script defer src="https://code.getmdl.io/1.3.0/material.min.js"></script>
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
crossorigin="anonymous"></script>
<style>
body {
background: #ccc;
color: #fff;
}
#main-container {
display: none;
}
.spinner {
width: 40px;
height: 40px;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
.double-bounce1,
.double-bounce2 {
width: 100%;
height: 100%;
border-radius: 50%;
background-color: #333;
opacity: 0.6;
position: absolute;
top: 0;
left: 0;
-webkit-animation: sk-bounce 2.0s infinite ease-in-out;
animation: sk-bounce 2.0s infinite ease-in-out;
}
.double-bounce2 {
-webkit-animation-delay: -1.0s;
animation-delay: -1.0s;
}
@-webkit-keyframes sk-bounce {
0%,
100% {
-webkit-transform: scale(0.0)
}
50% {
-webkit-transform: scale(1.0)
}
}
@keyframes sk-bounce {
0%,
100% {
transform: scale(0.0);
-webkit-transform: scale(0.0);
}
50% {
transform: scale(1.0);
-webkit-transform: scale(1.0);
}
}
</style>
<script src="./build/indexedDB.js"></script>
</head>
<body>
<div class="spinner" id="spinner">
<div class="double-bounce1"></div>
<div class="double-bounce2"></div>
</div>
<div id="main-container">
<div class="mdl-grid" style="margin: 0 auto;">
<div class="mdl-cell mdl-cell--12-col">
<h3 style="text-align: center">TODO Task</h3>
</div>
</div>
<div class="mdl-grid" style="margin: 0 auto;">
<div class="mdl-cell mdl-cell--12-col">
<div class="mdl-card mdl-shadow--2dp" style="min-height: auto;margin: 0 auto;width:410px">
<div class="mdl-card__supporting-text">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" id="val">
<label class="mdl-textfield__label" for="val">Add Task ...</label>
</div>
<button id="add" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent" style="vertical-align: super;color:#fff">Add</button>
</div>
</div>
</div>
</div>
<div class="mdl-grid" style="margin: 0 auto;">
<div class="mdl-cell mdl-cell--12-col" id="task-container">
</div>
</div>
</div>
<script type="text/template" id="task-template">
<div class="mdl-card mdl-shadow--2dp" style="min-height: auto;margin: 0 auto;width:410px;margin-bottom: 0.5%">
<div class="mdl-card__supporting-text">
<label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="{{ID}}">
<input type="checkbox" id="{{ID}}" class="mdl-checkbox__input" >
<span class="mdl-checkbox__label">{{Checkbox}}</span>
</label>
</div>
</div>
</script>
<script type="text/javascript">
(function (dbConnection) {
var model = {
repository: (function () {
IndexedDB.DbContextBuilder.Debug(false);
var sampleContextBuilder = new IndexedDB.DbContextBuilder(dbConnection);
sampleContextBuilder.Ready = function () {
$("#spinner").fadeOut("slow", function () {
$("#main-container").fadeIn("slow");
});
};
var repositories = sampleContextBuilder
.CreateDB("Sample")
.ConfigureModel({
name: "Sample",
keyPath: "id",
autoIncrement: false,
seed: [
{ id: 1, value: "Task1" },
{ id: 2, value: "Task2" },
{ id: 3, value: "Task3" }
]
}).Build();
return repositories.Sample;
})()
};
var controller = {
init: function () {
view.init();
},
add: function (data) {
model.repository.Add(data).then(controller.readAll, function () {
alert('asdfas');
});
},
readAll: function () {
model.repository.GetAll().then(view.render);
},
remove: function (id) {
model.repository.Delete(id).then(controller.readAll);
}
};
var view = {
init: function () {
this.$container = $('#task-container');
this.$taskTemplate = $('#task-template').html();
$('#add').click(function () {
var val = $('#val').val();
var obj = { id: Date.now(), value: val };
controller.add(obj);
$('#val').val("");
});
controller.readAll();
},
render: function (data) {
$(view.$container).html('');
for (var d of data) {
var str = view.$taskTemplate.replace(/{{Checkbox}}/g, d.value).replace(/{{ID}}/g, d.id);
$(view.$container).append(str);
}
componentHandler.upgradeDom();
}
}
document.addEventListener('DOMContentLoaded', function () {
controller.init();
})
} (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB));
</script>
</body>
</html>