-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
43 lines (40 loc) · 929 Bytes
/
index.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
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<title>GunDB Hello</title>
<style>
body {
font-family: sans-serif;
color: #303438;
text-align: center;
}
</style>
</head>
<body>
<h1>GunDB Hello World </h1>
<p>Open your web console</p>
<!-- Loads gun -->
<script src='//rawgit.com/amark/gun/master/gun.js'></script>
<script>
(function () {
// Sync this gun instance with the server.
var gun = Gun([
location.origin+'/gun',
]);
// Reads key 'data'.
var data = gun.get('data');
// Exposed so the JS console can see it.
window.data = data;
window.gun = gun;
console.log('Gun reference exposed as %cwindow.data', 'color: red');
// Writes a value to the key 'data'.
data.put({ message: 'Hello world!' });
// Listen for real-time change events.
data.get('message').on(function (message) {
console.log('Message:', message);
});
}())
</script>
</body>
</html>