<!DOCTYPE html>
<html> <head>
<meta charset="utf-8">
<title>Toolbox Customization Codelab</title>
<link rel="stylesheet" href="toolbox_style.css">
<script src="StartingScreen.js"></script>
<script src="Simulator.js"></script>
<script src="ForwardBackward.js"></script>
<script src="TurnLeftRight.js"></script>
<style>
html,
body {
height: 100%;
}
body {
background-color: #ffffff;
font-family: sans-serif;
overflow: hidden;
}
h1 {
font-weight: normal;
font-size: 140%;
margin: 10px;
}
#blocklyDiv {
float: bottom;
height: 50%;
width: 100%;
}
</style>
</head>
<body>
<div id="blocklyDiv"></div>
<script>
const nameToolbox = {
// "categoryToolbox" is a Toolbox
"kind": "categoryToolbox",
"contents": [
// Main menu
{
// "category" is a Menu item
"kind": "category",
// The word "Simulator" is displayed on the Main menu
"name": "Simulator",
"contents": [
{
// "block" creates a block on the screen
"kind": "block",
// "typeSimulator" is the block name found in a .js file
"type": "typeSimulator"
},
]
},
// Main menu
{
// "category" is a Menu item
"kind": "category",
// The word "Movement" is displayed on the Main menu
"name": "Movement",
"contents": [
// Nested menu
{
// "category" is a Menu item
"kind": "category",
// The words "Forward or backward" are displayed on the Nested menu
"name": "Forward or backward",
"contents": [
{
// "block" creates a block on the screen
"kind": "block",
// "typeForwardBackward" is the block name found in a .js file
"type": "typeForwardBackward"
}
]
},
// Nested menu
{
// "category" is a Menu item
"kind": "category",
// The words "Turn left or right" are displayed on the Nested menu
"name": "Turn left or right",
"contents": [
{
// "block" creates a block on the screen
"kind": "block",
// "typeTurnLeftRight" is the block name found in a .js file
"type": "typeTurnLeftRight"
}
]
}
]
},
]
}
const workspace0 = Blockly.inject('blocklyDiv', {toolbox: nameToolbox});
// Place a block on the starting screen
Blockly.serialization.blocks.append({
type: 'typeStartingScreen',
// do not allow it to be deleted
deletable: false,
movable: false,
editable: false,
}, workspace0);
workspace0.addChangeListener(Blockly.Events.disableOrphans);
</script>
</body>
</html>