-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathdoc-intro.html
More file actions
50 lines (48 loc) · 1.52 KB
/
doc-intro.html
File metadata and controls
50 lines (48 loc) · 1.52 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
<!doctype html>
<html>
<head>
<!-- this is a way to automatically bootstrap polyscript -->
<script type="module" src="https://esm.sh/polyscript"></script>
</head>
<body>
<script type="micropython" id="my-target">
from js import document
# explicitly grab the current script as target
my_target = document.getElementById('my-target')
# verify it is the exact same node with same id
print(document.currentScript.id == my_target.id)
</script>
<script type="micropython">
from polyscript import XWorker
print(XWorker != None)
</script>
<script type="micropython">
def print_type(event, double):
# logs "click 4"
print(f"{event.type} {double(2)}")
</script>
<button micropython-click="print_type(event, lambda x: x * 2)">
print type
</button>
<script type="micropython">
def log():
print(1)
</script>
<!-- note the env value -->
<script type="micropython" env="two">
def log():
print(2)
</script>
<!-- note the micropython-env value -->
<button
micropython-env="two"
micropython-click="log()"
>
log
</button>
<script type="micropython">
from js import document
document.body.append('polyscript')
</script>
</body>
</html>