-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathtodo4.html
99 lines (89 loc) · 2.7 KB
/
todo4.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
<script src="https://cdn.jsdelivr.net/npm/gun/gun.js"></script>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gun/lib/unset.js"></script>
<script>
var gun = Gun("ws://127.0.0.1:8000/gun")
let basicTest = () => {
console.log("basic test.")
gun.get("proj.simple://1").put({
"attr1": "val"
})
gun.get("proj.simple://2").put({
"attr2": 5
})
gun.get("proj.simple://2").put({
"attr2": "zc"
}) // should fail.
}
let midTest = () => {
console.log("mid test")
gun.get("proj.person://4").put({
name: "ahmed"
})
gun.get("proj.person://4").put({
"name": "ahmed"
})
gun.get("proj.person://4").get("email").put({
"addr": "ahmed@gmail.com",
})
gun.get("proj.person://5").get("email").put({
"addr": "andrew@gmail.com",
})
gun.get("proj.person://5").get("email").put({
"addr": "dmdm@gmail.com",
})
gun.get("proj.person://5").get("email").put({
"addr": "notdmdm@gmail.com",
})
}
let advTest = () => {
console.log("advanced test")
gun.get("proj.human://7").put({
"name": "xmon"
})
gun.get("proj.human://7").get("phone").put({
"model": "samsung"
})
gun.get("proj.human://7").get("phone").get("os").put({
"name": "android"
})
gun.get("proj.human://8").put({
"name": "richxmon"
})
gun.get("proj.human://8").get("phone").put({
"model": "iphone"
})
gun.get("proj.human://8").get("phone").get("os").put({
"name": "ios"
})
gun.get("proj.human://8").get("list_favcolors").set("white")
gun.get("proj.human://8").get("list_favcolors").set("red")
gun.get("proj.human://8").get("list_favcolors").set("blue")
// gun.get("proj.human://8").get("list_favcolors").unset("red")
let python = gun.get('langs_python').put({name:'python'})
gun.get("proj.human://8").get("list_langs").set(python)
let ruby = gun.get('langs_ruby').put({name:'ruby'})
gun.get("proj.human://8").get("list_langs").set(ruby)
}
let nesetedListTest = () => {
gun.get("proj.programmar://8").get("list_langs").set({
"name": "python",
"list_releases": {
"0": "3.6",
"1": "3.7"
}
})
}
let unsetObjTest = () => {
let football = gun.get("footbal").put({name: 'football'})
let tennis = gun.get("tennis").put({name: 'tennis'})
gun.get("proj.programmar://9").get("list_hobbies").set(football);
gun.get("proj.programmar://9").get("list_hobbies").set(tennis);
gun.get("proj.programmar://9").get("list_hobbies").unset(tennis);
}
basicTest()
midTest()
advTest()
nesetedListTest()
unsetObjTest()
</script>