index.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Blockly Demo: Toolbox</title>
  6. <script src="../../blockly_compressed.js"></script>
  7. <script src="../../blocks_compressed.js"></script>
  8. <script src="../../msg/js/en.js"></script>
  9. <style>
  10. body {
  11. background-color: #fff;
  12. font-family: sans-serif;
  13. }
  14. h1 {
  15. font-weight: normal;
  16. font-size: 140%;
  17. }
  18. </style>
  19. </head>
  20. <body>
  21. <h1><a href="https://developers.google.com/blockly/">Blockly</a> &gt;
  22. <a href="../index.html">Demos</a> &gt; Toolbox</h1>
  23. <p>This is a demo of a complex category structure for the toolbox.</p>
  24. <p>&rarr; More info on the <a href="https://developers.google.com/blockly/guides/configure/web/toolbox">Toolbox</a>&hellip;</p>
  25. <div id="blocklyDiv" style="height: 600px; width: 800px;"></div>
  26. <xml id="toolbox" style="display: none">
  27. <category name="Logic">
  28. <category name="If">
  29. <block type="controls_if"></block>
  30. <block type="controls_if">
  31. <mutation else="1"></mutation>
  32. </block>
  33. <block type="controls_if">
  34. <mutation elseif="1" else="1"></mutation>
  35. </block>
  36. </category>
  37. <category name="Boolean">
  38. <block type="logic_compare"></block>
  39. <block type="logic_operation"></block>
  40. <block type="logic_negate"></block>
  41. <block type="logic_boolean"></block>
  42. <block type="logic_null"></block>
  43. <block type="logic_ternary"></block>
  44. </category>
  45. </category>
  46. <category name="Loops">
  47. <block type="controls_repeat_ext">
  48. <value name="TIMES">
  49. <block type="math_number">
  50. <field name="NUM">10</field>
  51. </block>
  52. </value>
  53. </block>
  54. <block type="controls_whileUntil"></block>
  55. <block type="controls_for">
  56. <field name="VAR">i</field>
  57. <value name="FROM">
  58. <block type="math_number">
  59. <field name="NUM">1</field>
  60. </block>
  61. </value>
  62. <value name="TO">
  63. <block type="math_number">
  64. <field name="NUM">10</field>
  65. </block>
  66. </value>
  67. <value name="BY">
  68. <block type="math_number">
  69. <field name="NUM">1</field>
  70. </block>
  71. </value>
  72. </block>
  73. <block type="controls_forEach"></block>
  74. <block type="controls_flow_statements"></block>
  75. </category>
  76. <category name="Math">
  77. <block type="math_number"></block>
  78. <block type="math_arithmetic"></block>
  79. <block type="math_single"></block>
  80. <block type="math_trig"></block>
  81. <block type="math_constant"></block>
  82. <block type="math_number_property"></block>
  83. <block type="math_round"></block>
  84. <block type="math_on_list"></block>
  85. <block type="math_modulo"></block>
  86. <block type="math_constrain">
  87. <value name="LOW">
  88. <block type="math_number">
  89. <field name="NUM">1</field>
  90. </block>
  91. </value>
  92. <value name="HIGH">
  93. <block type="math_number">
  94. <field name="NUM">100</field>
  95. </block>
  96. </value>
  97. </block>
  98. <block type="math_random_int">
  99. <value name="FROM">
  100. <block type="math_number">
  101. <field name="NUM">1</field>
  102. </block>
  103. </value>
  104. <value name="TO">
  105. <block type="math_number">
  106. <field name="NUM">100</field>
  107. </block>
  108. </value>
  109. </block>
  110. <block type="math_random_float"></block>
  111. </category>
  112. <category name="Lists">
  113. <block type="lists_create_empty"></block>
  114. <block type="lists_create_with"></block>
  115. <block type="lists_repeat">
  116. <value name="NUM">
  117. <block type="math_number">
  118. <field name="NUM">5</field>
  119. </block>
  120. </value>
  121. </block>
  122. <block type="lists_length"></block>
  123. <block type="lists_isEmpty"></block>
  124. <block type="lists_indexOf"></block>
  125. <block type="lists_getIndex"></block>
  126. <block type="lists_setIndex"></block>
  127. </category>
  128. <category name="Variables" custom="VARIABLE"></category>
  129. <category name="Functions" custom="PROCEDURE"></category>
  130. <sep></sep>
  131. <category name="Library" expanded="true">
  132. <category name="Randomize">
  133. <block type="procedures_defnoreturn">
  134. <mutation>
  135. <arg name="list"></arg>
  136. </mutation>
  137. <field name="NAME">randomize</field>
  138. <statement name="STACK">
  139. <block type="controls_for" inline="true">
  140. <field name="VAR">x</field>
  141. <value name="FROM">
  142. <block type="math_number">
  143. <field name="NUM">1</field>
  144. </block>
  145. </value>
  146. <value name="TO">
  147. <block type="lists_length" inline="false">
  148. <value name="VALUE">
  149. <block type="variables_get">
  150. <field name="VAR">list</field>
  151. </block>
  152. </value>
  153. </block>
  154. </value>
  155. <value name="BY">
  156. <block type="math_number">
  157. <field name="NUM">1</field>
  158. </block>
  159. </value>
  160. <statement name="DO">
  161. <block type="variables_set" inline="false">
  162. <field name="VAR">y</field>
  163. <value name="VALUE">
  164. <block type="math_random_int" inline="true">
  165. <value name="FROM">
  166. <block type="math_number">
  167. <field name="NUM">1</field>
  168. </block>
  169. </value>
  170. <value name="TO">
  171. <block type="lists_length" inline="false">
  172. <value name="VALUE">
  173. <block type="variables_get">
  174. <field name="VAR">list</field>
  175. </block>
  176. </value>
  177. </block>
  178. </value>
  179. </block>
  180. </value>
  181. <next>
  182. <block type="variables_set" inline="false">
  183. <field name="VAR">temp</field>
  184. <value name="VALUE">
  185. <block type="lists_getIndex" inline="true">
  186. <mutation statement="false" at="true"></mutation>
  187. <field name="MODE">GET</field>
  188. <field name="WHERE">FROM_START</field>
  189. <value name="AT">
  190. <block type="variables_get">
  191. <field name="VAR">y</field>
  192. </block>
  193. </value>
  194. <value name="VALUE">
  195. <block type="variables_get">
  196. <field name="VAR">list</field>
  197. </block>
  198. </value>
  199. </block>
  200. </value>
  201. <next>
  202. <block type="lists_setIndex" inline="false">
  203. <value name="AT">
  204. <block type="variables_get">
  205. <field name="VAR">y</field>
  206. </block>
  207. </value>
  208. <value name="LIST">
  209. <block type="variables_get">
  210. <field name="VAR">list</field>
  211. </block>
  212. </value>
  213. <value name="TO">
  214. <block type="lists_getIndex" inline="true">
  215. <mutation statement="false" at="true"></mutation>
  216. <field name="MODE">GET</field>
  217. <field name="WHERE">FROM_START</field>
  218. <value name="AT">
  219. <block type="variables_get">
  220. <field name="VAR">x</field>
  221. </block>
  222. </value>
  223. <value name="VALUE">
  224. <block type="variables_get">
  225. <field name="VAR">list</field>
  226. </block>
  227. </value>
  228. </block>
  229. </value>
  230. <next>
  231. <block type="lists_setIndex" inline="false">
  232. <value name="AT">
  233. <block type="variables_get">
  234. <field name="VAR">x</field>
  235. </block>
  236. </value>
  237. <value name="LIST">
  238. <block type="variables_get">
  239. <field name="VAR">list</field>
  240. </block>
  241. </value>
  242. <value name="TO">
  243. <block type="variables_get">
  244. <field name="VAR">temp</field>
  245. </block>
  246. </value>
  247. </block>
  248. </next>
  249. </block>
  250. </next>
  251. </block>
  252. </next>
  253. </block>
  254. </statement>
  255. </block>
  256. </statement>
  257. </block>
  258. </category>
  259. <category name="Jabberwocky">
  260. <block type="text_print">
  261. <value name="TEXT">
  262. <block type="text">
  263. <field name="TEXT">'Twas brillig, and the slithy toves</field>
  264. </block>
  265. </value>
  266. <next>
  267. <block type="text_print">
  268. <value name="TEXT">
  269. <block type="text">
  270. <field name="TEXT"> Did gyre and gimble in the wabe:</field>
  271. </block>
  272. </value>
  273. <next>
  274. <block type="text_print">
  275. <value name="TEXT">
  276. <block type="text">
  277. <field name="TEXT">All mimsy were the borogroves,</field>
  278. </block>
  279. </value>
  280. <next>
  281. <block type="text_print">
  282. <value name="TEXT">
  283. <block type="text">
  284. <field name="TEXT"> And the mome raths outgrabe.</field>
  285. </block>
  286. </value>
  287. </block>
  288. </next>
  289. </block>
  290. </next>
  291. </block>
  292. </next>
  293. </block>
  294. <block type="text_print">
  295. <value name="TEXT">
  296. <block type="text">
  297. <field name="TEXT">"Beware the Jabberwock, my son!</field>
  298. </block>
  299. </value>
  300. <next>
  301. <block type="text_print">
  302. <value name="TEXT">
  303. <block type="text">
  304. <field name="TEXT"> The jaws that bite, the claws that catch!</field>
  305. </block>
  306. </value>
  307. <next>
  308. <block type="text_print">
  309. <value name="TEXT">
  310. <block type="text">
  311. <field name="TEXT">Beware the Jubjub bird, and shun</field>
  312. </block>
  313. </value>
  314. <next>
  315. <block type="text_print">
  316. <value name="TEXT">
  317. <block type="text">
  318. <field name="TEXT"> The frumious Bandersnatch!"</field>
  319. </block>
  320. </value>
  321. </block>
  322. </next>
  323. </block>
  324. </next>
  325. </block>
  326. </next>
  327. </block>
  328. </category>
  329. </category>
  330. </xml>
  331. <script>
  332. var workspace = Blockly.inject('blocklyDiv',
  333. {media: '../../media/',
  334. toolbox: document.getElementById('toolbox')});
  335. </script>
  336. </body>
  337. </html>