-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.htm
More file actions
126 lines (113 loc) · 2.85 KB
/
index.htm
File metadata and controls
126 lines (113 loc) · 2.85 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<style>
html, body {
margin: 0;
padding: 0;
height: 100%;
font-size: 32px;
font-family: consolas, "ubuntu mono", monospace;
}
body {
padding: 0 1rem;
position: relative;
}
.frame {
border: .25rem solid #1e77d3;
border-radius: 1rem;
margin: 1rem 0;
min-height: 5rem;
position: relative;
padding: .5rem 2.5rem .5rem .5rem;
}
.button {
border: 2px solid #333;
border-radius: .5rem;
width: 1.5rem;
height: 1.5rem;
text-align: center;
line-height: 1.5rem;
cursor: pointer;
background: #efefef;
font-family: initial;
user-select: none;
}
.add {
display: inline-block;
transform: rotate(45deg);
}
.close {
position: absolute;
top: .25rem;
right: .25rem;
}
.locals {
margin-bottom: .5rem;
}
.cell {
border: .25rem solid;
display: inline-block;
padding: .25rem .75rem;
}
.add-cell {
position: absolute;
top: 2.25rem;
right: .25rem;
}
</style>
</head>
<body>
<div id="frames">
<div class="button add">✕</div>
</div>
<script>
(() => {
const frames = document.getElementById('frames');
const addFrame = frames.querySelector('.add');
function closeFrame(e) {
frames.removeChild(e.currentTarget.parentNode);
}
function deleteCell(e) {
e.currentTarget.parentNode.removeChild(e.currentTarget);
}
function cell() {
const cell = document.createElement('div');
cell.classList.add('cell');
cell.contentEditable = 'plaintext-only';
// comment out this line for fun wiggle in firefox :)
cell.innerText = '\u200b';
cell.addEventListener('dblclick', deleteCell);
return cell;
}
function addCell(e) {
e.currentTarget.parentNode.appendChild(cell());
}
function newFrame() {
const frame = document.createElement('div');
frame.classList.add('frame');
const close = document.createElement('div');
close.classList.add('close', 'button');
close.addEventListener('click', closeFrame);
close.innerText = '✕';
frame.appendChild(close);
const locals = document.createElement('div');
locals.classList.add('locals');
locals.contentEditable = 'plaintext-only';
locals.innerText = 'locals: {}';
frame.appendChild(locals);
frame.appendChild(cell());
const add = document.createElement('add');
add.classList.add('button', 'add', 'add-cell');
add.innerText = '✕';
add.addEventListener('click', addCell);
frame.appendChild(add);
frames.insertBefore(frame, addFrame);
}
addFrame.addEventListener('click', newFrame);
newFrame();
})();
</script>
</body>
</html>