-
Notifications
You must be signed in to change notification settings - Fork 2
/
script.js
22 lines (18 loc) · 697 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function updateCode() {
const code = document.querySelector('pre code');
code.textContent = document.querySelector('fc').innerHTML.trimLeft();
hljs.highlightBlock(code);
}
const controls = document.getElementById('controls');
function listener(evt) {
const [id, _, prop] = evt.target.parentElement.textContent.split(' ');
document.getElementById(id).style[prop] = `${evt.target.value}px`;
updateCode();
}
controls.addEventListener('click', listener);
controls.addEventListener('keyup', listener);
for (const node of controls.children) {
const [id, _, prop] = node.textContent.split(' ');
document.getElementById(id).style[prop] = `${node.children[0].value}px`;
}
updateCode();