-
Notifications
You must be signed in to change notification settings - Fork 10
/
flow.js
28 lines (23 loc) · 808 Bytes
/
flow.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
function createButton (parent, emoji, action) {
const node = document.createElement('BUTTON')
node.innerHTML = emoji
node.onclick = action
parent.appendChild(node)
}
function clickControl (flowDiv, clickHistory) {
if (!flowDiv) {
return
}
const ulNode = document.createElement('UL')
clickHistory.subscribe((data, obj) => {
const node = document.createElement('LI')
createButton(node, '❌', x => ulNode.removeChild(node))
createButton(node, '🢁', x => node.previousElementSibling?.before(node))
createButton(node, '🢃', x => node.nextElementSibling?.after(node))
const textnode = document.createTextNode(data.className + ' ' + data.name)
node.appendChild(textnode)
ulNode.appendChild(node)
})
flowDiv.appendChild(ulNode)
}
export { clickControl }