diff --git a/tests/playground.html b/tests/playground.html index 8e63815ea..596e8f373 100644 --- a/tests/playground.html +++ b/tests/playground.html @@ -77,37 +77,42 @@ function start() { document.forms.options.elements.dir.selectedIndex = Number(rtl); var toolbox = getToolboxElement(); document.forms.options.elements.toolbox.selectedIndex = - Number(toolbox.getElementsByTagName('category').length == 0); + getToolboxFormIndex(toolbox.id); match = location.search.match(/side=([^&]+)/); var side = match ? match[1] : 'start'; document.forms.options.elements.side.value = side; // Create main workspace. workspace = Blockly.inject('blocklyDiv', - {comments: true, - collapse: true, - disable: true, - grid: - {spacing: 25, - length: 3, - colour: '#ccc', - snap: true}, - horizontalLayout: side == 'top' || side == 'bottom', - maxBlocks: Infinity, - media: '../media/', - oneBasedIndex: true, - readOnly: false, - rtl: rtl, - scrollbars: true, - toolbox: toolbox, - toolboxPosition: side == 'top' || side == 'start' ? 'start' : 'end', - zoom: - {controls: true, - wheel: true, - startScale: 1.0, - maxScale: 4, - minScale: .25, - scaleSpeed: 1.1} - }); + { + comments: true, + collapse: true, + disable: true, + grid: + { + spacing: 25, + length: 3, + colour: '#ccc', + snap: true + }, + horizontalLayout: side == 'top' || side == 'bottom', + maxBlocks: Infinity, + media: '../media/', + oneBasedIndex: true, + readOnly: false, + rtl: rtl, + scrollbars: true, + toolbox: toolbox, + toolboxPosition: side == 'top' || side == 'start' ? 'start' : 'end', + zoom: + { + controls: true, + wheel: true, + startScale: 1.0, + maxScale: 4, + minScale: .25, + scaleSpeed: 1.1 + } + }); // Restore previously displayed text. if (sessionStorage) { var text = sessionStorage.getItem('textarea'); @@ -137,7 +142,24 @@ function setBackgroundColor() { function getToolboxElement() { var match = location.search.match(/toolbox=([^&]+)/); - return document.getElementById('toolbox-' + (match ? match[1] : 'categories')); + // Default to the basic toolbox with categories and untyped variables, + // but override that if the toolbox type is set in the URL. + var toolboxSuffix = (match ? match[1] : 'categories'); + // The three possible values are: "simple", "categories", + // "categories-typed-variables". + return document.getElementById('toolbox-' + toolboxSuffix); +} + +function getToolboxFormIndex(id) { + if (id == 'toolbox-categories') { + return 0; + } else if (id == 'toolbox-categories-typed-variables') { + return 1; + } else if (id == 'toolbox-simple') { + return 2; + } + // Didn't recognize it. + return 0; } function toXml() { @@ -301,7 +323,8 @@ h1 {

+ + + + + + +