multi_playground.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Multi-toolbox Playground</title>
  6. <script src="../blockly_uncompressed.js"></script>
  7. <script src="../msg/messages.js"></script>
  8. <script src="../blocks/logic.js"></script>
  9. <script src="../blocks/loops.js"></script>
  10. <script src="../blocks/math.js"></script>
  11. <script src="../blocks/text.js"></script>
  12. <script src="../blocks/lists.js"></script>
  13. <script src="../blocks/colour.js"></script>
  14. <script src="../blocks/variables.js"></script>
  15. <script src="../blocks/procedures.js"></script>
  16. <script>
  17. 'use strict';
  18. var options = {
  19. comments: true,
  20. collapse: true,
  21. disable: true,
  22. maxBlocks: Infinity,
  23. media: '../media/',
  24. oneBasedIndex: true,
  25. readOnly: false,
  26. //rtl: false,
  27. scrollbars: true,
  28. trashcan: true,
  29. //toolbox: null,
  30. //horizontalLayout: false,
  31. //toolboxPosition: 'start',
  32. zoom: {
  33. controls: true,
  34. wheel: false,
  35. startScale: 1.0,
  36. maxScale: 4,
  37. minScale: 0.25,
  38. scaleSpeed: 1.1
  39. }
  40. };
  41. function start() {
  42. var match = location.search.match(/toolbox=([^&]+)/);
  43. var toolbox =
  44. document.getElementById('toolbox-' + (match ? match[1] : 'categories'));
  45. document.forms.options.elements.toolbox.selectedIndex =
  46. Number(toolbox.getElementsByTagName('category').length == 0);
  47. startBlocklyInstance('VertStartLTR', false, false, 'start', toolbox);
  48. startBlocklyInstance('VertStartRTL', true, false, 'start', toolbox);
  49. startBlocklyInstance('VertEndLTR', false, false, 'end', toolbox);
  50. startBlocklyInstance('VertEndRTL', true, false, 'end', toolbox);
  51. startBlocklyInstance('HorizontalStartLTR', false, true, 'start', toolbox);
  52. startBlocklyInstance('HorizontalStartRTL', true, true, 'start', toolbox);
  53. startBlocklyInstance('HorizontalEndLTR', false, true, 'end', toolbox);
  54. startBlocklyInstance('HorizontalEndRTL', true, true, 'end', toolbox);
  55. }
  56. function startBlocklyInstance(suffix, rtl, horizontalLayout, position,
  57. toolbox) {
  58. options.rtl = rtl;
  59. options.toolbox = toolbox;
  60. options.horizontalLayout = horizontalLayout;
  61. options.toolboxPosition = position;
  62. Blockly.inject('blocklyDiv' + suffix, options);
  63. }
  64. </script>
  65. <style>
  66. html, body {
  67. height: 100%;
  68. }
  69. body {
  70. background-color: #fff;
  71. font-family: sans-serif;
  72. }
  73. h1 {
  74. font-weight: normal;
  75. font-size: 140%;
  76. }
  77. #octaweb {
  78. width: 100%;
  79. }
  80. #octaweb th {
  81. padding-top: 1em;
  82. width: 50%;
  83. }
  84. #octaweb td {
  85. width: 50%;
  86. }
  87. #octaweb td >div {
  88. height: 480px;
  89. width: 100%;
  90. }
  91. </style>
  92. </head>
  93. <body onload="start()">
  94. <h1>Blockly Multi Playground</h1>
  95. <form id="options">
  96. <select name="toolbox" onchange="document.forms.options.submit()">
  97. <option value="categories">Categories</option>
  98. <option value="simple">Simple</option>
  99. </select>
  100. </form>
  101. <table id="octaweb">
  102. <tr>
  103. <th>LTR, Vertical, Start</th>
  104. <th>RTL, Vertical, Start</th>
  105. </tr>
  106. <tr>
  107. <td><div id="blocklyDivVertStartLTR"></div></td>
  108. <td><div id="blocklyDivVertStartRTL"></div></td>
  109. </tr>
  110. <tr>
  111. <th>LTR, Vertical, End</th>
  112. <th>RTL, Vertical, End</th>
  113. </tr>
  114. <tr>
  115. <td><div id="blocklyDivVertEndLTR"></div></td>
  116. <td><div id="blocklyDivVertEndRTL"></div></td>
  117. </tr>
  118. <tr>
  119. <th>LTR, Horizontal, Start</th>
  120. <th>RTL, Horizontal, Start</th>
  121. </tr>
  122. <tr>
  123. <td><div id="blocklyDivHorizontalStartLTR"></div></td>
  124. <td><div id="blocklyDivHorizontalStartRTL"></div></td>
  125. </tr>
  126. <tr>
  127. <th>LTR, Horizontal, End</th>
  128. <th>RTL, Horizontal, End</th>
  129. </tr>
  130. <tr>
  131. <td><div id="blocklyDivHorizontalEndLTR"></div></td>
  132. <td><div id="blocklyDivHorizontalEndRTL"></div></td>
  133. </tr>
  134. </table>
  135. <xml id="toolbox-simple" style="display: none">
  136. <block type="controls_if"></block>
  137. <block type="logic_compare"></block>
  138. <!-- <block type="control_repeat"></block> -->
  139. <block type="logic_operation"></block>
  140. <block type="controls_repeat_ext">
  141. <value name="TIMES">
  142. <shadow type="math_number">
  143. <field name="NUM">10</field>
  144. </shadow>
  145. </value>
  146. </block>
  147. <block type="logic_operation"></block>
  148. <block type="logic_negate"></block>
  149. <block type="logic_boolean"></block>
  150. <block type="logic_null" disabled="true"></block>
  151. <block type="logic_ternary"></block>
  152. </xml>
  153. <xml id="toolbox-categories" style="display: none">
  154. <category name="Logic" colour="210">
  155. <block type="controls_if"></block>
  156. <block type="logic_compare"></block>
  157. <block type="logic_operation"></block>
  158. <block type="logic_negate"></block>
  159. <block type="logic_boolean"></block>
  160. <block type="logic_null" disabled="true"></block>
  161. <block type="logic_ternary"></block>
  162. </category>
  163. <category name="Loops" colour="120">
  164. <block type="controls_repeat_ext">
  165. <value name="TIMES">
  166. <shadow type="math_number">
  167. <field name="NUM">10</field>
  168. </shadow>
  169. </value>
  170. </block>
  171. <block type="controls_repeat" disabled="true"></block>
  172. <block type="controls_whileUntil"></block>
  173. <block type="controls_for">
  174. <value name="FROM">
  175. <shadow type="math_number">
  176. <field name="NUM">1</field>
  177. </shadow>
  178. </value>
  179. <value name="TO">
  180. <shadow type="math_number">
  181. <field name="NUM">10</field>
  182. </shadow>
  183. </value>
  184. <value name="BY">
  185. <shadow type="math_number">
  186. <field name="NUM">1</field>
  187. </shadow>
  188. </value>
  189. </block>
  190. <block type="controls_forEach"></block>
  191. <block type="controls_flow_statements"></block>
  192. </category>
  193. <category name="Math" colour="230">
  194. <block type="math_number" gap="32"></block>
  195. <block type="math_arithmetic">
  196. <value name="A">
  197. <shadow type="math_number">
  198. <field name="NUM">1</field>
  199. </shadow>
  200. </value>
  201. <value name="B">
  202. <shadow type="math_number">
  203. <field name="NUM">1</field>
  204. </shadow>
  205. </value>
  206. </block>
  207. <block type="math_single">
  208. <value name="NUM">
  209. <shadow type="math_number">
  210. <field name="NUM">9</field>
  211. </shadow>
  212. </value>
  213. </block>
  214. <block type="math_trig">
  215. <value name="NUM">
  216. <shadow type="math_number">
  217. <field name="NUM">45</field>
  218. </shadow>
  219. </value>
  220. </block>
  221. <block type="math_constant"></block>
  222. <block type="math_number_property">
  223. <value name="NUMBER_TO_CHECK">
  224. <shadow type="math_number">
  225. <field name="NUM">0</field>
  226. </shadow>
  227. </value>
  228. </block>
  229. <block type="math_round">
  230. <value name="NUM">
  231. <shadow type="math_number">
  232. <field name="NUM">3.1</field>
  233. </shadow>
  234. </value>
  235. </block>
  236. <block type="math_on_list"></block>
  237. <block type="math_modulo">
  238. <value name="DIVIDEND">
  239. <shadow type="math_number">
  240. <field name="NUM">64</field>
  241. </shadow>
  242. </value>
  243. <value name="DIVISOR">
  244. <shadow type="math_number">
  245. <field name="NUM">10</field>
  246. </shadow>
  247. </value>
  248. </block>
  249. <block type="math_constrain">
  250. <value name="VALUE">
  251. <shadow type="math_number">
  252. <field name="NUM">50</field>
  253. </shadow>
  254. </value>
  255. <value name="LOW">
  256. <shadow type="math_number">
  257. <field name="NUM">1</field>
  258. </shadow>
  259. </value>
  260. <value name="HIGH">
  261. <shadow type="math_number">
  262. <field name="NUM">100</field>
  263. </shadow>
  264. </value>
  265. </block>
  266. <block type="math_random_int">
  267. <value name="FROM">
  268. <shadow type="math_number">
  269. <field name="NUM">1</field>
  270. </shadow>
  271. </value>
  272. <value name="TO">
  273. <shadow type="math_number">
  274. <field name="NUM">100</field>
  275. </shadow>
  276. </value>
  277. </block>
  278. <block type="math_random_float"></block>
  279. </category>
  280. <category name="Text" colour="160">
  281. <block type="text"></block>
  282. <block type="text_join"></block>
  283. <block type="text_append">
  284. <value name="TEXT">
  285. <shadow type="text"></shadow>
  286. </value>
  287. </block>
  288. <block type="text_length">
  289. <value name="VALUE">
  290. <shadow type="text">
  291. <field name="TEXT">abc</field>
  292. </shadow>
  293. </value>
  294. </block>
  295. <block type="text_isEmpty">
  296. <value name="VALUE">
  297. <shadow type="text">
  298. <field name="TEXT"></field>
  299. </shadow>
  300. </value>
  301. </block>
  302. <block type="text_indexOf">
  303. <value name="VALUE">
  304. <block type="variables_get">
  305. <field name="VAR">text</field>
  306. </block>
  307. </value>
  308. <value name="FIND">
  309. <shadow type="text">
  310. <field name="TEXT">abc</field>
  311. </shadow>
  312. </value>
  313. </block>
  314. <block type="text_charAt">
  315. <value name="VALUE">
  316. <block type="variables_get">
  317. <field name="VAR">text</field>
  318. </block>
  319. </value>
  320. </block>
  321. <block type="text_getSubstring">
  322. <value name="STRING">
  323. <block type="variables_get">
  324. <field name="VAR">text</field>
  325. </block>
  326. </value>
  327. </block>
  328. <block type="text_changeCase">
  329. <value name="TEXT">
  330. <shadow type="text">
  331. <field name="TEXT">abc</field>
  332. </shadow>
  333. </value>
  334. </block>
  335. <block type="text_trim">
  336. <value name="TEXT">
  337. <shadow type="text">
  338. <field name="TEXT">abc</field>
  339. </shadow>
  340. </value>
  341. </block>
  342. <block type="text_print">
  343. <value name="TEXT">
  344. <shadow type="text">
  345. <field name="TEXT">abc</field>
  346. </shadow>
  347. </value>
  348. </block>
  349. <block type="text_prompt_ext">
  350. <value name="TEXT">
  351. <shadow type="text">
  352. <field name="TEXT">abc</field>
  353. </shadow>
  354. </value>
  355. </block>
  356. </category>
  357. <category name="Lists" colour="260">
  358. <block type="lists_create_with">
  359. <mutation items="0"></mutation>
  360. </block>
  361. <block type="lists_create_with"></block>
  362. <block type="lists_repeat">
  363. <value name="NUM">
  364. <shadow type="math_number">
  365. <field name="NUM">5</field>
  366. </shadow>
  367. </value>
  368. </block>
  369. <block type="lists_length"></block>
  370. <block type="lists_isEmpty"></block>
  371. <block type="lists_indexOf">
  372. <value name="VALUE">
  373. <block type="variables_get">
  374. <field name="VAR">list</field>
  375. </block>
  376. </value>
  377. </block>
  378. <block type="lists_getIndex">
  379. <value name="VALUE">
  380. <block type="variables_get">
  381. <field name="VAR">list</field>
  382. </block>
  383. </value>
  384. </block>
  385. <block type="lists_setIndex">
  386. <value name="LIST">
  387. <block type="variables_get">
  388. <field name="VAR">list</field>
  389. </block>
  390. </value>
  391. </block>
  392. <block type="lists_getSublist">
  393. <value name="LIST">
  394. <block type="variables_get">
  395. <field name="VAR">list</field>
  396. </block>
  397. </value>
  398. </block>
  399. <block type="lists_split">
  400. <value name="DELIM">
  401. <shadow type="text">
  402. <field name="TEXT">,</field>
  403. </shadow>
  404. </value>
  405. </block>
  406. <block type="lists_sort"></block>
  407. </category>
  408. <category name="Colour" colour="20">
  409. <block type="colour_picker"></block>
  410. <block type="colour_random"></block>
  411. <block type="colour_rgb">
  412. <value name="RED">
  413. <shadow type="math_number">
  414. <field name="NUM">100</field>
  415. </shadow>
  416. </value>
  417. <value name="GREEN">
  418. <shadow type="math_number">
  419. <field name="NUM">50</field>
  420. </shadow>
  421. </value>
  422. <value name="BLUE">
  423. <shadow type="math_number">
  424. <field name="NUM">0</field>
  425. </shadow>
  426. </value>
  427. </block>
  428. <block type="colour_blend">
  429. <value name="COLOUR1">
  430. <shadow type="colour_picker">
  431. <field name="COLOUR">#ff0000</field>
  432. </shadow>
  433. </value>
  434. <value name="COLOUR2">
  435. <shadow type="colour_picker">
  436. <field name="COLOUR">#3333ff</field>
  437. </shadow>
  438. </value>
  439. <value name="RATIO">
  440. <shadow type="math_number">
  441. <field name="NUM">0.5</field>
  442. </shadow>
  443. </value>
  444. </block>
  445. </category>
  446. <sep></sep>
  447. <category name="Variables" colour="330" custom="VARIABLE"></category>
  448. <category name="Functions" colour="290" custom="PROCEDURE"></category>
  449. </xml>
  450. </body>
  451. </html>