-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (24 loc) · 1.07 KB
/
index.js
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
document.addEventListener('DOMContentLoaded', async () => {
const insertAfter = (referenceNode, newNode) => {
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
}
const node = await Ipfs.create({ repo: 'ipfs-' + Math.random() })
window.node = node
const status = node.isOnline() ? 'online' : 'offline'
const id = await node.id()
console.log(`Node status: ${status}`)
const statusDOM = document.getElementById('status')
statusDOM.innerHTML = `Node status: ${status}`
const newDiv = document.createElement("div");
newDiv.id = "node"
const newContent = document.createTextNode(`ID: ${id.id}`);
newDiv.appendChild(newContent);
insertAfter(statusDOM, newDiv);
//const add = prompt("Enter text")
//const cid = await node.add(add)
//console.log(cid)
//document.getElementById("textStatus").innerHTML = "https://ipfs.io/ipfs/" + cid.path
// You can write more code here to use it. Use methods like
// node.add, node.get. See the API docs here:
// https://github.com/ipfs/js-ipfs/tree/master/packages/interface-ipfs-core
})