-
Notifications
You must be signed in to change notification settings - Fork 4
/
index-bb-localstorage.html
80 lines (51 loc) · 1.49 KB
/
index-bb-localstorage.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
<!DOCTYPE HTML PUBLIC>
<html>
<body>
</body>
<script src="js/vendor/underscore-min.js"></script>
<script src="js/vendor/backbone-min.js"></script>
<script src="js/backbone.sync/backbone-sync-localstorage.js"></script>
<script src="js/vendor/zepto.min.js"></script>
<script>
(function($) {
window.Doc = Backbone.Model.extend({
storeName : "docsDB"
});
window.Docs = Backbone.Collection.extend({
model : Doc,
storeName : "docsDB"
});
window.Human = Backbone.Model.extend({
storeName : "humansDB"
});
window.Humans = Backbone.Collection.extend({
model : Human,
storeName : "humansDB"
});
var doc1, doc2, doc3, doc4, h1, h2, h3;
doc1 = new Doc({id:'001', title:'TITLE 1', text:'TEXT1'});
doc2 = new Doc({id:'002', title:'TITLE 2', text:'TEXT2'});
doc3 = new Doc({id:'003', title:'TITLE 3', text:'TEXT3'});
doc4 = new Doc({id:'004', title:'TITLE 4', text:'TEXT4'});
h1 = new Human({id:'001', name:'Human 1'});
h2 = new Human({id:'002', name:'Human 2'});
h3 = new Human({id:'003', name:'Human 3'});
doc1.save();
doc2.save();
doc3.save();
doc4.save();
h1.save();
h2.save();
h3.save();
var docs = new Docs();
var humans = new Humans();
docs.fetch();
humans.fetch();
console.log(docs);
console.log(humans);
var other_doc = new Doc({id:'001'});
other_doc.fetch();
console.log(other_doc);
})(Zepto);
</script>
</html>