-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
200 lines (152 loc) · 7.92 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
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
198
199
200
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!-- blockly resources: [harrison] -->
<!-- https://developers.google.com/blockly/guides/get-started/web -->
<!-- https://developers.google.com/blockly/guides/app-integration/running-javascript -->
<!-- https://developers.google.com/blockly/guides/configure/web/fixed-size -->
<!-- block categories -->
<!-- https://developers.google.com/blockly/guides/configure/web/toolbox#block_groups -->
<!-- blockly demo with list of block types (originally had to compile this myself) -->
<!-- https://blockly-demo.appspot.com/static/demos/blockfactory/index.html -->
<!-- custom blocks -->
<!-- https://developers.google.com/blockly/guides/create-custom-blocks/define-blocks -->
<!-- https://developers.google.com/blockly/guides/create-custom-blocks/generating-code -->
<!-- https://blockly-demo.appspot.com/static/demos/blockfactory/index.html -->
<!-- blockly core -->
<script src="blockly/blockly_compressed.js"></script>
<script src="blockly/blocks_compressed.js"></script>
<script src="blockly/javascript_compressed.js"></script>
<!-- messages for user's language -->
<script src="blockly/msg/js/en.js"></script>
<!-- jquery, bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- override bootstrap with my own css -->
<link rel="stylesheet" href="css/styles.css">
<!-- disable mobile zoom before iOS 10 -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<!-- code to generate js from blockly -->
<script type="text/javascript" src="js/generate.js"></script>
<script type="text/javascript">
function initialize() {
$('#myModal').on('shown.bs.modal', function (e) {
/* workaround for Blockly to render within Bootstrap modal */
window.dispatchEvent(new Event('resize'));
/* https://github.com/google/blockly/issues/56 */
/* fix text fields */
$(document).off('focusin.modal');
});
}
function runCodeClicked() {
try {
var code = Blockly.JavaScript.workspaceToCode(workspace);
/* debug */
alert("code: " + code);
eval(code);
} catch (e) {
alert(e);
}
}
</script>
<!-- custom blocks -->
<script type="text/javascript" src="blockly-custom/blocks/game.js"></script>
<script type="text/javascript" src="blockly-custom/generators/game.js"></script>
<!-- game engine -->
<script type="text/javascript" src="phaser/build/phaser.min.js"></script>
</head>
<body onload="initialize()">
<div class="container">
<div class="row">
<button type="button" class="btn btn-primary btn-large" data-toggle="modal" data-target="#myModal">Show Code Terminal</button>
</div>
<div class="row">
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="codeTerminalLabel" aria-hidden="true">
<div class="modal-dialog" style="width: 60%; height: 80%;" id="thing2">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="codeTerminalLabel">Code Terminal</h4>
</div>
<div class="modal-body">
<!-- blockly div -->
<div id="blocklyDiv"></div>
<!-- blockly toolbox -->
<xml id="toolbox">
<!-- divided by category file name -->
<category name="Robot_controls" colour="20">
<block type="move_character"></block>
<block type="character_jump"></block>
<block type="repeat"></block>
</category>
<category name="Gate_controls" colour="20">
<block type="move_gate"></block>
<block type="repeat"></block>
</category>
<category name="Platform_controls" colour="20">
<block type="move_platform_horizontal"></block>
<block type="move_platform_vertical"></block>
<block type="repeat"></block>
</category>
<category name="Logic" colour="210">
<block type="logic_boolean"></block>
<block type="logic_compare"></block>
<block type="logic_operation"></block>
<block type="logic_negate"></block>
<block type="logic_null"></block>
<block type="logic_ternary"></block>
<block type="controls_if"></block>
<block type="controls_ifelse"></block>
<block type="controls_if_if"></block>
<block type="controls_if_elseif"></block>
<block type="controls_if_else"></block>
</category>
<category name="Loops" colour="120">
<block type="controls_repeat_ext"></block>
<block type="controls_repeat"></block>
<block type="controls_whileUntil"></block>
<block type="controls_for"></block>
<block type="controls_forEach"></block>
<block type="controls_flow_statements"></block>
</category>
<category name="Math" colour="230">
<block type="math_number"></block>
<block type="math_arithmetic"></block>
<block type="math_single"></block>
<block type="math_trig"></block>
<block type="math_constant"></block>
<block type="math_number_property"></block>
<block type="math_change"></block>
<block type="math_round"></block>
<block type="math_on_list"></block>
<block type="math_modulo"></block>
<block type="math_constrain"></block>
<block type="math_random_int"></block>
<block type="math_random_float"></block>
</category>
<!-- skipped procedures.js and variables.js -->
</xml>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" data-dismiss="modal" onclick="runCodeClicked()">Run Code</button>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div id="game" class="overlay"></div>
<div id="orientation"></div>
</div>
</div>
<!-- inject blockly into above div -->
<script>
var workspace = Blockly.inject('blocklyDiv', {toolbox: document.getElementById('toolbox')} );
</script>
<!-- inject game engine into above div -->
<script type="text/javascript" src="game/title.js"></script>
</body>
</html>