Increase commonality between playgrounds.

This commit is contained in:
Neil Fraser
2016-06-05 15:32:54 -07:00
parent 266e2ffa9a
commit f642fa80d5
2 changed files with 143 additions and 175 deletions

View File

@@ -70,12 +70,11 @@ function start() {
document.forms.options.elements.dir.selectedIndex = Number(rtl);
var match = location.search.match(/toolbox=([^&]+)/);
var toolbox =
document.getElementById('toolbox-' + (match ? match[1] : 'simple'));
document.getElementById('toolbox-' + (match ? match[1] : 'categories'));
document.forms.options.elements.toolbox.selectedIndex =
Number(toolbox.getElementsByTagName('category').length == 0);
match = location.search.match(/side=([^&]+)/);
var side = match ? match[1] : 'start';
console.log(side)
document.forms.options.elements.side.value = side;
// Create main workspace.
workspace = Blockly.inject('blocklyDiv',
@@ -323,6 +322,77 @@ h1 {
<div id="blocklyDiv"></div>
<h1>Blockly Playground</h1>
<p><a href="javascript:void(workspace.setVisible(true))">Show</a>
- <a href="javascript:void(workspace.setVisible(false))">Hide</a></p>
<form id="options">
<select name="dir" onchange="document.forms.options.submit()">
<option value="ltr">LTR</option>
<option value="rtl">RTL</option>
</select>
<select name="toolbox" onchange="document.forms.options.submit()">
<option value="categories">Categories</option>
<option value="simple">Simple</option>
</select>
<select name="side" onchange="document.forms.options.submit()">
<option value="start">Start</option>
<option value="end">End</option>
<option value="top">Top</option>
<option value="bottom">Bottom</option>
</select>
</form>
<p>
<input type="button" value="Export to XML" onclick="toXml()">
&nbsp;
<input type="button" value="Import from XML" onclick="fromXml()" id="import">
<br>
<input type="button" value="To JavaScript" onclick="toCode('JavaScript')">
&nbsp;
<input type="button" value="To Python" onclick="toCode('Python')">
&nbsp;
<input type="button" value="To PHP" onclick="toCode('PHP')">
&nbsp;
<input type="button" value="To Lua" onclick="toCode('Lua')">
&nbsp;
<input type="button" value="To Dart" onclick="toCode('Dart')">
<br>
<textarea id="importExport" style="width: 26%; height: 12em"
onchange="taChange();" onkeyup="taChange()"></textarea>
</p>
<p>
Stress test: &nbsp;
<input type="button" value="Airstrike!" onclick="airstrike(100)">
<input type="button" value="Spaghetti!" onclick="spaghetti(8)">
<input type="button" value="Fake some drags!" onclick="fakeManyDrags()">
</p>
<p>
Log events: &nbsp;
<input type="checkbox" onclick="logEvents(this.checked)" id="logCheck">
</p>
<xml id="toolbox-simple" style="display: none">
<block type="controls_if"></block>
<block type="logic_compare"></block>
<!-- <block type="control_repeat"></block> -->
<block type="logic_operation"></block>
<block type="controls_repeat_ext">
<value name="TIMES">
<shadow type="math_number">
<field name="NUM">10</field>
</shadow>
</value>
</block>
<block type="logic_operation"></block>
<block type="logic_negate"></block>
<block type="logic_boolean"></block>
<block type="logic_null" disabled="true"></block>
<block type="logic_ternary"></block>
</xml>
<xml id="toolbox-categories" style="display: none">
<category name="Logic" colour="210">
<block type="controls_if"></block>
@@ -627,68 +697,5 @@ h1 {
<category name="Variables" colour="330" custom="VARIABLE"></category>
<category name="Functions" colour="290" custom="PROCEDURE"></category>
</xml>
<xml id="toolbox-simple" style="display: none">
<block type="controls_if"></block>
<block type="logic_compare"></block>
<block type="controls_repeat_ext"></block>
<block type="math_number"></block>
<block type="math_arithmetic"></block>
<block type="text"></block>
<block type="text_print"></block>
</xml>
<h1>Blockly Playground</h1>
<p><a href="javascript:void(workspace.setVisible(true))">Show</a>
- <a href="javascript:void(workspace.setVisible(false))">Hide</a></p>
<form id="options">
<select name="dir" onchange="document.forms.options.submit()">
<option value="ltr">LTR</option>
<option value="rtl">RTL</option>
</select>
<select name="toolbox" onchange="document.forms.options.submit()">
<option value="categories">Categories</option>
<option value="simple">Simple</option>
</select>
<select name="side" onchange="document.forms.options.submit()">
<option value="start">Start</option>
<option value="end">End</option>
<option value="top">Top</option>
<option value="bottom">Bottom</option>
</select>
</form>
<p>
<input type="button" value="Export to XML" onclick="toXml()">
&nbsp;
<input type="button" value="Import from XML" onclick="fromXml()" id="import">
<br>
<input type="button" value="To JavaScript" onclick="toCode('JavaScript')">
&nbsp;
<input type="button" value="To Python" onclick="toCode('Python')">
&nbsp;
<input type="button" value="To PHP" onclick="toCode('PHP')">
&nbsp;
<input type="button" value="To Lua" onclick="toCode('Lua')">
&nbsp;
<input type="button" value="To Dart" onclick="toCode('Dart')">
<br>
<textarea id="importExport" style="width: 26%; height: 12em"
onchange="taChange();" onkeyup="taChange()"></textarea>
</p>
<p>
Stress test: &nbsp;
<input type="button" value="Airstrike!" onclick="airstrike(100)">
<input type="button" value="Spaghetti!" onclick="spaghetti(8)">
<input type="button" value="Fake some drags!" onclick="fakeManyDrags()">
</p>
<p>
Log events: &nbsp;
<input type="checkbox" onclick="logEvents(this.checked)" id="logCheck">
</p>
</body>
</html>