-
Notifications
You must be signed in to change notification settings - Fork 0
/
Auto-fill.html
197 lines (157 loc) · 4.72 KB
/
Auto-fill.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
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<html>
<title>Launcher</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="rabbit.png"><style>
body { background: rgba(18, 18, 18, 1); color: rgba(255,255,255,.87);
padding:0px; margin:0px;}
@font-face {
font-family: Mono;
src: url("lib/RobotoMono-Light.ttf") format("truetype");
}
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: url("lib/MaterialIcons-Regular.ttf") format('truetype')
}
.material-icons {
font-family: 'Material Icons' !important;
font-weight: normal;
font-style: normal;
font-size: 24px; /* Preferred icon size */
display: inline-block;
line-height: 1;
text-transform: none;
letter-spacing: normal;
word-wrap: normal;
white-space: nowrap;
direction: ltr;
/* Support for all WebKit browsers. */
-webkit-font-smoothing: antialiased;
/* Support for Safari and Chrome. */
text-rendering: optimizeLegibility;
/* Support for Firefox. */
-moz-osx-font-smoothing: grayscale;
/* Support for IE. */
font-feature-settings: 'liga';
}
* {
font-family: Mono;
font-size: 16px;
}
pre, code, pre > * {
font-family: Mono;
}
dialog {
background-color: rgba(18,18,18,1);
color: rgba(255,255,255,.87);
border: none;
padding: 0px;
box-shadow: 0 24px 38px 3px rgba(0,0,0,0.14), 0 9px 46px 8px rgba(0,0,0,0.12), 0 11px 15px -7px rgba(0,0,0,0.20);
box-sizing: border-box;
}
.card {
background-color: rgba(18,18,18,1);
color: rgba(255,255,255,.87);
border: none;
padding: 12px 16px;
box-sizing: border-box;
}
button, textarea, input{
background: none;
color: rgba(255,255,255,.87);
border: none;
border-bottom: 2px solid rgb(220, 20, 60);
outline: none;
box-sizing: border-box;
}
.glow_crimson, .tile_crimson:hover, .tile_crimson:focus{
box-shadow: 0 4px 5px 0 rgba(220, 20, 60, 0.14), 0 1px 10px 0 rgba(220, 20, 60, 0.12), 0 2px 4px -1px rgba(220, 20, 60, 0.20);
background: rgb(220, 20, 60) !important;
}
.animate {
transition-timing-function: cubic-bezier(0.4, 0.0, 0.2, 1);
transition: all 0.3s;
}
::placeholder {
color: rgba(255,255,255,.6);
}
</style>
<body onload="brython({indexedDB: false})"></body>
<script src="lib/brython.js"></script>
<script type="text/python">
from browser.html import *
import _jsre as re
from browser import window
from browser import document as doc
class Tile(DIV):
def __init__(self, text, x=0, y=0, width=0, height=0, display='inline',
opacity=1, axis=('left', 'top'), font_size='24px', **kw):
for k, v in (
(axis[0], x), (axis[1], y),
('width', width), ('height', height),
('display', display), ('opacity', opacity),
('box-sizing', 'border-box'), ('position', 'absolute')):
self.style[k] = v
super().__init__(DIV(text,
style={
'position': 'absolute',
'left': '50%', 'top': '50%',
'transform': 'translate(-50%, -50%)',
'font-size': font_size}), **kw)
@property
def text(self):
return self.children[0].text
@text.setter
def text(self, value):
self.children[0].text = value
class Icon(I):
def __init__(self, *l, font_size='32px', **kw):
super().__init__(*l, **{'Class': 'material-icons', **kw})
self.style['font-size'] = font_size
def popup(root, width='auto', height='auto'):
if isinstance(root, (tuple, list, str, int, float, set, dict)):
root = DIV(root)
d = DIALOG(root)
root.style['width'] = width
root.style['height'] = height
def on_click(ev):
d.remove()
d.bind('close', on_click)
doc <= d
d.showModal()
return d
body = doc.querySelector('body')
viewport = body.width, body.height
tb = TEXTAREA(style={'width': '100%', 'height': '100%'})
run = Tile(Icon('play_arrow'), tabindex=0, x=0, y=0, width=64, height=64, axis=('right', 'bottom'), Class='tile_crimson animate')
parts = {}
def run_text(ev):
parts.clear()
parts.update({i: INPUT(placeholder=i, style={'width':'100%'}) for i in re.findall(r'\[(.*?)\]', tb.value)})
build = Tile(Icon('play_arrow'), tabindex=0, x=0, y=0, width=64, height=64, axis=('right', 'bottom'), Class='tile_crimson animate')
def build_text(ev):
ev.preventDefault()
text = tb.value
for k, v in parts.items():
text = text.replace(k, v.value)
popup(TEXTAREA(text), 500, 500)
build.bind('click', build_text)
build.bind('keypress', build_text)
popup(list(parts.values()) + [build], 500, 500)
run.bind('click', run_text)
run.bind('keypress', run_text)
root = tb, run
body <= root
</script>
<script>
var _logger = function(msg){
if(msg != "using indexedDB for stdlib modules cache"){
alert(msg)
}
}
//console.log=_logger
//console.error=_logger
//console.warning=_logger
</script>
</html>