forked from noahcoolboy/block-hill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
69 lines (63 loc) · 2.03 KB
/
index.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
<html>
<head></head>
<body>
<script src="blockly/blockly_compressed.js"></script>
<script src="blockly/blocks_compressed.js"></script>
<script src="blockly/msg/js/en.js"></script>
<script src="blockly/javascript_compressed.js"></script>
<script src="definitions.js"></script>
<script src="stubs.js"></script>
<script src="toolbox.js"></script>
<style>
td {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
border: 1px solid grey;
border-bottom: none;
padding: 5px 19px;
cursor: pointer;
}
</style>
<table>
<tbody>
<tr>
<td id="work">Workspace</td>
<td id="code">Code</td>
</tr>
</tbody>
</table>
<div id="blocklyDiv" syle="height: 100%; width: 100%;"></div>
<span id="codespan" syle="height: 100%; width: 100%;">
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa
</span>
<script>
var workspace = Blockly.inject("blocklyDiv", {
toolbox: window.toolbox,
grid: {
spacing: 50,
length: 5,
colour: "#ccc",
snap: true
},
trashcan: true,
maxTrashcanContents: 0,
sounds: true,
zoom: {
controls: true,
wheel: true,
scaleSpeed: 1.01
},
collapse: true,
comments: true
})
document.getElementById("code").addEventListener("click", () => {
document.getElementById("blocklyDiv").hidden = true
document.getElementById("codespan").hidden = false
document.getElementById("codespan").innerText = Blockly.JavaScript.workspaceToCode(workspace)
})
document.getElementById("work").addEventListener("click", () => {
document.getElementById("codespan").hidden = true
document.getElementById("blocklyDiv").hidden = false
})
</script>
</body>
</html>