index.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  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_change">
  84. <value name="DELTA">
  85. <block type="math_number">
  86. <field name="NUM">1</field>
  87. </block>
  88. </value>
  89. </block>
  90. <block type="math_round"></block>
  91. <block type="math_on_list"></block>
  92. <block type="math_modulo"></block>
  93. <block type="math_constrain">
  94. <value name="LOW">
  95. <block type="math_number">
  96. <field name="NUM">1</field>
  97. </block>
  98. </value>
  99. <value name="HIGH">
  100. <block type="math_number">
  101. <field name="NUM">100</field>
  102. </block>
  103. </value>
  104. </block>
  105. <block type="math_random_int">
  106. <value name="FROM">
  107. <block type="math_number">
  108. <field name="NUM">1</field>
  109. </block>
  110. </value>
  111. <value name="TO">
  112. <block type="math_number">
  113. <field name="NUM">100</field>
  114. </block>
  115. </value>
  116. </block>
  117. <block type="math_random_float"></block>
  118. </category>
  119. <category name="Lists">
  120. <block type="lists_create_empty"></block>
  121. <block type="lists_create_with"></block>
  122. <block type="lists_repeat">
  123. <value name="NUM">
  124. <block type="math_number">
  125. <field name="NUM">5</field>
  126. </block>
  127. </value>
  128. </block>
  129. <block type="lists_length"></block>
  130. <block type="lists_isEmpty"></block>
  131. <block type="lists_indexOf"></block>
  132. <block type="lists_getIndex"></block>
  133. <block type="lists_setIndex"></block>
  134. </category>
  135. <category name="Variables" custom="VARIABLE"></category>
  136. <category name="Functions" custom="PROCEDURE"></category>
  137. <sep></sep>
  138. <category name="Library" expanded="true">
  139. <category name="Randomize">
  140. <block type="procedures_defnoreturn">
  141. <mutation>
  142. <arg name="list"></arg>
  143. </mutation>
  144. <field name="NAME">randomize</field>
  145. <statement name="STACK">
  146. <block type="controls_for" inline="true">
  147. <field name="VAR">x</field>
  148. <value name="FROM">
  149. <block type="math_number">
  150. <field name="NUM">1</field>
  151. </block>
  152. </value>
  153. <value name="TO">
  154. <block type="lists_length" inline="false">
  155. <value name="VALUE">
  156. <block type="variables_get">
  157. <field name="VAR">list</field>
  158. </block>
  159. </value>
  160. </block>
  161. </value>
  162. <value name="BY">
  163. <block type="math_number">
  164. <field name="NUM">1</field>
  165. </block>
  166. </value>
  167. <statement name="DO">
  168. <block type="variables_set" inline="false">
  169. <field name="VAR">y</field>
  170. <value name="VALUE">
  171. <block type="math_random_int" inline="true">
  172. <value name="FROM">
  173. <block type="math_number">
  174. <field name="NUM">1</field>
  175. </block>
  176. </value>
  177. <value name="TO">
  178. <block type="lists_length" inline="false">
  179. <value name="VALUE">
  180. <block type="variables_get">
  181. <field name="VAR">list</field>
  182. </block>
  183. </value>
  184. </block>
  185. </value>
  186. </block>
  187. </value>
  188. <next>
  189. <block type="variables_set" inline="false">
  190. <field name="VAR">temp</field>
  191. <value name="VALUE">
  192. <block type="lists_getIndex" inline="true">
  193. <mutation statement="false" at="true"></mutation>
  194. <field name="MODE">GET</field>
  195. <field name="WHERE">FROM_START</field>
  196. <value name="AT">
  197. <block type="variables_get">
  198. <field name="VAR">y</field>
  199. </block>
  200. </value>
  201. <value name="VALUE">
  202. <block type="variables_get">
  203. <field name="VAR">list</field>
  204. </block>
  205. </value>
  206. </block>
  207. </value>
  208. <next>
  209. <block type="lists_setIndex" inline="false">
  210. <value name="AT">
  211. <block type="variables_get">
  212. <field name="VAR">y</field>
  213. </block>
  214. </value>
  215. <value name="LIST">
  216. <block type="variables_get">
  217. <field name="VAR">list</field>
  218. </block>
  219. </value>
  220. <value name="TO">
  221. <block type="lists_getIndex" inline="true">
  222. <mutation statement="false" at="true"></mutation>
  223. <field name="MODE">GET</field>
  224. <field name="WHERE">FROM_START</field>
  225. <value name="AT">
  226. <block type="variables_get">
  227. <field name="VAR">x</field>
  228. </block>
  229. </value>
  230. <value name="VALUE">
  231. <block type="variables_get">
  232. <field name="VAR">list</field>
  233. </block>
  234. </value>
  235. </block>
  236. </value>
  237. <next>
  238. <block type="lists_setIndex" inline="false">
  239. <value name="AT">
  240. <block type="variables_get">
  241. <field name="VAR">x</field>
  242. </block>
  243. </value>
  244. <value name="LIST">
  245. <block type="variables_get">
  246. <field name="VAR">list</field>
  247. </block>
  248. </value>
  249. <value name="TO">
  250. <block type="variables_get">
  251. <field name="VAR">temp</field>
  252. </block>
  253. </value>
  254. </block>
  255. </next>
  256. </block>
  257. </next>
  258. </block>
  259. </next>
  260. </block>
  261. </statement>
  262. </block>
  263. </statement>
  264. </block>
  265. </category>
  266. <category name="Jabberwocky">
  267. <block type="text_print">
  268. <value name="TEXT">
  269. <block type="text">
  270. <field name="TEXT">'Twas brillig, and the slithy toves</field>
  271. </block>
  272. </value>
  273. <next>
  274. <block type="text_print">
  275. <value name="TEXT">
  276. <block type="text">
  277. <field name="TEXT"> Did gyre and gimble in the wabe:</field>
  278. </block>
  279. </value>
  280. <next>
  281. <block type="text_print">
  282. <value name="TEXT">
  283. <block type="text">
  284. <field name="TEXT">All mimsy were the borogroves,</field>
  285. </block>
  286. </value>
  287. <next>
  288. <block type="text_print">
  289. <value name="TEXT">
  290. <block type="text">
  291. <field name="TEXT"> And the mome raths outgrabe.</field>
  292. </block>
  293. </value>
  294. </block>
  295. </next>
  296. </block>
  297. </next>
  298. </block>
  299. </next>
  300. </block>
  301. <block type="text_print">
  302. <value name="TEXT">
  303. <block type="text">
  304. <field name="TEXT">"Beware the Jabberwock, my son!</field>
  305. </block>
  306. </value>
  307. <next>
  308. <block type="text_print">
  309. <value name="TEXT">
  310. <block type="text">
  311. <field name="TEXT"> The jaws that bite, the claws that catch!</field>
  312. </block>
  313. </value>
  314. <next>
  315. <block type="text_print">
  316. <value name="TEXT">
  317. <block type="text">
  318. <field name="TEXT">Beware the Jubjub bird, and shun</field>
  319. </block>
  320. </value>
  321. <next>
  322. <block type="text_print">
  323. <value name="TEXT">
  324. <block type="text">
  325. <field name="TEXT"> The frumious Bandersnatch!"</field>
  326. </block>
  327. </value>
  328. </block>
  329. </next>
  330. </block>
  331. </next>
  332. </block>
  333. </next>
  334. </block>
  335. </category>
  336. </category>
  337. </xml>
  338. <script>
  339. var workspace = Blockly.inject('blocklyDiv',
  340. {media: '../../media/',
  341. toolbox: document.getElementById('toolbox')});
  342. </script>
  343. </body>
  344. </html>