summaryrefslogtreecommitdiff
path: root/blockly/demos
diff options
context:
space:
mode:
Diffstat (limited to 'blockly/demos')
-rw-r--r--blockly/demos/accessible/icon.pngbin0 -> 1416 bytes
-rw-r--r--blockly/demos/accessible/index.html347
-rw-r--r--blockly/demos/blockfactory/blocks.js802
-rw-r--r--blockly/demos/blockfactory/factory.js850
-rw-r--r--blockly/demos/blockfactory/icon.pngbin0 -> 4441 bytes
-rw-r--r--blockly/demos/blockfactory/index.html230
-rw-r--r--blockly/demos/blockfactory/link.pngbin0 -> 228 bytes
-rw-r--r--blockly/demos/blocklyfactory/app_controller.js688
-rw-r--r--blockly/demos/blocklyfactory/block_exporter_controller.js335
-rw-r--r--blockly/demos/blocklyfactory/block_exporter_tools.js276
-rw-r--r--blockly/demos/blocklyfactory/block_exporter_view.js145
-rw-r--r--blockly/demos/blocklyfactory/block_library_controller.js337
-rw-r--r--blockly/demos/blocklyfactory/block_library_storage.js178
-rw-r--r--blockly/demos/blocklyfactory/block_library_view.js226
-rw-r--r--blockly/demos/blocklyfactory/block_option.js181
-rw-r--r--blockly/demos/blocklyfactory/factory.css597
-rw-r--r--blockly/demos/blocklyfactory/factory.js265
-rw-r--r--blockly/demos/blocklyfactory/factory_utils.js989
-rw-r--r--blockly/demos/blocklyfactory/index.html740
-rw-r--r--blockly/demos/blocklyfactory/link.pngbin0 -> 228 bytes
-rw-r--r--blockly/demos/blocklyfactory/standard_categories.js395
-rw-r--r--blockly/demos/blocklyfactory/workspacefactory/index.html847
-rw-r--r--blockly/demos/blocklyfactory/workspacefactory/style.css224
-rw-r--r--blockly/demos/blocklyfactory/workspacefactory/wfactory_controller.js1344
-rw-r--r--blockly/demos/blocklyfactory/workspacefactory/wfactory_generator.js252
-rw-r--r--blockly/demos/blocklyfactory/workspacefactory/wfactory_init.js617
-rw-r--r--blockly/demos/blocklyfactory/workspacefactory/wfactory_model.js599
-rw-r--r--blockly/demos/blocklyfactory/workspacefactory/wfactory_view.js452
-rw-r--r--blockly/demos/code/code.js532
-rw-r--r--blockly/demos/code/icon.pngbin0 -> 4049 bytes
-rw-r--r--blockly/demos/code/icons.pngbin0 -> 546 bytes
-rw-r--r--blockly/demos/code/index.html374
-rw-r--r--blockly/demos/code/msg/ar.js24
-rw-r--r--blockly/demos/code/msg/be-tarask.js24
-rw-r--r--blockly/demos/code/msg/br.js24
-rw-r--r--blockly/demos/code/msg/ca.js24
-rw-r--r--blockly/demos/code/msg/cs.js24
-rw-r--r--blockly/demos/code/msg/da.js24
-rw-r--r--blockly/demos/code/msg/de.js24
-rw-r--r--blockly/demos/code/msg/el.js24
-rw-r--r--blockly/demos/code/msg/en.js24
-rw-r--r--blockly/demos/code/msg/es.js24
-rw-r--r--blockly/demos/code/msg/et.js24
-rw-r--r--blockly/demos/code/msg/fa.js24
-rw-r--r--blockly/demos/code/msg/fr.js24
-rw-r--r--blockly/demos/code/msg/he.js24
-rw-r--r--blockly/demos/code/msg/hrx.js24
-rw-r--r--blockly/demos/code/msg/hu.js24
-rw-r--r--blockly/demos/code/msg/ia.js24
-rw-r--r--blockly/demos/code/msg/is.js24
-rw-r--r--blockly/demos/code/msg/it.js24
-rw-r--r--blockly/demos/code/msg/ja.js24
-rw-r--r--blockly/demos/code/msg/ko.js24
-rw-r--r--blockly/demos/code/msg/mk.js24
-rw-r--r--blockly/demos/code/msg/ms.js24
-rw-r--r--blockly/demos/code/msg/nb.js24
-rw-r--r--blockly/demos/code/msg/nl.js24
-rw-r--r--blockly/demos/code/msg/oc.js24
-rw-r--r--blockly/demos/code/msg/pl.js24
-rw-r--r--blockly/demos/code/msg/pms.js24
-rw-r--r--blockly/demos/code/msg/pt-br.js24
-rw-r--r--blockly/demos/code/msg/ro.js24
-rw-r--r--blockly/demos/code/msg/ru.js24
-rw-r--r--blockly/demos/code/msg/sc.js24
-rw-r--r--blockly/demos/code/msg/sk.js24
-rw-r--r--blockly/demos/code/msg/sr.js24
-rw-r--r--blockly/demos/code/msg/sv.js24
-rw-r--r--blockly/demos/code/msg/ta.js24
-rw-r--r--blockly/demos/code/msg/th.js24
-rw-r--r--blockly/demos/code/msg/tlh.js24
-rw-r--r--blockly/demos/code/msg/tr.js24
-rw-r--r--blockly/demos/code/msg/uk.js24
-rw-r--r--blockly/demos/code/msg/vi.js24
-rw-r--r--blockly/demos/code/msg/zh-hans.js24
-rw-r--r--blockly/demos/code/msg/zh-hant.js24
-rw-r--r--blockly/demos/code/style.css163
-rw-r--r--blockly/demos/fixed/icon.pngbin0 -> 2114 bytes
-rw-r--r--blockly/demos/fixed/index.html47
-rw-r--r--blockly/demos/generator/icon.pngbin0 -> 3600 bytes
-rw-r--r--blockly/demos/generator/index.html145
-rw-r--r--blockly/demos/graph/icon.pngbin0 -> 1762 bytes
-rw-r--r--blockly/demos/graph/index.html358
-rw-r--r--blockly/demos/headless/icon.pngbin0 -> 4359 bytes
-rw-r--r--blockly/demos/headless/index.html120
-rw-r--r--blockly/demos/index.html212
-rw-r--r--blockly/demos/interpreter/acorn_interpreter.js153
-rw-r--r--blockly/demos/interpreter/icon.pngbin0 -> 3200 bytes
-rw-r--r--blockly/demos/interpreter/index.html200
-rw-r--r--blockly/demos/maxBlocks/icon.pngbin0 -> 2003 bytes
-rw-r--r--blockly/demos/maxBlocks/index.html98
-rw-r--r--blockly/demos/mirror/icon.pngbin0 -> 2464 bytes
-rw-r--r--blockly/demos/mirror/index.html76
-rw-r--r--blockly/demos/plane/README.txt26
-rw-r--r--blockly/demos/plane/blocks.js103
-rw-r--r--blockly/demos/plane/generated/ar.js37
-rw-r--r--blockly/demos/plane/generated/be-tarask.js37
-rw-r--r--blockly/demos/plane/generated/br.js37
-rw-r--r--blockly/demos/plane/generated/ca.js37
-rw-r--r--blockly/demos/plane/generated/da.js37
-rw-r--r--blockly/demos/plane/generated/de.js37
-rw-r--r--blockly/demos/plane/generated/el.js37
-rw-r--r--blockly/demos/plane/generated/en.js37
-rw-r--r--blockly/demos/plane/generated/es.js37
-rw-r--r--blockly/demos/plane/generated/et.js37
-rw-r--r--blockly/demos/plane/generated/fa.js37
-rw-r--r--blockly/demos/plane/generated/fr.js37
-rw-r--r--blockly/demos/plane/generated/he.js37
-rw-r--r--blockly/demos/plane/generated/hrx.js37
-rw-r--r--blockly/demos/plane/generated/hu.js37
-rw-r--r--blockly/demos/plane/generated/ia.js37
-rw-r--r--blockly/demos/plane/generated/is.js37
-rw-r--r--blockly/demos/plane/generated/it.js37
-rw-r--r--blockly/demos/plane/generated/ja.js37
-rw-r--r--blockly/demos/plane/generated/ko.js37
-rw-r--r--blockly/demos/plane/generated/ms.js37
-rw-r--r--blockly/demos/plane/generated/nb.js37
-rw-r--r--blockly/demos/plane/generated/nl.js37
-rw-r--r--blockly/demos/plane/generated/pl.js37
-rw-r--r--blockly/demos/plane/generated/pms.js37
-rw-r--r--blockly/demos/plane/generated/pt-br.js37
-rw-r--r--blockly/demos/plane/generated/ro.js37
-rw-r--r--blockly/demos/plane/generated/ru.js37
-rw-r--r--blockly/demos/plane/generated/sc.js37
-rw-r--r--blockly/demos/plane/generated/sv.js37
-rw-r--r--blockly/demos/plane/generated/th.js37
-rw-r--r--blockly/demos/plane/generated/tr.js37
-rw-r--r--blockly/demos/plane/generated/uk.js37
-rw-r--r--blockly/demos/plane/generated/vi.js37
-rw-r--r--blockly/demos/plane/generated/zh-hans.js37
-rw-r--r--blockly/demos/plane/generated/zh-hant.js37
-rw-r--r--blockly/demos/plane/icon.pngbin0 -> 3397 bytes
-rw-r--r--blockly/demos/plane/index.html19
-rw-r--r--blockly/demos/plane/plane.js445
-rw-r--r--blockly/demos/plane/slider.js287
-rw-r--r--blockly/demos/plane/soy/COPYING202
-rw-r--r--blockly/demos/plane/soy/README45
-rw-r--r--blockly/demos/plane/soy/SoyMsgExtractor.jarbin0 -> 11030911 bytes
-rw-r--r--blockly/demos/plane/soy/SoyToJsSrcCompiler.jarbin0 -> 11030912 bytes
-rw-r--r--blockly/demos/plane/soy/soyutils.js2767
-rw-r--r--blockly/demos/plane/style.css97
-rw-r--r--blockly/demos/plane/template.soy225
-rw-r--r--blockly/demos/plane/xlf/extracted_msgs.xlf77
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_ar.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_be-tarask.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_br.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_ca.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_da.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_de.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_el.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_en.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_es.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_et.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_fa.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_fr.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_he.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_hrx.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_hu.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_ia.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_is.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_it.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_ja.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_ko.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_ms.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_nb.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_nl.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_pl.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_pms.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_pt-br.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_ro.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_ru.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_sc.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_sv.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_th.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_tr.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_uk.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_vi.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_zh-hans.xlf63
-rw-r--r--blockly/demos/plane/xlf/translated_msgs_zh-hant.xlf63
-rw-r--r--blockly/demos/prettify.css1
-rw-r--r--blockly/demos/prettify.js30
-rw-r--r--blockly/demos/resizable/icon.pngbin0 -> 3260 bytes
-rw-r--r--blockly/demos/resizable/index.html52
-rw-r--r--blockly/demos/resizable/overlay.html93
-rw-r--r--blockly/demos/rtl/icon.pngbin0 -> 3140 bytes
-rw-r--r--blockly/demos/rtl/index.html204
-rw-r--r--blockly/demos/storage/icon.pngbin0 -> 3268 bytes
-rw-r--r--blockly/demos/storage/index.html94
-rw-r--r--blockly/demos/toolbox/icon.pngbin0 -> 2827 bytes
-rw-r--r--blockly/demos/toolbox/index.html343
189 files changed, 24136 insertions, 0 deletions
diff --git a/blockly/demos/accessible/icon.png b/blockly/demos/accessible/icon.png
new file mode 100644
index 0000000..3ea238c
--- /dev/null
+++ b/blockly/demos/accessible/icon.png
Binary files differ
diff --git a/blockly/demos/accessible/index.html b/blockly/demos/accessible/index.html
new file mode 100644
index 0000000..af42476
--- /dev/null
+++ b/blockly/demos/accessible/index.html
@@ -0,0 +1,347 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Accessible Blockly Demo</title>
+
+ <!-- Load Blockly -->
+ <script src="../../blockly_compressed.js"></script>
+ <script src="../../blocks_compressed.js"></script>
+ <script src="../../javascript_compressed.js"></script>
+ <script src="../../msg/js/en.js"></script>
+ <script src="../../msg/messages.js"></script>
+ <script src="../../accessible/messages.js"></script>
+
+ <!-- Load accessibleBlockly -->
+ <script src="../../accessible/libs/es6-shim.min.js"></script>
+ <script src="../../accessible/libs/angular2-polyfills.min.js"></script>
+ <script src="../../accessible/libs/Rx.umd.min.js"></script>
+ <script src="../../accessible/libs/angular2-all.umd.min.js"></script>
+
+ <script src="../../accessible/utils.service.js"></script>
+ <script src="../../accessible/audio.service.js"></script>
+ <script src="../../accessible/notifications.service.js"></script>
+ <script src="../../accessible/clipboard.service.js"></script>
+ <script src="../../accessible/tree.service.js"></script>
+ <script src="../../accessible/translate.pipe.js"></script>
+
+ <script src="../../accessible/field.component.js"></script>
+ <script src="../../accessible/toolbox-tree.component.js"></script>
+ <script src="../../accessible/toolbox.component.js"></script>
+ <script src="../../accessible/workspace-tree.component.js"></script>
+ <script src="../../accessible/workspace.component.js"></script>
+ <script src="../../accessible/app.component.js"></script>
+
+ <link rel="stylesheet" href="../../accessible/media/accessible.css">
+ <style>
+ body {
+ background-color: #fff;
+ font-family: sans-serif;
+ }
+ h1 {
+ font-weight: normal;
+ font-size: 140%;
+ }
+
+ *:focus {
+ background: yellow;
+ }
+ </style>
+</head>
+<body>
+ <h1>
+ <a href="https://developers.google.com/blockly/">Blockly</a> &gt;
+ <a href="../index.html">Demos</a> &gt; Accessible Blockly
+ </h1>
+
+ <p>This is a simple demo of a version of Blockly designed for screen readers.</p>
+
+ <p>
+ In Blockly, you can move blocks from the toolbox to the workspace and join
+ them to create programs. To navigate between components, use Tab or
+ Shift-Tab. When you're on a block, move right to access its submenus, and
+ move up or down to go to the next or previous block in the sequence.
+ </p>
+
+ <!--
+ <p>&rarr; More info on <a href="https://developers.google.com/blockly/">accessible Blockly</a>&hellip;</p>
+ -->
+
+ <blockly-app></blockly-app>
+
+ <script>
+ var ACCESSIBLE_GLOBALS = {
+ // Additional buttons for the workspace toolbar that
+ // go before the "Clear Workspace" button.
+ toolbarButtonConfig: [],
+ // Prefix of path to sound files.
+ mediaPathPrefix: '../../accessible/media/'
+ };
+ document.addEventListener('DOMContentLoaded', function() {
+ ng.platform.browser.bootstrap(blocklyApp.AppView);
+ });
+ </script>
+
+ <xml id="blockly-toolbox-xml" style="display: none">
+ <category name="Logic" colour="210">
+ <block type="controls_if"></block>
+ <block type="logic_compare"></block>
+ <block type="logic_operation"></block>
+ <block type="logic_negate"></block>
+ <block type="logic_boolean"></block>
+ <block type="logic_ternary"></block>
+ </category>
+ <category name="Loops" colour="120">
+ <block type="controls_repeat_ext">
+ <value name="TIMES">
+ <block type="math_number">
+ <field name="NUM">10</field>
+ </block>
+ </value>
+ </block>
+ <block type="controls_whileUntil"></block>
+ <block type="controls_for">
+ <value name="FROM">
+ <block type="math_number">
+ <field name="NUM">1</field>
+ </block>
+ </value>
+ <value name="TO">
+ <block type="math_number">
+ <field name="NUM">10</field>
+ </block>
+ </value>
+ <value name="BY">
+ <block type="math_number">
+ <field name="NUM">1</field>
+ </block>
+ </value>
+ </block>
+ <block type="controls_forEach"></block>
+ <block type="controls_flow_statements"></block>
+ </category>
+ <category name="Math" colour="230">
+ <block type="math_number" gap="32"></block>
+ <block type="math_arithmetic">
+ <value name="A">
+ <block type="math_number">
+ <field name="NUM">1</field>
+ </block>
+ </value>
+ <value name="B">
+ <block type="math_number">
+ <field name="NUM">1</field>
+ </block>
+ </value>
+ </block>
+ <block type="math_single">
+ <value name="NUM">
+ <block type="math_number">
+ <field name="NUM">9</field>
+ </block>
+ </value>
+ </block>
+ <block type="math_trig">
+ <value name="NUM">
+ <block type="math_number">
+ <field name="NUM">45</field>
+ </block>
+ </value>
+ </block>
+ <block type="math_constant"></block>
+ <block type="math_number_property">
+ <value name="NUMBER_TO_CHECK">
+ <block type="math_number">
+ <field name="NUM">0</field>
+ </block>
+ </value>
+ </block>
+ <block type="math_change">
+ <value name="DELTA">
+ <block type="math_number">
+ <field name="NUM">1</field>
+ </block>
+ </value>
+ </block>
+ <block type="math_round">
+ <value name="NUM">
+ <block type="math_number">
+ <field name="NUM">3.1</field>
+ </block>
+ </value>
+ </block>
+ <block type="math_on_list"></block>
+ <block type="math_modulo">
+ <value name="DIVIDEND">
+ <block type="math_number">
+ <field name="NUM">64</field>
+ </block>
+ </value>
+ <value name="DIVISOR">
+ <block type="math_number">
+ <field name="NUM">10</field>
+ </block>
+ </value>
+ </block>
+ <block type="math_constrain">
+ <value name="VALUE">
+ <block type="math_number">
+ <field name="NUM">50</field>
+ </block>
+ </value>
+ <value name="LOW">
+ <block type="math_number">
+ <field name="NUM">1</field>
+ </block>
+ </value>
+ <value name="HIGH">
+ <block type="math_number">
+ <field name="NUM">100</field>
+ </block>
+ </value>
+ </block>
+ <block type="math_random_int">
+ <value name="FROM">
+ <block type="math_number">
+ <field name="NUM">1</field>
+ </block>
+ </value>
+ <value name="TO">
+ <block type="math_number">
+ <field name="NUM">100</field>
+ </block>
+ </value>
+ </block>
+ <block type="math_random_float"></block>
+ </category>
+ <category name="Text" colour="160">
+ <block type="text"></block>
+ <block type="text_join"></block>
+ <block type="text_append">
+ <value name="TEXT">
+ <block type="text"></block>
+ </value>
+ </block>
+ <block type="text_length">
+ <value name="VALUE">
+ <block type="text">
+ <field name="TEXT">abc</field>
+ </block>
+ </value>
+ </block>
+ <block type="text_isEmpty">
+ <value name="VALUE">
+ <block type="text">
+ <field name="TEXT"></field>
+ </block>
+ </value>
+ </block>
+ <block type="text_indexOf">
+ <value name="VALUE">
+ <block type="variables_get">
+ <field name="VAR">text</field>
+ </block>
+ </value>
+ <value name="FIND">
+ <block type="text">
+ <field name="TEXT">abc</field>
+ </block>
+ </value>
+ </block>
+ <block type="text_charAt">
+ <value name="VALUE">
+ <block type="variables_get">
+ <field name="VAR">text</field>
+ </block>
+ </value>
+ </block>
+ <block type="text_getSubstring">
+ <value name="STRING">
+ <block type="variables_get">
+ <field name="VAR">text</field>
+ </block>
+ </value>
+ </block>
+ <block type="text_changeCase">
+ <value name="TEXT">
+ <block type="text">
+ <field name="TEXT">abc</field>
+ </block>
+ </value>
+ </block>
+ <block type="text_trim">
+ <value name="TEXT">
+ <block type="text">
+ <field name="TEXT">abc</field>
+ </block>
+ </value>
+ </block>
+ <block type="text_print">
+ <value name="TEXT">
+ <block type="text">
+ <field name="TEXT">abc</field>
+ </block>
+ </value>
+ </block>
+ <block type="text_prompt_ext">
+ <value name="TEXT">
+ <block type="text">
+ <field name="TEXT">abc</field>
+ </block>
+ </value>
+ </block>
+ </category>
+ <category name="Lists" colour="260">
+ <block type="lists_create_with">
+ <mutation items="0"></mutation>
+ </block>
+ <block type="lists_create_with"></block>
+ <block type="lists_repeat">
+ <value name="NUM">
+ <block type="math_number">
+ <field name="NUM">5</field>
+ </block>
+ </value>
+ </block>
+ <block type="lists_length"></block>
+ <block type="lists_isEmpty"></block>
+ <block type="lists_indexOf">
+ <value name="VALUE">
+ <block type="variables_get">
+ <field name="VAR">list</field>
+ </block>
+ </value>
+ </block>
+ <block type="lists_getIndex">
+ <value name="VALUE">
+ <block type="variables_get">
+ <field name="VAR">list</field>
+ </block>
+ </value>
+ </block>
+ <block type="lists_setIndex">
+ <value name="LIST">
+ <block type="variables_get">
+ <field name="VAR">list</field>
+ </block>
+ </value>
+ </block>
+ <block type="lists_getSublist">
+ <value name="LIST">
+ <block type="variables_get">
+ <field name="VAR">list</field>
+ </block>
+ </value>
+ </block>
+ <block type="lists_split">
+ <value name="DELIM">
+ <block type="text">
+ <field name="TEXT">,</field>
+ </block>
+ </value>
+ </block>
+ </category>
+ </xml>
+
+</body>
+</html>
diff --git a/blockly/demos/blockfactory/blocks.js b/blockly/demos/blockfactory/blocks.js
new file mode 100644
index 0000000..3cd1dcd
--- /dev/null
+++ b/blockly/demos/blockfactory/blocks.js
@@ -0,0 +1,802 @@
+/**
+ * Blockly Demos: Block Factory Blocks
+ *
+ * Copyright 2012 Google Inc.
+ * https://developers.google.com/blockly/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @fileoverview Blocks for Blockly's Block Factory application.
+ * @author fraser@google.com (Neil Fraser)
+ */
+'use strict';
+
+Blockly.Blocks['factory_base'] = {
+ // Base of new block.
+ init: function() {
+ this.setColour(120);
+ this.appendDummyInput()
+ .appendField('name')
+ .appendField(new Blockly.FieldTextInput('block_type'), 'NAME');
+ this.appendStatementInput('INPUTS')
+ .setCheck('Input')
+ .appendField('inputs');
+ var dropdown = new Blockly.FieldDropdown([
+ ['automatic inputs', 'AUTO'],
+ ['external inputs', 'EXT'],
+ ['inline inputs', 'INT']]);
+ this.appendDummyInput()
+ .appendField(dropdown, 'INLINE');
+ dropdown = new Blockly.FieldDropdown([
+ ['no connections', 'NONE'],
+ ['← left output', 'LEFT'],
+ ['↕ top+bottom connections', 'BOTH'],
+ ['↑ top connection', 'TOP'],
+ ['↓ bottom connection', 'BOTTOM']],
+ function(option) {
+ this.sourceBlock_.updateShape_(option);
+ });
+ this.appendDummyInput()
+ .appendField(dropdown, 'CONNECTIONS');
+ this.appendValueInput('COLOUR')
+ .setCheck('Colour')
+ .appendField('colour');
+ this.setTooltip('Build a custom block by plugging\n' +
+ 'fields, inputs and other blocks here.');
+ this.setHelpUrl(
+ 'https://developers.google.com/blockly/guides/create-custom-blocks/block-factory');
+ },
+ mutationToDom: function() {
+ var container = document.createElement('mutation');
+ container.setAttribute('connections', this.getFieldValue('CONNECTIONS'));
+ return container;
+ },
+ domToMutation: function(xmlElement) {
+ var connections = xmlElement.getAttribute('connections');
+ this.updateShape_(connections);
+ },
+ updateShape_: function(option) {
+ var outputExists = this.getInput('OUTPUTTYPE');
+ var topExists = this.getInput('TOPTYPE');
+ var bottomExists = this.getInput('BOTTOMTYPE');
+ if (option == 'LEFT') {
+ if (!outputExists) {
+ this.addTypeInput_('OUTPUTTYPE', 'output type');
+ }
+ } else if (outputExists) {
+ this.removeInput('OUTPUTTYPE');
+ }
+ if (option == 'TOP' || option == 'BOTH') {
+ if (!topExists) {
+ this.addTypeInput_('TOPTYPE', 'top type');
+ }
+ } else if (topExists) {
+ this.removeInput('TOPTYPE');
+ }
+ if (option == 'BOTTOM' || option == 'BOTH') {
+ if (!bottomExists) {
+ this.addTypeInput_('BOTTOMTYPE', 'bottom type');
+ }
+ } else if (bottomExists) {
+ this.removeInput('BOTTOMTYPE');
+ }
+ },
+ addTypeInput_: function(name, label) {
+ this.appendValueInput(name)
+ .setCheck('Type')
+ .appendField(label);
+ this.moveInputBefore(name, 'COLOUR');
+ var type = this.workspace.newBlock('type_null');
+ type.setShadow(true);
+ type.outputConnection.connect(this.getInput(name).connection);
+ type.initSvg();
+ type.render();
+ }
+};
+
+var FIELD_MESSAGE = 'fields %1 %2';
+var FIELD_ARGS = [
+ {
+ "type": "field_dropdown",
+ "name": "ALIGN",
+ "options": [['left', 'LEFT'], ['right', 'RIGHT'], ['centre', 'CENTRE']],
+ },
+ {
+ "type": "input_statement",
+ "name": "FIELDS",
+ "check": "Field"
+ }
+];
+
+var TYPE_MESSAGE = 'type %1';
+var TYPE_ARGS = [
+ {
+ "type": "input_value",
+ "name": "TYPE",
+ "check": "Type",
+ "align": "RIGHT"
+ }
+];
+
+Blockly.Blocks['input_value'] = {
+ // Value input.
+ init: function() {
+ this.jsonInit({
+ "message0": "value input %1 %2",
+ "args0": [
+ {
+ "type": "field_input",
+ "name": "INPUTNAME",
+ "text": "NAME"
+ },
+ {
+ "type": "input_dummy"
+ }
+ ],
+ "message1": FIELD_MESSAGE,
+ "args1": FIELD_ARGS,
+ "message2": TYPE_MESSAGE,
+ "args2": TYPE_ARGS,
+ "previousStatement": "Input",
+ "nextStatement": "Input",
+ "colour": 210,
+ "tooltip": "A value socket for horizontal connections.",
+ "helpUrl": "https://www.youtube.com/watch?v=s2_xaEvcVI0#t=71"
+ });
+ },
+ onchange: function() {
+ inputNameCheck(this);
+ }
+};
+
+Blockly.Blocks['input_statement'] = {
+ // Statement input.
+ init: function() {
+ this.jsonInit({
+ "message0": "statement input %1 %2",
+ "args0": [
+ {
+ "type": "field_input",
+ "name": "INPUTNAME",
+ "text": "NAME"
+ },
+ {
+ "type": "input_dummy"
+ },
+ ],
+ "message1": FIELD_MESSAGE,
+ "args1": FIELD_ARGS,
+ "message2": TYPE_MESSAGE,
+ "args2": TYPE_ARGS,
+ "previousStatement": "Input",
+ "nextStatement": "Input",
+ "colour": 210,
+ "tooltip": "A statement socket for enclosed vertical stacks.",
+ "helpUrl": "https://www.youtube.com/watch?v=s2_xaEvcVI0#t=246"
+ });
+ },
+ onchange: function() {
+ inputNameCheck(this);
+ }
+};
+
+Blockly.Blocks['input_dummy'] = {
+ // Dummy input.
+ init: function() {
+ this.jsonInit({
+ "message0": "dummy input",
+ "message1": FIELD_MESSAGE,
+ "args1": FIELD_ARGS,
+ "previousStatement": "Input",
+ "nextStatement": "Input",
+ "colour": 210,
+ "tooltip": "For adding fields on a separate row with no " +
+ "connections. Alignment options (left, right, centre) " +
+ "apply only to multi-line fields.",
+ "helpUrl": "https://www.youtube.com/watch?v=s2_xaEvcVI0#t=293"
+ });
+ }
+};
+
+Blockly.Blocks['field_static'] = {
+ // Text value.
+ init: function() {
+ this.setColour(160);
+ this.appendDummyInput()
+ .appendField('text')
+ .appendField(new Blockly.FieldTextInput(''), 'TEXT');
+ this.setPreviousStatement(true, 'Field');
+ this.setNextStatement(true, 'Field');
+ this.setTooltip('Static text that serves as a label.');
+ this.setHelpUrl('https://www.youtube.com/watch?v=s2_xaEvcVI0#t=88');
+ }
+};
+
+Blockly.Blocks['field_input'] = {
+ // Text input.
+ init: function() {
+ this.setColour(160);
+ this.appendDummyInput()
+ .appendField('text input')
+ .appendField(new Blockly.FieldTextInput('default'), 'TEXT')
+ .appendField(',')
+ .appendField(new Blockly.FieldTextInput('NAME'), 'FIELDNAME');
+ this.setPreviousStatement(true, 'Field');
+ this.setNextStatement(true, 'Field');
+ this.setTooltip('An input field for the user to enter text.');
+ this.setHelpUrl('https://www.youtube.com/watch?v=s2_xaEvcVI0#t=319');
+ },
+ onchange: function() {
+ fieldNameCheck(this);
+ }
+};
+
+Blockly.Blocks['field_number'] = {
+ // Numeric input.
+ init: function() {
+ this.setColour(160);
+ this.appendDummyInput()
+ .appendField('numeric input')
+ .appendField(new Blockly.FieldNumber(0), 'VALUE')
+ .appendField(',')
+ .appendField(new Blockly.FieldTextInput('NAME'), 'FIELDNAME');
+ this.appendDummyInput()
+ .appendField('min')
+ .appendField(new Blockly.FieldNumber(-Infinity), 'MIN')
+ .appendField('max')
+ .appendField(new Blockly.FieldNumber(Infinity), 'MAX')
+ .appendField('precision')
+ .appendField(new Blockly.FieldNumber(0, 0), 'PRECISION');
+ this.setPreviousStatement(true, 'Field');
+ this.setNextStatement(true, 'Field');
+ this.setTooltip('An input field for the user to enter a number.');
+ this.setHelpUrl('https://www.youtube.com/watch?v=s2_xaEvcVI0#t=319');
+ },
+ onchange: function() {
+ fieldNameCheck(this);
+ }
+};
+
+Blockly.Blocks['field_angle'] = {
+ // Angle input.
+ init: function() {
+ this.setColour(160);
+ this.appendDummyInput()
+ .appendField('angle input')
+ .appendField(new Blockly.FieldAngle('90'), 'ANGLE')
+ .appendField(',')
+ .appendField(new Blockly.FieldTextInput('NAME'), 'FIELDNAME');
+ this.setPreviousStatement(true, 'Field');
+ this.setNextStatement(true, 'Field');
+ this.setTooltip('An input field for the user to enter an angle.');
+ this.setHelpUrl('https://www.youtube.com/watch?v=s2_xaEvcVI0#t=372');
+ },
+ onchange: function() {
+ fieldNameCheck(this);
+ }
+};
+
+Blockly.Blocks['field_dropdown'] = {
+ // Dropdown menu.
+ init: function() {
+ this.appendDummyInput()
+ .appendField('dropdown')
+ .appendField(new Blockly.FieldTextInput('NAME'), 'FIELDNAME');
+ this.optionCount_ = 3;
+ this.updateShape_();
+ this.setPreviousStatement(true, 'Field');
+ this.setNextStatement(true, 'Field');
+ this.setMutator(new Blockly.Mutator(['field_dropdown_option']));
+ this.setColour(160);
+ this.setTooltip('Dropdown menu with a list of options.');
+ this.setHelpUrl('https://www.youtube.com/watch?v=s2_xaEvcVI0#t=386');
+ },
+ mutationToDom: function(workspace) {
+ // Create XML to represent menu options.
+ var container = document.createElement('mutation');
+ container.setAttribute('options', this.optionCount_);
+ return container;
+ },
+ domToMutation: function(container) {
+ // Parse XML to restore the menu options.
+ this.optionCount_ = parseInt(container.getAttribute('options'), 10);
+ this.updateShape_();
+ },
+ decompose: function(workspace) {
+ // Populate the mutator's dialog with this block's components.
+ var containerBlock = workspace.newBlock('field_dropdown_container');
+ containerBlock.initSvg();
+ var connection = containerBlock.getInput('STACK').connection;
+ for (var i = 0; i < this.optionCount_; i++) {
+ var optionBlock = workspace.newBlock('field_dropdown_option');
+ optionBlock.initSvg();
+ connection.connect(optionBlock.previousConnection);
+ connection = optionBlock.nextConnection;
+ }
+ return containerBlock;
+ },
+ compose: function(containerBlock) {
+ // Reconfigure this block based on the mutator dialog's components.
+ var optionBlock = containerBlock.getInputTargetBlock('STACK');
+ // Count number of inputs.
+ var data = [];
+ while (optionBlock) {
+ data.push([optionBlock.userData_, optionBlock.cpuData_]);
+ optionBlock = optionBlock.nextConnection &&
+ optionBlock.nextConnection.targetBlock();
+ }
+ this.optionCount_ = data.length;
+ this.updateShape_();
+ // Restore any data.
+ for (var i = 0; i < this.optionCount_; i++) {
+ this.setFieldValue(data[i][0] || 'option', 'USER' + i);
+ this.setFieldValue(data[i][1] || 'OPTIONNAME', 'CPU' + i);
+ }
+ },
+ saveConnections: function(containerBlock) {
+ // Store names and values for each option.
+ var optionBlock = containerBlock.getInputTargetBlock('STACK');
+ var i = 0;
+ while (optionBlock) {
+ optionBlock.userData_ = this.getFieldValue('USER' + i);
+ optionBlock.cpuData_ = this.getFieldValue('CPU' + i);
+ i++;
+ optionBlock = optionBlock.nextConnection &&
+ optionBlock.nextConnection.targetBlock();
+ }
+ },
+ updateShape_: function() {
+ // Modify this block to have the correct number of options.
+ // Add new options.
+ for (var i = 0; i < this.optionCount_; i++) {
+ if (!this.getInput('OPTION' + i)) {
+ this.appendDummyInput('OPTION' + i)
+ .appendField(new Blockly.FieldTextInput('option'), 'USER' + i)
+ .appendField(',')
+ .appendField(new Blockly.FieldTextInput('OPTIONNAME'), 'CPU' + i);
+ }
+ }
+ // Remove deleted options.
+ while (this.getInput('OPTION' + i)) {
+ this.removeInput('OPTION' + i);
+ i++;
+ }
+ },
+ onchange: function() {
+ if (this.workspace && this.optionCount_ < 1) {
+ this.setWarningText('Drop down menu must\nhave at least one option.');
+ } else {
+ fieldNameCheck(this);
+ }
+ }
+};
+
+Blockly.Blocks['field_dropdown_container'] = {
+ // Container.
+ init: function() {
+ this.setColour(160);
+ this.appendDummyInput()
+ .appendField('add options');
+ this.appendStatementInput('STACK');
+ this.setTooltip('Add, remove, or reorder options\n' +
+ 'to reconfigure this dropdown menu.');
+ this.setHelpUrl('https://www.youtube.com/watch?v=s2_xaEvcVI0#t=386');
+ this.contextMenu = false;
+ }
+};
+
+Blockly.Blocks['field_dropdown_option'] = {
+ // Add option.
+ init: function() {
+ this.setColour(160);
+ this.appendDummyInput()
+ .appendField('option');
+ this.setPreviousStatement(true);
+ this.setNextStatement(true);
+ this.setTooltip('Add a new option to the dropdown menu.');
+ this.setHelpUrl('https://www.youtube.com/watch?v=s2_xaEvcVI0#t=386');
+ this.contextMenu = false;
+ }
+};
+
+Blockly.Blocks['field_checkbox'] = {
+ // Checkbox.
+ init: function() {
+ this.setColour(160);
+ this.appendDummyInput()
+ .appendField('checkbox')
+ .appendField(new Blockly.FieldCheckbox('TRUE'), 'CHECKED')
+ .appendField(',')
+ .appendField(new Blockly.FieldTextInput('NAME'), 'FIELDNAME');
+ this.setPreviousStatement(true, 'Field');
+ this.setNextStatement(true, 'Field');
+ this.setTooltip('Checkbox field.');
+ this.setHelpUrl('https://www.youtube.com/watch?v=s2_xaEvcVI0#t=485');
+ },
+ onchange: function() {
+ fieldNameCheck(this);
+ }
+};
+
+Blockly.Blocks['field_colour'] = {
+ // Colour input.
+ init: function() {
+ this.setColour(160);
+ this.appendDummyInput()
+ .appendField('colour')
+ .appendField(new Blockly.FieldColour('#ff0000'), 'COLOUR')
+ .appendField(',')
+ .appendField(new Blockly.FieldTextInput('NAME'), 'FIELDNAME');
+ this.setPreviousStatement(true, 'Field');
+ this.setNextStatement(true, 'Field');
+ this.setTooltip('Colour input field.');
+ this.setHelpUrl('https://www.youtube.com/watch?v=s2_xaEvcVI0#t=495');
+ },
+ onchange: function() {
+ fieldNameCheck(this);
+ }
+};
+
+Blockly.Blocks['field_date'] = {
+ // Date input.
+ init: function() {
+ this.setColour(160);
+ this.appendDummyInput()
+ .appendField('date')
+ .appendField(new Blockly.FieldDate(), 'DATE')
+ .appendField(',')
+ .appendField(new Blockly.FieldTextInput('NAME'), 'FIELDNAME');
+ this.setPreviousStatement(true, 'Field');
+ this.setNextStatement(true, 'Field');
+ this.setTooltip('Date input field.');
+ },
+ onchange: function() {
+ fieldNameCheck(this);
+ }
+};
+
+Blockly.Blocks['field_variable'] = {
+ // Dropdown for variables.
+ init: function() {
+ this.setColour(160);
+ this.appendDummyInput()
+ .appendField('variable')
+ .appendField(new Blockly.FieldTextInput('item'), 'TEXT')
+ .appendField(',')
+ .appendField(new Blockly.FieldTextInput('NAME'), 'FIELDNAME');
+ this.setPreviousStatement(true, 'Field');
+ this.setNextStatement(true, 'Field');
+ this.setTooltip('Dropdown menu for variable names.');
+ this.setHelpUrl('https://www.youtube.com/watch?v=s2_xaEvcVI0#t=510');
+ },
+ onchange: function() {
+ fieldNameCheck(this);
+ }
+};
+
+Blockly.Blocks['field_image'] = {
+ // Image.
+ init: function() {
+ this.setColour(160);
+ var src = 'https://www.gstatic.com/codesite/ph/images/star_on.gif';
+ this.appendDummyInput()
+ .appendField('image')
+ .appendField(new Blockly.FieldTextInput(src), 'SRC');
+ this.appendDummyInput()
+ .appendField('width')
+ .appendField(new Blockly.FieldNumber('15', 0, NaN, 1), 'WIDTH')
+ .appendField('height')
+ .appendField(new Blockly.FieldNumber('15', 0, NaN, 1), 'HEIGHT')
+ .appendField('alt text')
+ .appendField(new Blockly.FieldTextInput('*'), 'ALT');
+ this.setPreviousStatement(true, 'Field');
+ this.setNextStatement(true, 'Field');
+ this.setTooltip('Static image (JPEG, PNG, GIF, SVG, BMP).\n' +
+ 'Retains aspect ratio regardless of height and width.\n' +
+ 'Alt text is for when collapsed.');
+ this.setHelpUrl('https://www.youtube.com/watch?v=s2_xaEvcVI0#t=567');
+ }
+};
+
+Blockly.Blocks['type_group'] = {
+ // Group of types.
+ init: function() {
+ this.typeCount_ = 2;
+ this.updateShape_();
+ this.setOutput(true, 'Type');
+ this.setMutator(new Blockly.Mutator(['type_group_item']));
+ this.setColour(230);
+ this.setTooltip('Allows more than one type to be accepted.');
+ this.setHelpUrl('https://www.youtube.com/watch?v=s2_xaEvcVI0#t=677');
+ },
+ mutationToDom: function(workspace) {
+ // Create XML to represent a group of types.
+ var container = document.createElement('mutation');
+ container.setAttribute('types', this.typeCount_);
+ return container;
+ },
+ domToMutation: function(container) {
+ // Parse XML to restore the group of types.
+ this.typeCount_ = parseInt(container.getAttribute('types'), 10);
+ this.updateShape_();
+ for (var i = 0; i < this.typeCount_; i++) {
+ this.removeInput('TYPE' + i);
+ }
+ for (var i = 0; i < this.typeCount_; i++) {
+ var input = this.appendValueInput('TYPE' + i)
+ .setCheck('Type');
+ if (i == 0) {
+ input.appendField('any of');
+ }
+ }
+ },
+ decompose: function(workspace) {
+ // Populate the mutator's dialog with this block's components.
+ var containerBlock = workspace.newBlock('type_group_container');
+ containerBlock.initSvg();
+ var connection = containerBlock.getInput('STACK').connection;
+ for (var i = 0; i < this.typeCount_; i++) {
+ var typeBlock = workspace.newBlock('type_group_item');
+ typeBlock.initSvg();
+ connection.connect(typeBlock.previousConnection);
+ connection = typeBlock.nextConnection;
+ }
+ return containerBlock;
+ },
+ compose: function(containerBlock) {
+ // Reconfigure this block based on the mutator dialog's components.
+ var typeBlock = containerBlock.getInputTargetBlock('STACK');
+ // Count number of inputs.
+ var connections = [];
+ while (typeBlock) {
+ connections.push(typeBlock.valueConnection_);
+ typeBlock = typeBlock.nextConnection &&
+ typeBlock.nextConnection.targetBlock();
+ }
+ // Disconnect any children that don't belong.
+ for (var i = 0; i < this.typeCount_; i++) {
+ var connection = this.getInput('TYPE' + i).connection.targetConnection;
+ if (connection && connections.indexOf(connection) == -1) {
+ connection.disconnect();
+ }
+ }
+ this.typeCount_ = connections.length;
+ this.updateShape_();
+ // Reconnect any child blocks.
+ for (var i = 0; i < this.typeCount_; i++) {
+ Blockly.Mutator.reconnect(connections[i], this, 'TYPE' + i);
+ }
+ },
+ saveConnections: function(containerBlock) {
+ // Store a pointer to any connected child blocks.
+ var typeBlock = containerBlock.getInputTargetBlock('STACK');
+ var i = 0;
+ while (typeBlock) {
+ var input = this.getInput('TYPE' + i);
+ typeBlock.valueConnection_ = input && input.connection.targetConnection;
+ i++;
+ typeBlock = typeBlock.nextConnection &&
+ typeBlock.nextConnection.targetBlock();
+ }
+ },
+ updateShape_: function() {
+ // Modify this block to have the correct number of inputs.
+ // Add new inputs.
+ for (var i = 0; i < this.typeCount_; i++) {
+ if (!this.getInput('TYPE' + i)) {
+ var input = this.appendValueInput('TYPE' + i);
+ if (i == 0) {
+ input.appendField('any of');
+ }
+ }
+ }
+ // Remove deleted inputs.
+ while (this.getInput('TYPE' + i)) {
+ this.removeInput('TYPE' + i);
+ i++;
+ }
+ }
+};
+
+Blockly.Blocks['type_group_container'] = {
+ // Container.
+ init: function() {
+ this.jsonInit({
+ "message0": "add types %1 %2",
+ "args0": [
+ {"type": "input_dummy"},
+ {"type": "input_statement", "name": "STACK"}
+ ],
+ "colour": 230,
+ "tooltip": "Add, or remove allowed type.",
+ "helpUrl": "https://www.youtube.com/watch?v=s2_xaEvcVI0#t=677"
+ });
+ }
+};
+
+Blockly.Blocks['type_group_item'] = {
+ // Add type.
+ init: function() {
+ this.jsonInit({
+ "message0": "type",
+ "previousStatement": null,
+ "nextStatement": null,
+ "colour": 230,
+ "tooltip": "Add a new allowed type.",
+ "helpUrl": "https://www.youtube.com/watch?v=s2_xaEvcVI0#t=677"
+ });
+ }
+};
+
+Blockly.Blocks['type_null'] = {
+ // Null type.
+ valueType: null,
+ init: function() {
+ this.jsonInit({
+ "message0": "any",
+ "output": "Type",
+ "colour": 230,
+ "tooltip": "Any type is allowed.",
+ "helpUrl": "https://www.youtube.com/watch?v=s2_xaEvcVI0#t=602"
+ });
+ }
+};
+
+Blockly.Blocks['type_boolean'] = {
+ // Boolean type.
+ valueType: 'Boolean',
+ init: function() {
+ this.jsonInit({
+ "message0": "Boolean",
+ "output": "Type",
+ "colour": 230,
+ "tooltip": "Booleans (true/false) are allowed.",
+ "helpUrl": "https://www.youtube.com/watch?v=s2_xaEvcVI0#t=602"
+ });
+ }
+};
+
+Blockly.Blocks['type_number'] = {
+ // Number type.
+ valueType: 'Number',
+ init: function() {
+ this.jsonInit({
+ "message0": "Number",
+ "output": "Type",
+ "colour": 230,
+ "tooltip": "Numbers (int/float) are allowed.",
+ "helpUrl": "https://www.youtube.com/watch?v=s2_xaEvcVI0#t=602"
+ });
+ }
+};
+
+Blockly.Blocks['type_string'] = {
+ // String type.
+ valueType: 'String',
+ init: function() {
+ this.jsonInit({
+ "message0": "String",
+ "output": "Type",
+ "colour": 230,
+ "tooltip": "Strings (text) are allowed.",
+ "helpUrl": "https://www.youtube.com/watch?v=s2_xaEvcVI0#t=602"
+ });
+ }
+};
+
+Blockly.Blocks['type_list'] = {
+ // List type.
+ valueType: 'Array',
+ init: function() {
+ this.jsonInit({
+ "message0": "Array",
+ "output": "Type",
+ "colour": 230,
+ "tooltip": "Arrays (lists) are allowed.",
+ "helpUrl": "https://www.youtube.com/watch?v=s2_xaEvcVI0#t=602"
+ });
+ }
+};
+
+Blockly.Blocks['type_other'] = {
+ // Other type.
+ init: function() {
+ this.jsonInit({
+ "message0": "other %1",
+ "args0": [{"type": "field_input", "name": "TYPE", "text": ""}],
+ "output": "Type",
+ "colour": 230,
+ "tooltip": "Custom type to allow.",
+ "helpUrl": "https://www.youtube.com/watch?v=s2_xaEvcVI0#t=702"
+ });
+ }
+};
+
+Blockly.Blocks['colour_hue'] = {
+ // Set the colour of the block.
+ init: function() {
+ this.appendDummyInput()
+ .appendField('hue:')
+ .appendField(new Blockly.FieldAngle('0', this.validator), 'HUE');
+ this.setOutput(true, 'Colour');
+ this.setTooltip('Paint the block with this colour.');
+ this.setHelpUrl('https://www.youtube.com/watch?v=s2_xaEvcVI0#t=55');
+ },
+ validator: function(text) {
+ // Update the current block's colour to match.
+ var hue = parseInt(text, 10);
+ if (!isNaN(hue)) {
+ this.sourceBlock_.setColour(hue);
+ }
+ },
+ mutationToDom: function(workspace) {
+ var container = document.createElement('mutation');
+ container.setAttribute('colour', this.getColour());
+ return container;
+ },
+ domToMutation: function(container) {
+ this.setColour(container.getAttribute('colour'));
+ }
+};
+
+/**
+ * Check to see if more than one field has this name.
+ * Highly inefficient (On^2), but n is small.
+ * @param {!Blockly.Block} referenceBlock Block to check.
+ */
+function fieldNameCheck(referenceBlock) {
+ if (!referenceBlock.workspace) {
+ // Block has been deleted.
+ return;
+ }
+ var name = referenceBlock.getFieldValue('FIELDNAME').toLowerCase();
+ var count = 0;
+ var blocks = referenceBlock.workspace.getAllBlocks();
+ for (var i = 0, block; block = blocks[i]; i++) {
+ var otherName = block.getFieldValue('FIELDNAME');
+ if (!block.disabled && !block.getInheritedDisabled() &&
+ otherName && otherName.toLowerCase() == name) {
+ count++;
+ }
+ }
+ var msg = (count > 1) ?
+ 'There are ' + count + ' field blocks\n with this name.' : null;
+ referenceBlock.setWarningText(msg);
+}
+
+/**
+ * Check to see if more than one input has this name.
+ * Highly inefficient (On^2), but n is small.
+ * @param {!Blockly.Block} referenceBlock Block to check.
+ */
+function inputNameCheck(referenceBlock) {
+ if (!referenceBlock.workspace) {
+ // Block has been deleted.
+ return;
+ }
+ var name = referenceBlock.getFieldValue('INPUTNAME').toLowerCase();
+ var count = 0;
+ var blocks = referenceBlock.workspace.getAllBlocks();
+ for (var i = 0, block; block = blocks[i]; i++) {
+ var otherName = block.getFieldValue('INPUTNAME');
+ if (!block.disabled && !block.getInheritedDisabled() &&
+ otherName && otherName.toLowerCase() == name) {
+ count++;
+ }
+ }
+ var msg = (count > 1) ?
+ 'There are ' + count + ' input blocks\n with this name.' : null;
+ referenceBlock.setWarningText(msg);
+}
diff --git a/blockly/demos/blockfactory/factory.js b/blockly/demos/blockfactory/factory.js
new file mode 100644
index 0000000..4af5ff2
--- /dev/null
+++ b/blockly/demos/blockfactory/factory.js
@@ -0,0 +1,850 @@
+/**
+ * Blockly Demos: Block Factory
+ *
+ * Copyright 2012 Google Inc.
+ * https://developers.google.com/blockly/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @fileoverview JavaScript for Blockly's Block Factory application.
+ * @author fraser@google.com (Neil Fraser)
+ */
+'use strict';
+
+/**
+ * Workspace for user to build block.
+ * @type {Blockly.Workspace}
+ */
+var mainWorkspace = null;
+
+/**
+ * Workspace for preview of block.
+ * @type {Blockly.Workspace}
+ */
+var previewWorkspace = null;
+
+/**
+ * Name of block if not named.
+ */
+var UNNAMED = 'unnamed';
+
+/**
+ * Change the language code format.
+ */
+function formatChange() {
+ var mask = document.getElementById('blocklyMask');
+ var languagePre = document.getElementById('languagePre');
+ var languageTA = document.getElementById('languageTA');
+ if (document.getElementById('format').value == 'Manual') {
+ Blockly.hideChaff();
+ mask.style.display = 'block';
+ languagePre.style.display = 'none';
+ languageTA.style.display = 'block';
+ var code = languagePre.textContent.trim();
+ languageTA.value = code;
+ languageTA.focus();
+ updatePreview();
+ } else {
+ mask.style.display = 'none';
+ languageTA.style.display = 'none';
+ languagePre.style.display = 'block';
+ updateLanguage();
+ }
+ disableEnableLink();
+}
+
+/**
+ * Update the language code based on constructs made in Blockly.
+ */
+function updateLanguage() {
+ var rootBlock = getRootBlock();
+ if (!rootBlock) {
+ return;
+ }
+ var blockType = rootBlock.getFieldValue('NAME').trim().toLowerCase();
+ if (!blockType) {
+ blockType = UNNAMED;
+ }
+ blockType = blockType.replace(/\W/g, '_').replace(/^(\d)/, '_\\1');
+ switch (document.getElementById('format').value) {
+ case 'JSON':
+ var code = formatJson_(blockType, rootBlock);
+ break;
+ case 'JavaScript':
+ var code = formatJavaScript_(blockType, rootBlock);
+ break;
+ }
+ injectCode(code, 'languagePre');
+ updatePreview();
+}
+
+/**
+ * Update the language code as JSON.
+ * @param {string} blockType Name of block.
+ * @param {!Blockly.Block} rootBlock Factory_base block.
+ * @return {string} Generanted language code.
+ * @private
+ */
+function formatJson_(blockType, rootBlock) {
+ var JS = {};
+ // Type is not used by Blockly, but may be used by a loader.
+ JS.type = blockType;
+ // Generate inputs.
+ var message = [];
+ var args = [];
+ var contentsBlock = rootBlock.getInputTargetBlock('INPUTS');
+ var lastInput = null;
+ while (contentsBlock) {
+ if (!contentsBlock.disabled && !contentsBlock.getInheritedDisabled()) {
+ var fields = getFieldsJson_(contentsBlock.getInputTargetBlock('FIELDS'));
+ for (var i = 0; i < fields.length; i++) {
+ if (typeof fields[i] == 'string') {
+ message.push(fields[i].replace(/%/g, '%%'));
+ } else {
+ args.push(fields[i]);
+ message.push('%' + args.length);
+ }
+ }
+
+ var input = {type: contentsBlock.type};
+ // Dummy inputs don't have names. Other inputs do.
+ if (contentsBlock.type != 'input_dummy') {
+ input.name = contentsBlock.getFieldValue('INPUTNAME');
+ }
+ var check = JSON.parse(getOptTypesFrom(contentsBlock, 'TYPE') || 'null');
+ if (check) {
+ input.check = check;
+ }
+ var align = contentsBlock.getFieldValue('ALIGN');
+ if (align != 'LEFT') {
+ input.align = align;
+ }
+ args.push(input);
+ message.push('%' + args.length);
+ lastInput = contentsBlock;
+ }
+ contentsBlock = contentsBlock.nextConnection &&
+ contentsBlock.nextConnection.targetBlock();
+ }
+ // Remove last input if dummy and not empty.
+ if (lastInput && lastInput.type == 'input_dummy') {
+ var fields = lastInput.getInputTargetBlock('FIELDS');
+ if (fields && getFieldsJson_(fields).join('').trim() != '') {
+ var align = lastInput.getFieldValue('ALIGN');
+ if (align != 'LEFT') {
+ JS.lastDummyAlign0 = align;
+ }
+ args.pop();
+ message.pop();
+ }
+ }
+ JS.message0 = message.join(' ');
+ if (args.length) {
+ JS.args0 = args;
+ }
+ // Generate inline/external switch.
+ if (rootBlock.getFieldValue('INLINE') == 'EXT') {
+ JS.inputsInline = false;
+ } else if (rootBlock.getFieldValue('INLINE') == 'INT') {
+ JS.inputsInline = true;
+ }
+ // Generate output, or next/previous connections.
+ switch (rootBlock.getFieldValue('CONNECTIONS')) {
+ case 'LEFT':
+ JS.output =
+ JSON.parse(getOptTypesFrom(rootBlock, 'OUTPUTTYPE') || 'null');
+ break;
+ case 'BOTH':
+ JS.previousStatement =
+ JSON.parse(getOptTypesFrom(rootBlock, 'TOPTYPE') || 'null');
+ JS.nextStatement =
+ JSON.parse(getOptTypesFrom(rootBlock, 'BOTTOMTYPE') || 'null');
+ break;
+ case 'TOP':
+ JS.previousStatement =
+ JSON.parse(getOptTypesFrom(rootBlock, 'TOPTYPE') || 'null');
+ break;
+ case 'BOTTOM':
+ JS.nextStatement =
+ JSON.parse(getOptTypesFrom(rootBlock, 'BOTTOMTYPE') || 'null');
+ break;
+ }
+ // Generate colour.
+ var colourBlock = rootBlock.getInputTargetBlock('COLOUR');
+ if (colourBlock && !colourBlock.disabled) {
+ var hue = parseInt(colourBlock.getFieldValue('HUE'), 10);
+ JS.colour = hue;
+ }
+ JS.tooltip = '';
+ JS.helpUrl = 'http://www.example.com/';
+ return JSON.stringify(JS, null, ' ');
+}
+
+/**
+ * Update the language code as JavaScript.
+ * @param {string} blockType Name of block.
+ * @param {!Blockly.Block} rootBlock Factory_base block.
+ * @return {string} Generanted language code.
+ * @private
+ */
+function formatJavaScript_(blockType, rootBlock) {
+ var code = [];
+ code.push("Blockly.Blocks['" + blockType + "'] = {");
+ code.push(" init: function() {");
+ // Generate inputs.
+ var TYPES = {'input_value': 'appendValueInput',
+ 'input_statement': 'appendStatementInput',
+ 'input_dummy': 'appendDummyInput'};
+ var contentsBlock = rootBlock.getInputTargetBlock('INPUTS');
+ while (contentsBlock) {
+ if (!contentsBlock.disabled && !contentsBlock.getInheritedDisabled()) {
+ var name = '';
+ // Dummy inputs don't have names. Other inputs do.
+ if (contentsBlock.type != 'input_dummy') {
+ name = escapeString(contentsBlock.getFieldValue('INPUTNAME'));
+ }
+ code.push(' this.' + TYPES[contentsBlock.type] + '(' + name + ')');
+ var check = getOptTypesFrom(contentsBlock, 'TYPE');
+ if (check) {
+ code.push(' .setCheck(' + check + ')');
+ }
+ var align = contentsBlock.getFieldValue('ALIGN');
+ if (align != 'LEFT') {
+ code.push(' .setAlign(Blockly.ALIGN_' + align + ')');
+ }
+ var fields = getFieldsJs_(contentsBlock.getInputTargetBlock('FIELDS'));
+ for (var i = 0; i < fields.length; i++) {
+ code.push(' .appendField(' + fields[i] + ')');
+ }
+ // Add semicolon to last line to finish the statement.
+ code[code.length - 1] += ';';
+ }
+ contentsBlock = contentsBlock.nextConnection &&
+ contentsBlock.nextConnection.targetBlock();
+ }
+ // Generate inline/external switch.
+ if (rootBlock.getFieldValue('INLINE') == 'EXT') {
+ code.push(' this.setInputsInline(false);');
+ } else if (rootBlock.getFieldValue('INLINE') == 'INT') {
+ code.push(' this.setInputsInline(true);');
+ }
+ // Generate output, or next/previous connections.
+ switch (rootBlock.getFieldValue('CONNECTIONS')) {
+ case 'LEFT':
+ code.push(connectionLineJs_('setOutput', 'OUTPUTTYPE'));
+ break;
+ case 'BOTH':
+ code.push(connectionLineJs_('setPreviousStatement', 'TOPTYPE'));
+ code.push(connectionLineJs_('setNextStatement', 'BOTTOMTYPE'));
+ break;
+ case 'TOP':
+ code.push(connectionLineJs_('setPreviousStatement', 'TOPTYPE'));
+ break;
+ case 'BOTTOM':
+ code.push(connectionLineJs_('setNextStatement', 'BOTTOMTYPE'));
+ break;
+ }
+ // Generate colour.
+ var colourBlock = rootBlock.getInputTargetBlock('COLOUR');
+ if (colourBlock && !colourBlock.disabled) {
+ var hue = parseInt(colourBlock.getFieldValue('HUE'), 10);
+ if (!isNaN(hue)) {
+ code.push(' this.setColour(' + hue + ');');
+ }
+ }
+ code.push(" this.setTooltip('');");
+ code.push(" this.setHelpUrl('http://www.example.com/');");
+ code.push(' }');
+ code.push('};');
+ return code.join('\n');
+}
+
+/**
+ * Create JS code required to create a top, bottom, or value connection.
+ * @param {string} functionName JavaScript function name.
+ * @param {string} typeName Name of type input.
+ * @return {string} Line of JavaScript code to create connection.
+ * @private
+ */
+function connectionLineJs_(functionName, typeName) {
+ var type = getOptTypesFrom(getRootBlock(), typeName);
+ if (type) {
+ type = ', ' + type;
+ } else {
+ type = '';
+ }
+ return ' this.' + functionName + '(true' + type + ');';
+}
+
+/**
+ * Returns field strings and any config.
+ * @param {!Blockly.Block} block Input block.
+ * @return {!Array.<string>} Field strings.
+ * @private
+ */
+function getFieldsJs_(block) {
+ var fields = [];
+ while (block) {
+ if (!block.disabled && !block.getInheritedDisabled()) {
+ switch (block.type) {
+ case 'field_static':
+ // Result: 'hello'
+ fields.push(escapeString(block.getFieldValue('TEXT')));
+ break;
+ case 'field_input':
+ // Result: new Blockly.FieldTextInput('Hello'), 'GREET'
+ fields.push('new Blockly.FieldTextInput(' +
+ escapeString(block.getFieldValue('TEXT')) + '), ' +
+ escapeString(block.getFieldValue('FIELDNAME')));
+ break;
+ case 'field_number':
+ // Result: new Blockly.FieldNumber(10, 0, 100, 1), 'NUMBER'
+ var args = [
+ Number(block.getFieldValue('VALUE')),
+ Number(block.getFieldValue('MIN')),
+ Number(block.getFieldValue('MAX')),
+ Number(block.getFieldValue('PRECISION'))
+ ];
+ // Remove any trailing arguments that aren't needed.
+ if (args[3] == 0) {
+ args.pop();
+ if (args[2] == Infinity) {
+ args.pop();
+ if (args[1] == -Infinity) {
+ args.pop();
+ }
+ }
+ }
+ fields.push('new Blockly.FieldNumber(' + args.join(', ') + '), ' +
+ escapeString(block.getFieldValue('FIELDNAME')));
+ break;
+ case 'field_angle':
+ // Result: new Blockly.FieldAngle(90), 'ANGLE'
+ fields.push('new Blockly.FieldAngle(' +
+ Number(block.getFieldValue('ANGLE')) + '), ' +
+ escapeString(block.getFieldValue('FIELDNAME')));
+ break;
+ case 'field_checkbox':
+ // Result: new Blockly.FieldCheckbox('TRUE'), 'CHECK'
+ fields.push('new Blockly.FieldCheckbox(' +
+ escapeString(block.getFieldValue('CHECKED')) + '), ' +
+ escapeString(block.getFieldValue('FIELDNAME')));
+ break;
+ case 'field_colour':
+ // Result: new Blockly.FieldColour('#ff0000'), 'COLOUR'
+ fields.push('new Blockly.FieldColour(' +
+ escapeString(block.getFieldValue('COLOUR')) + '), ' +
+ escapeString(block.getFieldValue('FIELDNAME')));
+ break;
+ case 'field_date':
+ // Result: new Blockly.FieldDate('2015-02-04'), 'DATE'
+ fields.push('new Blockly.FieldDate(' +
+ escapeString(block.getFieldValue('DATE')) + '), ' +
+ escapeString(block.getFieldValue('FIELDNAME')));
+ break;
+ case 'field_variable':
+ // Result: new Blockly.FieldVariable('item'), 'VAR'
+ var varname = escapeString(block.getFieldValue('TEXT') || null);
+ fields.push('new Blockly.FieldVariable(' + varname + '), ' +
+ escapeString(block.getFieldValue('FIELDNAME')));
+ break;
+ case 'field_dropdown':
+ // Result:
+ // new Blockly.FieldDropdown([['yes', '1'], ['no', '0']]), 'TOGGLE'
+ var options = [];
+ for (var i = 0; i < block.optionCount_; i++) {
+ options[i] = '[' + escapeString(block.getFieldValue('USER' + i)) +
+ ', ' + escapeString(block.getFieldValue('CPU' + i)) + ']';
+ }
+ if (options.length) {
+ fields.push('new Blockly.FieldDropdown([' +
+ options.join(', ') + ']), ' +
+ escapeString(block.getFieldValue('FIELDNAME')));
+ }
+ break;
+ case 'field_image':
+ // Result: new Blockly.FieldImage('http://...', 80, 60, '*')
+ var src = escapeString(block.getFieldValue('SRC'));
+ var width = Number(block.getFieldValue('WIDTH'));
+ var height = Number(block.getFieldValue('HEIGHT'));
+ var alt = escapeString(block.getFieldValue('ALT'));
+ fields.push('new Blockly.FieldImage(' +
+ src + ', ' + width + ', ' + height + ', ' + alt + ')');
+ break;
+ }
+ }
+ block = block.nextConnection && block.nextConnection.targetBlock();
+ }
+ return fields;
+}
+
+/**
+ * Returns field strings and any config.
+ * @param {!Blockly.Block} block Input block.
+ * @return {!Array.<string|!Object>} Array of static text and field configs.
+ * @private
+ */
+function getFieldsJson_(block) {
+ var fields = [];
+ while (block) {
+ if (!block.disabled && !block.getInheritedDisabled()) {
+ switch (block.type) {
+ case 'field_static':
+ // Result: 'hello'
+ fields.push(block.getFieldValue('TEXT'));
+ break;
+ case 'field_input':
+ fields.push({
+ type: block.type,
+ name: block.getFieldValue('FIELDNAME'),
+ text: block.getFieldValue('TEXT')
+ });
+ break;
+ case 'field_number':
+ var obj = {
+ type: block.type,
+ name: block.getFieldValue('FIELDNAME'),
+ value: parseFloat(block.getFieldValue('VALUE'))
+ };
+ var min = parseFloat(block.getFieldValue('MIN'));
+ if (min > -Infinity) {
+ obj.min = min;
+ }
+ var max = parseFloat(block.getFieldValue('MAX'));
+ if (max < Infinity) {
+ obj.max = max;
+ }
+ var precision = parseFloat(block.getFieldValue('PRECISION'));
+ if (precision) {
+ obj.precision = precision;
+ }
+ fields.push(obj);
+ break;
+ case 'field_angle':
+ fields.push({
+ type: block.type,
+ name: block.getFieldValue('FIELDNAME'),
+ angle: Number(block.getFieldValue('ANGLE'))
+ });
+ break;
+ case 'field_checkbox':
+ fields.push({
+ type: block.type,
+ name: block.getFieldValue('FIELDNAME'),
+ checked: block.getFieldValue('CHECKED') == 'TRUE'
+ });
+ break;
+ case 'field_colour':
+ fields.push({
+ type: block.type,
+ name: block.getFieldValue('FIELDNAME'),
+ colour: block.getFieldValue('COLOUR')
+ });
+ break;
+ case 'field_date':
+ fields.push({
+ type: block.type,
+ name: block.getFieldValue('FIELDNAME'),
+ date: block.getFieldValue('DATE')
+ });
+ break;
+ case 'field_variable':
+ fields.push({
+ type: block.type,
+ name: block.getFieldValue('FIELDNAME'),
+ variable: block.getFieldValue('TEXT') || null
+ });
+ break;
+ case 'field_dropdown':
+ var options = [];
+ for (var i = 0; i < block.optionCount_; i++) {
+ options[i] = [block.getFieldValue('USER' + i),
+ block.getFieldValue('CPU' + i)];
+ }
+ if (options.length) {
+ fields.push({
+ type: block.type,
+ name: block.getFieldValue('FIELDNAME'),
+ options: options
+ });
+ }
+ break;
+ case 'field_image':
+ fields.push({
+ type: block.type,
+ src: block.getFieldValue('SRC'),
+ width: Number(block.getFieldValue('WIDTH')),
+ height: Number(block.getFieldValue('HEIGHT')),
+ alt: block.getFieldValue('ALT')
+ });
+ break;
+ }
+ }
+ block = block.nextConnection && block.nextConnection.targetBlock();
+ }
+ return fields;
+}
+
+/**
+ * Escape a string.
+ * @param {string} string String to escape.
+ * @return {string} Escaped string surrouned by quotes.
+ */
+function escapeString(string) {
+ return JSON.stringify(string);
+}
+
+/**
+ * Fetch the type(s) defined in the given input.
+ * Format as a string for appending to the generated code.
+ * @param {!Blockly.Block} block Block with input.
+ * @param {string} name Name of the input.
+ * @return {?string} String defining the types.
+ */
+function getOptTypesFrom(block, name) {
+ var types = getTypesFrom_(block, name);
+ if (types.length == 0) {
+ return undefined;
+ } else if (types.indexOf('null') != -1) {
+ return 'null';
+ } else if (types.length == 1) {
+ return types[0];
+ } else {
+ return '[' + types.join(', ') + ']';
+ }
+}
+
+/**
+ * Fetch the type(s) defined in the given input.
+ * @param {!Blockly.Block} block Block with input.
+ * @param {string} name Name of the input.
+ * @return {!Array.<string>} List of types.
+ * @private
+ */
+function getTypesFrom_(block, name) {
+ var typeBlock = block.getInputTargetBlock(name);
+ var types;
+ if (!typeBlock || typeBlock.disabled) {
+ types = [];
+ } else if (typeBlock.type == 'type_other') {
+ types = [escapeString(typeBlock.getFieldValue('TYPE'))];
+ } else if (typeBlock.type == 'type_group') {
+ types = [];
+ for (var i = 0; i < typeBlock.typeCount_; i++) {
+ types = types.concat(getTypesFrom_(typeBlock, 'TYPE' + i));
+ }
+ // Remove duplicates.
+ var hash = Object.create(null);
+ for (var n = types.length - 1; n >= 0; n--) {
+ if (hash[types[n]]) {
+ types.splice(n, 1);
+ }
+ hash[types[n]] = true;
+ }
+ } else {
+ types = [escapeString(typeBlock.valueType)];
+ }
+ return types;
+}
+
+/**
+ * Update the generator code.
+ * @param {!Blockly.Block} block Rendered block in preview workspace.
+ */
+function updateGenerator(block) {
+ function makeVar(root, name) {
+ name = name.toLowerCase().replace(/\W/g, '_');
+ return ' var ' + root + '_' + name;
+ }
+ var language = document.getElementById('language').value;
+ var code = [];
+ code.push("Blockly." + language + "['" + block.type +
+ "'] = function(block) {");
+
+ // Generate getters for any fields or inputs.
+ for (var i = 0, input; input = block.inputList[i]; i++) {
+ for (var j = 0, field; field = input.fieldRow[j]; j++) {
+ var name = field.name;
+ if (!name) {
+ continue;
+ }
+ if (field instanceof Blockly.FieldVariable) {
+ // Subclass of Blockly.FieldDropdown, must test first.
+ code.push(makeVar('variable', name) +
+ " = Blockly." + language +
+ ".variableDB_.getName(block.getFieldValue('" + name +
+ "'), Blockly.Variables.NAME_TYPE);");
+ } else if (field instanceof Blockly.FieldAngle) {
+ // Subclass of Blockly.FieldTextInput, must test first.
+ code.push(makeVar('angle', name) +
+ " = block.getFieldValue('" + name + "');");
+ } else if (Blockly.FieldDate && field instanceof Blockly.FieldDate) {
+ // Blockly.FieldDate may not be compiled into Blockly.
+ code.push(makeVar('date', name) +
+ " = block.getFieldValue('" + name + "');");
+ } else if (field instanceof Blockly.FieldColour) {
+ code.push(makeVar('colour', name) +
+ " = block.getFieldValue('" + name + "');");
+ } else if (field instanceof Blockly.FieldCheckbox) {
+ code.push(makeVar('checkbox', name) +
+ " = block.getFieldValue('" + name + "') == 'TRUE';");
+ } else if (field instanceof Blockly.FieldDropdown) {
+ code.push(makeVar('dropdown', name) +
+ " = block.getFieldValue('" + name + "');");
+ } else if (field instanceof Blockly.FieldNumber) {
+ code.push(makeVar('number', name) +
+ " = block.getFieldValue('" + name + "');");
+ } else if (field instanceof Blockly.FieldTextInput) {
+ code.push(makeVar('text', name) +
+ " = block.getFieldValue('" + name + "');");
+ }
+ }
+ var name = input.name;
+ if (name) {
+ if (input.type == Blockly.INPUT_VALUE) {
+ code.push(makeVar('value', name) +
+ " = Blockly." + language + ".valueToCode(block, '" + name +
+ "', Blockly." + language + ".ORDER_ATOMIC);");
+ } else if (input.type == Blockly.NEXT_STATEMENT) {
+ code.push(makeVar('statements', name) +
+ " = Blockly." + language + ".statementToCode(block, '" +
+ name + "');");
+ }
+ }
+ }
+ // Most languages end lines with a semicolon. Python does not.
+ var lineEnd = {
+ 'JavaScript': ';',
+ 'Python': '',
+ 'PHP': ';',
+ 'Dart': ';'
+ };
+ code.push(" // TODO: Assemble " + language + " into code variable.");
+ if (block.outputConnection) {
+ code.push(" var code = '...';");
+ code.push(" // TODO: Change ORDER_NONE to the correct strength.");
+ code.push(" return [code, Blockly." + language + ".ORDER_NONE];");
+ } else {
+ code.push(" var code = '..." + (lineEnd[language] || '') + "\\n';");
+ code.push(" return code;");
+ }
+ code.push("};");
+
+ injectCode(code.join('\n'), 'generatorPre');
+}
+
+/**
+ * Existing direction ('ltr' vs 'rtl') of preview.
+ */
+var oldDir = null;
+
+/**
+ * Update the preview display.
+ */
+function updatePreview() {
+ // Toggle between LTR/RTL if needed (also used in first display).
+ var newDir = document.getElementById('direction').value;
+ if (oldDir != newDir) {
+ if (previewWorkspace) {
+ previewWorkspace.dispose();
+ }
+ var rtl = newDir == 'rtl';
+ previewWorkspace = Blockly.inject('preview',
+ {rtl: rtl,
+ media: '../../media/',
+ scrollbars: true});
+ oldDir = newDir;
+ }
+ previewWorkspace.clear();
+
+ // Fetch the code and determine its format (JSON or JavaScript).
+ var format = document.getElementById('format').value;
+ if (format == 'Manual') {
+ var code = document.getElementById('languageTA').value;
+ // If the code is JSON, it will parse, otherwise treat as JS.
+ try {
+ JSON.parse(code);
+ format = 'JSON';
+ } catch (e) {
+ format = 'JavaScript';
+ }
+ } else {
+ var code = document.getElementById('languagePre').textContent;
+ }
+ if (!code.trim()) {
+ // Nothing to render. Happens while cloud storage is loading.
+ return;
+ }
+
+ // Backup Blockly.Blocks object so that main workspace and preview don't
+ // collide if user creates a 'factory_base' block, for instance.
+ var backupBlocks = Blockly.Blocks;
+ try {
+ // Make a shallow copy.
+ Blockly.Blocks = {};
+ for (var prop in backupBlocks) {
+ Blockly.Blocks[prop] = backupBlocks[prop];
+ }
+
+ if (format == 'JSON') {
+ var json = JSON.parse(code);
+ Blockly.Blocks[json.type || UNNAMED] = {
+ init: function() {
+ this.jsonInit(json);
+ }
+ };
+ } else if (format == 'JavaScript') {
+ eval(code);
+ } else {
+ throw 'Unknown format: ' + format;
+ }
+
+ // Look for a block on Blockly.Blocks that does not match the backup.
+ var blockType = null;
+ for (var type in Blockly.Blocks) {
+ if (typeof Blockly.Blocks[type].init == 'function' &&
+ Blockly.Blocks[type] != backupBlocks[type]) {
+ blockType = type;
+ break;
+ }
+ }
+ if (!blockType) {
+ return;
+ }
+
+ // Create the preview block.
+ var previewBlock = previewWorkspace.newBlock(blockType);
+ previewBlock.initSvg();
+ previewBlock.render();
+ previewBlock.setMovable(false);
+ previewBlock.setDeletable(false);
+ previewBlock.moveBy(15, 10);
+ previewWorkspace.clearUndo();
+
+ updateGenerator(previewBlock);
+ } finally {
+ Blockly.Blocks = backupBlocks;
+ }
+}
+
+/**
+ * Inject code into a pre tag, with syntax highlighting.
+ * Safe from HTML/script injection.
+ * @param {string} code Lines of code.
+ * @param {string} id ID of <pre> element to inject into.
+ */
+function injectCode(code, id) {
+ var pre = document.getElementById(id);
+ pre.textContent = code;
+ code = pre.innerHTML;
+ code = prettyPrintOne(code, 'js');
+ pre.innerHTML = code;
+}
+
+/**
+ * Return the uneditable container block that everything else attaches to.
+ * @return {Blockly.Block}
+ */
+function getRootBlock() {
+ var blocks = mainWorkspace.getTopBlocks(false);
+ for (var i = 0, block; block = blocks[i]; i++) {
+ if (block.type == 'factory_base') {
+ return block;
+ }
+ }
+ return null;
+}
+
+/**
+ * Disable the link button if the format is 'Manual', enable otherwise.
+ */
+function disableEnableLink() {
+ var linkButton = document.getElementById('linkButton');
+ linkButton.disabled = document.getElementById('format').value == 'Manual';
+}
+
+/**
+ * Initialize Blockly and layout. Called on page load.
+ */
+function init() {
+ if ('BlocklyStorage' in window) {
+ BlocklyStorage.HTTPREQUEST_ERROR =
+ 'There was a problem with the request.\n';
+ BlocklyStorage.LINK_ALERT =
+ 'Share your blocks with this link:\n\n%1';
+ BlocklyStorage.HASH_ERROR =
+ 'Sorry, "%1" doesn\'t correspond with any saved Blockly file.';
+ BlocklyStorage.XML_ERROR = 'Could not load your saved file.\n'+
+ 'Perhaps it was created with a different version of Blockly?';
+ var linkButton = document.getElementById('linkButton');
+ linkButton.style.display = 'inline-block';
+ linkButton.addEventListener('click',
+ function() {BlocklyStorage.link(mainWorkspace);});
+ disableEnableLink();
+ }
+
+ document.getElementById('helpButton').addEventListener('click',
+ function() {
+ open('https://developers.google.com/blockly/guides/create-custom-blocks/block-factory',
+ 'BlockFactoryHelp');
+ });
+
+ var expandList = [
+ document.getElementById('blockly'),
+ document.getElementById('blocklyMask'),
+ document.getElementById('preview'),
+ document.getElementById('languagePre'),
+ document.getElementById('languageTA'),
+ document.getElementById('generatorPre')
+ ];
+ var onresize = function(e) {
+ for (var i = 0, expand; expand = expandList[i]; i++) {
+ expand.style.width = (expand.parentNode.offsetWidth - 2) + 'px';
+ expand.style.height = (expand.parentNode.offsetHeight - 2) + 'px';
+ }
+ };
+ onresize();
+ window.addEventListener('resize', onresize);
+
+ var toolbox = document.getElementById('toolbox');
+ mainWorkspace = Blockly.inject('blockly',
+ {collapse: false,
+ toolbox: toolbox,
+ media: '../../media/'});
+
+ // Create the root block.
+ if ('BlocklyStorage' in window && window.location.hash.length > 1) {
+ BlocklyStorage.retrieveXml(window.location.hash.substring(1),
+ mainWorkspace);
+ } else {
+ var xml = '<xml><block type="factory_base" deletable="false" movable="false"></block></xml>';
+ Blockly.Xml.domToWorkspace(Blockly.Xml.textToDom(xml), mainWorkspace);
+ }
+ mainWorkspace.clearUndo();
+
+ mainWorkspace.addChangeListener(Blockly.Events.disableOrphans);
+ mainWorkspace.addChangeListener(updateLanguage);
+ document.getElementById('direction')
+ .addEventListener('change', updatePreview);
+ document.getElementById('languageTA')
+ .addEventListener('change', updatePreview);
+ document.getElementById('languageTA')
+ .addEventListener('keyup', updatePreview);
+ document.getElementById('format')
+ .addEventListener('change', formatChange);
+ document.getElementById('language')
+ .addEventListener('change', updatePreview);
+}
+window.addEventListener('load', init);
diff --git a/blockly/demos/blockfactory/icon.png b/blockly/demos/blockfactory/icon.png
new file mode 100644
index 0000000..d4d19b4
--- /dev/null
+++ b/blockly/demos/blockfactory/icon.png
Binary files differ
diff --git a/blockly/demos/blockfactory/index.html b/blockly/demos/blockfactory/index.html
new file mode 100644
index 0000000..449b9a5
--- /dev/null
+++ b/blockly/demos/blockfactory/index.html
@@ -0,0 +1,230 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="target-densitydpi=device-dpi, height=660, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
+ <title>Blockly Demo: Block Factory</title>
+ <script src="/storage.js"></script>
+ <script src="factory.js"></script>
+ <script src="../../blockly_compressed.js"></script>
+ <script src="../../msg/messages.js"></script>
+ <script src="blocks.js"></script>
+ <style>
+ html, body {
+ height: 100%;
+ }
+ body {
+ background-color: #fff;
+ font-family: sans-serif;
+ margin: 0 5px;
+ overflow: hidden
+ }
+ h1 {
+ font-weight: normal;
+ font-size: 140%;
+ }
+ h3 {
+ margin-top: 5px;
+ margin-bottom: 0;
+ }
+ table {
+ height: 100%;
+ width: 100%;
+ }
+ td {
+ vertical-align: top;
+ padding: 0;
+ }
+ #blockly {
+ position: fixed;
+ }
+ #blocklyMask {
+ background-color: #000;
+ cursor: not-allowed;
+ display: none;
+ position: fixed;
+ opacity: 0.2;
+ z-index: 9;
+ }
+ #preview {
+ position: absolute;
+ }
+ pre,
+ #languageTA {
+ border: #ddd 1px solid;
+ margin-top: 0;
+ position: absolute;
+ overflow: scroll;
+ }
+ #languageTA {
+ display: none;
+ font-family: monospace;
+ font-size: 10pt;
+ }
+
+ button {
+ border-radius: 4px;
+ border: 1px solid #ddd;
+ background-color: #eee;
+ color: #000;
+ padding: 10px;
+ margin: 0 5px;
+ font-size: large;
+ }
+ button:hover:not(:disabled) {
+ box-shadow: 2px 2px 5px #888;
+ }
+ button:disabled {
+ opacity: 0.6;
+ }
+ button>* {
+ opacity: 0.6;
+ vertical-align: text-bottom;
+ }
+ button:hover:not(:disabled)>* {
+ opacity: 1;
+ }
+ #linkButton {
+ display: none;
+ }
+ </style>
+ <link rel="stylesheet" href="../prettify.css">
+ <script src="../prettify.js"></script>
+</head>
+<body>
+ <table>
+ <tr>
+ <td width="50%" height="5%">
+ <h1><a href="https://developers.google.com/blockly/">Blockly</a> &gt;
+ <a href="../index.html">Demos</a> &gt; Block Factory</h1>
+ </td>
+ <td width="50%" height="5%">
+ <table>
+ <tr>
+ <td style="vertical-align: bottom;">
+ <h3>Preview:
+ <select id="direction">
+ <option value="ltr">LTR</option>
+ <option value="rtl">RTL</option>
+ </select>
+ </h3>
+ </td>
+ <td style="vertical-align: middle; text-align: right;">
+ <button id="linkButton" title="Save and link to blocks.">
+ <img src="link.png" height="21" width="21">
+ </button>
+ <button id="linkButton" title="Save and link to blocks.">
+ <img src="link.png" height="21" width="21">
+ </button>
+ <button id="helpButton" title="View documentation in new window.">
+ <span>Help</span>
+ </button>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td width="50%" height="95%" style="padding: 2px;">
+ <div id="blockly"></div>
+ <div id="blocklyMask"></div>
+ </td>
+ <td width="50%" height="95%">
+ <table>
+ <tr>
+ <td height="30%">
+ <div id="preview"></div>
+ </td>
+ </tr>
+ <tr>
+ <td height="5%">
+ <h3>Language code:
+ <select id="format">
+ <option value="JSON">JSON</option>
+ <option value="JavaScript">JavaScript</option>
+ <option value="Manual">Manual edit&hellip;</option>
+ </select>
+ </h3>
+ </td>
+ </tr>
+ <tr>
+ <td height="30%">
+ <pre id="languagePre"></pre>
+ <textarea id="languageTA"></textarea>
+ </td>
+ </tr>
+ <tr>
+ <td height="5%">
+ <h3>Generator stub:
+ <select id="language">
+ <option value="JavaScript">JavaScript</option>
+ <option value="Python">Python</option>
+ <option value="PHP">PHP</option>
+ <option value="Lua">Lua</option>
+ <option value="Dart">Dart</option>
+ </select>
+ </h3>
+ </td>
+ </tr>
+ <tr>
+ <td height="30%">
+ <pre id="generatorPre"></pre>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ <xml id="toolbox" style="display: none">
+ <category name="Input">
+ <block type="input_value">
+ <value name="TYPE">
+ <shadow type="type_null"></shadow>
+ </value>
+ </block>
+ <block type="input_statement">
+ <value name="TYPE">
+ <shadow type="type_null"></shadow>
+ </value>
+ </block>
+ <block type="input_dummy"></block>
+ </category>
+ <category name="Field">
+ <block type="field_static"></block>
+ <block type="field_input"></block>
+ <block type="field_number"></block>
+ <block type="field_angle"></block>
+ <block type="field_dropdown"></block>
+ <block type="field_checkbox"></block>
+ <block type="field_colour"></block>
+ <!--
+ Date picker commented out since it increases footprint by 60%.
+ Add it only if you need it. See also goog.require in blockly.js.
+ <block type="field_date"></block>
+ -->
+ <block type="field_variable"></block>
+ <block type="field_image"></block>
+ </category>
+ <category name="Type">
+ <block type="type_group"></block>
+ <block type="type_null"></block>
+ <block type="type_boolean"></block>
+ <block type="type_number"></block>
+ <block type="type_string"></block>
+ <block type="type_list"></block>
+ <block type="type_other"></block>
+ </category>
+ <category name="Colour" id="colourCategory">
+ <block type="colour_hue"><mutation colour="20"></mutation><field name="HUE">20</field></block>
+ <block type="colour_hue"><mutation colour="65"></mutation><field name="HUE">65</field></block>
+ <block type="colour_hue"><mutation colour="120"></mutation><field name="HUE">120</field></block>
+ <block type="colour_hue"><mutation colour="160"></mutation><field name="HUE">160</field></block>
+ <block type="colour_hue"><mutation colour="210"></mutation><field name="HUE">210</field></block>
+ <block type="colour_hue"><mutation colour="230"></mutation><field name="HUE">230</field></block>
+ <block type="colour_hue"><mutation colour="260"></mutation><field name="HUE">260</field></block>
+ <block type="colour_hue"><mutation colour="290"></mutation><field name="HUE">290</field></block>
+ <block type="colour_hue"><mutation colour="330"></mutation><field name="HUE">330</field></block>
+ </category>
+ </xml>
+</body>
+</html>
diff --git a/blockly/demos/blockfactory/link.png b/blockly/demos/blockfactory/link.png
new file mode 100644
index 0000000..11dfd82
--- /dev/null
+++ b/blockly/demos/blockfactory/link.png
Binary files differ
diff --git a/blockly/demos/blocklyfactory/app_controller.js b/blockly/demos/blocklyfactory/app_controller.js
new file mode 100644
index 0000000..a1d8847
--- /dev/null
+++ b/blockly/demos/blocklyfactory/app_controller.js
@@ -0,0 +1,688 @@
+/**
+ * @license
+ * Visual Blocks Editor
+ *
+ * Copyright 2016 Google Inc.
+ * https://developers.google.com/blockly/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @fileoverview The AppController Class brings together the Block
+ * Factory, Block Library, and Block Exporter functionality into a single web
+ * app.
+ *
+ * @author quachtina96 (Tina Quach)
+ */
+goog.provide('AppController');
+
+goog.require('BlockFactory');
+goog.require('FactoryUtils');
+goog.require('BlockLibraryController');
+goog.require('BlockExporterController');
+goog.require('goog.dom.classlist');
+goog.require('goog.string');
+goog.require('goog.ui.PopupColorPicker');
+goog.require('goog.ui.ColorPicker');
+
+/**
+ * Controller for the Blockly Factory
+ * @constructor
+ */
+AppController = function() {
+ // Initialize Block Library
+ this.blockLibraryName = 'blockLibrary';
+ this.blockLibraryController =
+ new BlockLibraryController(this.blockLibraryName);
+ this.blockLibraryController.populateBlockLibrary();
+
+ // Construct Workspace Factory Controller.
+ this.workspaceFactoryController = new WorkspaceFactoryController
+ ('workspacefactory_toolbox', 'toolbox_blocks', 'preview_blocks');
+
+ // Initialize Block Exporter
+ this.exporter =
+ new BlockExporterController(this.blockLibraryController.storage);
+
+ // Map of tab type to the div element for the tab.
+ this.tabMap = Object.create(null);
+ this.tabMap[AppController.BLOCK_FACTORY] =
+ goog.dom.getElement('blockFactory_tab');
+ this.tabMap[AppController.WORKSPACE_FACTORY] =
+ goog.dom.getElement('workspaceFactory_tab');
+ this.tabMap[AppController.EXPORTER] =
+ goog.dom.getElement('blocklibraryExporter_tab');
+
+ // Last selected tab.
+ this.lastSelectedTab = null;
+ // Selected tab.
+ this.selectedTab = AppController.BLOCK_FACTORY;
+};
+
+// Constant values representing the three tabs in the controller.
+AppController.BLOCK_FACTORY = 'BLOCK_FACTORY';
+AppController.WORKSPACE_FACTORY = 'WORKSPACE_FACTORY';
+AppController.EXPORTER = 'EXPORTER';
+
+/**
+ * Tied to the 'Import Block Library' button. Imports block library from file to
+ * Block Factory. Expects user to upload a single file of JSON mapping each
+ * block type to its xml text representation.
+ */
+AppController.prototype.importBlockLibraryFromFile = function() {
+ var self = this;
+ var files = document.getElementById('files');
+ // If the file list is empty, the user likely canceled in the dialog.
+ if (files.files.length > 0) {
+ // The input tag doesn't have the "multiple" attribute
+ // so the user can only choose 1 file.
+ var file = files.files[0];
+ var fileReader = new FileReader();
+
+ // Create a map of block type to xml text from the file when it has been
+ // read.
+ fileReader.addEventListener('load', function(event) {
+ var fileContents = event.target.result;
+ // Create empty object to hold the read block library information.
+ var blockXmlTextMap = Object.create(null);
+ try {
+ // Parse the file to get map of block type to xml text.
+ blockXmlTextMap = self.formatBlockLibraryForImport_(fileContents);
+ } catch (e) {
+ var message = 'Could not load your block library file.\n'
+ window.alert(message + '\nFile Name: ' + file.name);
+ return;
+ }
+
+ // Create a new block library storage object with inputted block library.
+ var blockLibStorage = new BlockLibraryStorage(
+ self.blockLibraryName, blockXmlTextMap);
+
+ // Update block library controller with the new block library
+ // storage.
+ self.blockLibraryController.setBlockLibraryStorage(blockLibStorage);
+ // Update the block library dropdown.
+ self.blockLibraryController.populateBlockLibrary();
+ // Update the exporter's block library storage.
+ self.exporter.setBlockLibraryStorage(blockLibStorage);
+ });
+ // Read the file.
+ fileReader.readAsText(file);
+ }
+};
+
+/**
+ * Tied to the 'Export Block Library' button. Exports block library to file that
+ * contains JSON mapping each block type to its xml text representation.
+ */
+AppController.prototype.exportBlockLibraryToFile = function() {
+ // Get map of block type to xml.
+ var blockLib = this.blockLibraryController.getBlockLibrary();
+ // Concatenate the xmls, each separated by a blank line.
+ var blockLibText = this.formatBlockLibraryForExport_(blockLib);
+ // Get file name.
+ var filename = prompt('Enter the file name under which to save your block ' +
+ 'library.');
+ // Download file if all necessary parameters are provided.
+ if (filename) {
+ FactoryUtils.createAndDownloadFile(blockLibText, filename, 'xml');
+ } else {
+ alert('Could not export Block Library without file name under which to ' +
+ 'save library.');
+ }
+};
+
+/**
+ * Converts an object mapping block type to xml to text file for output.
+ * @private
+ *
+ * @param {!Object} blockXmlMap - Object mapping block type to xml.
+ * @return {string} Xml text containing the block xmls.
+ */
+AppController.prototype.formatBlockLibraryForExport_ = function(blockXmlMap) {
+ // Create DOM for XML.
+ var xmlDom = goog.dom.createDom('xml', {
+ 'xmlns':"http://www.w3.org/1999/xhtml"
+ });
+
+ // Append each block node to xml dom.
+ for (var blockType in blockXmlMap) {
+ var blockXmlDom = Blockly.Xml.textToDom(blockXmlMap[blockType]);
+ var blockNode = blockXmlDom.firstElementChild;
+ xmlDom.appendChild(blockNode);
+ }
+
+ // Return the xml text.
+ return Blockly.Xml.domToText(xmlDom);
+};
+
+/**
+ * Converts imported block library to an object mapping block type to block xml.
+ * @private
+ *
+ * @param {string} xmlText - String representation of an xml with each block as
+ * a child node.
+ * @return {!Object} object mapping block type to xml text.
+ */
+AppController.prototype.formatBlockLibraryForImport_ = function(xmlText) {
+ var xmlDom = Blockly.Xml.textToDom(xmlText);
+
+ // Get array of xmls. Use an asterisk (*) instead of a tag name for the XPath
+ // selector, to match all elements at that level and get all factory_base
+ // blocks.
+ var blockNodes = goog.dom.xml.selectNodes(xmlDom, '*');
+
+ // Create empty map. The line below creates a truly empy object. It doesn't
+ // have built-in attributes/functions such as length or toString.
+ var blockXmlTextMap = Object.create(null);
+
+ // Populate map.
+ for (var i = 0, blockNode; blockNode = blockNodes[i]; i++) {
+
+ // Add outer xml tag to the block for proper injection in to the
+ // main workspace.
+ // Create DOM for XML.
+ var xmlDom = goog.dom.createDom('xml', {
+ 'xmlns':"http://www.w3.org/1999/xhtml"
+ });
+ xmlDom.appendChild(blockNode);
+
+ var xmlText = Blockly.Xml.domToText(xmlDom);
+ // All block types should be lowercase.
+ var blockType = this.getBlockTypeFromXml_(xmlText).toLowerCase();
+
+ blockXmlTextMap[blockType] = xmlText;
+ }
+
+ return blockXmlTextMap;
+};
+
+/**
+ * Extracts out block type from xml text, the kind that is saved in block
+ * library storage.
+ * @private
+ *
+ * @param {!string} xmlText - A block's xml text.
+ * @return {string} The block type that corresponds to the provided xml text.
+ */
+AppController.prototype.getBlockTypeFromXml_ = function(xmlText) {
+ var xmlDom = Blockly.Xml.textToDom(xmlText);
+ // Find factory base block.
+ var factoryBaseBlockXml = xmlDom.getElementsByTagName('block')[0];
+ // Get field elements from factory base.
+ var fields = factoryBaseBlockXml.getElementsByTagName('field');
+ for (var i = 0; i < fields.length; i++) {
+ // The field whose name is 'NAME' holds the block type as its value.
+ if (fields[i].getAttribute('name') == 'NAME') {
+ return fields[i].childNodes[0].nodeValue;
+ }
+ }
+};
+
+/**
+ * Add click handlers to each tab to allow switching between the Block Factory,
+ * Workspace Factory, and Block Exporter tab.
+ *
+ * @param {!Object} tabMap - Map of tab name to div element that is the tab.
+ */
+AppController.prototype.addTabHandlers = function(tabMap) {
+ var self = this;
+ for (var tabName in tabMap) {
+ var tab = tabMap[tabName];
+ // Use an additional closure to correctly assign the tab callback.
+ tab.addEventListener('click', self.makeTabClickHandler_(tabName));
+ }
+};
+
+/**
+ * Set the selected tab.
+ * @private
+ *
+ * @param {string} tabName AppController.BLOCK_FACTORY,
+ * AppController.WORKSPACE_FACTORY, or AppController.EXPORTER
+ */
+AppController.prototype.setSelected_ = function(tabName) {
+ this.lastSelectedTab = this.selectedTab;
+ this.selectedTab = tabName;
+};
+
+/**
+ * Creates the tab click handler specific to the tab specified.
+ * @private
+ *
+ * @param {string} tabName AppController.BLOCK_FACTORY,
+ * AppController.WORKSPACE_FACTORY, or AppController.EXPORTER
+ * @return {Function} The tab click handler.
+ */
+AppController.prototype.makeTabClickHandler_ = function(tabName) {
+ var self = this;
+ return function() {
+ self.setSelected_(tabName);
+ self.onTab();
+ };
+};
+
+/**
+ * Called on each tab click. Hides and shows specific content based on which tab
+ * (Block Factory, Workspace Factory, or Exporter) is selected.
+ */
+AppController.prototype.onTab = function() {
+ // Get tab div elements.
+ var blockFactoryTab = this.tabMap[AppController.BLOCK_FACTORY];
+ var exporterTab = this.tabMap[AppController.EXPORTER];
+ var workspaceFactoryTab = this.tabMap[AppController.WORKSPACE_FACTORY];
+
+ // Warn user if they have unsaved changes when leaving Block Factory.
+ if (this.lastSelectedTab == AppController.BLOCK_FACTORY &&
+ this.selectedTab != AppController.BLOCK_FACTORY) {
+
+ var hasUnsavedChanges =
+ !FactoryUtils.savedBlockChanges(this.blockLibraryController);
+ if (hasUnsavedChanges &&
+ !confirm('You have unsaved changes in Block Factory.')) {
+ // If the user doesn't want to switch tabs with unsaved changes,
+ // stay on Block Factory Tab.
+ this.setSelected_(AppController.BLOCK_FACTORY);
+ this.lastSelectedTab = AppController.BLOCK_FACTORY;
+ return;
+ }
+ }
+
+ // Only enable key events in workspace factory if workspace factory tab is
+ // selected.
+ this.workspaceFactoryController.keyEventsEnabled =
+ this.selectedTab == AppController.WORKSPACE_FACTORY;
+
+ // Turn selected tab on and other tabs off.
+ this.styleTabs_();
+
+ if (this.selectedTab == AppController.EXPORTER) {
+ // Hide other tabs.
+ FactoryUtils.hide('workspaceFactoryContent');
+ FactoryUtils.hide('blockFactoryContent');
+ // Show exporter tab.
+ FactoryUtils.show('blockLibraryExporter');
+
+ // Need accurate state in order to know which blocks are used in workspace
+ // factory.
+ this.workspaceFactoryController.saveStateFromWorkspace();
+
+ // Update exporter's list of the types of blocks used in workspace factory.
+ var usedBlockTypes = this.workspaceFactoryController.getAllUsedBlockTypes();
+ this.exporter.setUsedBlockTypes(usedBlockTypes);
+
+ // Update exporter's block selector to reflect current block library.
+ this.exporter.updateSelector();
+
+ // Update the exporter's preview to reflect any changes made to the blocks.
+ this.exporter.updatePreview();
+
+ } else if (this.selectedTab == AppController.BLOCK_FACTORY) {
+ // Hide other tabs.
+ FactoryUtils.hide('blockLibraryExporter');
+ FactoryUtils.hide('workspaceFactoryContent');
+ // Show Block Factory.
+ FactoryUtils.show('blockFactoryContent');
+
+ } else if (this.selectedTab == AppController.WORKSPACE_FACTORY) {
+ // Hide other tabs.
+ FactoryUtils.hide('blockLibraryExporter');
+ FactoryUtils.hide('blockFactoryContent');
+ // Show workspace factory container.
+ FactoryUtils.show('workspaceFactoryContent');
+ // Update block library category.
+ var categoryXml = this.exporter.getBlockLibraryCategory();
+ var blockTypes = this.blockLibraryController.getStoredBlockTypes();
+ this.workspaceFactoryController.setBlockLibCategory(categoryXml,
+ blockTypes);
+ }
+
+ // Resize to render workspaces' toolboxes correctly for all tabs.
+ window.dispatchEvent(new Event('resize'));
+};
+
+/**
+ * Called on each tab click. Styles the tabs to reflect which tab is selected.
+ * @private
+ */
+AppController.prototype.styleTabs_ = function() {
+ for (var tabName in this.tabMap) {
+ if (this.selectedTab == tabName) {
+ goog.dom.classlist.addRemove(this.tabMap[tabName], 'taboff', 'tabon');
+ } else {
+ goog.dom.classlist.addRemove(this.tabMap[tabName], 'tabon', 'taboff');
+ }
+ }
+};
+
+/**
+ * Assign button click handlers for the exporter.
+ */
+AppController.prototype.assignExporterClickHandlers = function() {
+ var self = this;
+ document.getElementById('button_setBlocks').addEventListener('click',
+ function() {
+ document.getElementById('dropdownDiv_setBlocks').classList.toggle("show");
+ });
+
+ document.getElementById('dropdown_addAllUsed').addEventListener('click',
+ function() {
+ self.exporter.selectUsedBlocks();
+ self.exporter.updatePreview();
+ document.getElementById('dropdownDiv_setBlocks').classList.remove("show");
+ });
+
+ document.getElementById('dropdown_addAllFromLib').addEventListener('click',
+ function() {
+ self.exporter.selectAllBlocks();
+ self.exporter.updatePreview();
+ document.getElementById('dropdownDiv_setBlocks').classList.remove("show");
+ });
+
+ document.getElementById('clearSelectedButton').addEventListener('click',
+ function() {
+ self.exporter.clearSelectedBlocks();
+ self.exporter.updatePreview();
+ document.getElementById('dropdownDiv_setBlocks').classList.remove("show");
+ });
+
+ // Export blocks when the user submits the export settings.
+ document.getElementById('exporterSubmitButton').addEventListener('click',
+ function() {
+ self.exporter.export();
+ });
+};
+
+/**
+ * Assign change listeners for the exporter. These allow for the dynamic update
+ * of the exporter preview.
+ */
+AppController.prototype.assignExporterChangeListeners = function() {
+ var self = this;
+
+ var blockDefCheck = document.getElementById('blockDefCheck');
+ var genStubCheck = document.getElementById('genStubCheck');
+
+ var blockDefs = document.getElementById('blockDefs');
+ var blockDefSettings = document.getElementById('blockDefSettings');
+ var blockDefElements = [blockDefs, blockDefSettings];
+
+ var genStubs = document.getElementById('genStubs');
+ var genStubSettings = document.getElementById('genStubSettings');
+ var genStubElements = [genStubs, genStubSettings];
+
+ // Select the block definitions and generator stubs on default.
+ blockDefCheck.checked = true;
+ genStubCheck.checked = true;
+
+ // Checking the block definitions checkbox displays preview of code to export.
+ document.getElementById('blockDefCheck').addEventListener('change',
+ function(e) {
+ self.ifCheckedDisplay(blockDefCheck, blockDefElements);
+ });
+
+ // Preview updates when user selects different block definition format.
+ document.getElementById('exportFormat').addEventListener('change',
+ function(e) {
+ self.exporter.updatePreview();
+ });
+
+ // Checking the generator stub checkbox displays preview of code to export.
+ document.getElementById('genStubCheck').addEventListener('change',
+ function(e) {
+ self.ifCheckedDisplay(genStubCheck, genStubElements);
+ });
+
+ // Preview updates when user selects different generator stub language.
+ document.getElementById('exportLanguage').addEventListener('change',
+ function(e) {
+ self.exporter.updatePreview();
+ });
+};
+
+/**
+ * If given checkbox is checked, display given elements. Otherwise, hide.
+ *
+ * @param {!Element} checkbox - Input element of type checkbox.
+ * @param {!Array.<!Element>} elementArray - Array of elements to show when
+ * block is checked.
+ */
+AppController.prototype.ifCheckedDisplay = function(checkbox, elementArray) {
+ for (var i = 0, element; element = elementArray[i]; i++) {
+ element.style.display = checkbox.checked ? 'block' : 'none';
+ }
+};
+
+/**
+ * Assign button click handlers for the block library.
+ */
+AppController.prototype.assignLibraryClickHandlers = function() {
+ var self = this;
+
+ // Button for saving block to library.
+ document.getElementById('saveToBlockLibraryButton').addEventListener('click',
+ function() {
+ self.blockLibraryController.saveToBlockLibrary();
+ });
+
+ // Button for removing selected block from library.
+ document.getElementById('removeBlockFromLibraryButton').addEventListener(
+ 'click',
+ function() {
+ self.blockLibraryController.removeFromBlockLibrary();
+ });
+
+ // Button for clearing the block library.
+ document.getElementById('clearBlockLibraryButton').addEventListener('click',
+ function() {
+ self.blockLibraryController.clearBlockLibrary();
+ });
+
+ // Hide and show the block library dropdown.
+ document.getElementById('button_blockLib').addEventListener('click',
+ function() {
+ document.getElementById('dropdownDiv_blockLib').classList.toggle("show");
+ });
+};
+
+/**
+ * Assign button click handlers for the block factory.
+ */
+AppController.prototype.assignBlockFactoryClickHandlers = function() {
+ var self = this;
+ // Assign button event handlers for Block Factory.
+ document.getElementById('localSaveButton')
+ .addEventListener('click', function() {
+ self.exportBlockLibraryToFile();
+ });
+
+ document.getElementById('helpButton').addEventListener('click',
+ function() {
+ open('https://developers.google.com/blockly/custom-blocks/block-factory',
+ 'BlockFactoryHelp');
+ });
+
+ document.getElementById('files').addEventListener('change',
+ function() {
+ // Warn user.
+ var replace = confirm('This imported block library will ' +
+ 'replace your current block library.');
+ if (replace) {
+ self.importBlockLibraryFromFile();
+ // Clear this so that the change event still fires even if the
+ // same file is chosen again. If the user re-imports a file, we
+ // want to reload the workspace with its contents.
+ this.value = null;
+ }
+ });
+
+ document.getElementById('createNewBlockButton')
+ .addEventListener('click', function() {
+ // If there are unsaved changes warn user, check if they'd like to
+ // proceed with unsaved changes, and act accordingly.
+ var proceedWithUnsavedChanges =
+ self.blockLibraryController.warnIfUnsavedChanges();
+ if (!proceedWithUnsavedChanges) {
+ return;
+ }
+
+ BlockFactory.showStarterBlock();
+ self.blockLibraryController.setNoneSelected();
+
+ // Close the Block Library Dropdown.
+ goog.dom.getElement('dropdownDiv_blockLib').classList.remove("show");
+ });
+};
+
+/**
+ * Add event listeners for the block factory.
+ */
+AppController.prototype.addBlockFactoryEventListeners = function() {
+ // Update code on changes to block being edited.
+ BlockFactory.mainWorkspace.addChangeListener(BlockFactory.updateLanguage);
+
+ // Disable blocks not attached to the factory_base block.
+ BlockFactory.mainWorkspace.addChangeListener(Blockly.Events.disableOrphans);
+
+ // Update the buttons on the screen based on whether
+ // changes have been saved.
+ var self = this;
+ BlockFactory.mainWorkspace.addChangeListener(function() {
+ self.blockLibraryController.updateButtons(FactoryUtils.savedBlockChanges(
+ self.blockLibraryController));
+ });
+
+ document.getElementById('direction')
+ .addEventListener('change', BlockFactory.updatePreview);
+ document.getElementById('languageTA')
+ .addEventListener('change', BlockFactory.updatePreview);
+ document.getElementById('languageTA')
+ .addEventListener('keyup', BlockFactory.updatePreview);
+ document.getElementById('format')
+ .addEventListener('change', BlockFactory.formatChange);
+ document.getElementById('language')
+ .addEventListener('change', BlockFactory.updatePreview);
+};
+
+/**
+ * Handle Blockly Storage with App Engine.
+ */
+AppController.prototype.initializeBlocklyStorage = function() {
+ BlocklyStorage.HTTPREQUEST_ERROR =
+ 'There was a problem with the request.\n';
+ BlocklyStorage.LINK_ALERT =
+ 'Share your blocks with this link:\n\n%1';
+ BlocklyStorage.HASH_ERROR =
+ 'Sorry, "%1" doesn\'t correspond with any saved Blockly file.';
+ BlocklyStorage.XML_ERROR = 'Could not load your saved file.\n' +
+ 'Perhaps it was created with a different version of Blockly?';
+ var linkButton = document.getElementById('linkButton');
+ linkButton.style.display = 'inline-block';
+ linkButton.addEventListener('click',
+ function() {
+ BlocklyStorage.link(BlockFactory.mainWorkspace);});
+ BlockFactory.disableEnableLink();
+};
+
+/**
+ * Handle resizing of elements.
+ */
+AppController.prototype.onresize = function(event) {
+ if (this.selectedTab == AppController.BLOCK_FACTORY) {
+ // Handle resizing of Block Factory elements.
+ var expandList = [
+ document.getElementById('blocklyPreviewContainer'),
+ document.getElementById('blockly'),
+ document.getElementById('blocklyMask'),
+ document.getElementById('preview'),
+ document.getElementById('languagePre'),
+ document.getElementById('languageTA'),
+ document.getElementById('generatorPre'),
+ ];
+ for (var i = 0, expand; expand = expandList[i]; i++) {
+ expand.style.width = (expand.parentNode.offsetWidth - 2) + 'px';
+ expand.style.height = (expand.parentNode.offsetHeight - 2) + 'px';
+ }
+ } else if (this.selectedTab == AppController.EXPORTER) {
+ // Handle resize of Exporter block options.
+ this.exporter.view.centerPreviewBlocks();
+ }
+};
+
+/**
+ * Handler for the window's 'onbeforeunload' event. When a user has unsaved
+ * changes and refreshes or leaves the page, confirm that they want to do so
+ * before actually refreshing.
+ */
+AppController.prototype.confirmLeavePage = function() {
+ if ((!BlockFactory.isStarterBlock() &&
+ !FactoryUtils.savedBlockChanges(this.blockLibraryController)) ||
+ this.workspaceFactoryController.hasUnsavedChanges()) {
+ // When a string is assigned to the returnValue Event property, a dialog box
+ // appears, asking the users for confirmation to leave the page.
+ return 'You will lose any unsaved changes. Are you sure you want ' +
+ 'to exit this page?';
+ }
+};
+
+/**
+ * Initialize Blockly and layout. Called on page load.
+ */
+AppController.prototype.init = function() {
+ // Handle Blockly Storage with App Engine
+ if ('BlocklyStorage' in window) {
+ this.initializeBlocklyStorage();
+ }
+
+ // Assign click handlers.
+ this.assignExporterClickHandlers();
+ this.assignLibraryClickHandlers();
+ this.assignBlockFactoryClickHandlers();
+
+ this.onresize();
+ var self = this;
+ window.addEventListener('resize', function() {
+ self.onresize();
+ });
+
+ // Inject Block Factory Main Workspace.
+ var toolbox = document.getElementById('blockfactory_toolbox');
+ BlockFactory.mainWorkspace = Blockly.inject('blockly',
+ {collapse: false,
+ toolbox: toolbox,
+ media: '../../media/'});
+
+ // Add tab handlers for switching between Block Factory and Block Exporter.
+ this.addTabHandlers(this.tabMap);
+
+ // Assign exporter change listeners.
+ this.assignExporterChangeListeners();
+
+ // Create the root block on Block Factory main workspace.
+ if ('BlocklyStorage' in window && window.location.hash.length > 1) {
+ BlocklyStorage.retrieveXml(window.location.hash.substring(1),
+ BlockFactory.mainWorkspace);
+ } else {
+ BlockFactory.showStarterBlock();
+ }
+ BlockFactory.mainWorkspace.clearUndo();
+
+ // Add Block Factory event listeners.
+ this.addBlockFactoryEventListeners();
+
+ // Workspace Factory init.
+ WorkspaceFactoryInit.initWorkspaceFactory(this.workspaceFactoryController);
+};
+
+
diff --git a/blockly/demos/blocklyfactory/block_exporter_controller.js b/blockly/demos/blocklyfactory/block_exporter_controller.js
new file mode 100644
index 0000000..e0c192f
--- /dev/null
+++ b/blockly/demos/blocklyfactory/block_exporter_controller.js
@@ -0,0 +1,335 @@
+/**
+ * @license
+ * Visual Blocks Editor
+ *
+ * Copyright 2016 Google Inc.
+ * https://developers.google.com/blockly/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @fileoverview Javascript for the Block Exporter Controller class. Allows
+ * users to export block definitions and generator stubs of their saved blocks
+ * easily using a visual interface. Depends on Block Exporter View and Block
+ * Exporter Tools classes. Interacts with Export Settings in the index.html.
+ *
+ * @author quachtina96 (Tina Quach)
+ */
+
+'use strict';
+
+goog.provide('BlockExporterController');
+
+goog.require('FactoryUtils');
+goog.require('StandardCategories');
+goog.require('BlockExporterView');
+goog.require('BlockExporterTools');
+goog.require('goog.dom.xml');
+
+/**
+ * BlockExporter Controller Class
+ * @constructor
+ *
+ * @param {!BlockLibrary.Storage} blockLibStorage - Block Library Storage.
+ */
+BlockExporterController = function(blockLibStorage) {
+ // BlockLibrary.Storage object containing user's saved blocks.
+ this.blockLibStorage = blockLibStorage;
+ // Utils for generating code to export.
+ this.tools = new BlockExporterTools();
+ // The ID of the block selector, a div element that will be populated with the
+ // block options.
+ this.selectorID = 'blockSelector';
+ // Map of block types stored in block library to their corresponding Block
+ // Option objects.
+ this.blockOptions = this.tools.createBlockSelectorFromLib(
+ this.blockLibStorage, this.selectorID);
+ // View provides the block selector and export settings UI.
+ this.view = new BlockExporterView(this.blockOptions);
+};
+
+/**
+ * Set the block library storage object from which exporter exports.
+ *
+ * @param {!BlockLibraryStorage} blockLibStorage - Block Library Storage object
+ * that stores the blocks.
+ */
+BlockExporterController.prototype.setBlockLibraryStorage =
+ function(blockLibStorage) {
+ this.blockLibStorage = blockLibStorage;
+};
+
+/**
+ * Get the block library storage object from which exporter exports.
+ *
+ * @return {!BlockLibraryStorage} blockLibStorage - Block Library Storage object
+ * that stores the blocks.
+ */
+BlockExporterController.prototype.getBlockLibraryStorage =
+ function(blockLibStorage) {
+ return this.blockLibStorage;
+};
+
+/**
+ * Get selected blocks from block selector, pulls info from the Export
+ * Settings form in Block Exporter, and downloads code accordingly.
+ */
+BlockExporterController.prototype.export = function() {
+ // Get selected blocks' information.
+ var blockTypes = this.view.getSelectedBlockTypes();
+ var blockXmlMap = this.blockLibStorage.getBlockXmlMap(blockTypes);
+
+ // Pull block definition(s) settings from the Export Settings form.
+ var wantBlockDef = document.getElementById('blockDefCheck').checked;
+ var definitionFormat = document.getElementById('exportFormat').value;
+ var blockDef_filename = document.getElementById('blockDef_filename').value;
+
+ // Pull block generator stub(s) settings from the Export Settings form.
+ var wantGenStub = document.getElementById('genStubCheck').checked;
+ var language = document.getElementById('exportLanguage').value;
+ var generatorStub_filename = document.getElementById(
+ 'generatorStub_filename').value;
+
+ if (wantBlockDef) {
+ // User wants to export selected blocks' definitions.
+ if (!blockDef_filename) {
+ // User needs to enter filename.
+ alert('Please enter a filename for your block definition(s) download.');
+ } else {
+ // Get block definition code in the selected format for the blocks.
+ var blockDefs = this.tools.getBlockDefinitions(blockXmlMap,
+ definitionFormat);
+ // Download the file, using .js file ending for JSON or Javascript.
+ FactoryUtils.createAndDownloadFile(
+ blockDefs, blockDef_filename, 'javascript');
+ }
+ }
+
+ if (wantGenStub) {
+ // User wants to export selected blocks' generator stubs.
+ if (!generatorStub_filename) {
+ // User needs to enter filename.
+ alert('Please enter a filename for your generator stub(s) download.');
+ } else {
+ // Get generator stub code in the selected language for the blocks.
+ var genStubs = this.tools.getGeneratorCode(blockXmlMap,
+ language);
+ // Get the correct file extension.
+ if (language == 'JavaScript') {
+ var fileType = 'javascript';
+ } else {
+ var fileType = 'plain';
+ }
+ // Download the file.
+ FactoryUtils.createAndDownloadFile(
+ genStubs, generatorStub_filename, fileType);
+ }
+ }
+
+};
+
+/**
+ * Update the Exporter's block selector with block options generated from blocks
+ * stored in block library.
+ */
+BlockExporterController.prototype.updateSelector = function() {
+ // Get previously selected block types.
+ var oldSelectedTypes = this.view.getSelectedBlockTypes();
+
+ // Generate options from block library and assign to view.
+ this.blockOptions = this.tools.createBlockSelectorFromLib(
+ this.blockLibStorage, this.selectorID);
+ this.addBlockOptionSelectHandlers();
+ this.view.setBlockOptions(this.blockOptions);
+
+ // Select all previously selected blocks.
+ for (var i = 0, blockType; blockType = oldSelectedTypes[i]; i++) {
+ if (this.blockOptions[blockType]) {
+ this.view.select(blockType);
+ }
+ }
+
+ this.view.listSelectedBlocks();
+};
+
+/**
+ * Tied to the 'Clear Selected Blocks' button in the Block Exporter.
+ * Deselects all blocks in the selector and updates text accordingly.
+ */
+BlockExporterController.prototype.clearSelectedBlocks = function() {
+ this.view.deselectAllBlocks();
+ this.view.listSelectedBlocks();
+};
+
+/**
+ * Tied to the 'All Stored' button in the Block Exporter 'Select' dropdown.
+ * Selects all blocks stored in block library for export.
+ */
+BlockExporterController.prototype.selectAllBlocks = function() {
+ var allBlockTypes = this.blockLibStorage.getBlockTypes();
+ for (var i = 0, blockType; blockType = allBlockTypes[i]; i++) {
+ this.view.select(blockType);
+ }
+ this.view.listSelectedBlocks();
+};
+
+/**
+ * Returns the category xml containing all blocks in the block library.
+ *
+ * @return {Element} Xml for a category to be used in toolbox.
+ */
+BlockExporterController.prototype.getBlockLibraryCategory = function() {
+ return this.tools.generateCategoryFromBlockLib(this.blockLibStorage);
+};
+
+/**
+ * Add select handlers to each block option to update the view and the selected
+ * blocks accordingly.
+ */
+BlockExporterController.prototype.addBlockOptionSelectHandlers = function() {
+ var self = this;
+
+ // Click handler for a block option. Toggles whether or not it's selected and
+ // updates helper text accordingly.
+ var updateSelectedBlockTypes_ = function(blockOption) {
+ // Toggle selected.
+ blockOption.setSelected(!blockOption.isSelected());
+
+ // Show currently selected blocks in helper text.
+ self.view.listSelectedBlocks();
+ };
+
+ // Returns a block option select handler.
+ var makeBlockOptionSelectHandler_ = function(blockOption) {
+ return function() {
+ updateSelectedBlockTypes_(blockOption);
+ self.updatePreview();
+ };
+ };
+
+ // Assign a click handler to each block option.
+ for (var blockType in this.blockOptions) {
+ var blockOption = this.blockOptions[blockType];
+ // Use an additional closure to correctly assign the tab callback.
+ blockOption.dom.addEventListener(
+ 'click', makeBlockOptionSelectHandler_(blockOption));
+ }
+};
+
+/**
+ * Tied to the 'All Used' button in the Block Exporter's 'Select' button.
+ * Selects all blocks stored in block library and used in workspace factory.
+ */
+BlockExporterController.prototype.selectUsedBlocks = function() {
+ // Deselect all blocks.
+ this.view.deselectAllBlocks();
+
+ // Get list of block types that are in block library and used in workspace
+ // factory.
+ var storedBlockTypes = this.blockLibStorage.getBlockTypes();
+ var sharedBlockTypes = [];
+ // Keep list of custom block types used but not in library.
+ var unstoredCustomBlockTypes = [];
+
+ for (var i = 0, blockType; blockType = this.usedBlockTypes[i]; i++) {
+ if (storedBlockTypes.indexOf(blockType) != -1) {
+ sharedBlockTypes.push(blockType);
+ } else if (StandardCategories.coreBlockTypes.indexOf(blockType) == -1) {
+ unstoredCustomBlockTypes.push(blockType);
+ }
+ }
+
+ // Select each shared block type.
+ for (var i = 0, blockType; blockType = sharedBlockTypes[i]; i++) {
+ this.view.select(blockType);
+ }
+ this.view.listSelectedBlocks();
+
+ if (unstoredCustomBlockTypes.length > 0){
+ // Warn user to import block defifnitions and generator code for blocks
+ // not in their Block Library nor Blockly's standard library.
+ var blockTypesText = unstoredCustomBlockTypes.join(', ');
+ var customWarning = 'Custom blocks used in workspace factory but not ' +
+ 'stored in block library:\n ' + blockTypesText +
+ '\n\nDon\'t forget to include block definitions and generator code ' +
+ 'for these blocks.';
+ alert(customWarning);
+ }
+};
+
+/**
+ * Set the array that holds the block types used in workspace factory.
+ *
+ * @param {!Array.<!string>} usedBlockTypes - Block types used in
+ */
+BlockExporterController.prototype.setUsedBlockTypes =
+ function(usedBlockTypes) {
+ this.usedBlockTypes = usedBlockTypes;
+};
+
+/**
+ * Updates preview code (block definitions and generator stubs) in the exporter
+ * preview to reflect selected blocks.
+ */
+BlockExporterController.prototype.updatePreview = function() {
+ // Generate preview code for selected blocks.
+ var blockDefs = this.getBlockDefinitionsOfSelected();
+ var genStubs = this.getGeneratorStubsOfSelected();
+
+ // Update the text areas containing the code.
+ FactoryUtils.injectCode(blockDefs, 'blockDefs_textArea');
+ FactoryUtils.injectCode(genStubs, 'genStubs_textArea');
+};
+
+/**
+ * Returns a map of each selected block's type to its corresponding xml.
+ *
+ * @return {!Object} a map of each selected block's type (a string) to its
+ * corresponding xml element.
+ */
+BlockExporterController.prototype.getSelectedBlockXmlMap = function() {
+ var blockTypes = this.view.getSelectedBlockTypes();
+ return this.blockLibStorage.getBlockXmlMap(blockTypes);
+};
+
+/**
+ * Get block definition code in the selected format for selected blocks.
+ *
+ * @return {!string} The concatenation of each selected block's language code
+ * in the format specified in export settings.
+ */
+BlockExporterController.prototype.getBlockDefinitionsOfSelected = function() {
+ // Get selected blocks' information.
+ var blockXmlMap = this.getSelectedBlockXmlMap();
+
+ // Get block definition code in the selected format for the blocks.
+ var definitionFormat = document.getElementById('exportFormat').value;
+ return this.tools.getBlockDefinitions(blockXmlMap, definitionFormat);
+};
+
+/**
+ * Get generator stubs in the selected language for selected blocks.
+ *
+ * @return {!string} The concatenation of each selected block's generator stub
+ * in the language specified in export settings.
+ */
+BlockExporterController.prototype.getGeneratorStubsOfSelected = function() {
+ // Get selected blocks' information.
+ var blockXmlMap = this.getSelectedBlockXmlMap();
+
+ // Get generator stub code in the selected language for the blocks.
+ var language = document.getElementById('exportLanguage').value;
+ return this.tools.getGeneratorCode(blockXmlMap, language);
+};
+
diff --git a/blockly/demos/blocklyfactory/block_exporter_tools.js b/blockly/demos/blocklyfactory/block_exporter_tools.js
new file mode 100644
index 0000000..1396800
--- /dev/null
+++ b/blockly/demos/blocklyfactory/block_exporter_tools.js
@@ -0,0 +1,276 @@
+/**
+ * @license
+ * Visual Blocks Editor
+ *
+ * Copyright 2016 Google Inc.
+ * https://developers.google.com/blockly/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @fileoverview Javascript for the BlockExporter Tools class, which generates
+ * block definitions and generator stubs for given block types. Also generates
+ * toolbox xml for the exporter's workspace. Depends on the FactoryUtils for
+ * its code generation functions.
+ *
+ * @author quachtina96 (Tina Quach)
+ */
+'use strict';
+
+goog.provide('BlockExporterTools');
+
+goog.require('FactoryUtils');
+goog.require('BlockOption');
+goog.require('goog.dom');
+goog.require('goog.dom.xml');
+
+/**
+* Block Exporter Tools Class
+* @constructor
+*/
+BlockExporterTools = function() {
+ // Create container for hidden workspace.
+ this.container = goog.dom.createDom('div', {
+ 'id': 'blockExporterTools_hiddenWorkspace'
+ }, ''); // Empty quotes for empty div.
+ // Hide hidden workspace.
+ this.container.style.display = 'none';
+ goog.dom.appendChild(document.body, this.container);
+ /**
+ * Hidden workspace for the Block Exporter that holds pieces that make
+ * up the block
+ * @type {Blockly.Workspace}
+ */
+ this.hiddenWorkspace = Blockly.inject(this.container.id,
+ {collapse: false,
+ media: '../../media/'});
+};
+
+/**
+ * Get Blockly Block object from xml that encodes the blocks used to design
+ * the block.
+ * @private
+ *
+ * @param {!Element} xml - Xml element that encodes the blocks used to design
+ * the block. For example, the block xmls saved in block library.
+ * @return {!Blockly.Block} - Root block (factory_base block) which contains
+ * all information needed to generate block definition or null.
+ */
+BlockExporterTools.prototype.getRootBlockFromXml_ = function(xml) {
+ // Render xml in hidden workspace.
+ this.hiddenWorkspace.clear();
+ Blockly.Xml.domToWorkspace(xml, this.hiddenWorkspace);
+ // Get root block.
+ var rootBlock = this.hiddenWorkspace.getTopBlocks()[0] || null;
+ return rootBlock;
+};
+
+/**
+ * Return the given language code of each block type in an array.
+ *
+ * @param {!Object} blockXmlMap - Map of block type to xml.
+ * @param {string} definitionFormat - 'JSON' or 'JavaScript'
+ * @return {string} The concatenation of each block's language code in the
+ * desired format.
+ */
+BlockExporterTools.prototype.getBlockDefinitions =
+ function(blockXmlMap, definitionFormat) {
+ var blockCode = [];
+ for (var blockType in blockXmlMap) {
+ var xml = blockXmlMap[blockType];
+ if (xml) {
+ // Render and get block from hidden workspace.
+ var rootBlock = this.getRootBlockFromXml_(xml);
+ if (rootBlock) {
+ // Generate the block's definition.
+ var code = FactoryUtils.getBlockDefinition(blockType, rootBlock,
+ definitionFormat, this.hiddenWorkspace);
+ // Add block's definition to the definitions to return.
+ } else {
+ // Append warning comment and write to console.
+ var code = '// No block definition generated for ' + blockType +
+ '. Could not find root block in xml stored for this block.';
+ console.log('No block definition generated for ' + blockType +
+ '. Could not find root block in xml stored for this block.');
+ }
+ } else {
+ // Append warning comment and write to console.
+ var code = '// No block definition generated for ' + blockType +
+ '. Block was not found in Block Library Storage.';
+ console.log('No block definition generated for ' + blockType +
+ '. Block was not found in Block Library Storage.');
+ }
+ blockCode.push(code);
+ }
+ return blockCode.join("\n\n");
+};
+
+/**
+ * Return the generator code of each block type in an array in a given language.
+ *
+ * @param {!Object} blockXmlMap - Map of block type to xml.
+ * @param {string} generatorLanguage - e.g.'JavaScript', 'Python', 'PHP', 'Lua',
+ * 'Dart'
+ * @return {string} The concatenation of each block's generator code in the
+ * desired format.
+ */
+BlockExporterTools.prototype.getGeneratorCode =
+ function(blockXmlMap, generatorLanguage) {
+ var multiblockCode = [];
+ // Define the custom blocks in order to be able to create instances of
+ // them in the exporter workspace.
+ this.addBlockDefinitions(blockXmlMap);
+
+ for (var blockType in blockXmlMap) {
+ var xml = blockXmlMap[blockType];
+ if (xml) {
+ // Render the preview block in the hidden workspace.
+ var tempBlock =
+ FactoryUtils.getDefinedBlock(blockType, this.hiddenWorkspace);
+ // Get generator stub for the given block and add to generator code.
+ var blockGenCode =
+ FactoryUtils.getGeneratorStub(tempBlock, generatorLanguage);
+ } else {
+ // Append warning comment and write to console.
+ var blockGenCode = '// No generator stub generated for ' + blockType +
+ '. Block was not found in Block Library Storage.';
+ console.log('No block generator stub generated for ' + blockType +
+ '. Block was not found in Block Library Storage.');
+ }
+ multiblockCode.push(blockGenCode);
+ }
+ return multiblockCode.join("\n\n");
+};
+
+/**
+ * Evaluates block definition code of each block in given object mapping
+ * block type to xml. Called in order to be able to create instances of the
+ * blocks in the exporter workspace.
+ *
+ * @param {!Object} blockXmlMap - Map of block type to xml.
+ */
+BlockExporterTools.prototype.addBlockDefinitions = function(blockXmlMap) {
+ var blockDefs = this.getBlockDefinitions(blockXmlMap, 'JavaScript');
+ eval(blockDefs);
+};
+
+/**
+ * Pulls information about all blocks in the block library to generate xml
+ * for the selector workpace's toolbox.
+ *
+ * @param {!BlockLibraryStorage} blockLibStorage - Block Library Storage object.
+ * @return {!Element} Xml representation of the toolbox.
+ */
+BlockExporterTools.prototype.generateToolboxFromLibrary
+ = function(blockLibStorage) {
+ // Create DOM for XML.
+ var xmlDom = goog.dom.createDom('xml', {
+ 'id' : 'blockExporterTools_toolbox',
+ 'style' : 'display:none'
+ });
+
+ var allBlockTypes = blockLibStorage.getBlockTypes();
+ // Object mapping block type to XML.
+ var blockXmlMap = blockLibStorage.getBlockXmlMap(allBlockTypes);
+
+ // Define the custom blocks in order to be able to create instances of
+ // them in the exporter workspace.
+ this.addBlockDefinitions(blockXmlMap);
+
+ for (var blockType in blockXmlMap) {
+ // Get block.
+ var block = FactoryUtils.getDefinedBlock(blockType, this.hiddenWorkspace);
+ var category = FactoryUtils.generateCategoryXml([block], blockType);
+ xmlDom.appendChild(category);
+ }
+
+ // If there are no blocks in library and the map is empty, append dummy
+ // category.
+ if (Object.keys(blockXmlMap).length == 0) {
+ var category = goog.dom.createDom('category');
+ category.setAttribute('name','Next Saved Block');
+ xmlDom.appendChild(category);
+ }
+ return xmlDom;
+};
+
+/**
+ * Generate xml for the workspace factory's category from imported block
+ * definitions.
+ *
+ * @param {!BlockLibraryStorage} blockLibStorage - Block Library Storage object.
+ * @return {!Element} Xml representation of a category.
+ */
+BlockExporterTools.prototype.generateCategoryFromBlockLib =
+ function(blockLibStorage) {
+ var allBlockTypes = blockLibStorage.getBlockTypes();
+ // Object mapping block type to XML.
+ var blockXmlMap = blockLibStorage.getBlockXmlMap(allBlockTypes);
+
+ // Define the custom blocks in order to be able to create instances of
+ // them in the exporter workspace.
+ this.addBlockDefinitions(blockXmlMap);
+
+ // Get array of defined blocks.
+ var blocks = [];
+ for (var blockType in blockXmlMap) {
+ var block = FactoryUtils.getDefinedBlock(blockType, this.hiddenWorkspace);
+ blocks.push(block);
+ }
+
+ return FactoryUtils.generateCategoryXml(blocks,'Block Library');
+};
+
+/**
+ * Generate selector dom from block library storage. For each block in the
+ * library, it has a block option, which consists of a checkbox, a label,
+ * and a fixed size preview workspace.
+ *
+ * @param {!BlockLibraryStorage} blockLibStorage - Block Library Storage object.
+ * @param {!string} blockSelectorID - ID of the div element that will contain
+ * the block options.
+ * @return {!Object} Map of block type to Block Option object.
+ */
+BlockExporterTools.prototype.createBlockSelectorFromLib =
+ function(blockLibStorage, blockSelectorID) {
+ // Object mapping each stored block type to XML.
+ var allBlockTypes = blockLibStorage.getBlockTypes();
+ var blockXmlMap = blockLibStorage.getBlockXmlMap(allBlockTypes);
+
+ // Define the custom blocks in order to be able to create instances of
+ // them in the exporter workspace.
+ this.addBlockDefinitions(blockXmlMap);
+
+ var blockSelector = goog.dom.getElement(blockSelectorID);
+ // Clear the block selector.
+ goog.dom.removeChildren(blockSelector);
+
+ // Append each block option's dom to the selector.
+ var blockOptions = Object.create(null);
+ for (var blockType in blockXmlMap) {
+ // Get preview block's xml.
+ var block = FactoryUtils.getDefinedBlock(blockType, this.hiddenWorkspace);
+ var previewBlockXml = Blockly.Xml.workspaceToDom(this.hiddenWorkspace);
+
+ // Create block option, inject block into preview workspace, and append
+ // option to block selector.
+ var blockOpt = new BlockOption(blockSelector, blockType, previewBlockXml);
+ blockOpt.createDom();
+ goog.dom.appendChild(blockSelector, blockOpt.dom);
+ blockOpt.showPreviewBlock();
+ blockOptions[blockType] = blockOpt;
+ }
+ return blockOptions;
+};
+
diff --git a/blockly/demos/blocklyfactory/block_exporter_view.js b/blockly/demos/blocklyfactory/block_exporter_view.js
new file mode 100644
index 0000000..5b703f3
--- /dev/null
+++ b/blockly/demos/blocklyfactory/block_exporter_view.js
@@ -0,0 +1,145 @@
+/**
+ * @license
+ * Visual Blocks Editor
+ *
+ * Copyright 2016 Google Inc.
+ * https://developers.google.com/blockly/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @fileoverview Javascript for the Block Exporter View class. Reads from and
+ * manages a block selector through which users select blocks to export.
+ *
+ * @author quachtina96 (Tina Quach)
+ */
+
+'use strict';
+
+goog.provide('BlockExporterView');
+
+goog.require('BlockExporterTools');
+goog.require('BlockOption');
+goog.require('goog.dom');
+
+/**
+ * BlockExporter View Class
+ * @constructor
+ *
+ * @param {!Object} blockOptions - Map of block types to BlockOption objects.
+ */
+BlockExporterView = function(blockOptions) {
+ // Map of block types to BlockOption objects to select from.
+ this.blockOptions = blockOptions;
+};
+
+/**
+ * Set the block options in the selector of this instance of
+ * BlockExporterView.
+ *
+ * @param {!Object} blockOptions - Map of block types to BlockOption objects.
+ */
+BlockExporterView.prototype.setBlockOptions = function(blockOptions) {
+ this.blockOptions = blockOptions;
+};
+
+/**
+ * Updates the helper text.
+ *
+ * @param {string} newText - New helper text.
+ * @param {boolean} opt_append - True if appending to helper Text, false if
+ * replacing.
+ */
+BlockExporterView.prototype.updateHelperText = function(newText, opt_append) {
+ if (opt_append) {
+ goog.dom.getElement('helperText').textContent =
+ goog.dom.getElement('helperText').textContent + newText;
+ } else {
+ goog.dom.getElement('helperText').textContent = newText;
+ }
+};
+
+/**
+ * Updates the helper text to show list of currently selected blocks.
+ */
+BlockExporterView.prototype.listSelectedBlocks = function() {
+
+ var selectedBlocksText = this.getSelectedBlockTypes().join(",\n ");
+ goog.dom.getElement('selectedBlocksText').textContent = selectedBlocksText;
+};
+
+/**
+ * Selects a given block type in the selector.
+ *
+ * @param {string} blockType - Type of block to selector.
+ */
+BlockExporterView.prototype.select = function(blockType) {
+ this.blockOptions[blockType].setSelected(true);
+};
+
+/**
+ * Deselects a block in the selector.
+ *
+ * @param {!Blockly.Block} block - Type of block to add to selector workspce.
+ */
+BlockExporterView.prototype.deselect = function(blockType) {
+ this.blockOptions[blockType].setSelected(false);
+};
+
+
+/**
+ * Deselects all blocks.
+ */
+BlockExporterView.prototype.deselectAllBlocks = function() {
+ for (var blockType in this.blockOptions) {
+ this.deselect(blockType);
+ }
+};
+
+/**
+ * Given an array of selected blocks, selects these blocks in the view, marking
+ * the checkboxes accordingly.
+ *
+ * @param {Array.<Blockly.Block>} blockTypes - Array of block types to select.
+ */
+BlockExporterView.prototype.setSelectedBlockTypes = function(blockTypes) {
+ for (var i = 0, blockType; blockType = blockTypes[i]; i++) {
+ this.select(blockType);
+ }
+};
+
+/**
+ * Returns array of selected blocks.
+ *
+ * @return {!Array.<!string>} Array of all selected block types.
+ */
+BlockExporterView.prototype.getSelectedBlockTypes = function() {
+ var selectedTypes = [];
+ for (var blockType in this.blockOptions) {
+ var blockOption = this.blockOptions[blockType];
+ if (blockOption.isSelected()) {
+ selectedTypes.push(blockType);
+ }
+ }
+ return selectedTypes;
+};
+
+/**
+ * Centers the preview block of each block option in the exporter selector.
+ */
+BlockExporterView.prototype.centerPreviewBlocks = function() {
+ for (var blockType in this.blockOptions) {
+ this.blockOptions[blockType].centerBlock();
+ }
+};
diff --git a/blockly/demos/blocklyfactory/block_library_controller.js b/blockly/demos/blocklyfactory/block_library_controller.js
new file mode 100644
index 0000000..1c0345e
--- /dev/null
+++ b/blockly/demos/blocklyfactory/block_library_controller.js
@@ -0,0 +1,337 @@
+/**
+ * @license
+ * Visual Blocks Editor
+ *
+ * Copyright 2016 Google Inc.
+ * https://developers.google.com/blockly/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @fileoverview Contains the code for Block Library Controller, which
+ * depends on Block Library Storage and Block Library UI. Provides the
+ * interfaces for the user to
+ * - save their blocks to the browser
+ * - re-open and edit saved blocks
+ * - delete blocks
+ * - clear their block library
+ * Depends on BlockFactory functions defined in factory.js.
+ *
+ * @author quachtina96 (Tina Quach)
+ */
+'use strict';
+
+goog.provide('BlockLibraryController');
+
+goog.require('BlockLibraryStorage');
+goog.require('BlockLibraryView');
+goog.require('BlockFactory');
+
+/**
+ * Block Library Controller Class
+ * @constructor
+ *
+ * @param {string} blockLibraryName - Desired name of Block Library, also used
+ * to create the key for where it's stored in local storage.
+ * @param {!BlockLibraryStorage} opt_blockLibraryStorage - optional storage
+ * object that allows user to import a block library.
+ */
+BlockLibraryController = function(blockLibraryName, opt_blockLibraryStorage) {
+ this.name = blockLibraryName;
+ // Create a new, empty Block Library Storage object, or load existing one.
+ this.storage = opt_blockLibraryStorage || new BlockLibraryStorage(this.name);
+ // The BlockLibraryView object handles the proper updating and formatting of
+ // the block library dropdown.
+ this.view = new BlockLibraryView();
+};
+
+/**
+ * Returns the block type of the block the user is building.
+ * @private
+ *
+ * @return {string} The current block's type.
+ */
+BlockLibraryController.prototype.getCurrentBlockType = function() {
+ var rootBlock = FactoryUtils.getRootBlock(BlockFactory.mainWorkspace);
+ var blockType = rootBlock.getFieldValue('NAME').trim().toLowerCase();
+ // Replace white space with underscores
+ return blockType.replace(/\W/g, '_').replace(/^(\d)/, '_\\1');
+};
+
+/**
+ * Removes current block from Block Library and updates the save and delete
+ * buttons so that user may save block to library and but not delete.
+ *
+ * @param {string} blockType - Type of block.
+ */
+BlockLibraryController.prototype.removeFromBlockLibrary = function() {
+ var blockType = this.getCurrentBlockType();
+ this.storage.removeBlock(blockType);
+ this.storage.saveToLocalStorage();
+ this.populateBlockLibrary();
+ this.view.updateButtons(blockType, false, false);
+};
+
+/**
+ * Updates the workspace to show the block user selected from library
+ *
+ * @param {string} blockType - Block to edit on block factory.
+ */
+BlockLibraryController.prototype.openBlock = function(blockType) {
+ if (blockType) {
+ var xml = this.storage.getBlockXml(blockType);
+ BlockFactory.mainWorkspace.clear();
+ Blockly.Xml.domToWorkspace(xml, BlockFactory.mainWorkspace);
+ BlockFactory.mainWorkspace.clearUndo();
+ } else {
+ BlockFactory.showStarterBlock();
+ this.view.setSelectedBlockType(null);
+ }
+};
+
+/**
+ * Returns type of block selected from library.
+ *
+ * @return {string} Type of block selected.
+ */
+BlockLibraryController.prototype.getSelectedBlockType = function() {
+ return this.view.getSelectedBlockType();
+};
+
+/**
+ * Confirms with user before clearing the block library in local storage and
+ * updating the dropdown and displaying the starter block (factory_base).
+ */
+BlockLibraryController.prototype.clearBlockLibrary = function() {
+ var check = confirm('Delete all blocks from library?');
+ if (check) {
+ // Clear Block Library Storage.
+ this.storage.clear();
+ this.storage.saveToLocalStorage();
+ // Update dropdown.
+ this.view.clearOptions();
+ // Show default block.
+ BlockFactory.showStarterBlock();
+ // User may not save the starter block, but will get explicit instructions
+ // upon clicking the red save button.
+ this.view.updateButtons(null);
+ }
+};
+
+/**
+ * Saves current block to local storage and updates dropdown.
+ */
+BlockLibraryController.prototype.saveToBlockLibrary = function() {
+ var blockType = this.getCurrentBlockType();
+ // If user has not changed the name of the starter block.
+ if (blockType == 'block_type') {
+ // Do not save block if it has the default type, 'block_type'.
+ alert('You cannot save a block under the name "block_type". Try changing ' +
+ 'the name before saving. Then, click on the "Block Library" button ' +
+ 'to view your saved blocks.');
+ return;
+ }
+
+ // Create block xml.
+ var xmlElement = goog.dom.createDom('xml');
+ var block = FactoryUtils.getRootBlock(BlockFactory.mainWorkspace);
+ xmlElement.appendChild(Blockly.Xml.blockToDomWithXY(block));
+
+ // Do not add option again if block type is already in library.
+ if (!this.has(blockType)) {
+ this.view.addOption(blockType, true, true);
+ }
+
+ // Save block.
+ this.storage.addBlock(blockType, xmlElement);
+ this.storage.saveToLocalStorage();
+
+ // Show saved block without other stray blocks sitting in Block Factory's
+ // main workspace.
+ this.openBlock(blockType);
+
+ // Add select handler to the new option.
+ this.addOptionSelectHandler(blockType);
+};
+
+/**
+ * Checks to see if the given blockType is already in Block Library
+ *
+ * @param {string} blockType - Type of block.
+ * @return {boolean} Boolean indicating whether or not block is in the library.
+ */
+BlockLibraryController.prototype.has = function(blockType) {
+ var blockLibrary = this.storage.blocks;
+ return (blockType in blockLibrary && blockLibrary[blockType] != null);
+};
+
+/**
+ * Populates the dropdown menu.
+ */
+BlockLibraryController.prototype.populateBlockLibrary = function() {
+ this.view.clearOptions();
+ // Add an unselected option for each saved block.
+ var blockLibrary = this.storage.blocks;
+ for (var blockType in blockLibrary) {
+ this.view.addOption(blockType, false);
+ }
+ this.addOptionSelectHandlers();
+};
+
+/**
+ * Return block library mapping block type to xml.
+ *
+ * @return {Object} Object mapping block type to xml text.
+ */
+BlockLibraryController.prototype.getBlockLibrary = function() {
+ return this.storage.getBlockXmlTextMap();
+};
+
+/**
+ * Return stored xml of a given block type.
+ *
+ * @param {!string} blockType - The type of block.
+ * @return {!Element} Xml element of a given block type or null.
+ */
+BlockLibraryController.prototype.getBlockXml = function(blockType) {
+ return this.storage.getBlockXml(blockType);
+};
+
+/**
+ * Set the block library storage object from which exporter exports.
+ *
+ * @param {!BlockLibraryStorage} blockLibStorage - Block Library Storage
+ * object.
+ */
+BlockLibraryController.prototype.setBlockLibraryStorage
+ = function(blockLibStorage) {
+ this.storage = blockLibStorage;
+};
+
+/**
+ * Get the block library storage object from which exporter exports.
+ *
+ * @return {!BlockLibraryStorage} blockLibStorage - Block Library Storage object
+ * that stores the blocks.
+ */
+BlockLibraryController.prototype.getBlockLibraryStorage = function() {
+ return this.blockLibStorage;
+};
+
+/**
+ * Get the block library storage object from which exporter exports.
+ *
+ * @return {boolean} True if the Block Library is empty, false otherwise.
+ */
+BlockLibraryController.prototype.hasEmptyBlockLibrary = function() {
+ return this.storage.isEmpty();
+};
+
+/**
+ * Get all block types stored in block library.
+ *
+ * @return {!Array<!string>} Array of block types.
+ */
+BlockLibraryController.prototype.getStoredBlockTypes = function() {
+ return this.storage.getBlockTypes();
+};
+
+/**
+ * Sets the currently selected block option to none.
+ */
+BlockLibraryController.prototype.setNoneSelected = function() {
+ this.view.setSelectedBlockType(null);
+};
+
+/**
+ * If there are unsaved changes to the block in open in Block Factory
+ * and the block is not the starter block, check if user wants to proceed,
+ * knowing that it will cause them to lose their changes.
+ *
+ * @return {boolean} Whether or not to proceed.
+ */
+BlockLibraryController.prototype.warnIfUnsavedChanges = function() {
+ if (!FactoryUtils.savedBlockChanges(this)) {
+ return confirm('You have unsaved changes. By proceeding without saving ' +
+ ' your block first, you will lose these changes.');
+ }
+ return true;
+};
+
+/**
+ * Add select handler for an option of a given block type. The handler will to
+ * update the view and the selected block accordingly.
+ *
+ * @param {!string} blockType - The type of block represented by the option is
+ * for.
+ */
+BlockLibraryController.prototype.addOptionSelectHandler = function(blockType) {
+ var self = this;
+
+ // Click handler for a block option. Sets the block option as the selected
+ // option and opens the block for edit in Block Factory.
+ var setSelectedAndOpen_ = function(blockOption) {
+ var blockType = blockOption.textContent;
+ self.view.setSelectedBlockType(blockType);
+ self.openBlock(blockType);
+ // The block is saved in the block library and all changes have been saved
+ // when the user opens a block from the block library dropdown.
+ // Thus, the buttons show up as a disabled update button and an enabled
+ // delete.
+ self.view.updateButtons(blockType, true, true);
+ self.view.hide();
+ };
+
+ // Returns a block option select handler.
+ var makeOptionSelectHandler_ = function(blockOption) {
+ return function() {
+ // If there are unsaved changes warn user, check if they'd like to
+ // proceed with unsaved changes, and act accordingly.
+ var proceedWithUnsavedChanges = self.warnIfUnsavedChanges();
+ if (!proceedWithUnsavedChanges) {
+ return;
+ }
+ setSelectedAndOpen_(blockOption);
+ };
+ };
+
+ // Assign a click handler to the block option.
+ var blockOption = this.view.optionMap[blockType];
+ // Use an additional closure to correctly assign the tab callback.
+ blockOption.addEventListener(
+ 'click', makeOptionSelectHandler_(blockOption));
+};
+
+/**
+ * Add select handlers to each option to update the view and the selected
+ * blocks accordingly.
+ */
+BlockLibraryController.prototype.addOptionSelectHandlers = function() {
+ // Assign a click handler to each block option.
+ for (var blockType in this.view.optionMap) {
+ this.addOptionSelectHandler(blockType);
+ }
+};
+
+/**
+ * Update the save and delete buttons based on the current block type of the
+ * block the user is currently editing.
+ *
+ * @param {boolean} Whether changes to the block have been saved.
+ */
+BlockLibraryController.prototype.updateButtons = function(savedChanges) {
+ var blockType = this.getCurrentBlockType();
+ var isInLibrary = this.has(blockType);
+ this.view.updateButtons(blockType, isInLibrary, savedChanges);
+};
diff --git a/blockly/demos/blocklyfactory/block_library_storage.js b/blockly/demos/blocklyfactory/block_library_storage.js
new file mode 100644
index 0000000..c436195
--- /dev/null
+++ b/blockly/demos/blocklyfactory/block_library_storage.js
@@ -0,0 +1,178 @@
+/**
+ * @license
+ * Visual Blocks Editor
+ *
+ * Copyright 2016 Google Inc.
+ * https://developers.google.com/blockly/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @fileoverview Javascript for Block Library's Storage Class.
+ * Depends on Block Library for its namespace.
+ *
+ * @author quachtina96 (Tina Quach)
+ */
+
+'use strict';
+
+goog.provide('BlockLibraryStorage');
+
+/**
+ * Represents a block library's storage.
+ * @constructor
+ *
+ * @param {string} blockLibraryName - Desired name of Block Library, also used
+ * to create the key for where it's stored in local storage.
+ * @param {Object} opt_blocks - Object mapping block type to xml.
+ */
+BlockLibraryStorage = function(blockLibraryName, opt_blocks) {
+ // Add prefix to this.name to avoid collisions in local storage.
+ this.name = 'BlockLibraryStorage.' + blockLibraryName;
+ if (!opt_blocks) {
+ // Initialize this.blocks by loading from local storage.
+ this.loadFromLocalStorage();
+ if (this.blocks == null) {
+ this.blocks = Object.create(null);
+ // The line above is equivalent of {} except that this object is TRULY
+ // empty. It doesn't have built-in attributes/functions such as length or
+ // toString.
+ this.saveToLocalStorage();
+ }
+ } else {
+ this.blocks = opt_blocks;
+ this.saveToLocalStorage();
+ }
+};
+
+/**
+ * Reads the named block library from local storage and saves it in this.blocks.
+ */
+BlockLibraryStorage.prototype.loadFromLocalStorage = function() {
+ // goog.global is synonymous to window, and allows for flexibility
+ // between browsers.
+ var object = goog.global.localStorage[this.name];
+ this.blocks = object ? JSON.parse(object) : null;
+};
+
+/**
+ * Writes the current block library (this.blocks) to local storage.
+ */
+BlockLibraryStorage.prototype.saveToLocalStorage = function() {
+ goog.global.localStorage[this.name] = JSON.stringify(this.blocks);
+};
+
+/**
+ * Clears the current block library.
+ */
+BlockLibraryStorage.prototype.clear = function() {
+ this.blocks = Object.create(null);
+ // The line above is equivalent of {} except that this object is TRULY
+ // empty. It doesn't have built-in attributes/functions such as length or
+ // toString.
+};
+
+/**
+ * Saves block to block library.
+ *
+ * @param {string} blockType - Type of block.
+ * @param {Element} blockXML - The block's XML pulled from workspace.
+ */
+BlockLibraryStorage.prototype.addBlock = function(blockType, blockXML) {
+ var prettyXml = Blockly.Xml.domToPrettyText(blockXML);
+ this.blocks[blockType] = prettyXml;
+};
+
+/**
+ * Removes block from current block library (this.blocks).
+ *
+ * @param {string} blockType - Type of block.
+ */
+BlockLibraryStorage.prototype.removeBlock = function(blockType) {
+ delete this.blocks[blockType];
+};
+
+/**
+ * Returns the xml of given block type stored in current block library
+ * (this.blocks).
+ *
+ * @param {string} blockType - Type of block.
+ * @return {Element} The xml that represents the block type or null.
+ */
+BlockLibraryStorage.prototype.getBlockXml = function(blockType) {
+ var xml = this.blocks[blockType] || null;
+ if (xml) {
+ var xml = Blockly.Xml.textToDom(xml);
+ }
+ return xml;
+};
+
+
+/**
+ * Returns map of each block type to its corresponding xml stored in current
+ * block library (this.blocks).
+ *
+ * @param {Array.<!string>} blockTypes - Types of blocks.
+ * @return {!Object} Map of block type to corresponding xml.
+ */
+BlockLibraryStorage.prototype.getBlockXmlMap = function(blockTypes) {
+ var blockXmlMap = {};
+ for (var i = 0; i < blockTypes.length; i++) {
+ var blockType = blockTypes[i];
+ var xml = this.getBlockXml(blockType);
+ blockXmlMap[blockType] = xml;
+ }
+ return blockXmlMap;
+};
+
+/**
+ * Returns array of all block types stored in current block library.
+ *
+ * @return {!Array.<string>} Array of block types stored in library.
+ */
+BlockLibraryStorage.prototype.getBlockTypes = function() {
+ return Object.keys(this.blocks);
+};
+
+/**
+ * Checks to see if block library is empty.
+ *
+ * @return {boolean} True if empty, false otherwise.
+ */
+BlockLibraryStorage.prototype.isEmpty = function() {
+ for (var blockType in this.blocks) {
+ return false;
+ }
+ return true;
+};
+
+/**
+ * Returns array of all block types stored in current block library.
+ *
+ * @return {!Array.<string>} Map of block type to corresponding xml text.
+ */
+BlockLibraryStorage.prototype.getBlockXmlTextMap = function() {
+ return this.blocks;
+};
+
+/**
+ * Returns boolean of whether or not a given blockType is stored in block
+ * library.
+ *
+ * @param {string} blockType - Type of block.
+ * @return {boolean} Whether or not blockType is stored in block library.
+ */
+BlockLibraryStorage.prototype.has = function(blockType) {
+ return this.blocks[blockType] ? true : false;
+};
diff --git a/blockly/demos/blocklyfactory/block_library_view.js b/blockly/demos/blocklyfactory/block_library_view.js
new file mode 100644
index 0000000..00c676d
--- /dev/null
+++ b/blockly/demos/blocklyfactory/block_library_view.js
@@ -0,0 +1,226 @@
+/**
+ * @license
+ * Visual Blocks Editor
+ *
+ * Copyright 2016 Google Inc.
+ * https://developers.google.com/blockly/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @fileoverview Javascript for BlockLibraryView class. It manages the display
+ * of the Block Library dropdown, save, and delete buttons.
+ *
+ * @author quachtina96 (Tina Quach)
+ */
+
+'use strict';
+
+goog.provide('BlockLibraryView');
+
+goog.require('goog.dom');
+goog.require('goog.dom.classlist');
+
+/**
+ * BlockLibraryView Class
+ * @constructor
+ */
+var BlockLibraryView = function() {
+ // Div element to contain the block types to choose from.
+ // Id of the div that holds the block library view.
+ this.blockLibraryViewDivID = 'dropdownDiv_blockLib';
+ this.dropdown = goog.dom.getElement('dropdownDiv_blockLib');
+ // Map of block type to corresponding 'a' element that is the option in the
+ // dropdown. Used to quickly and easily get a specific option.
+ this.optionMap = Object.create(null);
+ // Save and delete buttons.
+ this.saveButton = goog.dom.getElement('saveToBlockLibraryButton');
+ this.deleteButton = goog.dom.getElement('removeBlockFromLibraryButton');
+ // Initially, user should not be able to delete a block. They must save a
+ // block or select a stored block first.
+ this.deleteButton.disabled = true;
+};
+
+/**
+ * Open the Block Library dropdown.
+ */
+BlockLibraryView.prototype.show = function() {
+ this.dropdown.classList.add("show");
+};
+
+/**
+ * Close the Block Library dropdown.
+ */
+BlockLibraryView.prototype.hide = function() {
+ this.dropdown.classList.remove("show");
+};
+
+/**
+ * Creates a node of a given element type and appends to the node with given id.
+ *
+ * @param {!string} blockType - Type of block.
+ * @param {boolean} selected - Whether or not the option should be selected on
+ * the dropdown.
+ */
+BlockLibraryView.prototype.addOption = function(blockType, selected) {
+ // Create option.
+ var option = goog.dom.createDom('a', {
+ 'id': 'dropdown_' + blockType,
+ 'class': 'blockLibOpt'
+ }, blockType);
+
+ // Add option to dropdown.
+ this.dropdown.appendChild(option);
+ this.optionMap[blockType] = option;
+
+ // Select the block.
+ if (selected) {
+ this.setSelectedBlockType(blockType);
+ }
+};
+
+/**
+ * Sets a given block type to selected and all other blocks to deselected.
+ * If null, deselects all blocks.
+ *
+ * @param {string} blockTypeToSelect - Type of block to select or null.
+ */
+BlockLibraryView.prototype.setSelectedBlockType = function(blockTypeToSelect) {
+ // Select given block type and deselect all others. Will deselect all blocks
+ // if null or invalid block type selected.
+ for (var blockType in this.optionMap) {
+ var option = this.optionMap[blockType];
+ if (blockType == blockTypeToSelect) {
+ this.selectOption_(option);
+ } else {
+ this.deselectOption_(option);
+ }
+ }
+};
+
+/**
+ * Selects a given option.
+ * @private
+ *
+ * @param {!Element} option - HTML 'a' element in the dropdown that represents
+ * a particular block type.
+ */
+BlockLibraryView.prototype.selectOption_ = function(option) {
+ goog.dom.classlist.add(option, 'dropdown-content-selected');
+};
+
+/**
+ * Deselects a given option.
+ * @private
+ *
+ * @param {!Element} option - HTML 'a' element in the dropdown that represents
+ * a particular block type.
+ */
+BlockLibraryView.prototype.deselectOption_ = function(option) {
+ goog.dom.classlist.remove(option, 'dropdown-content-selected');
+};
+
+/**
+ * Updates the save and delete buttons to represent how the current block will
+ * be saved by including the block type in the button text as well as indicating
+ * whether the block is being saved or updated.
+ *
+ * @param {!string} blockType - The type of block being edited.
+ * @param {boolean} isInLibrary - Whether the block type is in the library.
+ * @param {boolean} savedChanges - Whether changes to block have been saved.
+ */
+BlockLibraryView.prototype.updateButtons =
+ function(blockType, isInLibrary, savedChanges) {
+ if (blockType) {
+ // User is editing a block.
+
+ if (!isInLibrary) {
+ // Block type has not been saved to library yet. Disable the delete button
+ // and allow user to save.
+ this.saveButton.textContent = 'Save "' + blockType + '"';
+ this.saveButton.disabled = false;
+ this.deleteButton.disabled = true;
+ } else {
+ // Block type has already been saved. Disable the save button unless the
+ // there are unsaved changes (checked below).
+ this.saveButton.textContent = 'Update "' + blockType + '"';
+ this.saveButton.disabled = true;
+ this.deleteButton.disabled = false;
+ }
+ this.deleteButton.textContent = 'Delete "' + blockType + '"';
+
+ // If changes to block have been made and are not saved, make button
+ // green to encourage user to save the block.
+ if (!savedChanges) {
+ var buttonFormatClass = 'button_warn';
+
+ // If block type is the default, 'block_type', make button red to alert
+ // user.
+ if (blockType == 'block_type') {
+ buttonFormatClass = 'button_alert';
+ }
+ goog.dom.classlist.add(this.saveButton, buttonFormatClass);
+ this.saveButton.disabled = false;
+
+ } else {
+ // No changes to save.
+ var classesToRemove = ['button_alert', 'button_warn'];
+ goog.dom.classlist.removeAll(this.saveButton, classesToRemove);
+ this.saveButton.disabled = true;
+ }
+
+ }
+};
+
+/**
+ * Removes option currently selected in dropdown from dropdown menu.
+ */
+BlockLibraryView.prototype.removeSelectedOption = function() {
+ var selectedOption = this.getSelectedOption();
+ this.dropdown.removeNode(selectedOption);
+};
+
+/**
+ * Returns block type of selected block.
+ *
+ * @return {string} Type of block selected.
+ */
+BlockLibraryView.prototype.getSelectedBlockType = function() {
+ var selectedOption = this.getSelectedOption();
+ var blockType = selectedOption.textContent;
+ return blockType;
+};
+
+/**
+ * Returns selected option.
+ *
+ * @return {!Element} HTML 'a' element that is the option for a block type.
+ */
+BlockLibraryView.prototype.getSelectedOption = function() {
+ return goog.dom.getElementByClass('dropdown-content-selected', this.dropdown);
+};
+
+/**
+ * Removes all options from dropdown.
+ */
+BlockLibraryView.prototype.clearOptions = function() {
+ var blockOpts = goog.dom.getElementsByClass('blockLibOpt', this.dropdown);
+ if (blockOpts) {
+ for (var i = 0, option; option = blockOpts[i]; i++) {
+ goog.dom.removeNode(option);
+ }
+ }
+};
+
+
diff --git a/blockly/demos/blocklyfactory/block_option.js b/blockly/demos/blocklyfactory/block_option.js
new file mode 100644
index 0000000..265de70
--- /dev/null
+++ b/blockly/demos/blocklyfactory/block_option.js
@@ -0,0 +1,181 @@
+/**
+ * @license
+ * Visual Blocks Editor
+ *
+ * Copyright 2016 Google Inc.
+ * https://developers.google.com/blockly/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @fileoverview Javascript for the BlockOption class, used to represent each of
+ * the various blocks that you may select. Each block option has a checkbox,
+ * a label, and a preview workspace through which to view the block.
+ *
+ * @author quachtina96 (Tina Quach)
+ */
+'use strict';
+
+goog.provide('BlockOption');
+goog.require('goog.dom');
+
+ /**
+ * BlockOption Class
+ * A block option includes checkbox, label, and div element that shows a preview
+ * of the block.
+ * @constructor
+ *
+ * @param {!Element} blockSelector - Scrollable div that will contain the
+ * block options for the selector.
+ * @param {!string} blockType - Type of block for which to create an option.
+ * @param {!Element} previewBlockXml - Xml element containing the preview block.
+ */
+var BlockOption = function(blockSelector, blockType, previewBlockXml) {
+ // The div to contain the block option.
+ this.blockSelector = blockSelector;
+ // The type of block represented by the option.
+ this.blockType = blockType;
+ // The checkbox for the option. Set in createDom.
+ this.checkbox = null;
+ // The dom for the option. Set in createDom.
+ this.dom = null;
+ // Xml element containing the preview block.
+ this.previewBlockXml = previewBlockXml;
+ // Workspace containing preview of block. Set upon injection of workspace in
+ // showPreviewBlock.
+ this.previewWorkspace = null;
+ // Whether or not block the option is selected.
+ this.selected = false;
+ // Using this.selected rather than this.checkbox.checked allows for proper
+ // handling of click events on the block option; Without this, clicking
+ // directly on the checkbox does not toggle selection.
+};
+
+/**
+ * Creates the dom for a single block option. Includes checkbox, label, and div
+ * in which to inject the preview block.
+ *
+ * @return {!Element} Root node of the selector dom which consists of a
+ * checkbox, a label, and a fixed size preview workspace per block.
+ */
+BlockOption.prototype.createDom = function() {
+ // Create the div for the block option.
+ var blockOptContainer = goog.dom.createDom('div', {
+ 'id': this.blockType,
+ 'class': 'blockOption'
+ }, ''); // Empty quotes for empty div.
+
+ // Create and append div in which to inject the workspace for viewing the
+ // block option.
+ var blockOptionPreview = goog.dom.createDom('div', {
+ 'id' : this.blockType + '_workspace',
+ 'class': 'blockOption_preview'
+ }, '');
+ goog.dom.appendChild(blockOptContainer,blockOptionPreview);
+
+ // Create and append container to hold checkbox and label.
+ var checkLabelContainer = goog.dom.createDom('div', {
+ 'class': 'blockOption_checkLabel'
+ }, '');
+ goog.dom.appendChild(blockOptContainer,checkLabelContainer);
+
+ // Create and append container for checkbox.
+ var checkContainer = goog.dom.createDom('div', {
+ 'class': 'blockOption_check'
+ }, '');
+ goog.dom.appendChild(checkLabelContainer, checkContainer);
+
+ // Create and append checkbox.
+ this.checkbox = goog.dom.createDom('input', {
+ 'type': 'checkbox',
+ 'id': this.blockType + '_check'
+ }, '');
+ goog.dom.appendChild(checkContainer, this.checkbox);
+
+ // Create and append container for block label.
+ var labelContainer = goog.dom.createDom('div', {
+ 'class': 'blockOption_label'
+ }, '');
+ goog.dom.appendChild(checkLabelContainer, labelContainer);
+
+ // Create and append text node for the label.
+ var labelText = goog.dom.createDom('p', {
+ 'id': this.blockType + '_text'
+ }, this.blockType);
+ goog.dom.appendChild(labelContainer, labelText);
+
+ this.dom = blockOptContainer;
+ return this.dom;
+};
+
+/**
+ * Injects a workspace containing the block into the block option's preview div.
+ */
+BlockOption.prototype.showPreviewBlock = function() {
+ // Get ID of preview workspace.
+ var blockOptPreviewID = this.dom.id + '_workspace';
+
+ // Inject preview block.
+ var workspace = Blockly.inject(blockOptPreviewID, {readOnly:true});
+ Blockly.Xml.domToWorkspace(this.previewBlockXml, workspace);
+ this.previewWorkspace = workspace;
+
+ // Center the preview block in the workspace.
+ this.centerBlock();
+};
+
+/**
+ * Centers the preview block in the workspace.
+ */
+BlockOption.prototype.centerBlock = function() {
+ // Get metrics.
+ var block = this.previewWorkspace.getTopBlocks()[0];
+ var blockMetrics = block.getHeightWidth();
+ var blockCoordinates = block.getRelativeToSurfaceXY();
+ var workspaceMetrics = this.previewWorkspace.getMetrics();
+
+ // Calculate new coordinates.
+ var x = workspaceMetrics.viewWidth/2 - blockMetrics['width']/2 -
+ blockCoordinates.x;
+ var y = workspaceMetrics.viewHeight/2 - blockMetrics['height']/2 -
+ blockCoordinates.y;
+
+ // Move block.
+ block.moveBy(x, y);
+};
+
+/**
+ * Selects or deselects the block option.
+ *
+ * @param {!boolean} selected - True if selecting option, false if deselecting
+ * option.
+ */
+BlockOption.prototype.setSelected = function(selected) {
+ this.selected = selected;
+ if (this.checkbox) {
+ this.checkbox.checked = selected;
+ }
+};
+
+/**
+ * Returns boolean telling whether or not block is selected.
+ *
+ * @return {!boolean} True if selecting option, false if deselecting
+ * option.
+ */
+BlockOption.prototype.isSelected = function() {
+ return this.selected;
+};
+
+
diff --git a/blockly/demos/blocklyfactory/factory.css b/blockly/demos/blocklyfactory/factory.css
new file mode 100644
index 0000000..f212b1d
--- /dev/null
+++ b/blockly/demos/blocklyfactory/factory.css
@@ -0,0 +1,597 @@
+/**
+ * @license
+ * Visual Blocks Editor
+ *
+ * Copyright 2016 Google Inc.
+ * https://developers.google.com/blockly/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+html, body {
+ height: 100%;
+ min-height: 375px;
+}
+
+body {
+ background-color: #fff;
+ font-family: sans-serif;
+ margin: 0 5px;
+ overflow: hidden;
+}
+
+h1 {
+ font-weight: normal;
+ font-size: 140%;
+}
+
+h3 {
+ margin-top: 5px;
+ margin-bottom: 0;
+}
+
+table {
+ border: none;
+ border-collapse: collapse;
+ height: 100%;
+ margin: 0;
+ padding: 0;
+ width: 100%;
+}
+
+td {
+ vertical-align: top;
+ padding: 0;
+}
+
+p {
+ display: block;
+ -webkit-margin-before: 0em;
+ -webkit-margin-after: 0em;
+ -webkit-margin-start: 0px;
+ -webkit-margin-end: 0px;
+ padding: 5px 0px;
+}
+
+#factoryHeader {
+ display: table;
+ height: 10%;
+}
+
+#blockly {
+ position: absolute;
+}
+
+#blocklyMask {
+ background-color: #000;
+ cursor: not-allowed;
+ display: none;
+ position: fixed;
+ opacity: 0.2;
+ z-index: 9;
+}
+
+#preview {
+ position: absolute;
+}
+
+pre,
+#languageTA {
+ border: #ddd 1px solid;
+ margin-top: 0;
+ position: absolute;
+ overflow: scroll;
+}
+
+#languageTA {
+ display: none;
+ font: 10pt monospace;
+}
+
+.downloadButton {
+ padding: 5px;
+}
+
+button:disabled, .buttonStyle:disabled {
+ opacity: 0.6;
+}
+
+button>*, .buttonStyle>* {
+ opacity: 1;
+ vertical-align: text-bottom;
+}
+
+button, .buttonStyle {
+ border-radius: 4px;
+ border: 1px solid #ddd;
+ background-color: #eee;
+ color: #000;
+ padding: 10px;
+ margin: 10px 5px;
+ font-size: small;
+}
+
+.buttonStyle:hover:not(:disabled), button:hover:not(:disabled) {
+ box-shadow: 2px 2px 5px #888;
+}
+
+.buttonStyle:hover:not(:disabled)>*, button:hover:not(:disabled)>* {
+ opacity: 1;
+}
+
+#linkButton {
+ display: none;
+}
+
+#helpButton {
+ float: right;
+}
+
+#blockFactoryContent {
+ height: 85%;
+ width: 100%;
+ overflow: hidden;
+}
+
+#blockFactoryPreview {
+ height: 100%;
+ width: 100%;
+}
+
+#blockLibraryContainer {
+ vertical-align: bottom;
+}
+
+#blockLibraryControls {
+ text-align: right;
+ vertical-align: middle;
+}
+
+#previewContainer {
+ vertical-align: bottom;
+}
+
+#buttonContainer {
+ text-align: right;
+ vertical-align: middle;
+}
+
+#files {
+ position: absolute;
+ visibility: hidden;
+}
+
+.toolbox {
+ display: none;
+}
+
+#blocklyWorkspaceContainer {
+ width: 50%;
+}
+
+#workspaceFactoryContent {
+ clear: both;
+ display: none;
+ height: 90%;
+ overflow-x: hidden;
+ overflow-y: scroll;
+}
+
+/* Exporter */
+
+#blockLibraryExporter {
+ clear: both;
+ display: none;
+ height: 90%;
+ overflow-x: hidden;
+ overflow-y: scroll;
+}
+
+#exportSelector {
+ display: inline-block;
+ float: left;
+ height: 70%;
+ width: 30%;
+}
+
+#exportSettings {
+ float: left;
+ overflow: hidden;
+ padding-left: 16px;
+ width: 20%;
+}
+
+#selectedBlocksTextContainer {
+ max-height: 200px;
+ overflow-y: scroll;
+ padding-bottom: 2em;
+}
+
+::-webkit-scrollbar {
+ -webkit-appearance: none;
+ width: 7px;
+}
+
+::-webkit-scrollbar-thumb {
+ border-radius: 4px;
+ background-color: #ccc;
+ -webkit-box-shadow: 0 0 1px rgba(255,255,255,.5);
+}
+
+.subsettings {
+ margin: 0px 25px;
+}
+
+#exporterHiddenWorkspace {
+ display: none;
+}
+
+#exportPreview {
+ float: right;
+ height: 90%;
+ overflow: hidden;
+ width: 45%;
+}
+
+.exportPreviewTextArea {
+ display: block;
+ float: right;
+ height: 40%;
+ width: 100%;
+}
+
+#genStubs_textArea, #blockDefs_textArea {
+ display: block;
+ height: 80%;
+ margin-right: 20px;
+ max-height: 300px;
+ overflow: scroll;
+ position: static;
+}
+
+#blockDefs_label, #genStubs_label {
+ display: block;
+}
+
+#blockSelector {
+ background-color: #eee;
+ border: 1px solid lightgrey;
+ width: 80%;
+ height: 90%;
+ overflow-y: scroll;
+ position: relative;
+}
+
+/* Exporter Block Option */
+
+.blockOption {
+ background-color: #eee;
+ padding: 15px 20px;
+ width: 95%;
+}
+
+.blockOption_check_label {
+ position: relative;
+}
+
+.blockOption_check {
+ float: left;
+ padding: 4px;
+}
+
+.blockOption_label {
+ float: left;
+ max-width: inherit;
+ overflow-y: scroll;
+ word-wrap: break-word;
+}
+
+.blockOption_preview {
+ height: 100px;
+ padding-top: 10px;
+ width: 90%;
+}
+
+/* Block Library */
+
+#dropdownDiv_blockLib {
+ max-height: 65%;
+ overflow-y: scroll;
+}
+
+#button_blockLib {
+ border-color: darkgrey;
+ font-size: large;
+}
+
+.button_alert {
+ background-color: #fcc;
+ border-color: #f99;
+}
+
+.button_warn {
+ background-color: #aea;
+ border-color: #5d5;
+}
+
+/* Tabs */
+
+.tab {
+ float: left;
+ padding: 5px 19px;
+}
+
+.tab:hover:not(.tabon){
+ background-color: #e8e8e8;
+}
+
+.tab.tabon {
+ background-color: #ccc;
+}
+
+.tab.taboff {
+ cursor: pointer;
+}
+
+#tabContainer {
+ background-color: #f8f8f8;
+ border-top: 1px solid #ddd;
+ border-bottom: 1px solid #ddd;
+ display: table;
+ width: 100%;
+}
+
+/* Workspace Factory */
+
+section {
+ float: left;
+}
+
+aside {
+ float: right;
+}
+
+#categoryTable>table {
+ border: 1px solid #ccc;
+ border-bottom: none;
+ width: auto;
+}
+
+td.tabon {
+ background-color: #ccc;
+ border-bottom-color: #ccc;
+ padding: 5px 19px;
+}
+
+td.taboff {
+ cursor: pointer;
+ padding: 5px 19px;
+}
+
+td.taboff:hover {
+ background-color: #eee;
+}
+
+.large {
+ font-size: large;
+}
+
+td {
+ padding: 0;
+ vertical-align: top;
+}
+
+.inputfile {
+ height: 0;
+ opacity: 0;
+ overflow: hidden;
+ position: absolute;
+ width: 0;
+ z-index: -1;
+}
+#wfactoryHeader {
+ height: 29%;
+ padding: 0.5%;
+}
+
+#workspaceTabs {
+ background-color: #f8f8f8;
+ border: 1px solid #ccc;
+ display: table;
+ width: auto;
+}
+
+#toolbox_section {
+ height: 85%;
+ width: 60%;
+}
+
+#previewHelp {
+ padding: 10px;
+ width: 98%;
+}
+
+#toolbox_blocks {
+ height: 100%;
+ width: 100%;
+}
+
+#preview_blocks {
+ height: 80%;
+ padding: 10px;
+ width: 100%;
+}
+
+#createDiv {
+ height: 79%;
+ padding: 0.5%;
+ width: 60%;
+}
+
+#previewDiv {
+ border: 10px solid #eee;
+ height: 77%;
+ margin-right: 0.5%;
+ padding-bottom: 10px;
+ width: 35%;
+}
+
+#previewBorder {
+ border: 5px solid #ddd;
+ height: 100%;
+ padding-right: 20px;
+}
+
+.disabled {
+ background-color: white;
+ opacity: 0.5;
+}
+
+#toolbox_div {
+ display: table;
+ height: auto;
+ margin-right: 5%;
+ overflow: hidden;
+ width: 35%;
+}
+
+#preload_div {
+ display: table;
+ height: 70%;
+ margin-right: 5%;
+ max-height: 500px;
+ overflow: hidden;
+ overflow-y: scroll;
+ width: 35%;
+}
+
+#shadowBlockDropdown {
+ height: 15%;
+}
+
+#preloadHelp {
+ display: table-row;
+ height: 30%;
+}
+
+#workspace_options {
+ display: table-row;
+ margin-top: 2%;
+}
+
+#disable_div {
+ background-color: white;
+ height: 100%;
+ left: 0;
+ opacity: .5;
+ position: absolute;
+ top: 0;
+ width: 100%;
+ z-index: -1; /* Start behind workspace */
+}
+
+#grid_options, #zoom_options, #maxBlockNumber_option {
+ padding-left: 15px;
+}
+
+/* Rules for Closure popup color picker */
+.goog-palette {
+ outline: none;
+ cursor: default;
+}
+
+.goog-palette-cell {
+ height: 13px;
+ width: 15px;
+ margin: 0;
+ border: 0;
+ text-align: center;
+ vertical-align: middle;
+ border-right: 1px solid #000000;
+ font-size: 1px;
+}
+
+.goog-palette-colorswatch {
+ border: 1px solid #000000;
+ height: 13px;
+ position: relative;
+ width: 15px;
+}
+
+.goog-palette-cell-hover .goog-palette-colorswatch {
+ border: 1px solid #FFF;
+}
+
+.goog-palette-cell-selected .goog-palette-colorswatch {
+ border: 1px solid #000;
+ color: #fff;
+}
+
+.goog-palette-table {
+ border: 1px solid #000;
+ border-collapse: collapse;
+}
+
+.goog-popupcolorpicker {
+ position: absolute;
+}
+
+/* The container <div> - needed to position the dropdown content */
+.dropdown {
+ display: inline-block;
+}
+
+/* Dropdown Content (Hidden by Default) */
+.dropdown-content {
+ background-color: #FFF;
+ box-shadow: 0px 8px 16px 0px rgba(0,0,0,.2);
+ display: none;
+ min-width: 170px;
+ opacity: 1;
+ position: absolute;
+ z-index: 1;
+}
+
+/* Links inside the dropdown */
+.dropdown-content a, .dropdown-content label {
+ color: black;
+ display: block;
+ font-size: small;
+ padding: 12px 16px;
+ text-decoration: none;
+}
+
+/* Change color of dropdown links on hover. */
+.dropdown-content a:hover, .dropdown-content label:hover {
+ background-color: #EEE;
+}
+
+/* Change color of dropdown links on selected. */
+.dropdown-content-selected {
+ background-color: #DDD;
+}
+
+/* Show the dropdown menu */
+.show {
+ display: block;
+}
+
+.shadowBlock>.blocklyPath {
+ fill-opacity: .5;
+ stroke-opacity: .5;
+}
+
+.shadowBlock>.blocklyPathLight,
+.shadowBlock>.blocklyPathDark {
+ display: none;
+}
diff --git a/blockly/demos/blocklyfactory/factory.js b/blockly/demos/blocklyfactory/factory.js
new file mode 100644
index 0000000..837d04b
--- /dev/null
+++ b/blockly/demos/blocklyfactory/factory.js
@@ -0,0 +1,265 @@
+/**
+ * @license
+ * Visual Blocks Editor
+ *
+ * Copyright 2016 Google Inc.
+ * https://developers.google.com/blockly/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @fileoverview JavaScript for Blockly's Block Factory application through
+ * which users can build blocks using a visual interface and dynamically
+ * generate a preview block and starter code for the block (block definition and
+ * generator stub. Uses the Block Factory namespace. Depends on the FactoryUtils
+ * for its code generation functions.
+ *
+ * @author fraser@google.com (Neil Fraser), quachtina96 (Tina Quach)
+ */
+'use strict';
+
+/**
+ * Namespace for Block Factory.
+ */
+goog.provide('BlockFactory');
+
+goog.require('FactoryUtils');
+goog.require('StandardCategories');
+
+
+/**
+ * Workspace for user to build block.
+ * @type {Blockly.Workspace}
+ */
+BlockFactory.mainWorkspace = null;
+
+/**
+ * Workspace for preview of block.
+ * @type {Blockly.Workspace}
+ */
+BlockFactory.previewWorkspace = null;
+
+/**
+ * Name of block if not named.
+ */
+BlockFactory.UNNAMED = 'unnamed';
+
+/**
+ * Existing direction ('ltr' vs 'rtl') of preview.
+ */
+BlockFactory.oldDir = null;
+
+/*
+ * The starting xml for the Block Factory main workspace. Contains the
+ * unmovable, undeletable factory_base block.
+ */
+BlockFactory.STARTER_BLOCK_XML_TEXT = '<xml><block type="factory_base" ' +
+ 'deletable="false" movable="false"></block></xml>';
+
+/**
+ * Change the language code format.
+ */
+BlockFactory.formatChange = function() {
+ var mask = document.getElementById('blocklyMask');
+ var languagePre = document.getElementById('languagePre');
+ var languageTA = document.getElementById('languageTA');
+ if (document.getElementById('format').value == 'Manual') {
+ Blockly.hideChaff();
+ mask.style.display = 'block';
+ languagePre.style.display = 'none';
+ languageTA.style.display = 'block';
+ var code = languagePre.textContent.trim();
+ languageTA.value = code;
+ languageTA.focus();
+ BlockFactory.updatePreview();
+ } else {
+ mask.style.display = 'none';
+ languageTA.style.display = 'none';
+ languagePre.style.display = 'block';
+ BlockFactory.updateLanguage();
+ }
+ BlockFactory.disableEnableLink();
+};
+
+/**
+ * Update the language code based on constructs made in Blockly.
+ */
+BlockFactory.updateLanguage = function() {
+ var rootBlock = FactoryUtils.getRootBlock(BlockFactory.mainWorkspace);
+ if (!rootBlock) {
+ return;
+ }
+ var blockType = rootBlock.getFieldValue('NAME').trim().toLowerCase();
+ if (!blockType) {
+ blockType = BlockFactory.UNNAMED;
+ }
+ var format = document.getElementById('format').value;
+ var code = FactoryUtils.getBlockDefinition(blockType, rootBlock, format,
+ BlockFactory.mainWorkspace);
+ FactoryUtils.injectCode(code, 'languagePre');
+ BlockFactory.updatePreview();
+};
+
+/**
+ * Update the generator code.
+ * @param {!Blockly.Block} block Rendered block in preview workspace.
+ */
+BlockFactory.updateGenerator = function(block) {
+ var language = document.getElementById('language').value;
+ var generatorStub = FactoryUtils.getGeneratorStub(block, language);
+ FactoryUtils.injectCode(generatorStub, 'generatorPre');
+};
+
+/**
+ * Update the preview display.
+ */
+BlockFactory.updatePreview = function() {
+ // Toggle between LTR/RTL if needed (also used in first display).
+ var newDir = document.getElementById('direction').value;
+ if (BlockFactory.oldDir != newDir) {
+ if (BlockFactory.previewWorkspace) {
+ BlockFactory.previewWorkspace.dispose();
+ }
+ var rtl = newDir == 'rtl';
+ BlockFactory.previewWorkspace = Blockly.inject('preview',
+ {rtl: rtl,
+ media: '../../media/',
+ scrollbars: true});
+ BlockFactory.oldDir = newDir;
+ }
+ BlockFactory.previewWorkspace.clear();
+
+ // Fetch the code and determine its format (JSON or JavaScript).
+ var format = document.getElementById('format').value;
+ if (format == 'Manual') {
+ var code = document.getElementById('languageTA').value;
+ // If the code is JSON, it will parse, otherwise treat as JS.
+ try {
+ JSON.parse(code);
+ format = 'JSON';
+ } catch (e) {
+ format = 'JavaScript';
+ }
+ } else {
+ var code = document.getElementById('languagePre').textContent;
+ }
+ if (!code.trim()) {
+ // Nothing to render. Happens while cloud storage is loading.
+ return;
+ }
+
+ // Backup Blockly.Blocks object so that main workspace and preview don't
+ // collide if user creates a 'factory_base' block, for instance.
+ var backupBlocks = Blockly.Blocks;
+ try {
+ // Make a shallow copy.
+ Blockly.Blocks = Object.create(null);
+ for (var prop in backupBlocks) {
+ Blockly.Blocks[prop] = backupBlocks[prop];
+ }
+
+ if (format == 'JSON') {
+ var json = JSON.parse(code);
+ Blockly.Blocks[json.type || BlockFactory.UNNAMED] = {
+ init: function() {
+ this.jsonInit(json);
+ }
+ };
+ } else if (format == 'JavaScript') {
+ eval(code);
+ } else {
+ throw 'Unknown format: ' + format;
+ }
+
+ // Look for a block on Blockly.Blocks that does not match the backup.
+ var blockType = null;
+ for (var type in Blockly.Blocks) {
+ if (typeof Blockly.Blocks[type].init == 'function' &&
+ Blockly.Blocks[type] != backupBlocks[type]) {
+ blockType = type;
+ break;
+ }
+ }
+ if (!blockType) {
+ return;
+ }
+
+ // Create the preview block.
+ var previewBlock = BlockFactory.previewWorkspace.newBlock(blockType);
+ previewBlock.initSvg();
+ previewBlock.render();
+ previewBlock.setMovable(false);
+ previewBlock.setDeletable(false);
+ previewBlock.moveBy(15, 10);
+ BlockFactory.previewWorkspace.clearUndo();
+ BlockFactory.updateGenerator(previewBlock);
+
+ // Warn user only if their block type is already exists in Blockly's
+ // standard library.
+ var rootBlock = FactoryUtils.getRootBlock(BlockFactory.mainWorkspace);
+ if (StandardCategories.coreBlockTypes.indexOf(blockType) != -1) {
+ rootBlock.setWarningText('A core Blockly block already exists ' +
+ 'under this name.');
+
+ } else if (blockType == 'block_type') {
+ // Warn user to let them know they can't save a block under the default
+ // name 'block_type'
+ rootBlock.setWarningText('You cannot save a block with the default ' +
+ 'name, "block_type"');
+
+ } else {
+ rootBlock.setWarningText(null);
+ }
+
+ } finally {
+ Blockly.Blocks = backupBlocks;
+ }
+};
+
+/**
+ * Disable link and save buttons if the format is 'Manual', enable otherwise.
+ */
+BlockFactory.disableEnableLink = function() {
+ var linkButton = document.getElementById('linkButton');
+ var saveBlockButton = document.getElementById('localSaveButton');
+ var saveToLibButton = document.getElementById('saveToBlockLibraryButton');
+ var disabled = document.getElementById('format').value == 'Manual';
+ linkButton.disabled = disabled;
+ saveBlockButton.disabled = disabled;
+ saveToLibButton.disabled = disabled;
+};
+
+/**
+ * Render starter block (factory_base).
+ */
+BlockFactory.showStarterBlock = function() {
+ BlockFactory.mainWorkspace.clear();
+ var xml = Blockly.Xml.textToDom(BlockFactory.STARTER_BLOCK_XML_TEXT);
+ Blockly.Xml.domToWorkspace(xml, BlockFactory.mainWorkspace);
+};
+
+/**
+ * Returns whether or not the current block open is the starter block.
+ */
+BlockFactory.isStarterBlock = function() {
+ var rootBlock = FactoryUtils.getRootBlock(BlockFactory.mainWorkspace);
+ // The starter block does not have blocks nested into the factory_base block.
+ return !(rootBlock.getChildren().length > 0 ||
+ // The starter block's name is the default, 'block_type'.
+ rootBlock.getFieldValue('NAME').trim().toLowerCase() != 'block_type' ||
+ // The starter block has no connections.
+ rootBlock.getFieldValue('CONNECTIONS') != 'NONE' ||
+ // The starter block has automatic inputs.
+ rootBlock.getFieldValue('INLINE') != 'AUTO');
+};
diff --git a/blockly/demos/blocklyfactory/factory_utils.js b/blockly/demos/blocklyfactory/factory_utils.js
new file mode 100644
index 0000000..08c003a
--- /dev/null
+++ b/blockly/demos/blocklyfactory/factory_utils.js
@@ -0,0 +1,989 @@
+/**
+ * @license
+ * Visual Blocks Editor
+ *
+ * Copyright 2016 Google Inc.
+ * https://developers.google.com/blockly/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @fileoverview FactoryUtils is a namespace that holds block starter code
+ * generation functions shared by the Block Factory, Workspace Factory, and
+ * Exporter applications within Blockly Factory. Holds functions to generate
+ * block definitions and generator stubs and to create and download files.
+ *
+ * @author fraser@google.com (Neil Fraser), quachtina96 (Tina Quach)
+ */
+ 'use strict';
+
+/**
+ * Namespace for FactoryUtils.
+ */
+goog.provide('FactoryUtils');
+
+/**
+ * Get block definition code for the current block.
+ *
+ * @param {string} blockType - Type of block.
+ * @param {!Blockly.Block} rootBlock - RootBlock from main workspace in which
+ * user uses Block Factory Blocks to create a custom block.
+ * @param {string} format - 'JSON' or 'JavaScript'.
+ * @param {!Blockly.Workspace} workspace - Where the root block lives.
+ * @return {string} Block definition.
+ */
+FactoryUtils.getBlockDefinition = function(blockType, rootBlock, format, workspace) {
+ blockType = blockType.replace(/\W/g, '_').replace(/^(\d)/, '_\\1');
+ switch (format) {
+ case 'JSON':
+ var code = FactoryUtils.formatJson_(blockType, rootBlock);
+ break;
+ case 'JavaScript':
+ var code = FactoryUtils.formatJavaScript_(blockType, rootBlock, workspace);
+ break;
+ }
+ return code;
+};
+
+/**
+ * Get the generator code for a given block.
+ *
+ * @param {!Blockly.Block} block - Rendered block in preview workspace.
+ * @param {string} generatorLanguage - 'JavaScript', 'Python', 'PHP', 'Lua',
+ * 'Dart'.
+ * @return {string} Generator code for multiple blocks.
+ */
+FactoryUtils.getGeneratorStub = function(block, generatorLanguage) {
+ function makeVar(root, name) {
+ name = name.toLowerCase().replace(/\W/g, '_');
+ return ' var ' + root + '_' + name;
+ }
+ // The makevar function lives in the original update generator.
+ var language = generatorLanguage;
+ var code = [];
+ code.push("Blockly." + language + "['" + block.type +
+ "'] = function(block) {");
+
+ // Generate getters for any fields or inputs.
+ for (var i = 0, input; input = block.inputList[i]; i++) {
+ for (var j = 0, field; field = input.fieldRow[j]; j++) {
+ var name = field.name;
+ if (!name) {
+ continue;
+ }
+ if (field instanceof Blockly.FieldVariable) {
+ // Subclass of Blockly.FieldDropdown, must test first.
+ code.push(makeVar('variable', name) +
+ " = Blockly." + language +
+ ".variableDB_.getName(block.getFieldValue('" + name +
+ "'), Blockly.Variables.NAME_TYPE);");
+ } else if (field instanceof Blockly.FieldAngle) {
+ // Subclass of Blockly.FieldTextInput, must test first.
+ code.push(makeVar('angle', name) +
+ " = block.getFieldValue('" + name + "');");
+ } else if (Blockly.FieldDate && field instanceof Blockly.FieldDate) {
+ // Blockly.FieldDate may not be compiled into Blockly.
+ code.push(makeVar('date', name) +
+ " = block.getFieldValue('" + name + "');");
+ } else if (field instanceof Blockly.FieldColour) {
+ code.push(makeVar('colour', name) +
+ " = block.getFieldValue('" + name + "');");
+ } else if (field instanceof Blockly.FieldCheckbox) {
+ code.push(makeVar('checkbox', name) +
+ " = block.getFieldValue('" + name + "') == 'TRUE';");
+ } else if (field instanceof Blockly.FieldDropdown) {
+ code.push(makeVar('dropdown', name) +
+ " = block.getFieldValue('" + name + "');");
+ } else if (field instanceof Blockly.FieldNumber) {
+ code.push(makeVar('number', name) +
+ " = block.getFieldValue('" + name + "');");
+ } else if (field instanceof Blockly.FieldTextInput) {
+ code.push(makeVar('text', name) +
+ " = block.getFieldValue('" + name + "');");
+ }
+ }
+ var name = input.name;
+ if (name) {
+ if (input.type == Blockly.INPUT_VALUE) {
+ code.push(makeVar('value', name) +
+ " = Blockly." + language + ".valueToCode(block, '" + name +
+ "', Blockly." + language + ".ORDER_ATOMIC);");
+ } else if (input.type == Blockly.NEXT_STATEMENT) {
+ code.push(makeVar('statements', name) +
+ " = Blockly." + language + ".statementToCode(block, '" +
+ name + "');");
+ }
+ }
+ }
+ // Most languages end lines with a semicolon. Python does not.
+ var lineEnd = {
+ 'JavaScript': ';',
+ 'Python': '',
+ 'PHP': ';',
+ 'Dart': ';'
+ };
+ code.push(" // TODO: Assemble " + language + " into code variable.");
+ if (block.outputConnection) {
+ code.push(" var code = '...';");
+ code.push(" // TODO: Change ORDER_NONE to the correct strength.");
+ code.push(" return [code, Blockly." + language + ".ORDER_NONE];");
+ } else {
+ code.push(" var code = '..." + (lineEnd[language] || '') + "\\n';");
+ code.push(" return code;");
+ }
+ code.push("};");
+
+ return code.join('\n');
+};
+
+/**
+ * Update the language code as JSON.
+ * @param {string} blockType Name of block.
+ * @param {!Blockly.Block} rootBlock Factory_base block.
+ * @return {string} Generanted language code.
+ * @private
+ */
+FactoryUtils.formatJson_ = function(blockType, rootBlock) {
+ var JS = {};
+ // Type is not used by Blockly, but may be used by a loader.
+ JS.type = blockType;
+ // Generate inputs.
+ var message = [];
+ var args = [];
+ var contentsBlock = rootBlock.getInputTargetBlock('INPUTS');
+ var lastInput = null;
+ while (contentsBlock) {
+ if (!contentsBlock.disabled && !contentsBlock.getInheritedDisabled()) {
+ var fields = FactoryUtils.getFieldsJson_(
+ contentsBlock.getInputTargetBlock('FIELDS'));
+ for (var i = 0; i < fields.length; i++) {
+ if (typeof fields[i] == 'string') {
+ message.push(fields[i].replace(/%/g, '%%'));
+ } else {
+ args.push(fields[i]);
+ message.push('%' + args.length);
+ }
+ }
+
+ var input = {type: contentsBlock.type};
+ // Dummy inputs don't have names. Other inputs do.
+ if (contentsBlock.type != 'input_dummy') {
+ input.name = contentsBlock.getFieldValue('INPUTNAME');
+ }
+ var check = JSON.parse(
+ FactoryUtils.getOptTypesFrom(contentsBlock, 'TYPE') || 'null');
+ if (check) {
+ input.check = check;
+ }
+ var align = contentsBlock.getFieldValue('ALIGN');
+ if (align != 'LEFT') {
+ input.align = align;
+ }
+ args.push(input);
+ message.push('%' + args.length);
+ lastInput = contentsBlock;
+ }
+ contentsBlock = contentsBlock.nextConnection &&
+ contentsBlock.nextConnection.targetBlock();
+ }
+ // Remove last input if dummy and not empty.
+ if (lastInput && lastInput.type == 'input_dummy') {
+ var fields = lastInput.getInputTargetBlock('FIELDS');
+ if (fields && FactoryUtils.getFieldsJson_(fields).join('').trim() != '') {
+ var align = lastInput.getFieldValue('ALIGN');
+ if (align != 'LEFT') {
+ JS.lastDummyAlign0 = align;
+ }
+ args.pop();
+ message.pop();
+ }
+ }
+ JS.message0 = message.join(' ');
+ if (args.length) {
+ JS.args0 = args;
+ }
+ // Generate inline/external switch.
+ if (rootBlock.getFieldValue('INLINE') == 'EXT') {
+ JS.inputsInline = false;
+ } else if (rootBlock.getFieldValue('INLINE') == 'INT') {
+ JS.inputsInline = true;
+ }
+ // Generate output, or next/previous connections.
+ switch (rootBlock.getFieldValue('CONNECTIONS')) {
+ case 'LEFT':
+ JS.output =
+ JSON.parse(
+ FactoryUtils.getOptTypesFrom(rootBlock, 'OUTPUTTYPE') || 'null');
+ break;
+ case 'BOTH':
+ JS.previousStatement =
+ JSON.parse(
+ FactoryUtils.getOptTypesFrom(rootBlock, 'TOPTYPE') || 'null');
+ JS.nextStatement =
+ JSON.parse(
+ FactoryUtils.getOptTypesFrom(rootBlock, 'BOTTOMTYPE') || 'null');
+ break;
+ case 'TOP':
+ JS.previousStatement =
+ JSON.parse(
+ FactoryUtils.getOptTypesFrom(rootBlock, 'TOPTYPE') || 'null');
+ break;
+ case 'BOTTOM':
+ JS.nextStatement =
+ JSON.parse(
+ FactoryUtils.getOptTypesFrom(rootBlock, 'BOTTOMTYPE') || 'null');
+ break;
+ }
+ // Generate colour.
+ var colourBlock = rootBlock.getInputTargetBlock('COLOUR');
+ if (colourBlock && !colourBlock.disabled) {
+ var hue = parseInt(colourBlock.getFieldValue('HUE'), 10);
+ JS.colour = hue;
+ }
+ JS.tooltip = '';
+ JS.helpUrl = 'http://www.example.com/';
+ return JSON.stringify(JS, null, ' ');
+};
+
+/**
+ * Update the language code as JavaScript.
+ * @param {string} blockType Name of block.
+ * @param {!Blockly.Block} rootBlock Factory_base block.
+ * @param {!Blockly.Workspace} workspace - Where the root block lives.
+
+ * @return {string} Generated language code.
+ * @private
+ */
+FactoryUtils.formatJavaScript_ = function(blockType, rootBlock, workspace) {
+ var code = [];
+ code.push("Blockly.Blocks['" + blockType + "'] = {");
+ code.push(" init: function() {");
+ // Generate inputs.
+ var TYPES = {'input_value': 'appendValueInput',
+ 'input_statement': 'appendStatementInput',
+ 'input_dummy': 'appendDummyInput'};
+ var contentsBlock = rootBlock.getInputTargetBlock('INPUTS');
+ while (contentsBlock) {
+ if (!contentsBlock.disabled && !contentsBlock.getInheritedDisabled()) {
+ var name = '';
+ // Dummy inputs don't have names. Other inputs do.
+ if (contentsBlock.type != 'input_dummy') {
+ name =
+ FactoryUtils.escapeString(contentsBlock.getFieldValue('INPUTNAME'));
+ }
+ code.push(' this.' + TYPES[contentsBlock.type] + '(' + name + ')');
+ var check = FactoryUtils.getOptTypesFrom(contentsBlock, 'TYPE');
+ if (check) {
+ code.push(' .setCheck(' + check + ')');
+ }
+ var align = contentsBlock.getFieldValue('ALIGN');
+ if (align != 'LEFT') {
+ code.push(' .setAlign(Blockly.ALIGN_' + align + ')');
+ }
+ var fields = FactoryUtils.getFieldsJs_(
+ contentsBlock.getInputTargetBlock('FIELDS'));
+ for (var i = 0; i < fields.length; i++) {
+ code.push(' .appendField(' + fields[i] + ')');
+ }
+ // Add semicolon to last line to finish the statement.
+ code[code.length - 1] += ';';
+ }
+ contentsBlock = contentsBlock.nextConnection &&
+ contentsBlock.nextConnection.targetBlock();
+ }
+ // Generate inline/external switch.
+ if (rootBlock.getFieldValue('INLINE') == 'EXT') {
+ code.push(' this.setInputsInline(false);');
+ } else if (rootBlock.getFieldValue('INLINE') == 'INT') {
+ code.push(' this.setInputsInline(true);');
+ }
+ // Generate output, or next/previous connections.
+ switch (rootBlock.getFieldValue('CONNECTIONS')) {
+ case 'LEFT':
+ code.push(FactoryUtils.connectionLineJs_('setOutput', 'OUTPUTTYPE', workspace));
+ break;
+ case 'BOTH':
+ code.push(
+ FactoryUtils.connectionLineJs_('setPreviousStatement', 'TOPTYPE', workspace));
+ code.push(
+ FactoryUtils.connectionLineJs_('setNextStatement', 'BOTTOMTYPE', workspace));
+ break;
+ case 'TOP':
+ code.push(
+ FactoryUtils.connectionLineJs_('setPreviousStatement', 'TOPTYPE', workspace));
+ break;
+ case 'BOTTOM':
+ code.push(
+ FactoryUtils.connectionLineJs_('setNextStatement', 'BOTTOMTYPE', workspace));
+ break;
+ }
+ // Generate colour.
+ var colourBlock = rootBlock.getInputTargetBlock('COLOUR');
+ if (colourBlock && !colourBlock.disabled) {
+ var hue = parseInt(colourBlock.getFieldValue('HUE'), 10);
+ if (!isNaN(hue)) {
+ code.push(' this.setColour(' + hue + ');');
+ }
+ }
+ code.push(" this.setTooltip('');");
+ code.push(" this.setHelpUrl('http://www.example.com/');");
+ code.push(' }');
+ code.push('};');
+ return code.join('\n');
+};
+
+/**
+ * Create JS code required to create a top, bottom, or value connection.
+ * @param {string} functionName JavaScript function name.
+ * @param {string} typeName Name of type input.
+ * @param {!Blockly.Workspace} workspace - Where the root block lives.
+ * @return {string} Line of JavaScript code to create connection.
+ * @private
+ */
+FactoryUtils.connectionLineJs_ = function(functionName, typeName, workspace) {
+ var type = FactoryUtils.getOptTypesFrom(
+ FactoryUtils.getRootBlock(workspace), typeName);
+ if (type) {
+ type = ', ' + type;
+ } else {
+ type = '';
+ }
+ return ' this.' + functionName + '(true' + type + ');';
+};
+
+/**
+ * Returns field strings and any config.
+ * @param {!Blockly.Block} block Input block.
+ * @return {!Array.<string>} Field strings.
+ * @private
+ */
+FactoryUtils.getFieldsJs_ = function(block) {
+ var fields = [];
+ while (block) {
+ if (!block.disabled && !block.getInheritedDisabled()) {
+ switch (block.type) {
+ case 'field_static':
+ // Result: 'hello'
+ fields.push(FactoryUtils.escapeString(block.getFieldValue('TEXT')));
+ break;
+ case 'field_input':
+ // Result: new Blockly.FieldTextInput('Hello'), 'GREET'
+ fields.push('new Blockly.FieldTextInput(' +
+ FactoryUtils.escapeString(block.getFieldValue('TEXT')) + '), ' +
+ FactoryUtils.escapeString(block.getFieldValue('FIELDNAME')));
+ break;
+ case 'field_number':
+ // Result: new Blockly.FieldNumber(10, 0, 100, 1), 'NUMBER'
+ var args = [
+ Number(block.getFieldValue('VALUE')),
+ Number(block.getFieldValue('MIN')),
+ Number(block.getFieldValue('MAX')),
+ Number(block.getFieldValue('PRECISION'))
+ ];
+ // Remove any trailing arguments that aren't needed.
+ if (args[3] == 0) {
+ args.pop();
+ if (args[2] == Infinity) {
+ args.pop();
+ if (args[1] == -Infinity) {
+ args.pop();
+ }
+ }
+ }
+ fields.push('new Blockly.FieldNumber(' + args.join(', ') + '), ' +
+ FactoryUtils.escapeString(block.getFieldValue('FIELDNAME')));
+ break;
+ case 'field_angle':
+ // Result: new Blockly.FieldAngle(90), 'ANGLE'
+ fields.push('new Blockly.FieldAngle(' +
+ parseFloat(block.getFieldValue('ANGLE')) + '), ' +
+ FactoryUtils.escapeString(block.getFieldValue('FIELDNAME')));
+ break;
+ case 'field_checkbox':
+ // Result: new Blockly.FieldCheckbox('TRUE'), 'CHECK'
+ fields.push('new Blockly.FieldCheckbox(' +
+ FactoryUtils.escapeString(block.getFieldValue('CHECKED')) +
+ '), ' +
+ FactoryUtils.escapeString(block.getFieldValue('FIELDNAME')));
+ break;
+ case 'field_colour':
+ // Result: new Blockly.FieldColour('#ff0000'), 'COLOUR'
+ fields.push('new Blockly.FieldColour(' +
+ FactoryUtils.escapeString(block.getFieldValue('COLOUR')) +
+ '), ' +
+ FactoryUtils.escapeString(block.getFieldValue('FIELDNAME')));
+ break;
+ case 'field_date':
+ // Result: new Blockly.FieldDate('2015-02-04'), 'DATE'
+ fields.push('new Blockly.FieldDate(' +
+ FactoryUtils.escapeString(block.getFieldValue('DATE')) + '), ' +
+ FactoryUtils.escapeString(block.getFieldValue('FIELDNAME')));
+ break;
+ case 'field_variable':
+ // Result: new Blockly.FieldVariable('item'), 'VAR'
+ var varname
+ = FactoryUtils.escapeString(block.getFieldValue('TEXT') || null);
+ fields.push('new Blockly.FieldVariable(' + varname + '), ' +
+ FactoryUtils.escapeString(block.getFieldValue('FIELDNAME')));
+ break;
+ case 'field_dropdown':
+ // Result:
+ // new Blockly.FieldDropdown([['yes', '1'], ['no', '0']]), 'TOGGLE'
+ var options = [];
+ for (var i = 0; i < block.optionCount_; i++) {
+ options[i] = '[' +
+ FactoryUtils.escapeString(block.getFieldValue('USER' + i)) +
+ ', ' +
+ FactoryUtils.escapeString(block.getFieldValue('CPU' + i)) + ']';
+ }
+ if (options.length) {
+ fields.push('new Blockly.FieldDropdown([' +
+ options.join(', ') + ']), ' +
+ FactoryUtils.escapeString(block.getFieldValue('FIELDNAME')));
+ }
+ break;
+ case 'field_image':
+ // Result: new Blockly.FieldImage('http://...', 80, 60)
+ var src = FactoryUtils.escapeString(block.getFieldValue('SRC'));
+ var width = Number(block.getFieldValue('WIDTH'));
+ var height = Number(block.getFieldValue('HEIGHT'));
+ var alt = FactoryUtils.escapeString(block.getFieldValue('ALT'));
+ fields.push('new Blockly.FieldImage(' +
+ src + ', ' + width + ', ' + height + ', ' + alt + ')');
+ break;
+ }
+ }
+ block = block.nextConnection && block.nextConnection.targetBlock();
+ }
+ return fields;
+};
+
+/**
+ * Returns field strings and any config.
+ * @param {!Blockly.Block} block Input block.
+ * @return {!Array.<string|!Object>} Array of static text and field configs.
+ * @private
+ */
+FactoryUtils.getFieldsJson_ = function(block) {
+ var fields = [];
+ while (block) {
+ if (!block.disabled && !block.getInheritedDisabled()) {
+ switch (block.type) {
+ case 'field_static':
+ // Result: 'hello'
+ fields.push(block.getFieldValue('TEXT'));
+ break;
+ case 'field_input':
+ fields.push({
+ type: block.type,
+ name: block.getFieldValue('FIELDNAME'),
+ text: block.getFieldValue('TEXT')
+ });
+ break;
+ case 'field_number':
+ var obj = {
+ type: block.type,
+ name: block.getFieldValue('FIELDNAME'),
+ value: parseFloat(block.getFieldValue('VALUE'))
+ };
+ var min = parseFloat(block.getFieldValue('MIN'));
+ if (min > -Infinity) {
+ obj.min = min;
+ }
+ var max = parseFloat(block.getFieldValue('MAX'));
+ if (max < Infinity) {
+ obj.max = max;
+ }
+ var precision = parseFloat(block.getFieldValue('PRECISION'));
+ if (precision) {
+ obj.precision = precision;
+ }
+ fields.push(obj);
+ break;
+ case 'field_angle':
+ fields.push({
+ type: block.type,
+ name: block.getFieldValue('FIELDNAME'),
+ angle: Number(block.getFieldValue('ANGLE'))
+ });
+ break;
+ case 'field_checkbox':
+ fields.push({
+ type: block.type,
+ name: block.getFieldValue('FIELDNAME'),
+ checked: block.getFieldValue('CHECKED') == 'TRUE'
+ });
+ break;
+ case 'field_colour':
+ fields.push({
+ type: block.type,
+ name: block.getFieldValue('FIELDNAME'),
+ colour: block.getFieldValue('COLOUR')
+ });
+ break;
+ case 'field_date':
+ fields.push({
+ type: block.type,
+ name: block.getFieldValue('FIELDNAME'),
+ date: block.getFieldValue('DATE')
+ });
+ break;
+ case 'field_variable':
+ fields.push({
+ type: block.type,
+ name: block.getFieldValue('FIELDNAME'),
+ variable: block.getFieldValue('TEXT') || null
+ });
+ break;
+ case 'field_dropdown':
+ var options = [];
+ for (var i = 0; i < block.optionCount_; i++) {
+ options[i] = [block.getFieldValue('USER' + i),
+ block.getFieldValue('CPU' + i)];
+ }
+ if (options.length) {
+ fields.push({
+ type: block.type,
+ name: block.getFieldValue('FIELDNAME'),
+ options: options
+ });
+ }
+ break;
+ case 'field_image':
+ fields.push({
+ type: block.type,
+ src: block.getFieldValue('SRC'),
+ width: Number(block.getFieldValue('WIDTH')),
+ height: Number(block.getFieldValue('HEIGHT')),
+ alt: block.getFieldValue('ALT')
+ });
+ break;
+ }
+ }
+ block = block.nextConnection && block.nextConnection.targetBlock();
+ }
+ return fields;
+};
+
+/**
+ * Fetch the type(s) defined in the given input.
+ * Format as a string for appending to the generated code.
+ * @param {!Blockly.Block} block Block with input.
+ * @param {string} name Name of the input.
+ * @return {?string} String defining the types.
+ */
+FactoryUtils.getOptTypesFrom = function(block, name) {
+ var types = FactoryUtils.getTypesFrom_(block, name);
+ if (types.length == 0) {
+ return undefined;
+ } else if (types.indexOf('null') != -1) {
+ return 'null';
+ } else if (types.length == 1) {
+ return types[0];
+ } else {
+ return '[' + types.join(', ') + ']';
+ }
+};
+
+
+/**
+ * Fetch the type(s) defined in the given input.
+ * @param {!Blockly.Block} block Block with input.
+ * @param {string} name Name of the input.
+ * @return {!Array.<string>} List of types.
+ * @private
+ */
+FactoryUtils.getTypesFrom_ = function(block, name) {
+ var typeBlock = block.getInputTargetBlock(name);
+ var types;
+ if (!typeBlock || typeBlock.disabled) {
+ types = [];
+ } else if (typeBlock.type == 'type_other') {
+ types = [FactoryUtils.escapeString(typeBlock.getFieldValue('TYPE'))];
+ } else if (typeBlock.type == 'type_group') {
+ types = [];
+ for (var n = 0; n < typeBlock.typeCount_; n++) {
+ types = types.concat(FactoryUtils.getTypesFrom_(typeBlock, 'TYPE' + n));
+ }
+ // Remove duplicates.
+ var hash = Object.create(null);
+ for (var n = types.length - 1; n >= 0; n--) {
+ if (hash[types[n]]) {
+ types.splice(n, 1);
+ }
+ hash[types[n]] = true;
+ }
+ } else {
+ types = [FactoryUtils.escapeString(typeBlock.valueType)];
+ }
+ return types;
+};
+
+/**
+ * Escape a string.
+ * @param {string} string String to escape.
+ * @return {string} Escaped string surrouned by quotes.
+ */
+FactoryUtils.escapeString = function(string) {
+ return JSON.stringify(string);
+};
+
+/**
+ * Return the uneditable container block that everything else attaches to in
+ * given workspace
+ *
+ * @param {!Blockly.Workspace} workspace - where the root block lives
+ * @return {Blockly.Block} root block
+ */
+FactoryUtils.getRootBlock = function(workspace) {
+ var blocks = workspace.getTopBlocks(false);
+ for (var i = 0, block; block = blocks[i]; i++) {
+ if (block.type == 'factory_base') {
+ return block;
+ }
+ }
+ return null;
+};
+
+// TODO(quachtina96): Move hide, show, makeInvisible, and makeVisible to a new
+// AppView namespace.
+
+/**
+ * Hides element so that it's invisible and doesn't take up space.
+ *
+ * @param {string} elementID - ID of element to hide.
+ */
+FactoryUtils.hide = function(elementID) {
+ document.getElementById(elementID).style.display = 'none';
+};
+
+/**
+ * Un-hides an element.
+ *
+ * @param {string} elementID - ID of element to hide.
+ */
+FactoryUtils.show = function(elementID) {
+ document.getElementById(elementID).style.display = 'block';
+};
+
+/**
+ * Hides element so that it's invisible but still takes up space.
+ *
+ * @param {string} elementID - ID of element to hide.
+ */
+FactoryUtils.makeInvisible = function(elementID) {
+ document.getElementById(elementID).visibility = 'hidden';
+};
+
+/**
+ * Makes element visible.
+ *
+ * @param {string} elementID - ID of element to hide.
+ */
+FactoryUtils.makeVisible = function(elementID) {
+ document.getElementById(elementID).visibility = 'visible';
+};
+
+/**
+ * Create a file with the given attributes and download it.
+ * @param {string} contents - The contents of the file.
+ * @param {string} filename - The name of the file to save to.
+ * @param {string} fileType - The type of the file to save.
+ */
+FactoryUtils.createAndDownloadFile = function(contents, filename, fileType) {
+ var data = new Blob([contents], {type: 'text/' + fileType});
+ var clickEvent = new MouseEvent("click", {
+ "view": window,
+ "bubbles": true,
+ "cancelable": false
+ });
+
+ var a = document.createElement('a');
+ a.href = window.URL.createObjectURL(data);
+ a.download = filename;
+ a.textContent = 'Download file!';
+ a.dispatchEvent(clickEvent);
+};
+
+/**
+ * Get Blockly Block by rendering pre-defined block in workspace.
+ *
+ * @param {!Element} blockType - Type of block that has already been defined.
+ * @param {!Blockly.Workspace} workspace - Workspace on which to render
+ * the block.
+ * @return {!Blockly.Block} the Blockly.Block of desired type.
+ */
+FactoryUtils.getDefinedBlock = function(blockType, workspace) {
+ workspace.clear();
+ return workspace.newBlock(blockType);
+};
+
+/**
+ * Parses a block definition get the type of the block it defines.
+ *
+ * @param {!string} blockDef - A single block definition.
+ * @return {string} Type of block defined by the given definition.
+ */
+FactoryUtils.getBlockTypeFromJsDefinition = function(blockDef) {
+ var indexOfStartBracket = blockDef.indexOf('[\'');
+ var indexOfEndBracket = blockDef.indexOf('\']');
+ if (indexOfStartBracket != -1 && indexOfEndBracket != -1) {
+ return blockDef.substring(indexOfStartBracket + 2, indexOfEndBracket);
+ } else {
+ throw new Error ('Could not parse block type out of JavaScript block ' +
+ 'definition. Brackets normally enclosing block type not found.');
+ }
+};
+
+/**
+ * Generates a category containing blocks of the specified block types.
+ *
+ * @param {!Array.<Blockly.Block>} blocks - Blocks to include in the category.
+ * @param {string} categoryName - Name to use for the generated category.
+ * @return {Element} - Category xml containing the given block types.
+ */
+FactoryUtils.generateCategoryXml = function(blocks, categoryName) {
+ // Create category DOM element.
+ var categoryElement = goog.dom.createDom('category');
+ categoryElement.setAttribute('name', categoryName);
+
+ // For each block, add block element to category.
+ for (var i = 0, block; block = blocks[i]; i++) {
+
+ // Get preview block XML.
+ var blockXml = Blockly.Xml.blockToDom(block);
+ blockXml.removeAttribute('id');
+
+ // Add block to category and category to XML.
+ categoryElement.appendChild(blockXml);
+ }
+ return categoryElement;
+};
+
+/**
+ * Parses a string containing JavaScript block definition(s) to create an array
+ * in which each element is a single block definition.
+ *
+ * @param {!string} blockDefsString - JavaScript block definition(s).
+ * @return {!Array.<string>} - Array of block definitions.
+ */
+FactoryUtils.parseJsBlockDefinitions = function(blockDefsString) {
+ var blockDefArray = [];
+ var defStart = blockDefsString.indexOf('Blockly.Blocks');
+
+ while (blockDefsString.indexOf('Blockly.Blocks', defStart) != -1) {
+ var nextStart = blockDefsString.indexOf('Blockly.Blocks', defStart + 1);
+ if (nextStart == -1) {
+ // This is the last block definition.
+ nextStart = blockDefsString.length;
+ }
+ var blockDef = blockDefsString.substring(defStart, nextStart);
+ blockDefArray.push(blockDef);
+ defStart = nextStart;
+ }
+ return blockDefArray;
+};
+
+/**
+ * Parses a string containing JSON block definition(s) to create an array
+ * in which each element is a single block definition. Expected input is
+ * one or more block definitions in the form of concatenated, stringified
+ * JSON objects.
+ *
+ * @param {!string} blockDefsString - String containing JSON block
+ * definition(s).
+ * @return {!Array.<string>} - Array of block definitions.
+ */
+FactoryUtils.parseJsonBlockDefinitions = function(blockDefsString) {
+ var blockDefArray = [];
+ var unbalancedBracketCount = 0;
+ var defStart = 0;
+ // Iterate through the blockDefs string. Keep track of whether brackets
+ // are balanced.
+ for (var i = 0; i < blockDefsString.length; i++) {
+ var currentChar = blockDefsString[i];
+ if (currentChar == '{') {
+ unbalancedBracketCount++;
+ }
+ else if (currentChar == '}') {
+ unbalancedBracketCount--;
+ if (unbalancedBracketCount == 0 && i > 0) {
+ // The brackets are balanced. We've got a complete block defintion.
+ var blockDef = blockDefsString.substring(defStart, i + 1);
+ blockDefArray.push(blockDef);
+ defStart = i + 1;
+ }
+ }
+ }
+ return blockDefArray;
+};
+
+/**
+ * Define blocks from imported block definitions.
+ *
+ * @param {!string} blockDefsString - Block definition(s).
+ * @param {!string} format - Block definition format ('JSON' or 'JavaScript').
+ * @return {!Array<!Element>} Array of block types defined.
+ */
+FactoryUtils.defineAndGetBlockTypes = function(blockDefsString, format) {
+ var blockTypes = [];
+
+ // Define blocks and get block types.
+ if (format == 'JSON') {
+ var blockDefArray = FactoryUtils.parseJsonBlockDefinitions(blockDefsString);
+
+ // Populate array of blocktypes and define each block.
+ for (var i = 0, blockDef; blockDef = blockDefArray[i]; i++) {
+ var json = JSON.parse(blockDef);
+ blockTypes.push(json.type);
+
+ // Define the block.
+ Blockly.Blocks[json.type] = {
+ init: function() {
+ this.jsonInit(json);
+ }
+ };
+ }
+ } else if (format == 'JavaScript') {
+ var blockDefArray = FactoryUtils.parseJsBlockDefinitions(blockDefsString);
+
+ // Populate array of block types.
+ for (var i = 0, blockDef; blockDef = blockDefArray[i]; i++) {
+ var blockType = FactoryUtils.getBlockTypeFromJsDefinition(blockDef);
+ blockTypes.push(blockType);
+ }
+
+ // Define all blocks.
+ eval(blockDefsString);
+ }
+
+ return blockTypes;
+};
+
+/**
+ * Inject code into a pre tag, with syntax highlighting.
+ * Safe from HTML/script injection.
+ * @param {string} code Lines of code.
+ * @param {string} id ID of <pre> element to inject into.
+ */
+FactoryUtils.injectCode = function(code, id) {
+ var pre = document.getElementById(id);
+ pre.textContent = code;
+ code = pre.innerHTML;
+ code = prettyPrintOne(code, 'js');
+ pre.innerHTML = code;
+};
+
+/**
+ * Returns whether or not two blocks are the same based on their xml. Expects
+ * xml with a single child node that is a factory_base block, the xml found on
+ * Block Factory's main workspace.
+ *
+ * @param {!Element} blockXml1 - An xml element with a single child node that
+ * is a factory_base block.
+ * @param {!Element} blockXml2 - An xml element with a single child node that
+ * is a factory_base block.
+ * @return {boolean} Whether or not two blocks are the same based on their xml.
+ */
+FactoryUtils.sameBlockXml = function(blockXml1, blockXml2) {
+ // Each xml element should contain a single child element with a 'block' tag
+ if (goog.string.caseInsensitiveCompare(blockXml1.tagName, 'xml') ||
+ goog.string.caseInsensitiveCompare(blockXml2.tagName, 'xml')) {
+ throw new Error('Expected two xml elements, recieved elements with tag ' +
+ 'names: ' + blockXml1.tagName + ' and ' + blockXml2.tagName + '.');
+ }
+
+ // Compare the block elements directly. The xml tags may include other meta
+ // information we want to igrore.
+ var blockElement1 = blockXml1.getElementsByTagName('block')[0];
+ var blockElement2 = blockXml2.getElementsByTagName('block')[0];
+
+ if (!(blockElement1 && blockElement2)) {
+ throw new Error('Could not get find block element in xml.');
+ }
+
+ var blockXmlText1 = Blockly.Xml.domToText(blockElement1);
+ var blockXmlText2 = Blockly.Xml.domToText(blockElement2);
+
+ // Strip white space.
+ blockXmlText1 = blockXmlText1.replace(/\s+/g, '');
+ blockXmlText2 = blockXmlText2.replace(/\s+/g, '');
+
+ // Return whether or not changes have been saved.
+ return blockXmlText1 == blockXmlText2;
+};
+
+/*
+ * Checks if a block has a variable field. Blocks with variable fields cannot
+ * be shadow blocks.
+ *
+ * @param {Blockly.Block} block The block to check if a variable field exists.
+ * @return {boolean} True if the block has a variable field, false otherwise.
+ */
+FactoryUtils.hasVariableField = function(block) {
+ if (!block) {
+ return false;
+ }
+ for (var i = 0, input; input = block.inputList[i]; i++) {
+ for (var j = 0, field; field = input.fieldRow[j]; j++) {
+ if (field.name == 'VAR') {
+ return true;
+ }
+ }
+ }
+ return false;
+};
+
+/**
+ * Checks if a block is a procedures block. If procedures block names are
+ * ever updated or expanded, this function should be updated as well (no
+ * other known markers for procedure blocks beyond name).
+ *
+ * @param {Blockly.Block} block The block to check.
+ * @return {boolean} True if hte block is a procedure block, false otherwise.
+ */
+FactoryUtils.isProcedureBlock = function(block) {
+ return block &&
+ (block.type == 'procedures_defnoreturn' ||
+ block.type == 'procedures_defreturn' ||
+ block.type == 'procedures_callnoreturn' ||
+ block.type == 'procedures_callreturn' ||
+ block.type == 'procedures_ifreturn');
+};
+
+/**
+ * Returns whether or not a modified block's changes has been saved to the
+ * Block Library.
+ * TODO(quachtina96): move into the Block Factory Controller once made.
+ *
+ * @param {!BlockLibraryController} blockLibraryController - Block Library
+ * Controller storing custom blocks.
+ * @return {boolean} True if all changes made to the block have been saved to
+ * the given Block Library.
+ */
+FactoryUtils.savedBlockChanges = function(blockLibraryController) {
+ if (BlockFactory.isStarterBlock()) {
+ return true;
+ }
+ var blockType = blockLibraryController.getCurrentBlockType();
+ var currentXml = Blockly.Xml.workspaceToDom(BlockFactory.mainWorkspace);
+
+ if (blockLibraryController.has(blockType)) {
+ // Block is saved in block library.
+ var savedXml = blockLibraryController.getBlockXml(blockType);
+ return FactoryUtils.sameBlockXml(savedXml, currentXml);
+ }
+ return false;
+};
+
diff --git a/blockly/demos/blocklyfactory/index.html b/blockly/demos/blocklyfactory/index.html
new file mode 100644
index 0000000..69d18a0
--- /dev/null
+++ b/blockly/demos/blocklyfactory/index.html
@@ -0,0 +1,740 @@
+<!-- TODO(quachtina96): move the CSS out to a separate file -->
+
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="target-densitydpi=device-dpi, height=660, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
+ <title>Blockly Demo: Blockly Factory</title>
+ <script src="../../blockly_compressed.js"></script>
+ <script src="../../javascript_compressed.js"></script>
+ <script src="../../msg/messages.js"></script>
+ <script src="../../blocks_compressed.js"></script>
+ <script src="workspacefactory/wfactory_model.js"></script>
+ <script src="workspacefactory/wfactory_controller.js"></script>
+ <script src="workspacefactory/wfactory_view.js"></script>
+ <script src="workspacefactory/wfactory_generator.js"></script>
+ <script src="workspacefactory/wfactory_init.js"></script>
+ <script src="standard_categories.js"></script>
+ <script src="/storage.js"></script>
+ <script src="../../../closure-library/closure/goog/base.js"></script>
+ <script src="factory_utils.js"></script>
+ <script src="block_option.js"></script>
+ <script src="factory.js"></script>
+ <script src="block_library_view.js"></script>
+ <script src="block_library_storage.js"></script>
+ <script src="block_library_controller.js"></script>
+ <script src="block_exporter_tools.js"></script>
+ <script src="block_exporter_view.js"></script>
+ <script src="block_exporter_controller.js"></script>
+ <script src="../blockfactory/blocks.js"></script>
+ <script src="app_controller.js"></script>
+ <link rel="stylesheet" href="factory.css">
+ <link rel="stylesheet" href="../prettify.css">
+ <script src="../prettify.js"></script>
+ <script>
+ var blocklyFactory;
+ var init = function() {
+ blocklyFactory = new AppController();
+ blocklyFactory.init();
+ };
+ window.addEventListener('load', init);
+ </script>
+</head>
+<body onbeforeunload="return blocklyFactory.confirmLeavePage()">
+<h1><a href="https://developers.google.com/blockly/">Blockly</a> &gt;
+ <a href="../index.html">Demos</a> &gt; Blockly Factory
+ <button id="helpButton" title="View documentation in new window.">
+ <span>Help</span>
+ </button>
+</h1>
+ <div id="tabContainer">
+ <div id="blockFactory_tab" class="tab tabon"> Block Factory</div>
+ <div id="blocklibraryExporter_tab" class="tab taboff"> Block Exporter</div>
+ <div id="workspaceFactory_tab" class="tab taboff"> Workspace Factory</div>
+ </div>
+
+ <!-- Exporter tab -->
+ <div id="blockLibraryExporter">
+ <br>
+ <p id="helperText"> First, select blocks from your block library by clicking on them. Then, use the Export Settings form to download starter code for selected blocks.
+ </p>
+ <div id="exportSelector">
+ <br>
+ <h3> Block Selector </h3>
+ <div class='dropdown'>
+ <button id="button_setBlocks">Select</button>
+ <div id="dropdownDiv_setBlocks" class="dropdown-content">
+ <a id='dropdown_addAllFromLib' title="Select all block library blocks.">All Stored in Block Library</a>
+ <a id='dropdown_addAllUsed' title="Select all block library blocks used in workspace factory.">All Used in Workspace Factory</a>
+ </div>
+ <button id='clearSelectedButton' title="Clear selected blocks.">Clear Selected</a>
+ </div>
+
+ <div id="blockSelector"></div>
+ </div>
+
+ <!-- Users may customize export settings through this form -->
+ <div id="exportSettings">
+ <br>
+ <h3> Export Settings </h3>
+ <form id="exportSettingsForm">
+
+ <div id="selectedBlocksTextContainer">
+ <p>Currently Selected:</p>
+ <p id="selectedBlocksText"></p>
+ </div>
+ <input type="checkbox" id="blockDefCheck">Block Definition(s)<br>
+ <div id="blockDefSettings" class="subsettings">
+ Format:
+ <select id="exportFormat">
+ <option value="JSON">JSON</option>
+ <option value="JavaScript">JavaScript</option>
+ </select>
+ <br>
+ File Name:
+ <br>
+ <input type="text" id="blockDef_filename">
+ </div>
+ <br>
+ <input type="checkbox" id="genStubCheck">Generator Stub(s)<br>
+ <div id="genStubSettings" class="subsettings">
+ Language:
+ <select id="exportLanguage">
+ <option value="JavaScript">JavaScript</option>
+ <option value="Python">Python</option>
+ <option value="PHP">PHP</option>
+ <option value="Lua">Lua</option>
+ <option value="Dart">Dart</option>
+ </select>
+ <br>
+ File Name:
+ <br>
+ <input type="text" id="generatorStub_filename"><br>
+ </div>
+ <br>
+ </form>
+ <button id="exporterSubmitButton" title="Download block starter code as specified in export settings."> Export </button>
+ </div>
+ <div id="exportPreview">
+ <br>
+ <h3>Export Preview </h3>
+ <div id="blockDefs" class="exportPreviewTextArea">
+ <p id="blockDefs_label">Block Definitions:</p>
+ <pre id="blockDefs_textArea"></pre>
+ </div>
+ <div id="genStubs" class="exportPreviewTextArea">
+ <p id="genStubs_label">Generator Stubs:</p>
+ <pre id="genStubs_textArea"></pre>
+ </div>
+ </div>
+ </div>
+
+ <!-- Workspace Factory tab -->
+
+ <div id="workspaceFactoryContent">
+ <div id="factoryHeader">
+ <p>
+ <div class="dropdown">
+ <button id="button_importBlocks">Import Custom Blocks</button>
+ <div id="dropdownDiv_importBlocks" class="dropdown-content">
+ <input type="file" id="input_importBlocksJson" accept=".js, .json, .txt" class="inputfile"</input>
+ <label for="input_importBlocksJson">From JSON</label>
+ <input type="file" id="input_importBlocksJs" accept=".js, .txt" class="inputfile"</input>
+ <label for="input_importBlocksJs">From Javascript</label>
+ </div>
+ </div>
+
+ <div class="dropdown">
+ <button id="button_load">Load to Edit</button>
+ <div id="dropdownDiv_load" class="dropdown-content">
+ <input type="file" id="input_loadToolbox" accept=".xml" class="inputfile"></input>
+ <label for="input_loadToolbox">Toolbox</label>
+ <input type="file" id="input_loadPreload" accept=".xml" class="inputfile"</input>
+ <label for="input_loadPreload">Workspace Blocks</label>
+ </div>
+ </div>
+
+ <div class="dropdown">
+ <button id="button_export">Export</button>
+ <div id="dropdownDiv_export" class="dropdown-content">
+ <a id='dropdown_exportOptions'>Starter Code</a>
+ <a id='dropdown_exportToolbox'>Toolbox</a>
+ <a id='dropdown_exportPreload'>Workspace Blocks</a>
+ <a id='dropdown_exportAll'>All</a>
+ </div>
+ </div>
+
+ <button id="button_clear">Clear</button>
+
+ </p>
+ </div>
+
+ <section id="createDiv">
+ <div id="createHeader">
+ <h3>Edit</h3>
+ <p id="editHelpText">Drag blocks into the workspace to configure the toolbox in your custom workspace.</p>
+ </div>
+ <table id='workspaceTabs' style="width:auto; height:auto">
+ <td id="tab_toolbox" class="tabon">Toolbox</td>
+ <td id="tab_preload" class="taboff">Workspace</td>
+ </table>
+ <section id="toolbox_section">
+ <div id="toolbox_blocks"></div>
+ </section>
+ <aside id="toolbox_div">
+ <p id="categoryHeader">Your categories will appear here</p>
+ <table id="categoryTable" style="width:auto; height:auto">
+ </table>
+ <p>&nbsp;</p>
+
+ <div class='dropdown'>
+ <button id="button_add" class="large">+</button>
+ <div id="dropdownDiv_add" class="dropdown-content">
+ <a id='dropdown_newCategory'>New Category</a>
+ <a id='dropdown_loadCategory'>Standard Category</a>
+ <a id='dropdown_separator'>Separator</a>
+ <a id='dropdown_loadStandardToolbox'>Standard Toolbox</a>
+ </div>
+ </div>
+
+ <button id="button_remove" class="large">-</button>
+
+ <button id="button_up" class="large">&#8593;</button>
+ <button id="button_down" class="large">&#8595;</button>
+
+ <br>
+ <div class='dropdown'>
+ <button id="button_editCategory">Edit Category</button>
+ <div id="dropdownDiv_editCategory" class="dropdown-content">
+ <a id='dropdown_name'>Name</a>
+ <a id='dropdown_color'>Color</a>
+ </div>
+ </div>
+
+ </aside>
+
+ <button id='button_addShadow' style='display:none'>Make Shadow</button>
+ <button id='button_removeShadow' style='display:none'>Remove Shadow</button>
+
+ <aside id='preload_div' style='display:none'>
+ <div id="preloadHelp">
+ <p>Configure the options for your Blockly inject call.</p>
+ <button id="button_optionsHelp">Help</button>
+ <button class="small" id="button_standardOptions">Reset to Default</button>
+ </div>
+ <div id="workspace_options">
+ <input type="checkbox" id="option_readOnly_checkbox" class="optionsInput">Read Only<br>
+ <input type="checkbox" id="option_collapse_checkbox" class="optionsInput">Collapsible Blocks<br>
+ <input type="checkbox" id="option_comments_checkbox" class="optionsInput">Comments for Blocks<br>
+ <input type="checkbox" id="option_css_checkbox" class="optionsInput">Use Blockly CSS<br>
+ <input type="checkbox" id="option_disable_checkbox" class="optionsInput">Disabled Blocks<br>
+ <input type="checkbox" id="option_grid_checkbox" class="optionsInput">Use Grid<br>
+ <div id="grid_options" name="grid" style="display:none">
+ Spacing <input type="number" id="gridOption_spacing_number" class="optionsInput" value="0"><br>
+ Length <input type="number" id="gridOption_length_number" class="optionsInput" value="1"><br>
+ Color <input type="text" id="gridOption_colour_text" class="optionsInput" value="#888"><br>
+ <input type="checkbox" id="gridOption_snap_checkbox" class="optionsInput" value="grid_snap_checkbox">Snap<br>
+ </div>
+ <input type="checkbox" id="option_infiniteBlocks_checkbox" class="optionsInput" value="checked">Infinite Blocks<br>
+ <div id="maxBlockNumber_option" style="display:none">
+ Max Blocks <input type="number" id="option_maxBlocks_number" class="optionsInput" value=100><br>
+ </div>
+ Path to Blockly Media <input type="text" id="option_media_text" class="optionsInput"><br>
+ <input type="checkbox" id="option_rtl_checkbox" class="optionsInput">Layout with RTL<br>
+ <input type="checkbox" id="option_scrollbars_checkbox" class="optionsInput">Scrollbars<br>
+ <input type="checkbox" id="option_sounds_checkbox" class="optionsInput">Sounds<br>
+ <div id="trashcan_option">
+ <input type="checkbox" id="option_trashcan_checkbox" class="optionsInput">Trashcan<br>
+ </div>
+ <input type="checkbox" id="option_zoom_checkbox" class="optionsInput">Zoom<br>
+ <div id="zoom_options" name="zoom" style="display:none">
+ <input type="checkbox" id="zoomOption_controls_checkbox" class="optionsInput">Zoom Controls<br>
+ <input type="checkbox" id="zoomOption_wheel_checkbox" class="optionsInput">Zoom Wheel<br>
+ Start Scale <input type="number" id="zoomOption_startScale_number" class="optionsInput" name="startScale" value="1.0"><br>
+ Max Scale <input type="number" id="zoomOption_maxScale_number" class="optionsInput" value="3"><br>
+ Min Scale <input type="number" id="zoomOption_minScale_number" class="optionsInput" value="0.3"><br>
+ Scale Speed <input type="number" id="zoomOption_scaleSpeed_number" class="optionsInput" value="1.2"><br>
+ </div>
+ </div>
+ </aside>
+
+
+ </section>
+
+ <aside id="previewDiv">
+ <div id="previewBorder">
+ <div id="previewHelp">
+ <h3>Preview</h3>
+ <p>This is what your custom workspace will look like.</p>
+ </div>
+ <div id="preview_blocks" class="content"></div>
+ </div>
+ </aside>
+ </div>
+
+ <!-- Blockly Factory Tab -->
+ <table id="blockFactoryContent">
+ <tr width="100%" height="10%">
+ <td width="50%" height="5%">
+ <table>
+ <tr id="blockLibrary">
+ <td id="blockLibraryContainer">
+ <span>
+ <div class='dropdown'>
+ <button id="button_blockLib">Block Library</button>
+ <div id="dropdownDiv_blockLib" class="dropdown-content">
+ <a id='createNewBlockButton'>Create New Block</a>
+ </div>
+ </div>
+ <select id="blockLibraryDropdown" style="display:none">
+ </select>
+ </span>
+ </td>
+ <td id="blockLibraryControls">
+ <button id="saveToBlockLibraryButton" title="Save block to Block Library.">
+ Save "block_type"
+ </button>
+ <button id="removeBlockFromLibraryButton" title="Remove block from Block Library.">
+ Delete "block_type"
+ </button>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td height="5%">
+ <table id="blockFactoryPreview">
+ <tr>
+ <td id="previewContainer">
+ <h3>Preview:
+ <select id="direction">
+ <option value="ltr">LTR</option>
+ <option value="rtl">RTL</option>
+ </select>
+ </h3>
+ </td>
+ <td id="buttonContainer">
+ <button id="linkButton" title="Save and link to blocks.">
+ <img src="link.png" height="21" width="21">
+ </button>
+ <button id="clearBlockLibraryButton" title="Clear Block Library.">
+ <span>Clear Library</span>
+ </button>
+ <label for="files" class="buttonStyle">
+ <span class=>Import Block Library</span>
+ </label>
+ <input id="files" type="file" name="files"
+ accept="application/xml">
+ <button id="localSaveButton" title="Save block library xml to a local file.">
+ <span>Download Block Library</span>
+ </button>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr height="80%">
+ <td id="blocklyWorkspaceContainer">
+ <div id="blockly"></div>
+ <div id="blocklyMask"></div>
+ </td>
+ <td width="50%">
+ <table id="blocklyPreviewContainer">
+ <tr>
+ <td height="30%">
+ <div id="preview"></div>
+ </td>
+ </tr>
+ <tr>
+ <td height="5%">
+ <h3>Block Definition:
+ <select id="format">
+ <option value="JSON">JSON</option>
+ <option value="JavaScript">JavaScript</option>
+ <option value="Manual">Manual edit&hellip;</option>
+ </select>
+ </h3>
+ </td>
+ </tr>
+ <tr>
+ <td height="30%">
+ <pre id="languagePre"></pre>
+ <textarea id="languageTA"></textarea>
+ </td>
+ </tr>
+ <tr>
+ <td height="5%">
+ <h3>Generator stub:
+ <select id="language">
+ <option value="JavaScript">JavaScript</option>
+ <option value="Python">Python</option>
+ <option value="PHP">PHP</option>
+ <option value="Lua">Lua</option>
+ <option value="Dart">Dart</option>
+ </select>
+ </h3>
+ </td>
+ </tr>
+ <tr>
+ <td height="30%">
+ <pre id="generatorPre"></pre>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+
+ <xml id="blockfactory_toolbox" class="toolbox">
+ <category name="Input">
+ <block type="input_value">
+ <value name="TYPE">
+ <shadow type="type_null"></shadow>
+ </value>
+ </block>
+ <block type="input_statement">
+ <value name="TYPE">
+ <shadow type="type_null"></shadow>
+ </value>
+ </block>
+ <block type="input_dummy"></block>
+ </category>
+ <category name="Field">
+ <block type="field_static"></block>
+ <block type="field_input"></block>
+ <block type="field_number"></block>
+ <block type="field_angle"></block>
+ <block type="field_dropdown"></block>
+ <block type="field_checkbox"></block>
+ <block type="field_colour"></block>
+ <!--
+ Date picker commented out since it increases footprint by 60%.
+ Add it only if you need it. See also goog.require in blockly.js.
+ <block type="field_date"></block>
+ -->
+ <block type="field_variable"></block>
+ <block type="field_image"></block>
+ </category>
+ <category name="Type">
+ <block type="type_group"></block>
+ <block type="type_null"></block>
+ <block type="type_boolean"></block>
+ <block type="type_number"></block>
+ <block type="type_string"></block>
+ <block type="type_list"></block>
+ <block type="type_other"></block>
+ </category>
+ <category name="Colour" id="colourCategory">
+ <block type="colour_hue"><mutation colour="20"></mutation><field name="HUE">20</field></block>
+ <block type="colour_hue"><mutation colour="65"></mutation><field name="HUE">65</field></block>
+ <block type="colour_hue"><mutation colour="120"></mutation><field name="HUE">120</field></block>
+ <block type="colour_hue"><mutation colour="160"></mutation><field name="HUE">160</field></block>
+ <block type="colour_hue"><mutation colour="210"></mutation><field name="HUE">210</field></block>
+ <block type="colour_hue"><mutation colour="230"></mutation><field name="HUE">230</field></block>
+ <block type="colour_hue"><mutation colour="260"></mutation><field name="HUE">260</field></block>
+ <block type="colour_hue"><mutation colour="290"></mutation><field name="HUE">290</field></block>
+ <block type="colour_hue"><mutation colour="330"></mutation><field name="HUE">330</field></block>
+ </category>
+ </xml>
+
+ <xml id="workspacefactory_toolbox" class="toolbox">
+ <category name="Logic" colour="210">
+ <block type="controls_if"></block>
+ <block type="logic_compare"></block>
+ <block type="logic_operation"></block>
+ <block type="logic_negate"></block>
+ <block type="logic_boolean"></block>
+ <block type="logic_null"></block>
+ <block type="logic_ternary"></block>
+ </category>
+ <category name="Loops" colour="120">
+ <block type="controls_repeat_ext">
+ <value name="TIMES">
+ <shadow type="math_number">
+ <field name="NUM">10</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="controls_whileUntil"></block>
+ <block type="controls_for">
+ <value name="FROM">
+ <shadow type="math_number">
+ <field name="NUM">1</field>
+ </shadow>
+ </value>
+ <value name="TO">
+ <shadow type="math_number">
+ <field name="NUM">10</field>
+ </shadow>
+ </value>
+ <value name="BY">
+ <shadow type="math_number">
+ <field name="NUM">1</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="controls_forEach"></block>
+ <block type="controls_flow_statements"></block>
+ </category>
+ <category name="Math" colour="230">
+ <block type="math_number"></block>
+ <block type="math_arithmetic">
+ <value name="A">
+ <shadow type="math_number">
+ <field name="NUM">1</field>
+ </shadow>
+ </value>
+ <value name="B">
+ <shadow type="math_number">
+ <field name="NUM">1</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_single">
+ <value name="NUM">
+ <shadow type="math_number">
+ <field name="NUM">9</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_trig">
+ <value name="NUM">
+ <shadow type="math_number">
+ <field name="NUM">45</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_constant"></block>
+ <block type="math_number_property">
+ <value name="NUMBER_TO_CHECK">
+ <shadow type="math_number">
+ <field name="NUM">0</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_round">
+ <value name="NUM">
+ <shadow type="math_number">
+ <field name="NUM">3.1</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_on_list"></block>
+ <block type="math_modulo">
+ <value name="DIVIDEND">
+ <shadow type="math_number">
+ <field name="NUM">64</field>
+ </shadow>
+ </value>
+ <value name="DIVISOR">
+ <shadow type="math_number">
+ <field name="NUM">10</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_constrain">
+ <value name="VALUE">
+ <shadow type="math_number">
+ <field name="NUM">50</field>
+ </shadow>
+ </value>
+ <value name="LOW">
+ <shadow type="math_number">
+ <field name="NUM">1</field>
+ </shadow>
+ </value>
+ <value name="HIGH">
+ <shadow type="math_number">
+ <field name="NUM">100</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_random_int">
+ <value name="FROM">
+ <shadow type="math_number">
+ <field name="NUM">1</field>
+ </shadow>
+ </value>
+ <value name="TO">
+ <shadow type="math_number">
+ <field name="NUM">100</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_random_float"></block>
+ </category>
+ <category name="Text" colour="160">
+ <block type="text"></block>
+ <block type="text_join"></block>
+ <block type="text_append">
+ <value name="TEXT">
+ <shadow type="text"></shadow>
+ </value>
+ </block>
+ <block type="text_length">
+ <value name="VALUE">
+ <shadow type="text">
+ <field name="TEXT">abc</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="text_isEmpty">
+ <value name="VALUE">
+ <shadow type="text">
+ <field name="TEXT"></field>
+ </shadow>
+ </value>
+ </block>
+ <block type="text_indexOf">
+ <value name="VALUE">
+ <block type="variables_get">
+ <field name="VAR">text</field>
+ </block>
+ </value>
+ <value name="FIND">
+ <shadow type="text">
+ <field name="TEXT">abc</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="text_charAt">
+ <value name="VALUE">
+ <block type="variables_get">
+ <field name="VAR">text</field>
+ </block>
+ </value>
+ </block>
+ <block type="text_getSubstring">
+ <value name="STRING">
+ <block type="variables_get">
+ <field name="VAR">text</field>
+ </block>
+ </value>
+ </block>
+ <block type="text_changeCase">
+ <value name="TEXT">
+ <shadow type="text">
+ <field name="TEXT">abc</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="text_trim">
+ <value name="TEXT">
+ <shadow type="text">
+ <field name="TEXT">abc</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="text_print">
+ <value name="TEXT">
+ <shadow type="text">
+ <field name="TEXT">abc</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="text_prompt_ext">
+ <value name="TEXT">
+ <shadow type="text">
+ <field name="TEXT">abc</field>
+ </shadow>
+ </value>
+ </block>
+ </category>
+ <category name="Lists" colour="260">
+ <block type="lists_create_with">
+ <mutation items="0"></mutation>
+ </block>
+ <block type="lists_create_with"></block>
+ <block type="lists_repeat">
+ <value name="NUM">
+ <shadow type="math_number">
+ <field name="NUM">5</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="lists_length"></block>
+ <block type="lists_isEmpty"></block>
+ <block type="lists_indexOf">
+ <value name="VALUE">
+ <block type="variables_get">
+ <field name="VAR">list</field>
+ </block>
+ </value>
+ </block>
+ <block type="lists_getIndex">
+ <value name="VALUE">
+ <block type="variables_get">
+ <field name="VAR">list</field>
+ </block>
+ </value>
+ </block>
+ <block type="lists_setIndex">
+ <value name="LIST">
+ <block type="variables_get">
+ <field name="VAR">list</field>
+ </block>
+ </value>
+ </block>
+ <block type="lists_getSublist">
+ <value name="LIST">
+ <block type="variables_get">
+ <field name="VAR">list</field>
+ </block>
+ </value>
+ </block>
+ <block type="lists_split">
+ <value name="DELIM">
+ <shadow type="text">
+ <field name="TEXT">,</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="lists_sort"></block>
+ </category>
+ <category name="Colour" colour="20">
+ <block type="colour_picker"></block>
+ <block type="colour_random"></block>
+ <block type="colour_rgb">
+ <value name="RED">
+ <shadow type="math_number">
+ <field name="NUM">100</field>
+ </shadow>
+ </value>
+ <value name="GREEN">
+ <shadow type="math_number">
+ <field name="NUM">50</field>
+ </shadow>
+ </value>
+ <value name="BLUE">
+ <shadow type="math_number">
+ <field name="NUM">0</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="colour_blend">
+ <value name="COLOUR1">
+ <shadow type="colour_picker">
+ <field name="COLOUR">#ff0000</field>
+ </shadow>
+ </value>
+ <value name="COLOUR2">
+ <shadow type="colour_picker">
+ <field name="COLOUR">#3333ff</field>
+ </shadow>
+ </value>
+ <value name="RATIO">
+ <shadow type="math_number">
+ <field name="NUM">0.5</field>
+ </shadow>
+ </value>
+ </block>
+ </category>
+ <sep></sep>
+ <category name="Variables" colour="330" custom="VARIABLE"></category>
+ <category name="Functions" colour="290" custom="PROCEDURE"></category>
+ <sep></sep>
+ <category name="Block Library" colour="260" id="blockLibCategory"></category>
+ </xml>
+
+</body>
+</html>
diff --git a/blockly/demos/blocklyfactory/link.png b/blockly/demos/blocklyfactory/link.png
new file mode 100644
index 0000000..11dfd82
--- /dev/null
+++ b/blockly/demos/blocklyfactory/link.png
Binary files differ
diff --git a/blockly/demos/blocklyfactory/standard_categories.js b/blockly/demos/blocklyfactory/standard_categories.js
new file mode 100644
index 0000000..ef102fc
--- /dev/null
+++ b/blockly/demos/blocklyfactory/standard_categories.js
@@ -0,0 +1,395 @@
+/**
+ * @license
+ * Visual Blocks Editor
+ *
+ * Copyright 2016 Google Inc.
+ * https://developers.google.com/blockly/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @fileoverview Contains a map of standard Blockly categories used to load
+ * standard Blockly categories into the user's toolbox. The map is keyed by
+ * the lower case name of the category, and contains the Category object for
+ * that particular category. Also has a list of core block types provided
+ * by Blockly.
+ *
+ * @author Emma Dauterman (evd2014)
+ */
+ 'use strict';
+
+/**
+ * Namespace for StandardCategories
+ */
+goog.provide('StandardCategories');
+
+// Map of standard category information necessary to add a standard category
+// to the toolbox.
+StandardCategories.categoryMap = Object.create(null);
+
+StandardCategories.categoryMap['logic'] =
+ new ListElement(ListElement.TYPE_CATEGORY, 'Logic');
+StandardCategories.categoryMap['logic'].xml =
+ Blockly.Xml.textToDom(
+ '<xml>' +
+ '<block type="controls_if"></block>' +
+ '<block type="logic_compare"></block>' +
+ '<block type="logic_operation"></block>' +
+ '<block type="logic_negate"></block>' +
+ '<block type="logic_boolean"></block>' +
+ '<block type="logic_null"></block>' +
+ '<block type="logic_ternary"></block>' +
+ '</xml>');
+StandardCategories.categoryMap['logic'].color ='#5C81A6';
+
+StandardCategories.categoryMap['loops'] =
+ new ListElement(ListElement.TYPE_CATEGORY, 'Loops');
+StandardCategories.categoryMap['loops'].xml =
+ Blockly.Xml.textToDom(
+ '<xml>' +
+ '<block type="controls_repeat_ext">' +
+ '<value name="TIMES">' +
+ '<shadow type="math_number">' +
+ '<field name="NUM">10</field>' +
+ '</shadow>' +
+ '</value>' +
+ '</block>' +
+ '<block type="controls_whileUntil"></block>' +
+ '<block type="controls_for">' +
+ '<value name="FROM">' +
+ '<shadow type="math_number">' +
+ '<field name="NUM">1</field>' +
+ '</shadow>' +
+ '</value>' +
+ '<value name="TO">' +
+ '<shadow type="math_number">' +
+ '<field name="NUM">10</field>' +
+ '</shadow>' +
+ '</value>' +
+ '<value name="BY">' +
+ '<shadow type="math_number">' +
+ '<field name="NUM">1</field>' +
+ '</shadow>' +
+ '</value>' +
+ '</block>' +
+ '<block type="controls_forEach"></block>' +
+ '<block type="controls_flow_statements"></block>' +
+ '</xml>');
+StandardCategories.categoryMap['loops'].color = '#5CA65C';
+
+StandardCategories.categoryMap['math'] =
+ new ListElement(ListElement.TYPE_CATEGORY, 'Math');
+StandardCategories.categoryMap['math'].xml =
+ Blockly.Xml.textToDom(
+ '<xml>' +
+ '<block type="math_number"></block>' +
+ '<block type="math_arithmetic">' +
+ '<value name="A">' +
+ '<shadow type="math_number">' +
+ '<field name="NUM">1</field>' +
+ '</shadow>' +
+ '</value>' +
+ '<value name="B">' +
+ '<shadow type="math_number">' +
+ '<field name="NUM">1</field>' +
+ '</shadow>' +
+ '</value>' +
+ '</block>' +
+ '<block type="math_single">' +
+ '<value name="NUM">' +
+ '<shadow type="math_number">' +
+ '<field name="NUM">9</field>' +
+ '</shadow>' +
+ '</value>' +
+ '</block>' +
+ '<block type="math_trig">' +
+ '<value name="NUM">' +
+ '<shadow type="math_number">' +
+ '<field name="NUM">45</field>' +
+ '</shadow>' +
+ '</value>' +
+ '</block>' +
+ '<block type="math_constant"></block>' +
+ '<block type="math_number_property">' +
+ '<value name="NUMBER_TO_CHECK">' +
+ '<shadow type="math_number">' +
+ '<field name="NUM">0</field>' +
+ '</shadow>' +
+ '</value>' +
+ '</block>' +
+ '<block type="math_round">' +
+ '<value name="NUM">' +
+ '<shadow type="math_number">' +
+ '<field name="NUM">3.1</field>' +
+ '</shadow>' +
+ '</value>' +
+ '</block>' +
+ '<block type="math_on_list"></block>' +
+ '<block type="math_modulo">' +
+ '<value name="DIVIDEND">' +
+ '<shadow type="math_number">' +
+ '<field name="NUM">64</field>' +
+ '</shadow>' +
+ '</value>' +
+ '<value name="DIVISOR">' +
+ '<shadow type="math_number">' +
+ '<field name="NUM">10</field>'+
+ '</shadow>' +
+ '</value>' +
+ '</block>' +
+ '<block type="math_constrain">' +
+ '<value name="VALUE">' +
+ '<shadow type="math_number">' +
+ '<field name="NUM">50</field>' +
+ '</shadow>' +
+ '</value>' +
+ '<value name="LOW">' +
+ '<shadow type="math_number">' +
+ '<field name="NUM">1</field>' +
+ '</shadow>' +
+ '</value>' +
+ '<value name="HIGH">' +
+ '<shadow type="math_number">' +
+ '<field name="NUM">100</field>' +
+ '</shadow>' +
+ '</value>' +
+ '</block>' +
+ '<block type="math_random_int">' +
+ '<value name="FROM">' +
+ '<shadow type="math_number">' +
+ '<field name="NUM">1</field>' +
+ '</shadow>' +
+ '</value>' +
+ '<value name="TO">' +
+ '<shadow type="math_number">' +
+ '<field name="NUM">100</field>' +
+ '</shadow>' +
+ '</value>' +
+ '</block>' +
+ '<block type="math_random_float"></block>' +
+ '</xml>');
+StandardCategories.categoryMap['math'].color = '#5C68A6';
+
+StandardCategories.categoryMap['text'] =
+ new ListElement(ListElement.TYPE_CATEGORY, 'Text');
+StandardCategories.categoryMap['text'].xml =
+ Blockly.Xml.textToDom(
+ '<xml>' +
+ '<block type="text"></block>' +
+ '<block type="text_join"></block>' +
+ '<block type="text_append">' +
+ '<value name="TEXT">' +
+ '<shadow type="text"></shadow>' +
+ '</value>' +
+ '</block>' +
+ '<block type="text_length">' +
+ '<value name="VALUE">' +
+ '<shadow type="text">' +
+ '<field name="TEXT">abc</field>' +
+ '</shadow>' +
+ '</value>' +
+ '</block>' +
+ '<block type="text_isEmpty">' +
+ '<value name="VALUE">' +
+ '<shadow type="text">' +
+ '<field name="TEXT"></field>' +
+ '</shadow>' +
+ '</value>' +
+ '</block>' +
+ '<block type="text_indexOf">' +
+ '<value name="VALUE">' +
+ '<block type="variables_get">' +
+ '<field name="VAR">text</field>' +
+ '</block>' +
+ '</value>' +
+ '<value name="FIND">' +
+ '<shadow type="text">' +
+ '<field name="TEXT">abc</field>' +
+ '</shadow>' +
+ '</value>' +
+ '</block>' +
+ '<block type="text_charAt">' +
+ '<value name="VALUE">' +
+ '<block type="variables_get">' +
+ '<field name="VAR">text</field>' +
+ '</block>' +
+ '</value>' +
+ '</block>' +
+ '<block type="text_getSubstring">' +
+ '<value name="STRING">' +
+ '<block type="variables_get">' +
+ '<field name="VAR">text</field>' +
+ '</block>' +
+ '</value>' +
+ '</block>' +
+ '<block type="text_changeCase">' +
+ '<value name="TEXT">' +
+ '<shadow type="text">' +
+ '<field name="TEXT">abc</field>' +
+ '</shadow>' +
+ '</value>' +
+ '</block>' +
+ '<block type="text_trim">' +
+ '<value name="TEXT">' +
+ '<shadow type="text">' +
+ '<field name="TEXT">abc</field>' +
+ '</shadow>' +
+ '</value>' +
+ '</block>' +
+ '<block type="text_print">' +
+ '<value name="TEXT">' +
+ '<shadow type="text">' +
+ '<field name="TEXT">abc</field>' +
+ '</shadow>' +
+ '</value>' +
+ '</block>' +
+ '<block type="text_prompt_ext">' +
+ '<value name="TEXT">' +
+ '<shadow type="text">' +
+ '<field name="TEXT">abc</field>' +
+ '</shadow>' +
+ '</value>' +
+ '</block>' +
+ '</xml>');
+StandardCategories.categoryMap['text'].color = '#5CA68D';
+
+StandardCategories.categoryMap['lists'] =
+ new ListElement(ListElement.TYPE_CATEGORY, 'Lists');
+StandardCategories.categoryMap['lists'].xml =
+ Blockly.Xml.textToDom(
+ '<xml>' +
+ '<block type="lists_create_with">' +
+ '<mutation items="0"></mutation>' +
+ '</block>' +
+ '<block type="lists_create_with"></block>' +
+ '<block type="lists_repeat">' +
+ '<value name="NUM">' +
+ '<shadow type="math_number">' +
+ '<field name="NUM">5</field>' +
+ '</shadow>' +
+ '</value>' +
+ '</block>' +
+ '<block type="lists_length"></block>' +
+ '<block type="lists_isEmpty"></block>' +
+ '<block type="lists_indexOf">' +
+ '<value name="VALUE">' +
+ '<block type="variables_get">' +
+ '<field name="VAR">list</field>' +
+ '</block>' +
+ '</value>' +
+ '</block>' +
+ '<block type="lists_getIndex">' +
+ '<value name="VALUE">' +
+ '<block type="variables_get">' +
+ '<field name="VAR">list</field>' +
+ '</block>' +
+ '</value>' +
+ '</block>' +
+ '<block type="lists_setIndex">' +
+ '<value name="LIST">' +
+ '<block type="variables_get">' +
+ '<field name="VAR">list</field>' +
+ '</block>' +
+ '</value>' +
+ '</block>' +
+ '<block type="lists_getSublist">' +
+ '<value name="LIST">' +
+ '<block type="variables_get">' +
+ '<field name="VAR">list</field>' +
+ '</block>' +
+ '</value>' +
+ '</block>' +
+ '<block type="lists_split">' +
+ '<value name="DELIM">' +
+ '<shadow type="text">' +
+ '<field name="TEXT">,</field>' +
+ '</shadow>' +
+ '</value>' +
+ '</block>' +
+ '<block type="lists_sort"></block>' +
+ '</xml>');
+StandardCategories.categoryMap['lists'].color = '#745CA6';
+
+StandardCategories.categoryMap['colour'] =
+ new ListElement(ListElement.TYPE_CATEGORY, 'Colour');
+StandardCategories.categoryMap['colour'].xml =
+ Blockly.Xml.textToDom(
+ '<xml>' +
+ '<block type="colour_picker"></block>' +
+ '<block type="colour_random"></block>' +
+ '<block type="colour_rgb">' +
+ '<value name="RED">' +
+ '<shadow type="math_number">' +
+ '<field name="NUM">100</field>' +
+ '</shadow>' +
+ '</value>' +
+ '<value name="GREEN">' +
+ '<shadow type="math_number">' +
+ '<field name="NUM">50</field>' +
+ '</shadow>' +
+ '</value>' +
+ '<value name="BLUE">' +
+ '<shadow type="math_number">' +
+ '<field name="NUM">0</field>' +
+ '</shadow>' +
+ '</value>' +
+ '</block>' +
+ '<block type="colour_blend">' +
+ '<value name="COLOUR1">' +
+ '<shadow type="colour_picker">' +
+ '<field name="COLOUR">#ff0000</field>' +
+ '</shadow>' +
+ '</value>' +
+ '<value name="COLOUR2">' +
+ '<shadow type="colour_picker">' +
+ '<field name="COLOUR">#3333ff</field>' +
+ '</shadow>' +
+ '</value>' +
+ '<value name="RATIO">' +
+ '<shadow type="math_number">' +
+ '<field name="NUM">0.5</field>' +
+ '</shadow>' +
+ '</value>' +
+ '</block>' +
+ '</xml>');
+StandardCategories.categoryMap['colour'].color = '#A6745C';
+
+StandardCategories.categoryMap['functions'] =
+ new ListElement(ListElement.TYPE_CATEGORY, 'Functions');
+StandardCategories.categoryMap['functions'].color = '#9A5CA6'
+StandardCategories.categoryMap['functions'].custom = 'PROCEDURE';
+
+StandardCategories.categoryMap['variables'] =
+ new ListElement(ListElement.TYPE_CATEGORY, 'Variables');
+StandardCategories.categoryMap['variables'].color = '#A65C81';
+StandardCategories.categoryMap['variables'].custom = 'VARIABLE';
+
+// All standard block types in provided in Blockly core.
+StandardCategories.coreBlockTypes = ["controls_if", "logic_compare",
+ "logic_operation", "logic_negate", "logic_boolean", "logic_null",
+ "logic_ternary", "controls_repeat_ext", "controls_whileUntil",
+ "controls_for", "controls_forEach", "controls_flow_statements",
+ "math_number", "math_arithmetic", "math_single", "math_trig",
+ "math_constant", "math_number_property", "math_change", "math_round",
+ "math_on_list", "math_modulo", "math_constrain", "math_random_int",
+ "math_random_float", "text", "text_join", "text_append", "text_length",
+ "text_isEmpty", "text_indexOf", "variables_get", "text_charAt",
+ "text_getSubstring", "text_changeCase", "text_trim", "text_print",
+ "text_prompt_ext", "colour_picker", "colour_random", "colour_rgb",
+ "colour_blend", "lists_create_with", "lists_repeat", "lists_length",
+ "lists_isEmpty", "lists_indexOf", "lists_getIndex", "lists_setIndex",
+ "lists_getSublist", "lists_split", "lists_sort", "variables_set",
+ "procedures_defreturn", "procedures_ifreturn", "procedures_defnoreturn",
+ "procedures_callreturn"];
+
diff --git a/blockly/demos/blocklyfactory/workspacefactory/index.html b/blockly/demos/blocklyfactory/workspacefactory/index.html
new file mode 100644
index 0000000..c45c449
--- /dev/null
+++ b/blockly/demos/blocklyfactory/workspacefactory/index.html
@@ -0,0 +1,847 @@
+<!DOCTYPE html>
+<html>
+<title>Blockly Workspace Factory</title>
+<script src="../../../blockly_compressed.js"></script>
+<script src="../../../javascript_compressed.js"></script>
+<script src="../../../msg/messages.js"></script>
+<script src="../../../blocks_compressed.js"></script>
+<script src="wfactory_model.js"></script>
+<script src="wfactory_controller.js"></script>
+<script src="wfactory_view.js"></script>
+<script src="wfactory_generator.js"></script>
+<script src="standard_categories.js"></script>
+<script src="../../../../closure-library/closure/goog/base.js"></script>
+<link rel="stylesheet" href="style.css">
+
+<script>
+goog.require('goog.ui.PopupColorPicker');
+goog.require('goog.ui.ColorPicker');
+</script>
+
+<table width="100%" height="100%">
+ <tr>
+ <td>
+ <h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt;
+ <a href="../index.html">Demos</a>&rlm; &gt;
+ <span id="title">Workspace Factory</span>
+ </h1>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>
+ <div class="dropdown">
+ <button id="button_import">Import</button>
+ <div id="dropdownDiv_import" class="dropdown-content">
+ <input type="file" id="input_importToolbox" class="inputfile"></input>
+ <label for="input_importToolbox">Toolbox</label>
+ <input type="file" id="input_importPreload" class="inputfile"></input>
+ <label for="input_importPreload">Workspace Blocks</label>
+ </div>
+ </div>
+
+ <div class="dropdown">
+ <button id="button_export">Export</button>
+ <div id="dropdownDiv_export" class="dropdown-content">
+ <a id='dropdown_exportToolbox'>Toolbox</a>
+ <a id='dropdown_exportPreload'>Workspace Blocks</a>
+ <a id='dropdown_exportOptions'>Inject Options</a>
+ <a id='dropdown_exportAll'>All</a>
+ </div>
+ </div>
+
+ <button id="button_print">Print Toolbox</button>
+ <button id="button_clear">Clear Toolbox</button>
+ </p>
+ </td>
+ </tr>
+</table>
+
+<section id="createDiv">
+ <p id="editHelpText">Drag blocks into your toolbox:</p>
+ <table id='workspaceTabs'>
+ <td id="tab_toolbox" class="tabon">Toolbox</td>
+ <td id="tab_preload" class="taboff">Workspace</td>
+ </table>
+ <section id="toolbox_section">
+ <div id="toolbox_blocks" class="content"></div>
+ <div id='disable_div'></div>
+ </section>
+
+ <aside id="toolbox_div">
+ <table id="categoryTable">
+ <td id="tab_help">Your categories will appear here</td>
+ </table>
+ <p>&nbsp;</p>
+
+ <div class='dropdown'>
+ <button id="button_add">+</button>
+ <div id="dropdownDiv_add" class="dropdown-content">
+ <a id='dropdown_newCategory'>New Category</a>
+ <a id='dropdown_loadCategory'>Standard Category</a>
+ <a id='dropdown_separator'>Separator</a>
+ </div>
+ </div>
+
+ <button id="button_remove">-</button>
+
+ <button id="button_up">&#8593;</button>
+ <button id="button_down">&#8595;</button>
+
+ <p>&nbsp;</p>
+ <div class='dropdown'>
+ <button id="button_editCategory">Edit Category</button>
+ <div id="dropdownDiv_editCategory" class="dropdown-content">
+ <a id='dropdown_name'>Name</a>
+ <a id='dropdown_color'>Color</a>
+ </div>
+ </div>
+
+ </aside>
+
+ <div class='dropdown'>
+ <button id="button_editShadow">Edit Block</button>
+ <div id="dropdownDiv_editShadowAdd" class="dropdown-content">
+ <a id='dropdown_addShadow'>Add Shadow</a>
+ </div>
+ <div id="dropdownDiv_editShadowRemove" class="dropdown-content">
+ <a id='dropdown_removeShadow'>Remove Shadow</a>
+ </div>
+ </div>
+
+ <aside id='preload_div' style='display:none'>
+ <p>Configure the <a href="https://developers.google.com/blockly/guides/get-started/web">options</a> for your Blockly inject call.</p>
+ <button class="small" id="button_standardOptions">Standard Options</button>
+ <form id="workspace_options">
+ <input type="checkbox" id="option_collapse_checkbox" name="collapse">Collapsible Blocks<br>
+ <input type="checkbox" id="option_comments_checkbox" name="comments">Comments for Blocks<br>
+ <input type="checkbox" id="option_css_checkbox" name="css">Use Blockly CSS<br>
+ <input type="checkbox" id="option_disable_checkbox" name="disable">Disabled Blocks<br>
+ <input type="checkbox" id="option_grid_checkbox" name="grid">Use Grid<br>
+ <div id="grid_options" name="grid" style="display:none">
+ Spacing <input type="text" id="gridOption_spacing_text" name="spacing" value="0"><br>
+ Length <input type="text" id="gridOption_length_text" name="length" value="1"><br>
+ Color <input type="text" id="gridOption_colour_text" name="colour" value="#888"><br>
+ <input type="checkbox" id="gridOption_snap_checkbox" value="grid_snap_checkbox" name="snap">Snap<br>
+ </div>
+ Max Blocks <input type="text" id="option_maxBlocks_text" name="maxBlocks" value="Infinity"><br>
+ Path to Blockly Media <input type="text" id="option_media_text" name="media"><br>
+ <input type="checkbox" id="option_readOnly_checkbox" name="readOnly">Read Only<br>
+ <input type="checkbox" id="option_rtl_checkbox" name="rtl">Layout with RTL<br>
+ <input type="checkbox" id="option_scrollbars_checkbox" name="scrollbars">Scrollbars<br>
+ <input type="checkbox" id="option_sounds_checkbox" name="sounds">Sounds<br>
+ <input type="checkbox" id="option_trashcan_checkbox" name="trashcan">Trashcan<br>
+ <input type="checkbox" id="option_zoom_checkbox" name="zoom">Zoom<br>
+ <div id="zoom_options" name="zoom" style="display:none">
+ <input type="checkbox" id="zoomOption_controls_checkbox" name="controls">Zoom Controls<br>
+ <input type="checkbox" id="zoomOption_wheel_checkbox" name="wheel">Zoom Wheel<br>
+ Start Scale <input type="text" id="zoomOption_startScale_text" name="startScale" value="1.0"><br>
+ Max Scale <input type="text" id="zoomOption_maxScale_text" name="maxScale" value="3"><br>
+ Min Scale <input type="text" id="zoomOption_minScale_text" name="minScale" value="0.3"><br>
+ Scale Speed <input type="text" id="zoomOption_scaleSpeed_text" name="scaleSpeed" value="1.2"><br>
+ </div>
+ </form>
+ </aside>
+
+</section>
+
+<aside id="previewDiv">
+ <p>Preview your workspace:</p>
+ <div id="preview_blocks" class="content"></div>
+</aside>
+
+<xml id="toolbox" style="display: none">
+ <category name="Logic" colour="210">
+ <block type="controls_if"></block>
+ <block type="logic_compare"></block>
+ <block type="logic_operation"></block>
+ <block type="logic_negate"></block>
+ <block type="logic_boolean"></block>
+ <block type="logic_null"></block>
+ <block type="logic_ternary"></block>
+ </category>
+ <category name="Loops" colour="120">
+ <block type="controls_repeat_ext">
+ <value name="TIMES">
+ <shadow type="math_number">
+ <field name="NUM">10</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="controls_whileUntil"></block>
+ <block type="controls_for">
+ <value name="FROM">
+ <shadow type="math_number">
+ <field name="NUM">1</field>
+ </shadow>
+ </value>
+ <value name="TO">
+ <shadow type="math_number">
+ <field name="NUM">10</field>
+ </shadow>
+ </value>
+ <value name="BY">
+ <shadow type="math_number">
+ <field name="NUM">1</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="controls_forEach"></block>
+ <block type="controls_flow_statements"></block>
+ </category>
+ <category name="Math" colour="230">
+ <block type="math_number"></block>
+ <block type="math_arithmetic">
+ <value name="A">
+ <shadow type="math_number">
+ <field name="NUM">1</field>
+ </shadow>
+ </value>
+ <value name="B">
+ <shadow type="math_number">
+ <field name="NUM">1</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_single">
+ <value name="NUM">
+ <shadow type="math_number">
+ <field name="NUM">9</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_trig">
+ <value name="NUM">
+ <shadow type="math_number">
+ <field name="NUM">45</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_constant"></block>
+ <block type="math_number_property">
+ <value name="NUMBER_TO_CHECK">
+ <shadow type="math_number">
+ <field name="NUM">0</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_change">
+ <value name="DELTA">
+ <shadow type="math_number">
+ <field name="NUM">1</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_round">
+ <value name="NUM">
+ <shadow type="math_number">
+ <field name="NUM">3.1</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_on_list"></block>
+ <block type="math_modulo">
+ <value name="DIVIDEND">
+ <shadow type="math_number">
+ <field name="NUM">64</field>
+ </shadow>
+ </value>
+ <value name="DIVISOR">
+ <shadow type="math_number">
+ <field name="NUM">10</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_constrain">
+ <value name="VALUE">
+ <shadow type="math_number">
+ <field name="NUM">50</field>
+ </shadow>
+ </value>
+ <value name="LOW">
+ <shadow type="math_number">
+ <field name="NUM">1</field>
+ </shadow>
+ </value>
+ <value name="HIGH">
+ <shadow type="math_number">
+ <field name="NUM">100</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_random_int">
+ <value name="FROM">
+ <shadow type="math_number">
+ <field name="NUM">1</field>
+ </shadow>
+ </value>
+ <value name="TO">
+ <shadow type="math_number">
+ <field name="NUM">100</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_random_float"></block>
+ </category>
+ <category name="Text" colour="160">
+ <block type="text"></block>
+ <block type="text_join"></block>
+ <block type="text_append">
+ <value name="TEXT">
+ <shadow type="text"></shadow>
+ </value>
+ </block>
+ <block type="text_length">
+ <value name="VALUE">
+ <shadow type="text">
+ <field name="TEXT">abc</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="text_isEmpty">
+ <value name="VALUE">
+ <shadow type="text">
+ <field name="TEXT"></field>
+ </shadow>
+ </value>
+ </block>
+ <block type="text_indexOf">
+ <value name="VALUE">
+ <block type="variables_get">
+ <field name="VAR">text</field>
+ </block>
+ </value>
+ <value name="FIND">
+ <shadow type="text">
+ <field name="TEXT">abc</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="text_charAt">
+ <value name="VALUE">
+ <block type="variables_get">
+ <field name="VAR">text</field>
+ </block>
+ </value>
+ </block>
+ <block type="text_getSubstring">
+ <value name="STRING">
+ <block type="variables_get">
+ <field name="VAR">text</field>
+ </block>
+ </value>
+ </block>
+ <block type="text_changeCase">
+ <value name="TEXT">
+ <shadow type="text">
+ <field name="TEXT">abc</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="text_trim">
+ <value name="TEXT">
+ <shadow type="text">
+ <field name="TEXT">abc</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="text_print">
+ <value name="TEXT">
+ <shadow type="text">
+ <field name="TEXT">abc</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="text_prompt_ext">
+ <value name="TEXT">
+ <shadow type="text">
+ <field name="TEXT">abc</field>
+ </shadow>
+ </value>
+ </block>
+ </category>
+ <category name="Lists" colour="260">
+ <block type="lists_create_with">
+ <mutation items="0"></mutation>
+ </block>
+ <block type="lists_create_with"></block>
+ <block type="lists_repeat">
+ <value name="NUM">
+ <shadow type="math_number">
+ <field name="NUM">5</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="lists_length"></block>
+ <block type="lists_isEmpty"></block>
+ <block type="lists_indexOf">
+ <value name="VALUE">
+ <block type="variables_get">
+ <field name="VAR">list</field>
+ </block>
+ </value>
+ </block>
+ <block type="lists_getIndex">
+ <value name="VALUE">
+ <block type="variables_get">
+ <field name="VAR">list</field>
+ </block>
+ </value>
+ </block>
+ <block type="lists_setIndex">
+ <value name="LIST">
+ <block type="variables_get">
+ <field name="VAR">list</field>
+ </block>
+ </value>
+ </block>
+ <block type="lists_getSublist">
+ <value name="LIST">
+ <block type="variables_get">
+ <field name="VAR">list</field>
+ </block>
+ </value>
+ </block>
+ <block type="lists_split">
+ <value name="DELIM">
+ <shadow type="text">
+ <field name="TEXT">,</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="lists_sort"></block>
+ </category>
+ <category name="Colour" colour="20">
+ <block type="colour_picker"></block>
+ <block type="colour_random"></block>
+ <block type="colour_rgb">
+ <value name="RED">
+ <shadow type="math_number">
+ <field name="NUM">100</field>
+ </shadow>
+ </value>
+ <value name="GREEN">
+ <shadow type="math_number">
+ <field name="NUM">50</field>
+ </shadow>
+ </value>
+ <value name="BLUE">
+ <shadow type="math_number">
+ <field name="NUM">0</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="colour_blend">
+ <value name="COLOUR1">
+ <shadow type="colour_picker">
+ <field name="COLOUR">#ff0000</field>
+ </shadow>
+ </value>
+ <value name="COLOUR2">
+ <shadow type="colour_picker">
+ <field name="COLOUR">#3333ff</field>
+ </shadow>
+ </value>
+ <value name="RATIO">
+ <shadow type="math_number">
+ <field name="NUM">0.5</field>
+ </shadow>
+ </value>
+ </block>
+ </category>
+ <sep></sep>
+ <category name="Variables" colour="330" custom="VARIABLE"></category>
+ <category name="Functions" colour="290" custom="PROCEDURE"></category>
+</xml>
+<script type="text/javascript">
+ // Array of Blockly category colors, variety of hues with saturation 45%
+ // and value 65% as specified in Blockly Developer documentation:
+ // https://developers.google.com/blockly/guides/create-custom-blocks/define-blocks
+ var colors = ['#A65C5C',
+ '#A6635C',
+ '#A66A5C',
+ '#A6725C',
+ '#A6795C',
+ '#A6815C',
+ '#A6885C',
+ '#A6905C',
+ '#A6975C',
+ '#A69F5C',
+ '#A6A65C',
+ '#9FA65C',
+ '#97A65C',
+ '#90A65C',
+ '#88A65C',
+ '#81A65C',
+ '#79A65C',
+ '#6FA65C',
+ '#66A65C',
+ '#5EA65C',
+ '#5CA661',
+ '#5CA668',
+ '#5CA66F',
+ '#5CA677',
+ '#5CA67E',
+ '#5CA686',
+ '#5CA68D',
+ '#5CA695',
+ '#5CA69C',
+ '#5CA6A4',
+ '#5CA1A6',
+ '#5C9AA6',
+ '#5C92A6',
+ '#5C8BA6',
+ '#5C83A6',
+ '#5C7CA6',
+ '#5C74A6',
+ '#5C6AA6',
+ '#5C61A6',
+ '#5E5CA6',
+ '#665CA6',
+ '#6D5CA6',
+ '#745CA6',
+ '#7C5CA6',
+ '#835CA6',
+ '#8B5CA6',
+ '#925CA6',
+ '#9A5CA6',
+ '#A15CA6',
+ '#A65CA4',
+ '#A65C9C',
+ '#A65C95',
+ '#A65C8D',
+ '#A65C86',
+ '#A65C7E',
+ '#A65C77',
+ '#A65C6F',
+ '#A65C66',
+ '#A65C61',
+ '#A65C5E'];
+
+ // Create empty workspace for configuring workspace.
+ var toolboxWorkspace = Blockly.inject('toolbox_blocks',
+ {grid:
+ {spacing: 25,
+ length: 3,
+ colour: '#ccc',
+ snap: true},
+ media: '../../../media/',
+ toolbox: toolbox,
+ });
+ // Create empty workspace for previewing created workspace.
+ var previewWorkspace = Blockly.inject('preview_blocks',
+ {grid:
+ {spacing: 25,
+ length: 3,
+ colour: '#ccc',
+ snap: true},
+ media: '../../../media/',
+ toolbox: '<xml></xml>',
+ zoom:
+ {controls: true,
+ wheel: true}
+ });
+
+ var controller = new WorkspaceFactoryController(toolboxWorkspace, previewWorkspace);
+
+ // Wrappers to attach buttons to method calls for the controller object
+ var addWrapper = function() {
+ document.getElementById('dropdownDiv_add').classList.toggle("show");
+ };
+ var newCategoryWrapper = function() {
+ controller.addCategory();
+ document.getElementById('dropdownDiv_add').classList.remove("show");
+ };
+ var loadCategoryWrapper = function() {
+ controller.loadCategory();
+ document.getElementById('dropdownDiv_add').classList.remove("show");
+ };
+ var separatorWrapper = function() {
+ controller.addSeparator();
+ document.getElementById('dropdownDiv_add').classList.remove("show");
+ };
+ var removeWrapper = function() {
+ controller.removeElement();
+ };
+ var exportWrapper = function() {
+ document.getElementById('dropdownDiv_export').classList.toggle("show");
+ document.getElementById('dropdownDiv_import').classList.remove("show");
+ };
+ var printWrapper = function() {
+ controller.printConfig();
+ };
+ var upWrapper = function() {
+ controller.moveElement(-1);
+ };
+ var downWrapper = function() {
+ controller.moveElement(1);
+ };
+ var editCategoryWrapper = function() {
+ document.getElementById('dropdownDiv_editCategory').classList.toggle("show");
+ };
+ var nameWrapper = function() {
+ controller.changeCategoryName();
+ document.getElementById('dropdownDiv_editCategory').classList.remove("show");
+ };
+ var shadowAddWrapper = function() {
+ controller.addShadow();
+ document.getElementById('dropdownDiv_editShadowAdd').classList.remove("show");
+ };
+ var shadowRemoveWrapper = function() {
+ controller.removeShadow();
+ document.getElementById('dropdownDiv_editShadowRemove').classList.remove("show");
+ // If turning invalid shadow block back to normal block, remove warning and disable
+ // block editing privileges.
+ Blockly.selected.setWarningText(null);
+ if (!Blockly.selected.getSurroundParent()) {
+ document.getElementById('button_editShadow').disabled = true;
+ }
+ };
+ var editShadowWrapper = function() {
+ if (Blockly.selected) {
+ // Can only edit blocks when a block is selected.
+
+ if (!controller.isUserGenShadowBlock(Blockly.selected.id) && Blockly.selected.getSurroundParent() != null) {
+ // If a block is selected that could be a valid shadow block (not a shadow block,
+ // has a surrounding parent), let the user make it a shadow block.
+ // Use toggle instead of add so that the user can click the button again
+ // to make the dropdown disappear without clicking one of the options.
+ document.getElementById('dropdownDiv_editShadowRemove').classList.remove("show");
+ document.getElementById('dropdownDiv_editShadowAdd').classList.toggle("show");
+ } else {
+ // If the block is a shadow block, let the user make it a normal block.
+ document.getElementById('dropdownDiv_editShadowAdd').classList.remove("show");
+ document.getElementById('dropdownDiv_editShadowRemove').classList.toggle("show");
+ }
+ }
+ };
+ var importWrapper = function() {
+ document.getElementById('dropdownDiv_import').classList.toggle("show");
+ document.getElementById('dropdownDiv_export').classList.remove("show");
+ };
+ var clearWrapper = function() {
+ controller.clearToolbox();
+ };
+ var editToolboxWrapper = function() {
+ controller.setMode(WorkspaceFactoryController.MODE_TOOLBOX);
+ };
+ var editPreloadWrapper = function() {
+ controller.setMode(WorkspaceFactoryController.MODE_PRELOAD);
+ };
+ var importToolboxWrapper = function(e) {
+ controller.importFile(event.target.files[0], WorkspaceFactoryController.MODE_TOOLBOX);
+ document.getElementById('dropdownDiv_import').classList.remove("show");
+ };
+ var importPreloadWrapper = function(e) {
+ controller.importFile(event.target.files[0], WorkspaceFactoryController.MODE_PRELOAD);
+ document.getElementById('dropdownDiv_import').classList.remove("show");
+ };
+ var editToolboxWrapper = function() {
+ controller.setMode(WorkspaceFactoryController.MODE_TOOLBOX);
+ };
+ var editPreloadWrapper = function() {
+ controller.setMode(WorkspaceFactoryController.MODE_PRELOAD);
+ };
+ var exportToolboxWrapper = function() {
+ controller.exportFile(WorkspaceFactoryController.MODE_TOOLBOX);
+ document.getElementById('dropdownDiv_export').classList.remove("show");
+ }
+ var exportPreloadWrapper = function() {
+ controller.exportXmlFile(WorkspaceFactoryController.MODE_PRELOAD);
+ document.getElementById('dropdownDiv_export').classList.remove("show");
+ }
+ var exportOptionsWrapper = function() {
+ controller.exportOptionsFile();
+ document.getElementById('dropdownDiv_export').classList.remove("show");
+ }
+ var exportAllWrapper = function() {
+ controller.exportXmlFile(WorkspaceFactoryController.MODE_TOOLBOX);
+ controller.exportXmlFile(WorkspaceFactoryController.MODE_PRELOAD);
+ controller.exportOptionsFile();
+ document.getElementById('dropdownDiv_export').classList.remove("show");
+ }
+ var standardOptionsWrapper = function() {
+ controller.setStandardOptionsAndUpdate();
+ };
+
+ document.getElementById('button_add').addEventListener
+ ('click', addWrapper);
+ document.getElementById('dropdown_newCategory').addEventListener
+ ('click', newCategoryWrapper);
+ document.getElementById('dropdown_loadCategory').addEventListener
+ ('click', loadCategoryWrapper);
+ document.getElementById('dropdown_separator').addEventListener
+ ('click', separatorWrapper);
+ document.getElementById('button_remove').addEventListener
+ ('click', removeWrapper);
+ document.getElementById('dropdown_exportToolbox').addEventListener
+ ('click', exportToolboxWrapper);
+ document.getElementById('dropdown_exportPreload').addEventListener
+ ('click', exportPreloadWrapper);
+ document.getElementById('dropdown_exportOptions').addEventListener
+ ('click', exportOptionsWrapper);
+ document.getElementById('dropdown_exportAll').addEventListener
+ ('click', exportAllWrapper);
+ document.getElementById('button_export').addEventListener
+ ('click', exportWrapper);
+ document.getElementById('button_print').addEventListener
+ ('click', printWrapper);
+ document.getElementById('button_up').addEventListener
+ ('click', upWrapper);
+ document.getElementById('button_down').addEventListener
+ ('click', downWrapper);
+ document.getElementById('button_editCategory').addEventListener
+ ('click', editCategoryWrapper);
+ document.getElementById('button_editShadow').addEventListener
+ ('click', editShadowWrapper);
+ document.getElementById('dropdown_name').addEventListener
+ ('click', nameWrapper);
+ document.getElementById('button_import').addEventListener
+ ('click', importWrapper);
+ document.getElementById('input_importToolbox').addEventListener
+ ('change', importToolboxWrapper);
+ document.getElementById('input_importPreload').addEventListener
+ ('change', importPreloadWrapper);
+ document.getElementById('button_clear').addEventListener
+ ('click', clearWrapper);
+ document.getElementById('dropdown_addShadow').addEventListener
+ ('click', shadowAddWrapper);
+ document.getElementById('dropdown_removeShadow').addEventListener
+ ('click', shadowRemoveWrapper);
+ document.getElementById('tab_toolbox').addEventListener
+ ('click', editToolboxWrapper);
+ document.getElementById('tab_preload').addEventListener
+ ('click', editPreloadWrapper);
+ document.getElementById('button_standardOptions').addEventListener
+ ('click', standardOptionsWrapper);
+
+ // Use up and down arrow keys to move categories.
+ // TODO(evd2014): When merge with next CL for editing preloaded blocks, make sure
+ // mode is toolbox.
+ window.addEventListener('keydown', function(e) {
+ if (e.keyCode == 38) { // Arrow up.
+ upWrapper();
+ } else if (e.keyCode == 40) { // Arrow down.
+ downWrapper();
+ }
+ });
+
+ // Create color picker with specific set of Blockly colors.
+ var colorPicker = new goog.ui.ColorPicker();
+ colorPicker.setColors(colors);
+ // Create and render the popup color picker and attach to button.
+ var popupPicker = new goog.ui.PopupColorPicker(null, colorPicker);
+ popupPicker.render();
+ popupPicker.attach(document.getElementById('dropdown_color'));
+ popupPicker.setFocusable(true);
+ goog.events.listen(popupPicker, 'change', function(e) {
+ controller.changeSelectedCategoryColor(popupPicker.getSelectedColor());
+ document.getElementById('dropdownDiv_editCategory').classList.remove
+ ("show");
+ });
+
+ // Disable category editing buttons until categories are created.
+ document.getElementById('button_remove').disabled = true;
+ document.getElementById('button_up').disabled = true;
+ document.getElementById('button_down').disabled = true;
+ document.getElementById('button_editCategory').disabled = true;
+ document.getElementById('button_editShadow').disabled = true;
+
+ toolboxWorkspace.addChangeListener(function(e) {
+ // Listen for Blockly move and delete events to update preview.
+ // Not listening for Blockly create events because causes the user to drop
+ // blocks when dragging them into workspace. Could cause problems if ever load
+ // blocks into workspace directly without calling updatePreview.
+ if (e.type == Blockly.Events.MOVE || e.type == Blockly.Events.DELETE) {
+ controller.saveStateFromWorkspace();
+ controller.updatePreview();
+ }
+
+ // Listen for Blockly UI events to correctly enable the "Edit Block" button.
+ // Only enable "Edit Block" when a block is selected and it has a surrounding
+ // parent, meaning it is nested in another block (blocks that are not
+ // nested in parents cannot be shadow blocks).
+ if (e.type == Blockly.Events.MOVE || (e.type == Blockly.Events.UI &&
+ e.element == 'selected')) {
+ var selected = Blockly.selected;
+
+ if (selected != null && selected.getSurroundParent() != null) {
+
+ // A valid shadow block is selected. Enable block editing and remove warnings.
+ document.getElementById('button_editShadow').disabled = false;
+ Blockly.selected.setWarningText(null);
+ } else {
+ if (selected != null && controller.isUserGenShadowBlock(selected.id)) {
+
+ // Provide warning if shadow block is moved and is no longer a valid shadow block.
+ Blockly.selected.setWarningText('Shadow blocks must be nested inside other' +
+ ' blocks to be displayed.');
+
+ // Give editing options so that the user can make an invalid shadow block
+ // a normal block.
+ document.getElementById('button_editShadow').disabled = false;
+ } else {
+
+ // No block selected that is a shadow block or could be a valid shadow block.
+ // Disable block editing.
+ document.getElementById('button_editShadow').disabled = true;
+ document.getElementById('dropdownDiv_editShadowRemove').classList.remove("show");
+ document.getElementById('dropdownDiv_editShadowAdd').classList.remove("show");
+ }
+ }
+ }
+
+ // Convert actual shadow blocks added from the toolbox to user-generated shadow blocks.
+ if (e.type == Blockly.Events.CREATE) {
+ controller.convertShadowBlocks();
+ }
+ });
+
+ // Add event listeners for checkboxes and text fields for configuring the Options object.
+
+ // Checking the grid checkbox displays grid options and updates the options
+ // object.
+ document.getElementById('option_grid_checkbox').addEventListener('change', function(e) {
+ document.getElementById('grid_options').style.display = document.getElementById('option_grid_checkbox').checked ? 'block' : 'none';
+ controller.generateNewOptions();
+ });
+
+ // Checking the grid checkbox displays zoom options and updates the options
+ // object.
+ document.getElementById('option_zoom_checkbox').addEventListener('change', function(e) {
+ document.getElementById('zoom_options').style.display = document.getElementById('option_zoom_checkbox').checked ? 'block' : 'none';
+ controller.generateNewOptions();
+ });
+
+ var optionListener = function() {
+ controller.generateNewOptions();
+ };
+
+ // Add event listeners to generate new options for each options input field.
+ document.getElementById('option_collapse_checkbox').addEventListener('change', optionListener);
+ document.getElementById('option_comments_checkbox').addEventListener('change', optionListener);
+ document.getElementById('option_css_checkbox').addEventListener('change', optionListener);
+ document.getElementById('option_disable_checkbox').addEventListener('change', optionListener);
+ document.getElementById('gridOption_spacing_text').addEventListener('change', optionListener);
+ document.getElementById('gridOption_length_text').addEventListener('change', optionListener);
+ document.getElementById('gridOption_colour_text').addEventListener('change', optionListener);
+ document.getElementById('gridOption_snap_checkbox').addEventListener('change', optionListener);
+ document.getElementById('option_maxBlocks_text').addEventListener('change', optionListener);
+ document.getElementById('option_media_text').addEventListener('change', optionListener);
+ document.getElementById('option_readOnly_checkbox').addEventListener('change', optionListener);
+ document.getElementById('option_rtl_checkbox').addEventListener('change', optionListener);
+ document.getElementById('option_scrollbars_checkbox').addEventListener('change', optionListener);
+ document.getElementById('option_sounds_checkbox').addEventListener('change', optionListener);
+ document.getElementById('option_trashcan_checkbox').addEventListener('change', optionListener);
+ document.getElementById('zoomOption_controls_checkbox').addEventListener('change', optionListener);
+ document.getElementById('zoomOption_wheel_checkbox').addEventListener('change', optionListener);
+ document.getElementById('zoomOption_startScale_text').addEventListener('change', optionListener);
+ document.getElementById('zoomOption_maxScale_text').addEventListener('change', optionListener);
+ document.getElementById('zoomOption_minScale_text').addEventListener('change', optionListener);
+ document.getElementById('zoomOption_scaleSpeed_text').addEventListener('change', optionListener);
+
+ // Check standard options and apply the changes to update the view.
+ controller.setStandardOptionsAndUpdate();
+
+</script>
+</html>
diff --git a/blockly/demos/blocklyfactory/workspacefactory/style.css b/blockly/demos/blocklyfactory/workspacefactory/style.css
new file mode 100644
index 0000000..3acb321
--- /dev/null
+++ b/blockly/demos/blocklyfactory/workspacefactory/style.css
@@ -0,0 +1,224 @@
+body {
+ background-color: #fff;
+ font-family: sans-serif;
+}
+
+h1 {
+ font-weight: normal;
+ font-size: 140%;
+}
+
+section {
+ float: left;
+}
+
+aside {
+ float: right;
+}
+
+#categoryTable>table {
+ border: 1px solid #ccc;
+ border-bottom: none;
+}
+
+#workspaceTabs>table {
+ float: right;
+}
+
+td.tabon {
+ border-bottom-color: #ddd !important;
+ background-color: #ddd;
+ padding: 5px 19px;
+}
+
+td.taboff {
+ cursor: pointer;
+ padding: 5px 19px;
+}
+
+td.taboff:hover {
+ background-color: #eee;
+}
+
+button {
+ border-radius: 4px;
+ border: 1px solid #ddd;
+ background-color: #eee;
+ color: #000;
+ font-size: large;
+ margin: 0 5px;
+ padding: 10px;
+}
+
+button:hover:not(:disabled) {
+ box-shadow: 2px 2px 5px #888;
+}
+
+button:disabled {
+ opacity: .6;
+}
+
+button>* {
+ opacity: .6;
+ vertical-align: text-bottom;
+}
+
+button:hover:not(:disabled)>* {
+ opacity: 1;
+}
+
+button.small {
+ font-size: small;
+}
+
+table {
+ border: none;
+ border-collapse: collapse;
+ margin: 0;
+ padding: 0;
+}
+
+td {
+ padding: 0;
+ vertical-align: top;
+}
+
+.inputfile {
+ height: 0;
+ opacity: 0;
+ overflow: hidden;
+ position: absolute;
+ width: 0;
+ z-index: -1;
+}
+
+#toolbox_section {
+ height: 480px;
+ width: 80%;
+ position: relative;
+}
+
+#toolbox_blocks {
+ height: 100%;
+ width: 100%;
+}
+
+#preview_blocks {
+ height: 300px;
+ width: 100%;
+}
+
+#createDiv {
+ width: 70%;
+}
+
+#previewDiv {
+ width: 30%;
+}
+
+#toolbox_div {
+ width: 20%;
+}
+
+#preload_div {
+ width: 20%;
+}
+
+#disable_div {
+ background-color: white;
+ height: 100%;
+ left: 0;
+ opacity: .5;
+ position: absolute;
+ top: 0;
+ width: 100%;
+ z-index: -1; /* Start behind workspace */
+}
+
+/* Rules for Closure popup color picker */
+.goog-palette {
+ outline: none;
+ cursor: default;
+}
+
+.goog-palette-cell {
+ height: 13px;
+ width: 15px;
+ margin: 0;
+ border: 0;
+ text-align: center;
+ vertical-align: middle;
+ border-right: 1px solid #000000;
+ font-size: 1px;
+}
+
+.goog-palette-colorswatch {
+ border: 1px solid #000000;
+ height: 13px;
+ position: relative;
+ width: 15px;
+}
+
+.goog-palette-cell-hover .goog-palette-colorswatch {
+ border: 1px solid #FFF;
+}
+
+.goog-palette-cell-selected .goog-palette-colorswatch {
+ border: 1px solid #000;
+ color: #fff;
+}
+
+.goog-palette-table {
+ border: 1px solid #000;
+ border-collapse: collapse;
+}
+
+.goog-popupcolorpicker {
+ position: absolute;
+}
+
+/* The container <div> - needed to position the dropdown content */
+.dropdown {
+ position: relative;
+ display: inline-block;
+}
+
+/* Dropdown Content (Hidden by Default) */
+.dropdown-content {
+ background-color: #f9f9f9;
+ box-shadow: 0px 8px 16px 0px rgba(0,0,0,.2);
+ display: none;
+ min-width: 170px;
+ opacity: 1;
+ position: absolute;
+ z-index: 1;
+}
+
+/* Links inside the dropdown */
+.dropdown-content a, .dropdown-content label {
+ color: black;
+ display: block;
+ font-size: small;
+ padding: 12px 16px;
+ text-decoration: none;
+}
+
+/* Change color of dropdown links on hover. */
+.dropdown-content a:hover, .dropdown-content label:hover {
+ background-color: #f1f1f1
+}
+
+/* Show the dropdown menu */
+.show {
+ display: block;
+}
+
+.shadowBlock>.blocklyPath {
+ fill-opacity: .5;
+ stroke-opacity: .5;
+}
+
+.shadowBlock>.blocklyPathLight,
+.shadowBlock>.blocklyPathDark {
+ display: none;
+}
diff --git a/blockly/demos/blocklyfactory/workspacefactory/wfactory_controller.js b/blockly/demos/blocklyfactory/workspacefactory/wfactory_controller.js
new file mode 100644
index 0000000..faf3c09
--- /dev/null
+++ b/blockly/demos/blocklyfactory/workspacefactory/wfactory_controller.js
@@ -0,0 +1,1344 @@
+/**
+ * @license
+ * Visual Blocks Editor
+ *
+ * Copyright 2016 Google Inc.
+ * https://developers.google.com/blockly/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @fileoverview Contains the controller code for workspace factory. Depends
+ * on the model and view objects (created as internal variables) and interacts
+ * with previewWorkspace and toolboxWorkspace (internal references stored to
+ * both). Also depends on standard_categories.js for standard Blockly
+ * categories. Provides the functionality for the actions the user can initiate:
+ * - adding and removing categories
+ * - switching between categories
+ * - printing and downloading configuration xml
+ * - updating the preview workspace
+ * - changing a category name
+ * - moving the position of a category.
+ *
+ * @author Emma Dauterman (evd2014)
+ */
+
+ goog.require('FactoryUtils');
+ goog.require('StandardCategories');
+
+/**
+ * Class for a WorkspaceFactoryController
+ * @constructor
+ *
+ * @param {!string} toolboxName Name of workspace toolbox XML.
+ * @param {!string} toolboxDiv Name of div to inject toolbox workspace in.
+ * @param {!string} previewDiv Name of div to inject preview workspace in.
+ */
+WorkspaceFactoryController = function(toolboxName, toolboxDiv, previewDiv) {
+ // Toolbox XML element for the editing workspace.
+ this.toolbox = document.getElementById(toolboxName);
+
+ // Workspace for user to drag blocks in for a certain category.
+ this.toolboxWorkspace = Blockly.inject(toolboxDiv,
+ {grid:
+ {spacing: 25,
+ length: 3,
+ colour: '#ccc',
+ snap: true},
+ media: '../../media/',
+ toolbox: this.toolbox
+ });
+
+ // Workspace for user to preview their changes.
+ this.previewWorkspace = Blockly.inject(previewDiv,
+ {grid:
+ {spacing: 25,
+ length: 3,
+ colour: '#ccc',
+ snap: true},
+ media: '../../media/',
+ toolbox: '<xml></xml>',
+ zoom:
+ {controls: true,
+ wheel: true}
+ });
+
+ // Model to keep track of categories and blocks.
+ this.model = new WorkspaceFactoryModel();
+ // Updates the category tabs.
+ this.view = new WorkspaceFactoryView();
+ // Generates XML for categories.
+ this.generator = new WorkspaceFactoryGenerator(this.model);
+ // Tracks which editing mode the user is in. Toolbox mode on start.
+ this.selectedMode = WorkspaceFactoryController.MODE_TOOLBOX;
+ // True if key events are enabled, false otherwise.
+ this.keyEventsEnabled = true;
+ // True if there are unsaved changes in the toolbox, false otherwise.
+ this.hasUnsavedToolboxChanges = false;
+ // True if there are unsaved changes in the preloaded blocks, false otherwise.
+ this.hasUnsavedPreloadChanges = false;
+};
+
+// Toolbox editing mode. Changes the user makes to the workspace updates the
+// toolbox.
+WorkspaceFactoryController.MODE_TOOLBOX = 'toolbox';
+// Pre-loaded workspace editing mode. Changes the user makes to the workspace
+// udpates the pre-loaded blocks.
+WorkspaceFactoryController.MODE_PRELOAD = 'preload';
+
+/**
+ * Currently prompts the user for a name, checking that it's valid (not used
+ * before), and then creates a tab and switches to it.
+ */
+WorkspaceFactoryController.prototype.addCategory = function() {
+ // Transfers the user's blocks to a flyout if it's the first category created.
+ this.transferFlyoutBlocksToCategory();
+
+ // After possibly creating a category, check again if it's the first category.
+ var isFirstCategory = !this.model.hasElements();
+ // Get name from user.
+ name = this.promptForNewCategoryName('Enter the name of your new category: ');
+ if (!name) { //Exit if cancelled.
+ return;
+ }
+ // Create category.
+ this.createCategory(name);
+ // Switch to category.
+ this.switchElement(this.model.getCategoryIdByName(name));
+
+ // Sets the default options for injecting the workspace
+ // when there are categories if adding the first category.
+ if (isFirstCategory) {
+ this.view.setCategoryOptions(this.model.hasElements());
+ this.generateNewOptions();
+ }
+ // Update preview.
+ this.updatePreview();
+};
+
+/**
+ * Helper method for addCategory. Adds a category to the view given a name, ID,
+ * and a boolean for if it's the first category created. Assumes the category
+ * has already been created in the model. Does not switch to category.
+ *
+ * @param {!string} name Name of category being added.
+ * @param {!string} id The ID of the category being added.
+ */
+WorkspaceFactoryController.prototype.createCategory = function(name) {
+ // Create empty category
+ var category = new ListElement(ListElement.TYPE_CATEGORY, name);
+ this.model.addElementToList(category);
+ // Create new category.
+ var tab = this.view.addCategoryRow(name, category.id);
+ this.addClickToSwitch(tab, category.id);
+};
+
+/**
+ * Given a tab and a ID to be associated to that tab, adds a listener to
+ * that tab so that when the user clicks on the tab, it switches to the
+ * element associated with that ID.
+ *
+ * @param {!Element} tab The DOM element to add the listener to.
+ * @param {!string} id The ID of the element to switch to when tab is clicked.
+ */
+WorkspaceFactoryController.prototype.addClickToSwitch = function(tab, id) {
+ var self = this;
+ var clickFunction = function(id) { // Keep this in scope for switchElement
+ return function() {
+ self.switchElement(id);
+ };
+ };
+ this.view.bindClick(tab, clickFunction(id));
+};
+
+/**
+ * Transfers the blocks in the user's flyout to a new category if
+ * the user is creating their first category and their workspace is not
+ * empty. Should be called whenever it is possible to switch from single flyout
+ * to categories (not including importing).
+ */
+WorkspaceFactoryController.prototype.transferFlyoutBlocksToCategory =
+ function() {
+ // Saves the user's blocks from the flyout in a category if there is no
+ // toolbox and the user has dragged in blocks.
+ if (!this.model.hasElements() &&
+ this.toolboxWorkspace.getAllBlocks().length > 0) {
+ // Create the new category.
+ this.createCategory('Category 1', true);
+ // Set the new category as selected.
+ var id = this.model.getCategoryIdByName('Category 1');
+ this.model.setSelectedById(id);
+ this.view.setCategoryTabSelection(id, true);
+ // Allow user to use the default options for injecting with categories.
+ this.view.setCategoryOptions(this.model.hasElements());
+ this.generateNewOptions();
+ // Update preview here in case exit early.
+ this.updatePreview();
+ }
+};
+
+/**
+ * Attached to "-" button. Checks if the user wants to delete
+ * the current element. Removes the element and switches to another element.
+ * When the last element is removed, it switches to a single flyout mode.
+ *
+ */
+WorkspaceFactoryController.prototype.removeElement = function() {
+ // Check that there is a currently selected category to remove.
+ if (!this.model.getSelected()) {
+ return;
+ }
+
+ // Check if user wants to remove current category.
+ var check = confirm('Are you sure you want to delete the currently selected '
+ + this.model.getSelected().type + '?');
+ if (!check) { // If cancelled, exit.
+ return;
+ }
+
+ var selectedId = this.model.getSelectedId();
+ var selectedIndex = this.model.getIndexByElementId(selectedId);
+ // Delete element visually.
+ this.view.deleteElementRow(selectedId, selectedIndex);
+ // Delete element in model.
+ this.model.deleteElementFromList(selectedIndex);
+
+ // Find next logical element to switch to.
+ var next = this.model.getElementByIndex(selectedIndex);
+ if (!next && this.model.hasElements()) {
+ next = this.model.getElementByIndex(selectedIndex - 1);
+ }
+ var nextId = next ? next.id : null;
+
+ // Open next element.
+ this.clearAndLoadElement(nextId);
+
+ // If no element to switch to, display message, clear the workspace, and
+ // set a default selected element not in toolbox list in the model.
+ if (!nextId) {
+ alert('You currently have no categories or separators. All your blocks' +
+ ' will be displayed in a single flyout.');
+ this.toolboxWorkspace.clear();
+ this.toolboxWorkspace.clearUndo();
+ this.model.createDefaultSelectedIfEmpty();
+ }
+ // Update preview.
+ this.updatePreview();
+};
+
+/**
+ * Gets a valid name for a new category from the user.
+ *
+ * @param {!string} promptString Prompt for the user to enter a name.
+ * @return {string} Valid name for a new category, or null if cancelled.
+ */
+WorkspaceFactoryController.prototype.promptForNewCategoryName =
+ function(promptString) {
+ do {
+ var name = prompt(promptString);
+ if (!name) { // If cancelled.
+ return null;
+ }
+ } while (this.model.hasCategoryByName(name));
+ return name;
+}
+
+/**
+ * Switches to a new tab for the element given by ID. Stores XML and blocks
+ * to reload later, updates selected accordingly, and clears the workspace
+ * and clears undo, then loads the new element.
+ *
+ * @param {!string} id ID of tab to be opened, must be valid element ID.
+ */
+WorkspaceFactoryController.prototype.switchElement = function(id) {
+ // Disables events while switching so that Blockly delete and create events
+ // don't update the preview repeatedly.
+ Blockly.Events.disable();
+ // Caches information to reload or generate xml if switching to/from element.
+ // Only saves if a category is selected.
+ if (this.model.getSelectedId() != null && id != null) {
+ this.model.getSelected().saveFromWorkspace(this.toolboxWorkspace);
+ }
+ // Load element.
+ this.clearAndLoadElement(id);
+ // Enable Blockly events again.
+ Blockly.Events.enable();
+};
+
+/**
+ * Switches to a new tab for the element by ID. Helper for switchElement.
+ * Updates selected, clears the workspace and clears undo, loads a new element.
+ *
+ * @param {!string} id ID of category to load
+ */
+WorkspaceFactoryController.prototype.clearAndLoadElement = function(id) {
+ // Unselect current tab if switching to and from an element.
+ if (this.model.getSelectedId() != null && id != null) {
+ this.view.setCategoryTabSelection(this.model.getSelectedId(), false);
+ }
+
+ // If switching to another category, set category selection in the model and
+ // view.
+ if (id != null) {
+ // Set next category.
+ this.model.setSelectedById(id);
+
+ // Clears workspace and loads next category.
+ this.clearAndLoadXml_(this.model.getSelectedXml());
+
+ // Selects the next tab.
+ this.view.setCategoryTabSelection(id, true);
+
+ // Order blocks as shown in flyout.
+ this.toolboxWorkspace.cleanUp();
+
+ // Update category editing buttons.
+ this.view.updateState(this.model.getIndexByElementId
+ (this.model.getSelectedId()), this.model.getSelected());
+ } else {
+ // Update category editing buttons for no categories.
+ this.view.updateState(-1, null);
+ }
+};
+
+/**
+ * Tied to "Export" button. Gets a file name from the user and downloads
+ * the corresponding configuration xml to that file.
+ *
+ * @param {!string} exportMode The type of file to export
+ * (WorkspaceFactoryController.MODE_TOOLBOX for the toolbox configuration,
+ * and WorkspaceFactoryController.MODE_PRELOAD for the pre-loaded workspace
+ * configuration)
+ */
+WorkspaceFactoryController.prototype.exportXmlFile = function(exportMode) {
+ // Get file name.
+ var fileName = prompt('File Name for ' + (exportMode ==
+ WorkspaceFactoryController.MODE_TOOLBOX ? 'toolbox XML: ' :
+ 'pre-loaded workspace XML: '));
+ if (!fileName) { // If cancelled
+ return;
+ }
+
+ // Generate XML.
+ if (exportMode == WorkspaceFactoryController.MODE_TOOLBOX) {
+ // Export the toolbox XML.
+
+ var configXml = Blockly.Xml.domToPrettyText
+ (this.generator.generateToolboxXml());
+ this.hasUnsavedToolboxChanges = false;
+ } else if (exportMode == WorkspaceFactoryController.MODE_PRELOAD) {
+ // Export the pre-loaded block XML.
+
+ var configXml = Blockly.Xml.domToPrettyText
+ (this.generator.generateWorkspaceXml());
+ this.hasUnsavedPreloadChanges = false;
+ } else {
+ // Unknown mode. Throw error.
+ throw new Error ("Unknown export mode: " + exportMode);
+ }
+
+ // Download file.
+ var data = new Blob([configXml], {type: 'text/xml'});
+ this.view.createAndDownloadFile(fileName, data);
+ };
+
+/**
+ * Export the options object to be used for the Blockly inject call. Gets a
+ * file name from the user and downloads the options object to that file.
+ */
+WorkspaceFactoryController.prototype.exportInjectFile = function() {
+ var fileName = prompt('File Name for starter Blockly workspace code: ');
+ if (!fileName) { // If cancelled.
+ return;
+ }
+ // Generate new options to remove toolbox XML from options object (if
+ // necessary).
+ this.generateNewOptions();
+ var printableOptions = this.generator.generateInjectString()
+ var data = new Blob([printableOptions], {type: 'text/javascript'});
+ this.view.createAndDownloadFile(fileName, data);
+};
+
+/**
+ * Tied to "Print" button. Mainly used for debugging purposes. Prints
+ * the configuration XML to the console.
+ */
+WorkspaceFactoryController.prototype.printConfig = function() {
+ // Capture any changes made by user before generating XML.
+ this.saveStateFromWorkspace();
+ // Print XML.
+ window.console.log(Blockly.Xml.domToPrettyText
+ (this.generator.generateToolboxXml()));
+};
+
+/**
+ * Updates the preview workspace based on the toolbox workspace. If switching
+ * from no categories to categories or categories to no categories, reinjects
+ * Blockly with reinjectPreview, otherwise just updates without reinjecting.
+ * Called whenever a list element is created, removed, or modified and when
+ * Blockly move and delete events are fired. Do not call on create events
+ * or disabling will cause the user to "drop" their current blocks. Make sure
+ * that no changes have been made to the workspace since updating the model
+ * (if this might be the case, call saveStateFromWorkspace).
+ */
+WorkspaceFactoryController.prototype.updatePreview = function() {
+ // Disable events to stop updatePreview from recursively calling itself
+ // through event handlers.
+ Blockly.Events.disable();
+
+ // Only update the toolbox if not in read only mode.
+ if (!this.model.options['readOnly']) {
+ // Get toolbox XML.
+ var tree = Blockly.Options.parseToolboxTree
+ (this.generator.generateToolboxXml());
+
+ // No categories, creates a simple flyout.
+ if (tree.getElementsByTagName('category').length == 0) {
+ // No categories, creates a simple flyout.
+ if (this.previewWorkspace.toolbox_) {
+ this.reinjectPreview(tree); // Switch to simple flyout, expensive.
+ } else {
+ this.previewWorkspace.updateToolbox(tree);
+ }
+ } else {
+ // Uses categories, creates a toolbox.
+ if (!this.previewWorkspace.toolbox_) {
+ this.reinjectPreview(tree); // Create a toolbox, expensive.
+ } else {
+ // Close the toolbox before updating it so that the user has to reopen
+ // the flyout and see their updated toolbox (open flyout doesn't update)
+ this.previewWorkspace.toolbox_.clearSelection();
+ this.previewWorkspace.updateToolbox(tree);
+ }
+ }
+ }
+
+ // Update pre-loaded blocks in the preview workspace.
+ this.previewWorkspace.clear();
+ Blockly.Xml.domToWorkspace(this.generator.generateWorkspaceXml(),
+ this.previewWorkspace);
+
+ // Reenable events.
+ Blockly.Events.enable();
+};
+
+/**
+ * Saves the state from the workspace depending on the current mode. Should
+ * be called after making changes to the workspace.
+ */
+WorkspaceFactoryController.prototype.saveStateFromWorkspace = function() {
+ if (this.selectedMode == WorkspaceFactoryController.MODE_TOOLBOX) {
+ // If currently editing the toolbox.
+ // Update flags if toolbox has been changed.
+ if (this.model.getSelectedXml() !=
+ Blockly.Xml.workspaceToDom(this.toolboxWorkspace)) {
+ this.hasUnsavedToolboxChanges = true;
+ }
+
+ this.model.getSelected().saveFromWorkspace(this.toolboxWorkspace);
+
+ } else if (this.selectedMode == WorkspaceFactoryController.MODE_PRELOAD) {
+ // If currently editing the pre-loaded workspace.
+ // Update flags if preloaded blocks have been changed.
+ if (this.model.getPreloadXml() !=
+ Blockly.Xml.workspaceToDom(this.toolboxWorkspace)) {
+ this.hasUnsavedPreloadChanges = true;
+ }
+
+ this.model.savePreloadXml
+ (Blockly.Xml.workspaceToDom(this.toolboxWorkspace));
+ }
+};
+
+/**
+ * Used to completely reinject the preview workspace. This should be used only
+ * when switching from simple flyout to categories, or categories to simple
+ * flyout. More expensive than simply updating the flyout or toolbox.
+ *
+ * @param {!Element} tree of xml elements
+ * @package
+ */
+WorkspaceFactoryController.prototype.reinjectPreview = function(tree) {
+ this.previewWorkspace.dispose();
+ var injectOptions = this.readOptions_();
+ injectOptions['toolbox'] = Blockly.Xml.domToPrettyText(tree);
+ this.previewWorkspace = Blockly.inject('preview_blocks', injectOptions);
+ Blockly.Xml.domToWorkspace(this.generator.generateWorkspaceXml(),
+ this.previewWorkspace);
+};
+
+/**
+ * Tied to "change name" button. Changes the name of the selected category.
+ * Continues prompting the user until they input a category name that is not
+ * currently in use, exits if user presses cancel.
+ */
+WorkspaceFactoryController.prototype.changeCategoryName = function() {
+ // Return if a category is not selected.
+ if (this.model.getSelected().type != ListElement.TYPE_CATEGORY) {
+ return;
+ }
+ // Get new name from user.
+ var newName = this.promptForNewCategoryName('What do you want to change this'
+ + ' category\'s name to?');
+ if (!newName) { // If cancelled.
+ return;
+ }
+ // Change category name.
+ this.model.getSelected().changeName(newName);
+ this.view.updateCategoryName(newName, this.model.getSelectedId());
+ // Update preview.
+ this.updatePreview();
+};
+
+/**
+ * Tied to arrow up and arrow down buttons. Swaps with the element above or
+ * below the currently selected element (offset categories away from the
+ * current element). Updates state to enable the correct element editing
+ * buttons.
+ *
+ * @param {int} offset The index offset from the currently selected element
+ * to swap with. Positive if the element to be swapped with is below, negative
+ * if the element to be swapped with is above.
+ */
+WorkspaceFactoryController.prototype.moveElement = function(offset) {
+ var curr = this.model.getSelected();
+ if (!curr) { // Return if no selected element.
+ return;
+ }
+ var currIndex = this.model.getIndexByElementId(curr.id);
+ var swapIndex = this.model.getIndexByElementId(curr.id) + offset;
+ var swap = this.model.getElementByIndex(swapIndex);
+ if (!swap) { // Return if cannot swap in that direction.
+ return;
+ }
+ // Move currently selected element to index of other element.
+ // Indexes must be valid because confirmed that curr and swap exist.
+ this.moveElementToIndex(curr, swapIndex, currIndex);
+ // Update element editing buttons.
+ this.view.updateState(swapIndex, this.model.getSelected());
+ // Update preview.
+ this.updatePreview();
+};
+
+/**
+ * Moves a element to a specified index and updates the model and view
+ * accordingly. Helper functions throw an error if indexes are out of bounds.
+ *
+ * @param {!Element} element The element to move.
+ * @param {int} newIndex The index to insert the element at.
+ * @param {int} oldIndex The index the element is currently at.
+ */
+WorkspaceFactoryController.prototype.moveElementToIndex = function(element,
+ newIndex, oldIndex) {
+ this.model.moveElementToIndex(element, newIndex, oldIndex);
+ this.view.moveTabToIndex(element.id, newIndex, oldIndex);
+};
+
+/**
+ * Changes the color of the selected category. Return if selected element is
+ * a separator.
+ *
+ * @param {!string} color The color to change the selected category. Must be
+ * a valid CSS string.
+ */
+WorkspaceFactoryController.prototype.changeSelectedCategoryColor =
+ function(color) {
+ // Return if category is not selected.
+ if (this.model.getSelected().type != ListElement.TYPE_CATEGORY) {
+ return;
+ }
+ // Change color of selected category.
+ this.model.getSelected().changeColor(color);
+ this.view.setBorderColor(this.model.getSelectedId(), color);
+ this.updatePreview();
+};
+
+/**
+ * Tied to the "Standard Category" dropdown option, this function prompts
+ * the user for a name of a standard Blockly category (case insensitive) and
+ * loads it as a new category and switches to it. Leverages StandardCategories.
+ */
+WorkspaceFactoryController.prototype.loadCategory = function() {
+ // Prompt user for the name of the standard category to load.
+ do {
+ var name = prompt('Enter the name of the category you would like to import '
+ + '(Logic, Loops, Math, Text, Lists, Colour, Variables, or Functions)');
+ if (!name) {
+ return; // Exit if cancelled.
+ }
+ } while (!this.isStandardCategoryName(name));
+
+ // Load category.
+ this.loadCategoryByName(name);
+};
+
+/**
+ * Loads a Standard Category by name and switches to it. Leverages
+ * StandardCategories. Returns if cannot load standard category.
+ *
+ * @param {string} name Name of the standard category to load.
+ */
+WorkspaceFactoryController.prototype.loadCategoryByName = function(name) {
+ // Check if the user can load that standard category.
+ if (!this.isStandardCategoryName(name)) {
+ return;
+ }
+ if (this.model.hasVariables() && name.toLowerCase() == 'variables') {
+ alert('A Variables category already exists. You cannot create multiple' +
+ ' variables categories.');
+ return;
+ }
+ if (this.model.hasProcedures() && name.toLowerCase() == 'functions') {
+ alert('A Functions category already exists. You cannot create multiple' +
+ ' functions categories.');
+ return;
+ }
+ // Check if the user can create a category with that name.
+ var standardCategory = StandardCategories.categoryMap[name.toLowerCase()]
+ if (this.model.hasCategoryByName(standardCategory.name)) {
+ alert('You already have a category with the name ' + standardCategory.name
+ + '. Rename your category and try again.');
+ return;
+ }
+ // Transfers current flyout blocks to a category if it's the first category
+ // created.
+ this.transferFlyoutBlocksToCategory();
+
+ var isFirstCategory = !this.model.hasElements();
+ // Copy the standard category in the model.
+ var copy = standardCategory.copy();
+
+ // Add it to the model.
+ this.model.addElementToList(copy);
+
+ // Update the copy in the view.
+ var tab = this.view.addCategoryRow(copy.name, copy.id);
+ this.addClickToSwitch(tab, copy.id);
+ // Color the category tab in the view.
+ if (copy.color) {
+ this.view.setBorderColor(copy.id, copy.color);
+ }
+ // Switch to loaded category.
+ this.switchElement(copy.id);
+ // Convert actual shadow blocks to user-generated shadow blocks.
+ this.convertShadowBlocks();
+ // Save state from workspace before updating preview.
+ this.saveStateFromWorkspace();
+ if (isFirstCategory) {
+ // Allow the user to use the default options for injecting the workspace
+ // when there are categories.
+ this.view.setCategoryOptions(this.model.hasElements());
+ this.generateNewOptions();
+ }
+ // Update preview.
+ this.updatePreview();
+};
+
+/**
+ * Loads the standard Blockly toolbox into the editing space. Should only
+ * be called when the mode is set to toolbox.
+ */
+WorkspaceFactoryController.prototype.loadStandardToolbox = function() {
+ this.loadCategoryByName('Logic');
+ this.loadCategoryByName('Loops');
+ this.loadCategoryByName('Math');
+ this.loadCategoryByName('Text');
+ this.loadCategoryByName('Lists');
+ this.loadCategoryByName('Colour');
+ this.addSeparator();
+ this.loadCategoryByName('Variables');
+ this.loadCategoryByName('Functions');
+}
+
+/**
+ * Given the name of a category, determines if it's the name of a standard
+ * category (case insensitive).
+ *
+ * @param {string} name The name of the category that should be checked if it's
+ * in StandardCategories categoryMap
+ * @return {boolean} True if name is a standard category name, false otherwise.
+ */
+WorkspaceFactoryController.prototype.isStandardCategoryName = function(name) {
+ for (var category in StandardCategories.categoryMap) {
+ if (name.toLowerCase() == category) {
+ return true;
+ }
+ }
+ return false;
+};
+
+/**
+ * Connected to the "add separator" dropdown option. If categories already
+ * exist, adds a separator to the model and view. Does not switch to select
+ * the separator, and updates the preview.
+ */
+WorkspaceFactoryController.prototype.addSeparator = function() {
+ // If adding the first element in the toolbox, transfers the user's blocks
+ // in a flyout to a category.
+ this.transferFlyoutBlocksToCategory();
+ // Create the separator in the model.
+ var separator = new ListElement(ListElement.TYPE_SEPARATOR);
+ this.model.addElementToList(separator);
+ // Create the separator in the view.
+ var tab = this.view.addSeparatorTab(separator.id);
+ this.addClickToSwitch(tab, separator.id);
+ // Switch to the separator and update the preview.
+ this.switchElement(separator.id);
+ this.updatePreview();
+};
+
+/**
+ * Connected to the import button. Given the file path inputted by the user
+ * from file input, if the import mode is for the toolbox, this function loads
+ * that toolbox XML to the workspace, creating category and separator tabs as
+ * necessary. If the import mode is for pre-loaded blocks in the workspace,
+ * this function loads that XML to the workspace to be edited further. This
+ * function switches mode to whatever the import mode is. Catches errors from
+ * file reading and prints an error message alerting the user.
+ *
+ * @param {string} file The path for the file to be imported into the workspace.
+ * Should contain valid toolbox XML.
+ * @param {!string} importMode The mode corresponding to the type of file the
+ * user is importing (WorkspaceFactoryController.MODE_TOOLBOX or
+ * WorkspaceFactoryController.MODE_PRELOAD).
+ */
+WorkspaceFactoryController.prototype.importFile = function(file, importMode) {
+ // Exit if cancelled.
+ if (!file) {
+ return;
+ }
+
+ Blockly.Events.disable();
+ var controller = this;
+ var reader = new FileReader();
+
+ // To be executed when the reader has read the file.
+ reader.onload = function() {
+ // Try to parse XML from file and load it into toolbox editing area.
+ // Print error message if fail.
+ try {
+ var tree = Blockly.Xml.textToDom(reader.result);
+ if (importMode == WorkspaceFactoryController.MODE_TOOLBOX) {
+ // Switch mode.
+ controller.setMode(WorkspaceFactoryController.MODE_TOOLBOX);
+
+ // Confirm that the user wants to override their current toolbox.
+ var hasToolboxElements = controller.model.hasElements() ||
+ controller.getAllBlocks().length > 0;
+ if (hasToolboxElements &&
+ !confirm('Are you sure you want to import? You will lose your '
+ + 'current toolbox. ')) {
+ return;
+ }
+ // Import toolbox XML.
+ controller.importToolboxFromTree_(tree);
+
+ } else if (importMode == WorkspaceFactoryController.MODE_PRELOAD) {
+ // Switch mode.
+ controller.setMode(WorkspaceFactoryController.MODE_PRELOAD);
+
+ // Confirm that the user wants to override their current blocks.
+ if (controller.toolboxWorkspace.getAllBlocks().length > 0 &&
+ !confirm('Are you sure you want to import? You will lose your '
+ + 'current workspace blocks. ')) {
+ return;
+ }
+
+ // Import pre-loaded workspace XML.
+ controller.importPreloadFromTree_(tree);
+ } else {
+ // Throw error if invalid mode.
+ throw new Error("Unknown import mode: " + importMode);
+ }
+ } catch(e) {
+ alert('Cannot load XML from file.');
+ console.log(e);
+ } finally {
+ Blockly.Events.enable();
+ }
+ }
+
+ // Read the file asynchronously.
+ reader.readAsText(file);
+};
+
+/**
+ * Given a XML DOM tree, loads it into the toolbox editing area so that the
+ * user can continue editing their work. Assumes that tree is in valid toolbox
+ * XML format. Assumes that the mode is MODE_TOOLBOX.
+ * @private
+ *
+ * @param {!Element} tree XML tree to be loaded to toolbox editing area.
+ */
+WorkspaceFactoryController.prototype.importToolboxFromTree_ = function(tree) {
+ // Clear current editing area.
+ this.model.clearToolboxList();
+ this.view.clearToolboxTabs();
+
+ if (tree.getElementsByTagName('category').length == 0) {
+ // No categories present.
+ // Load all the blocks into a single category evenly spaced.
+ Blockly.Xml.domToWorkspace(tree, this.toolboxWorkspace);
+ this.toolboxWorkspace.cleanUp();
+
+ // Convert actual shadow blocks to user-generated shadow blocks.
+ this.convertShadowBlocks();
+
+ // Add message to denote empty category.
+ this.view.addEmptyCategoryMessage();
+
+ } else {
+ // Categories/separators present.
+ for (var i = 0, item; item = tree.children[i]; i++) {
+
+ if (item.tagName == 'category') {
+ // If the element is a category, create a new category and switch to it.
+ this.createCategory(item.getAttribute('name'), false);
+ var category = this.model.getElementByIndex(i);
+ this.switchElement(category.id);
+
+ // Load all blocks in that category to the workspace to be evenly
+ // spaced and saved to that category.
+ for (var j = 0, blockXml; blockXml = item.children[j]; j++) {
+ Blockly.Xml.domToBlock(blockXml, this.toolboxWorkspace);
+ }
+
+ // Evenly space the blocks.
+ this.toolboxWorkspace.cleanUp();
+
+ // Convert actual shadow blocks to user-generated shadow blocks.
+ this.convertShadowBlocks();
+
+ // Set category color.
+ if (item.getAttribute('colour')) {
+ category.changeColor(item.getAttribute('colour'));
+ this.view.setBorderColor(category.id, category.color);
+ }
+ // Set any custom tags.
+ if (item.getAttribute('custom')) {
+ this.model.addCustomTag(category, item.getAttribute('custom'));
+ }
+ } else {
+ // If the element is a separator, add the separator and switch to it.
+ this.addSeparator();
+ this.switchElement(this.model.getElementByIndex(i).id);
+ }
+ }
+ }
+ this.view.updateState(this.model.getIndexByElementId
+ (this.model.getSelectedId()), this.model.getSelected());
+
+ this.saveStateFromWorkspace();
+
+ // Set default configuration options for a single flyout or multiple
+ // categories.
+ this.view.setCategoryOptions(this.model.hasElements());
+ this.generateNewOptions();
+
+ this.updatePreview();
+};
+
+/**
+ * Given a XML DOM tree, loads it into the pre-loaded workspace editing area.
+ * Assumes that tree is in valid XML format and that the selected mode is
+ * MODE_PRELOAD.
+ *
+ * @param {!Element} tree XML tree to be loaded to pre-loaded block editing
+ * area.
+ */
+WorkspaceFactoryController.prototype.importPreloadFromTree_ = function(tree) {
+ this.clearAndLoadXml_(tree);
+ this.model.savePreloadXml(tree);
+ this.updatePreview();
+}
+
+/**
+ * Given a XML DOM tree, loads it into the pre-loaded workspace editing area.
+ * Assumes that tree is in valid XML format and that the selected mode is
+ * MODE_PRELOAD.
+ *
+ * @param {!Element} tree XML tree to be loaded to pre-loaded block editing
+ * area.
+ */
+WorkspaceFactoryController.prototype.importPreloadFromTree_ = function(tree) {
+ this.clearAndLoadXml_(tree);
+ this.model.savePreloadXml(tree);
+ this.saveStateFromWorkspace();
+ this.updatePreview();
+}
+
+/**
+ * Given a XML DOM tree, loads it into the pre-loaded workspace editing area.
+ * Assumes that tree is in valid XML format and that the selected mode is
+ * MODE_PRELOAD.
+ *
+ * @param {!Element} tree XML tree to be loaded to pre-loaded block editing
+ * area.
+ */
+WorkspaceFactoryController.prototype.importPreloadFromTree_ = function(tree) {
+ this.clearAndLoadXml_(tree);
+ this.model.savePreloadXml(tree);
+ this.saveStateFromWorkspace();
+ this.updatePreview();
+}
+
+/**
+ * Clears the editing area completely, deleting all categories and all
+ * blocks in the model and view and all pre-loaded blocks. Tied to the
+ * "Clear" button.
+ */
+WorkspaceFactoryController.prototype.clearAll = function() {
+ if (!confirm('Are you sure you want to clear all of your work in Workspace' +
+ ' Factory?')) {
+ return;
+ }
+ var hasCategories = this.model.hasElements();
+ this.model.clearToolboxList();
+ this.view.clearToolboxTabs();
+ this.model.savePreloadXml(Blockly.Xml.textToDom('<xml></xml>'));
+ this.view.addEmptyCategoryMessage();
+ this.view.updateState(-1, null);
+ this.toolboxWorkspace.clear();
+ this.toolboxWorkspace.clearUndo();
+ this.saveStateFromWorkspace();
+ this.hasUnsavedToolboxChanges = false;
+ this.hasUnsavedPreloadChanges = false;
+ this.view.setCategoryOptions(this.model.hasElements());
+ this.generateNewOptions();
+ this.updatePreview();
+};
+
+/*
+ * Makes the currently selected block a user-generated shadow block. These
+ * blocks are not made into real shadow blocks, but recorded in the model
+ * and visually marked as shadow blocks, allowing the user to move and edit
+ * them (which would be impossible with actual shadow blocks). Updates the
+ * preview when done.
+ *
+ */
+WorkspaceFactoryController.prototype.addShadow = function() {
+ // No block selected to make a shadow block.
+ if (!Blockly.selected) {
+ return;
+ }
+ // Clear any previous warnings on the block (would only have warnings on
+ // a non-shadow block if it was nested inside another shadow block).
+ Blockly.selected.setWarningText(null);
+ // Set selected block and all children as shadow blocks.
+ this.addShadowForBlockAndChildren_(Blockly.selected);
+
+ // Save and update the preview.
+ this.saveStateFromWorkspace();
+ this.updatePreview();
+};
+
+/**
+ * Sets a block and all of its children to be user-generated shadow blocks,
+ * both in the model and view.
+ * @private
+ *
+ * @param {!Blockly.Block} block The block to be converted to a user-generated
+ * shadow block.
+ */
+WorkspaceFactoryController.prototype.addShadowForBlockAndChildren_ =
+ function(block) {
+ // Convert to shadow block.
+ this.view.markShadowBlock(block);
+ this.model.addShadowBlock(block.id);
+
+ if (FactoryUtils.hasVariableField(block)) {
+ block.setWarningText('Cannot make variable blocks shadow blocks.');
+ }
+
+ // Convert all children to shadow blocks recursively.
+ var children = block.getChildren();
+ for (var i = 0; i < children.length; i++) {
+ this.addShadowForBlockAndChildren_(children[i]);
+ }
+};
+
+/**
+ * If the currently selected block is a user-generated shadow block, this
+ * function makes it a normal block again, removing it from the list of
+ * shadow blocks and loading the workspace again. Updates the preview again.
+ *
+ */
+WorkspaceFactoryController.prototype.removeShadow = function() {
+ // No block selected to modify.
+ if (!Blockly.selected) {
+ return;
+ }
+ this.model.removeShadowBlock(Blockly.selected.id);
+ this.view.unmarkShadowBlock(Blockly.selected);
+
+ // If turning invalid shadow block back to normal block, remove warning.
+ Blockly.selected.setWarningText(null);
+
+ this.saveStateFromWorkspace();
+ this.updatePreview();
+};
+
+/**
+ * Given a unique block ID, uses the model to determine if a block is a
+ * user-generated shadow block.
+ *
+ * @param {!string} blockId The unique ID of the block to examine.
+ * @return {boolean} True if the block is a user-generated shadow block, false
+ * otherwise.
+ */
+WorkspaceFactoryController.prototype.isUserGenShadowBlock = function(blockId) {
+ return this.model.isShadowBlock(blockId);
+}
+
+/**
+ * Call when importing XML containing real shadow blocks. This function turns
+ * all real shadow blocks loaded in the workspace into user-generated shadow
+ * blocks, meaning they are marked as shadow blocks by the model and appear as
+ * shadow blocks in the view but are still editable and movable.
+ */
+WorkspaceFactoryController.prototype.convertShadowBlocks = function() {
+ var blocks = this.toolboxWorkspace.getAllBlocks();
+ for (var i = 0, block; block = blocks[i]; i++) {
+ if (block.isShadow()) {
+ block.setShadow(false);
+ // Delete the shadow DOM attached to the block so that the shadow block
+ // does not respawn. Dependent on implementation details.
+ var parentConnection = block.outputConnection ?
+ block.outputConnection.targetConnection :
+ block.previousConnection.targetConnection;
+ if (parentConnection) {
+ parentConnection.setShadowDom(null);
+ }
+ this.model.addShadowBlock(block.id);
+ this.view.markShadowBlock(block);
+ }
+ }
+};
+
+/**
+ * Sets the currently selected mode that determines what the toolbox workspace
+ * is being used to edit. Updates the view and then saves and loads XML
+ * to and from the toolbox and updates the help text.
+ *
+ * @param {!string} tab The type of tab being switched to
+ * (WorkspaceFactoryController.MODE_TOOLBOX or
+ * WorkspaceFactoryController.MODE_PRELOAD).
+ */
+WorkspaceFactoryController.prototype.setMode = function(mode) {
+ // No work to change mode that's currently set.
+ if (this.selectedMode == mode) {
+ return;
+ }
+
+ // No work to change mode that's currently set.
+ if (this.selectedMode == mode) {
+ return;
+ }
+
+ // Set tab selection and display appropriate tab.
+ this.view.setModeSelection(mode);
+
+ // Update selected tab.
+ this.selectedMode = mode;
+
+ // Update help text above workspace.
+ this.view.updateHelpText(mode);
+
+ if (mode == WorkspaceFactoryController.MODE_TOOLBOX) {
+ // Open the toolbox editing space.
+ this.model.savePreloadXml
+ (Blockly.Xml.workspaceToDom(this.toolboxWorkspace));
+ this.clearAndLoadXml_(this.model.getSelectedXml());
+ this.view.disableWorkspace(this.view.shouldDisableWorkspace
+ (this.model.getSelected()));
+ } else {
+ // Open the pre-loaded workspace editing space.
+ if (this.model.getSelected()) {
+ this.model.getSelected().saveFromWorkspace(this.toolboxWorkspace);
+ }
+ this.clearAndLoadXml_(this.model.getPreloadXml());
+ this.view.disableWorkspace(false);
+ }
+};
+
+/**
+ * Clears the toolbox workspace and loads XML to it, marking shadow blocks
+ * as necessary.
+ * @private
+ *
+ * @param {!Element} xml The XML to be loaded to the workspace.
+ */
+WorkspaceFactoryController.prototype.clearAndLoadXml_ = function(xml) {
+ this.toolboxWorkspace.clear();
+ this.toolboxWorkspace.clearUndo();
+ Blockly.Xml.domToWorkspace(xml, this.toolboxWorkspace);
+ this.view.markShadowBlocks(this.model.getShadowBlocksInWorkspace
+ (this.toolboxWorkspace.getAllBlocks()));
+ this.warnForUndefinedBlocks_();
+};
+
+/**
+ * Sets the standard default options for the options object and updates
+ * the preview workspace. The default values depends on if categories are
+ * present.
+ */
+WorkspaceFactoryController.prototype.setStandardOptionsAndUpdate = function() {
+ this.view.setBaseOptions();
+ this.view.setCategoryOptions(this.model.hasElements());
+ this.generateNewOptions();
+ };
+
+/**
+ * Generates a new options object for injecting a Blockly workspace based
+ * on user input. Should be called every time a change has been made to
+ * an input field. Updates the model and reinjects the preview workspace.
+ */
+WorkspaceFactoryController.prototype.generateNewOptions = function() {
+ this.model.setOptions(this.readOptions_());
+
+ this.reinjectPreview(Blockly.Options.parseToolboxTree
+ (this.generator.generateToolboxXml()));
+};
+
+/**
+ * Generates a new options object for injecting a Blockly workspace based on
+ * user input.
+ * @private
+ *
+ * @return {!Object} Blockly injection options object.
+ */
+WorkspaceFactoryController.prototype.readOptions_ = function() {
+ var optionsObj = Object.create(null);
+
+ // Add all standard options to the options object.
+ // Use parse int to get numbers from value inputs.
+ optionsObj['collapse'] =
+ document.getElementById('option_collapse_checkbox').checked;
+ optionsObj['comments'] =
+ document.getElementById('option_comments_checkbox').checked;
+ optionsObj['css'] = document.getElementById('option_css_checkbox').checked;
+ optionsObj['disable'] =
+ document.getElementById('option_disable_checkbox').checked;
+ if (document.getElementById('option_infiniteBlocks_checkbox').checked) {
+ optionsObj['maxBlocks'] = Infinity;
+ } else {
+ var maxBlocksValue =
+ document.getElementById('option_maxBlocks_number').value;
+ optionsObj['maxBlocks'] = typeof maxBlocksValue == 'string' ?
+ parseInt(maxBlocksValue) : maxBlocksValue;
+ }
+ optionsObj['media'] = document.getElementById('option_media_text').value;
+ optionsObj['readOnly'] =
+ document.getElementById('option_readOnly_checkbox').checked;
+ optionsObj['rtl'] = document.getElementById('option_rtl_checkbox').checked;
+ optionsObj['scrollbars'] =
+ document.getElementById('option_scrollbars_checkbox').checked;
+ optionsObj['sounds'] =
+ document.getElementById('option_sounds_checkbox').checked;
+ if (!optionsObj['readOnly']) {
+ optionsObj['trashcan'] =
+ document.getElementById('option_trashcan_checkbox').checked;
+ }
+
+ // If using a grid, add all grid options.
+ if (document.getElementById('option_grid_checkbox').checked) {
+ var grid = Object.create(null);
+ var spacingValue =
+ document.getElementById('gridOption_spacing_number').value;
+ grid['spacing'] = typeof spacingValue == 'string' ?
+ parseInt(spacingValue) : spacingValue;
+ var lengthValue = document.getElementById('gridOption_length_number').value;
+ grid['length'] = typeof lengthValue == 'string' ?
+ parseInt(lengthValue) : lengthValue;
+ grid['colour'] = document.getElementById('gridOption_colour_text').value;
+ grid['snap'] = document.getElementById('gridOption_snap_checkbox').checked;
+ optionsObj['grid'] = grid;
+ }
+
+ // If using zoom, add all zoom options.
+ if (document.getElementById('option_zoom_checkbox').checked) {
+ var zoom = Object.create(null);
+ zoom['controls'] =
+ document.getElementById('zoomOption_controls_checkbox').checked;
+ zoom['wheel'] =
+ document.getElementById('zoomOption_wheel_checkbox').checked;
+ var startScaleValue =
+ document.getElementById('zoomOption_startScale_number').value;
+ zoom['startScale'] = typeof startScaleValue == 'string' ?
+ parseFloat(startScaleValue) : startScaleValue;
+ var maxScaleValue =
+ document.getElementById('zoomOption_maxScale_number').value;
+ zoom['maxcale'] = typeof maxScaleValue == 'string' ?
+ parseFloat(maxScaleValue) : maxScaleValue;
+ var minScaleValue =
+ document.getElementById('zoomOption_minScale_number').value;
+ zoom['minScale'] = typeof minScaleValue == 'string' ?
+ parseFloat(minScaleValue) : minScaleValue;
+ var scaleSpeedValue =
+ document.getElementById('zoomOption_scaleSpeed_number').value;
+ zoom['startScale'] = typeof startScaleValue == 'string' ?
+ parseFloat(scaleSpeedValue) : scaleSpeedValue;
+ optionsObj['zoom'] = zoom;
+ }
+
+ return optionsObj;
+};
+
+/**
+ * Imports blocks from a file, generating a category in the toolbox workspace
+ * to allow the user to use imported blocks in the toolbox and in pre-loaded
+ * blocks.
+ *
+ * @param {!File} file File object for the blocks to import.
+ * @param {!string} format The format of the file to import, either 'JSON' or
+ * 'JavaScript'.
+ */
+WorkspaceFactoryController.prototype.importBlocks =
+ function(file, format) {
+ // Generate category name from file name.
+ var categoryName = file.name;
+
+ var controller = this;
+ var reader = new FileReader();
+
+ // To be executed when the reader has read the file.
+ reader.onload = function() {
+ try {
+ // Define blocks using block types from file.
+ var blockTypes = FactoryUtils.defineAndGetBlockTypes(reader.result,
+ format);
+
+ // If an imported block type is already defined, check if the user wants
+ // to override the current block definition.
+ if (controller.model.hasDefinedBlockTypes(blockTypes) &&
+ !confirm('An imported block uses the same name as a block '
+ + 'already in your toolbox. Are you sure you want to override the '
+ + 'currently defined block?')) {
+ return;
+ }
+
+ var blocks = controller.generator.getDefinedBlocks(blockTypes);
+ // Generate category XML and append to toolbox.
+ var categoryXml = FactoryUtils.generateCategoryXml(blocks, categoryName);
+ // Get random color for category between 0 and 360. Gives each imported
+ // category a different color.
+ var randomColor = Math.floor(Math.random() * 360);
+ categoryXml.setAttribute('colour', randomColor);
+ controller.toolbox.appendChild(categoryXml);
+ controller.toolboxWorkspace.updateToolbox(controller.toolbox);
+ // Update imported block types.
+ controller.model.addImportedBlockTypes(blockTypes);
+ // Reload current category to possibly reflect any newly defined blocks.
+ controller.clearAndLoadXml_
+ (Blockly.Xml.workspaceToDom(controller.toolboxWorkspace));
+ } catch (e) {
+ alert('Cannot read blocks from file.');
+ window.console.log(e);
+ }
+ }
+
+ // Read the file asynchronously.
+ reader.readAsText(file);
+};
+
+/*
+ * Updates the block library category in the toolbox workspace toolbox.
+ *
+ * @param {!Element} categoryXml XML for the block library category.
+ * @param {!Array<!string>} libBlockTypes Array of block types from the block
+ * library.
+ */
+WorkspaceFactoryController.prototype.setBlockLibCategory =
+ function(categoryXml, libBlockTypes) {
+ var blockLibCategory = document.getElementById('blockLibCategory');
+
+ // Set category id so that it can be easily replaced, and set a standard,
+ // arbitrary block library color.
+ categoryXml.setAttribute('id', 'blockLibCategory');
+ categoryXml.setAttribute('colour', 260);
+
+ // Update the toolbox and toolboxWorkspace.
+ this.toolbox.replaceChild(categoryXml, blockLibCategory);
+ this.toolboxWorkspace.toolbox_.clearSelection();
+ this.toolboxWorkspace.updateToolbox(this.toolbox);
+
+ // Update the block library types.
+ this.model.updateLibBlockTypes(libBlockTypes);
+
+ // Reload XML on page to account for blocks now defined or undefined in block
+ // library.
+ this.clearAndLoadXml_(Blockly.Xml.workspaceToDom(this.toolboxWorkspace));
+};
+
+/**
+ * Return the block types used in the custom toolbox and pre-loaded workspace.
+ *
+ * @return {!Array.<!string>} Block types used in the custom toolbox and
+ * pre-loaded workspace.
+ */
+WorkspaceFactoryController.prototype.getAllUsedBlockTypes = function() {
+ return this.model.getAllUsedBlockTypes();
+};
+
+/**
+ * Determines if a block loaded in the workspace has a definition (if it
+ * is a standard block, is defined in the block library, or has a definition
+ * imported).
+ *
+ * @param {!Blockly.Block} block The block to examine.
+ */
+WorkspaceFactoryController.prototype.isDefinedBlock = function(block) {
+ return this.model.isDefinedBlockType(block.type);
+};
+
+/**
+ * Sets a warning on blocks loaded to the workspace that are not defined.
+ * @private
+ */
+WorkspaceFactoryController.prototype.warnForUndefinedBlocks_ = function() {
+ var blocks = this.toolboxWorkspace.getAllBlocks();
+ for (var i = 0, block; block = blocks[i]; i++) {
+ if (!this.isDefinedBlock(block)) {
+ block.setWarningText(block.type + ' is not defined (it is not a standard '
+ + 'block, \nin your block library, or an imported block)');
+ }
+ }
+};
+
+/*
+ * Determines if a standard variable category is in the custom toolbox.
+ *
+ * @return {boolean} True if a variables category is in use, false otherwise.
+ */
+WorkspaceFactoryController.prototype.hasVariablesCategory = function() {
+ return this.model.hasVariables();
+};
+
+/**
+ * Determines if a standard procedures category is in the custom toolbox.
+ *
+ * @return {boolean} True if a procedures category is in use, false otherwise.
+ */
+WorkspaceFactoryController.prototype.hasProceduresCategory = function() {
+ return this.model.hasProcedures();
+};
+
+/**
+ * Determines if there are any unsaved changes in workspace factory.
+ *
+ * @return {boolean} True if there are unsaved changes, false otherwise.
+ */
+WorkspaceFactoryController.prototype.hasUnsavedChanges = function() {
+ return this.hasUnsavedToolboxChanges || this.hasUnsavedPreloadChanges;
+};
diff --git a/blockly/demos/blocklyfactory/workspacefactory/wfactory_generator.js b/blockly/demos/blocklyfactory/workspacefactory/wfactory_generator.js
new file mode 100644
index 0000000..c3183ab
--- /dev/null
+++ b/blockly/demos/blocklyfactory/workspacefactory/wfactory_generator.js
@@ -0,0 +1,252 @@
+/**
+ * @license
+ * Visual Blocks Editor
+ *
+ * Copyright 2016 Google Inc.
+ * https://developers.google.com/blockly/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @fileoverview Generates the configuration xml used to update the preview
+ * workspace or print to the console or download to a file. Leverages
+ * Blockly.Xml and depends on information in the model (holds a reference).
+ * Depends on a hidden workspace created in the generator to load saved XML in
+ * order to generate toolbox XML.
+ *
+ * @author Emma Dauterman (evd2014)
+ */
+
+goog.require('FactoryUtils');
+
+/**
+ * Class for a WorkspaceFactoryGenerator
+ * @constructor
+ */
+WorkspaceFactoryGenerator = function(model) {
+ // Model to share information about categories and shadow blocks.
+ this.model = model;
+ // Create hidden workspace to load saved XML to generate toolbox XML.
+ var hiddenBlocks = document.createElement('div');
+ // Generate a globally unique ID for the hidden div element to avoid
+ // collisions.
+ var hiddenBlocksId = Blockly.genUid();
+ hiddenBlocks.id = hiddenBlocksId;
+ hiddenBlocks.style.display = 'none';
+ document.body.appendChild(hiddenBlocks);
+ this.hiddenWorkspace = Blockly.inject(hiddenBlocksId);
+};
+
+/**
+ * Generates the xml for the toolbox or flyout with information from
+ * toolboxWorkspace and the model. Uses the hiddenWorkspace to generate XML.
+ * Save state of workspace in model (saveFromWorkspace) before calling if
+ * changes might have been made to the selected category.
+ *
+ * @param {!Blockly.workspace} toolboxWorkspace Toolbox editing workspace where
+ * blocks are added by user to be part of the toolbox.
+ * @return {!Element} XML element representing toolbox or flyout corresponding
+ * to toolbox workspace.
+ */
+WorkspaceFactoryGenerator.prototype.generateToolboxXml = function() {
+ // Create DOM for XML.
+ var xmlDom = goog.dom.createDom('xml',
+ {
+ 'id' : 'toolbox',
+ 'style' : 'display:none'
+ });
+ if (!this.model.hasElements()) {
+ // Toolbox has no categories. Use XML directly from workspace.
+ this.loadToHiddenWorkspace_(this.model.getSelectedXml());
+ this.appendHiddenWorkspaceToDom_(xmlDom);
+ } else {
+ // Toolbox has categories.
+ // Assert that selected != null
+ if (!this.model.getSelected()) {
+ throw new Error('Selected is null when the toolbox is empty.');
+ }
+
+ var xml = this.model.getSelectedXml();
+ var toolboxList = this.model.getToolboxList();
+
+ // Iterate through each category to generate XML for each using the
+ // hidden workspace. Load each category to the hidden workspace to make sure
+ // that all the blocks that are not top blocks are also captured as block
+ // groups in the flyout.
+ for (var i = 0; i < toolboxList.length; i++) {
+ var element = toolboxList[i];
+ if (element.type == ListElement.TYPE_SEPARATOR) {
+ // If the next element is a separator.
+ var nextElement = goog.dom.createDom('sep');
+ } else if (element.type == ListElement.TYPE_CATEGORY) {
+ // If the next element is a category.
+ var nextElement = goog.dom.createDom('category');
+ nextElement.setAttribute('name', element.name);
+ // Add a colour attribute if one exists.
+ if (element.color != null) {
+ nextElement.setAttribute('colour', element.color);
+ }
+ // Add a custom attribute if one exists.
+ if (element.custom != null) {
+ nextElement.setAttribute('custom', element.custom);
+ }
+ // Load that category to hidden workspace, setting user-generated shadow
+ // blocks as real shadow blocks.
+ this.loadToHiddenWorkspace_(element.xml);
+ this.appendHiddenWorkspaceToDom_(nextElement);
+ }
+ xmlDom.appendChild(nextElement);
+ }
+ }
+ return xmlDom;
+ };
+
+
+ /**
+ * Generates XML for the workspace (different from generateConfigXml in that
+ * it includes XY and ID attributes). Uses a workspace and converts user
+ * generated shadow blocks to actual shadow blocks.
+ *
+ * @return {!Element} XML element representing toolbox or flyout corresponding
+ * to toolbox workspace.
+ */
+WorkspaceFactoryGenerator.prototype.generateWorkspaceXml = function() {
+ // Load workspace XML to hidden workspace with user-generated shadow blocks
+ // as actual shadow blocks.
+ this.hiddenWorkspace.clear();
+ Blockly.Xml.domToWorkspace(this.model.getPreloadXml(), this.hiddenWorkspace);
+ this.setShadowBlocksInHiddenWorkspace_();
+
+ // Generate XML and set attributes.
+ var generatedXml = Blockly.Xml.workspaceToDom(this.hiddenWorkspace);
+ generatedXml.setAttribute('id', 'workspaceBlocks');
+ generatedXml.setAttribute('style', 'display:none');
+ return generatedXml;
+ };
+
+/**
+ * Generates a string representation of the options object for injecting the
+ * workspace and starter code.
+ *
+ * @return {!string} String representation of starter code for injecting.
+ */
+WorkspaceFactoryGenerator.prototype.generateInjectString = function() {
+
+ var addAttributes = function(obj, tabChar) {
+ if (!obj) {
+ return '{}\n';
+ }
+ var str = '';
+ for (var key in obj) {
+ if (key == 'grid' || key == 'zoom') {
+ var temp = tabChar + key + ' : {\n' + addAttributes(obj[key],
+ tabChar + '\t') + tabChar + '}, \n';
+ } else if (typeof obj[key] == 'string') {
+ var temp = tabChar + key + ' : \'' + obj[key] + '\', \n';
+ } else {
+ var temp = tabChar + key + ' : ' + obj[key] + ', \n';
+ }
+ str += temp;
+ }
+ var lastCommaIndex = str.lastIndexOf(',');
+ str = str.slice(0, lastCommaIndex) + '\n';
+ return str;
+ };
+
+ var attributes = addAttributes(this.model.options, '\t');
+ if (!this.model.options['readOnly']) {
+ attributes = '\ttoolbox : toolbox, \n' +
+ attributes;
+ }
+ var finalStr = '/* TODO: Change toolbox XML ID if necessary. Can export ' +
+ 'toolbox XML from Workspace Factory. */\n' +
+ 'var toolbox = document.getElementById("toolbox");\n\n';
+ finalStr += 'var options = { \n' + attributes + '};';
+ finalStr += '\n\n/* Inject your workspace */ \nvar workspace = Blockly.' +
+ 'inject(/* TODO: Add ID of div to inject Blockly into */, options);';
+ finalStr += '\n\n/* Load Workspace Blocks from XML to workspace. ' +
+ 'Remove all code below if no blocks to load */\n\n' +
+ '/* TODO: Change workspace blocks XML ID if necessary. Can export' +
+ ' workspace blocks XML from Workspace Factory. */\n' +
+ 'var workspaceBlocks = document.getElementById("workspaceBlocks"); \n\n' +
+ '/* Load blocks to workspace. */\n' +
+ 'Blockly.Xml.domToWorkspace(workspace, workspaceBlocks);';
+ return finalStr;
+}
+
+/**
+ * Loads the given XML to the hidden workspace and sets any user-generated
+ * shadow blocks to be actual shadow blocks.
+ * @private
+ *
+ * @param {!Element} xml The XML to be loaded to the hidden workspace.
+ */
+WorkspaceFactoryGenerator.prototype.loadToHiddenWorkspace_ = function(xml) {
+ this.hiddenWorkspace.clear();
+ Blockly.Xml.domToWorkspace(xml, this.hiddenWorkspace);
+ this.setShadowBlocksInHiddenWorkspace_();
+}
+
+ /**
+ * Encodes blocks in the hidden workspace in a XML DOM element. Very
+ * similar to workspaceToDom, but doesn't capture IDs. Uses the top-level
+ * blocks loaded in hiddenWorkspace.
+ * @private
+ *
+ * @param {!Element} xmlDom Tree of XML elements to be appended to.
+ */
+WorkspaceFactoryGenerator.prototype.appendHiddenWorkspaceToDom_ =
+ function(xmlDom) {
+ var blocks = this.hiddenWorkspace.getTopBlocks();
+ for (var i = 0, block; block = blocks[i]; i++) {
+ var blockChild = Blockly.Xml.blockToDom(block);
+ blockChild.removeAttribute('id');
+ xmlDom.appendChild(blockChild);
+ }
+};
+
+/**
+ * Sets the user-generated shadow blocks loaded into hiddenWorkspace to be
+ * actual shadow blocks. This is done so that blockToDom records them as
+ * shadow blocks instead of regular blocks.
+ * @private
+ *
+ */
+WorkspaceFactoryGenerator.prototype.setShadowBlocksInHiddenWorkspace_ =
+ function() {
+ var blocks = this.hiddenWorkspace.getAllBlocks();
+ for (var i = 0; i < blocks.length; i++) {
+ if (this.model.isShadowBlock(blocks[i].id)) {
+ blocks[i].setShadow(true);
+ }
+ }
+};
+
+/**
+ * Given a set of block types, gets the Blockly.Block objects for each block
+ * type.
+ *
+ * @param {!Array<!Element>} blockTypes Array of blocks that have been defined.
+ * @return {!Array<!Blockly.Block>} Array of Blockly.Block objects corresponding
+ * to the array of blockTypes.
+ */
+WorkspaceFactoryGenerator.prototype.getDefinedBlocks = function(blockTypes) {
+ var blocks = [];
+ for (var i = 0; i < blockTypes.length ; i++) {
+ blocks.push(FactoryUtils.getDefinedBlock(blockTypes[i],
+ this.hiddenWorkspace));
+ }
+ return blocks;
+};
+
diff --git a/blockly/demos/blocklyfactory/workspacefactory/wfactory_init.js b/blockly/demos/blocklyfactory/workspacefactory/wfactory_init.js
new file mode 100644
index 0000000..78f8b7d
--- /dev/null
+++ b/blockly/demos/blocklyfactory/workspacefactory/wfactory_init.js
@@ -0,0 +1,617 @@
+/**
+ * @license
+ * Visual Blocks Editor
+ *
+ * Copyright 2016 Google Inc.
+ * https://developers.google.com/blockly/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @fileoverview Contains the init functions for the workspace factory tab.
+ * Adds click handlers to buttons and dropdowns, adds event listeners for
+ * keydown events and Blockly events, and configures the initial setup of
+ * the page.
+ *
+ * @author Emma Dauterman (evd2014)
+ */
+
+ goog.require('FactoryUtils');
+
+/**
+ * Namespace for workspace factory initialization methods.
+ * @namespace
+ */
+WorkspaceFactoryInit = {};
+
+/**
+ * Initialization for workspace factory tab.
+ *
+ * @param {!FactoryController} controller The controller for the workspace
+ * factory tab.
+ */
+WorkspaceFactoryInit.initWorkspaceFactory = function(controller) {
+ // Disable category editing buttons until categories are created.
+ document.getElementById('button_remove').disabled = true;
+ document.getElementById('button_up').disabled = true;
+ document.getElementById('button_down').disabled = true;
+ document.getElementById('button_editCategory').disabled = true;
+
+ this.initColorPicker_(controller);
+ this.addWorkspaceFactoryEventListeners_(controller);
+ this.assignWorkspaceFactoryClickHandlers_(controller);
+ this.addWorkspaceFactoryOptionsListeners_(controller);
+
+ // Check standard options and apply the changes to update the view.
+ controller.setStandardOptionsAndUpdate();
+};
+
+/**
+ * Initialize the color picker in workspace factory.
+ * @private
+ *
+ * @param {!FactoryController} controller The controller for the workspace
+ * factory tab.
+ */
+WorkspaceFactoryInit.initColorPicker_ = function(controller) {
+ // Array of Blockly category colors, variety of hues with saturation 45%
+ // and value 65% as specified in Blockly Developer documentation:
+ // https://developers.google.com/blockly/guides/create-custom-blocks/define-blocks
+ var colors = ['#A65C5C',
+ '#A6635C',
+ '#A66A5C',
+ '#A6725C',
+ '#A6795C',
+ '#A6815C',
+ '#A6885C',
+ '#A6905C',
+ '#A6975C',
+ '#A69F5C',
+ '#A6A65C',
+ '#9FA65C',
+ '#97A65C',
+ '#90A65C',
+ '#88A65C',
+ '#81A65C',
+ '#79A65C',
+ '#6FA65C',
+ '#66A65C',
+ '#5EA65C',
+ '#5CA661',
+ '#5CA668',
+ '#5CA66F',
+ '#5CA677',
+ '#5CA67E',
+ '#5CA686',
+ '#5CA68D',
+ '#5CA695',
+ '#5CA69C',
+ '#5CA6A4',
+ '#5CA1A6',
+ '#5C9AA6',
+ '#5C92A6',
+ '#5C8BA6',
+ '#5C83A6',
+ '#5C7CA6',
+ '#5C74A6',
+ '#5C6AA6',
+ '#5C61A6',
+ '#5E5CA6',
+ '#665CA6',
+ '#6D5CA6',
+ '#745CA6',
+ '#7C5CA6',
+ '#835CA6',
+ '#8B5CA6',
+ '#925CA6',
+ '#9A5CA6',
+ '#A15CA6',
+ '#A65CA4',
+ '#A65C9C',
+ '#A65C95',
+ '#A65C8D',
+ '#A65C86',
+ '#A65C7E',
+ '#A65C77',
+ '#A65C6F',
+ '#A65C66',
+ '#A65C61',
+ '#A65C5E'];
+
+ // Create color picker with specific set of Blockly colors.
+ var colorPicker = new goog.ui.ColorPicker();
+ colorPicker.setColors(colors);
+
+ // Create and render the popup color picker and attach to button.
+ var popupPicker = new goog.ui.PopupColorPicker(null, colorPicker);
+ popupPicker.render();
+ popupPicker.attach(document.getElementById('dropdown_color'));
+ popupPicker.setFocusable(true);
+ goog.events.listen(popupPicker, 'change', function(e) {
+ controller.changeSelectedCategoryColor(popupPicker.getSelectedColor());
+ document.getElementById('dropdownDiv_editCategory').classList.remove
+ ("show");
+ });
+};
+
+/**
+ * Assign click handlers for workspace factory.
+ * @private
+ *
+ * @param {!FactoryController} controller The controller for the workspace
+ * factory tab.
+ */
+WorkspaceFactoryInit.assignWorkspaceFactoryClickHandlers_ =
+ function(controller) {
+ document.getElementById('tab_toolbox').addEventListener
+ ('click',
+ function() {
+ controller.setMode(WorkspaceFactoryController.MODE_TOOLBOX);
+ });
+
+ document.getElementById('tab_preload').addEventListener
+ ('click',
+ function() {
+ controller.setMode(WorkspaceFactoryController.MODE_PRELOAD);
+ });
+
+ document.getElementById('button_add').addEventListener
+ ('click',
+ function() {
+ document.getElementById('dropdownDiv_add').classList.toggle("show");
+ });
+
+ document.getElementById('dropdown_newCategory').addEventListener
+ ('click',
+ function() {
+ controller.addCategory();
+ document.getElementById('dropdownDiv_add').classList.remove("show");
+ });
+
+ document.getElementById('dropdown_loadCategory').addEventListener
+ ('click',
+ function() {
+ controller.loadCategory();
+ document.getElementById('dropdownDiv_add').classList.remove("show");
+ });
+
+ document.getElementById('dropdown_separator').addEventListener
+ ('click',
+ function() {
+ controller.addSeparator();
+ document.getElementById('dropdownDiv_add').classList.remove("show");
+ });
+
+ document.getElementById('dropdown_loadStandardToolbox').addEventListener
+ ('click',
+ function() {
+ controller.loadStandardToolbox();
+ document.getElementById('dropdownDiv_add').classList.remove("show");
+ });
+
+ document.getElementById('button_remove').addEventListener
+ ('click',
+ function() {
+ controller.removeElement();
+ });
+
+ document.getElementById('dropdown_exportToolbox').addEventListener
+ ('click',
+ function() {
+ controller.exportXmlFile(WorkspaceFactoryController.MODE_TOOLBOX);
+ document.getElementById('dropdownDiv_export').classList.remove("show");
+ });
+
+ document.getElementById('dropdown_exportPreload').addEventListener
+ ('click',
+ function() {
+ controller.exportXmlFile(WorkspaceFactoryController.MODE_PRELOAD);
+ document.getElementById('dropdownDiv_export').classList.remove("show");
+ });
+
+ document.getElementById('dropdown_exportOptions').addEventListener
+ ('click',
+ function() {
+ controller.exportInjectFile();
+ document.getElementById('dropdownDiv_export').classList.remove("show");
+ });
+
+ document.getElementById('dropdown_exportAll').addEventListener
+ ('click',
+ function() {
+ controller.exportInjectFile();
+ controller.exportXmlFile(WorkspaceFactoryController.MODE_TOOLBOX);
+ controller.exportXmlFile(WorkspaceFactoryController.MODE_PRELOAD);
+ document.getElementById('dropdownDiv_export').classList.remove("show");
+ });
+
+ document.getElementById('button_export').addEventListener
+ ('click',
+ function() {
+ document.getElementById('dropdownDiv_export').classList.toggle("show");
+ document.getElementById('dropdownDiv_load').classList.remove("show");
+ document.getElementById('dropdownDiv_importBlocks').classList.
+ remove("show");
+ });
+
+ document.getElementById('button_up').addEventListener
+ ('click',
+ function() {
+ controller.moveElement(-1);
+ });
+
+ document.getElementById('button_down').addEventListener
+ ('click',
+ function() {
+ controller.moveElement(1);
+ });
+
+ document.getElementById('button_editCategory').addEventListener
+ ('click',
+ function() {
+ document.getElementById('dropdownDiv_editCategory').classList.
+ toggle("show");
+ });
+
+ document.getElementById('dropdown_name').addEventListener
+ ('click',
+ function() {
+ controller.changeCategoryName();
+ document.getElementById('dropdownDiv_editCategory').classList.
+ remove("show");
+ });
+
+document.getElementById('button_importBlocks').addEventListener
+ ('click',
+ function() {
+ document.getElementById('dropdownDiv_importBlocks').classList.
+ toggle("show");
+ document.getElementById('dropdownDiv_export').classList.remove("show");
+ document.getElementById('dropdownDiv_load').classList.remove("show");
+ });
+
+ document.getElementById('button_load').addEventListener
+ ('click',
+ function() {
+ document.getElementById('dropdownDiv_load').classList.toggle("show");
+ document.getElementById('dropdownDiv_export').classList.remove("show");
+ document.getElementById('dropdownDiv_importBlocks').classList.
+ remove("show");
+ });
+
+ document.getElementById('input_loadToolbox').addEventListener
+ ('change',
+ function() {
+ controller.importFile(event.target.files[0],
+ WorkspaceFactoryController.MODE_TOOLBOX);
+ document.getElementById('dropdownDiv_load').classList.remove("show");
+ });
+
+ document.getElementById('input_loadPreload').addEventListener
+ ('change',
+ function() {
+ controller.importFile(event.target.files[0],
+ WorkspaceFactoryController.MODE_PRELOAD);
+ document.getElementById('dropdownDiv_load').classList.remove("show");
+ });
+
+ document.getElementById('input_importBlocksJson').addEventListener
+ ('change',
+ function() {
+ controller.importBlocks(event.target.files[0],'JSON');
+ document.getElementById('dropdownDiv_importBlocks').classList.
+ remove("show");
+ });
+
+ document.getElementById('input_importBlocksJs').addEventListener
+ ('change',
+ function() {
+ controller.importBlocks(event.target.files[0],'JavaScript');
+ document.getElementById('dropdownDiv_importBlocks').classList.
+ remove("show");
+ });
+
+ document.getElementById('button_clear').addEventListener
+ ('click',
+ function() {
+ document.getElementById('dropdownDiv_importBlocks').classList.
+ remove("show");
+ document.getElementById('dropdownDiv_export').classList.remove("show");
+ document.getElementById('dropdownDiv_load').classList.remove("show");
+ controller.clearAll();
+ });
+
+ document.getElementById('button_addShadow').addEventListener
+ ('click',
+ function() {
+ controller.addShadow();
+ WorkspaceFactoryInit.displayAddShadow_(false);
+ WorkspaceFactoryInit.displayRemoveShadow_(true);
+ });
+
+ document.getElementById('button_removeShadow').addEventListener
+ ('click',
+ function() {
+ controller.removeShadow();
+ WorkspaceFactoryInit.displayAddShadow_(true);
+ WorkspaceFactoryInit.displayRemoveShadow_(false);
+
+ // Disable shadow editing button if turning invalid shadow block back
+ // to normal block.
+ if (!Blockly.selected.getSurroundParent()) {
+ document.getElementById('button_addShadow').disabled = true;
+ }
+ });
+
+ document.getElementById('button_standardOptions').addEventListener
+ ('click', function() {
+ controller.setStandardOptionsAndUpdate();
+ });
+
+ document.getElementById('button_optionsHelp').addEventListener
+ ('click', function() {
+ open('https://developers.google.com/blockly/guides/get-started/web');
+ });
+};
+
+/**
+ * Add event listeners for workspace factory.
+ * @private
+ *
+ * @param {!FactoryController} controller The controller for the workspace
+ * factory tab.
+ */
+WorkspaceFactoryInit.addWorkspaceFactoryEventListeners_ = function(controller) {
+ // Use up and down arrow keys to move categories.
+ window.addEventListener('keydown', function(e) {
+ // Don't let arrow keys have any effect if not in Workspace Factory
+ // editing the toolbox.
+ if (!(controller.keyEventsEnabled && controller.selectedMode
+ == WorkspaceFactoryController.MODE_TOOLBOX)) {
+ return;
+ }
+
+ if (e.keyCode == 38) {
+ // Arrow up.
+ controller.moveElement(-1);
+ } else if (e.keyCode == 40) {
+ // Arrow down.
+ controller.moveElement(1);
+ }
+ });
+
+ // Determines if a block breaks shadow block placement rules.
+ // Breaks rules if (1) a shadow block no longer has a valid
+ // parent, or (2) a normal block is inside of a shadow block.
+ var isInvalidBlockPlacement = function(block) {
+ return ((controller.isUserGenShadowBlock(block.id) &&
+ !block.getSurroundParent()) ||
+ (!controller.isUserGenShadowBlock(block.id) && block.getSurroundParent()
+ && controller.isUserGenShadowBlock(block.getSurroundParent().id)));
+ };
+
+ // Add change listeners for toolbox workspace in workspace factory.
+ controller.toolboxWorkspace.addChangeListener(function(e) {
+ // Listen for Blockly move and delete events to update preview.
+ // Not listening for Blockly create events because causes the user to drop
+ // blocks when dragging them into workspace. Could cause problems if ever
+ // load blocks into workspace directly without calling updatePreview.
+ if (e.type == Blockly.Events.MOVE || e.type == Blockly.Events.DELETE ||
+ e.type == Blockly.Events.CHANGE) {
+ controller.saveStateFromWorkspace();
+ controller.updatePreview();
+ }
+
+ // Listen for Blockly UI events to correctly enable the "Edit Block" button.
+ // Only enable "Edit Block" when a block is selected and it has a
+ // surrounding parent, meaning it is nested in another block (blocks that
+ // are not nested in parents cannot be shadow blocks).
+ if (e.type == Blockly.Events.MOVE || (e.type == Blockly.Events.UI &&
+ e.element == 'selected')) {
+ var selected = Blockly.selected;
+
+ // Show shadow button if a block is selected. Show "Add Shadow" if
+ // a block is not a shadow block, show "Remove Shadow" if it is a
+ // shadow block.
+ if (selected) {
+ var isShadow = controller.isUserGenShadowBlock(selected.id);
+ WorkspaceFactoryInit.displayAddShadow_(!isShadow);
+ WorkspaceFactoryInit.displayRemoveShadow_(isShadow);
+ } else {
+ WorkspaceFactoryInit.displayAddShadow_(false);
+ WorkspaceFactoryInit.displayRemoveShadow_(false);
+ }
+
+ if (selected != null && selected.getSurroundParent() != null &&
+ !controller.isUserGenShadowBlock(selected.getSurroundParent().id)) {
+ // Selected block is a valid shadow block or could be a valid shadow
+ // block.
+
+ // Enable block editing and remove warnings if the block is not a
+ // variable user-generated shadow block.
+ document.getElementById('button_addShadow').disabled = false;
+ document.getElementById('button_removeShadow').disabled = false;
+
+ if (!FactoryUtils.hasVariableField(selected) &&
+ controller.isDefinedBlock(selected)) {
+ selected.setWarningText(null);
+ }
+ } else {
+ // Selected block cannot be a valid shadow block.
+
+ if (selected != null && isInvalidBlockPlacement(selected)) {
+ // Selected block breaks shadow block rules.
+ // Invalid shadow block if (1) a shadow block no longer has a valid
+ // parent, or (2) a normal block is inside of a shadow block.
+
+ if (!controller.isUserGenShadowBlock(selected.id)) {
+ // Warn if a non-shadow block is nested inside a shadow block.
+ selected.setWarningText('Only shadow blocks can be nested inside\n'
+ + 'other shadow blocks.');
+ } else if (!FactoryUtils.hasVariableField(selected)) {
+ // Warn if a shadow block is invalid only if not replacing
+ // warning for variables.
+ selected.setWarningText('Shadow blocks must be nested inside other'
+ + ' blocks.')
+ }
+
+ // Give editing options so that the user can make an invalid shadow
+ // block a normal block.
+ document.getElementById('button_removeShadow').disabled = false;
+ document.getElementById('button_addShadow').disabled = true;
+ } else {
+ // Selected block does not break any shadow block rules, but cannot
+ // be a shadow block.
+
+ // Remove possible 'invalid shadow block placement' warning.
+ if (selected != null && controller.isDefinedBlock(selected) &&
+ (!FactoryUtils.hasVariableField(selected) ||
+ !controller.isUserGenShadowBlock(selected.id))) {
+ selected.setWarningText(null);
+ }
+
+ // No block selected that is a shadow block or could be a valid shadow
+ // block. Disable block editing.
+ document.getElementById('button_addShadow').disabled = true;
+ document.getElementById('button_removeShadow').disabled = true;
+ }
+ }
+ }
+
+ // Convert actual shadow blocks added from the toolbox to user-generated
+ // shadow blocks.
+ if (e.type == Blockly.Events.CREATE) {
+ controller.convertShadowBlocks();
+
+ // Let the user create a Variables or Functions category if they use
+ // blocks from either category.
+
+ // Get all children of a block and add them to childList.
+ var getAllChildren = function(block, childList) {
+ childList.push(block);
+ var children = block.getChildren();
+ for (var i = 0, child; child = children[i]; i++) {
+ getAllChildren(child, childList);
+ }
+ };
+
+ var newBaseBlock = controller.toolboxWorkspace.getBlockById(e.blockId);
+ var allNewBlocks = [];
+ getAllChildren(newBaseBlock, allNewBlocks);
+ var variableCreated = false;
+ var procedureCreated = false;
+
+ // Check if the newly created block or any of its children are variable
+ // or procedure blocks.
+ for (var i = 0, block; block = allNewBlocks[i]; i++) {
+ if (FactoryUtils.hasVariableField(block)) {
+ variableCreated = true;
+ } else if (FactoryUtils.isProcedureBlock(block)) {
+ procedureCreated = true;
+ }
+ }
+
+ // If any of the newly created blocks are variable or procedure blocks,
+ // prompt the user to create the corresponding standard category.
+ if (variableCreated && !controller.hasVariablesCategory()) {
+ if (confirm('Your new block has a variables field. To use this block '
+ + 'fully, you will need a Variables category. Do you want to add '
+ + 'a Variables category to your custom toolbox?')) {
+ controller.setMode(WorkspaceFactoryController.MODE_TOOLBOX);
+ controller.loadCategoryByName('variables');
+ }
+ }
+
+ if (procedureCreated && !controller.hasProceduresCategory()) {
+ if (confirm('Your new block is a function block. To use this block '
+ + 'fully, you will need a Functions category. Do you want to add '
+ + 'a Functions category to your custom toolbox?')) {
+ controller.setMode(WorkspaceFactoryController.MODE_TOOLBOX);
+ controller.loadCategoryByName('functions');
+ }
+ }
+ }
+ });
+};
+
+/**
+ * Display or hide the add shadow button.
+ *
+ * @param {boolean} show True if the add shadow button should be shown, false
+ * otherwise.
+ */
+WorkspaceFactoryInit.displayAddShadow_ = function(show) {
+ document.getElementById('button_addShadow').style.display =
+ show ? 'inline-block' : 'none';
+};
+
+/**
+ * Display or hide the remove shadow button.
+ *
+ * @param {boolean} show True if the remove shadow button should be shown, false
+ * otherwise.
+ */
+WorkspaceFactoryInit.displayRemoveShadow_ = function(show) {
+ document.getElementById('button_removeShadow').style.display =
+ show ? 'inline-block' : 'none';
+}
+
+/**
+ * Add listeners for workspace factory options input elements.
+ * @private
+ *
+ * @param {!FactoryController} controller The controller for the workspace
+ * factory tab.
+ */
+WorkspaceFactoryInit.addWorkspaceFactoryOptionsListeners_ =
+ function(controller) {
+
+ // Checking the grid checkbox displays grid options.
+ document.getElementById('option_grid_checkbox').addEventListener('change',
+ function(e) {
+ document.getElementById('grid_options').style.display =
+ document.getElementById('option_grid_checkbox').checked ?
+ 'block' : 'none';
+ });
+
+ // Checking the grid checkbox displays zoom options.
+ document.getElementById('option_zoom_checkbox').addEventListener('change',
+ function(e) {
+ document.getElementById('zoom_options').style.display =
+ document.getElementById('option_zoom_checkbox').checked ?
+ 'block' : 'none';
+ });
+
+ document.getElementById('option_readOnly_checkbox').addEventListener('change',
+ function(e) {
+ document.getElementById('trashcan_option').style.display =
+ document.getElementById('option_readOnly_checkbox').checked ?
+ 'none' : 'block';
+ });
+
+ document.getElementById('option_infiniteBlocks_checkbox').addEventListener('change',
+ function(e) {
+ document.getElementById('maxBlockNumber_option').style.display =
+ document.getElementById('option_infiniteBlocks_checkbox').checked ?
+ 'none' : 'block';
+ });
+
+ // Generate new options every time an options input is updated.
+ var optionsElements = document.getElementsByClassName('optionsInput');
+ for (var i = 0; i < optionsElements.length; i++) {
+ optionsElements[i].addEventListener('change', function() {
+ controller.generateNewOptions();
+ });
+ }
+};
diff --git a/blockly/demos/blocklyfactory/workspacefactory/wfactory_model.js b/blockly/demos/blocklyfactory/workspacefactory/wfactory_model.js
new file mode 100644
index 0000000..eabaafb
--- /dev/null
+++ b/blockly/demos/blocklyfactory/workspacefactory/wfactory_model.js
@@ -0,0 +1,599 @@
+/**
+ * @license
+ * Visual Blocks Editor
+ *
+ * Copyright 2016 Google Inc.
+ * https://developers.google.com/blockly/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @fileoverview Stores and updates information about state and categories
+ * in workspace factory. Each list element is either a separator or a category,
+ * and each category stores its name, XML to load that category, color,
+ * custom tags, and a unique ID making it possible to change category names and
+ * move categories easily. Keeps track of the currently selected list
+ * element. Also keeps track of all the user-created shadow blocks and
+ * manipulates them as necessary.
+ *
+ * @author Emma Dauterman (evd2014)
+ */
+
+/**
+ * Class for a WorkspaceFactoryModel
+ * @constructor
+ */
+WorkspaceFactoryModel = function() {
+ // Ordered list of ListElement objects. Empty if there is a single flyout.
+ this.toolboxList = [];
+ // ListElement for blocks in a single flyout. Null if a toolbox exists.
+ this.flyout = new ListElement(ListElement.TYPE_FLYOUT);
+ // Array of block IDs for all user created shadow blocks.
+ this.shadowBlocks = [];
+ // Reference to currently selected ListElement. Stored in this.toolboxList if
+ // there are categories, or in this.flyout if blocks are displayed in a single
+ // flyout.
+ this.selected = this.flyout;
+ // Boolean for if a Variable category has been added.
+ this.hasVariableCategory = false;
+ // Boolean for if a Procedure category has been added.
+ this.hasProcedureCategory = false;
+ // XML to be pre-loaded to workspace. Empty on default;
+ this.preloadXml = Blockly.Xml.textToDom('<xml></xml>');
+ // Options object to be configured for Blockly inject call.
+ this.options = new Object(null);
+ // Block Library block types.
+ this.libBlockTypes = [];
+ // Imported block types.
+ this.importedBlockTypes = [];
+ //
+};
+
+/**
+ * Given a name, determines if it is the name of a category already present.
+ * Used when getting a valid category name from the user.
+ *
+ * @param {string} name String name to be compared against.
+ * @return {boolean} True if string is a used category name, false otherwise.
+ */
+WorkspaceFactoryModel.prototype.hasCategoryByName = function(name) {
+ for (var i = 0; i < this.toolboxList.length; i++) {
+ if (this.toolboxList[i].type == ListElement.TYPE_CATEGORY &&
+ this.toolboxList[i].name == name) {
+ return true;
+ }
+ }
+ return false;
+};
+
+/**
+ * Determines if a category with the 'VARIABLE' tag exists.
+ *
+ * @return {boolean} True if there exists a category with the Variables tag,
+ * false otherwise.
+ */
+WorkspaceFactoryModel.prototype.hasVariables = function() {
+ return this.hasVariableCategory;
+};
+
+/**
+ * Determines if a category with the 'PROCEDURE' tag exists.
+ *
+ * @return {boolean} True if there exists a category with the Procedures tag,
+ * false otherwise.
+ */
+WorkspaceFactoryModel.prototype.hasProcedures = function() {
+ return this.hasProcedureCategory;
+};
+
+/**
+ * Determines if the user has any elements in the toolbox. Uses the length of
+ * toolboxList.
+ *
+ * @return {boolean} True if elements exist, false otherwise.
+ */
+WorkspaceFactoryModel.prototype.hasElements = function() {
+ return this.toolboxList.length > 0;
+};
+
+/**
+ * Given a ListElement, adds it to the toolbox list.
+ *
+ * @param {!ListElement} element The element to be added to the list.
+ */
+WorkspaceFactoryModel.prototype.addElementToList = function(element) {
+ // Update state if the copied category has a custom tag.
+ this.hasVariableCategory = element.custom == 'VARIABLE' ? true :
+ this.hasVariableCategory;
+ this.hasProcedureCategory = element.custom == 'PROCEDURE' ? true :
+ this.hasProcedureCategory;
+ // Add element to toolboxList.
+ this.toolboxList.push(element);
+ // Empty single flyout.
+ this.flyout = null;
+};
+
+/**
+ * Given an index, deletes a list element and all associated data.
+ *
+ * @param {int} index The index of the list element to delete.
+ */
+WorkspaceFactoryModel.prototype.deleteElementFromList = function(index) {
+ // Check if index is out of bounds.
+ if (index < 0 || index >= this.toolboxList.length) {
+ return; // No entry to delete.
+ }
+ // Check if need to update flags.
+ this.hasVariableCategory = this.toolboxList[index].custom == 'VARIABLE' ?
+ false : this.hasVariableCategory;
+ this.hasProcedureCategory = this.toolboxList[index].custom == 'PROCEDURE' ?
+ false : this.hasProcedureCategory;
+ // Remove element.
+ this.toolboxList.splice(index, 1);
+};
+
+/**
+ * Sets selected to be an empty category not in toolbox list if toolbox list
+ * is empty. Should be called when removing the last element from toolbox list.
+ * If the toolbox list is empty, selected stores the XML for the single flyout
+ * of blocks displayed.
+ *
+ */
+WorkspaceFactoryModel.prototype.createDefaultSelectedIfEmpty = function() {
+ if (this.toolboxList.length == 0) {
+ this.flyout = new ListElement(ListElement.TYPE_FLYOUT);
+ this.selected = this.flyout;
+ }
+}
+
+/**
+ * Moves a list element to a certain position in toolboxList by removing it
+ * and then inserting it at the correct index. Checks that indices are in
+ * bounds (throws error if not), but assumes that oldIndex is the correct index
+ * for list element.
+ *
+ * @param {!ListElement} element The element to move in toolboxList.
+ * @param {int} newIndex The index to insert the element at.
+ * @param {int} oldIndex The index the element is currently at.
+ */
+WorkspaceFactoryModel.prototype.moveElementToIndex = function(element, newIndex,
+ oldIndex) {
+ // Check that indexes are in bounds.
+ if (newIndex < 0 || newIndex >= this.toolboxList.length || oldIndex < 0 ||
+ oldIndex >= this.toolboxList.length) {
+ throw new Error('Index out of bounds when moving element in the model.');
+ }
+ this.deleteElementFromList(oldIndex);
+ this.toolboxList.splice(newIndex, 0, element);
+}
+
+/**
+ * Returns the ID of the currently selected element. Returns null if there are
+ * no categories (if selected == null).
+ *
+ * @return {string} The ID of the element currently selected.
+ */
+WorkspaceFactoryModel.prototype.getSelectedId = function() {
+ return this.selected ? this.selected.id : null;
+};
+
+/**
+ * Returns the name of the currently selected category. Returns null if there
+ * are no categories (if selected == null) or the selected element is not
+ * a category (in which case its name is null).
+ *
+ * @return {string} The name of the category currently selected.
+ */
+WorkspaceFactoryModel.prototype.getSelectedName = function() {
+ return this.selected ? this.selected.name : null;
+};
+
+/**
+ * Returns the currently selected list element object.
+ *
+ * @return {ListElement} The currently selected ListElement
+ */
+WorkspaceFactoryModel.prototype.getSelected = function() {
+ return this.selected;
+};
+
+/**
+ * Sets list element currently selected by id.
+ *
+ * @param {string} id ID of list element that should now be selected.
+ */
+WorkspaceFactoryModel.prototype.setSelectedById = function(id) {
+ this.selected = this.getElementById(id);
+};
+
+/**
+ * Given an ID of a list element, returns the index of that list element in
+ * toolboxList. Returns -1 if ID is not present.
+ *
+ * @param {!string} id The ID of list element to search for.
+ * @return {int} The index of the list element in toolboxList, or -1 if it
+ * doesn't exist.
+ */
+
+WorkspaceFactoryModel.prototype.getIndexByElementId = function(id) {
+ for (var i = 0; i < this.toolboxList.length; i++) {
+ if (this.toolboxList[i].id == id) {
+ return i;
+ }
+ }
+ return -1; // ID not present in toolboxList.
+};
+
+/**
+ * Given the ID of a list element, returns that ListElement object.
+ *
+ * @param {!string} id The ID of element to search for.
+ * @return {ListElement} Corresponding ListElement object in toolboxList, or
+ * null if that element does not exist.
+ */
+WorkspaceFactoryModel.prototype.getElementById = function(id) {
+ for (var i = 0; i < this.toolboxList.length; i++) {
+ if (this.toolboxList[i].id == id) {
+ return this.toolboxList[i];
+ }
+ }
+ return null; // ID not present in toolboxList.
+};
+
+/**
+ * Given the index of a list element in toolboxList, returns that ListElement
+ * object.
+ *
+ * @param {int} index The index of the element to return.
+ * @return {ListElement} The corresponding ListElement object in toolboxList.
+ */
+WorkspaceFactoryModel.prototype.getElementByIndex = function(index) {
+ if (index < 0 || index >= this.toolboxList.length) {
+ return null;
+ }
+ return this.toolboxList[index];
+};
+
+/**
+ * Returns the xml to load the selected element.
+ *
+ * @return {!Element} The XML of the selected element, or null if there is
+ * no selected element.
+ */
+WorkspaceFactoryModel.prototype.getSelectedXml = function() {
+ return this.selected ? this.selected.xml : null;
+};
+
+/**
+ * Return ordered list of ListElement objects.
+ *
+ * @return {!Array<!ListElement>} ordered list of ListElement objects
+ */
+WorkspaceFactoryModel.prototype.getToolboxList = function() {
+ return this.toolboxList;
+};
+
+/**
+ * Gets the ID of a category given its name.
+ *
+ * @param {string} name Name of category.
+ * @return {int} ID of category
+ */
+WorkspaceFactoryModel.prototype.getCategoryIdByName = function(name) {
+ for (var i = 0; i < this.toolboxList.length; i++) {
+ if (this.toolboxList[i].name == name) {
+ return this.toolboxList[i].id;
+ }
+ }
+ return null; // Name not present in toolboxList.
+};
+
+/**
+ * Clears the toolbox list, deleting all ListElements.
+ */
+WorkspaceFactoryModel.prototype.clearToolboxList = function() {
+ this.toolboxList = [];
+ this.hasVariableCategory = false;
+ this.hasProcedureCategory = false;
+ this.shadowBlocks = [];
+ this.selected.xml = Blockly.Xml.textToDom('<xml></xml>');
+};
+
+/**
+ * Class for a ListElement
+ * Adds a shadow block to the list of shadow blocks.
+ *
+ * @param {!string} blockId The unique ID of block to be added.
+ */
+WorkspaceFactoryModel.prototype.addShadowBlock = function(blockId) {
+ this.shadowBlocks.push(blockId);
+};
+
+/**
+ * Removes a shadow block ID from the list of shadow block IDs if that ID is
+ * in the list.
+ *
+ * @param {!string} blockId The unique ID of block to be removed.
+ */
+WorkspaceFactoryModel.prototype.removeShadowBlock = function(blockId) {
+ for (var i = 0; i < this.shadowBlocks.length; i++) {
+ if (this.shadowBlocks[i] == blockId) {
+ this.shadowBlocks.splice(i, 1);
+ return;
+ }
+ }
+};
+
+/**
+ * Determines if a block is a shadow block given a unique block ID.
+ *
+ * @param {!string} blockId The unique ID of the block to examine.
+ * @return {boolean} True if the block is a user-generated shadow block, false
+ * otherwise.
+ */
+WorkspaceFactoryModel.prototype.isShadowBlock = function(blockId) {
+ for (var i = 0; i < this.shadowBlocks.length; i++) {
+ if (this.shadowBlocks[i] == blockId) {
+ return true;
+ }
+ }
+ return false;
+};
+
+/**
+ * Given a set of blocks currently loaded, returns all blocks in the workspace
+ * that are user generated shadow blocks.
+ *
+ * @param {!<Blockly.Block>} blocks Array of blocks currently loaded.
+ * @return {!<Blockly.Block>} Array of user-generated shadow blocks currently
+ * loaded.
+ */
+WorkspaceFactoryModel.prototype.getShadowBlocksInWorkspace =
+ function(workspaceBlocks) {
+ var shadowsInWorkspace = [];
+ for (var i = 0; i < workspaceBlocks.length; i++) {
+ if (this.isShadowBlock(workspaceBlocks[i].id)) {
+ shadowsInWorkspace.push(workspaceBlocks[i]);
+ }
+ }
+ return shadowsInWorkspace;
+};
+
+/**
+ * Adds a custom tag to a category, updating state variables accordingly.
+ * Only accepts 'VARIABLE' and 'PROCEDURE' tags.
+ *
+ * @param {!ListElement} category The category to add the tag to.
+ * @param {!string} tag The custom tag to add to the category.
+ */
+WorkspaceFactoryModel.prototype.addCustomTag = function(category, tag) {
+ // Only update list elements that are categories.
+ if (category.type != ListElement.TYPE_CATEGORY) {
+ return;
+ }
+ // Only update the tag to be 'VARIABLE' or 'PROCEDURE'.
+ if (tag == 'VARIABLE') {
+ this.hasVariableCategory = true;
+ category.custom = 'VARIABLE';
+ } else if (tag == 'PROCEDURE') {
+ this.hasProcedureCategory = true;
+ category.custom = 'PROCEDURE';
+ }
+};
+
+/**
+ * Have basic pre-loaded workspace working
+ * Saves XML as XML to be pre-loaded into the workspace.
+ *
+ * @param {!Element} xml The XML to be saved.
+ */
+WorkspaceFactoryModel.prototype.savePreloadXml = function(xml) {
+ this.preloadXml = xml
+};
+
+/**
+ * Gets the XML to be pre-loaded into the workspace.
+ *
+ * @return {!Element} The XML for the workspace.
+ */
+WorkspaceFactoryModel.prototype.getPreloadXml = function() {
+ return this.preloadXml;
+};
+
+/**
+ * Sets a new options object for injecting a Blockly workspace.
+ *
+ * @param {Object} options Options object for injecting a Blockly workspace.
+ */
+WorkspaceFactoryModel.prototype.setOptions = function(options) {
+ this.options = options;
+};
+
+/*
+ * Returns an array of all the block types currently being used in the toolbox
+ * and the pre-loaded blocks. No duplicates.
+ * TODO(evd2014): Move pushBlockTypesToList to FactoryUtils.
+ *
+ * @return {!Array<!string>} Array of block types currently being used.
+ */
+WorkspaceFactoryModel.prototype.getAllUsedBlockTypes = function() {
+ var blockTypeList = [];
+
+ // Given XML for the workspace, adds all block types included in the XML
+ // to the list, not including duplicates.
+ var pushBlockTypesToList = function(xml, list) {
+ // Get all block XML nodes.
+ var blocks = xml.getElementsByTagName('block');
+
+ // Add block types if not already in list.
+ for (var i = 0; i < blocks.length; i++) {
+ var type = blocks[i].getAttribute('type');
+ if (list.indexOf(type) == -1) {
+ list.push(type);
+ }
+ }
+ };
+
+ if (this.flyout) {
+ // If has a single flyout, add block types for the single flyout.
+ pushBlockTypesToList(this.getSelectedXml(), blockTypeList);
+ } else {
+ // If has categories, add block types for each category.
+
+ for (var i = 0, category; category = this.toolboxList[i]; i++) {
+ if (category.type == ListElement.TYPE_CATEGORY) {
+ pushBlockTypesToList(category.xml, blockTypeList);
+ }
+ }
+ }
+
+ // Add the block types from any pre-loaded blocks.
+ pushBlockTypesToList(this.getPreloadXml(), blockTypeList);
+
+ return blockTypeList;
+};
+
+/**
+ * Adds new imported block types to the list of current imported block types.
+ *
+ * @param {!Array<!string>} blockTypes Array of block types imported.
+ */
+WorkspaceFactoryModel.prototype.addImportedBlockTypes = function(blockTypes) {
+ this.importedBlockTypes = this.importedBlockTypes.concat(blockTypes);
+};
+
+/**
+ * Updates block types in block library.
+ *
+ * @param {!Array<!string>} blockTypes Array of block types in block library.
+ */
+WorkspaceFactoryModel.prototype.updateLibBlockTypes = function(blockTypes) {
+ this.libBlockTypes = blockTypes;
+};
+
+/**
+ * Determines if a block type is defined as a standard block, in the block
+ * library, or as an imported block.
+ *
+ * @param {!string} blockType Block type to check.
+ * @return {boolean} True if blockType is defined, false otherwise.
+ */
+WorkspaceFactoryModel.prototype.isDefinedBlockType = function(blockType) {
+ var isStandardBlock = StandardCategories.coreBlockTypes.indexOf(blockType)
+ != -1;
+ var isLibBlock = this.libBlockTypes.indexOf(blockType) != -1;
+ var isImportedBlock = this.importedBlockTypes.indexOf(blockType) != -1;
+ return (isStandardBlock || isLibBlock || isImportedBlock);
+};
+
+/**
+ * Checks if any of the block types are already defined.
+ *
+ * @param {!Array<!string>} blockTypes Array of block types.
+ * @return {boolean} True if a block type in the array is already defined,
+ * false if none of the blocks are already defined.
+ */
+WorkspaceFactoryModel.prototype.hasDefinedBlockTypes = function(blockTypes) {
+ for (var i = 0, blockType; blockType = blockTypes[i]; i++) {
+ if (this.isDefinedBlockType(blockType)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+/**
+ * Class for a ListElement.
+ * @constructor
+ */
+ListElement = function(type, opt_name) {
+ this.type = type;
+ // XML DOM element to load the element.
+ this.xml = Blockly.Xml.textToDom('<xml></xml>');
+ // Name of category. Can be changed by user. Null if separator.
+ this.name = opt_name ? opt_name : null;
+ // Unique ID of element. Does not change.
+ this.id = Blockly.genUid();
+ // Color of category. Default is no color. Null if separator.
+ this.color = null;
+ // Stores a custom tag, if necessary. Null if no custom tag or separator.
+ this.custom = null;
+};
+
+// List element types.
+ListElement.TYPE_CATEGORY = 'category';
+ListElement.TYPE_SEPARATOR = 'separator';
+ListElement.TYPE_FLYOUT = 'flyout';
+
+/**
+ * Saves a category by updating its XML (does not save XML for
+ * elements that are not categories).
+ *
+ * @param {!Blockly.workspace} workspace The workspace to save category entry
+ * from.
+ */
+ListElement.prototype.saveFromWorkspace = function(workspace) {
+ // Only save XML for categories and flyouts.
+ if (this.type == ListElement.TYPE_FLYOUT ||
+ this.type == ListElement.TYPE_CATEGORY) {
+ this.xml = Blockly.Xml.workspaceToDom(workspace);
+ }
+};
+
+
+/**
+ * Changes the name of a category object given a new name. Returns if
+ * not a category.
+ *
+ * @param {string} name New name of category.
+ */
+ListElement.prototype.changeName = function (name) {
+ // Only update list elements that are categories.
+ if (this.type != ListElement.TYPE_CATEGORY) {
+ return;
+ }
+ this.name = name;
+};
+
+/**
+ * Sets the color of a category. If tries to set the color of something other
+ * than a category, returns.
+ *
+ * @param {!string} color The color that should be used for that category.
+ */
+ListElement.prototype.changeColor = function (color) {
+ if (this.type != ListElement.TYPE_CATEGORY) {
+ return;
+ }
+ this.color = color;
+};
+
+/**
+ * Makes a copy of the original element and returns it. Everything about the
+ * copy is identical except for its ID.
+ *
+ * @return {!ListElement} The copy of the ListElement.
+ */
+ListElement.prototype.copy = function() {
+ copy = new ListElement(this.type);
+ // Generate a unique ID for the element.
+ copy.id = Blockly.genUid();
+ // Copy all attributes except ID.
+ copy.name = this.name;
+ copy.xml = this.xml;
+ copy.color = this.color;
+ copy.custom = this.custom;
+ // Return copy.
+ return copy;
+};
diff --git a/blockly/demos/blocklyfactory/workspacefactory/wfactory_view.js b/blockly/demos/blocklyfactory/workspacefactory/wfactory_view.js
new file mode 100644
index 0000000..6bfb8f9
--- /dev/null
+++ b/blockly/demos/blocklyfactory/workspacefactory/wfactory_view.js
@@ -0,0 +1,452 @@
+/**
+ * @license
+ * Visual Blocks Editor
+ *
+ * Copyright 2016 Google Inc.
+ * https://developers.google.com/blockly/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Controls the UI elements for workspace factory, mainly the category tabs.
+ * Also includes downloading files because that interacts directly with the DOM.
+ * Depends on WorkspaceFactoryController (for adding mouse listeners). Tabs for
+ * each category are stored in tab map, which associates a unique ID for a
+ * category with a particular tab.
+ *
+ * @author Emma Dauterman (edauterman)
+ */
+
+ goog.require('FactoryUtils');
+
+ /**
+ * Class for a WorkspaceFactoryView
+ * @constructor
+ */
+
+WorkspaceFactoryView = function() {
+ // For each tab, maps ID of a ListElement to the td DOM element.
+ this.tabMap = Object.create(null);
+};
+
+/**
+ * Adds a category tab to the UI, and updates tabMap accordingly.
+ *
+ * @param {!string} name The name of the category being created
+ * @param {!string} id ID of category being created
+ * @return {!Element} DOM element created for tab
+ */
+WorkspaceFactoryView.prototype.addCategoryRow = function(name, id) {
+ var table = document.getElementById('categoryTable');
+ var count = table.rows.length;
+
+ // Delete help label and enable category buttons if it's the first category.
+ if (count == 0) {
+ document.getElementById('categoryHeader').textContent = 'Your Categories:';
+ }
+
+ // Create tab.
+ var row = table.insertRow(count);
+ var nextEntry = row.insertCell(0);
+ // Configure tab.
+ nextEntry.id = this.createCategoryIdName(name);
+ nextEntry.textContent = name;
+ // Store tab.
+ this.tabMap[id] = table.rows[count].cells[0];
+ // Return tab.
+ return nextEntry;
+};
+
+/**
+ * Deletes a category tab from the UI and updates tabMap accordingly.
+ *
+ * @param {!string} id ID of category to be deleted.
+ * @param {!string} name The name of the category to be deleted.
+ */
+WorkspaceFactoryView.prototype.deleteElementRow = function(id, index) {
+ // Delete tab entry.
+ delete this.tabMap[id];
+ // Delete tab row.
+ var table = document.getElementById('categoryTable');
+ var count = table.rows.length;
+ table.deleteRow(index);
+
+ // If last category removed, add category help text and disable category
+ // buttons.
+ this.addEmptyCategoryMessage();
+};
+
+/**
+ * If there are no toolbox elements created, adds a help message to show
+ * where categories will appear. Should be called when deleting list elements
+ * in case the last element is deleted.
+ */
+WorkspaceFactoryView.prototype.addEmptyCategoryMessage = function() {
+ var table = document.getElementById('categoryTable');
+ if (table.rows.length == 0) {
+ document.getElementById('categoryHeader').textContent =
+ 'Your categories will appear here';
+ }
+}
+
+/**
+ * Given the index of the currently selected element, updates the state of
+ * the buttons that allow the user to edit the list elements. Updates the edit
+ * and arrow buttons. Should be called when adding or removing elements
+ * or when changing to a new element or when swapping to a different element.
+ *
+ * TODO(evd2014): Switch to using CSS to add/remove styles.
+ *
+ * @param {int} selectedIndex The index of the currently selected category,
+ * -1 if no categories created.
+ * @param {ListElement} selected The selected ListElement.
+ */
+WorkspaceFactoryView.prototype.updateState = function(selectedIndex, selected) {
+ // Disable/enable editing buttons as necessary.
+ document.getElementById('button_editCategory').disabled = selectedIndex < 0 ||
+ selected.type != ListElement.TYPE_CATEGORY;
+ document.getElementById('button_remove').disabled = selectedIndex < 0;
+ document.getElementById('button_up').disabled =
+ selectedIndex <= 0 ? true : false;
+ var table = document.getElementById('categoryTable');
+ document.getElementById('button_down').disabled = selectedIndex >=
+ table.rows.length - 1 || selectedIndex < 0 ? true : false;
+ // Disable/enable the workspace as necessary.
+ this.disableWorkspace(this.shouldDisableWorkspace(selected));
+};
+
+/**
+ * Determines the DOM id for a category given its name.
+ *
+ * @param {!string} name Name of category
+ * @return {!string} ID of category tab
+ */
+WorkspaceFactoryView.prototype.createCategoryIdName = function(name) {
+ return 'tab_' + name;
+};
+
+/**
+ * Switches a tab on or off.
+ *
+ * @param {!string} id ID of the tab to switch on or off.
+ * @param {boolean} selected True if tab should be on, false if tab should be
+ * off.
+ */
+WorkspaceFactoryView.prototype.setCategoryTabSelection =
+ function(id, selected) {
+ if (!this.tabMap[id]) {
+ return; // Exit if tab does not exist.
+ }
+ this.tabMap[id].className = selected ? 'tabon' : 'taboff';
+};
+
+/**
+ * Used to bind a click to a certain DOM element (used for category tabs).
+ * Taken directly from code.js
+ *
+ * @param {string|!Element} e1 tab element or corresponding id string
+ * @param {!Function} func Function to be executed on click
+ */
+WorkspaceFactoryView.prototype.bindClick = function(el, func) {
+ if (typeof el == 'string') {
+ el = document.getElementById(el);
+ }
+ el.addEventListener('click', func, true);
+ el.addEventListener('touchend', func, true);
+};
+
+/**
+ * Creates a file and downloads it. In some browsers downloads, and in other
+ * browsers, opens new tab with contents.
+ *
+ * @param {!string} filename Name of file
+ * @param {!Blob} data Blob containing contents to download
+ */
+WorkspaceFactoryView.prototype.createAndDownloadFile =
+ function(filename, data) {
+ var clickEvent = new MouseEvent("click", {
+ "view": window,
+ "bubbles": true,
+ "cancelable": false
+ });
+ var a = document.createElement('a');
+ a.href = window.URL.createObjectURL(data);
+ a.download = filename;
+ a.textContent = 'Download file!';
+ a.dispatchEvent(clickEvent);
+ };
+
+/**
+ * Given the ID of a certain category, updates the corresponding tab in
+ * the DOM to show a new name.
+ *
+ * @param {!string} newName Name of string to be displayed on tab
+ * @param {!string} id ID of category to be updated
+ *
+ */
+WorkspaceFactoryView.prototype.updateCategoryName = function(newName, id) {
+ this.tabMap[id].textContent = newName;
+ this.tabMap[id].id = this.createCategoryIdName(newName);
+};
+
+/**
+ * Moves a tab from one index to another. Adjusts index inserting before
+ * based on if inserting before or after. Checks that the indexes are in
+ * bounds, throws error if not.
+ *
+ * @param {!string} id The ID of the category to move.
+ * @param {int} newIndex The index to move the category to.
+ * @param {int} oldIndex The index the category is currently at.
+ */
+WorkspaceFactoryView.prototype.moveTabToIndex =
+ function(id, newIndex, oldIndex) {
+ var table = document.getElementById('categoryTable');
+ // Check that indexes are in bounds
+ if (newIndex < 0 || newIndex >= table.rows.length || oldIndex < 0 ||
+ oldIndex >= table.rows.length) {
+ throw new Error('Index out of bounds when moving tab in the view.');
+ }
+
+ if (newIndex < oldIndex) {
+ // Inserting before.
+ var row = table.insertRow(newIndex);
+ row.appendChild(this.tabMap[id]);
+ table.deleteRow(oldIndex + 1);
+ } else {
+ // Inserting after.
+ var row = table.insertRow(newIndex + 1);
+ row.appendChild(this.tabMap[id]);
+ table.deleteRow(oldIndex);
+ }
+};
+
+/**
+ * Given a category ID and color, use that color to color the left border of the
+ * tab for that category.
+ *
+ * @param {!string} id The ID of the category to color.
+ * @param {!string} color The color for to be used for the border of the tab.
+ * Must be a valid CSS string.
+ */
+WorkspaceFactoryView.prototype.setBorderColor = function(id, color) {
+ var tab = this.tabMap[id];
+ tab.style.borderLeftWidth = "8px";
+ tab.style.borderLeftStyle = "solid";
+ tab.style.borderColor = color;
+};
+
+/**
+ * Given a separator ID, creates a corresponding tab in the view, updates
+ * tab map, and returns the tab.
+ *
+ * @param {!string} id The ID of the separator.
+ * @param {!Element} The td DOM element representing the separator.
+ */
+WorkspaceFactoryView.prototype.addSeparatorTab = function(id) {
+ var table = document.getElementById('categoryTable');
+ var count = table.rows.length;
+
+ if (count == 0) {
+ document.getElementById('categoryHeader').textContent = 'Your Categories:';
+ }
+ // Create separator.
+ var row = table.insertRow(count);
+ var nextEntry = row.insertCell(0);
+ // Configure separator.
+ nextEntry.style.height = '10px';
+ // Store and return separator.
+ this.tabMap[id] = table.rows[count].cells[0];
+ return nextEntry;
+};
+
+/**
+ * Disables or enables the workspace by putting a div over or under the
+ * toolbox workspace, depending on the value of disable. Used when switching
+ * to/from separators where the user shouldn't be able to drag blocks into
+ * the workspace.
+ *
+ * @param {boolean} disable True if the workspace should be disabled, false
+ * if it should be enabled.
+ */
+WorkspaceFactoryView.prototype.disableWorkspace = function(disable) {
+ if (disable) {
+ document.getElementById('toolbox_section').className = 'disabled';
+ document.getElementById('toolbox_blocks').style.pointerEvents = 'none';
+ } else {
+ document.getElementById('toolbox_section').className = '';
+ document.getElementById('toolbox_blocks').style.pointerEvents = 'auto';
+ }
+
+};
+
+/**
+ * Determines if the workspace should be disabled. The workspace should be
+ * disabled if category is a separator or has VARIABLE or PROCEDURE tags.
+ *
+ * @return {boolean} True if the workspace should be disabled, false otherwise.
+ */
+WorkspaceFactoryView.prototype.shouldDisableWorkspace = function(category) {
+ return category != null && category.type != ListElement.TYPE_FLYOUT &&
+ (category.type == ListElement.TYPE_SEPARATOR ||
+ category.custom == 'VARIABLE' || category.custom == 'PROCEDURE');
+};
+
+/*
+ * Removes all categories and separators in the view. Clears the tabMap to
+ * reflect this.
+ */
+WorkspaceFactoryView.prototype.clearToolboxTabs = function() {
+ this.tabMap = [];
+ var oldCategoryTable = document.getElementById('categoryTable');
+ var newCategoryTable = document.createElement('table');
+ newCategoryTable.id = 'categoryTable';
+ newCategoryTable.style.width = 'auto';
+ oldCategoryTable.parentElement.replaceChild(newCategoryTable,
+ oldCategoryTable);
+};
+
+/**
+ * Given a set of blocks currently loaded user-generated shadow blocks, visually
+ * marks them without making them actual shadow blocks (allowing them to still
+ * be editable and movable).
+ *
+ * @param {!<Blockly.Block>} blocks Array of user-generated shadow blocks
+ * currently loaded.
+ */
+WorkspaceFactoryView.prototype.markShadowBlocks = function(blocks) {
+ for (var i = 0; i < blocks.length; i++) {
+ this.markShadowBlock(blocks[i]);
+ }
+};
+
+/**
+ * Visually marks a user-generated shadow block as a shadow block in the
+ * workspace without making the block an actual shadow block (allowing it
+ * to be moved and edited).
+ *
+ * @param {!Blockly.Block} block The block that should be marked as a shadow
+ * block (must be rendered).
+ */
+WorkspaceFactoryView.prototype.markShadowBlock = function(block) {
+ // Add Blockly CSS for user-generated shadow blocks.
+ Blockly.addClass_(block.svgGroup_, 'shadowBlock');
+ // If not a valid shadow block, add a warning message.
+ if (!block.getSurroundParent()) {
+ block.setWarningText('Shadow blocks must be nested inside' +
+ ' other blocks to be displayed.');
+ }
+
+ if (FactoryUtils.hasVariableField(block)) {
+ block.setWarningText('Cannot make variable blocks shadow blocks.');
+ }
+};
+
+/**
+ * Removes visual marking for a shadow block given a rendered block.
+ *
+ * @param {!Blockly.Block} block The block that should be unmarked as a shadow
+ * block (must be rendered).
+ */
+WorkspaceFactoryView.prototype.unmarkShadowBlock = function(block) {
+ // Remove Blockly CSS for user-generated shadow blocks.
+ if (Blockly.hasClass_(block.svgGroup_, 'shadowBlock')) {
+ Blockly.removeClass_(block.svgGroup_, 'shadowBlock');
+ }
+};
+
+/**
+ * Sets the tabs for modes according to which mode the user is currenly
+ * editing in.
+ *
+ * @param {!string} mode The mode being switched to
+ * (WorkspaceFactoryController.MODE_TOOLBOX or WorkspaceFactoryController.MODE_PRELOAD).
+ */
+WorkspaceFactoryView.prototype.setModeSelection = function(mode) {
+ document.getElementById('tab_preload').className = mode ==
+ WorkspaceFactoryController.MODE_PRELOAD ? 'tabon' : 'taboff';
+ document.getElementById('preload_div').style.display = mode ==
+ WorkspaceFactoryController.MODE_PRELOAD ? 'block' : 'none';
+ document.getElementById('tab_toolbox').className = mode ==
+ WorkspaceFactoryController.MODE_TOOLBOX ? 'tabon' : 'taboff';
+ document.getElementById('toolbox_div').style.display = mode ==
+ WorkspaceFactoryController.MODE_TOOLBOX ? 'block' : 'none';
+};
+
+/**
+ * Updates the help text above the workspace depending on the selected mode.
+ *
+ * @param {!string} mode The selected mode (WorkspaceFactoryController.MODE_TOOLBOX or
+ * WorkspaceFactoryController.MODE_PRELOAD).
+ */
+WorkspaceFactoryView.prototype.updateHelpText = function(mode) {
+ if (mode == WorkspaceFactoryController.MODE_TOOLBOX) {
+ var helpText = 'Drag blocks into the workspace to configure the toolbox '
+ + 'in your custom workspace.';
+ } else {
+ var helpText = 'Drag blocks into the workspace to pre-load them in your '
+ + 'custom workspace.'
+ }
+ document.getElementById('editHelpText').textContent = helpText;
+};
+
+/**
+ * Sets the basic options that are not dependent on if there are categories
+ * or a single flyout of blocks. Updates checkboxes and text fields.
+ */
+WorkspaceFactoryView.prototype.setBaseOptions = function() {
+ // Set basic options.
+ document.getElementById('option_css_checkbox').checked = true;
+ document.getElementById('option_infiniteBlocks_checkbox').checked = true;
+ document.getElementById('option_maxBlocks_number').value = 100;
+ document.getElementById('option_media_text').value =
+ 'https://blockly-demo.appspot.com/static/media/';
+ document.getElementById('option_readOnly_checkbox').checked = false;
+ document.getElementById('option_rtl_checkbox').checked = false;
+ document.getElementById('option_sounds_checkbox').checked = true;
+
+ // Uncheck grid and zoom options and hide suboptions.
+ document.getElementById('option_grid_checkbox').checked = false;
+ document.getElementById('grid_options').style.display = 'none';
+ document.getElementById('option_zoom_checkbox').checked = false;
+ document.getElementById('zoom_options').style.display = 'none';
+
+ // Set grid options.
+ document.getElementById('gridOption_spacing_number').value = 0;
+ document.getElementById('gridOption_length_number').value = 1;
+ document.getElementById('gridOption_colour_text').value = '#888';
+ document.getElementById('gridOption_snap_checkbox').checked = false;
+
+ // Set zoom options.
+ document.getElementById('zoomOption_controls_checkbox').checked = true;
+ document.getElementById('zoomOption_wheel_checkbox').checked = true;
+ document.getElementById('zoomOption_startScale_number').value = 1.0;
+ document.getElementById('zoomOption_maxScale_number').value = 3;
+ document.getElementById('zoomOption_minScale_number').value = 0.3;
+ document.getElementById('zoomOption_scaleSpeed_number').value = 1.2;
+};
+
+/**
+ * Updates category specific options depending on if there are categories
+ * currently present. Updates checkboxes and text fields in the view.
+ *
+ * @param {boolean} hasCategories True if categories are present, false if all
+ * blocks are displayed in a single flyout.
+ */
+WorkspaceFactoryView.prototype.setCategoryOptions = function(hasCategories) {
+ document.getElementById('option_collapse_checkbox').checked = hasCategories;
+ document.getElementById('option_comments_checkbox').checked = hasCategories;
+ document.getElementById('option_disable_checkbox').checked = hasCategories;
+ document.getElementById('option_scrollbars_checkbox').checked = hasCategories;
+ document.getElementById('option_trashcan_checkbox').checked = hasCategories;
+}
diff --git a/blockly/demos/code/code.js b/blockly/demos/code/code.js
new file mode 100644
index 0000000..65a2621
--- /dev/null
+++ b/blockly/demos/code/code.js
@@ -0,0 +1,532 @@
+/**
+ * Blockly Demos: Code
+ *
+ * Copyright 2012 Google Inc.
+ * https://developers.google.com/blockly/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @fileoverview JavaScript for Blockly's Code demo.
+ * @author fraser@google.com (Neil Fraser)
+ */
+'use strict';
+
+/**
+ * Create a namespace for the application.
+ */
+var Code = {};
+
+/**
+ * Lookup for names of supported languages. Keys should be in ISO 639 format.
+ */
+Code.LANGUAGE_NAME = {
+ 'ar': 'العربية',
+ 'be-tarask': 'Taraškievica',
+ 'br': 'Brezhoneg',
+ 'ca': 'Català',
+ 'cs': 'Česky',
+ 'da': 'Dansk',
+ 'de': 'Deutsch',
+ 'el': 'Ελληνικά',
+ 'en': 'English',
+ 'es': 'Español',
+ 'et': 'Eesti',
+ 'fa': 'فارسی',
+ 'fr': 'Français',
+ 'he': 'עברית',
+ 'hrx': 'Hunsrik',
+ 'hu': 'Magyar',
+ 'ia': 'Interlingua',
+ 'is': 'Íslenska',
+ 'it': 'Italiano',
+ 'ja': '日本語',
+ 'ko': '한국어',
+ 'mk': 'Македонски',
+ 'ms': 'Bahasa Melayu',
+ 'nb': 'Norsk Bokmål',
+ 'nl': 'Nederlands, Vlaams',
+ 'oc': 'Lenga d\'òc',
+ 'pl': 'Polski',
+ 'pms': 'Piemontèis',
+ 'pt-br': 'Português Brasileiro',
+ 'ro': 'Română',
+ 'ru': 'Русский',
+ 'sc': 'Sardu',
+ 'sk': 'Slovenčina',
+ 'sr': 'Српски',
+ 'sv': 'Svenska',
+ 'ta': 'தமிழ்',
+ 'th': 'ภาษาไทย',
+ 'tlh': 'tlhIngan Hol',
+ 'tr': 'Türkçe',
+ 'uk': 'Українська',
+ 'vi': 'Tiếng Việt',
+ 'zh-hans': '简体中文',
+ 'zh-hant': '正體中文'
+};
+
+/**
+ * List of RTL languages.
+ */
+Code.LANGUAGE_RTL = ['ar', 'fa', 'he', 'lki'];
+
+/**
+ * Blockly's main workspace.
+ * @type {Blockly.WorkspaceSvg}
+ */
+Code.workspace = null;
+
+/**
+ * Extracts a parameter from the URL.
+ * If the parameter is absent default_value is returned.
+ * @param {string} name The name of the parameter.
+ * @param {string} defaultValue Value to return if paramater not found.
+ * @return {string} The parameter value or the default value if not found.
+ */
+Code.getStringParamFromUrl = function(name, defaultValue) {
+ var val = location.search.match(new RegExp('[?&]' + name + '=([^&]+)'));
+ return val ? decodeURIComponent(val[1].replace(/\+/g, '%20')) : defaultValue;
+};
+
+/**
+ * Get the language of this user from the URL.
+ * @return {string} User's language.
+ */
+Code.getLang = function() {
+ var lang = Code.getStringParamFromUrl('lang', '');
+ if (Code.LANGUAGE_NAME[lang] === undefined) {
+ // Default to English.
+ lang = 'en';
+ }
+ return lang;
+};
+
+/**
+ * Is the current language (Code.LANG) an RTL language?
+ * @return {boolean} True if RTL, false if LTR.
+ */
+Code.isRtl = function() {
+ return Code.LANGUAGE_RTL.indexOf(Code.LANG) != -1;
+};
+
+/**
+ * Load blocks saved on App Engine Storage or in session/local storage.
+ * @param {string} defaultXml Text representation of default blocks.
+ */
+Code.loadBlocks = function(defaultXml) {
+ try {
+ var loadOnce = window.sessionStorage.loadOnceBlocks;
+ } catch(e) {
+ // Firefox sometimes throws a SecurityError when accessing sessionStorage.
+ // Restarting Firefox fixes this, so it looks like a bug.
+ var loadOnce = null;
+ }
+ if ('BlocklyStorage' in window && window.location.hash.length > 1) {
+ // An href with #key trigers an AJAX call to retrieve saved blocks.
+ BlocklyStorage.retrieveXml(window.location.hash.substring(1));
+ } else if (loadOnce) {
+ // Language switching stores the blocks during the reload.
+ delete window.sessionStorage.loadOnceBlocks;
+ var xml = Blockly.Xml.textToDom(loadOnce);
+ Blockly.Xml.domToWorkspace(xml, Code.workspace);
+ } else if (defaultXml) {
+ // Load the editor with default starting blocks.
+ var xml = Blockly.Xml.textToDom(defaultXml);
+ Blockly.Xml.domToWorkspace(xml, Code.workspace);
+ } else if ('BlocklyStorage' in window) {
+ // Restore saved blocks in a separate thread so that subsequent
+ // initialization is not affected from a failed load.
+ window.setTimeout(BlocklyStorage.restoreBlocks, 0);
+ }
+};
+
+/**
+ * Save the blocks and reload with a different language.
+ */
+Code.changeLanguage = function() {
+ // Store the blocks for the duration of the reload.
+ // This should be skipped for the index page, which has no blocks and does
+ // not load Blockly.
+ // MSIE 11 does not support sessionStorage on file:// URLs.
+ if (typeof Blockly != 'undefined' && window.sessionStorage) {
+ var xml = Blockly.Xml.workspaceToDom(Code.workspace);
+ var text = Blockly.Xml.domToText(xml);
+ window.sessionStorage.loadOnceBlocks = text;
+ }
+
+ var languageMenu = document.getElementById('languageMenu');
+ var newLang = encodeURIComponent(
+ languageMenu.options[languageMenu.selectedIndex].value);
+ var search = window.location.search;
+ if (search.length <= 1) {
+ search = '?lang=' + newLang;
+ } else if (search.match(/[?&]lang=[^&]*/)) {
+ search = search.replace(/([?&]lang=)[^&]*/, '$1' + newLang);
+ } else {
+ search = search.replace(/\?/, '?lang=' + newLang + '&');
+ }
+
+ window.location = window.location.protocol + '//' +
+ window.location.host + window.location.pathname + search;
+};
+
+/**
+ * Bind a function to a button's click event.
+ * On touch enabled browsers, ontouchend is treated as equivalent to onclick.
+ * @param {!Element|string} el Button element or ID thereof.
+ * @param {!Function} func Event handler to bind.
+ */
+Code.bindClick = function(el, func) {
+ if (typeof el == 'string') {
+ el = document.getElementById(el);
+ }
+ el.addEventListener('click', func, true);
+ el.addEventListener('touchend', func, true);
+};
+
+/**
+ * Load the Prettify CSS and JavaScript.
+ */
+Code.importPrettify = function() {
+ //<link rel="stylesheet" href="../prettify.css">
+ //<script src="../prettify.js"></script>
+ var link = document.createElement('link');
+ link.setAttribute('rel', 'stylesheet');
+ link.setAttribute('href', '../prettify.css');
+ document.head.appendChild(link);
+ var script = document.createElement('script');
+ script.setAttribute('src', '../prettify.js');
+ document.head.appendChild(script);
+};
+
+/**
+ * Compute the absolute coordinates and dimensions of an HTML element.
+ * @param {!Element} element Element to match.
+ * @return {!Object} Contains height, width, x, and y properties.
+ * @private
+ */
+Code.getBBox_ = function(element) {
+ var height = element.offsetHeight;
+ var width = element.offsetWidth;
+ var x = 0;
+ var y = 0;
+ do {
+ x += element.offsetLeft;
+ y += element.offsetTop;
+ element = element.offsetParent;
+ } while (element);
+ return {
+ height: height,
+ width: width,
+ x: x,
+ y: y
+ };
+};
+
+/**
+ * User's language (e.g. "en").
+ * @type {string}
+ */
+Code.LANG = Code.getLang();
+
+/**
+ * List of tab names.
+ * @private
+ */
+Code.TABS_ = ['blocks', 'javascript', 'php', 'python', 'dart', 'lua', 'xml'];
+
+Code.selected = 'blocks';
+
+/**
+ * Switch the visible pane when a tab is clicked.
+ * @param {string} clickedName Name of tab clicked.
+ */
+Code.tabClick = function(clickedName) {
+ // If the XML tab was open, save and render the content.
+ if (document.getElementById('tab_xml').className == 'tabon') {
+ var xmlTextarea = document.getElementById('content_xml');
+ var xmlText = xmlTextarea.value;
+ var xmlDom = null;
+ try {
+ xmlDom = Blockly.Xml.textToDom(xmlText);
+ } catch (e) {
+ var q =
+ window.confirm(MSG['badXml'].replace('%1', e));
+ if (!q) {
+ // Leave the user on the XML tab.
+ return;
+ }
+ }
+ if (xmlDom) {
+ Code.workspace.clear();
+ Blockly.Xml.domToWorkspace(xmlDom, Code.workspace);
+ }
+ }
+
+ if (document.getElementById('tab_blocks').className == 'tabon') {
+ Code.workspace.setVisible(false);
+ }
+ // Deselect all tabs and hide all panes.
+ for (var i = 0; i < Code.TABS_.length; i++) {
+ var name = Code.TABS_[i];
+ document.getElementById('tab_' + name).className = 'taboff';
+ document.getElementById('content_' + name).style.visibility = 'hidden';
+ }
+
+ // Select the active tab.
+ Code.selected = clickedName;
+ document.getElementById('tab_' + clickedName).className = 'tabon';
+ // Show the selected pane.
+ document.getElementById('content_' + clickedName).style.visibility =
+ 'visible';
+ Code.renderContent();
+ if (clickedName == 'blocks') {
+ Code.workspace.setVisible(true);
+ }
+ Blockly.svgResize(Code.workspace);
+};
+
+/**
+ * Populate the currently selected pane with content generated from the blocks.
+ */
+Code.renderContent = function() {
+ var content = document.getElementById('content_' + Code.selected);
+ // Initialize the pane.
+ if (content.id == 'content_xml') {
+ var xmlTextarea = document.getElementById('content_xml');
+ var xmlDom = Blockly.Xml.workspaceToDom(Code.workspace);
+ var xmlText = Blockly.Xml.domToPrettyText(xmlDom);
+ xmlTextarea.value = xmlText;
+ xmlTextarea.focus();
+ } else if (content.id == 'content_javascript') {
+ var code = Blockly.JavaScript.workspaceToCode(Code.workspace);
+ content.textContent = code;
+ if (typeof prettyPrintOne == 'function') {
+ code = content.innerHTML;
+ code = prettyPrintOne(code, 'js');
+ content.innerHTML = code;
+ }
+ } else if (content.id == 'content_python') {
+ code = Blockly.Python.workspaceToCode(Code.workspace);
+ content.textContent = code;
+ if (typeof prettyPrintOne == 'function') {
+ code = content.innerHTML;
+ code = prettyPrintOne(code, 'py');
+ content.innerHTML = code;
+ }
+ } else if (content.id == 'content_php') {
+ code = Blockly.PHP.workspaceToCode(Code.workspace);
+ content.textContent = code;
+ if (typeof prettyPrintOne == 'function') {
+ code = content.innerHTML;
+ code = prettyPrintOne(code, 'php');
+ content.innerHTML = code;
+ }
+ } else if (content.id == 'content_dart') {
+ code = Blockly.Dart.workspaceToCode(Code.workspace);
+ content.textContent = code;
+ if (typeof prettyPrintOne == 'function') {
+ code = content.innerHTML;
+ code = prettyPrintOne(code, 'dart');
+ content.innerHTML = code;
+ }
+ } else if (content.id == 'content_lua') {
+ code = Blockly.Lua.workspaceToCode(Code.workspace);
+ content.textContent = code;
+ if (typeof prettyPrintOne == 'function') {
+ code = content.innerHTML;
+ code = prettyPrintOne(code, 'lua');
+ content.innerHTML = code;
+ }
+ }
+};
+
+/**
+ * Initialize Blockly. Called on page load.
+ */
+Code.init = function() {
+ Code.initLanguage();
+
+ var rtl = Code.isRtl();
+ var container = document.getElementById('content_area');
+ var onresize = function(e) {
+ var bBox = Code.getBBox_(container);
+ for (var i = 0; i < Code.TABS_.length; i++) {
+ var el = document.getElementById('content_' + Code.TABS_[i]);
+ el.style.top = bBox.y + 'px';
+ el.style.left = bBox.x + 'px';
+ // Height and width need to be set, read back, then set again to
+ // compensate for scrollbars.
+ el.style.height = bBox.height + 'px';
+ el.style.height = (2 * bBox.height - el.offsetHeight) + 'px';
+ el.style.width = bBox.width + 'px';
+ el.style.width = (2 * bBox.width - el.offsetWidth) + 'px';
+ }
+ // Make the 'Blocks' tab line up with the toolbox.
+ if (Code.workspace && Code.workspace.toolbox_.width) {
+ document.getElementById('tab_blocks').style.minWidth =
+ (Code.workspace.toolbox_.width - 38) + 'px';
+ // Account for the 19 pixel margin and on each side.
+ }
+ };
+ window.addEventListener('resize', onresize, false);
+
+ // Interpolate translated messages into toolbox.
+ var toolboxText = document.getElementById('toolbox').outerHTML;
+ toolboxText = toolboxText.replace(/{(\w+)}/g,
+ function(m, p1) {return MSG[p1]});
+ var toolboxXml = Blockly.Xml.textToDom(toolboxText);
+
+ Code.workspace = Blockly.inject('content_blocks',
+ {grid:
+ {spacing: 25,
+ length: 3,
+ colour: '#ccc',
+ snap: true},
+ media: '../../media/',
+ rtl: rtl,
+ toolbox: toolboxXml,
+ zoom:
+ {controls: true,
+ wheel: true}
+ });
+
+ // Add to reserved word list: Local variables in execution environment (runJS)
+ // and the infinite loop detection function.
+ Blockly.JavaScript.addReservedWords('code,timeouts,checkTimeout');
+
+ Code.loadBlocks('');
+
+ if ('BlocklyStorage' in window) {
+ // Hook a save function onto unload.
+ BlocklyStorage.backupOnUnload(Code.workspace);
+ }
+
+ Code.tabClick(Code.selected);
+
+ Code.bindClick('trashButton',
+ function() {Code.discard(); Code.renderContent();});
+ Code.bindClick('runButton', Code.runJS);
+ // Disable the link button if page isn't backed by App Engine storage.
+ var linkButton = document.getElementById('linkButton');
+ if ('BlocklyStorage' in window) {
+ BlocklyStorage['HTTPREQUEST_ERROR'] = MSG['httpRequestError'];
+ BlocklyStorage['LINK_ALERT'] = MSG['linkAlert'];
+ BlocklyStorage['HASH_ERROR'] = MSG['hashError'];
+ BlocklyStorage['XML_ERROR'] = MSG['xmlError'];
+ Code.bindClick(linkButton,
+ function() {BlocklyStorage.link(Code.workspace);});
+ } else if (linkButton) {
+ linkButton.className = 'disabled';
+ }
+
+ for (var i = 0; i < Code.TABS_.length; i++) {
+ var name = Code.TABS_[i];
+ Code.bindClick('tab_' + name,
+ function(name_) {return function() {Code.tabClick(name_);};}(name));
+ }
+ onresize();
+ Blockly.svgResize(Code.workspace);
+
+ // Lazy-load the syntax-highlighting.
+ window.setTimeout(Code.importPrettify, 1);
+};
+
+/**
+ * Initialize the page language.
+ */
+Code.initLanguage = function() {
+ // Set the HTML's language and direction.
+ var rtl = Code.isRtl();
+ document.dir = rtl ? 'rtl' : 'ltr';
+ document.head.parentElement.setAttribute('lang', Code.LANG);
+
+ // Sort languages alphabetically.
+ var languages = [];
+ for (var lang in Code.LANGUAGE_NAME) {
+ languages.push([Code.LANGUAGE_NAME[lang], lang]);
+ }
+ var comp = function(a, b) {
+ // Sort based on first argument ('English', 'Русский', '简体字', etc).
+ if (a[0] > b[0]) return 1;
+ if (a[0] < b[0]) return -1;
+ return 0;
+ };
+ languages.sort(comp);
+ // Populate the language selection menu.
+ var languageMenu = document.getElementById('languageMenu');
+ languageMenu.options.length = 0;
+ for (var i = 0; i < languages.length; i++) {
+ var tuple = languages[i];
+ var lang = tuple[tuple.length - 1];
+ var option = new Option(tuple[0], lang);
+ if (lang == Code.LANG) {
+ option.selected = true;
+ }
+ languageMenu.options.add(option);
+ }
+ languageMenu.addEventListener('change', Code.changeLanguage, true);
+
+ // Inject language strings.
+ document.title += ' ' + MSG['title'];
+ document.getElementById('title').textContent = MSG['title'];
+ document.getElementById('tab_blocks').textContent = MSG['blocks'];
+
+ document.getElementById('linkButton').title = MSG['linkTooltip'];
+ document.getElementById('runButton').title = MSG['runTooltip'];
+ document.getElementById('trashButton').title = MSG['trashTooltip'];
+};
+
+/**
+ * Execute the user's code.
+ * Just a quick and dirty eval. Catch infinite loops.
+ */
+Code.runJS = function() {
+ Blockly.JavaScript.INFINITE_LOOP_TRAP = ' checkTimeout();\n';
+ var timeouts = 0;
+ var checkTimeout = function() {
+ if (timeouts++ > 1000000) {
+ throw MSG['timeout'];
+ }
+ };
+ var code = Blockly.JavaScript.workspaceToCode(Code.workspace);
+ Blockly.JavaScript.INFINITE_LOOP_TRAP = null;
+ try {
+ eval(code);
+ } catch (e) {
+ alert(MSG['badCode'].replace('%1', e));
+ }
+};
+
+/**
+ * Discard all blocks from the workspace.
+ */
+Code.discard = function() {
+ var count = Code.workspace.getAllBlocks().length;
+ if (count < 2 ||
+ window.confirm(Blockly.Msg.DELETE_ALL_BLOCKS.replace('%1', count))) {
+ Code.workspace.clear();
+ if (window.location.hash) {
+ window.location.hash = '';
+ }
+ }
+};
+
+// Load the Code demo's language strings.
+document.write('<script src="msg/' + Code.LANG + '.js"></script>\n');
+// Load Blockly's language strings.
+document.write('<script src="../../msg/js/' + Code.LANG + '.js"></script>\n');
+
+window.addEventListener('load', Code.init);
diff --git a/blockly/demos/code/icon.png b/blockly/demos/code/icon.png
new file mode 100644
index 0000000..e2f23bd
--- /dev/null
+++ b/blockly/demos/code/icon.png
Binary files differ
diff --git a/blockly/demos/code/icons.png b/blockly/demos/code/icons.png
new file mode 100644
index 0000000..7cced7a
--- /dev/null
+++ b/blockly/demos/code/icons.png
Binary files differ
diff --git a/blockly/demos/code/index.html b/blockly/demos/code/index.html
new file mode 100644
index 0000000..3878ec0
--- /dev/null
+++ b/blockly/demos/code/index.html
@@ -0,0 +1,374 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="google" value="notranslate">
+ <title>Blockly Demo:</title>
+ <link rel="stylesheet" href="style.css">
+ <script src="/storage.js"></script>
+ <script src="../../blockly_compressed.js"></script>
+ <script src="../../blocks_compressed.js"></script>
+ <script src="../../javascript_compressed.js"></script>
+ <script src="../../python_compressed.js"></script>
+ <script src="../../php_compressed.js"></script>
+ <script src="../../lua_compressed.js"></script>
+ <script src="../../dart_compressed.js"></script>
+ <script src="code.js"></script>
+</head>
+<body>
+ <table width="100%" height="100%">
+ <tr>
+ <td>
+ <h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt;
+ <a href="../index.html">Demos</a>&rlm; &gt;
+ <span id="title">...</span>
+ </h1>
+ </td>
+ <td class="farSide">
+ <select id="languageMenu"></select>
+ </td>
+ </tr>
+ <tr>
+ <td colspan=2>
+ <table width="100%">
+ <tr id="tabRow" height="1em">
+ <td id="tab_blocks" class="tabon">...</td>
+ <td class="tabmin">&nbsp;</td>
+ <td id="tab_javascript" class="taboff">JavaScript</td>
+ <td class="tabmin">&nbsp;</td>
+ <td id="tab_python" class="taboff">Python</td>
+ <td class="tabmin">&nbsp;</td>
+ <td id="tab_php" class="taboff">PHP</td>
+ <td class="tabmin">&nbsp;</td>
+ <td id="tab_lua" class="taboff">Lua</td>
+ <td class="tabmin">&nbsp;</td>
+ <td id="tab_dart" class="taboff">Dart</td>
+ <td class="tabmin">&nbsp;</td>
+ <td id="tab_xml" class="taboff">XML</td>
+ <td class="tabmax">
+ <button id="trashButton" class="notext" title="...">
+ <img src='../../media/1x1.gif' class="trash icon21">
+ </button>
+ <button id="linkButton" class="notext" title="...">
+ <img src='../../media/1x1.gif' class="link icon21">
+ </button>
+ <button id="runButton" class="notext primary" title="...">
+ <img src='../../media/1x1.gif' class="run icon21">
+ </button>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td height="99%" colspan=2 id="content_area">
+ </td>
+ </tr>
+ </table>
+ <div id="content_blocks" class="content"></div>
+ <pre id="content_javascript" class="content"></pre>
+ <pre id="content_python" class="content"></pre>
+ <pre id="content_php" class="content"></pre>
+ <pre id="content_lua" class="content"></pre>
+ <pre id="content_dart" class="content"></pre>
+ <textarea id="content_xml" class="content" wrap="off"></textarea>
+
+ <xml id="toolbox" style="display: none">
+ <category name="{catLogic}" colour="210">
+ <block type="controls_if"></block>
+ <block type="logic_compare"></block>
+ <block type="logic_operation"></block>
+ <block type="logic_negate"></block>
+ <block type="logic_boolean"></block>
+ <block type="logic_null"></block>
+ <block type="logic_ternary"></block>
+ </category>
+ <category name="{catLoops}" colour="120">
+ <block type="controls_repeat_ext">
+ <value name="TIMES">
+ <shadow type="math_number">
+ <field name="NUM">10</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="controls_whileUntil"></block>
+ <block type="controls_for">
+ <value name="FROM">
+ <shadow type="math_number">
+ <field name="NUM">1</field>
+ </shadow>
+ </value>
+ <value name="TO">
+ <shadow type="math_number">
+ <field name="NUM">10</field>
+ </shadow>
+ </value>
+ <value name="BY">
+ <shadow type="math_number">
+ <field name="NUM">1</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="controls_forEach"></block>
+ <block type="controls_flow_statements"></block>
+ </category>
+ <category name="{catMath}" colour="230">
+ <block type="math_number"></block>
+ <block type="math_arithmetic">
+ <value name="A">
+ <shadow type="math_number">
+ <field name="NUM">1</field>
+ </shadow>
+ </value>
+ <value name="B">
+ <shadow type="math_number">
+ <field name="NUM">1</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_single">
+ <value name="NUM">
+ <shadow type="math_number">
+ <field name="NUM">9</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_trig">
+ <value name="NUM">
+ <shadow type="math_number">
+ <field name="NUM">45</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_constant"></block>
+ <block type="math_number_property">
+ <value name="NUMBER_TO_CHECK">
+ <shadow type="math_number">
+ <field name="NUM">0</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_round">
+ <value name="NUM">
+ <shadow type="math_number">
+ <field name="NUM">3.1</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_on_list"></block>
+ <block type="math_modulo">
+ <value name="DIVIDEND">
+ <shadow type="math_number">
+ <field name="NUM">64</field>
+ </shadow>
+ </value>
+ <value name="DIVISOR">
+ <shadow type="math_number">
+ <field name="NUM">10</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_constrain">
+ <value name="VALUE">
+ <shadow type="math_number">
+ <field name="NUM">50</field>
+ </shadow>
+ </value>
+ <value name="LOW">
+ <shadow type="math_number">
+ <field name="NUM">1</field>
+ </shadow>
+ </value>
+ <value name="HIGH">
+ <shadow type="math_number">
+ <field name="NUM">100</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_random_int">
+ <value name="FROM">
+ <shadow type="math_number">
+ <field name="NUM">1</field>
+ </shadow>
+ </value>
+ <value name="TO">
+ <shadow type="math_number">
+ <field name="NUM">100</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_random_float"></block>
+ </category>
+ <category name="{catText}" colour="160">
+ <block type="text"></block>
+ <block type="text_join"></block>
+ <block type="text_append">
+ <value name="TEXT">
+ <shadow type="text"></shadow>
+ </value>
+ </block>
+ <block type="text_length">
+ <value name="VALUE">
+ <shadow type="text">
+ <field name="TEXT">abc</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="text_isEmpty">
+ <value name="VALUE">
+ <shadow type="text">
+ <field name="TEXT"></field>
+ </shadow>
+ </value>
+ </block>
+ <block type="text_indexOf">
+ <value name="VALUE">
+ <block type="variables_get">
+ <field name="VAR">{textVariable}</field>
+ </block>
+ </value>
+ <value name="FIND">
+ <shadow type="text">
+ <field name="TEXT">abc</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="text_charAt">
+ <value name="VALUE">
+ <block type="variables_get">
+ <field name="VAR">{textVariable}</field>
+ </block>
+ </value>
+ </block>
+ <block type="text_getSubstring">
+ <value name="STRING">
+ <block type="variables_get">
+ <field name="VAR">{textVariable}</field>
+ </block>
+ </value>
+ </block>
+ <block type="text_changeCase">
+ <value name="TEXT">
+ <shadow type="text">
+ <field name="TEXT">abc</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="text_trim">
+ <value name="TEXT">
+ <shadow type="text">
+ <field name="TEXT">abc</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="text_print">
+ <value name="TEXT">
+ <shadow type="text">
+ <field name="TEXT">abc</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="text_prompt_ext">
+ <value name="TEXT">
+ <shadow type="text">
+ <field name="TEXT">abc</field>
+ </shadow>
+ </value>
+ </block>
+ </category>
+ <category name="{catLists}" colour="260">
+ <block type="lists_create_with">
+ <mutation items="0"></mutation>
+ </block>
+ <block type="lists_create_with"></block>
+ <block type="lists_repeat">
+ <value name="NUM">
+ <shadow type="math_number">
+ <field name="NUM">5</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="lists_length"></block>
+ <block type="lists_isEmpty"></block>
+ <block type="lists_indexOf">
+ <value name="VALUE">
+ <block type="variables_get">
+ <field name="VAR">{listVariable}</field>
+ </block>
+ </value>
+ </block>
+ <block type="lists_getIndex">
+ <value name="VALUE">
+ <block type="variables_get">
+ <field name="VAR">{listVariable}</field>
+ </block>
+ </value>
+ </block>
+ <block type="lists_setIndex">
+ <value name="LIST">
+ <block type="variables_get">
+ <field name="VAR">{listVariable}</field>
+ </block>
+ </value>
+ </block>
+ <block type="lists_getSublist">
+ <value name="LIST">
+ <block type="variables_get">
+ <field name="VAR">{listVariable}</field>
+ </block>
+ </value>
+ </block>
+ <block type="lists_split">
+ <value name="DELIM">
+ <shadow type="text">
+ <field name="TEXT">,</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="lists_sort"></block>
+ </category>
+ <category name="{catColour}" colour="20">
+ <block type="colour_picker"></block>
+ <block type="colour_random"></block>
+ <block type="colour_rgb">
+ <value name="RED">
+ <shadow type="math_number">
+ <field name="NUM">100</field>
+ </shadow>
+ </value>
+ <value name="GREEN">
+ <shadow type="math_number">
+ <field name="NUM">50</field>
+ </shadow>
+ </value>
+ <value name="BLUE">
+ <shadow type="math_number">
+ <field name="NUM">0</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="colour_blend">
+ <value name="COLOUR1">
+ <shadow type="colour_picker">
+ <field name="COLOUR">#ff0000</field>
+ </shadow>
+ </value>
+ <value name="COLOUR2">
+ <shadow type="colour_picker">
+ <field name="COLOUR">#3333ff</field>
+ </shadow>
+ </value>
+ <value name="RATIO">
+ <shadow type="math_number">
+ <field name="NUM">0.5</field>
+ </shadow>
+ </value>
+ </block>
+ </category>
+ <sep></sep>
+ <category name="{catVariables}" colour="330" custom="VARIABLE"></category>
+ <category name="{catFunctions}" colour="290" custom="PROCEDURE"></category>
+ </xml>
+
+</body>
+</html>
diff --git a/blockly/demos/code/msg/ar.js b/blockly/demos/code/msg/ar.js
new file mode 100644
index 0000000..952198b
--- /dev/null
+++ b/blockly/demos/code/msg/ar.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "كود",
+ blocks: "البلوكات",
+ linkTooltip: "احفظ ووصلة إلى البلوكات.",
+ runTooltip: "شغل البرنامج المعرف بواسطة البلوكات في مساحة العمل.",
+ badCode: "خطأ في البرنامج:\n %1",
+ timeout: "تم تجاوز الحد الأقصى لتكرارات التنفيذ .",
+ trashTooltip: "تجاهل كل البلوكات.",
+ catLogic: "منطق",
+ catLoops: "الحلقات",
+ catMath: "رياضيات",
+ catText: "نص",
+ catLists: "قوائم",
+ catColour: "لون",
+ catVariables: "متغيرات",
+ catFunctions: "إجراءات",
+ listVariable: "قائمة",
+ textVariable: "نص",
+ httpRequestError: "كانت هناك مشكلة مع هذا الطلب.",
+ linkAlert: "مشاركة كود بلوكلي الخاص بك مع هذا الرابط:\n %1",
+ hashError: "عذراً،ال '%1' لا تتوافق مع أي برنامج تم حفظه.",
+ xmlError: "تعذر تحميل الملف المحفوظة الخاصة بك. ربما تم إنشاؤه باستخدام إصدار مختلف من بلوكلي؟",
+ badXml: "خطأ في توزيع ال \"XML\":\n %1\n\nحدد 'موافق' للتخلي عن التغييرات أو 'إلغاء الأمر' لمواصلة تحرير ال\"XML\"."
+};
diff --git a/blockly/demos/code/msg/be-tarask.js b/blockly/demos/code/msg/be-tarask.js
new file mode 100644
index 0000000..5c8d722
--- /dev/null
+++ b/blockly/demos/code/msg/be-tarask.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Код",
+ blocks: "Блёкі",
+ linkTooltip: "Захаваць і зьвязаць з блёкамі.",
+ runTooltip: "Запусьціце праграму, вызначаную блёкамі ў працоўнай вобласьці.",
+ badCode: "Памылка праграмы:\n%1",
+ timeout: "Перавышана максымальная колькасьць ітэрацыяў.",
+ trashTooltip: "Выдаліць усе блёкі.",
+ catLogic: "Лёгіка",
+ catLoops: "Петлі",
+ catMath: "Матэматычныя формулы",
+ catText: "Тэкст",
+ catLists: "Сьпісы",
+ catColour: "Колер",
+ catVariables: "Зьменныя",
+ catFunctions: "Функцыі",
+ listVariable: "сьпіс",
+ textVariable: "тэкст",
+ httpRequestError: "Узьнікла праблема з запытам.",
+ linkAlert: "Падзяліцца Вашым блёкам праз гэтую спасылку:\n\n%1",
+ hashError: "Прабачце, '%1' не адпавядае ніводнай захаванай праграме.",
+ xmlError: "Не атрымалася загрузіць захаваны файл. Магчыма, ён быў створаны з іншай вэрсіяй Блёклі?",
+ badXml: "Памылка сынтаксічнага аналізу XML:\n%1\n\nАбярыце \"ОК\", каб адмовіцца ад зьменаў ці \"Скасаваць\" для далейшага рэдагаваньня XML."
+};
diff --git a/blockly/demos/code/msg/br.js b/blockly/demos/code/msg/br.js
new file mode 100644
index 0000000..321e28e
--- /dev/null
+++ b/blockly/demos/code/msg/br.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Kod",
+ blocks: "Bloc'hoù",
+ linkTooltip: "Enrollañ ha liammañ d'ar bloc'hadoù.",
+ runTooltip: "Lañsañ ar programm termenet gant ar bloc'hadoù en takad labour.",
+ badCode: "Fazi programm :\n%1",
+ timeout: "Tizhet eo bet an niver brasañ a iteradurioù seveniñ aotreet.",
+ trashTooltip: "Disteurel an holl vloc'hoù.",
+ catLogic: "Poell",
+ catLoops: "Boukloù",
+ catMath: "Matematik",
+ catText: "Testenn",
+ catLists: "Rolloù",
+ catColour: "Liv",
+ catVariables: "Argemmennoù",
+ catFunctions: "Arc'hwelioù",
+ listVariable: "roll",
+ textVariable: "testenn",
+ httpRequestError: "Ur gudenn zo gant ar reked.",
+ linkAlert: "Rannañ ho ploc'hoù gant al liamm-mañ :\n\n%1",
+ hashError: "Digarezit. \"%1\" ne glot gant programm enrollet ebet.",
+ xmlError: "Ne c'haller ket kargañ ho restr enrollet. Marteze e oa bet krouet gant ur stumm disheñvel eus Blockly ?",
+ badXml: "Fazi dielfennañ XML :\n%1\n\nDibabit \"Mat eo\" evit dilezel ar c'hemmoù-se pe \"Nullañ\" evit kemmañ an XML c'hoazh."
+};
diff --git a/blockly/demos/code/msg/ca.js b/blockly/demos/code/msg/ca.js
new file mode 100644
index 0000000..2b6d973
--- /dev/null
+++ b/blockly/demos/code/msg/ca.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Codi",
+ blocks: "Blocs",
+ linkTooltip: "Desa i enllaça als blocs.",
+ runTooltip: "Executa el programa definit pels blocs de l'àrea de treball.",
+ badCode: "Error de programa:\n %1",
+ timeout: "S'ha superat el nombre màxim d'iteracions d'execució.",
+ trashTooltip: "Descarta tots els blocs.",
+ catLogic: "Lògica",
+ catLoops: "Bucles",
+ catMath: "Matemàtiques",
+ catText: "Text",
+ catLists: "Llistes",
+ catColour: "Color",
+ catVariables: "Variables",
+ catFunctions: "Procediments",
+ listVariable: "llista",
+ textVariable: "text",
+ httpRequestError: "Hi ha hagut un problema amb la sol·licitud.",
+ linkAlert: "Comparteix els teus blocs amb aquest enllaç: %1",
+ hashError: "Ho sentim, '%1' no es correspon amb cap fitxer desat de Blockly.",
+ xmlError: "No s'ha pogut carregar el teu fitxer desat. Potser va ser creat amb una versió diferent de Blockly?",
+ badXml: "Error d'anàlisi XML:\n%1\n\nSeleccioneu 'Acceptar' per abandonar els vostres canvis, o 'Cancel·lar' per continuar editant l'XML."
+};
diff --git a/blockly/demos/code/msg/cs.js b/blockly/demos/code/msg/cs.js
new file mode 100644
index 0000000..1026511
--- /dev/null
+++ b/blockly/demos/code/msg/cs.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Kód",
+ blocks: "Bloky",
+ linkTooltip: "Ulož a spoj bloky..",
+ runTooltip: "",
+ badCode: "Chyba programu:\n%1",
+ timeout: "Maximum execution iterations exceeded.",
+ trashTooltip: "Zahodit všechny bloky.",
+ catLogic: "Logika",
+ catLoops: "Smyčky",
+ catMath: "Matematika",
+ catText: "Text",
+ catLists: "Seznamy",
+ catColour: "Barva",
+ catVariables: "Proměnné",
+ catFunctions: "Procedury",
+ listVariable: "seznam",
+ textVariable: "text",
+ httpRequestError: "Došlo k potížím s požadavkem.",
+ linkAlert: "Sdílej bloky tímto odkazem: \n\n%1",
+ hashError: "Omlouváme se, '%1' nesouhlasí s žádným z uložených souborů.",
+ xmlError: "Nepodařilo se uložit vás soubor. Pravděpodobně byl vytvořen jinou verzí Blockly?",
+ badXml: "Chyba parsování XML:\n%1\n\nVybrat \"OK\" pro zahození vašich změn nebo 'Cancel' k dalšímu upravování XML."
+};
diff --git a/blockly/demos/code/msg/da.js b/blockly/demos/code/msg/da.js
new file mode 100644
index 0000000..089450b
--- /dev/null
+++ b/blockly/demos/code/msg/da.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Kode",
+ blocks: "Blokke",
+ linkTooltip: "Gem og link til blokke.",
+ runTooltip: "Kør programmet, der er defineret af blokkene i arbejdsområdet.",
+ badCode: "Programfejl:\n%1",
+ timeout: "Maksimale antal udførelsesgentagelser overskredet.",
+ trashTooltip: "Kassér alle blokke.",
+ catLogic: "Logik",
+ catLoops: "Løkker",
+ catMath: "Matematik",
+ catText: "Tekst",
+ catLists: "Lister",
+ catColour: "Farve",
+ catVariables: "Variabler",
+ catFunctions: "Funktioner",
+ listVariable: "liste",
+ textVariable: "tekst",
+ httpRequestError: "Der var et problem med forespørgslen.",
+ linkAlert: "Del dine blokke med dette link:\n\n%1",
+ hashError: "Beklager, '%1' passer ikke med nogen gemt Blockly fil.",
+ xmlError: "Kunne ikke hente din gemte fil. Måske er den lavet med en anden udgave af Blockly?",
+ badXml: "Fejl under fortolkningen af XML:\n%1\n\nVælg 'OK' for at opgive dine ændringer eller 'Afbryd' for at redigere XML-filen yderligere."
+};
diff --git a/blockly/demos/code/msg/de.js b/blockly/demos/code/msg/de.js
new file mode 100644
index 0000000..422f918
--- /dev/null
+++ b/blockly/demos/code/msg/de.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Code",
+ blocks: "Bausteine",
+ linkTooltip: "Speichern und auf Bausteine verlinken.",
+ runTooltip: "Das Programm ausführen, das von den Bausteinen im Arbeitsbereich definiert ist.",
+ badCode: "Programmfehler:\n%1",
+ timeout: "Die maximalen Ausführungswiederholungen wurden überschritten.",
+ trashTooltip: "Alle Bausteine verwerfen.",
+ catLogic: "Logik",
+ catLoops: "Schleifen",
+ catMath: "Mathematik",
+ catText: "Text",
+ catLists: "Listen",
+ catColour: "Farbe",
+ catVariables: "Variablen",
+ catFunctions: "Funktionen",
+ listVariable: "Liste",
+ textVariable: "Text",
+ httpRequestError: "Mit der Anfrage gab es ein Problem.",
+ linkAlert: "Teile deine Bausteine mit diesem Link:\n\n%1",
+ hashError: "„%1“ stimmt leider mit keinem gespeicherten Programm überein.",
+ xmlError: "Deine gespeicherte Datei konnte nicht geladen werden. Vielleicht wurde sie mit einer anderen Version von Blockly erstellt.",
+ badXml: "Fehler beim Parsen von XML:\n%1\n\nWähle 'OK' zum Verwerfen deiner Änderungen oder 'Abbrechen' zum weiteren Bearbeiten des XML."
+};
diff --git a/blockly/demos/code/msg/el.js b/blockly/demos/code/msg/el.js
new file mode 100644
index 0000000..c63b7a6
--- /dev/null
+++ b/blockly/demos/code/msg/el.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Κώδικας",
+ blocks: "Μπλοκ",
+ linkTooltip: "Αποθηκεύει και συνδέει σε μπλοκ.",
+ runTooltip: "Εκτελεί το πρόγραμμα που ορίζεται από τα μπλοκ στον χώρο εργασίας.",
+ badCode: "Σφάλμα προγράμματος:\n%1",
+ timeout: "Υπέρβαση μέγιστου αριθμού επαναλήψεων.",
+ trashTooltip: "Απόρριψη όλων των μπλοκ.",
+ catLogic: "Λογική",
+ catLoops: "Επαναλήψεις",
+ catMath: "Μαθηματικά",
+ catText: "Κείμενο",
+ catLists: "Λίστες",
+ catColour: "Χρώμα",
+ catVariables: "Μεταβλητές",
+ catFunctions: "Συναρτήσεις",
+ listVariable: "λίστα",
+ textVariable: "κείμενο",
+ httpRequestError: "Υπήρξε πρόβλημα με το αίτημα.",
+ linkAlert: "Κοινοποίησε τα μπλοκ σου με αυτόν τον σύνδεσμο:\n\n%1",
+ hashError: "Λυπάμαι, το «%1» δεν αντιστοιχεί σε κανένα αποθηκευμένο πρόγραμμα.",
+ xmlError: "Δεν μπορώ να φορτώσω το αποθηκευμένο αρχείο σου. Μήπως δημιουργήθηκε από μία παλιότερη έκδοση του Blockly;",
+ badXml: "Σφάλμα ανάλυσης XML:\n%1\n\nΕπίλεξε «Εντάξει» για να εγκαταλείψεις τις αλλαγές σου ή «Ακύρωση» για να επεξεργαστείς το XML κι άλλο."
+};
diff --git a/blockly/demos/code/msg/en.js b/blockly/demos/code/msg/en.js
new file mode 100644
index 0000000..8d52cf3
--- /dev/null
+++ b/blockly/demos/code/msg/en.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Code",
+ blocks: "Blocks",
+ linkTooltip: "Save and link to blocks.",
+ runTooltip: "Run the program defined by the blocks in the workspace.",
+ badCode: "Program error:\n%1",
+ timeout: "Maximum execution iterations exceeded.",
+ trashTooltip: "Discard all blocks.",
+ catLogic: "Logic",
+ catLoops: "Loops",
+ catMath: "Math",
+ catText: "Text",
+ catLists: "Lists",
+ catColour: "Colour",
+ catVariables: "Variables",
+ catFunctions: "Functions",
+ listVariable: "list",
+ textVariable: "text",
+ httpRequestError: "There was a problem with the request.",
+ linkAlert: "Share your blocks with this link:\n\n%1",
+ hashError: "Sorry, '%1' doesn't correspond with any saved program.",
+ xmlError: "Could not load your saved file. Perhaps it was created with a different version of Blockly?",
+ badXml: "Error parsing XML:\n%1\n\nSelect 'OK' to abandon your changes or 'Cancel' to further edit the XML."
+};
diff --git a/blockly/demos/code/msg/es.js b/blockly/demos/code/msg/es.js
new file mode 100644
index 0000000..24358e3
--- /dev/null
+++ b/blockly/demos/code/msg/es.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Código",
+ blocks: "Bloques",
+ linkTooltip: "Guarda conexión a los bloques.",
+ runTooltip: "Ejecute el programa definido por los bloques en el área de trabajo.",
+ badCode: "Error del programa:\n%1",
+ timeout: "Se excedio el máximo de iteraciones ejecutadas permitidas.",
+ trashTooltip: "Descartar todos los bloques.",
+ catLogic: "Lógica",
+ catLoops: "Secuencias",
+ catMath: "Matemáticas",
+ catText: "Texto",
+ catLists: "Listas",
+ catColour: "Color",
+ catVariables: "Variables",
+ catFunctions: "Funciones",
+ listVariable: "lista",
+ textVariable: "texto",
+ httpRequestError: "Hubo un problema con la petición.",
+ linkAlert: "Comparte tus bloques con este enlace:\n\n%1",
+ hashError: "«%1» no corresponde con ningún programa guardado.",
+ xmlError: "No se pudo cargar el archivo guardado. ¿Quizá fue creado con otra versión de Blockly?",
+ badXml: "Error de análisis XML:\n%1\n\nSelecciona OK para abandonar tus cambios o Cancelar para seguir editando el XML."
+};
diff --git a/blockly/demos/code/msg/et.js b/blockly/demos/code/msg/et.js
new file mode 100644
index 0000000..320c391
--- /dev/null
+++ b/blockly/demos/code/msg/et.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Kood",
+ blocks: "Plokid",
+ linkTooltip: "Salvesta ja tekita link plokkidele.",
+ runTooltip: "Käivita töölaual olevate plokkidega defineeritud programm.",
+ badCode: "Viga programmis:\n%1",
+ timeout: "Käivitatavate iteratsioonide maksimaalne arv on ületatud.",
+ trashTooltip: "Eemalda kõik plokid.",
+ catLogic: "Loogika",
+ catLoops: "Kordus",
+ catMath: "Matemaatika",
+ catText: "Tekst",
+ catLists: "Loendid",
+ catColour: "Värv",
+ catVariables: "Muutujad",
+ catFunctions: "Funktsioonid",
+ listVariable: "loend",
+ textVariable: "tekst",
+ httpRequestError: "Probleem päringuga.",
+ linkAlert: "Oma plokke saad jagada selle lingiga:\n\n%1",
+ hashError: "Vabandust, kuid '%1' ei vasta ühelegi salvestatud programmile.",
+ xmlError: "Su salvestatud faili ei õnnestunud laadida. Võibolla on see loodud mõne teise Blockly versiooniga?",
+ badXml: "Viga XML-i parsimisel:\n%1\n\nTehtud muudatustest loobumiseks vajuta 'OK', XML-i muudatuste tegemise jätkamiseks 'Katkesta'."
+};
diff --git a/blockly/demos/code/msg/fa.js b/blockly/demos/code/msg/fa.js
new file mode 100644
index 0000000..96dd966
--- /dev/null
+++ b/blockly/demos/code/msg/fa.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "کد",
+ blocks: "بلوک‌ها",
+ linkTooltip: "ذخیره و پیوند به بلوک‌ها.",
+ runTooltip: "اجرای برنامهٔ تعریف‌شده توسط بلوک‌ها در فضای کار.",
+ badCode: "خطای برنامه:\n%1",
+ timeout: "حداکثر تکرارهای اجرا رد شده‌است.",
+ trashTooltip: "دورریختن همهٔ بلوک‌ها.",
+ catLogic: "منطق",
+ catLoops: "حلقه‌ها",
+ catMath: "ریاضی",
+ catText: "متن",
+ catLists: "فهرست‌ها",
+ catColour: "رنگ",
+ catVariables: "متغییرها",
+ catFunctions: "توابع",
+ listVariable: "فهرست",
+ textVariable: "متن",
+ httpRequestError: "مشکلی با درخواست وجود داشت.",
+ linkAlert: "اشتراک‌گذاری بلاک‌هایتان با این پیوند:\n\n%1",
+ hashError: "شرمنده، «%1» با هیچ برنامهٔ ذخیره‌شده‌ای تطبیق پیدا نکرد.",
+ xmlError: "نتوانست پروندهٔ ذخیرهٔ شما بارگیری شود. احتمالاً با نسخهٔ متفاوتی از بلوکی درست شده‌است؟",
+ badXml: "خطای تجزیهٔ اکس‌ام‌ال:\n%1\n\n«باشد» را برای ذخیره و «فسخ» را برای ویرایش بیشتر اکس‌ام‌ال انتخاب کنید."
+};
diff --git a/blockly/demos/code/msg/fr.js b/blockly/demos/code/msg/fr.js
new file mode 100644
index 0000000..6018113
--- /dev/null
+++ b/blockly/demos/code/msg/fr.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Code",
+ blocks: "Blocs",
+ linkTooltip: "Sauvegarder et lier aux blocs.",
+ runTooltip: "Lancer le programme défini par les blocs dans l’espace de travail.",
+ badCode: "Erreur du programme :\n%1",
+ timeout: "Nombre maximum d’itérations d’exécution dépassé.",
+ trashTooltip: "Jeter tous les blocs.",
+ catLogic: "Logique",
+ catLoops: "Boucles",
+ catMath: "Math",
+ catText: "Texte",
+ catLists: "Listes",
+ catColour: "Couleur",
+ catVariables: "Variables",
+ catFunctions: "Fonctions",
+ listVariable: "liste",
+ textVariable: "texte",
+ httpRequestError: "Il y a eu un problème avec la demande.",
+ linkAlert: "Partagez vos blocs grâce à ce lien:\n\n%1",
+ hashError: "Désolé, '%1' ne correspond à aucun programme sauvegardé.",
+ xmlError: "Impossible de charger le fichier de sauvegarde. Peut être a t-il été créé avec une autre version de Blockly?",
+ badXml: "Erreur d’analyse du XML :\n%1\n\nSélectionner 'OK' pour abandonner vos modifications ou 'Annuler' pour continuer à modifier le XML."
+};
diff --git a/blockly/demos/code/msg/he.js b/blockly/demos/code/msg/he.js
new file mode 100644
index 0000000..dc28266
--- /dev/null
+++ b/blockly/demos/code/msg/he.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "קוד",
+ blocks: "קטעי קוד",
+ linkTooltip: "שמירה וקישור לקטעי קוד.",
+ runTooltip: "הרצת התכנית שהוגדרה על ידי קטעי הקוד שבמרחב העבודה.",
+ badCode: "שגיאה בתכנית: %1",
+ timeout: "חריגה ממספר פעולות חוזרות אפשריות.",
+ trashTooltip: "השלך את כל קטעי הקוד.",
+ catLogic: "לוגיקה",
+ catLoops: "לולאות",
+ catMath: "מתמטיקה",
+ catText: "טקסט",
+ catLists: "רשימות",
+ catColour: "צבע",
+ catVariables: "משתנים",
+ catFunctions: "פונקציות",
+ listVariable: "רשימה",
+ textVariable: "טקסט",
+ httpRequestError: "הבקשה נכשלה.",
+ linkAlert: "ניתן לשתף את קטעי הקוד שלך באמצעות קישור זה:\n\n%1",
+ hashError: "לצערנו, '%1' איננו מתאים לאף אחת מהתוכניות השמורות",
+ xmlError: "נסיון הטעינה של הקובץ השמור שלך נכשל. האם ייתכן שהוא נוצר בגרסא שונה של בלוקלי?",
+ badXml: "תקלה בפענוח XML:\n\n%1\n\nנא לבחור 'אישור' כדי לנטוש את השינויים שלך או 'ביטול' כדי להמשיך ולערוך את ה־XML."
+};
diff --git a/blockly/demos/code/msg/hrx.js b/blockly/demos/code/msg/hrx.js
new file mode 100644
index 0000000..ca0dea3
--- /dev/null
+++ b/blockly/demos/code/msg/hrx.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Code",
+ blocks: "Bausten",
+ linkTooltip: "Speichre und auf Bausten verlinke.",
+ runTooltip: "Das Programm ausfüahre, das von den Bausten im Oorweitsbereich definiert ist.",
+ badCode: "Programmfehler:\n%1",
+ timeout: "Die maximale Ausführungswiederholunge woore üwerschritt.",
+ trashTooltip: "All Bausten verwerfe.",
+ catLogic: "Logik",
+ catLoops: "Schleife",
+ catMath: "Mathematik",
+ catText: "Text",
+ catLists: "Liste",
+ catColour: "Farreb",
+ catVariables: "Variable",
+ catFunctions: "Funktione",
+ listVariable: "List",
+ textVariable: "Text",
+ httpRequestError: "Mit der Oonfroch hots en Problem geb.",
+ linkAlert: "Tel von dein Bausten mit dem Link:\n\n%1",
+ hashError: "„%1“ stimmt leider mit kenem üweren gespeicherte Programm.",
+ xmlError: "Dein gespeicherte Datei könnt net gelood sin. Vielleicht woard se mit ener annre Version von Blockly erstellt.",
+ badXml: "Fehler beim Parse von XML:\n%1\n\nWähle 'OK' zum Verwerfe von deiner Ändrunge orrer 'Abbreche' zum XML weiter beoorbeite."
+};
diff --git a/blockly/demos/code/msg/hu.js b/blockly/demos/code/msg/hu.js
new file mode 100644
index 0000000..eee1868
--- /dev/null
+++ b/blockly/demos/code/msg/hu.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Kódszerkesztő",
+ blocks: "Blokkok",
+ linkTooltip: "Hivatkozás létrehozása",
+ runTooltip: "Program futtatása.",
+ badCode: "Program hiba:\n%1",
+ timeout: "A program elérte a maximális végrehajtási időt.",
+ trashTooltip: "Összes blokk törlése.",
+ catLogic: "Logikai műveletek",
+ catLoops: "Ciklusok",
+ catMath: "Matematikai műveletek",
+ catText: "Sztring műveletek",
+ catLists: "Listakezelés",
+ catColour: "Színek",
+ catVariables: "Változók",
+ catFunctions: "Eljárások",
+ listVariable: "lista",
+ textVariable: "szöveg",
+ httpRequestError: "A kéréssel kapcsolatban probléma merült fel.",
+ linkAlert: "Ezzel a hivatkozással tudod megosztani a programodat:\n\n%1",
+ hashError: "Sajnos a '%1' hivatkozás nem tartozik egyetlen programhoz sem.",
+ xmlError: "A programodat nem lehet betölteni. Elképzelhető, hogy a Blockly egy másik verziójában készült?",
+ badXml: "Hiba az XML feldolgozásakor:\n%1\n\nVáltozások elvetése?"
+};
diff --git a/blockly/demos/code/msg/ia.js b/blockly/demos/code/msg/ia.js
new file mode 100644
index 0000000..5938458
--- /dev/null
+++ b/blockly/demos/code/msg/ia.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Codice",
+ blocks: "Blocos",
+ linkTooltip: "Salveguardar e ligar a blocos.",
+ runTooltip: "Executar le programma definite per le blocos in le spatio de travalio.",
+ badCode: "Error del programma:\n%1",
+ timeout: "Le numero de iterationes executate ha excedite le maximo.",
+ trashTooltip: "Abandonar tote le blocos.",
+ catLogic: "Logica",
+ catLoops: "Buclas",
+ catMath: "Mathematica",
+ catText: "Texto",
+ catLists: "Listas",
+ catColour: "Color",
+ catVariables: "Variabiles",
+ catFunctions: "Functiones",
+ listVariable: "lista",
+ textVariable: "texto",
+ httpRequestError: "Il habeva un problema con le requesta.",
+ linkAlert: "Divide tu blocos con iste ligamine:\n\n%1",
+ hashError: "Infelicemente, '%1' non corresponde a alcun programma salveguardate.",
+ xmlError: "Impossibile cargar le file salveguardate. Pote esser que illo ha essite create con un altere version de Blockly?",
+ badXml: "Error de analyse del XML:\n%1\n\nSelige 'OK' pro abandonar le modificationes o 'Cancellar' pro continuar a modificar le codice XML."
+};
diff --git a/blockly/demos/code/msg/is.js b/blockly/demos/code/msg/is.js
new file mode 100644
index 0000000..fa5c40d
--- /dev/null
+++ b/blockly/demos/code/msg/is.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Kóði",
+ blocks: "Kubbar",
+ linkTooltip: "Vista og tengja við kubba.",
+ runTooltip: "Keyra forritið sem kubbarnir á vinnusvæðinu mynda.",
+ badCode: "Villa í forriti:\n%1",
+ timeout: "Forritið hefur endurtekið sig of oft.",
+ trashTooltip: "Fleygja öllum kubbum.",
+ catLogic: "Rökvísi",
+ catLoops: "Lykkjur",
+ catMath: "Reikningur",
+ catText: "Texti",
+ catLists: "Listar",
+ catColour: "Litir",
+ catVariables: "Breytur",
+ catFunctions: "Stefjur",
+ listVariable: "listi",
+ textVariable: "texti",
+ httpRequestError: "Það kom upp vandamál með beiðnina.",
+ linkAlert: "Deildu kubbunum þínum með þessari krækju:",
+ hashError: "Því miður, '%1' passar ekki við neitt vistað forrit.",
+ xmlError: "Gat ekki hlaðið vistuðu skrána þína. Var hún kannske búin til í annarri útgáfu af Blockly?",
+ badXml: "Villa við úrvinnslu XML:\n%1\n\nVeldu 'Í lagi' til að sleppa breytingum eða 'Hætta við' til að halda áfram með XML."
+};
diff --git a/blockly/demos/code/msg/it.js b/blockly/demos/code/msg/it.js
new file mode 100644
index 0000000..cd69b66
--- /dev/null
+++ b/blockly/demos/code/msg/it.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Codice",
+ blocks: "Blocchi",
+ linkTooltip: "Salva e collega ai blocchi.",
+ runTooltip: "Esegui il programma definito dai blocchi nell'area di lavoro.",
+ badCode: "Errore programma:\n%1",
+ timeout: "È stato superato il numero massimo consentito di interazioni eseguite.",
+ trashTooltip: "Elimina tutti i blocchi.",
+ catLogic: "Logica",
+ catLoops: "Cicli",
+ catMath: "Matematica",
+ catText: "Testo",
+ catLists: "Elenchi",
+ catColour: "Colore",
+ catVariables: "Variabili",
+ catFunctions: "Funzioni",
+ listVariable: "elenco",
+ textVariable: "testo",
+ httpRequestError: "La richiesta non è stata soddisfatta.",
+ linkAlert: "Condividi i tuoi blocchi con questo collegamento:\n\n%1",
+ hashError: "Mi spiace, '%1' non corrisponde ad alcun programma salvato.",
+ xmlError: "Non è stato possibile caricare il documento. Forse è stato creato con una versione diversa di Blockly?",
+ badXml: "Errore durante l'analisi XML:\n%1\n\nSeleziona 'OK' per abbandonare le modifiche o 'Annulla' per continuare a modificare l'XML."
+};
diff --git a/blockly/demos/code/msg/ja.js b/blockly/demos/code/msg/ja.js
new file mode 100644
index 0000000..6d50419
--- /dev/null
+++ b/blockly/demos/code/msg/ja.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "コード",
+ blocks: "ブロック",
+ linkTooltip: "ブロックの状態を保存してリンクを取得します。",
+ runTooltip: "ブロックで作成したプログラムを実行します。",
+ badCode: "プログラムのエラー:\n%1",
+ timeout: "命令の実行回数が制限値を超えました。",
+ trashTooltip: "すべてのブロックを消します。",
+ catLogic: "論理",
+ catLoops: "繰り返し",
+ catMath: "数学",
+ catText: "テキスト",
+ catLists: "リスト",
+ catColour: "色",
+ catVariables: "変数",
+ catFunctions: "関数",
+ listVariable: "リスト",
+ textVariable: "テキスト",
+ httpRequestError: "ネットワーク接続のエラーです。",
+ linkAlert: "ブロックの状態をこのリンクで共有できます:\n\n%1",
+ hashError: "すみません。「%1」という名前のプログラムは保存されていません。",
+ xmlError: "保存されたファイルを読み込めませんでした。別のバージョンのブロックリーで作成された可能性があります。",
+ badXml: "XML のエラーです:\n%1\n\nXML の変更をやめるには「OK」、編集を続けるには「キャンセル」を選んでください。"
+};
diff --git a/blockly/demos/code/msg/ko.js b/blockly/demos/code/msg/ko.js
new file mode 100644
index 0000000..990cb6f
--- /dev/null
+++ b/blockly/demos/code/msg/ko.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "코드",
+ blocks: "블록",
+ linkTooltip: "블록을 저장하고 링크를 가져옵니다.",
+ runTooltip: "작업 공간에서 블록으로 정의된 프로그램을 실행합니다.",
+ badCode: "프로그램 오류:\n%1",
+ timeout: "최대 실행 반복을 초과했습니다.",
+ trashTooltip: "모든 블록을 버립니다.",
+ catLogic: "논리",
+ catLoops: "반복",
+ catMath: "수학",
+ catText: "텍스트",
+ catLists: "목록",
+ catColour: "색",
+ catVariables: "변수",
+ catFunctions: "기능",
+ listVariable: "목록",
+ textVariable: "텍스트",
+ httpRequestError: "요청에 문제가 있습니다.",
+ linkAlert: "다음 링크로 블록을 공유하세요:\n\n%1",
+ hashError: "죄송하지만 '%1'은 어떤 저장된 프로그램으로 일치하지 않습니다.",
+ xmlError: "저장된 파일을 불러올 수 없습니다. 혹시 블록리의 다른 버전으로 만들었습니까?",
+ badXml: "XML 구문 분석 오류:\n%1\n\n바뀜을 포기하려면 '확인'을 선택하고 XML을 더 편집하려면 '취소'를 선택하세요."
+};
diff --git a/blockly/demos/code/msg/mk.js b/blockly/demos/code/msg/mk.js
new file mode 100644
index 0000000..cc344a6
--- /dev/null
+++ b/blockly/demos/code/msg/mk.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Код",
+ blocks: "Блокчиња",
+ linkTooltip: "Зачувај и стави врска до блокчињата.",
+ runTooltip: "Пушти го програмот определен од блокчињата во работниот простор.",
+ badCode: "Грешка во програмот:\n%1",
+ timeout: "Го надминавте допуштениот број на повторувања во извршувањето.",
+ trashTooltip: "Отстрани ги сите блокчиња.",
+ catLogic: "Логика",
+ catLoops: "Јамки",
+ catMath: "Математика",
+ catText: "Текст",
+ catLists: "Списоци",
+ catColour: "Боја",
+ catVariables: "Променливи",
+ catFunctions: "Функции",
+ listVariable: "список",
+ textVariable: "текст",
+ httpRequestError: "Се појави проблем во барањето.",
+ linkAlert: "Споделете ги вашите блокчиња со оваа врска:\n\n%1",
+ hashError: "„%1“ не одговара на ниеден зачуван програм.",
+ xmlError: "Не можев да ја вчитам зачуваната податотека. Да не сте ја создале со друга верзија на Blockly?",
+ badXml: "Грешка при расчленувањето на XML:\n%1\n\nСтиснете на „ОК“ за да ги напуштите промените или на „Откажи“ ако сакате уште да ја уредувате XML-податотеката."
+};
diff --git a/blockly/demos/code/msg/ms.js b/blockly/demos/code/msg/ms.js
new file mode 100644
index 0000000..87ee8de
--- /dev/null
+++ b/blockly/demos/code/msg/ms.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Kod",
+ blocks: "Blok",
+ linkTooltip: "Simpan dan pautkan kepada blok.",
+ runTooltip: "Jalankan aturcara yang ditetapkan oleh blok-blok di dalam ruang kerja.",
+ badCode: "Ralat aturcara:\n%1",
+ timeout: "Takat maksimum lelaran pelaksanaan dicecah.",
+ trashTooltip: "Buang semua Blok.",
+ catLogic: "Logik",
+ catLoops: "Gelung",
+ catMath: "Matematik",
+ catText: "Teks",
+ catLists: "Senarai",
+ catColour: "Warna",
+ catVariables: "Pemboleh ubah",
+ catFunctions: "Fungsi",
+ listVariable: "senarai",
+ textVariable: "teks",
+ httpRequestError: "Permintaan itu terdapat masalah.",
+ linkAlert: "Kongsikan blok-blok anda dengan pautan ini:\n\n%1",
+ hashError: "Maaf, '%1' tidak berpadanan dengan sebarang aturcara yang disimpan.",
+ xmlError: "Fail simpanan anda tidak dapat dimuatkan. Jangan-jangan ia dicipta dengan versi Blockly yang berlainan?",
+ badXml: "Ralat ketika menghuraikan XML:\n%1\n\nPilih 'OK' untuk melucutkan suntingan anda atau 'Batal' untuk bersambung menyunting XML-nya."
+};
diff --git a/blockly/demos/code/msg/nb.js b/blockly/demos/code/msg/nb.js
new file mode 100644
index 0000000..60ac039
--- /dev/null
+++ b/blockly/demos/code/msg/nb.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Kode",
+ blocks: "Blokker",
+ linkTooltip: "Lagre og lenke til blokker.",
+ runTooltip: "Kjør programmet definert av blokken i arbeidsområdet.",
+ badCode: "Programfeil:\n%1",
+ timeout: "Det maksimale antallet utførte looper er oversteget.",
+ trashTooltip: "Fjern alle blokker",
+ catLogic: "Logikk",
+ catLoops: "Looper",
+ catMath: "Matte",
+ catText: "Tekst",
+ catLists: "Lister",
+ catColour: "Farge",
+ catVariables: "Variabler",
+ catFunctions: "Funksjoner",
+ listVariable: "Liste",
+ textVariable: "Tekst",
+ httpRequestError: "Det oppsto et problem med forespørselen din",
+ linkAlert: "Del dine blokker med denne lenken:\n\n%1",
+ hashError: "Beklager, '%1' samsvarer ikke med noe lagret program.",
+ xmlError: "Kunne ikke laste inn filen. Kanskje den ble laget med en annen versjon av Blockly?",
+ badXml: "Feil ved parsering av XML:\n%1\n\nVelg 'OK' for å avbryte endringene eller 'Cancel' for å fortsette å redigere XML-koden."
+};
diff --git a/blockly/demos/code/msg/nl.js b/blockly/demos/code/msg/nl.js
new file mode 100644
index 0000000..339a5e8
--- /dev/null
+++ b/blockly/demos/code/msg/nl.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Code",
+ blocks: "Blokken",
+ linkTooltip: "Opslaan en koppelen naar blokken.",
+ runTooltip: "Voer het programma uit dat met de blokken in de werkruimte is gemaakt.",
+ badCode: "Programmafout:\n%1",
+ timeout: "Het maximale aantal iteraties is overschreden.",
+ trashTooltip: "Alle blokken verwijderen",
+ catLogic: "Logica",
+ catLoops: "Lussen",
+ catMath: "Formules",
+ catText: "Tekst",
+ catLists: "Lijsten",
+ catColour: "Kleur",
+ catVariables: "Variabelen",
+ catFunctions: "Functies",
+ listVariable: "lijst",
+ textVariable: "tekst",
+ httpRequestError: "Er is een probleem opgetreden tijdens het verwerken van het verzoek.",
+ linkAlert: "Deel uw blokken via deze koppeling:\n\n%1",
+ hashError: "\"%1\" komt helaas niet overeen met een opgeslagen bestand.",
+ xmlError: "Uw opgeslagen bestand kan niet geladen worden. Is het misschien gemaakt met een andere versie van Blockly?",
+ badXml: "Fout tijdens het verwerken van de XML:\n%1\n\nSelecteer \"OK\" om uw wijzigingen te negeren of \"Annuleren\" om de XML verder te bewerken."
+};
diff --git a/blockly/demos/code/msg/oc.js b/blockly/demos/code/msg/oc.js
new file mode 100644
index 0000000..c184ac8
--- /dev/null
+++ b/blockly/demos/code/msg/oc.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Còde",
+ blocks: "Blòts",
+ linkTooltip: "Salva e liga als blòts.",
+ runTooltip: "Aviar lo programa definit pels blòts dins l’espaci de trabalh.",
+ badCode: "Error del programa :\n%1",
+ timeout: "Nombre maximum d’iteracions d’execucion depassat.",
+ trashTooltip: "Getar totes los blòts.",
+ catLogic: "Logic",
+ catLoops: "Boclas",
+ catMath: "Math",
+ catText: "Tèxte",
+ catLists: "Listas",
+ catColour: "Color",
+ catVariables: "Variablas",
+ catFunctions: "Foncions",
+ listVariable: "lista",
+ textVariable: "tèxte",
+ httpRequestError: "I a agut un problèma amb la demanda.",
+ linkAlert: "Partejatz vòstres blòts gràcia a aqueste ligam :\n\n%1",
+ hashError: "O planhèm, '%1' correspond pas a un fichièr Blockly salvament.",
+ xmlError: "Impossible de cargar lo fichièr de salvament. Benlèu qu'es estat creat amb una autra version de Blockly ?",
+ badXml: "Error d’analisi del XML :\n%1\n\nSeleccionar 'D'acòrdi' per abandonar vòstras modificacions o 'Anullar' per modificar encara lo XML."
+};
diff --git a/blockly/demos/code/msg/pl.js b/blockly/demos/code/msg/pl.js
new file mode 100644
index 0000000..83bb05d
--- /dev/null
+++ b/blockly/demos/code/msg/pl.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Kod",
+ blocks: "Bloki",
+ linkTooltip: "Zapisz i podlinkuj do bloków",
+ runTooltip: "Uruchom program zdefinowany przez bloki w obszarze roboczym",
+ badCode: "Błąd programu:\n%1",
+ timeout: "Maksymalna liczba iteracji wykonywań przekroczona",
+ trashTooltip: "Odrzuć wszystkie bloki.",
+ catLogic: "Logika",
+ catLoops: "Pętle",
+ catMath: "Matematyka",
+ catText: "Tekst",
+ catLists: "Listy",
+ catColour: "Kolor",
+ catVariables: "Zmienne",
+ catFunctions: "Funkcje",
+ listVariable: "lista",
+ textVariable: "tekst",
+ httpRequestError: "Wystąpił problem z żądaniem.",
+ linkAlert: "Udpostępnij swoje bloki korzystając z poniższego linku : \n\n\n%1",
+ hashError: "Przepraszamy, \"%1\" nie odpowiada żadnemu zapisanemu programowi.",
+ xmlError: "Nie można załadować zapisanego pliku. Być może został utworzony za pomocą innej wersji Blockly?",
+ badXml: "Błąd parsowania XML : \n%1\n\nZaznacz 'OK' aby odrzucić twoje zmiany lub 'Cancel', żeby w przyszłości edytować XML."
+};
diff --git a/blockly/demos/code/msg/pms.js b/blockly/demos/code/msg/pms.js
new file mode 100644
index 0000000..a7704f7
--- /dev/null
+++ b/blockly/demos/code/msg/pms.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Còdes",
+ blocks: "Blòch",
+ linkTooltip: "Argistré e lijé ai blòch.",
+ runTooltip: "Fé andé ël programa definì dai blòch ant lë spassi ëd travaj.",
+ badCode: "Eror dël programa:\n%1",
+ timeout: "Nùmer màssim d'arpetission d'esecussion sorpassà.",
+ trashTooltip: "Scarté tuti ij blòch.",
+ catLogic: "Lògica",
+ catLoops: "Liasse",
+ catMath: "Matemàtica",
+ catText: "Test",
+ catLists: "Liste",
+ catColour: "Color",
+ catVariables: "Variàbij",
+ catFunctions: "Fonsion",
+ listVariable: "lista",
+ textVariable: "test",
+ httpRequestError: "A-i é staje un problema con l'arcesta.",
+ linkAlert: "Ch'a partagia ij sò blòch grassie a sta liura: %1",
+ hashError: "An dëspias, '%1 a corëspond a gnun programa salvà.",
+ xmlError: "A l'é nen podusse carié so archivi salvà. Miraco a l'é stàit creà con na version diferenta ëd Blockly?",
+ badXml: "Eror d'anàlisi dl'XML:\n%1\n\nSelessioné 'Va bin' për lassé perde toe modìfiche o 'Anulé' për modifiché ancora l'XML."
+};
diff --git a/blockly/demos/code/msg/pt-br.js b/blockly/demos/code/msg/pt-br.js
new file mode 100644
index 0000000..9b18d63
--- /dev/null
+++ b/blockly/demos/code/msg/pt-br.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Código",
+ blocks: "Blocos",
+ linkTooltip: "Salvar e ligar aos blocos.",
+ runTooltip: "Execute o programa definido pelos blocos na área de trabalho.",
+ badCode: "Erro no programa:\n%1",
+ timeout: "Máximo de iterações de execução excedido.",
+ trashTooltip: "Descartar todos os blocos.",
+ catLogic: "Lógica",
+ catLoops: "Laços",
+ catMath: "Matemática",
+ catText: "Texto",
+ catLists: "Listas",
+ catColour: "Cor",
+ catVariables: "Variáveis",
+ catFunctions: "Funções",
+ listVariable: "lista",
+ textVariable: "texto",
+ httpRequestError: "Houve um problema com a requisição.",
+ linkAlert: "Compartilhe seus blocos com este link:\n\n%1",
+ hashError: "Desculpe, '%1' não corresponde a um programa salvo.",
+ xmlError: "Não foi possível carregar seu arquivo salvo. Talvez ele tenha sido criado com uma versão diferente do Blockly?",
+ badXml: "Erro de análise XML:\n%1\n\nSelecione 'OK' para abandonar suas mudanças ou 'Cancelar' para editar o XML."
+};
diff --git a/blockly/demos/code/msg/ro.js b/blockly/demos/code/msg/ro.js
new file mode 100644
index 0000000..cd3de11
--- /dev/null
+++ b/blockly/demos/code/msg/ro.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Cod",
+ blocks: "Blocuri",
+ linkTooltip: "Salvează și adaugă la blocuri.",
+ runTooltip: "Execută programul definit de către blocuri în spațiul de lucru.",
+ badCode: "Eroare de program:\n%1",
+ timeout: "Numărul maxim de iterații a fost depășit.",
+ trashTooltip: "Șterge toate blocurile.",
+ catLogic: "Logic",
+ catLoops: "Bucle",
+ catMath: "Matematică",
+ catText: "Text",
+ catLists: "Liste",
+ catColour: "Culoare",
+ catVariables: "Variabile",
+ catFunctions: "Funcții",
+ listVariable: "listă",
+ textVariable: "text",
+ httpRequestError: "A apărut o problemă la solicitare.",
+ linkAlert: "Distribuie-ți blocurile folosind această legătură:\n\n%1",
+ hashError: "Scuze, „%1” nu corespunde nici unui program salvat.",
+ xmlError: "Sistemul nu a putut încărca fișierul salvat. Poate că a fost creat cu o altă versiune de Blockly?",
+ badXml: "Eroare de parsare XML:\n%1\n\nAlege „OK” pentru a renunța la modificările efectuate sau „Revocare” pentru a modifica în continuare fișierul XML."
+};
diff --git a/blockly/demos/code/msg/ru.js b/blockly/demos/code/msg/ru.js
new file mode 100644
index 0000000..389e905
--- /dev/null
+++ b/blockly/demos/code/msg/ru.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Код",
+ blocks: "Блоки",
+ linkTooltip: "Сохранить и показать ссылку на блоки.",
+ runTooltip: "Запустить программу, заданную блоками в рабочей области.",
+ badCode: "Ошибка программы:\n%1",
+ timeout: "Превышено максимальное количество итераций.",
+ trashTooltip: "Удалить все блоки.",
+ catLogic: "Логические",
+ catLoops: "Циклы",
+ catMath: "Математика",
+ catText: "Текст",
+ catLists: "Списки",
+ catColour: "Цвет",
+ catVariables: "Переменные",
+ catFunctions: "Функции",
+ listVariable: "список",
+ textVariable: "текст",
+ httpRequestError: "Произошла проблема при запросе.",
+ linkAlert: "Поделитесь своими блоками по этой ссылке:\n\n%1",
+ hashError: "К сожалению, «%1» не соответствует ни одному сохраненному файлу Блокли.",
+ xmlError: "Не удалось загрузить ваш сохраненный файл. Возможно, он был создан в другой версии Блокли?",
+ badXml: "Ошибка синтаксического анализа XML:\n%1\n\nВыберите 'ОК', чтобы отказаться от изменений или 'Cancel' для дальнейшего редактирования XML."
+};
diff --git a/blockly/demos/code/msg/sc.js b/blockly/demos/code/msg/sc.js
new file mode 100644
index 0000000..82f94d6
--- /dev/null
+++ b/blockly/demos/code/msg/sc.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Còdixi",
+ blocks: "Brocus",
+ linkTooltip: "Sarva e alliòngia a is brocus.",
+ runTooltip: "Arròllia su programa cumpostu de is brocus in s'àrea de traballu.",
+ badCode: "Errori in su Programa:\n%1",
+ timeout: "Giai lòmpius a su màssimu numeru de repicus.",
+ trashTooltip: "Boganci totu is brocus.",
+ catLogic: "Lògica",
+ catLoops: "Lòrigas",
+ catMath: "Matemàtica",
+ catText: "Testu",
+ catLists: "Lista",
+ catColour: "Colori",
+ catVariables: "Variabilis",
+ catFunctions: "Funtzionis",
+ listVariable: "lista",
+ textVariable: "testu",
+ httpRequestError: "Ddui fut unu problema cun sa pregunta",
+ linkAlert: "Poni is brocus tuus in custu acàpiu:\n\n%1",
+ hashError: "Mi dispraxit, '%1' non torrat a pari cun nimancu unu de is programas sarvaus.",
+ xmlError: "Non potzu carrigai su file sarvau. Fortzis est stètiu fatu cun d-una versioni diferenti de Blockly?",
+ badXml: "Errori in s'anàlisi XML:\n%1\n\nCraca 'OK' po perdi is mudàntzias 'Anudda' po sighì a scriri su XML."
+};
diff --git a/blockly/demos/code/msg/sk.js b/blockly/demos/code/msg/sk.js
new file mode 100644
index 0000000..3917df2
--- /dev/null
+++ b/blockly/demos/code/msg/sk.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Kód",
+ blocks: "Bloky",
+ linkTooltip: "Uložiť a zdieľať odkaz na tento program.",
+ runTooltip: "Spustiť program, zložený z dielcov na pracovnej ploche.",
+ badCode: "Chyba v programe:\n%1",
+ timeout: "Bol prekročený maximálny počet opakovaní.",
+ trashTooltip: "Zahodiť všetky dielce.",
+ catLogic: "Logika",
+ catLoops: "Cykly",
+ catMath: "Matematické",
+ catText: "Text",
+ catLists: "Zoznamy",
+ catColour: "Farby",
+ catVariables: "Premenné",
+ catFunctions: "Funkcie",
+ listVariable: "zoznam",
+ textVariable: "text",
+ httpRequestError: "Problém so spracovaním požiadavky.",
+ linkAlert: "Zdieľať tento program skopírovaním odkazu\n\n%1",
+ hashError: "Prepáč, '%1' nie je meno žiadnemu uloženému programu.",
+ xmlError: "Nebolo možné načítať uložený súbor. Možno bol vytvorený v inej verzii Blocky.",
+ badXml: "Chyba pri parsovaní XML:\n%1\n\nStlačte 'OK' ak chcete zrušiť zmeny alebo 'Zrušiť' pre pokračovanie v úpravách XML."
+};
diff --git a/blockly/demos/code/msg/sr.js b/blockly/demos/code/msg/sr.js
new file mode 100644
index 0000000..f9a026c
--- /dev/null
+++ b/blockly/demos/code/msg/sr.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Кôд",
+ blocks: "Блокови",
+ linkTooltip: "Сачувајте и повежите са блоковима.",
+ runTooltip: "Покрените програм заснован на блоковима у радном простору.",
+ badCode: "Грешка у програму:\n%1",
+ timeout: "Достигнут је максималан број понављања у извршавању.",
+ trashTooltip: "Одбаците све блокове.",
+ catLogic: "Логика",
+ catLoops: "Петље",
+ catMath: "Математика",
+ catText: "Текст",
+ catLists: "Спискови",
+ catColour: "Боја",
+ catVariables: "Променљиве",
+ catFunctions: "Процедуре",
+ listVariable: "списак",
+ textVariable: "текст",
+ httpRequestError: "Дошло је до проблема у захтеву.",
+ linkAlert: "Делите своје блокове овом везом:\n\n%1",
+ hashError: "„%1“ не одговара ниједном сачуваном програму.",
+ xmlError: "Не могу да учитам сачувану датотеку. Можда је направљена другом верзијом Blockly-ја.",
+ badXml: "Грешка при рашчлањивању XML-а:\n%1\n\nПритисните „У реду“ да напустите измене или „Откажи“ да наставите са уређивањем XML датотеке."
+};
diff --git a/blockly/demos/code/msg/sv.js b/blockly/demos/code/msg/sv.js
new file mode 100644
index 0000000..4134a4c
--- /dev/null
+++ b/blockly/demos/code/msg/sv.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Kod",
+ blocks: "Block",
+ linkTooltip: "Spara och länka till block.",
+ runTooltip: "Kör programmet som definierats av blocken i arbetsytan.",
+ badCode: "Programfel:\n%1",
+ timeout: "Det maximala antalet utförda loopar har överskridits.",
+ trashTooltip: "Släng alla block.",
+ catLogic: "Logik",
+ catLoops: "Loopar",
+ catMath: "Matematik",
+ catText: "Text",
+ catLists: "Listor",
+ catColour: "Färg",
+ catVariables: "Variabler",
+ catFunctions: "Funktioner",
+ listVariable: "lista",
+ textVariable: "text",
+ httpRequestError: "Det uppstod ett problem med begäran.",
+ linkAlert: "Dela dina block med denna länk: \n\n%1",
+ hashError: "Tyvärr, '%1' överensstämmer inte med något sparat program.",
+ xmlError: "Kunde inte läsa din sparade fil. Den skapades kanske med en annan version av Blockly?",
+ badXml: "Fel vid parsning av XML:\n%1\n\nKlicka på 'OK' för att strunta i dina ändringar eller 'Avbryt' för att fortsätta redigera XML-koden."
+};
diff --git a/blockly/demos/code/msg/ta.js b/blockly/demos/code/msg/ta.js
new file mode 100644
index 0000000..ff472e2
--- /dev/null
+++ b/blockly/demos/code/msg/ta.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "கணினி நிரல்", //Code
+ blocks: "நிரல் துண்டு", //block
+ linkTooltip: "சேமித்து நிரல் துண்டிற்கு இணைக்க", //save and link to block
+ runTooltip: "பணிமனை நினைவகத்தில் இயக்குக", //Run the program defined by the blocks in the workspace.
+ badCode: "கணினி நிரல் கோளாறு:\n%1",
+ timeout: "அதிகபட்ச அடுக்கின் அளவை மீரியது", //max iters reached/exceeded
+ trashTooltip: "நீக்கு",
+ catLogic: "தர்க வகை",
+ catLoops: "மடக்கு வாக்கியம்",
+ catMath: "கணிதம்",
+ catText: "உரை",
+ catLists: "பட்டியல்",
+ catColour: "வண்ணம்",
+ catVariables: "மாறிகள்",
+ catFunctions: "சார்புகள்",
+ listVariable: "பட்டியல் மாறி",
+ textVariable: "உரை சரம்",
+ httpRequestError: "இந்த செயலை இயக்குவதில் கோளாறு ஏற்பட்டது",
+ linkAlert: "இந்த சுட்டி வழியாக நிரல் துண்டுகளை பகிரவும்:\n\n%1",
+ hashError: "'%1' : இது சேமித்த நிரலாக தெரியவில்லை.",
+ xmlError: "உங்களது நிரலை காணவில்லை; வேறு Blockly அத்தியாயத்தில் சேமித்தீரா?",
+ badXml: "XML பகுப்பதில் கோளாறு:\n%1\n\nOK' கிளிக் செய்தால் மாற்றங்கள் இழப்பீர்கள்; பிழைகளுடன் தொடர 'Cancel' கிளிக் செய்யவும்."
+};
diff --git a/blockly/demos/code/msg/th.js b/blockly/demos/code/msg/th.js
new file mode 100644
index 0000000..1ac3624
--- /dev/null
+++ b/blockly/demos/code/msg/th.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "เขียนโปรแกรม",
+ blocks: "บล็อก",
+ linkTooltip: "บันทึกและสร้างลิงก์มายังบล็อกเหล่านี้",
+ runTooltip: "เรียกใช้โปรแกรมตามที่กำหนดไว้ด้วยบล็อกที่อยู่ในพื้นที่ทำงาน",
+ badCode: "โปรแกรมเกิดข้อผิดพลาด:\n%1",
+ timeout: "โปรแกรมทำงานซ้ำคำสั่งเดิมมากเกินไป",
+ trashTooltip: "ยกเลิกบล็อกทั้งหมด",
+ catLogic: "ตรรกะ",
+ catLoops: "การวนซ้ำ",
+ catMath: "คณิตศาสตร์",
+ catText: "ข้อความ",
+ catLists: "รายการ",
+ catColour: "สี",
+ catVariables: "ตัวแปร",
+ catFunctions: "ฟังก์ชัน",
+ listVariable: "รายการ",
+ textVariable: "ข้อความ",
+ httpRequestError: "มีปัญหาเกี่ยวกับการร้องขอ",
+ linkAlert: "แบ่งปันบล็อกของคุณด้วยลิงก์นี้:\n\n%1",
+ hashError: "เสียใจด้วย '%1' ไม่ตรงกับโปรแกรมใดๆ ที่เคยบันทึกเอาไว้เลย",
+ xmlError: "ไม่สามารถโหลดไฟล์ที่บันทึกไว้ของคุณได้ บางทีมันอาจจะถูกสร้างขึ้นด้วย Blockly รุ่นอื่นที่แตกต่างกัน?",
+ badXml: "เกิดข้อผิดพลาดในการแยกวิเคราะห์ XML:\n%1\n\nเลือก 'ตกลง' เพื่อละทิ้งการเปลี่ยนแปลงต่างๆ ที่ทำไว้ หรือเลือก 'ยกเลิก' เพื่อแก้ไข XML ต่อไป"
+};
diff --git a/blockly/demos/code/msg/tlh.js b/blockly/demos/code/msg/tlh.js
new file mode 100644
index 0000000..8d0c056
--- /dev/null
+++ b/blockly/demos/code/msg/tlh.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "ngoq",
+ blocks: "ngoghmey",
+ linkTooltip: "",
+ runTooltip: "",
+ badCode: "Qagh:\n%1",
+ timeout: "tlhoy nI'qu' poH.",
+ trashTooltip: "",
+ catLogic: "meq",
+ catLoops: "vIHtaHbogh ghomey",
+ catMath: "mI'QeD",
+ catText: "ghItlhHommey",
+ catLists: "tetlhmey",
+ catColour: "rItlh",
+ catVariables: "lIwmey",
+ catFunctions: "mIwmey",
+ listVariable: "tetlh",
+ textVariable: "ghItlhHom",
+ httpRequestError: "Qapbe' tlhobmeH QIn.",
+ linkAlert: "latlhvaD ngoghmeylIj DangeHmeH Quvvam yIlo':\n\n%1",
+ hashError: "Do'Ha', ngogh nab pollu'pu'bogh 'oHbe'law' \"%1\"'e'.",
+ xmlError: "ngogh nablIj pollu'pu'bogh chu'qa'laHbe' vay'. chaq pollu'pu'DI' ghunmeH ngogh pIm lo'lu'pu'.",
+ badXml: "XML yajchu'laHbe' vay':\n%1\n\nchoHmeylIj DalonmeH \"ruch\" yIwIv pagh XML DachoHqa'meH \"qIl\" yIwIv."
+};
diff --git a/blockly/demos/code/msg/tr.js b/blockly/demos/code/msg/tr.js
new file mode 100644
index 0000000..1448300
--- /dev/null
+++ b/blockly/demos/code/msg/tr.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Kod",
+ blocks: "Bloklar",
+ linkTooltip: "Blokları ve bağlantı adresini kaydet.",
+ runTooltip: "Çalışma alanında bloklar tarafından tanımlanan programını çalıştırın.",
+ badCode: "Program hatası:\n %1",
+ timeout: "Maksimum yürütme yinelemeleri aşıldı.",
+ trashTooltip: "Bütün blokları at.",
+ catLogic: "Mantık",
+ catLoops: "Döngüler",
+ catMath: "Matematik",
+ catText: "Metin",
+ catLists: "Listeler",
+ catColour: "Renk",
+ catVariables: "Değişkenler",
+ catFunctions: "İşlevler",
+ listVariable: "liste",
+ textVariable: "metin",
+ httpRequestError: "İstek ile ilgili bir problem var.",
+ linkAlert: "Bloklarını bu bağlantı ile paylaş:\n\n%1",
+ hashError: "Üzgünüz, '%1' hiç bir kaydedilmiş program ile uyuşmuyor.",
+ xmlError: "Kaydedilen dosyanız yüklenemiyor\nBlockly'nin önceki sürümü ile kaydedilmiş olabilir mi?",
+ badXml: "XML ayrıştırma hatası:\n%1\n\nDeğişikliklerden vazgeçmek için 'Tamam'ı, düzenlemeye devam etmek için 'İptal' seçeneğini seçiniz."
+};
diff --git a/blockly/demos/code/msg/uk.js b/blockly/demos/code/msg/uk.js
new file mode 100644
index 0000000..6b34627
--- /dev/null
+++ b/blockly/demos/code/msg/uk.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Код",
+ blocks: "Блоки",
+ linkTooltip: "Зберегти і пов'язати з блоками.",
+ runTooltip: "Запустіть програму, визначену блоками у робочій області.",
+ badCode: "Помилка програми:\n%1",
+ timeout: "Максимальне виконання ітерацій перевищено.",
+ trashTooltip: "Відкинути всі блоки.",
+ catLogic: "Логіка",
+ catLoops: "Петлі",
+ catMath: "Математика",
+ catText: "Текст",
+ catLists: "Списки",
+ catColour: "Колір",
+ catVariables: "Змінні",
+ catFunctions: "Функції",
+ listVariable: "список",
+ textVariable: "текст",
+ httpRequestError: "Виникла проблема із запитом.",
+ linkAlert: "Поділитися вашим блоками через посилання:\n\n%1",
+ hashError: "На жаль, \"%1\" не відповідає жодній збереженій програмі.",
+ xmlError: "Не вдалося завантажити ваш збережений файл. Можливо, він був створений з іншої версії Blockly?",
+ badXml: "Помилка синтаксичного аналізу XML:\n%1\n\nВиберіть \"Гаразд\", щоб відмовитися від змін або 'Скасувати' для подальшого редагування XML."
+};
diff --git a/blockly/demos/code/msg/vi.js b/blockly/demos/code/msg/vi.js
new file mode 100644
index 0000000..952d024
--- /dev/null
+++ b/blockly/demos/code/msg/vi.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "Chương trình",
+ blocks: "Các mảnh",
+ linkTooltip: "Lưu và lấy địa chỉ liên kết.",
+ runTooltip: "Chạy chương trình.",
+ badCode: "'Lỗi chương trình:\n%1",
+ timeout: "Đã vượt quá số lần lặp cho phép.",
+ trashTooltip: "Xóa tất cả mọi mảnh.",
+ catLogic: "Logic",
+ catLoops: "Vòng lặp",
+ catMath: "Công thức toán",
+ catText: "Văn bản",
+ catLists: "Danh sách",
+ catColour: "Màu",
+ catVariables: "Biến",
+ catFunctions: "Hàm",
+ listVariable: "danh sách",
+ textVariable: "văn bản",
+ httpRequestError: "Hoạt động bị trục trặc, không thực hiện được yêu cầu của bạn.",
+ linkAlert: "Chia sẻ chương trình của bạn với liên kết sau:\n\n %1",
+ hashError: "Không tìm thấy chương trình được lưu ở '%1'.",
+ xmlError: "Không mở được chương trình của bạn. Có thể nó nằm trong một phiên bản khác của Blockly?",
+ badXml: "Lỗi sử lý XML:\n %1\n\nChọn 'OK' để từ bỏ các thay đổi hoặc 'Hủy' để tiếp tục chỉnh sửa các XML."
+};
diff --git a/blockly/demos/code/msg/zh-hans.js b/blockly/demos/code/msg/zh-hans.js
new file mode 100644
index 0000000..abf8a65
--- /dev/null
+++ b/blockly/demos/code/msg/zh-hans.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "代码",
+ blocks: "块",
+ linkTooltip: "保存模块并生成链接。",
+ runTooltip: "于工作区中运行块所定义的程式。",
+ badCode: "程序错误:\n%1",
+ timeout: "超过最大执行行数。",
+ trashTooltip: "放弃所有块。",
+ catLogic: "逻辑",
+ catLoops: "循环",
+ catMath: "数学",
+ catText: "文本",
+ catLists: "列表",
+ catColour: "颜色",
+ catVariables: "变量",
+ catFunctions: "函数",
+ listVariable: "列表",
+ textVariable: "文本",
+ httpRequestError: "请求存在问题。",
+ linkAlert: "通过这个链接分享您的模块:\n\n%1",
+ hashError: "对不起,没有任何已保存的程序对应'%1' 。",
+ xmlError: "无法载入您保存的文件。您是否使用其他版本的Blockly创建该文件的?",
+ badXml: "XML解析错误:\n%1\n\n选择“确定”以取消您对XML的修改,或选择“取消”以继续编辑XML。"
+};
diff --git a/blockly/demos/code/msg/zh-hant.js b/blockly/demos/code/msg/zh-hant.js
new file mode 100644
index 0000000..48a8b52
--- /dev/null
+++ b/blockly/demos/code/msg/zh-hant.js
@@ -0,0 +1,24 @@
+var MSG = {
+ title: "程式碼",
+ blocks: "積木",
+ linkTooltip: "儲存積木組並提供連結。",
+ runTooltip: "於工作區中執行積木組所定義的程式。",
+ badCode: "程式錯誤:\n%1",
+ timeout: "超過最大執行數。",
+ trashTooltip: "捨棄所有積木。",
+ catLogic: "邏輯",
+ catLoops: "迴圈",
+ catMath: "數學式",
+ catText: "文字",
+ catLists: "列表",
+ catColour: "顏色",
+ catVariables: "變量",
+ catFunctions: "流程",
+ listVariable: "列表",
+ textVariable: "文字",
+ httpRequestError: "命令出現錯誤。",
+ linkAlert: "透過此連結分享您的積木組:\n\n%1",
+ hashError: "對不起,「%1」並未對應任何已保存的程式。",
+ xmlError: "未能載入您保存的檔案。或許它是由其他版本的Blockly創建?",
+ badXml: "解析 XML 時出現錯誤:\n%1\n\n選擇'確定'以放棄您的更改,或選擇'取消'以進一步編輯 XML。"
+};
diff --git a/blockly/demos/code/style.css b/blockly/demos/code/style.css
new file mode 100644
index 0000000..e05664f
--- /dev/null
+++ b/blockly/demos/code/style.css
@@ -0,0 +1,163 @@
+html, body {
+ height: 100%;
+}
+
+body {
+ background-color: #fff;
+ font-family: sans-serif;
+ margin: 0;
+ overflow: hidden;
+}
+
+.farSide {
+ text-align: right;
+}
+
+html[dir="RTL"] .farSide {
+ text-align: left;
+}
+
+/* Buttons */
+button {
+ margin: 5px;
+ padding: 10px;
+ border-radius: 4px;
+ border: 1px solid #ddd;
+ font-size: large;
+ background-color: #eee;
+ color: #000;
+}
+button.primary {
+ border: 1px solid #dd4b39;
+ background-color: #dd4b39;
+ color: #fff;
+}
+button.primary>img {
+ opacity: 1;
+}
+button>img {
+ opacity: 0.6;
+ vertical-align: text-bottom;
+}
+button:hover>img {
+ opacity: 1;
+}
+button:active {
+ border: 1px solid #888 !important;
+}
+button:hover {
+ box-shadow: 2px 2px 5px #888;
+}
+button.disabled:hover>img {
+ opacity: 0.6;
+}
+button.disabled {
+ display: none;
+}
+button.notext {
+ font-size: 10%;
+}
+
+h1 {
+ font-weight: normal;
+ font-size: 140%;
+ margin-left: 5px;
+ margin-right: 5px;
+}
+
+/* Tabs */
+#tabRow>td {
+ border: 1px solid #ccc;
+ border-bottom: none;
+}
+td.tabon {
+ border-bottom-color: #ddd !important;
+ background-color: #ddd;
+ padding: 5px 19px;
+}
+td.taboff {
+ cursor: pointer;
+ padding: 5px 19px;
+}
+td.taboff:hover {
+ background-color: #eee;
+}
+td.tabmin {
+ border-top-style: none !important;
+ border-left-style: none !important;
+ border-right-style: none !important;
+}
+td.tabmax {
+ border-top-style: none !important;
+ border-left-style: none !important;
+ border-right-style: none !important;
+ width: 99%;
+ padding-left: 10px;
+ padding-right: 10px;
+ text-align: right;
+}
+html[dir=rtl] td.tabmax {
+ text-align: left;
+}
+
+table {
+ border-collapse: collapse;
+ margin: 0;
+ padding: 0;
+ border: none;
+}
+td {
+ padding: 0;
+ vertical-align: top;
+}
+.content {
+ visibility: hidden;
+ margin: 0;
+ padding: 1ex;
+ position: absolute;
+ direction: ltr;
+}
+pre.content {
+ border: 1px solid #ccc;
+ overflow: scroll;
+}
+#content_blocks {
+ padding: 0;
+}
+.blocklySvg {
+ border-top: none !important;
+}
+#content_xml {
+ resize: none;
+ outline: none;
+ border: 1px solid #ccc;
+ font-family: monospace;
+ overflow: scroll;
+}
+#languageMenu {
+ vertical-align: top;
+ margin-top: 15px;
+ margin-right: 15px;
+}
+
+/* Buttons */
+button {
+ padding: 1px 10px;
+ margin: 1px 5px;
+}
+
+/* Sprited icons. */
+.icon21 {
+ height: 21px;
+ width: 21px;
+ background-image: url(icons.png);
+}
+.trash {
+ background-position: 0px 0px;
+}
+.link {
+ background-position: -21px 0px;
+}
+.run {
+ background-position: -42px 0px;
+}
diff --git a/blockly/demos/fixed/icon.png b/blockly/demos/fixed/icon.png
new file mode 100644
index 0000000..1158acf
--- /dev/null
+++ b/blockly/demos/fixed/icon.png
Binary files differ
diff --git a/blockly/demos/fixed/index.html b/blockly/demos/fixed/index.html
new file mode 100644
index 0000000..680fa76
--- /dev/null
+++ b/blockly/demos/fixed/index.html
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Blockly Demo: Fixed Blockly</title>
+ <script src="../../blockly_compressed.js"></script>
+ <script src="../../blocks_compressed.js"></script>
+ <script src="../../msg/js/en.js"></script>
+ <style>
+ body {
+ background-color: #fff;
+ font-family: sans-serif;
+ }
+ h1 {
+ font-weight: normal;
+ font-size: 140%;
+ }
+ </style>
+</head>
+<body>
+ <h1><a href="https://developers.google.com/blockly/">Blockly</a> &gt;
+ <a href="../index.html">Demos</a> &gt; Fixed Blockly</h1>
+
+ <p>This is a simple demo of injecting Blockly into a fixed-sized 'div' element.</p>
+
+ <p>&rarr; More info on <a href="https://developers.google.com/blockly/guides/configure-blockly/web/fixed-size">injecting fixed-sized Blockly</a>&hellip;</p>
+
+ <div id="blocklyDiv" style="height: 480px; width: 600px;"></div>
+
+ <xml id="toolbox" style="display: none">
+ <block type="controls_if"></block>
+ <block type="logic_compare"></block>
+ <block type="controls_repeat_ext"></block>
+ <block type="math_number"></block>
+ <block type="math_arithmetic"></block>
+ <block type="text"></block>
+ <block type="text_print"></block>
+ </xml>
+
+ <script>
+ var workspace = Blockly.inject('blocklyDiv',
+ {media: '../../media/',
+ toolbox: document.getElementById('toolbox')});
+ </script>
+
+</body>
+</html>
diff --git a/blockly/demos/generator/icon.png b/blockly/demos/generator/icon.png
new file mode 100644
index 0000000..132016e
--- /dev/null
+++ b/blockly/demos/generator/icon.png
Binary files differ
diff --git a/blockly/demos/generator/index.html b/blockly/demos/generator/index.html
new file mode 100644
index 0000000..7bc4838
--- /dev/null
+++ b/blockly/demos/generator/index.html
@@ -0,0 +1,145 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Blockly Demo: Generating JavaScript</title>
+ <script src="../../blockly_compressed.js"></script>
+ <script src="../../blocks_compressed.js"></script>
+ <script src="../../javascript_compressed.js"></script>
+ <script src="../../msg/js/en.js"></script>
+ <style>
+ body {
+ background-color: #fff;
+ font-family: sans-serif;
+ }
+ h1 {
+ font-weight: normal;
+ font-size: 140%;
+ }
+ </style>
+</head>
+<body>
+ <h1><a href="https://developers.google.com/blockly/">Blockly</a> &gt;
+ <a href="../index.html">Demos</a> &gt; Generating JavaScript</h1>
+
+ <p>This is a simple demo of generating code from blocks.</p>
+
+ <p>&rarr; More info on <a href="https://developers.google.com/blockly/guides/configure/web/code-generators">Code Generators</a>&hellip;</p>
+
+ <p>
+ <button onclick="showCode()">Show JavaScript</button>
+ <button onclick="runCode()">Run JavaScript</button>
+ </p>
+
+ <div id="blocklyDiv" style="height: 480px; width: 600px;"></div>
+
+ <xml id="toolbox" style="display: none">
+ <category name="Logic">
+ <block type="controls_if"></block>
+ <block type="logic_compare"></block>
+ <block type="logic_operation"></block>
+ <block type="logic_negate"></block>
+ <block type="logic_boolean"></block>
+ </category>
+ <category name="Loops">
+ <block type="controls_repeat_ext">
+ <value name="TIMES">
+ <block type="math_number">
+ <field name="NUM">10</field>
+ </block>
+ </value>
+ </block>
+ <block type="controls_whileUntil"></block>
+ </category>
+ <category name="Math">
+ <block type="math_number"></block>
+ <block type="math_arithmetic"></block>
+ <block type="math_single"></block>
+ </category>
+ <category name="Text">
+ <block type="text"></block>
+ <block type="text_length"></block>
+ <block type="text_print"></block>
+ </category>
+ </xml>
+
+ <xml id="startBlocks" style="display: none">
+ <block type="controls_if" inline="false" x="20" y="20">
+ <mutation else="1"></mutation>
+ <value name="IF0">
+ <block type="logic_compare" inline="true">
+ <field name="OP">EQ</field>
+ <value name="A">
+ <block type="math_arithmetic" inline="true">
+ <field name="OP">MULTIPLY</field>
+ <value name="A">
+ <block type="math_number">
+ <field name="NUM">6</field>
+ </block>
+ </value>
+ <value name="B">
+ <block type="math_number">
+ <field name="NUM">7</field>
+ </block>
+ </value>
+ </block>
+ </value>
+ <value name="B">
+ <block type="math_number">
+ <field name="NUM">42</field>
+ </block>
+ </value>
+ </block>
+ </value>
+ <statement name="DO0">
+ <block type="text_print" inline="false">
+ <value name="TEXT">
+ <block type="text">
+ <field name="TEXT">Don't panic</field>
+ </block>
+ </value>
+ </block>
+ </statement>
+ <statement name="ELSE">
+ <block type="text_print" inline="false">
+ <value name="TEXT">
+ <block type="text">
+ <field name="TEXT">Panic</field>
+ </block>
+ </value>
+ </block>
+ </statement>
+ </block>
+ </xml>
+
+ <script>
+ var workspace = Blockly.inject('blocklyDiv',
+ {media: '../../media/',
+ toolbox: document.getElementById('toolbox')});
+ Blockly.Xml.domToWorkspace(document.getElementById('startBlocks'),
+ workspace);
+
+ function showCode() {
+ // Generate JavaScript code and display it.
+ Blockly.JavaScript.INFINITE_LOOP_TRAP = null;
+ var code = Blockly.JavaScript.workspaceToCode(workspace);
+ alert(code);
+ }
+
+ function runCode() {
+ // Generate JavaScript code and run it.
+ window.LoopTrap = 1000;
+ Blockly.JavaScript.INFINITE_LOOP_TRAP =
+ 'if (--window.LoopTrap == 0) throw "Infinite loop.";\n';
+ var code = Blockly.JavaScript.workspaceToCode(workspace);
+ Blockly.JavaScript.INFINITE_LOOP_TRAP = null;
+ try {
+ eval(code);
+ } catch (e) {
+ alert(e);
+ }
+ }
+ </script>
+
+</body>
+</html>
diff --git a/blockly/demos/graph/icon.png b/blockly/demos/graph/icon.png
new file mode 100644
index 0000000..ad8b582
--- /dev/null
+++ b/blockly/demos/graph/icon.png
Binary files differ
diff --git a/blockly/demos/graph/index.html b/blockly/demos/graph/index.html
new file mode 100644
index 0000000..4732070
--- /dev/null
+++ b/blockly/demos/graph/index.html
@@ -0,0 +1,358 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Blockly Demo: Graph</title>
+ <script src="https://www.google.com/jsapi"></script>
+ <script src="../../blockly_compressed.js"></script>
+ <script src="../../blocks_compressed.js"></script>
+ <script src="../../javascript_compressed.js"></script>
+ <script src="../../msg/js/en.js"></script>
+ <style>
+ body {
+ background-color: #fff;
+ font-family: sans-serif;
+ }
+ h1 {
+ font-weight: normal;
+ font-size: 140%;
+ }
+ #funcText {
+ margin-top: 1em;
+ margin-left: 1.5em;
+ font-family: sans-serif;
+ }
+ #funcText>img {
+ height: 3px;
+ width: 15px;
+ vertical-align: middle;
+ margin-right: .5em;
+ }
+ #y1 {
+ background-color: #36c;
+ }
+ </style>
+</head>
+<body>
+ <h1><a href="https://developers.google.com/blockly/">Blockly</a> &gt;
+ <a href="../index.html">Demos</a> &gt; Graph</h1>
+
+ <p>This is a demo of giving instant feedback as blocks are changed.</p>
+
+ <p>&rarr; More info on <a href="https://developers.google.com/blockly/guides/configure/web/code-generators#generating_code">Realtime generation</a>&hellip;</p>
+
+ <table>
+ <tr>
+ <td>
+ <div id="visualization" style="width: 400px"></div>
+ </td>
+ <td>
+ <div id="blocklyDiv" style="height: 400px"></div>
+ </td>
+ </tr>
+ </table>
+
+ <div id="funcText">
+ <img id="y1" src="../../media/1x1.gif">
+ ...
+ </div>
+
+ <xml id="toolbox" style="display: none">
+ <category name="Math">
+ <block type="math_number"></block>
+ <block type="math_arithmetic">
+ <value name="A">
+ <shadow type="math_number">
+ <field name="NUM">1</field>
+ </shadow>
+ </value>
+ <value name="B">
+ <shadow type="math_number">
+ <field name="NUM">1</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_single">
+ <value name="NUM">
+ <shadow type="math_number">
+ <field name="NUM">9</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_trig">
+ <value name="NUM">
+ <shadow type="math_number">
+ <field name="NUM">45</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_constant"></block>
+ <block type="math_number_property">
+ <value name="NUMBER_TO_CHECK">
+ <shadow type="math_number">
+ <field name="NUM">0</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_round">
+ <value name="NUM">
+ <shadow type="math_number">
+ <field name="NUM">3.1</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_modulo">
+ <value name="DIVIDEND">
+ <shadow type="math_number">
+ <field name="NUM">64</field>
+ </shadow>
+ </value>
+ <value name="DIVISOR">
+ <shadow type="math_number">
+ <field name="NUM">10</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_constrain">
+ <value name="VALUE">
+ <shadow type="math_number">
+ <field name="NUM">50</field>
+ </shadow>
+ </value>
+ <value name="LOW">
+ <shadow type="math_number">
+ <field name="NUM">1</field>
+ </shadow>
+ </value>
+ <value name="HIGH">
+ <shadow type="math_number">
+ <field name="NUM">100</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_random_int">
+ <value name="FROM">
+ <shadow type="math_number">
+ <field name="NUM">1</field>
+ </shadow>
+ </value>
+ <value name="TO">
+ <shadow type="math_number">
+ <field name="NUM">100</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_random_float"></block>
+ </category>
+ <category name="Variables">
+ <block type="graph_get_x"></block>
+ </category>
+ <category name="Logic">
+ <block type="logic_compare"></block>
+ <block type="logic_operation"></block>
+ <block type="logic_negate"></block>
+ <block type="logic_boolean"></block>
+ <block type="logic_ternary"></block>
+ </category>
+ </xml>
+
+ <xml id="startBlocks" style="display: none">
+ <block type="graph_set_y" deletable="false" x="100" y="100">
+ <value name="VALUE">
+ <block type="math_arithmetic">
+ <field name="OP">POWER</field>
+ <value name="A">
+ <block type="graph_get_x"></block>
+ <shadow type="math_number">
+ <field name="NUM">1</field>
+ </shadow>
+ </value>
+ <value name="B">
+ <block type="math_number">
+ <field name="NUM">2</field>
+ </block>
+ <shadow type="math_number">
+ <field name="NUM">1</field>
+ </shadow>
+ </value>
+ </block>
+ </value>
+ </block>
+ </xml>
+
+ <script>
+// Load the Google Chart Tools Visualization API and the chart package.
+if (typeof google == 'object') {
+ google.load('visualization', '1', {packages: ['corechart']});
+} else {
+ alert('Unable to load Google\'s chart API.\n' +
+ 'Are you connected to the Internet?');
+}
+
+// Define the custom blocks and their JS generators.
+Blockly.Blocks['graph_get_x'] = {
+ // x variable getter.
+ init: function() {
+ this.jsonInit({
+ "message0": "x",
+ "output": "Number",
+ "colour": Blockly.Blocks.variables.HUE,
+ "tooltip": Blockly.Msg.VARIABLES_GET_TOOLTIP,
+ "helpUrl": Blockly.Msg.VARIABLES_GET_HELPURL
+ });
+ }
+};
+
+Blockly.JavaScript['graph_get_x'] = function(block) {
+ // x variable getter.
+ return ['x', Blockly.JavaScript.ORDER_ATOMIC];
+};
+
+Blockly.Blocks['graph_set_y'] = {
+ // y variable setter.
+ init: function() {
+ this.jsonInit({
+ "message0": "y = %1",
+ "args0": [
+ {
+ "type": "input_value",
+ "name": "VALUE",
+ "check": "Number"
+ }
+ ],
+ "colour": Blockly.Blocks.variables.HUE,
+ "tooltip": Blockly.Msg.VARIABLES_SET_TOOLTIP,
+ "helpUrl": Blockly.Msg.VARIABLES_SET_HELPURL
+ });
+ }
+};
+
+Blockly.JavaScript['graph_set_y'] = function(block) {
+ // y variable setter.
+ var argument0 = Blockly.JavaScript.valueToCode(block, 'VALUE',
+ Blockly.JavaScript.ORDER_ASSIGNMENT) || '';
+ return 'y = ' + argument0 + ';';
+};
+
+/**
+ * Create a namespace for the application.
+ */
+var Graph = {};
+
+/**
+ * Main Blockly workspace.
+ * @type {Blockly.WorkspaceSvg}
+ */
+Graph.workspace = null;
+
+/**
+ * Cached copy of the function string.
+ * @type {?string}
+ * @private
+ */
+Graph.oldFormula_ = null;
+
+/**
+ * Drawing options for the Chart API.
+ * @type {!Object}
+ * @private
+ */
+Graph.options_ = {
+ //curveType: 'function',
+ width: 400, height: 400,
+ chartArea: {left: '10%', width: '85%', height: '85%'}
+};
+
+/**
+ * Visualize the graph of y = f(x) using Google Chart Tools.
+ * For more documentation on Google Chart Tools, see this linechart example:
+ * https://developers.google.com/chart/interactive/docs/gallery/linechart
+ */
+Graph.drawVisualization = function() {
+ var formula = Blockly.JavaScript.workspaceToCode(Graph.workspace);
+ if (formula === Graph.oldFormula_) {
+ // No change in the formula, don't recompute.
+ return;
+ }
+ Graph.oldFormula_ = formula;
+
+ // Create and populate the data table.
+ var data = google.visualization.arrayToDataTable(Graph.plot(formula));
+ // Create and draw the visualization, passing in the data and options.
+ new google.visualization.LineChart(document.getElementById('visualization')).
+ draw(data, Graph.options_);
+
+ // Create the "y = ..." label. Find the relevant part of the code.
+ formula = formula.substring(formula.indexOf('y = '));
+ formula = formula.substring(0, formula.indexOf(';'));
+ var funcText = document.getElementById('funcText');
+ funcText.replaceChild(document.createTextNode(formula), funcText.lastChild);
+};
+
+/**
+ * Plot points on the function y = f(x).
+ * @param {string} code JavaScript code.
+ * @return {!Array.<!Array>} 2D Array of points on the graph.
+ */
+Graph.plot = function(code) {
+ // Initialize a table with two column headings.
+ var table = [];
+ var y;
+ // TODO: Improve range and scale of graph.
+ for (var x = -10; x <= 10; x = Math.round((x + 0.1) * 10) / 10) {
+ try {
+ eval(code);
+ } catch (e) {
+ y = NaN;
+ }
+ if (!isNaN(y)) {
+ // Prevent y from being displayed inconsistently, some in decimals, some
+ // in scientific notation, often when y has accumulated rounding errors.
+ y = Math.round(y * Math.pow(10, 14)) / Math.pow(10, 14);
+ table.push([x, y]);
+ }
+ }
+ // Add column heading to table.
+ if (table.length) {
+ table.unshift(['x', 'y']);
+ } else {
+ // If the table is empty, add a [0, 0] row to prevent graph error.
+ table.unshift(['x', 'y'], [0, 0]);
+ }
+ return table;
+};
+
+/**
+ * Force Blockly to resize into the available width.
+ */
+Graph.resize = function() {
+ var width = Math.max(window.innerWidth - 440, 250);
+ document.getElementById('blocklyDiv').style.width = width + 'px';
+ Blockly.svgResize(Graph.workspace);
+};
+
+/**
+ * Initialize Blockly and the graph. Called on page load.
+ */
+Graph.init = function() {
+ Graph.workspace = Blockly.inject('blocklyDiv',
+ {collapse: false,
+ disable: false,
+ media: '../../media/',
+ toolbox: document.getElementById('toolbox')});
+ Blockly.Xml.domToWorkspace(document.getElementById('startBlocks'),
+ Graph.workspace);
+ Graph.workspace.clearUndo();
+
+ // When Blockly changes, update the graph.
+ Graph.workspace.addChangeListener(Graph.drawVisualization);
+ Graph.workspace.addChangeListener(Blockly.Events.disableOrphans);
+ Graph.resize();
+};
+
+window.addEventListener('load', Graph.init);
+window.addEventListener('resize', Graph.resize);
+ </script>
+
+</body>
+</html>
diff --git a/blockly/demos/headless/icon.png b/blockly/demos/headless/icon.png
new file mode 100644
index 0000000..af9ebe7
--- /dev/null
+++ b/blockly/demos/headless/icon.png
Binary files differ
diff --git a/blockly/demos/headless/index.html b/blockly/demos/headless/index.html
new file mode 100644
index 0000000..62d49fd
--- /dev/null
+++ b/blockly/demos/headless/index.html
@@ -0,0 +1,120 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Blockly Demo: Headless</title>
+ <script src="../../blockly_compressed.js"></script>
+ <script src="../../blocks_compressed.js"></script>
+ <script src="../../python_compressed.js"></script>
+ <script src="../../msg/js/en.js"></script>
+ <style>
+ body {
+ background-color: #fff;
+ font-family: sans-serif;
+ }
+ h1 {
+ font-weight: normal;
+ font-size: 140%;
+ }
+ td {
+ vertical-align: top;
+ }
+ textarea {
+ width: 100%;
+ height: 20em;
+ }
+ </style>
+</head>
+<body>
+ <h1><a href="https://developers.google.com/blockly/">Blockly</a> &gt;
+ <a href="../index.html">Demos</a> &gt; Headless</h1>
+
+ <p>This is a simple demo of generating Python code from XML with no graphics.
+ This might be useful for server-side code generation.</p>
+
+ <table style="width: 100%">
+ <tr>
+ <td style="width:50%">
+ <textarea id="xml_input">
+<xml>
+ <block type="controls_if" inline="false" x="20" y="20">
+ <mutation else="1"></mutation>
+ <value name="IF0">
+ <block type="logic_compare" inline="true">
+ <field name="OP">EQ</field>
+ <value name="A">
+ <block type="math_arithmetic" inline="true">
+ <field name="OP">MULTIPLY</field>
+ <value name="A">
+ <block type="math_number">
+ <field name="NUM">6</field>
+ </block>
+ </value>
+ <value name="B">
+ <block type="math_number">
+ <field name="NUM">7</field>
+ </block>
+ </value>
+ </block>
+ </value>
+ <value name="B">
+ <block type="math_number">
+ <field name="NUM">42</field>
+ </block>
+ </value>
+ </block>
+ </value>
+ <statement name="DO0">
+ <block type="text_print" inline="false">
+ <value name="TEXT">
+ <block type="text">
+ <field name="TEXT">Don't panic</field>
+ </block>
+ </value>
+ </block>
+ </statement>
+ <statement name="ELSE">
+ <block type="text_print" inline="false">
+ <value name="TEXT">
+ <block type="text">
+ <field name="TEXT">Panic</field>
+ </block>
+ </value>
+ </block>
+ </statement>
+ </block>
+</xml>
+ </textarea>
+ </td>
+ <td>
+ </td>
+ <td style="width:50%">
+ <textarea id="code_output" readonly></textarea>
+ </td>
+ </tr>
+ </table>
+
+ <div style="text-align: center">
+ <button onclick="generate()">Generate Python &#10548;</button>
+ </div>
+
+ <script>
+ function generate() {
+ // Parse the XML into a tree.
+ var xmlText = document.getElementById('xml_input').value;
+ try {
+ var xml = Blockly.Xml.textToDom(xmlText)
+ } catch (e) {
+ alert(e);
+ return;
+ }
+ // Create a headless workspace.
+ var workspace = new Blockly.Workspace();
+ Blockly.Xml.domToWorkspace(xml, workspace);
+ var code = Blockly.Python.workspaceToCode(workspace);
+ document.getElementById('code_output').value = code;
+ }
+ </script>
+
+</body>
+</html>
diff --git a/blockly/demos/index.html b/blockly/demos/index.html
new file mode 100644
index 0000000..bd745ce
--- /dev/null
+++ b/blockly/demos/index.html
@@ -0,0 +1,212 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Blockly Demos</title>
+ <style>
+ body {
+ margin: 0 10%;
+ background-color: #fff;
+ font-family: sans-serif;
+ }
+ h1 {
+ font-weight: normal;
+ font-size: 140%;
+ }
+ td {
+ padding: 1ex;
+ }
+ img {
+ border: none;
+ }
+ </style>
+</head>
+<body>
+ <h1><a href="https://developers.google.com/blockly/">Blockly</a> &gt; Demos</h1>
+
+ <p>These demos are intended for developers who want to integrate Blockly with
+ their own applications.</p>
+
+ <table>
+ <tr>
+ <td>
+ <a href="fixed/index.html">
+ <img src="fixed/icon.png" height=80 width=100>
+ </a>
+ </td>
+ <td>
+ <div><a href="fixed/index.html">Fixed Blockly</a></div>
+ <div>Inject Blockly into a page as a fixed element.</div>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <a href="resizable/index.html">
+ <img src="resizable/icon.png" height=80 width=100>
+ </a>
+ </td>
+ <td>
+ <div><a href="resizable/index.html">Resizable Blockly</a></div>
+ <div>Inject Blockly into a page as a resizable element.</div>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <a href="toolbox/index.html">
+ <img src="toolbox/icon.png" height=80 width=100>
+ </a>
+ </td>
+ <td>
+ <div><a href="toolbox/index.html">Defining the Toolbox</a></div>
+ <div>Organize blocks into categories for the user.</div>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <a href="maxBlocks/index.html">
+ <img src="maxBlocks/icon.png" height=80 width=100>
+ </a>
+ </td>
+ <td>
+ <div><a href="maxBlocks/index.html">Maximum Block Limit</a></div>
+ <div>Limit the total number of blocks allowed (for academic exercises).</div>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <a href="generator/index.html">
+ <img src="generator/icon.png" height=80 width=100>
+ </a>
+ </td>
+ <td>
+ <div><a href="generator/index.html">Generate JavaScript</a></div>
+ <div>Turn blocks into code and execute it.</div>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <a href="headless/index.html">
+ <img src="headless/icon.png" height=80 width=100>
+ </a>
+ </td>
+ <td>
+ <div><a href="headless/index.html">Headless</a></div>
+ <div>Generate code from XML without graphics.</div>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <a href="interpreter/index.html">
+ <img src="interpreter/icon.png" height=80 width=100>
+ </a>
+ </td>
+ <td>
+ <div><a href="interpreter/index.html">JS Interpreter</a></div>
+ <div>Step by step execution in JavaScript.</div>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <a href="graph/index.html">
+ <img src="graph/icon.png" height=80 width=100>
+ </a>
+ </td>
+ <td>
+ <div><a href="graph/index.html">Graph</a></div>
+ <div>Instant updates when blocks are changed.</div>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <a href="rtl/index.html">
+ <img src="rtl/icon.png" height=80 width=100>
+ </a>
+ </td>
+ <td>
+ <div><a href="rtl/index.html">RTL</a></div>
+ <div>See what Blockly looks like in right-to-left mode (for Arabic and Hebrew).</div>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <a href="storage/index.html">
+ <img src="storage/icon.png" height=80 width=100>
+ </a>
+ </td>
+ <td>
+ <div><a href="storage/index.html">Cloud Storage</a></div>
+ <div>Save and load blocks with App Engine.</div>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <a href="mirror/index.html">
+ <img src="mirror/icon.png" height=80 width=100>
+ </a>
+ </td>
+ <td>
+ <div><a href="mirror/index.html">Mirrored Blockly</a></div>
+ <div>Two Blockly instances connected as master-slave.</div>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <a href="accessible/index.html">
+ <img src="accessible/icon.png" height=80 width=100>
+ </a>
+ </td>
+ <td>
+ <div><a href="accessible/index.html">Accessible Blockly</a></div>
+ <div>Version of Blockly accessible to screen readers.</div>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <a href="plane/index.html">
+ <img src="plane/icon.png" height=80 width=100>
+ </a>
+ </td>
+ <td>
+ <div><a href="plane/index.html">Plane</a></div>
+ <div>Using Closure Templates to support 35 languages.</div>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <a href="code/index.html">
+ <img src="code/icon.png" height=80 width=100>
+ </a>
+ </td>
+ <td>
+ <div><a href="code/index.html">Code Editor</a></div>
+ <div>Export a Blockly program into JavaScript, Python, PHP, Lua, Dart, or XML.</div>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <a href="blockfactory/index.html">
+ <img src="blockfactory/icon.png" height=80 width=100>
+ </a>
+ </td>
+ <td>
+ <div><a href="blockfactory/index.html">Block Factory</a></div>
+ <div>Build custom blocks using Blockly.</div>
+ </td>
+ </tr>
+ </table>
+</body>
+</html>
diff --git a/blockly/demos/interpreter/acorn_interpreter.js b/blockly/demos/interpreter/acorn_interpreter.js
new file mode 100644
index 0000000..698f14c
--- /dev/null
+++ b/blockly/demos/interpreter/acorn_interpreter.js
@@ -0,0 +1,153 @@
+var mod$$inline_58=function(a){function b(a){n=a||{};for(var b in Ua)Object.prototype.hasOwnProperty.call(n,b)||(n[b]=Ua[b]);wa=n.sourceFile||null}function c(a,b){var c=Ab(k,a);b+=" ("+c.line+":"+c.column+")";var f=new SyntaxError(b);f.pos=a;f.loc=c;f.raisedAt=g;throw f;}function d(a){function b(a){if(1==a.length)return c+="return str === "+JSON.stringify(a[0])+";";c+="switch(str){";for(var va=0;va<a.length;++va)c+="case "+JSON.stringify(a[va])+":";c+="return true}return false;"}a=a.split(" ");var c=
+"",f=[],e=0;a:for(;e<a.length;++e){for(var d=0;d<f.length;++d)if(f[d][0].length==a[e].length){f[d].push(a[e]);continue a}f.push([a[e]])}if(3<f.length){f.sort(function(a,b){return b.length-a.length});c+="switch(str.length){";for(e=0;e<f.length;++e)a=f[e],c+="case "+a[0].length+":",b(a);c+="}"}else b(a);return new Function("str",c)}function f(){this.line=H;this.column=g-E}function e(a,b){X=g;n.locations&&(ia=new f);p=a;l();I=b;R=a.beforeExpr}function h(){for(var a=g,b=n.onComment&&n.locations&&new f,
+c=k.charCodeAt(g+=2);g<S&&10!==c&&13!==c&&8232!==c&&8233!==c;)++g,c=k.charCodeAt(g);if(n.onComment)n.onComment(!1,k.slice(a+2,g),a,g,b,n.locations&&new f)}function l(){for(;g<S;){var a=k.charCodeAt(g);if(32===a)++g;else if(13===a)++g,a=k.charCodeAt(g),10===a&&++g,n.locations&&(++H,E=g);else if(10===a||8232===a||8233===a)++g,n.locations&&(++H,E=g);else if(8<a&&14>a)++g;else if(47===a)if(a=k.charCodeAt(g+1),42===a){var a=n.onComment&&n.locations&&new f,b=g,e=k.indexOf("*/",g+=2);-1===e&&c(g-2,"Unterminated comment");
+g=e+2;if(n.locations){Y.lastIndex=b;for(var d=void 0;(d=Y.exec(k))&&d.index<g;)++H,E=d.index+d[0].length}if(n.onComment)n.onComment(!0,k.slice(b+2,e),b,g,a,n.locations&&new f)}else if(47===a)h();else break;else if(160===a)++g;else if(5760<=a&&Bb.test(String.fromCharCode(a)))++g;else break}}function m(a){switch(a){case 46:return a=k.charCodeAt(g+1),48<=a&&57>=a?a=P(!0):(++g,a=e(xa)),a;case 40:return++g,e(J);case 41:return++g,e(F);case 59:return++g,e(K);case 44:return++g,e(L);case 91:return++g,e(ja);
+case 93:return++g,e(ka);case 123:return++g,e(Z);case 125:return++g,e(T);case 58:return++g,e(aa);case 63:return++g,e(ya);case 48:if(a=k.charCodeAt(g+1),120===a||88===a)return g+=2,a=x(16),null==a&&c(y+2,"Expected hexadecimal number"),la(k.charCodeAt(g))&&c(g,"Identifier directly after number"),a=e(ba,a);case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return P(!1);case 34:case 39:a:{g++;for(var b="";;){g>=S&&c(y,"Unterminated string constant");var f=k.charCodeAt(g);if(f===a){++g;
+a=e(da,b);break a}if(92===f){var f=k.charCodeAt(++g),d=/^[0-7]+/.exec(k.slice(g,g+3));for(d&&(d=d[0]);d&&255<parseInt(d,8);)d=d.slice(0,-1);"0"===d&&(d=null);++g;if(d)C&&c(g-2,"Octal literal in strict mode"),b+=String.fromCharCode(parseInt(d,8)),g+=d.length-1;else switch(f){case 110:b+="\n";break;case 114:b+="\r";break;case 120:b+=String.fromCharCode(ma(2));break;case 117:b+=String.fromCharCode(ma(4));break;case 85:b+=String.fromCharCode(ma(8));break;case 116:b+="\t";break;case 98:b+="\b";break;case 118:b+=
+"\x0B";break;case 102:b+="\f";break;case 48:b+="\x00";break;case 13:10===k.charCodeAt(g)&&++g;case 10:n.locations&&(E=g,++H);break;default:b+=String.fromCharCode(f)}}else 13!==f&&10!==f&&8232!==f&&8233!==f||c(y,"Unterminated string constant"),b+=String.fromCharCode(f),++g}}return a;case 47:return a=k.charCodeAt(g+1),R?(++g,a=D()):a=61===a?t(U,2):t(za,1),a;case 37:case 42:return a=k.charCodeAt(g+1),a=61===a?t(U,2):t(Cb,1),a;case 124:case 38:return b=k.charCodeAt(g+1),a=b===a?t(124===a?Va:Wa,2):61===
+b?t(U,2):t(124===a?Db:Eb,1),a;case 94:return a=k.charCodeAt(g+1),a=61===a?t(U,2):t(Fb,1),a;case 43:case 45:return b=k.charCodeAt(g+1),b===a?45==b&&62==k.charCodeAt(g+2)&&na.test(k.slice(M,g))?(g+=3,h(),l(),a=A()):a=t(Gb,2):a=61===b?t(U,2):t(Hb,1),a;case 60:case 62:return b=k.charCodeAt(g+1),f=1,b===a?(f=62===a&&62===k.charCodeAt(g+2)?3:2,a=61===k.charCodeAt(g+f)?t(U,f+1):t(Ib,f)):33==b&&60==a&&45==k.charCodeAt(g+2)&&45==k.charCodeAt(g+3)?(g+=4,h(),l(),a=A()):(61===b&&(f=61===k.charCodeAt(g+2)?3:2),
+a=t(Jb,f)),a;case 61:case 33:return b=k.charCodeAt(g+1),a=61===b?t(Kb,61===k.charCodeAt(g+2)?3:2):t(61===a?Aa:Xa,1),a;case 126:return t(Xa,1)}return!1}function A(a){a?g=y+1:y=g;n.locations&&(oa=new f);if(a)return D();if(g>=S)return e(pa);var b=k.charCodeAt(g);if(la(b)||92===b)return Ya();a=m(b);if(!1===a){b=String.fromCharCode(b);if("\\"===b||Za.test(b))return Ya();c(g,"Unexpected character '"+b+"'")}return a}function t(a,b){var c=k.slice(g,g+b);g+=b;e(a,c)}function D(){for(var a="",b,f,d=g;;){g>=
+S&&c(d,"Unterminated regular expression");a=k.charAt(g);na.test(a)&&c(d,"Unterminated regular expression");if(b)b=!1;else{if("["===a)f=!0;else if("]"===a&&f)f=!1;else if("/"===a&&!f)break;b="\\"===a}++g}a=k.slice(d,g);++g;(b=$a())&&!/^[gmsiy]*$/.test(b)&&c(d,"Invalid regexp flag");return e(Ba,new RegExp(a,b))}function x(a,b){for(var c=g,f=0,e=0,d=null==b?Infinity:b;e<d;++e){var h=k.charCodeAt(g),h=97<=h?h-97+10:65<=h?h-65+10:48<=h&&57>=h?h-48:Infinity;if(h>=a)break;++g;f=f*a+h}return g===c||null!=
+b&&g-c!==b?null:f}function P(a){var b=g,f=!1,d=48===k.charCodeAt(g);a||null!==x(10)||c(b,"Invalid number");46===k.charCodeAt(g)&&(++g,x(10),f=!0);a=k.charCodeAt(g);if(69===a||101===a)a=k.charCodeAt(++g),43!==a&&45!==a||++g,null===x(10)&&c(b,"Invalid number"),f=!0;la(k.charCodeAt(g))&&c(g,"Identifier directly after number");a=k.slice(b,g);var h;f?h=parseFloat(a):d&&1!==a.length?/[89]/.test(a)||C?c(b,"Invalid number"):h=parseInt(a,8):h=parseInt(a,10);return e(ba,h)}function ma(a){a=x(16,a);null===a&&
+c(y,"Bad character escape sequence");return a}function $a(){ca=!1;for(var a,b=!0,f=g;;){var e=k.charCodeAt(g);if(ab(e))ca&&(a+=k.charAt(g)),++g;else if(92===e){ca||(a=k.slice(f,g));ca=!0;117!=k.charCodeAt(++g)&&c(g,"Expecting Unicode escape sequence \\uXXXX");++g;var e=ma(4),d=String.fromCharCode(e);d||c(g-1,"Invalid Unicode escape");(b?la(e):ab(e))||c(g-4,"Invalid Unicode escape");a+=d}else break;b=!1}return ca?a:k.slice(f,g)}function Ya(){var a=$a(),b=V;ca||(Lb(a)?b=Ca[a]:(n.forbidReserved&&(3===
+n.ecmaVersion?Mb:Nb)(a)||C&&bb(a))&&c(y,"The keyword '"+a+"' is reserved"));return e(b,a)}function r(){Da=y;M=X;Ea=ia;A()}function Fa(a){C=a;g=M;if(n.locations)for(;g<E;)E=k.lastIndexOf("\n",E-2)+1,--H;l();A()}function cb(){this.type=null;this.start=y;this.end=null}function db(){this.start=oa;this.end=null;null!==wa&&(this.source=wa)}function z(){var a=new cb;n.locations&&(a.loc=new db);n.directSourceFile&&(a.sourceFile=n.directSourceFile);n.ranges&&(a.range=[y,0]);return a}function Q(a){var b=new cb;
+b.start=a.start;n.locations&&(b.loc=new db,b.loc.start=a.loc.start);n.ranges&&(b.range=[a.range[0],0]);return b}function q(a,b){a.type=b;a.end=M;n.locations&&(a.loc.end=Ea);n.ranges&&(a.range[1]=M);return a}function Ga(a){return 5<=n.ecmaVersion&&"ExpressionStatement"===a.type&&"Literal"===a.expression.type&&"use strict"===a.expression.value}function u(a){if(p===a)return r(),!0}function qa(){return!n.strictSemicolons&&(p===pa||p===T||na.test(k.slice(M,y)))}function W(){u(K)||qa()||N()}function v(a){p===
+a?r():N()}function N(){c(y,"Unexpected token")}function ra(a){"Identifier"!==a.type&&"MemberExpression"!==a.type&&c(a.start,"Assigning to rvalue");C&&"Identifier"===a.type&&sa(a.name)&&c(a.start,"Assigning to "+a.name+" in strict mode")}function G(){(p===za||p===U&&"/="==I)&&A(!0);var a=p,b=z();switch(a){case Ha:case eb:r();var f=a===Ha;u(K)||qa()?b.label=null:p!==V?N():(b.label=O(),W());for(var e=0;e<w.length;++e){var d=w[e];if(null==b.label||d.name===b.label.name){if(null!=d.kind&&(f||"loop"===
+d.kind))break;if(b.label&&f)break}}e===w.length&&c(b.start,"Unsyntactic "+a.keyword);return q(b,f?"BreakStatement":"ContinueStatement");case fb:return r(),W(),q(b,"DebuggerStatement");case gb:return r(),w.push(Ia),b.body=G(),w.pop(),v(Ja),b.test=ea(),W(),q(b,"DoWhileStatement");case hb:r();w.push(Ia);v(J);if(p===K)return Ka(b,null);if(p===La)return a=z(),r(),ib(a,!0),q(a,"VariableDeclaration"),1===a.declarations.length&&u(ta)?jb(b,a):Ka(b,a);a=B(!1,!0);return u(ta)?(ra(a),jb(b,a)):Ka(b,a);case Ma:return r(),
+Na(b,!0);case kb:return r(),b.test=ea(),b.consequent=G(),b.alternate=u(lb)?G():null,q(b,"IfStatement");case mb:return fa||c(y,"'return' outside of function"),r(),u(K)||qa()?b.argument=null:(b.argument=B(),W()),q(b,"ReturnStatement");case Oa:r();b.discriminant=ea();b.cases=[];v(Z);for(w.push(Ob);p!=T;)p===Pa||p===nb?(a=p===Pa,e&&q(e,"SwitchCase"),b.cases.push(e=z()),e.consequent=[],r(),a?e.test=B():(f&&c(Da,"Multiple default clauses"),f=!0,e.test=null),v(aa)):(e||N(),e.consequent.push(G()));e&&q(e,
+"SwitchCase");r();w.pop();return q(b,"SwitchStatement");case ob:return r(),na.test(k.slice(M,y))&&c(M,"Illegal newline after throw"),b.argument=B(),W(),q(b,"ThrowStatement");case pb:return r(),b.block=ga(),b.handler=null,p===qb&&(a=z(),r(),v(J),a.param=O(),C&&sa(a.param.name)&&c(a.param.start,"Binding "+a.param.name+" in strict mode"),v(F),a.guard=null,a.body=ga(),b.handler=q(a,"CatchClause")),b.guardedHandlers=rb,b.finalizer=u(sb)?ga():null,b.handler||b.finalizer||c(b.start,"Missing catch or finally clause"),
+q(b,"TryStatement");case La:return r(),ib(b),W(),q(b,"VariableDeclaration");case Ja:return r(),b.test=ea(),w.push(Ia),b.body=G(),w.pop(),q(b,"WhileStatement");case tb:return C&&c(y,"'with' in strict mode"),r(),b.object=ea(),b.body=G(),q(b,"WithStatement");case Z:return ga();case K:return r(),q(b,"EmptyStatement");default:f=I;d=B();if(a===V&&"Identifier"===d.type&&u(aa)){for(e=0;e<w.length;++e)w[e].name===f&&c(d.start,"Label '"+f+"' is already declared");a=p.isLoop?"loop":p===Oa?"switch":null;w.push({name:f,
+kind:a});b.body=G();w.pop();b.label=d;return q(b,"LabeledStatement")}b.expression=d;W();return q(b,"ExpressionStatement")}}function ea(){v(J);var a=B();v(F);return a}function ga(a){var b=z(),c=!0,f=!1,e;b.body=[];for(v(Z);!u(T);){var d=G();b.body.push(d);c&&a&&Ga(d)&&(e=f,Fa(f=!0));c=!1}f&&!e&&Fa(!1);return q(b,"BlockStatement")}function Ka(a,b){a.init=b;v(K);a.test=p===K?null:B();v(K);a.update=p===F?null:B();v(F);a.body=G();w.pop();return q(a,"ForStatement")}function jb(a,b){a.left=b;a.right=B();
+v(F);a.body=G();w.pop();return q(a,"ForInStatement")}function ib(a,b){a.declarations=[];for(a.kind="var";;){var f=z();f.id=O();C&&sa(f.id.name)&&c(f.id.start,"Binding "+f.id.name+" in strict mode");f.init=u(Aa)?B(!0,b):null;a.declarations.push(q(f,"VariableDeclarator"));if(!u(L))break}return a}function B(a,b){var c=Qa(b);if(!a&&p===L){var f=Q(c);for(f.expressions=[c];u(L);)f.expressions.push(Qa(b));return q(f,"SequenceExpression")}return c}function Qa(a){var b;b=a;var c;c=b;c=Ra(Sa(),-1,c);if(u(ya)){var f=
+Q(c);f.test=c;f.consequent=B(!0);v(aa);f.alternate=B(!0,b);b=q(f,"ConditionalExpression")}else b=c;return p.isAssign?(c=Q(b),c.operator=I,c.left=b,r(),c.right=Qa(a),ra(b),q(c,"AssignmentExpression")):b}function Ra(a,b,c){var f=p.binop;if(null!=f&&(!c||p!==ta)&&f>b){var e=Q(a);e.left=a;e.operator=I;a=p;r();e.right=Ra(Sa(),f,c);f=q(e,a===Va||a===Wa?"LogicalExpression":"BinaryExpression");return Ra(f,b,c)}return a}function Sa(){if(p.prefix){var a=z(),b=p.isUpdate;a.operator=I;R=a.prefix=!0;r();a.argument=
+Sa();b?ra(a.argument):C&&"delete"===a.operator&&"Identifier"===a.argument.type&&c(a.start,"Deleting local variable in strict mode");return q(a,b?"UpdateExpression":"UnaryExpression")}for(b=ha(ua());p.postfix&&!qa();)a=Q(b),a.operator=I,a.prefix=!1,a.argument=b,ra(b),r(),b=q(a,"UpdateExpression");return b}function ha(a,b){if(u(xa)){var c=Q(a);c.object=a;c.property=O(!0);c.computed=!1;return ha(q(c,"MemberExpression"),b)}return u(ja)?(c=Q(a),c.object=a,c.property=B(),c.computed=!0,v(ka),ha(q(c,"MemberExpression"),
+b)):!b&&u(J)?(c=Q(a),c.callee=a,c.arguments=Ta(F,!1),ha(q(c,"CallExpression"),b)):a}function ua(){switch(p){case ub:var a=z();r();return q(a,"ThisExpression");case V:return O();case ba:case da:case Ba:return a=z(),a.value=I,a.raw=k.slice(y,X),r(),q(a,"Literal");case vb:case wb:case xb:return a=z(),a.value=p.atomValue,a.raw=p.keyword,r(),q(a,"Literal");case J:var a=oa,b=y;r();var f=B();f.start=b;f.end=X;n.locations&&(f.loc.start=a,f.loc.end=ia);n.ranges&&(f.range=[b,X]);v(F);return f;case ja:return a=
+z(),r(),a.elements=Ta(ka,!0,!0),q(a,"ArrayExpression");case Z:a=z();b=!0;f=!1;a.properties=[];for(r();!u(T);){if(b)b=!1;else if(v(L),n.allowTrailingCommas&&u(T))break;var e={key:p===ba||p===da?ua():O(!0)},d=!1,h;u(aa)?(e.value=B(!0),h=e.kind="init"):5<=n.ecmaVersion&&"Identifier"===e.key.type&&("get"===e.key.name||"set"===e.key.name)?(d=f=!0,h=e.kind=e.key.name,e.key=p===ba||p===da?ua():O(!0),p!==J&&N(),e.value=Na(z(),!1)):N();if("Identifier"===e.key.type&&(C||f))for(var g=0;g<a.properties.length;++g){var l=
+a.properties[g];if(l.key.name===e.key.name){var m=h==l.kind||d&&"init"===l.kind||"init"===h&&("get"===l.kind||"set"===l.kind);m&&!C&&"init"===h&&"init"===l.kind&&(m=!1);m&&c(e.key.start,"Redefinition of property")}}a.properties.push(e)}return a=q(a,"ObjectExpression");case Ma:return a=z(),r(),Na(a,!1);case yb:return a=z(),r(),a.callee=ha(ua(),!0),u(J)?a.arguments=Ta(F,!1):a.arguments=rb,a=q(a,"NewExpression");default:N()}}function Na(a,b){p===V?a.id=O():b?N():a.id=null;a.params=[];var f=!0;for(v(J);!u(F);)f?
+f=!1:v(L),a.params.push(O());var f=fa,e=w;fa=!0;w=[];a.body=ga(!0);fa=f;w=e;if(C||a.body.body.length&&Ga(a.body.body[0]))for(f=a.id?-1:0;f<a.params.length;++f)if(e=0>f?a.id:a.params[f],(bb(e.name)||sa(e.name))&&c(e.start,"Defining '"+e.name+"' in strict mode"),0<=f)for(var d=0;d<f;++d)e.name===a.params[d].name&&c(e.start,"Argument name clash in strict mode");return q(a,b?"FunctionDeclaration":"FunctionExpression")}function Ta(a,b,c){for(var f=[],e=!0;!u(a);){if(e)e=!1;else if(v(L),b&&n.allowTrailingCommas&&
+u(a))break;c&&p===L?f.push(null):f.push(B(!0))}return f}function O(a){var b=z();b.name=p===V?I:a&&!n.forbidReserved&&p.keyword||N();R=!1;r();return q(b,"Identifier")}a.version="0.4.1";var n,k,S,wa;a.parse=function(a,c){k=String(a);S=k.length;b(c);H=1;g=E=0;R=!0;l();var e,d=n.program;Da=M=g;n.locations&&(Ea=new f);fa=C=null;w=[];A();e=d||z();var h=!0;d||(e.body=[]);for(;p!==pa;)d=G(),e.body.push(d),h&&Ga(d)&&Fa(!0),h=!1;return e=q(e,"Program")};var Ua=a.defaultOptions={ecmaVersion:5,strictSemicolons:!1,
+allowTrailingCommas:!0,forbidReserved:!1,locations:!1,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null},Ab=a.getLineInfo=function(a,b){for(var c=1,f=0;;){Y.lastIndex=f;var e=Y.exec(a);if(e&&e.index<b)++c,f=e.index+e[0].length;else break}return{line:c,column:b-f}};a.tokenize=function(a,c){function f(a){A(a);e.start=y;e.end=X;e.startLoc=oa;e.endLoc=ia;e.type=p;e.value=I;return e}k=String(a);S=k.length;b(c);H=1;g=E=0;R=!0;l();var e={};f.jumpTo=function(a,b){g=a;if(n.locations){H=
+1;E=Y.lastIndex=0;for(var c;(c=Y.exec(k))&&c.index<a;)++H,E=c.index+c[0].length}R=b;l()};return f};var g,y,X,oa,ia,p,I,R,H,E,Da,M,Ea,fa,w,C,rb=[],ba={type:"num"},Ba={type:"regexp"},da={type:"string"},V={type:"name"},pa={type:"eof"},Ha={keyword:"break"},Pa={keyword:"case",beforeExpr:!0},qb={keyword:"catch"},eb={keyword:"continue"},fb={keyword:"debugger"},nb={keyword:"default"},gb={keyword:"do",isLoop:!0},lb={keyword:"else",beforeExpr:!0},sb={keyword:"finally"},hb={keyword:"for",isLoop:!0},Ma={keyword:"function"},
+kb={keyword:"if"},mb={keyword:"return",beforeExpr:!0},Oa={keyword:"switch"},ob={keyword:"throw",beforeExpr:!0},pb={keyword:"try"},La={keyword:"var"},Ja={keyword:"while",isLoop:!0},tb={keyword:"with"},yb={keyword:"new",beforeExpr:!0},ub={keyword:"this"},vb={keyword:"null",atomValue:null},wb={keyword:"true",atomValue:!0},xb={keyword:"false",atomValue:!1},ta={keyword:"in",binop:7,beforeExpr:!0},Ca={"break":Ha,"case":Pa,"catch":qb,"continue":eb,"debugger":fb,"default":nb,"do":gb,"else":lb,"finally":sb,
+"for":hb,"function":Ma,"if":kb,"return":mb,"switch":Oa,"throw":ob,"try":pb,"var":La,"while":Ja,"with":tb,"null":vb,"true":wb,"false":xb,"new":yb,"in":ta,"instanceof":{keyword:"instanceof",binop:7,beforeExpr:!0},"this":ub,"typeof":{keyword:"typeof",prefix:!0,beforeExpr:!0},"void":{keyword:"void",prefix:!0,beforeExpr:!0},"delete":{keyword:"delete",prefix:!0,beforeExpr:!0}},ja={type:"[",beforeExpr:!0},ka={type:"]"},Z={type:"{",beforeExpr:!0},T={type:"}"},J={type:"(",beforeExpr:!0},F={type:")"},L={type:",",
+beforeExpr:!0},K={type:";",beforeExpr:!0},aa={type:":",beforeExpr:!0},xa={type:"."},ya={type:"?",beforeExpr:!0},za={binop:10,beforeExpr:!0},Aa={isAssign:!0,beforeExpr:!0},U={isAssign:!0,beforeExpr:!0},Gb={postfix:!0,prefix:!0,isUpdate:!0},Xa={prefix:!0,beforeExpr:!0},Va={binop:1,beforeExpr:!0},Wa={binop:2,beforeExpr:!0},Db={binop:3,beforeExpr:!0},Fb={binop:4,beforeExpr:!0},Eb={binop:5,beforeExpr:!0},Kb={binop:6,beforeExpr:!0},Jb={binop:7,beforeExpr:!0},Ib={binop:8,beforeExpr:!0},Hb={binop:9,prefix:!0,
+beforeExpr:!0},Cb={binop:10,beforeExpr:!0};a.tokTypes={bracketL:ja,bracketR:ka,braceL:Z,braceR:T,parenL:J,parenR:F,comma:L,semi:K,colon:aa,dot:xa,question:ya,slash:za,eq:Aa,name:V,eof:pa,num:ba,regexp:Ba,string:da};for(var zb in Ca)a.tokTypes["_"+zb]=Ca[zb];var Mb=d("abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile"),Nb=d("class enum extends super const export import"),
+bb=d("implements interface let package private protected public static yield"),sa=d("eval arguments"),Lb=d("break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this"),Bb=/[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/,Za=RegExp("[\u00aa\u00b5\u00ba\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]"),
+Pb=RegExp("[\u00aa\u00b5\u00ba\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc\u0300-\u036f\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u0620-\u0649\u0672-\u06d3\u06e7-\u06e8\u06fb-\u06fc\u0730-\u074a\u0800-\u0814\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0840-\u0857\u08e4-\u08fe\u0900-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962-\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09d7\u09df-\u09e0\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5f-\u0b60\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2-\u0ce3\u0ce6-\u0cef\u0d02\u0d03\u0d46-\u0d48\u0d57\u0d62-\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e34-\u0e3a\u0e40-\u0e45\u0e50-\u0e59\u0eb4-\u0eb9\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f41-\u0f47\u0f71-\u0f84\u0f86-\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1029\u1040-\u1049\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u170e-\u1710\u1720-\u1730\u1740-\u1750\u1772\u1773\u1780-\u17b2\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1920-\u192b\u1930-\u193b\u1951-\u196d\u19b0-\u19c0\u19c8-\u19c9\u19d0-\u19d9\u1a00-\u1a15\u1a20-\u1a53\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1b46-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1bb0-\u1bb9\u1be6-\u1bf3\u1c00-\u1c22\u1c40-\u1c49\u1c5b-\u1c7d\u1cd0-\u1cd2\u1d00-\u1dbe\u1e01-\u1f15\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2d81-\u2d96\u2de0-\u2dff\u3021-\u3028\u3099\u309a\ua640-\ua66d\ua674-\ua67d\ua69f\ua6f0-\ua6f1\ua7f8-\ua800\ua806\ua80b\ua823-\ua827\ua880-\ua881\ua8b4-\ua8c4\ua8d0-\ua8d9\ua8f3-\ua8f7\ua900-\ua909\ua926-\ua92d\ua930-\ua945\ua980-\ua983\ua9b3-\ua9c0\uaa00-\uaa27\uaa40-\uaa41\uaa4c-\uaa4d\uaa50-\uaa59\uaa7b\uaae0-\uaae9\uaaf2-\uaaf3\uabc0-\uabe1\uabec\uabed\uabf0-\uabf9\ufb20-\ufb28\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f]"),
+na=/[\n\r\u2028\u2029]/,Y=/\r\n|[\n\r\u2028\u2029]/g,la=a.isIdentifierStart=function(a){return 65>a?36===a:91>a?!0:97>a?95===a:123>a?!0:170<=a&&Za.test(String.fromCharCode(a))},ab=a.isIdentifierChar=function(a){return 48>a?36===a:58>a?!0:65>a?!1:91>a?!0:97>a?95===a:123>a?!0:170<=a&&Pb.test(String.fromCharCode(a))},ca,Ia={kind:"loop"},Ob={kind:"switch"}};
+"object"==typeof exports&&"object"==typeof module?mod$$inline_58(exports):"function"==typeof define&&define.amd?define(["exports"],mod$$inline_58):mod$$inline_58(this.acorn||(this.acorn={}));/*
+
+ JavaScript Interpreter
+
+ Copyright 2013 Google Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+var Interpreter=function(a,b){this.ast=acorn.parse(a);this.initFunc_=b;this.paused_=!1;this.UNDEFINED=new Interpreter.Primitive(void 0,this);this.NULL=new Interpreter.Primitive(null,this);this.TRUE=new Interpreter.Primitive(!0,this);this.FALSE=new Interpreter.Primitive(!1,this);this.NUMBER_ZERO=new Interpreter.Primitive(0,this);this.NUMBER_ONE=new Interpreter.Primitive(1,this);this.STRING_EMPTY=new Interpreter.Primitive("",this);var c=this.createScope(this.ast,null);this.TRUE.parent=this.BOOLEAN;
+this.FALSE.parent=this.BOOLEAN;this.NUMBER_ZERO.parent=this.NUMBER;this.NUMBER_ONE.parent=this.NUMBER;this.STRING_EMPTY.parent=this.STRING;this.stateStack=[{node:this.ast,scope:c,thisExpression:c,done:!1}]};
+Interpreter.prototype.appendCode=function(a){var b=this.stateStack[this.stateStack.length-1];if(!b||"Program"!=b.node.type)throw"Expecting original AST to start with a Program node.";a=acorn.parse(a);if(!a||"Program"!=a.type)throw"Expecting new AST to start with a Program node.";for(var c=0,d;d=a.body[c];c++)b.node.body.push(d);b.done=!1};
+Interpreter.prototype.step=function(){var a=this.stateStack[0];if(!a||"Program"==a.node.type&&a.done)return!1;if(this.paused_)return!0;this["step"+a.node.type]();return!0};Interpreter.prototype.run=function(){for(;!this.paused_&&this.step(););return this.paused_};
+Interpreter.prototype.initGlobalScope=function(a){this.setProperty(a,"Infinity",this.createPrimitive(Infinity),!0);this.setProperty(a,"NaN",this.createPrimitive(NaN),!0);this.setProperty(a,"undefined",this.UNDEFINED,!0);this.setProperty(a,"window",a,!0);this.setProperty(a,"self",a,!1);this.initFunction(a);this.initObject(a);a.parent=this.OBJECT;this.initArray(a);this.initNumber(a);this.initString(a);this.initBoolean(a);this.initDate(a);this.initMath(a);this.initRegExp(a);this.initJSON(a);var b=this,
+c;c=function(a){a=a||b.UNDEFINED;return b.createPrimitive(isNaN(a.toNumber()))};this.setProperty(a,"isNaN",this.createNativeFunction(c));c=function(a){a=a||b.UNDEFINED;return b.createPrimitive(isFinite(a.toNumber()))};this.setProperty(a,"isFinite",this.createNativeFunction(c));c=function(a){a=a||b.UNDEFINED;return b.createPrimitive(parseFloat(a.toNumber()))};this.setProperty(a,"parseFloat",this.createNativeFunction(c));c=function(a,c){a=a||b.UNDEFINED;c=c||b.UNDEFINED;return b.createPrimitive(parseInt(a.toString(),
+c.toNumber()))};this.setProperty(a,"parseInt",this.createNativeFunction(c));c=this.createObject(this.FUNCTION);c.eval=!0;this.setProperty(c,"length",this.NUMBER_ONE,!0);this.setProperty(a,"eval",c);for(var d="escape unescape decodeURI decodeURIComponent encodeURI encodeURIComponent".split(" "),f=0;f<d.length;f++)c=function(a){return function(c){c=c||b.UNDEFINED;return b.createPrimitive(a(c.toString()))}}(window[d[f]]),this.setProperty(a,d[f],this.createNativeFunction(c));this.initFunc_&&this.initFunc_(this,
+a)};
+Interpreter.prototype.initFunction=function(a){var b=this,c;c=function(a){for(var c=this.parent==b.FUNCTION?this:b.createObject(b.FUNCTION),e=arguments.length?arguments[arguments.length-1].toString():"",h=[],l=0;l<arguments.length-1;l++)h.push(arguments[l].toString());h=h.join(", ");if(-1!=h.indexOf(")"))throw new SyntaxError("Function arg string contains parenthesis");c.parentScope=b.stateStack[b.stateStack.length-1].scope;e=acorn.parse("$ = function("+h+") {"+e+"};");c.node=e.body[0].expression.right;b.setProperty(c,
+"length",b.createPrimitive(c.node.length),!0);return c};this.FUNCTION=this.createObject(null);this.setProperty(a,"Function",this.FUNCTION);this.FUNCTION.type="function";this.setProperty(this.FUNCTION,"prototype",this.createObject(null));this.FUNCTION.nativeFunc=c;a={type:"FunctionApply_",params:[],id:null,body:null,start:0,end:0};this.setProperty(this.FUNCTION.properties.prototype,"apply",this.createFunction(a,{}),!1,!0);a={type:"FunctionCall_",params:[],id:null,body:null,start:0,end:0};this.setProperty(this.FUNCTION.properties.prototype,
+"call",this.createFunction(a,{}),!1,!0);c=function(){return b.createPrimitive(this.toString())};this.setProperty(this.FUNCTION.properties.prototype,"toString",this.createNativeFunction(c),!1,!0);this.setProperty(this.FUNCTION,"toString",this.createNativeFunction(c),!1,!0);c=function(){return b.createPrimitive(this.valueOf())};this.setProperty(this.FUNCTION.properties.prototype,"valueOf",this.createNativeFunction(c),!1,!0);this.setProperty(this.FUNCTION,"valueOf",this.createNativeFunction(c),!1,!0)};
+Interpreter.prototype.initObject=function(a){var b=this,c;c=function(){var a=this.parent==b.OBJECT?this:b.createObject(b.OBJECT);return a};this.OBJECT=this.createNativeFunction(c);this.setProperty(a,"Object",this.OBJECT);c=function(){return b.createPrimitive(this.toString())};this.setProperty(this.OBJECT.properties.prototype,"toString",this.createNativeFunction(c),!1,!0);c=function(){return b.createPrimitive(this.valueOf())};this.setProperty(this.OBJECT.properties.prototype,"valueOf",this.createNativeFunction(c),
+!1,!0);c=function(a){for(var c in this.properties)if(c==a)return b.TRUE;return b.FALSE};this.setProperty(this.OBJECT.properties.prototype,"hasOwnProperty",this.createNativeFunction(c),!1,!0);c=function(a){var c=b.createObject(b.ARRAY),e=0,h;for(h in a.properties)b.setProperty(c,e,b.createPrimitive(h)),e++;return c};this.setProperty(this.OBJECT,"keys",this.createNativeFunction(c))};
+Interpreter.prototype.initArray=function(a){var b=this,c=function(a,b){var c=a?Math.floor(a.toNumber()):b;isNaN(c)&&(c=b);return c},d;d=function(a){var c=this.parent==b.ARRAY?this:b.createObject(b.ARRAY),d=arguments[0];if(d&&"number"==d.type)isNaN(b.arrayIndex(d))&&b.throwException("Invalid array length"),c.length=d.data;else{for(d=0;d<arguments.length;d++)c.properties[d]=arguments[d];c.length=d}return c};this.ARRAY=this.createNativeFunction(d);this.setProperty(a,"Array",this.ARRAY);d=function(){if(this.length){var a=
+this.properties[this.length-1];delete this.properties[this.length-1];this.length--}else a=b.UNDEFINED;return a};this.setProperty(this.ARRAY.properties.prototype,"pop",this.createNativeFunction(d),!1,!0);d=function(a){for(var c=0;c<arguments.length;c++)this.properties[this.length]=arguments[c],this.length++;return b.createPrimitive(this.length)};this.setProperty(this.ARRAY.properties.prototype,"push",this.createNativeFunction(d),!1,!0);d=function(){if(this.length){for(var a=this.properties[0],c=1;c<
+this.length;c++)this.properties[c-1]=this.properties[c];this.length--;delete this.properties[this.length]}else a=b.UNDEFINED;return a};this.setProperty(this.ARRAY.properties.prototype,"shift",this.createNativeFunction(d),!1,!0);d=function(a){for(var c=this.length-1;0<=c;c--)this.properties[c+arguments.length]=this.properties[c];this.length+=arguments.length;for(c=0;c<arguments.length;c++)this.properties[c]=arguments[c];return b.createPrimitive(this.length)};this.setProperty(this.ARRAY.properties.prototype,
+"unshift",this.createNativeFunction(d),!1,!0);d=function(){for(var a=0;a<this.length/2;a++){var c=this.properties[this.length-a-1];this.properties[this.length-a-1]=this.properties[a];this.properties[a]=c}return b.UNDEFINED};this.setProperty(this.ARRAY.properties.prototype,"reverse",this.createNativeFunction(d),!1,!0);d=function(a,e,d){a=c(a,0);a=0>a?Math.max(this.length+a,0):Math.min(a,this.length);e=c(e,Infinity);e=Math.min(e,this.length-a);for(var l=b.createObject(b.ARRAY),m=a;m<a+e;m++)l.properties[l.length++]=
+this.properties[m],this.properties[m]=this.properties[m+e];for(m=a+e;m<this.length-e;m++)this.properties[m]=this.properties[m+e];for(m=this.length-e;m<this.length;m++)delete this.properties[m];this.length-=e;for(m=this.length-1;m>=a;m--)this.properties[m+arguments.length-2]=this.properties[m];this.length+=arguments.length-2;for(m=2;m<arguments.length;m++)this.properties[a+m-2]=arguments[m];return l};this.setProperty(this.ARRAY.properties.prototype,"splice",this.createNativeFunction(d),!1,!0);d=function(a,
+e){var d=b.createObject(b.ARRAY),l=c(a,0);0>l&&(l=this.length+l);var l=Math.max(0,Math.min(l,this.length)),m=c(e,this.length);0>m&&(m=this.length+m);for(var m=Math.max(0,Math.min(m,this.length)),A=0;l<m;l++){var t=b.getProperty(this,l);b.setProperty(d,A++,t)}return d};this.setProperty(this.ARRAY.properties.prototype,"slice",this.createNativeFunction(d),!1,!0);d=function(a){a=a&&void 0!==a.data?a.toString():void 0;for(var c=[],d=0;d<this.length;d++)c[d]=this.properties[d];return b.createPrimitive(c.join(a))};
+this.setProperty(this.ARRAY.properties.prototype,"join",this.createNativeFunction(d),!1,!0);d=function(a){for(var c=b.createObject(b.ARRAY),d=0,l=0;l<this.length;l++){var m=b.getProperty(this,l);b.setProperty(c,d++,m)}for(l=0;l<arguments.length;l++){var A=arguments[l];if(b.isa(A,b.ARRAY))for(var t=0;t<A.length;t++)m=b.getProperty(A,t),b.setProperty(c,d++,m);else b.setProperty(c,d++,A)}return c};this.setProperty(this.ARRAY.properties.prototype,"concat",this.createNativeFunction(d),!1,!0);d=function(a,
+d){a=a||b.UNDEFINED;var h=c(d,0);0>h&&(h=this.length+h);for(h=Math.max(0,Math.min(h,this.length));h<this.length;h++){var l=b.getProperty(this,h);if(0==b.comp(l,a))return b.createPrimitive(h)}return b.createPrimitive(-1)};this.setProperty(this.ARRAY.properties.prototype,"indexOf",this.createNativeFunction(d),!1,!0);d=function(a,d){a=a||b.UNDEFINED;var h=c(d,this.length);0>h&&(h=this.length+h);for(h=Math.max(0,Math.min(h,this.length));0<=h;h--){var l=b.getProperty(this,h);if(0==b.comp(l,a))return b.createPrimitive(h)}return b.createPrimitive(-1)};
+this.setProperty(this.ARRAY.properties.prototype,"lastIndexOf",this.createNativeFunction(d),!1,!0);d=function(){for(var a=[],c=0;c<this.length;c++)a[c]=this.properties[c];a.sort();for(c=0;c<a.length;c++)b.setProperty(this,c,a[c]);return this};this.setProperty(this.ARRAY.properties.prototype,"sort",this.createNativeFunction(d),!1,!0)};
+Interpreter.prototype.initNumber=function(a){var b=this,c;c=function(a){a=a?a.toNumber():0;return this.parent==b.NUMBER?(this.toBoolean=function(){return!!a},this.toNumber=function(){return a},this.toString=function(){return String(a)},b.UNDEFINED):b.createPrimitive(a)};this.NUMBER=this.createNativeFunction(c);this.setProperty(a,"Number",this.NUMBER);a=["MAX_VALUE","MIN_VALUE","NaN","NEGATIVE_INFINITY","POSITIVE_INFINITY"];for(c=0;c<a.length;c++)this.setProperty(this.NUMBER,a[c],this.createPrimitive(Number[a[c]]));
+c=function(a){a=a?a.toNumber():void 0;var c=this.toNumber();return b.createPrimitive(c.toExponential(a))};this.setProperty(this.NUMBER.properties.prototype,"toExponential",this.createNativeFunction(c),!1,!0);c=function(a){a=a?a.toNumber():void 0;var c=this.toNumber();return b.createPrimitive(c.toFixed(a))};this.setProperty(this.NUMBER.properties.prototype,"toFixed",this.createNativeFunction(c),!1,!0);c=function(a){a=a?a.toNumber():void 0;var c=this.toNumber();return b.createPrimitive(c.toPrecision(a))};
+this.setProperty(this.NUMBER.properties.prototype,"toPrecision",this.createNativeFunction(c),!1,!0);c=function(a){a=a?a.toNumber():10;var c=this.toNumber();return b.createPrimitive(c.toString(a))};this.setProperty(this.NUMBER.properties.prototype,"toString",this.createNativeFunction(c),!1,!0)};
+Interpreter.prototype.initString=function(a){var b=this,c;c=function(a){a=(a||b.UNDEFINED).toString();return this.parent==b.STRING?(this.toBoolean=function(){return!!a},this.toNumber=function(){return Number(a)},this.toString=function(){return a},this.valueOf=function(){return a},this.data=a,b.UNDEFINED):b.createPrimitive(a)};this.STRING=this.createNativeFunction(c);this.setProperty(a,"String",this.STRING);a=["toLowerCase","toUpperCase","toLocaleLowerCase","toLocaleUpperCase"];for(var d=0;d<a.length;d++)c=
+function(a){return function(){return b.createPrimitive(a.apply(this))}}(String.prototype[a[d]]),this.setProperty(this.STRING.properties.prototype,a[d],this.createNativeFunction(c),!1,!0);c=function(){var a=this.toString();return b.createPrimitive(a.replace(/^\s+|\s+$/g,""))};this.setProperty(this.STRING.properties.prototype,"trim",this.createNativeFunction(c),!1,!0);c=function(){var a=this.toString();return b.createPrimitive(a.replace(/^\s+/g,""))};this.setProperty(this.STRING.properties.prototype,
+"trimLeft",this.createNativeFunction(c),!1,!0);c=function(){var a=this.toString();return b.createPrimitive(a.replace(/\s+$/g,""))};this.setProperty(this.STRING.properties.prototype,"trimRight",this.createNativeFunction(c),!1,!0);c=function(a){var c=this.toString();a=(a||b.UNDEFINED).toNumber();return b.createPrimitive(c.charAt(a))};this.setProperty(this.STRING.properties.prototype,"charAt",this.createNativeFunction(c),!1,!0);c=function(a){var c=this.toString();a=(a||b.UNDEFINED).toNumber();return b.createPrimitive(c.charCodeAt(a))};
+this.setProperty(this.STRING.properties.prototype,"charCodeAt",this.createNativeFunction(c),!1,!0);c=function(a,c){var d=this.toString();a=(a||b.UNDEFINED).toString();c=c?c.toNumber():void 0;return b.createPrimitive(d.indexOf(a,c))};this.setProperty(this.STRING.properties.prototype,"indexOf",this.createNativeFunction(c),!1,!0);c=function(a,c){var d=this.toString();a=(a||b.UNDEFINED).toString();c=c?c.toNumber():void 0;return b.createPrimitive(d.lastIndexOf(a,c))};this.setProperty(this.STRING.properties.prototype,
+"lastIndexOf",this.createNativeFunction(c),!1,!0);c=function(a){var c=this.toString();a=(a||b.UNDEFINED).toString();return b.createPrimitive(c.localeCompare(a))};this.setProperty(this.STRING.properties.prototype,"localeCompare",this.createNativeFunction(c),!1,!0);c=function(a,c){var d=this.toString();a=a?b.isa(a,b.REGEXP)?a.data:a.toString():void 0;c=c?c.toNumber():void 0;for(var d=d.split(a,c),l=b.createObject(b.ARRAY),m=0;m<d.length;m++)b.setProperty(l,m,b.createPrimitive(d[m]));return l};this.setProperty(this.STRING.properties.prototype,
+"split",this.createNativeFunction(c),!1,!0);c=function(a,c){var d=this.toString();a=a?a.toNumber():void 0;c=c?c.toNumber():void 0;return b.createPrimitive(d.substring(a,c))};this.setProperty(this.STRING.properties.prototype,"substring",this.createNativeFunction(c),!1,!0);c=function(a,c){var d=this.toString();a=a?a.toNumber():void 0;c=c?c.toNumber():void 0;return b.createPrimitive(d.substr(a,c))};this.setProperty(this.STRING.properties.prototype,"substr",this.createNativeFunction(c),!1,!0);c=function(a){for(var c=
+this.toString(),d=0;d<arguments.length;d++)c+=arguments[d].toString();return b.createPrimitive(c)};this.setProperty(this.STRING.properties.prototype,"concat",this.createNativeFunction(c),!1,!0);c=function(a,c){var d=this.toString();a=a?a.toNumber():void 0;c=c?c.toNumber():void 0;return b.createPrimitive(d.slice(a,c))};this.setProperty(this.STRING.properties.prototype,"slice",this.createNativeFunction(c),!1,!0);c=function(a){var c=this.toString();a=a?a.data:void 0;a=c.match(a);if(null===a)return b.NULL;
+for(var c=b.createObject(b.ARRAY),d=0;d<a.length;d++)b.setProperty(c,d,b.createPrimitive(a[d]));return c};this.setProperty(this.STRING.properties.prototype,"match",this.createNativeFunction(c),!1,!0);c=function(a){var c=this.toString();a=a?a.data:void 0;return b.createPrimitive(c.search(a))};this.setProperty(this.STRING.properties.prototype,"search",this.createNativeFunction(c),!1,!0);c=function(a,c){var d=this.toString();a=(a||b.UNDEFINED).valueOf();c=(c||b.UNDEFINED).toString();return b.createPrimitive(d.replace(a,
+c))};this.setProperty(this.STRING.properties.prototype,"replace",this.createNativeFunction(c),!1,!0)};Interpreter.prototype.initBoolean=function(a){var b=this,c;c=function(a){a=a?a.toBoolean():!1;return this.parent==b.BOOLEAN?(this.toBoolean=function(){return a},this.toNumber=function(){return Number(a)},this.toString=function(){return String(a)},this.valueOf=function(){return a},b.UNDEFINED):b.createPrimitive(a)};this.BOOLEAN=this.createNativeFunction(c);this.setProperty(a,"Boolean",this.BOOLEAN)};
+Interpreter.prototype.initDate=function(a){var b=this,c;c=function(a,c,d,l,m,A,t){var D=this.parent==b.DATE?this:b.createObject(b.DATE),x=a;if(arguments.length)if(1!=arguments.length||"string"!=x.type&&!b.isa(x,b.STRING)){for(var x=[],P=0;P<arguments.length;P++)x[P]=arguments[P]?arguments[P].toNumber():void 0;D.date=new (Function.prototype.bind.apply(Date,x))}else D.date=new Date(x.toString());else D.date=new Date;D.toString=function(){return String(this.date)};D.toNumber=function(){return Number(this.date)};
+D.valueOf=function(){return this.date.valueOf()};return D};this.DATE=this.createNativeFunction(c);this.setProperty(a,"Date",this.DATE);c=function(){return b.createPrimitive((new Date).getTime())};this.setProperty(this.DATE,"now",this.createNativeFunction(c),!1,!0);c=function(a){a=a?a.toString():void 0;return b.createPrimitive(Date.parse(a))};this.setProperty(this.DATE,"parse",this.createNativeFunction(c),!1,!0);c=function(a,c,d,l,m,A,t){for(var D=[],x=0;x<arguments.length;x++)D[x]=arguments[x]?arguments[x].toNumber():
+void 0;return b.createPrimitive(Date.UTC.apply(Date,D))};this.setProperty(this.DATE,"UTC",this.createNativeFunction(c),!1,!0);var d="getDate getDay getFullYear getHours getMilliseconds getMinutes getMonth getSeconds getTime getTimezoneOffset getUTCDate getUTCDay getUTCFullYear getUTCHours getUTCMilliseconds getUTCMinutes getUTCMonth getUTCSeconds getYear".split(" ");for(a=0;a<d.length;a++)c=function(a){return function(){return b.createPrimitive(this.date[a]())}}(d[a]),this.setProperty(this.DATE.properties.prototype,
+d[a],this.createNativeFunction(c),!1,!0);d="setDate setFullYear setHours setMilliseconds setMinutes setMonth setSeconds setTime setUTCDate setUTCFullYear setUTCHours setUTCMilliseconds setUTCMinutes setUTCMonth setUTCSeconds setYear".split(" ");for(a=0;a<d.length;a++)c=function(a){return function(c){for(var d=[],l=0;l<arguments.length;l++)d[l]=arguments[l]?arguments[l].toNumber():void 0;return b.createPrimitive(this.date[a].apply(this.date,d))}}(d[a]),this.setProperty(this.DATE.properties.prototype,
+d[a],this.createNativeFunction(c),!1,!0);d="toDateString toISOString toGMTString toLocaleDateString toLocaleString toLocaleTimeString toTimeString toUTCString".split(" ");for(a=0;a<d.length;a++)c=function(a){return function(){return b.createPrimitive(this.date[a]())}}(d[a]),this.setProperty(this.DATE.properties.prototype,d[a],this.createNativeFunction(c),!1,!0)};
+Interpreter.prototype.initMath=function(a){var b=this,c=this.createObject(this.OBJECT);this.setProperty(a,"Math",c);var d="E LN2 LN10 LOG2E LOG10E PI SQRT1_2 SQRT2".split(" ");for(a=0;a<d.length;a++)this.setProperty(c,d[a],this.createPrimitive(Math[d[a]]));d="abs acos asin atan atan2 ceil cos exp floor log max min pow random round sin sqrt tan".split(" ");for(a=0;a<d.length;a++){var f=function(a){return function(){for(var c=0;c<arguments.length;c++)arguments[c]=arguments[c].toNumber();return b.createPrimitive(a.apply(Math,
+arguments))}}(Math[d[a]]);this.setProperty(c,d[a],this.createNativeFunction(f))}};
+Interpreter.prototype.initRegExp=function(a){var b=this,c;c=function(a,c){var e;e=this.parent==b.REGEXP?this:b.createObject(b.REGEXP);a=a.toString();c=c&&c.toString();b.createRegExp(e,new RegExp(a,c||""));return e};this.REGEXP=this.createNativeFunction(c);this.setProperty(a,"RegExp",this.REGEXP);c=function(){return b.createPrimitive(this.data.toString())};this.setProperty(this.REGEXP.properties.prototype,"toString",this.createNativeFunction(c),!1,!0);c=function(a){a=a.toString();return b.createPrimitive(this.data.test(a))};
+this.setProperty(this.REGEXP.properties.prototype,"test",this.createNativeFunction(c),!1,!0);c=function(a){a=a.toString();this.data.lastIndex=b.getProperty(this,"lastIndex").toNumber();a=this.data.exec(a);b.setProperty(this,"lastIndex",b.createPrimitive(this.data.lastIndex));if(a){for(var c=b.createObject(b.ARRAY),e=0;e<a.length;e++)b.setProperty(c,e,b.createPrimitive(a[e]));b.setProperty(c,"index",b.createPrimitive(a.index));b.setProperty(c,"input",b.createPrimitive(a.input));return c}return b.NULL};
+this.setProperty(this.REGEXP.properties.prototype,"exec",this.createNativeFunction(c),!1,!0)};
+Interpreter.prototype.initJSON=function(a){function b(a){if("object"!==typeof a)return d.createPrimitive(a);var c;if(a instanceof Array){c=d.createObject(d.ARRAY);for(var f=0;f<a.length;f++)d.setProperty(c,f,b(a[f]))}else for(f in c=d.createObject(d.OBJECT),a)d.setProperty(c,f,b(a[f]));return c}function c(a){if(a.isPrimitive)return a.data;var b;if(a.length){b=[];for(var d=0;d<a.length;d++)b[d]=c(a.properties[d])}else for(d in b={},a.properties)b[d]=c(a.properties[d]);return b}var d=this,f=d.createObject(this.OBJECT);
+this.setProperty(a,"JSON",f);a=function(a){return function(c){c=c.data;c=a.call(JSON,c);return b(c)}}(JSON.parse);this.setProperty(f,"parse",this.createNativeFunction(a));a=function(a){return function(b){b=c(b);return d.createPrimitive(a.call(JSON,b))}}(JSON.stringify);this.setProperty(f,"stringify",this.createNativeFunction(a))};Interpreter.prototype.isa=function(a,b){if(a&&b){if(a.parent==b)return!0;if(!a.parent||!a.parent.prototype)return!1}else return!1;return this.isa(a.parent.prototype,b)};
+Interpreter.prototype.comp=function(a,b){if(a.isPrimitive&&"number"==typeof a&&isNaN(a.data)||b.isPrimitive&&"number"==typeof b&&isNaN(b.data)||!a.isPrimitive||!b.isPrimitive)return NaN;a=a.data;b=b.data;return a<b?-1:a>b?1:0};Interpreter.prototype.arrayIndex=function(a){a=Number(a);return!isFinite(a)||a!=Math.floor(a)||0>a?NaN:a};
+Interpreter.Primitive=function(a,b){var c=typeof a;this.data=a;this.type=c;"number"==c?this.parent=b.NUMBER:"string"==c?this.parent=b.STRING:"boolean"==c&&(this.parent=b.BOOLEAN)};Interpreter.Primitive.prototype.data=void 0;Interpreter.Primitive.prototype.type=void 0;Interpreter.Primitive.prototype.parent=null;Interpreter.Primitive.prototype.isPrimitive=!0;Interpreter.Primitive.prototype.toBoolean=function(){return Boolean(this.data)};Interpreter.Primitive.prototype.toNumber=function(){return Number(this.data)};
+Interpreter.Primitive.prototype.toString=function(){return String(this.data)};Interpreter.Primitive.prototype.valueOf=function(){return this.data};Interpreter.prototype.createPrimitive=function(a){return void 0===a?this.UNDEFINED:null===a?this.NULL:!0===a?this.TRUE:!1===a?this.FALSE:0===a?this.NUMBER_ZERO:1===a?this.NUMBER_ONE:""===a?this.STRING_EMPTY:a instanceof RegExp?this.createRegExp(this.createObject(this.REGEXP),a):new Interpreter.Primitive(a,this)};
+Interpreter.prototype.createObject=function(a){a={isPrimitive:!1,type:"object",parent:a,fixed:Object.create(null),nonenumerable:Object.create(null),properties:Object.create(null),toBoolean:function(){return!0},toNumber:function(){return NaN},toString:function(){return"["+this.type+"]"},valueOf:function(){return this}};this.isa(a,this.FUNCTION)&&(a.type="function",this.setProperty(a,"prototype",this.createObject(this.OBJECT||null)));this.isa(a,this.ARRAY)&&(a.length=0,a.toNumber=function(){return 0},
+a.toString=function(){for(var a=[],c=0;c<this.length;c++)a[c]=void 0==this.properties[c]||null==this.properties[c]?"":this.properties[c].toString();return a.join(",")});return a};
+Interpreter.prototype.createRegExp=function(a,b){a.data=b;this.setProperty(a,"lastIndex",this.createPrimitive(a.data.lastIndex),!1,!0);this.setProperty(a,"source",this.createPrimitive(a.data.source),!0,!0);this.setProperty(a,"global",this.createPrimitive(a.data.global),!0,!0);this.setProperty(a,"ignoreCase",this.createPrimitive(a.data.ignoreCase),!0,!0);this.setProperty(a,"multiline",this.createPrimitive(a.data.multiline),!0,!0);a.toString=function(){return String(this.data)};a.valueOf=function(){return this.data};
+return a};Interpreter.prototype.createFunction=function(a,b){var c=this.createObject(this.FUNCTION);c.parentScope=b||this.getScope();c.node=a;this.setProperty(c,"length",this.createPrimitive(c.node.params.length),!0);return c};Interpreter.prototype.createNativeFunction=function(a){var b=this.createObject(this.FUNCTION);b.nativeFunc=a;this.setProperty(b,"length",this.createPrimitive(a.length),!0);return b};
+Interpreter.prototype.getProperty=function(a,b){b=b.toString();if(this.isa(a,this.STRING)){if("length"==b)return this.createPrimitive(a.data.length);var c=this.arrayIndex(b);if(!isNaN(c)&&c<a.data.length)return this.createPrimitive(a.data[c])}else if(this.isa(a,this.ARRAY)&&"length"==b)return this.createPrimitive(a.length);for(;;){if(a.properties&&b in a.properties)return a.properties[b];if(a.parent&&a.parent.properties&&a.parent.properties.prototype)a=a.parent.properties.prototype;else break}return this.UNDEFINED};
+Interpreter.prototype.hasProperty=function(a,b){b=b.toString();if(a.isPrimitive)throw new TypeError("Primitive data type has no properties");if("length"==b&&(this.isa(a,this.STRING)||this.isa(a,this.ARRAY)))return!0;if(this.isa(a,this.STRING)){var c=this.arrayIndex(b);if(!isNaN(c)&&c<a.data.length)return!0}for(;;){if(a.properties&&b in a.properties)return!0;if(a.parent&&a.parent.properties&&a.parent.properties.prototype)a=a.parent.properties.prototype;else break}return!1};
+Interpreter.prototype.setProperty=function(a,b,c,d,f){b=b.toString();if(!a.isPrimitive&&!a.fixed[b]){if(this.isa(a,this.STRING)){var e=this.arrayIndex(b);if("length"==b||!isNaN(e)&&e<a.data.length)return}if(this.isa(a,this.ARRAY)){var h;if("length"==b){b=this.arrayIndex(c.toNumber());isNaN(b)&&this.throwException("Invalid array length");if(b<a.length)for(h in a.properties)h=this.arrayIndex(h),!isNaN(h)&&b<=h&&delete a.properties[h];a.length=b;return}isNaN(h=this.arrayIndex(b))||(a.length=Math.max(a.length,
+h+1))}a.properties[b]=c;d&&(a.fixed[b]=!0);f&&(a.nonenumerable[b]=!0)}};Interpreter.prototype.deleteProperty=function(a,b){b=b.toString();return a.isPrimitive||a.fixed[b]||"length"==b&&this.isa(a,this.ARRAY)?!1:delete a.properties[b]};Interpreter.prototype.getScope=function(){for(var a=0;a<this.stateStack.length;a++)if(this.stateStack[a].scope)return this.stateStack[a].scope;throw"No scope found.";};
+Interpreter.prototype.createScope=function(a,b){var c=this.createObject(null);(c.parentScope=b)||this.initGlobalScope(c);this.populateScope_(a,c);c.strict=!1;if(b&&b.strict)c.strict=!0;else{var d=a.body&&a.body[0];d&&d.expression&&"Literal"==d.expression.type&&"use strict"==d.expression.value&&(c.strict=!0)}return c};Interpreter.prototype.createSpecialScope=function(a,b){if(!a)throw"parentScope required";var c=b||this.createObject(null);c.parentScope=a;c.strict=a.strict;return c};
+Interpreter.prototype.getValueFromScope=function(a){var b=this.getScope();for(a=a.toString();b;){if(this.hasProperty(b,a))return this.getProperty(b,a);b=b.parentScope}this.throwException("Unknown identifier: "+a);return this.UNDEFINED};Interpreter.prototype.setValueToScope=function(a,b){for(var c=this.getScope(),d=c.strict,f=a.toString();c;){if(this.hasProperty(c,f)||!d&&!c.parentScope){this.setProperty(c,f,b);return}c=c.parentScope}this.throwException("Unknown identifier: "+f)};
+Interpreter.prototype.populateScope_=function(a,b){if("VariableDeclaration"==a.type)for(var c=0;c<a.declarations.length;c++)this.setProperty(b,a.declarations[c].id.name,this.UNDEFINED);else{if("FunctionDeclaration"==a.type){this.setProperty(b,a.id.name,this.createFunction(a,b));return}if("FunctionExpression"==a.type)return}var d=this,f;for(f in a){var e=a[f];if(e&&"object"==typeof e)if("number"==typeof e.length&&e.splice)for(c=0;c<e.length;c++){var h=e[c];h.constructor==d.ast.constructor&&d.populateScope_(h,
+b)}else e.constructor==d.ast.constructor&&d.populateScope_(e,b)}};Interpreter.prototype.getValue=function(a){if(a.length){var b=a[0];a=a[1];return this.getProperty(b,a)}return this.getValueFromScope(a)};Interpreter.prototype.setValue=function(a,b){if(a.length){var c=a[0],d=a[1];this.setProperty(c,d,b)}else this.setValueToScope(a,b)};
+Interpreter.prototype.throwException=function(a){do{this.stateStack.shift();var b=this.stateStack[0]}while(b&&"TryStatement"!==b.node.type);if(b)this.stateStack.unshift({node:b.node.handler,throwValue:a});else throw"Unhandled exception: "+a.toString();};
+Interpreter.prototype.stepArrayExpression=function(){var a=this.stateStack[0],b=a.node,c=a.n||0;a.array?this.setProperty(a.array,c-1,a.value):a.array=this.createObject(this.ARRAY);b.elements[c]?(a.n=c+1,this.stateStack.unshift({node:b.elements[c]})):(a.array.length=a.n||0,this.stateStack.shift(),this.stateStack[0].value=a.array)};
+Interpreter.prototype.stepAssignmentExpression=function(){var a=this.stateStack[0],b=a.node;if(a.doneLeft)if(a.doneRight){this.stateStack.shift();var c=a.leftSide,d=a.value;if("="==b.operator)b=d;else{var a=this.getValue(c),f=a.toNumber(),e=d.toNumber();if("+="==b.operator)"string"==a.type||"string"==d.type?(b=a.toString(),a=d.toString()):(b=f,a=e),b+=a;else if("-="==b.operator)b=f-e;else if("*="==b.operator)b=f*e;else if("/="==b.operator)b=f/e;else if("%="==b.operator)b=f%e;else if("<<="==b.operator)b=
+f<<e;else if(">>="==b.operator)b=f>>e;else if(">>>="==b.operator)b=f>>>e;else if("&="==b.operator)b=f&e;else if("^="==b.operator)b=f^e;else if("|="==b.operator)b=f|e;else throw"Unknown assignment expression: "+b.operator;b=this.createPrimitive(b)}this.setValue(c,b);this.stateStack[0].value=b}else a.doneRight=!0,a.leftSide=a.value,this.stateStack.unshift({node:b.right});else a.doneLeft=!0,this.stateStack.unshift({node:b.left,components:!0})};
+Interpreter.prototype.stepBinaryExpression=function(){var a=this.stateStack[0],b=a.node;if(a.doneLeft)if(a.doneRight){this.stateStack.shift();var c=a.leftValue,a=a.value,d=this.comp(c,a);if("=="==b.operator||"!="==b.operator)c=c.isPrimitive&&a.isPrimitive?c.data==a.data:0===d,"!="==b.operator&&(c=!c);else if("==="==b.operator||"!=="==b.operator)c=c.isPrimitive&&a.isPrimitive?c.data===a.data:c===a,"!=="==b.operator&&(c=!c);else if(">"==b.operator)c=1==d;else if(">="==b.operator)c=1==d||0===d;else if("<"==
+b.operator)c=-1==d;else if("<="==b.operator)c=-1==d||0===d;else if("+"==b.operator)"string"==c.type||"string"==a.type?(c=c.toString(),a=a.toString()):(c=c.toNumber(),a=a.toNumber()),c+=a;else if("in"==b.operator)c=this.hasProperty(a,c);else if(c=c.toNumber(),a=a.toNumber(),"-"==b.operator)c-=a;else if("*"==b.operator)c*=a;else if("/"==b.operator)c/=a;else if("%"==b.operator)c%=a;else if("&"==b.operator)c&=a;else if("|"==b.operator)c|=a;else if("^"==b.operator)c^=a;else if("<<"==b.operator)c<<=a;else if(">>"==
+b.operator)c>>=a;else if(">>>"==b.operator)c>>>=a;else throw"Unknown binary operator: "+b.operator;this.stateStack[0].value=this.createPrimitive(c)}else a.doneRight=!0,a.leftValue=a.value,this.stateStack.unshift({node:b.right});else a.doneLeft=!0,this.stateStack.unshift({node:b.left})};Interpreter.prototype.stepBlockStatement=function(){var a=this.stateStack[0],b=a.node,c=a.n_||0;b.body[c]?(a.done=!1,a.n_=c+1,this.stateStack.unshift({node:b.body[c]})):(a.done=!0,"Program"!=a.node.type&&this.stateStack.shift())};
+Interpreter.prototype.stepBreakStatement=function(){var a=this.stateStack.shift(),a=a.node,b=null;a.label&&(b=a.label.name);for(a=this.stateStack.shift();a&&"CallExpression"!=a.node.type&&"NewExpression"!=a.node.type;){if(b?b==a.label:a.isLoop||a.isSwitch)return;a=this.stateStack.shift()}throw new SyntaxError("Illegal break statement");};
+Interpreter.prototype.stepCallExpression=function(){var a=this.stateStack[0],b=a.node;if(a.doneCallee_){if(a.func_)c=a.n_,a.arguments.length!=b.arguments.length&&(a.arguments[c-1]=a.value);else{if("function"==a.value.type)a.func_=a.value;else if(a.member_=a.value[0],a.func_=this.getValue(a.value),!a.func_||"function"!=a.func_.type){this.throwException((a.func_&&a.func_.type)+" is not a function");return}"NewExpression"==a.node.type?(a.funcThis_=this.createObject(a.func_),a.isConstructor_=!0):a.funcThis_=
+a.value.length?a.value[0]:this.stateStack[this.stateStack.length-1].thisExpression;a.arguments=[];var c=0}if(b.arguments[c])a.n_=c+1,this.stateStack.unshift({node:b.arguments[c]});else if(a.doneExec)this.stateStack.shift(),this.stateStack[0].value=a.isConstructor_&&"object"!==a.value.type?a.funcThis_:a.value;else{a.doneExec=!0;if(a.func_.node&&("FunctionApply_"==a.func_.node.type||"FunctionCall_"==a.func_.node.type)){a.funcThis_=a.arguments.shift();if("FunctionApply_"==a.func_.node.type){var d=a.arguments.shift();
+if(d&&this.isa(d,this.ARRAY))for(a.arguments=[],b=0;b<d.length;b++)a.arguments[b]=this.getProperty(d,b);else a.arguments=[]}a.func_=a.member_}if(a.func_.node){c=this.createScope(a.func_.node.body,a.func_.parentScope);for(b=0;b<a.func_.node.params.length;b++){var d=this.createPrimitive(a.func_.node.params[b].name),f=a.arguments.length>b?a.arguments[b]:this.UNDEFINED;this.setProperty(c,d,f)}d=this.createObject(this.ARRAY);for(b=0;b<a.arguments.length;b++)this.setProperty(d,this.createPrimitive(b),a.arguments[b]);
+this.setProperty(c,"arguments",d);b={node:a.func_.node.body,scope:c,thisExpression:a.funcThis_};this.stateStack.unshift(b);a.value=this.UNDEFINED}else if(a.func_.nativeFunc)a.value=a.func_.nativeFunc.apply(a.funcThis_,a.arguments);else if(a.func_.asyncFunc){var e=this,b=function(b){a.value=b||e.UNDEFINED;e.paused_=!1},b=a.arguments.concat(b);a.func_.asyncFunc.apply(a.funcThis_,b);this.paused_=!0}else if(a.func_.eval)(b=a.arguments[0])?b.isPrimitive?(b=new Interpreter(b.toString()),b.stateStack[0].scope.parentScope=
+this.getScope(),a={node:{type:"Eval_"},interpreter:b},this.stateStack.unshift(a)):a.value=b:a.value=this.UNDEFINED;else throw new TypeError("function not a function (huh?)");}}else a.doneCallee_=!0,this.stateStack.unshift({node:b.callee,components:!0})};
+Interpreter.prototype.stepCatchClause=function(){var a=this.stateStack[0],b=a.node;if(a.doneBody)this.stateStack.shift();else{a.doneBody=!0;var c;if(b.param){c=this.createSpecialScope(this.getScope());var d=this.createPrimitive(b.param.name);this.setProperty(c,d,a.throwValue)}this.stateStack.unshift({node:b.body,scope:c})}};
+Interpreter.prototype.stepConditionalExpression=function(){var a=this.stateStack[0];a.done?(this.stateStack.shift(),"ConditionalExpression"==a.node.type&&(this.stateStack[0].value=a.value)):a.test?(a.done=!0,a.value.toBoolean()&&a.node.consequent?this.stateStack.unshift({node:a.node.consequent}):!a.value.toBoolean()&&a.node.alternate&&this.stateStack.unshift({node:a.node.alternate})):(a.test=!0,this.stateStack.unshift({node:a.node.test}))};
+Interpreter.prototype.stepContinueStatement=function(){var a=this.stateStack[0].node,b=null;a.label&&(b=a.label.name);for(a=this.stateStack[0];a&&"CallExpression"!=a.node.type&&"NewExpression"!=a.node.type;){if(a.isLoop&&(!b||b==a.label))return;this.stateStack.shift();a=this.stateStack[0]}throw new SyntaxError("Illegal continue statement");};
+Interpreter.prototype.stepDoWhileStatement=function(){var a=this.stateStack[0];a.isLoop=!0;"DoWhileStatement"==a.node.type&&void 0===a.test&&(a.value=this.TRUE,a.test=!0);a.test?(a.test=!1,a.value.toBoolean()?a.node.body&&this.stateStack.unshift({node:a.node.body}):this.stateStack.shift()):(a.test=!0,this.stateStack.unshift({node:a.node.test}))};Interpreter.prototype.stepEmptyStatement=function(){this.stateStack.shift()};
+Interpreter.prototype.stepEval_=function(){var a=this.stateStack[0];a.interpreter.step()||(this.stateStack.shift(),this.stateStack[0].value=a.interpreter.value||this.UNDEFINED)};Interpreter.prototype.stepExpressionStatement=function(){var a=this.stateStack[0];a.done?(this.stateStack.shift(),this.value=a.value):(a.done=!0,this.stateStack.unshift({node:a.node.expression}))};
+Interpreter.prototype.stepForInStatement=function(){var a=this.stateStack[0];a.isLoop=!0;var b=a.node;if(a.doneVariable_)if(a.doneObject_){"undefined"==typeof a.iterator&&(a.object=a.value,a.iterator=0);var c=null;a:do{var d=a.iterator,f;for(f in a.object.properties)if(!(f in a.object.nonenumerable)){if(0==d){c=f;break a}d--}a.object=a.object.parent&&a.object.parent.properties.prototype;a.iterator=0}while(a.object);a.iterator++;null===c?this.stateStack.shift():(this.setValueToScope(a.variable,this.createPrimitive(c)),
+b.body&&this.stateStack.unshift({node:b.body}))}else a.doneObject_=!0,a.variable=a.value,this.stateStack.unshift({node:b.right});else a.doneVariable_=!0,a=b.left,"VariableDeclaration"==a.type&&(a=a.declarations[0].id),this.stateStack.unshift({node:a,components:!0})};
+Interpreter.prototype.stepForStatement=function(){var a=this.stateStack[0];a.isLoop=!0;var b=a.node,c=a.mode||0;0==c?(a.mode=1,b.init&&this.stateStack.unshift({node:b.init})):1==c?(a.mode=2,b.test&&this.stateStack.unshift({node:b.test})):2==c?(a.mode=3,b.test&&a.value&&!a.value.toBoolean()?this.stateStack.shift():b.body&&this.stateStack.unshift({node:b.body})):3==c&&(a.mode=1,b.update&&this.stateStack.unshift({node:b.update}))};Interpreter.prototype.stepFunctionDeclaration=function(){this.stateStack.shift()};
+Interpreter.prototype.stepFunctionExpression=function(){var a=this.stateStack.shift();this.stateStack[0].value=this.createFunction(a.node)};Interpreter.prototype.stepIdentifier=function(){var a=this.stateStack.shift(),b=this.createPrimitive(a.node.name);this.stateStack[0].value=a.components?b:this.getValueFromScope(b)};Interpreter.prototype.stepIfStatement=Interpreter.prototype.stepConditionalExpression;
+Interpreter.prototype.stepLabeledStatement=function(){var a=this.stateStack.shift();this.stateStack.unshift({node:a.node.body,label:a.node.label.name})};Interpreter.prototype.stepLiteral=function(){var a=this.stateStack.shift();this.stateStack[0].value=this.createPrimitive(a.node.value)};
+Interpreter.prototype.stepLogicalExpression=function(){var a=this.stateStack[0],b=a.node;if("&&"!=b.operator&&"||"!=b.operator)throw"Unknown logical operator: "+b.operator;a.doneLeft_?a.doneRight_?(this.stateStack.shift(),this.stateStack[0].value=a.value):"&&"==b.operator&&!a.value.toBoolean()||"||"==b.operator&&a.value.toBoolean()?(this.stateStack.shift(),this.stateStack[0].value=a.value):(a.doneRight_=!0,this.stateStack.unshift({node:b.right})):(a.doneLeft_=!0,this.stateStack.unshift({node:b.left}))};
+Interpreter.prototype.stepMemberExpression=function(){var a=this.stateStack[0],b=a.node;a.doneObject_?a.doneProperty_?(this.stateStack.shift(),this.stateStack[0].value=a.components?[a.object,a.value]:this.getProperty(a.object,a.value)):(a.doneProperty_=!0,a.object=a.value,this.stateStack.unshift({node:b.property,components:!b.computed})):(a.doneObject_=!0,this.stateStack.unshift({node:b.object}))};Interpreter.prototype.stepNewExpression=Interpreter.prototype.stepCallExpression;
+Interpreter.prototype.stepObjectExpression=function(){var a=this.stateStack[0],b=a.node,c=a.valueToggle,d=a.n||0;a.object?c?a.key=a.value:this.setProperty(a.object,a.key,a.value):a.object=this.createObject(this.OBJECT);b.properties[d]?(c?(a.n=d+1,this.stateStack.unshift({node:b.properties[d].value})):this.stateStack.unshift({node:b.properties[d].key,components:!0}),a.valueToggle=!c):(this.stateStack.shift(),this.stateStack[0].value=a.object)};Interpreter.prototype.stepProgram=Interpreter.prototype.stepBlockStatement;
+Interpreter.prototype.stepReturnStatement=function(){var a=this.stateStack[0],b=a.node;if(b.argument&&!a.done)a.done=!0,this.stateStack.unshift({node:b.argument});else{b=a.value||this.UNDEFINED;do{this.stateStack.shift();if(0==this.stateStack.length)throw new SyntaxError("Illegal return statement");a=this.stateStack[0]}while("CallExpression"!=a.node.type&&"NewExpression"!=a.node.type);a.value=b}};
+Interpreter.prototype.stepSequenceExpression=function(){var a=this.stateStack[0],b=a.node,c=a.n||0;b.expressions[c]?(a.n=c+1,this.stateStack.unshift({node:b.expressions[c]})):(this.stateStack.shift(),this.stateStack[0].value=a.value)};
+Interpreter.prototype.stepSwitchStatement=function(){var a=this.stateStack[0];a.checked=a.checked||[];a.isSwitch=!0;if(a.test){a.switchValue||(a.switchValue=a.value);var b=a.index||0,c=a.node.cases[b];if(c)if(a.done||a.checked[b]||!c.test){if(a.done||!c.test||0==this.comp(a.value,a.switchValue)){a.done=!0;var d=a.n||0;if(c.consequent[d]){this.stateStack.unshift({node:c.consequent[d]});a.n=d+1;return}}a.n=0;a.index=b+1}else a.checked[b]=!0,this.stateStack.unshift({node:c.test});else this.stateStack.shift()}else a.test=
+!0,this.stateStack.unshift({node:a.node.discriminant})};Interpreter.prototype.stepThisExpression=function(){this.stateStack.shift();for(var a=0;a<this.stateStack.length;a++)if(this.stateStack[a].thisExpression){this.stateStack[0].value=this.stateStack[a].thisExpression;return}throw"No this expression found.";};Interpreter.prototype.stepThrowStatement=function(){var a=this.stateStack[0],b=a.node;a.argument?this.throwException(a.value):(a.argument=!0,this.stateStack.unshift({node:b.argument}))};
+Interpreter.prototype.stepTryStatement=function(){var a=this.stateStack[0],b=a.node;a.doneBlock?!a.doneFinalizer&&b.finalizer?(a.doneFinalizer=!0,this.stateStack.unshift({node:b.finalizer})):this.stateStack.shift():(a.doneBlock=!0,this.stateStack.unshift({node:b.block}))};
+Interpreter.prototype.stepUnaryExpression=function(){var a=this.stateStack[0],b=a.node;if(a.done){this.stateStack.shift();if("-"==b.operator)a=-a.value.toNumber();else if("+"==b.operator)a=a.value.toNumber();else if("!"==b.operator)a=!a.value.toBoolean();else if("~"==b.operator)a=~a.value.toNumber();else if("typeof"==b.operator)a=a.value.type;else if("delete"==b.operator)a.value.length?(b=a.value[0],a=a.value[1]):(b=this.getScope(),a=a.value),a=this.deleteProperty(b,a);else if("void"==b.operator)a=
+void 0;else throw"Unknown unary operator: "+b.operator;this.stateStack[0].value=this.createPrimitive(a)}else a.done=!0,a={node:b.argument},"delete"==b.operator&&(a.components=!0),this.stateStack.unshift(a)};
+Interpreter.prototype.stepUpdateExpression=function(){var a=this.stateStack[0],b=a.node;if(a.done){this.stateStack.shift();var a=a.value,c=this.getValue(a).toNumber(),d;if("++"==b.operator)d=this.createPrimitive(c+1);else if("--"==b.operator)d=this.createPrimitive(c-1);else throw"Unknown update expression: "+b.operator;this.setValue(a,d);this.stateStack[0].value=b.prefix?d:this.createPrimitive(c)}else a.done=!0,this.stateStack.unshift({node:b.argument,components:!0})};
+Interpreter.prototype.stepVariableDeclaration=function(){var a=this.stateStack[0],b=a.node,c=a.n||0;b.declarations[c]?(a.n=c+1,this.stateStack.unshift({node:b.declarations[c]})):this.stateStack.shift()};Interpreter.prototype.stepVariableDeclarator=function(){var a=this.stateStack[0],b=a.node;if(b.init&&!a.done)a.done=!0,this.stateStack.unshift({node:b.init});else{if(!this.hasProperty(this,b.id.name)||b.init)a=b.init?a.value:this.UNDEFINED,this.setValue(this.createPrimitive(b.id.name),a);this.stateStack.shift()}};
+Interpreter.prototype.stepWithStatement=function(){var a=this.stateStack[0],b=a.node;a.doneObject?a.doneBody?this.stateStack.shift():(a.doneBody=!0,a=this.createSpecialScope(this.getScope(),a.value),this.stateStack.unshift({node:b.body,scope:a})):(a.doneObject=!0,this.stateStack.unshift({node:b.object}))};Interpreter.prototype.stepWhileStatement=Interpreter.prototype.stepDoWhileStatement;window.Interpreter=Interpreter;Interpreter.prototype.appendCode=Interpreter.prototype.appendCode;
+Interpreter.prototype.step=Interpreter.prototype.step;Interpreter.prototype.run=Interpreter.prototype.run;
diff --git a/blockly/demos/interpreter/icon.png b/blockly/demos/interpreter/icon.png
new file mode 100644
index 0000000..0296283
--- /dev/null
+++ b/blockly/demos/interpreter/icon.png
Binary files differ
diff --git a/blockly/demos/interpreter/index.html b/blockly/demos/interpreter/index.html
new file mode 100644
index 0000000..86b2dee
--- /dev/null
+++ b/blockly/demos/interpreter/index.html
@@ -0,0 +1,200 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Blockly Demo: JS Interpreter</title>
+ <script src="acorn_interpreter.js"></script>
+ <script src="../../blockly_compressed.js"></script>
+ <script src="../../blocks_compressed.js"></script>
+ <script src="../../javascript_compressed.js"></script>
+ <script src="../../msg/js/en.js"></script>
+ <style>
+ body {
+ background-color: #fff;
+ font-family: sans-serif;
+ }
+ h1 {
+ font-weight: normal;
+ font-size: 140%;
+ }
+ </style>
+</head>
+<body>
+ <h1><a href="https://developers.google.com/blockly/">Blockly</a> &gt;
+ <a href="../index.html">Demos</a> &gt; JS Interpreter</h1>
+
+ <p>This is a simple demo of executing code with a sandboxed JavaScript interpreter.</p>
+
+ <p>&rarr; More info on <a href="https://developers.google.com/blockly/guides/configure-blockly/web/running-javascript#js_interpreter">JS Interpreter</a>&hellip;</p>
+
+ <p>
+ <button onclick="parseCode()">Parse JavaScript</button>
+ <button onclick="stepCode()" id="stepButton" disabled="disabled">Step JavaScript</button>
+ </p>
+
+ <div id="blocklyDiv" style="height: 480px; width: 600px;"></div>
+
+ <xml id="toolbox" style="display: none">
+ <category name="Logic">
+ <block type="controls_if"></block>
+ <block type="logic_compare"></block>
+ <block type="logic_operation"></block>
+ <block type="logic_negate"></block>
+ <block type="logic_boolean"></block>
+ </category>
+ <category name="Loops">
+ <block type="controls_repeat_ext">
+ <value name="TIMES">
+ <block type="math_number">
+ <field name="NUM">10</field>
+ </block>
+ </value>
+ </block>
+ <block type="controls_whileUntil"></block>
+ </category>
+ <category name="Math">
+ <block type="math_number"></block>
+ <block type="math_arithmetic"></block>
+ <block type="math_single"></block>
+ </category>
+ <category name="Text">
+ <block type="text"></block>
+ <block type="text_length"></block>
+ <block type="text_print"></block>
+ <block type="text_prompt_ext">
+ <value name="TEXT">
+ <block type="text"></block>
+ </value>
+ </block>
+ </category>
+ <category name="Variables" custom="VARIABLE"></category>
+ <category name="Functions" custom="PROCEDURE"></category>
+ </xml>
+
+ <xml id="startBlocks" style="display: none">
+ <block type="variables_set" inline="true" x="20" y="20">
+ <field name="VAR">n</field>
+ <value name="VALUE">
+ <block type="math_number">
+ <field name="NUM">1</field>
+ </block>
+ </value>
+ <next>
+ <block type="controls_repeat_ext" inline="true">
+ <value name="TIMES">
+ <block type="math_number">
+ <field name="NUM">4</field>
+ </block>
+ </value>
+ <statement name="DO">
+ <block type="variables_set" inline="true">
+ <field name="VAR">n</field>
+ <value name="VALUE">
+ <block type="math_arithmetic" inline="true">
+ <field name="OP">MULTIPLY</field>
+ <value name="A">
+ <block type="variables_get">
+ <field name="VAR">n</field>
+ </block>
+ </value>
+ <value name="B">
+ <block type="math_number">
+ <field name="NUM">2</field>
+ </block>
+ </value>
+ </block>
+ </value>
+ </block>
+ </statement>
+ <next>
+ <block type="text_print" inline="false">
+ <value name="TEXT">
+ <block type="variables_get">
+ <field name="VAR">n</field>
+ </block>
+ </value>
+ </block>
+ </next>
+ </block>
+ </next>
+ </block>
+ </xml>
+
+ <script>
+ var workspace = Blockly.inject('blocklyDiv',
+ {media: '../../media/',
+ toolbox: document.getElementById('toolbox')});
+ Blockly.Xml.domToWorkspace(document.getElementById('startBlocks'),
+ workspace);
+
+ var myInterpreter = null;
+
+ function initApi(interpreter, scope) {
+ // Add an API function for the alert() block.
+ var wrapper = function(text) {
+ text = text ? text.toString() : '';
+ return interpreter.createPrimitive(alert(text));
+ };
+ interpreter.setProperty(scope, 'alert',
+ interpreter.createNativeFunction(wrapper));
+
+ // Add an API function for the prompt() block.
+ var wrapper = function(text) {
+ text = text ? text.toString() : '';
+ return interpreter.createPrimitive(prompt(text));
+ };
+ interpreter.setProperty(scope, 'prompt',
+ interpreter.createNativeFunction(wrapper));
+
+ // Add an API function for highlighting blocks.
+ var wrapper = function(id) {
+ id = id ? id.toString() : '';
+ return interpreter.createPrimitive(highlightBlock(id));
+ };
+ interpreter.setProperty(scope, 'highlightBlock',
+ interpreter.createNativeFunction(wrapper));
+ }
+
+ var highlightPause = false;
+
+ function highlightBlock(id) {
+ workspace.highlightBlock(id);
+ highlightPause = true;
+ }
+
+ function parseCode() {
+ // Generate JavaScript code and parse it.
+ Blockly.JavaScript.STATEMENT_PREFIX = 'highlightBlock(%1);\n';
+ Blockly.JavaScript.addReservedWords('highlightBlock');
+ var code = Blockly.JavaScript.workspaceToCode(workspace);
+ myInterpreter = new Interpreter(code, initApi);
+
+ alert('Ready to execute this code:\n\n' + code);
+ document.getElementById('stepButton').disabled = '';
+ highlightPause = false;
+ workspace.traceOn(true);
+ workspace.highlightBlock(null);
+ }
+
+ function stepCode() {
+ try {
+ var ok = myInterpreter.step();
+ } finally {
+ if (!ok) {
+ // Program complete, no more code to execute.
+ document.getElementById('stepButton').disabled = 'disabled';
+ return;
+ }
+ }
+ if (highlightPause) {
+ // A block has been highlighted. Pause execution here.
+ highlightPause = false;
+ } else {
+ // Keep executing until a highlight statement is reached.
+ stepCode();
+ }
+ }
+ </script>
+
+</body>
+</html>
diff --git a/blockly/demos/maxBlocks/icon.png b/blockly/demos/maxBlocks/icon.png
new file mode 100644
index 0000000..13bf65a
--- /dev/null
+++ b/blockly/demos/maxBlocks/icon.png
Binary files differ
diff --git a/blockly/demos/maxBlocks/index.html b/blockly/demos/maxBlocks/index.html
new file mode 100644
index 0000000..8411201
--- /dev/null
+++ b/blockly/demos/maxBlocks/index.html
@@ -0,0 +1,98 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Blockly Demo: Maximum Block Limit</title>
+ <script src="../../blockly_compressed.js"></script>
+ <script src="../../blocks_compressed.js"></script>
+ <script src="../../msg/js/en.js"></script>
+ <style>
+ body {
+ background-color: #fff;
+ font-family: sans-serif;
+ }
+ h1 {
+ font-weight: normal;
+ font-size: 140%;
+ }
+ #capacity {
+ color: red;
+ }
+ </style>
+</head>
+<body>
+ <h1><a href="https://developers.google.com/blockly/">Blockly</a> &gt;
+ <a href="../index.html">Demos</a> &gt; Maximum Block Limit</h1>
+
+ <p>This is a demo of Blockly which has been restricted to a maximum of
+ five blocks.</p>
+
+ <p><b>You have <span id="capacity"></span> block(s) left.</b></p>
+
+ <div id="blocklyDiv" style="height: 480px; width: 600px;"></div>
+
+ <xml id="toolbox" style="display: none">
+ <category name="Logic">
+ <block type="controls_if"></block>
+ <block type="logic_compare"></block>
+ <block type="logic_operation"></block>
+ <block type="logic_negate"></block>
+ <block type="logic_boolean"></block>
+ </category>
+ <category name="Loops">
+ <block type="controls_repeat_ext">
+ <value name="TIMES">
+ <block type="math_number">
+ <field name="NUM">10</field>
+ </block>
+ </value>
+ </block>
+ <block type="controls_whileUntil"></block>
+ <block type="controls_for">
+ <field name="VAR">i</field>
+ <value name="FROM">
+ <block type="math_number">
+ <field name="NUM">1</field>
+ </block>
+ </value>
+ <value name="TO">
+ <block type="math_number">
+ <field name="NUM">10</field>
+ </block>
+ </value>
+ <value name="BY">
+ <block type="math_number">
+ <field name="NUM">1</field>
+ </block>
+ </value>
+ </block>
+ </category>
+ <category name="Math">
+ <block type="math_number"></block>
+ <block type="math_arithmetic"></block>
+ <block type="math_single"></block>
+ </category>
+ <category name="Text">
+ <block type="text"></block>
+ <block type="text_length"></block>
+ <block type="text_print"></block>
+ </category>
+ </xml>
+
+ <script>
+ var workspace = Blockly.inject('blocklyDiv',
+ {media: '../../media/',
+ maxBlocks: 5,
+ toolbox: document.getElementById('toolbox')});
+
+ function onchange(event) {
+ document.getElementById('capacity').innerHTML =
+ workspace.remainingCapacity();
+ }
+
+ workspace.addChangeListener(onchange);
+ onchange();
+ </script>
+
+</body>
+</html>
diff --git a/blockly/demos/mirror/icon.png b/blockly/demos/mirror/icon.png
new file mode 100644
index 0000000..45e2a9a
--- /dev/null
+++ b/blockly/demos/mirror/icon.png
Binary files differ
diff --git a/blockly/demos/mirror/index.html b/blockly/demos/mirror/index.html
new file mode 100644
index 0000000..0afd276
--- /dev/null
+++ b/blockly/demos/mirror/index.html
@@ -0,0 +1,76 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Blockly Demo: Mirrored Blockly</title>
+ <script src="../../blockly_compressed.js"></script>
+ <script src="../../blocks_compressed.js"></script>
+ <script src="../../msg/js/en.js"></script>
+ <style>
+ body {
+ background-color: #fff;
+ font-family: sans-serif;
+ }
+ h1 {
+ font-weight: normal;
+ font-size: 140%;
+ }
+ </style>
+</head>
+<body>
+ <h1><a href="https://developers.google.com/blockly/">Blockly</a> &gt;
+ <a href="../index.html">Demos</a> &gt; Mirrored Blockly</h1>
+
+ <p>This is a simple demo of a master Blockly that controls a slave Blockly.
+ Open the JavaScript console to see the event passing.</p>
+
+ <p>&rarr; More info on <a href="https://developers.google.com/blockly/guides/configure/web/events">events</a>&hellip;</p>
+
+ <table width="100%">
+ <tr>
+ <td>
+ <div id="masterDiv" style="height: 480px; width: 600px;"></div>
+ </td>
+ <td>
+ <div id="slaveDiv" style="height: 480px; width: 430px;"></div>
+ </td>
+ </tr>
+ </table>
+
+ <xml id="toolbox" style="display: none">
+ <block type="controls_if"></block>
+ <block type="logic_compare"></block>
+ <block type="controls_repeat_ext"></block>
+ <block type="math_number"></block>
+ <block type="math_arithmetic"></block>
+ <block type="text"></block>
+ <block type="text_print"></block>
+ </xml>
+
+ <script>
+ // Inject master workspace.
+ var masterWorkspace = Blockly.inject('masterDiv',
+ {media: '../../media/',
+ toolbox: document.getElementById('toolbox')});
+ // Inject slave workspace.
+ var slaveWorkspace = Blockly.inject('slaveDiv',
+ {media: '../../media/',
+ readOnly: true});
+ // Listen to events on master workspace.
+ masterWorkspace.addChangeListener(mirrorEvent);
+
+ function mirrorEvent(masterEvent) {
+ if (masterEvent.type == Blockly.Events.UI) {
+ return; // Don't mirror UI events.
+ }
+ // Convert event to JSON. This could then be transmitted across the net.
+ var json = masterEvent.toJson();
+ console.log(json);
+ // Convert JSON back into an event, then execute it.
+ var slaveEvent = Blockly.Events.fromJson(json, slaveWorkspace);
+ slaveEvent.run(true);
+ }
+ </script>
+
+</body>
+</html>
diff --git a/blockly/demos/plane/README.txt b/blockly/demos/plane/README.txt
new file mode 100644
index 0000000..6da3fa6
--- /dev/null
+++ b/blockly/demos/plane/README.txt
@@ -0,0 +1,26 @@
+This Blockly demo uses Closure Templates to create a multilingual application.
+Any changes to the template.soy file require a recompile. Here is the command
+to generate a quick English version for debugging:
+
+java -jar soy/SoyToJsSrcCompiler.jar --outputPathFormat generated/en.js --srcs template.soy
+
+To generate a full set of language translations, first extract all the strings
+from template.soy using this command:
+
+java -jar soy/SoyMsgExtractor.jar --outputFile xlf/extracted_msgs.xlf template.soy
+
+This generates xlf/extracted_msgs.xlf, which may then be used by any
+XLIFF-compatible translation console to generate a set of files with the
+translated strings. These should be placed in the xlf directory.
+
+Finally, generate all the language versions wih this command:
+
+java -jar soy/SoyToJsSrcCompiler.jar --locales ar,be-tarask,br,ca,da,de,el,en,es,fa,fr,he,hrx,hu,ia,is,it,ja,ko,ms,nb,nl,pl,pms,pt-br,ro,ru,sc,sv,th,tr,uk,vi,zh-hans,zh-hant --messageFilePathFormat xlf/translated_msgs_{LOCALE}.xlf --outputPathFormat "generated/{LOCALE}.js" template.soy
+
+This is the process that Google uses for maintaining Blockly Games in 40+
+languages. The XLIFF fromat is simple enough that it is trival to write a
+Python script to reformat it into some other format (such as JSON) for
+compatability with other translation consoles.
+
+For more information, see message translation for Closure Templates:
+https://developers.google.com/closure/templates/docs/translation
diff --git a/blockly/demos/plane/blocks.js b/blockly/demos/plane/blocks.js
new file mode 100644
index 0000000..18be29c
--- /dev/null
+++ b/blockly/demos/plane/blocks.js
@@ -0,0 +1,103 @@
+/**
+ * Blockly Demos: Plane Seat Calculator Blocks
+ *
+ * Copyright 2013 Google Inc.
+ * https://developers.google.com/blockly/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @fileoverview Blocks for Blockly's Plane Seat Calculator application.
+ * @author fraser@google.com (Neil Fraser)
+ */
+'use strict';
+
+Blockly.Blocks['plane_set_seats'] = {
+ // Block seat variable setter.
+ init: function() {
+ this.setHelpUrl(Blockly.Msg.VARIABLES_SET_HELPURL);
+ this.setColour(330);
+ this.appendValueInput('VALUE')
+ .appendField(Plane.getMsg('Plane_setSeats'));
+ this.setTooltip(Blockly.Msg.VARIABLES_SET_TOOLTIP);
+ this.setDeletable(false);
+ }
+};
+
+Blockly.JavaScript['plane_set_seats'] = function(block) {
+ // Generate JavaScript for seat variable setter.
+ var argument0 = Blockly.JavaScript.valueToCode(block, 'VALUE',
+ Blockly.JavaScript.ORDER_ASSIGNMENT) || 'NaN';
+ return argument0 + ';';
+};
+
+Blockly.Blocks['plane_get_rows'] = {
+ // Block for row variable getter.
+ init: function() {
+ this.setHelpUrl(Blockly.Msg.VARIABLES_GET_HELPURL);
+ this.setColour(330);
+ this.appendDummyInput()
+ .appendField(Plane.getMsg('Plane_getRows'), 'title');
+ this.setOutput(true, 'Number');
+ },
+ customUpdate: function() {
+ this.setFieldValue(
+ Plane.getMsg('Plane_getRows').replace('%1', Plane.rows1st), 'title');
+ }
+};
+
+Blockly.JavaScript['plane_get_rows'] = function(block) {
+ // Generate JavaScript for row variable getter.
+ return ['Plane.rows1st', Blockly.JavaScript.ORDER_MEMBER];
+};
+
+Blockly.Blocks['plane_get_rows1st'] = {
+ // Block for first class row variable getter.
+ init: function() {
+ this.setHelpUrl(Blockly.Msg.VARIABLES_GET_HELPURL);
+ this.setColour(330);
+ this.appendDummyInput()
+ .appendField(Plane.getMsg('Plane_getRows1'), 'title');
+ this.setOutput(true, 'Number');
+ },
+ customUpdate: function() {
+ this.setFieldValue(
+ Plane.getMsg('Plane_getRows1').replace('%1', Plane.rows1st), 'title');
+ }
+};
+
+Blockly.JavaScript['plane_get_rows1st'] = function(block) {
+ // Generate JavaScript for first class row variable getter.
+ return ['Plane.rows1st', Blockly.JavaScript.ORDER_MEMBER];
+};
+
+Blockly.Blocks['plane_get_rows2nd'] = {
+ // Block for second class row variable getter.
+ init: function() {
+ this.setHelpUrl(Blockly.Msg.VARIABLES_GET_HELPURL);
+ this.setColour(330);
+ this.appendDummyInput()
+ .appendField(Plane.getMsg('Plane_getRows2'), 'title');
+ this.setOutput(true, 'Number');
+ },
+ customUpdate: function() {
+ this.setFieldValue(
+ Plane.getMsg('Plane_getRows2').replace('%1', Plane.rows2nd), 'title');
+ }
+};
+
+Blockly.JavaScript['plane_get_rows2nd'] = function(block) {
+ // Generate JavaScript for second class row variable getter.
+ return ['Plane.rows2nd', Blockly.JavaScript.ORDER_MEMBER];
+};
diff --git a/blockly/demos/plane/generated/ar.js b/blockly/demos/plane/generated/ar.js
new file mode 100644
index 0000000..1310949
--- /dev/null
+++ b/blockly/demos/plane/generated/ar.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">الصفوف: %1</span><span id="Plane_getRows">الصفوف (%1)</span><span id="Plane_rows1">صفوف الطبقة الأولى: %1</span><span id="Plane_getRows1">صفوف الطبقة الأولى (%1)</span><span id="Plane_rows2">صفوف الفئة الثانية: %1</span><span id="Plane_getRows2">صفوف الفئة الثانية: (%1)</span><span id="Plane_seats">المقاعد: %1</span><span id="Plane_placeholder">؟</span><span id="Plane_setSeats">المقاعد =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">آلة حاسبة لمقعد الطائرة</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'هنالك طائرة تحتوي على عدد من صفوف مقاعد الركاب. كل صف يحتوي على أربعة مقاعد.';
+ break;
+ case 2:
+ output += 'طائرة بمقعدين في مقطورة الطيّار (للطيار ومساعده) وعدد من الصفوف يحتوي كل صف على أربعة مقاعد.';
+ break;
+ case 3:
+ output += 'طائرة بمقعدين في مقطورة الطيّار (للطيار ومساعده) وعدد من المقاعد في صفوف الدرجة الأولى والثانية. كل صف من صفوف الدرجة الأولى يحتوي على أربعة مقاعد. ويحتوي كل صف في الدرجة الثانية على خمسة مقاعد.';
+ break;
+ }
+ output += '</p><p>لبناء صيغة (أدناه) تقوم بحساب إجمالي عدد المقاعد في الطائرة عند تغيير الصفوف (أعلاه).</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/be-tarask.js b/blockly/demos/plane/generated/be-tarask.js
new file mode 100644
index 0000000..ba60f45
--- /dev/null
+++ b/blockly/demos/plane/generated/be-tarask.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">Радкоў: %1</span><span id="Plane_getRows">радкоў (%1)</span><span id="Plane_rows1">Радкі першага клясу: %1</span><span id="Plane_getRows1">радкі першага клясу (%1)</span><span id="Plane_rows2">Радкі другога клясу: %1</span><span id="Plane_getRows2">радкі другога клясу (%1)</span><span id="Plane_seats">Месцаў: %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">месцаў =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">Калькулятар месцаў у самалёце</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'Самалёт мае некалькі шэрагаў пасажырскіх сядзеньняў. Кожная шэраг утрымлівае чатыры месцы.';
+ break;
+ case 2:
+ output += 'Самалёт мае два месцы ў кабіне экіпажа (пілот і другі пілот), і некалькі шэрагаў пасажырскіх сядзеньняў. Кожны шэраг утрымлівае чатыры месцы.';
+ break;
+ case 3:
+ output += 'Самалёт мае два месцы ў кабіне экіпажа (пілот і другі пілот), і некалькі пасажырскіх шэрагаў месцаў 1-га кляса і 2-га кляса. Кожны шэраг 1-га кляса утрымлівае чатыры месцы. Кожны шэраг 2-га кляса ўтрымлівае пяць месцаў.';
+ break;
+ }
+ output += '</p><p>Пабудаваць формулу (ніжэй), якая падлічвае агульную колькасьць месцаў у самалёце пры зьмене радоў (гл. вышэй).</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/br.js b/blockly/demos/plane/generated/br.js
new file mode 100644
index 0000000..84c2fae
--- /dev/null
+++ b/blockly/demos/plane/generated/br.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">Renkennadoù : %1</span><span id="Plane_getRows">renkennadoù (%1)</span><span id="Plane_rows1">Renkennadoù kentañ klas : %1</span><span id="Plane_getRows1">Renkennadoù kentañ klas (%1)</span><span id="Plane_rows2">Renkennadoù eil klas : %1</span><span id="Plane_getRows2">Renkennadoù eil klas (%1)</span><span id="Plane_seats">Azezennoù : %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">azezennoù =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">Jederez azezenn nijerez</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'Un nijerez he deus un toullad renkennadoù azezennoù evit ar veajourien. Peder azezenn a zo e pep renkennad.';
+ break;
+ case 2:
+ output += 'En un nijerez ez eus div azezenn el logell leviañ(evit al loman hag an eil loman), hag ur toullad renkennadoù azezennoù evit an dremenidi. Peder azezenn zo e pep renkennad.';
+ break;
+ case 3:
+ output += 'En un nijerez ez eus div azezenn el logell leviañ(evit al loman hag an eil loman), hag un toullad renkennadoù azezennoù tremenidi kentañ hag eil klas. Peder azezenn zo e pep renkennad kentañ klas. Pemp azezenn zo e pemp renkennad eil klas.';
+ break;
+ }
+ output += '</p><p>Sevel ur formulenn (amañ dindan) evit jediñ an niver a azezennoù en holl en nijerez pa vez kemmet an niver a renkennadoù (amañ a-us).</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/ca.js b/blockly/demos/plane/generated/ca.js
new file mode 100644
index 0000000..0b45f3e
--- /dev/null
+++ b/blockly/demos/plane/generated/ca.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">Files: %1</span><span id="Plane_getRows">files (%1)</span><span id="Plane_rows1">files de primera classe: %1</span><span id="Plane_getRows1">files de primera classe (%1)</span><span id="Plane_rows2">files de segona classe: %1</span><span id="Plane_getRows2">files de segona classe (%1)</span><span id="Plane_seats">Seients: %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">seients =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">Calculadora de seients d\'avió</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'Un avió té un nombre de files de seients de passatgers. Cada fila conté quatre seients.';
+ break;
+ case 2:
+ output += 'Un avió té dos seients en la cabina de vol (pel pilot i pel copilot) i un nombre de files de seients de passatgers. Cada fila conté quatre seients.';
+ break;
+ case 3:
+ output += 'Un avió té dos seients en la cabina de vol (pel pilot i copilot) i un nombre de files per seients de passatgers de primera classe i de segona classe. Cada fila de primera classe conté quatre seients. Cada fila de segona classe conté cinc seients.';
+ break;
+ }
+ output += '</p><p>Construïu una fórmula (a sota) que calculi el nombre total de seients de l\'avió a mida que canviïn les files (a dalt).</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/da.js b/blockly/demos/plane/generated/da.js
new file mode 100644
index 0000000..2c79650
--- /dev/null
+++ b/blockly/demos/plane/generated/da.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">Rækker: %1</span><span id="Plane_getRows">rækker (%1)</span><span id="Plane_rows1">1. klasse rækker: %1</span><span id="Plane_getRows1">1. klasse rækker (%1)</span><span id="Plane_rows2">2. klasse rækker: %1</span><span id="Plane_getRows2">2. klasse rækker (%1)</span><span id="Plane_seats">Sæder: %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">sæder =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">Flysædelommeregner</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'Et fly har et antal rækker af passagersæder. Hver række indeholder fire sæder.';
+ break;
+ case 2:
+ output += 'Et fly har to pladser i cockpittet (til pilot og med-pilot), og et antal rækker af passagersæder. Hver række indeholder fire sæder.';
+ break;
+ case 3:
+ output += 'Et fly har to pladser i cockpittet (til pilot og med-pilot), og et antal rækker af 1. klasses og 2. klasses passagersæder. Hver 1. klasses række indeholder fire sæder. Hver 2. klasses række indeholder fem sæder.';
+ break;
+ }
+ output += '</p><p>Opbyg en formel (nedenfor), der beregner det samlede antal pladser på flyet, hvis antal rækker ændres (ovenfor).</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/de.js b/blockly/demos/plane/generated/de.js
new file mode 100644
index 0000000..d28d318
--- /dev/null
+++ b/blockly/demos/plane/generated/de.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">Reihen: %1</span><span id="Plane_getRows">Reihen (%1)</span><span id="Plane_rows1">Reihen der 1. Klasse: %1</span><span id="Plane_getRows1">Reihen der 1. Klasse (%1)</span><span id="Plane_rows2">Reihen der 2. Klasse: %1</span><span id="Plane_getRows2">Reihen der 2. Klasse (%1)</span><span id="Plane_seats">Sitze: %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">Sitze =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">Flugzeugsitzrechner</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'Ein Flugzeug hat eine Anzahl an Reihen mit Passagiersitzen. Jede Reihe enthält vier Sitze.';
+ break;
+ case 2:
+ output += 'Ein Flugzeug hat zwei Sitze im Pilotenstand (für den Piloten und Co-Piloten) und eine Anzahl an Reihen mit Passagiersitzen. Jede Reihe enthält vier Sitze.';
+ break;
+ case 3:
+ output += 'Ein Flugzeug hat zwei Sitze im Pilotenstand (für den Piloten und Co-Piloten) und eine Anzahl an Reihen mit Passagiersitzen der 1. und 2. Klasse. Jede 1.-Klasse-Reihe enthält vier Sitze. Jede 2.-Klasse-Reihe enthält fünf Sitze.';
+ break;
+ }
+ output += '</p><p>Erstelle eine Formel (unten), die die gesamte Anzahl an Sitzen im Flugzeug berechnet, wenn die Reihen (oben) geändert werden.</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/el.js b/blockly/demos/plane/generated/el.js
new file mode 100644
index 0000000..f8219c8
--- /dev/null
+++ b/blockly/demos/plane/generated/el.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">Σειρές: %1</span><span id="Plane_getRows">σειρές (%1)</span><span id="Plane_rows1">Σειρές 1ης θέσης: %1</span><span id="Plane_getRows1">Σειρές 1ης θέσης (%1)</span><span id="Plane_rows2">Σειρές 2ης θέσης: %1</span><span id="Plane_getRows2">Σειρές 2ης θέσης (%1)</span><span id="Plane_seats">Καθίσματα: %1</span><span id="Plane_placeholder">;</span><span id="Plane_setSeats">καθίσματα =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">Υπολογισμός Θέσεων Σε Αεροπλάνο</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'Ένα αεροπλάνο έχει έναν συγκεκριμένο αριθμό σειρών καθισμάτων επιβατών. Κάθε σειρά έχει τέσσερα καθίσματα.';
+ break;
+ case 2:
+ output += 'Ένα αεροπλάνο έχει δύο καθίσματα στον θάλαμο διακυβέρνησης (για τον κυβερνήτη και τον συγκυβερνήτη), καθώς και έναν αριθμό από σειρές καθισμάτων επιβατών. Κάθε σειρά έχει τέσσερα καθίσματα.';
+ break;
+ case 3:
+ output += 'Ένα αεροπλάνο έχει δύο καθίσματα στον θάλαμο διακυβέρνησης (για τον κυβερνήτη και τον συγκυβερνήτη), καθώς και έναν αριθμό σειρών καθισμάτων για την 1η και 2η θέση. Κάθε σειρά της 1ης θέσης έχει τέσσερα καθίσματα και κάθε σειρά της 2ης θέσης έχει πέντε καθίσματα.';
+ break;
+ }
+ output += '</p><p>Φτιάξε έναν τύπο (κάτω) που θα υπολογίζει τον συνολικό αριθμό καθισμάτων του αεροπλάνου καθώς αλλάζουν οι σειρές (πάνω).</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/en.js b/blockly/demos/plane/generated/en.js
new file mode 100644
index 0000000..1cbfc40
--- /dev/null
+++ b/blockly/demos/plane/generated/en.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">Rows: %1</span><span id="Plane_getRows">rows (%1)</span><span id="Plane_rows1">1st class rows: %1</span><span id="Plane_getRows1">1st class rows (%1)</span><span id="Plane_rows2">2nd class rows: %1</span><span id="Plane_getRows2">2nd class rows (%1)</span><span id="Plane_seats">Seats: %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">seats =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">Plane Seat Calculator</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'An airplane has a number of rows of passenger seats. Each row contains four seats.';
+ break;
+ case 2:
+ output += 'An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.';
+ break;
+ case 3:
+ output += 'An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.';
+ break;
+ }
+ output += '</p><p>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/es.js b/blockly/demos/plane/generated/es.js
new file mode 100644
index 0000000..0a3b781
--- /dev/null
+++ b/blockly/demos/plane/generated/es.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">Filas: %1</span><span id="Plane_getRows">filas (%1)</span><span id="Plane_rows1">Filas de primera clase: %1</span><span id="Plane_getRows1">Filas de primera clase: (%1)</span><span id="Plane_rows2">Filas de segunda clase: %1</span><span id="Plane_getRows2">Filas de segunda clase: (%1)</span><span id="Plane_seats">Asientos: %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">asientos =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">Calculadora de asientos de avión</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'Un avión  tiene un número de filas de asientos de pasajeros. Cada fila contiene cuatro asientos.';
+ break;
+ case 2:
+ output += 'Un avión tiene dos asientos en la cabina de vuelo (para el piloto y co-piloto), y un número de filas de asientos de pasajeros. Cada fila contiene cuatro asientos.';
+ break;
+ case 3:
+ output += 'Un avión tiene dos asientos en la cabina de vuelo (para el piloto y co-piloto), y un número de filas de asientos para pasajeros de primera y segunda clase. Cada fila de la primera clase contiene cuatro asientos. Cada fila de la segunda clase contiene cinco asientos.';
+ break;
+ }
+ output += '</p><p>Construir una fórmula (abajo) que calcule el número total de asientos en el avión cuando las filas sean cambiadas (arriba).</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/et.js b/blockly/demos/plane/generated/et.js
new file mode 100644
index 0000000..069c7cb
--- /dev/null
+++ b/blockly/demos/plane/generated/et.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">Ridu: %1</span><span id="Plane_getRows">rows (%1)</span><span id="Plane_rows1">1. klassi ridu: %1</span><span id="Plane_getRows1">1. klassi ridu (%1)</span><span id="Plane_rows2">2. klassi ridu: %1</span><span id="Plane_getRows2">2. klassi ridu (%1)</span><span id="Plane_seats">Istmeid: %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">istmete arv =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">Lennukiistmete kalkulaator</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'Lennukis on reisijate istmed mitmes reas. Igas reas on neli istet.';
+ break;
+ case 2:
+ output += 'Lennuki kokpitis on kaks istet (üks kummalegi piloodile) ja mingi arv istemridu reisijatele. Igas reas on neli istet.';
+ break;
+ case 3:
+ output += 'Lennuki kokpitis on kaks istet (üks kummalegi piloodile), mingi arv ridu 1. klassi reisijatele ja mingi arv ridu 2. klassi reisijatele. Igas 1. klassi reas on neli istet, igas 2. klassi reas viis istet.';
+ break;
+ }
+ output += '</p><p>Ehita plokkidest valem, mis arvutab istmete arvu lennukis õigesti sõltumata ridade arvust (seda saad muuta lennuki juures oleva liuguriga).</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/fa.js b/blockly/demos/plane/generated/fa.js
new file mode 100644
index 0000000..8f31707
--- /dev/null
+++ b/blockly/demos/plane/generated/fa.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">ردیف: %1</span><span id="Plane_getRows">ردیف\u200Cها (%1)</span><span id="Plane_rows1">اولین ردیف کلاس: %1</span><span id="Plane_getRows1">اولین کلاس ردیف\u200Cها (%1)</span><span id="Plane_rows2">دومین کلاس ردیف: %1</span><span id="Plane_getRows2">دومین کلاس ردیف\u200Cها (%1)</span><span id="Plane_seats">صندلی\u200Cها: %1</span><span id="Plane_placeholder">؟</span><span id="Plane_setSeats">صندلی\u200Cها =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">محاسبه\u200Cگر صندلی\u200Cهای هواپیما</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'یک هواپیما تعداد از صندلی\u200Cهای مسافرین را دارد. هر ردیف شمال چهار صندلی است.';
+ break;
+ case 2:
+ output += 'یک هواپیما دو صندلی در عرشهٔ پرواز دارد (برای خلبان و کمک خلبان) و تعدادی صندلی مسافرین. هر ردیف شامل چهار صندلی است.';
+ break;
+ case 3:
+ output += 'یک هواپیما دو صندلی در کابین خلبان دارد (برای خلبان و کمک خلبان) و تهداد از صندلی\u200Cها مسافرین درجه یک و درجه دو. هر ردیف درجه یک شامل چهار صندلی است. هر ردیف درجه دو شامل پنج صندلی است.';
+ break;
+ }
+ output += '</p><p>یک فرمول بسازید (پایین) که تعداد کل صندلی\u200Cهای هواپیما با تغییر ردیف را حساب کند (بالا).</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/fr.js b/blockly/demos/plane/generated/fr.js
new file mode 100644
index 0000000..29b17e9
--- /dev/null
+++ b/blockly/demos/plane/generated/fr.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">Rangées : %1</span><span id="Plane_getRows">rangées (%1)</span><span id="Plane_rows1">rangées de première classe : %1</span><span id="Plane_getRows1">rangées de première classe (%1)</span><span id="Plane_rows2">rangées de seconde classe : %1</span><span id="Plane_getRows2">rangées de seconde classe (%1)</span><span id="Plane_seats">Sièges : %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">sièges =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">Calculateur de sièges d’avion</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'Un avion a un nombre de rangées de sièges passager. Chaque rangée contient quatre sièges.';
+ break;
+ case 2:
+ output += 'Un avion a deux sièges dans le poste de pilotage (pour le pilote et le copilote), et un certain nombre de rangées de sièges passager. Chaque rangée contient quatre sièges.';
+ break;
+ case 3:
+ output += 'Un avion a deux sièges dans la cabine de pilotage (pour le pilote et le copilote), et un certain nombre de rangées de sièges passager de première et seconde classes. Chaque rangée de première classe contient quatre sièges. Chaque rangée de seconde classe contient cinq sièges.';
+ break;
+ }
+ output += '</p><p>Construire une formule (ci-dessous) qui calcule le nombre total de sièges dans l’avion quand le nombre de rangées est modifié (ci-dessus).</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/he.js b/blockly/demos/plane/generated/he.js
new file mode 100644
index 0000000..40d73a5
--- /dev/null
+++ b/blockly/demos/plane/generated/he.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">שורות: %1</span><span id="Plane_getRows">שורות (%1)</span><span id="Plane_rows1">שורות במחלקה ראשונה: %1</span><span id="Plane_getRows1">שורות במחלקה ראשונה (%1)</span><span id="Plane_rows2">שורות במחלקה שנייה: %1</span><span id="Plane_getRows2">שורות במחלקה שנייה: (%1)</span><span id="Plane_seats">מושבים: %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">מושבים =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">מחשבון מושב במטוס</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'במטוס יש מספר שורות עם מושבי נוסעים. בכל שורה יש ארבעה מושבים.';
+ break;
+ case 2:
+ output += 'במטוס יש שני מושבים עבור הצוות (בשביל הטייס וטייס המשנה), ומספר שורות עם מושבי נוסעים. בכל שורה יש ארבעה מושבים.';
+ break;
+ case 3:
+ output += 'במטוס יש שני מושבים עבור הצוות (בשביל הטייס וטייס המשנה), ומספר שורות מושבים במחלקת הנוסעים הראשונה ובמחלקת הנוסעים השנייה. כל שורה במחלקה הראשונה מכילה ארבעה מושבים. כל שורה במחלקה השנייה מכילה חמישה מושבים.';
+ break;
+ }
+ output += '</p><p>בנה נוסחה (למטה) אשר תחשב את סך כל המושבים במטוס בהתאם לשינוי מספר השורות (למעלה).</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/hrx.js b/blockly/demos/plane/generated/hrx.js
new file mode 100644
index 0000000..6e35614
--- /dev/null
+++ b/blockly/demos/plane/generated/hrx.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">Reihe: %1</span><span id="Plane_getRows">Reihe (%1)</span><span id="Plane_rows1">Reihe von der 1. Klasse: %1</span><span id="Plane_getRows1">Reihe von der 1. Klasse (%1)</span><span id="Plane_rows2">Reihe von der 2. Klasse: %1</span><span id="Plane_getRows2">Reihe von der 2. Klasse (%1)</span><span id="Plane_seats">Sitz: %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">Sitze =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">Fluchzeichsitzrechner</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'En Fluchzeich hot en Oonzohl an Reihe mit Passagiersitze. Jede Reih enthält vier Sitze.';
+ break;
+ case 2:
+ output += 'En Fluchzeich hot zwooi Sitze im Pilotestand (für den Pilot und Co-Pilot) und en Oonzohl an Reihe mit Passagiersitze. Jede Reih enthält vier Sitze.';
+ break;
+ case 3:
+ output += 'En Fluchzeich hot zwooi Sitze im Pilotstand (für den Pilot und Co-Pilot) und en Oonzohl an Reihe mit Passagiersitze der 1. und 2. Klasse. Jede 1.-Klasse-Reih enthält vier Sitze. Jede 2.-Klasse-Reih enthält fünf Sitze.';
+ break;
+ }
+ output += '</p><p>Erstell en Formel (unne), die die gesamte Oonzohl an Sitze im Fluchzeich berechnet, wenn die Reihe (uwe) geännert sin.</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/hu.js b/blockly/demos/plane/generated/hu.js
new file mode 100644
index 0000000..67181e7
--- /dev/null
+++ b/blockly/demos/plane/generated/hu.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">Sorok száma: %1</span><span id="Plane_getRows">Sorok száma (%1)</span><span id="Plane_rows1">1. osztály: %1 sor</span><span id="Plane_getRows1">1. osztály sorai (%1)</span><span id="Plane_rows2">2. osztály: %1 sor</span><span id="Plane_getRows2">2. osztály sorai (%1)</span><span id="Plane_seats">Ülések száma összesen: %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">Ülések száma =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">Repülőgép alkalmazás</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'Egy repülőgépen az utasok több sorban ülnek az utastérben. Az utastér minden sorában négy szék van.';
+ break;
+ case 2:
+ output += 'Egy repülőgépnek 2 ülése van a pilótafülkében (a pilótának és a másodpilótának), az utasok több sorban ülnek az utastérben. Az utastér minden sorában négy szék van.';
+ break;
+ case 3:
+ output += 'Egy repülőgépnek 2 ülése van a pilótafülkében (a pilótának és a másodpilótának), az utasok 1. és 2. osztályon utazhatnak. Az 1. osztályon négy szék van egy sorban. A 2. osztályon öt szék van egy sorban.';
+ break;
+ }
+ output += '</p><p>Készítsd el a képletet (lent) amivel kiszámolható, hogy hány ülés van összesen a repülőgépen annak függvényében, ahogy (fent) állítod a sorok számát.</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/ia.js b/blockly/demos/plane/generated/ia.js
new file mode 100644
index 0000000..50b6dc8
--- /dev/null
+++ b/blockly/demos/plane/generated/ia.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">Filas: %1</span><span id="Plane_getRows">filas (%1)</span><span id="Plane_rows1">Filas de prime classe: %1</span><span id="Plane_getRows1">filas de prime classe (%1)</span><span id="Plane_rows2">Filas de secunde classe: %1</span><span id="Plane_getRows2">filas de secunde classe (%1)</span><span id="Plane_seats">Sedes: %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">sedes =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">Calculator de sedias de avion</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'Un avion ha un numero de filas de sedes pro passageros. Cata fila contine quatro sedes.';
+ break;
+ case 2:
+ output += 'Un avion ha duo sedes in le cabina (pro le pilota e le copilota) e un numero de filas de sedes pro passageros. Cata fila contine quatro sedes.';
+ break;
+ case 3:
+ output += 'Un avion ha duo sedes in le cabina (pro le pilota e le copilota) e un numero de filas de sedes pro passageros del prime classe e del secunde classes. Cata fila del prime classe contine quatro sedes. Cata fila del secunde classe contine cinque sedes.';
+ break;
+ }
+ output += '</p><p>Construe un formula (ci infra) que calcula le numero total de sedes in le avion quando le numero de filas es cambiate (ci supra).</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/is.js b/blockly/demos/plane/generated/is.js
new file mode 100644
index 0000000..e221c97
--- /dev/null
+++ b/blockly/demos/plane/generated/is.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">Raðir: %1</span><span id="Plane_getRows">raðir (%1)</span><span id="Plane_rows1">Raðir 1. farrými: %1</span><span id="Plane_getRows1">raðir 1. farrými (%1)</span><span id="Plane_rows2">Raðir 2. farrými: %1</span><span id="Plane_getRows2">raðir 2. farrými (%1)</span><span id="Plane_seats">Sæti: %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">sæti =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">Flugsætareiknir</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'Flugvél er með einhvern fjölda sætaraða fyrir farþega. Í hverri röð eru fjögur sæti.';
+ break;
+ case 2:
+ output += 'Flugvél er með tvö sæti í stjórnklefa (fyrir flugmanninn og aðstoðarflugmanninn) og einhvern fjölda sætaraða fyrir farþega. Hver sætaröð hefur fjögur sæti.';
+ break;
+ case 3:
+ output += 'Flugvél er með tvö sæti í stjórnklefa (fyrir flugmanninn og aðstoðarflugmanninn) og einhvern fjölda sætaraða fyrir farþega á 1. og 2. farrými. Hver sætaröð á 1. farrými hefur fjögur sæti. Hver sætaröð á 2. farrými hefur fimm sæti.';
+ break;
+ }
+ output += '</p><p>Búðu til formúlu (hér fyrir neðan) sem reiknar heildarfjölda sæta í flugvélinni eftir því sem röðunum er breytt (hér fyrir ofan).</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/it.js b/blockly/demos/plane/generated/it.js
new file mode 100644
index 0000000..4a71337
--- /dev/null
+++ b/blockly/demos/plane/generated/it.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">File: %1</span><span id="Plane_getRows">file (%1)</span><span id="Plane_rows1">File 1ª classe: %1</span><span id="Plane_getRows1">file 1ª classe (%1)</span><span id="Plane_rows2">File 2ª classe: %1</span><span id="Plane_getRows2">File 2ª classe (%1)</span><span id="Plane_seats">Sedili: %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">sedili =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">Calcolo posti aereo</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'Un aeroplano ha un numero di file contenenti i posti a sedere dei passeggeri. Ogni fila, contiene quattro posti a sedere.';
+ break;
+ case 2:
+ output += 'Un aeroplano ha due posti a sedere nella cabina di pilotaggio (per il pilota e co-pilota), e un numero di file con i posti a sedere dei passeggeri. Ogni fila contiene quattro posti.';
+ break;
+ case 3:
+ output += 'Un aereo ha due posti nella cabina di pilotaggio (per il pilota e il co-pilota), e un numero di file in prima e seconda classe, con i posti a sedere dei passeggeri. Ogni fila della prima classe contiene quattro posti. Quelle invece della seconda classe, ne contengono cinque.';
+ break;
+ }
+ output += '</p><p>Costruisci una formula (sotto) che calcola il numero totale di posti a sedere su un aeroplano, così come cambiano le file di posti (sopra).</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/ja.js b/blockly/demos/plane/generated/ja.js
new file mode 100644
index 0000000..86bac97
--- /dev/null
+++ b/blockly/demos/plane/generated/ja.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">列の数: %1</span><span id="Plane_getRows">列の数 (%1)</span><span id="Plane_rows1">ファーストクラスの列数: %1</span><span id="Plane_getRows1">ファーストクラスの列数 (%1)</span><span id="Plane_rows2">セカンドクラスの列数: %1</span><span id="Plane_getRows2">セカンドクラスの列数 (%1)</span><span id="Plane_seats">座席の数: %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">座席の数 =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">飛行機座席計算機</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += '飛行機に乗客の座席の列があります。それぞれの列に 4 つの座席があります。';
+ break;
+ case 2:
+ output += '飛行機には、操縦室の 2 つの座席 (操縦士と副操縦士) と、乗客の座席の列があります。それぞれの列に 4 つの座席があります。';
+ break;
+ case 3:
+ output += '飛行機には、操縦室の 2 つの座席 (操縦士と副操縦士) と、ファーストクラスとセカンドクラスの乗客の座席の列があります。それぞれの列に、ファーストクラスでは 4 つの座席、セカンドクラスでは 5 つの座席があります。';
+ break;
+ }
+ output += '</p><p>飛行機の座席の数を計算する式を、上で列の数を変更しても正しくなるように、下に入力してください。</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/ko.js b/blockly/demos/plane/generated/ko.js
new file mode 100644
index 0000000..464f63f
--- /dev/null
+++ b/blockly/demos/plane/generated/ko.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">행 수: %1</span><span id="Plane_getRows">행 수 (%1)</span><span id="Plane_rows1">1등석 행 수: %1</span><span id="Plane_getRows1">1등석 행 수 (%1)</span><span id="Plane_rows2">2등석 행 수: %1</span><span id="Plane_getRows2">2등석 행 수 (%1)</span><span id="Plane_seats">좌석 수: %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">좌석수 =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">비행기 좌석 계산기</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += '비행기는 승객 좌석의 행 수가 있습니다. 각 행에는 시트 네 개가 포함되어 있습니다.';
+ break;
+ case 2:
+ output += '비행기는 비행 갑판(조종사와 부조종사용)에서 좌석 두 개가 있고, 승객 좌석의 행 수가 있습니다. 각 행에는 시트 네 개가 포함되어 있습니다.';
+ break;
+ case 3:
+ output += '비행기는 비행 갑판(조종사와 부조종사용)에서 좌석 두 개가 있고, 1등석과 2등석 승객 좌석의 행 수가 있습니다. 각 1등석 행에는 시트 네 개가 포함되어 있습니다. 각 2등석 행에는 시트 다섯 개가 포함되어 있습니다.';
+ break;
+ }
+ output += '</p><p>행이 바뀐(위) 비행기에 좌석의 총 수를 계산하는 공식(아래)을 구축하세요.</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/ms.js b/blockly/demos/plane/generated/ms.js
new file mode 100644
index 0000000..1a9a447
--- /dev/null
+++ b/blockly/demos/plane/generated/ms.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">Baris: %1</span><span id="Plane_getRows">baris (%1)</span><span id="Plane_rows1">Baris kelas pertama: %1</span><span id="Plane_getRows1">baris kelas pertama (%1)</span><span id="Plane_rows2">Baris kelas kedua: %1</span><span id="Plane_getRows2">baris kelas kedua (%1)</span><span id="Plane_seats">Tempat duduk: %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">tempat duduk =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">Pengira Tempat Duduk Kapal Terbang</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'Sebuah kapal terbang mempunyai sebilangan baris tempat duduk penumpang. Setiap baris mengandungi empat tempat duduk.';
+ break;
+ case 2:
+ output += 'Sebuah kapal terbang mempunyai tempat duduk di kokpit (untuk juruterbang dan pembantunya) dan sebilangan baris tempat duduk penumpang. Setiap baris mengandungi empat tempat duduk.';
+ break;
+ case 3:
+ output += 'Sebuah kapal terbang mempunyai tempat duduk di kokpit (untuk juruterbang dan pembantunya) dan sebilangan baris tempat duduk penumpang kelas pertama dan kelas kedua. Setiap baris kelas pertama mengandungi empat tempat duduk. Setiap baris kelas pertama mengandungi lima tempat duduk.';
+ break;
+ }
+ output += '</p><p>Wujudkan formula (di bawah) yang mengira jumlah tempat duduk di dalam kapal terbang sedangkan baris-barisnya diubah (di atas).</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/nb.js b/blockly/demos/plane/generated/nb.js
new file mode 100644
index 0000000..c71cba5
--- /dev/null
+++ b/blockly/demos/plane/generated/nb.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">Rader: %1</span><span id="Plane_getRows">rader (%1)</span><span id="Plane_rows1">Rader i første klasse: %1</span><span id="Plane_getRows1">Rader i første klasse (%1)</span><span id="Plane_rows2">Rader i andre klasse: %1</span><span id="Plane_getRows2">Rader i andre klasse (%1)</span><span id="Plane_seats">Seter: %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">seter =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">Flysetekalkulator</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'Et fly har et antall rader med passasjerseter. Hver rad inneholder fire seter.';
+ break;
+ case 2:
+ output += 'Et fly har to seter i cockpit (for piloten og andrepiloten), og et antall rader med passasjerseter. Hver rad inneholder fire seter.';
+ break;
+ case 3:
+ output += 'Et fly har to seter i cockpit (for piloten og andrepiloten), og et antall rader med passasjerseter på første og andre klasse. Hver av radene på første klasse har fire seter. Hver av radene på andre klasse har fem seter.';
+ break;
+ }
+ output += '</p><p>Bygg en formel (under) som beregner det totale antall seter på flyet etter hvert som radene endres (over).</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/nl.js b/blockly/demos/plane/generated/nl.js
new file mode 100644
index 0000000..edad19f
--- /dev/null
+++ b/blockly/demos/plane/generated/nl.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">Rijen: %1</span><span id="Plane_getRows">rijen (%1)</span><span id="Plane_rows1">Rijen 1e klas: %1</span><span id="Plane_getRows1">Rijen 1e klas (%1)</span><span id="Plane_rows2">Rijen 2e klas: %1</span><span id="Plane_getRows2">Rijen 2e klas (%1)</span><span id="Plane_seats">Zitplaatsen: %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">stoelen=</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">Vliegtuigstoelencalculator</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'Een vliegtuig heeft een aantal rijen met stoelen. Iedere rij heeft vier stoelen.';
+ break;
+ case 2:
+ output += 'Een vliegtuig heeft twee stoelen in de cockpit (voor de piloot en de copiloot) en een aantal rijen met stoelen voor passagiers. Iedere rij bevat vier stoelen.';
+ break;
+ case 3:
+ output += 'Een vliegtuig heeft twee stoelen in de cockpit (voor de piloot en de copiloot) en een aantal rijen voor 1e klasse en 2e klasse passagiers. Iedere rij in de 1e klasse heeft vier stoelen. Iedere rij in de 2e klasse heeft vijf stoelen.';
+ break;
+ }
+ output += '</p><p>Maak hieronder een formule die het totale aantal stoelen in het vliegtuig berekent als het aantal rijen hierboven wordt aangepast.</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/pl.js b/blockly/demos/plane/generated/pl.js
new file mode 100644
index 0000000..14b5ee6
--- /dev/null
+++ b/blockly/demos/plane/generated/pl.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">Rzędów: %1</span><span id="Plane_getRows">rzędów (%1)</span><span id="Plane_rows1">Rzędów w pierwszej klasie: %1</span><span id="Plane_getRows1">Rzędów w pierwszej klasie (%1)</span><span id="Plane_rows2">Rzędów w drugiej klasie: %1</span><span id="Plane_getRows2">Rzędów w drugiej klasie (%1)</span><span id="Plane_seats">Siedzeń: %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">siedzeń =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">Kalkulator miejsc w samolocie.</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'Samolot ma kilka rzędów siedzeń pasażerów. Każdy rząd zawiera cztery miejsca.';
+ break;
+ case 2:
+ output += 'Samolot ma dwa miejsca w kabinie pilotów (dla pierwszego i drugiego pilota) oraz rzędy siedzeń dla pasażerów. Każdy taki rząd składa się z czterech siedzeń.';
+ break;
+ case 3:
+ output += 'Samolot ma dwa miejsca w kabinie pilotów (dla pierwszego i drugiego pilota) oraz rzędy siedzeń dla pasażerów pierwszej i drugiej klasy. Każdy rząd pierwszej klasy składa się z czterech siedzeń. Każdy rząd drugiej klasy składa się z pięciu siedzeń.';
+ break;
+ }
+ output += '</p><p>Zbuduj wzór (poniżej), który pozwala obliczyć łączną liczbę siedzeń w samolocie w funkcji zmieniającej się liczby rzędów (powyżej).</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/pms.js b/blockly/demos/plane/generated/pms.js
new file mode 100644
index 0000000..df45f22
--- /dev/null
+++ b/blockly/demos/plane/generated/pms.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">Linie: %1</span><span id="Plane_getRows">linie (%1)</span><span id="Plane_rows1">linie ëd prima classa: %1</span><span id="Plane_getRows1">linie ëd prima classa (%1)</span><span id="Plane_rows2">linie ëd seconda classa: %1</span><span id="Plane_getRows2">linie ëd seconda classa (%1)</span><span id="Plane_seats">Sedij: %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">sedij =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">Calcolator ëd sedij d\'avion</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'N\'avion a l\'ha un nùmer ëd file ëd sedij da passëgé. Minca fila a l\'ha quatr sedij.';
+ break;
+ case 2:
+ output += 'N\'avion a l\'ha doi sedij ant la cabin-a ëd pilotage (për ël pilòta e ël cò-pilòta), e un chèich nùmer ëd file ëd sedij pr\'ij passagé. Minca fila a conten quatr sedij.';
+ break;
+ case 3:
+ output += 'N\'avion a l\'ha doi sedij ant la cabin-a ëd pilotage (për ël pilòta e ël cò-pilòta) e un chèich nùmer ëd file ëd sedij pr\'ij passagé ëd prima e sconda classa. Minca fila ëd prima classa a conten quatr sedij. Minca fila ëd seconda classa a conten sinch sedij.';
+ break;
+ }
+ output += '</p><p>Fabriché na fórmola (sì-sota) ch\'a fa \'l cont dël nùmer total ëd sedij ant l\'avion cand che ël nùmer dle file a cangia (sì-dzora).</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/pt-br.js b/blockly/demos/plane/generated/pt-br.js
new file mode 100644
index 0000000..2e96d38
--- /dev/null
+++ b/blockly/demos/plane/generated/pt-br.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">Filas: %1</span><span id="Plane_getRows">filas (%1)</span><span id="Plane_rows1">filas na primeira classe: %1</span><span id="Plane_getRows1">filas na primeira classe (%1)</span><span id="Plane_rows2">filas na segunda classe: %1</span><span id="Plane_getRows2">filas na segunda classe (%1)</span><span id="Plane_seats">Assentos: %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">assentos =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">Calculadora de Assentos em Avião</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'Um avião tem um número de filas de assentos para os passageiros. Cada fila contém quatro assentos.';
+ break;
+ case 2:
+ output += 'Um avião tem dois assentos na cabine de comando (para o piloto e o copiloto) e um número de filas de assentos para os passageiros. Cada fila contém quatro assentos.';
+ break;
+ case 3:
+ output += 'Um avião tem dois assentos na cabine de comando (para o piloto e o copiloto) e um número de filas de assentos na primeira e na segunda classe. Cada fila da primeira classe contém quatro assentos. Cada fila da segunda classe contém cinco assentos.';
+ break;
+ }
+ output += '</p><p>Elabore uma fórmula (abaixo) que calcule o número total de assentos no avião a medida que as filas são alteradas (acima).</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/ro.js b/blockly/demos/plane/generated/ro.js
new file mode 100644
index 0000000..426a571
--- /dev/null
+++ b/blockly/demos/plane/generated/ro.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">Rânduri: %1</span><span id="Plane_getRows">rânduri (%1)</span><span id="Plane_rows1">rânduri de clasa I: %1</span><span id="Plane_getRows1">rânduri de clasa I (%1)</span><span id="Plane_rows2">rânduri de clasa a II-a: %1</span><span id="Plane_getRows2">rânduri de clasa a II-a (%1)</span><span id="Plane_seats">Scaune: %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">scaune =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">Calculator pentru locurile dintr-un avion</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'Un avion are un număr de rânduri cu scaune pentru pasageri. Fiecare rând conține patru scaune.';
+ break;
+ case 2:
+ output += 'Un avion are două scaune în carlingă (pentru pilot și copilot) și un număr de rânduri cu scaune pentru pasageri. Fiecare rând conține patru scaune.';
+ break;
+ case 3:
+ output += 'Un avion are două scaune în carlingă (pentru pilot și copilot) și un număr de rânduri cu scaune de clasa I și clasa a II-a pentru pasageri. Fiecare rând de clasa I conține patru scaune. Fiecare rând de clasa a II-a conține cinci scaune.';
+ break;
+ }
+ output += '</p><p>Construiește o formulă (mai jos) care calculează numărul total de locuri dintr-un avion în timp ce rândurile se schimbă (mai sus).</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/ru.js b/blockly/demos/plane/generated/ru.js
new file mode 100644
index 0000000..78f384b
--- /dev/null
+++ b/blockly/demos/plane/generated/ru.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">Рядов: %1</span><span id="Plane_getRows">ряды (%1)</span><span id="Plane_rows1">Рядов 1-го класса: %1</span><span id="Plane_getRows1">ряды 1-го класса (%1)</span><span id="Plane_rows2">Рядов 2-го класса: %1</span><span id="Plane_getRows2">ряды 2-го класса (%1)</span><span id="Plane_seats">Мест: %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">места =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">Калькулятор посадочных мест в самолёте</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'В самолёте несколько рядов с пассажирскими местами. В каждом ряду 4 места.';
+ break;
+ case 2:
+ output += 'В самолёте 2 места для пилота и его помощника, а также несколько рядов с пассажирскими местами. В каждом ряду 4 места.';
+ break;
+ case 3:
+ output += 'В самолёте 2 места для пилота и его помощника, несколько рядов с пассажирскими местами первого класса, а также несколько рядов с пассажирскими местами второго класса. В каждом ряду первого класса 4 места. В каждом ряду второго класса 5 мест.';
+ break;
+ }
+ output += '</p><p>Постройте формулу в области ниже, которая поможет рассчитать общее количество мест в самолёте (как на рисунке выше).</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/sc.js b/blockly/demos/plane/generated/sc.js
new file mode 100644
index 0000000..453c5e7
--- /dev/null
+++ b/blockly/demos/plane/generated/sc.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">Fileras: %1</span><span id="Plane_getRows">fileras (%1)</span><span id="Plane_rows1">fileras de primu classi: %1</span><span id="Plane_getRows1">fileras de primu classi (%1)</span><span id="Plane_rows2">fileras de segunda classi: %1</span><span id="Plane_getRows2">fileras de segunda classi (%1)</span><span id="Plane_seats">Cadironis: %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">cadironis =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">Fai su contu de is cadironis de unu aparèchiu</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'Unu aparèchiu tenit unas cantu fileras de cadironis po passigeris. Dònnia filera tenit cuatru cadironis.';
+ break;
+ case 2:
+ output += 'Unu aparèchiu tenit duus cadironis in sa cabina de cumandu (po su pilota e su co-pilota), e unas cantu fileras de cadironis po passigeris. Dònnia filera tenit cuatru cadironis.';
+ break;
+ case 3:
+ output += 'Unu aparèchiu tenit duus cadironis in sa cabina de cumandu (po su pilota e su co-pilota), e unas cantu fileras de cadironis po passigeris de prima classi e de segunda classi. Dònnia filera de prima classi tenit cuatru cadironis. Dònnia filera de segunda classi tenit cincu cadironis.';
+ break;
+ }
+ output += '</p><p>Cuncorda una formula (innoi asuta) chi cumpudit su numeru totali de postus a setzi in s\'aparechiu, a segunda de comenti mudant is fileras de postus (innoi in susu)</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/sv.js b/blockly/demos/plane/generated/sv.js
new file mode 100644
index 0000000..acba58c
--- /dev/null
+++ b/blockly/demos/plane/generated/sv.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">Rader: %1</span><span id="Plane_getRows">rader (%1)</span><span id="Plane_rows1">Rader i första klass: %1</span><span id="Plane_getRows1">Rader i första klass (%1)</span><span id="Plane_rows2">Rader i andra klass: %1</span><span id="Plane_getRows2">Rader i andra klass (%1)</span><span id="Plane_seats">Säten: %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">säten =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">Plansäteskalkylator</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'Ett flygplan har ett antal rader med passagerarsäten. Varje rad innehåller fyra säten.';
+ break;
+ case 2:
+ output += 'Ett flygplan har två säten i cockpiten (ett för piloten och ett för andrepiloten) och ett antal rader med passagerarsäten. Varje rad innehåller fyra säten.';
+ break;
+ case 3:
+ output += 'Ett flygplan har två säten i cockpiten (ett för piloten och ett för andrepiloten) och ett antal rader med passagerarsäten i första och andra klass. Varje rad i första klass innehåller fyra säten. Varje rad i andra klass innehåller fem säten.';
+ break;
+ }
+ output += '</p><p>Bygg en formel (nedan) som beräknar det totala antalet säten på flygplanet när raderna ändras (ovan).</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/th.js b/blockly/demos/plane/generated/th.js
new file mode 100644
index 0000000..bfa8621
--- /dev/null
+++ b/blockly/demos/plane/generated/th.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">%1 แถว</span><span id="Plane_getRows">จำนวนแถว (%1)</span><span id="Plane_rows1">ชั้นเฟิร์สคลาส %1 แถว</span><span id="Plane_getRows1">จำนวนแถวชั้นเฟิร์สคลาส (%1)</span><span id="Plane_rows2">ชั้นธุรกิจ %1 แถว</span><span id="Plane_getRows2">จำนวนแถวชั้นธุรกิจ (%1)</span><span id="Plane_seats">คำนวณได้ทั้งหมด %1 ที่นั่ง</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">จำนวนที่นั่ง =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">ระบบคำนวณที่นั่งบนเครื่องบิน</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'ภายในเครื่องบินประกอบไปด้วยแถวของที่นั่งผู้โดยสาร ในแต่ละแถวจะมี 4 ที่นั่ง';
+ break;
+ case 2:
+ output += 'ภายในเครื่องบินจะมีที่นั่งนักบินอยู่ 2 ที่ (สำหรับนักบิน และผู้ช่วยนักบิน) และมีแถวที่นั่งผู้โดยสารอยู่จำนวนหนึ่ง ในแต่ละแถวจะมี 4 ที่นั่ง';
+ break;
+ case 3:
+ output += 'ภายในเครื่องบินจะมีที่นั่งนักบินอยู่ 2 ที่ (สำหรับนักบิน และผู้ช่วยนักบิน) และจะมีแถวที่นั่งสำหรับผู้โดยสาร "ชั้นเฟิร์สคลาส" และ "ชั้นธุรกิจ" อยู่จำนวนหนึ่ง โดยในชั้นเฟิร์สคลาสจะมีแถวละ 4 ที่นั่ง ส่วนในชั้นธุรกิจจะมีแถวละ 5 ที่นั่ง';
+ break;
+ }
+ output += '</p><p>สร้างสูตรคำนวณ (ด้านล่าง) เพื่อคำนวณหาจำนวนที่นั่งทั้งหมดบนเครื่องบิน ตามจำนวนแถวที่เปลี่ยนไป (ด้านบน)</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/tr.js b/blockly/demos/plane/generated/tr.js
new file mode 100644
index 0000000..e1bb134
--- /dev/null
+++ b/blockly/demos/plane/generated/tr.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">Sıralar: %1</span><span id="Plane_getRows">sıralar (%1)</span><span id="Plane_rows1">Birinci sınıf sıralar: (%1)</span><span id="Plane_getRows1">Birinci sınıf sıralar (%1)</span><span id="Plane_rows2">İkinci sınıf sıralar: %1</span><span id="Plane_getRows2">İkinci sınıf sıralar (%1)</span><span id="Plane_seats">Koltuklar: %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">koltuklar =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">Uçak Koltuğu Hesaplayıcı</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'Bir uçağın belirli sayıda koltuk sırası vardır. Her sıra dört koltuk içerir.';
+ break;
+ case 2:
+ output += 'Bir uçağın uçuş güvertesinde iki koltuğu (pilot ve yardımcı pilot için), ve belirli sayıda koltuk sırası vardır. Her sıra dört koltuk içerir.';
+ break;
+ case 3:
+ output += 'Bir uçağın uçuş güvertesinde iki koltuğu (pilot ve yardımcı pilot için), ve belirli sayıda birinci sınıf ve ikinci sınıf yolcu koltuğu sırası vardır. Her birinci sınıf sıra dört koltuk içerir. Her ikinci sınıf sıra beş koltuk içerir.';
+ break;
+ }
+ output += '</p><p>Sıralar(üstte) değiştikçe uçaktaki toplam koltuk sayısını hesaplayan bir formül(altta) oluşturun.</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/uk.js b/blockly/demos/plane/generated/uk.js
new file mode 100644
index 0000000..047adfc
--- /dev/null
+++ b/blockly/demos/plane/generated/uk.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">Рядки: %1</span><span id="Plane_getRows">рядки (%1)</span><span id="Plane_rows1">рядів 1-го класу: %1</span><span id="Plane_getRows1">рядів 1-го класу (%1)</span><span id="Plane_rows2">рядів 2-го класу: %1</span><span id="Plane_getRows2">рядів 2-го класу (%1)</span><span id="Plane_seats">Місць: %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">місць=</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">Калькулятор місць у літаку</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'Літак має кілька рядів пасажирських сидінь. Кожен ряд містить чотири місця.';
+ break;
+ case 2:
+ output += 'Літак має два місця в кабіні екіпажу (пілот і другий пілот), і кілька рядів пасажирських сидінь. Кожен рядок містить чотири місця.';
+ break;
+ case 3:
+ output += 'Літак має два місця в кабіні екіпажу (пілот і другий пілот), і кілька рядів 1-го класу 2-го класу пасажирських місць. Кожний ряд 1-го класу містить чотири місця. Кожен ряд 2-го класу містить п\'ять місць.';
+ break;
+ }
+ output += '</p><p>Побудувати формулу (нижче), яка обчислює кількість місць на літаку при зміні рядків (див. вище).</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/vi.js b/blockly/demos/plane/generated/vi.js
new file mode 100644
index 0000000..61dc24a
--- /dev/null
+++ b/blockly/demos/plane/generated/vi.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">Số hàng ghế: %1</span><span id="Plane_getRows">đếm số hàng ghế (%1)</span><span id="Plane_rows1">Hàng hạng nhất: %1</span><span id="Plane_getRows1">số hàng hạng nhất (%1)</span><span id="Plane_rows2">Hàng hạng hai: %1</span><span id="Plane_getRows2">số hàng hạng hai (%1)</span><span id="Plane_seats">Số chỗ ngồi: %1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">Tính số chỗ ngồi =</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">Máy bay ghế máy tính</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += 'Máy bay có một số hàng ghế hành khách. Mỗi hàng có bốn chỗ ngồi.';
+ break;
+ case 2:
+ output += 'Một máy bay có hai ghế trong buồng lái (dành cho phi công trưởng và phi công phụ), và một loạt hàng ghế cho hành khách. Mỗi hàng có bốn ghế (bốn chỗ ngồi).';
+ break;
+ case 3:
+ output += 'Một chiếc máy bay này có hai chỗ ngồi ở sàn (cho phi công trưởng và phi công phó), và một số hàng ghế hạng 1 và hạng 2. Mỗi hàng hạng 1 có bốn chỗ ngồi. Mỗi hàng hạng 2 có năm chỗ ngồi.';
+ break;
+ }
+ output += '</p><p>Dưới đây hãy tạo công thức tính số chỗ ngồi trên máy bay để nó thay đổi tùy theo số lượng hàng ghế (hình trên).</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/zh-hans.js b/blockly/demos/plane/generated/zh-hans.js
new file mode 100644
index 0000000..d8ea3d3
--- /dev/null
+++ b/blockly/demos/plane/generated/zh-hans.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">行:%1</span><span id="Plane_getRows">行 (%1)</span><span id="Plane_rows1">头等行:%1</span><span id="Plane_getRows1">头等行(%1)</span><span id="Plane_rows2">经济等行:%1</span><span id="Plane_getRows2">经济等行(%1)</span><span id="Plane_seats">座位:%1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">座位=</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">飞机座位计算器</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += '一架飞机有一定量行数的乘客座位,每行共四座。';
+ break;
+ case 2:
+ output += '一架飞机除了有两个座位供正副驾驶员,还有一定量行数的乘客座位。每行共四座。';
+ break;
+ case 3:
+ output += '一架飞机除了有两个座位供正副驾驶员,还有一定量行数的头等及经济乘客座位。头等每行共四座,经济每行共五座。';
+ break;
+ }
+ output += '</p><p>于下方写出一条公式以计算飞机上的座位总数。</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/generated/zh-hant.js b/blockly/demos/plane/generated/zh-hant.js
new file mode 100644
index 0000000..a85010e
--- /dev/null
+++ b/blockly/demos/plane/generated/zh-hant.js
@@ -0,0 +1,37 @@
+// This file was automatically generated from template.soy.
+// Please don't edit this file by hand.
+
+if (typeof planepage == 'undefined') { var planepage = {}; }
+
+
+planepage.messages = function(opt_data, opt_ignored, opt_ijData) {
+ return '<div style="display: none"><span id="Plane_rows">排:%1</span><span id="Plane_getRows">排(%1)</span><span id="Plane_rows1">頭等艙:%1 排</span><span id="Plane_getRows1">頭等艙(%1)</span><span id="Plane_rows2">經濟艙:%1 排</span><span id="Plane_getRows2">經濟艙(%1)</span><span id="Plane_seats">座位:%1</span><span id="Plane_placeholder">?</span><span id="Plane_setSeats">座位=</span></div>';
+};
+
+
+planepage.start = function(opt_data, opt_ignored, opt_ijData) {
+ var output = planepage.messages(null, null, opt_ijData) + '<table width="100%"><tr><td><h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt; <a href="../index.html">Demos</a>&rlm; &gt; <span id="title">飛機座位計算器</span> &nbsp; ';
+ var iLimit37 = opt_ijData.maxLevel + 1;
+ for (var i37 = 1; i37 < iLimit37; i37++) {
+ output += ' ' + ((i37 == opt_ijData.level) ? '<span class="tab" id="selected">' + soy.$$escapeHtml(i37) + '</span>' : (i37 < opt_ijData.level) ? '<a class="tab previous" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>' : '<a class="tab" href="?lang=' + soy.$$escapeHtml(opt_ijData.lang) + '&level=' + soy.$$escapeHtml(i37) + '">' + soy.$$escapeHtml(i37) + '</a>');
+ }
+ output += '</h1></td><td class="farSide"><span ' + ((opt_ijData.lang == 'en') ? 'id="languageBorder"' : '') + ' style="padding: 10px"><select id="languageMenu"></select></span></td></tr></table><script src="slider.js"><\/script><svg id="plane" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="320" viewBox="0 110 600 320"><defs><g id="row1st"><rect class="seat1st" width="10" height="10" x="75" y="243" /><rect class="seat1st" width="10" height="10" x="75" y="254" /><rect class="seat1st" width="10" height="10" x="75" y="272" /><rect class="seat1st" width="10" height="10" x="75" y="283" /></g><g id="row2nd"><rect class="seat2nd" width="10" height="8" x="75" y="243" /><rect class="seat2nd" width="10" height="8" x="75" y="251" /><rect class="seat2nd" width="10" height="8" x="75" y="269" /><rect class="seat2nd" width="10" height="8" x="75" y="277" /><rect class="seat2nd" width="10" height="8" x="75" y="285" /></g><linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient><linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#fff;stop-opacity:0" /><stop offset="100%" style="stop-color:#fff;stop-opacity:1" /></linearGradient></defs><path d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z" id="wing" /><path d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z" id="tail" /><path d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z" id="fuselage" /><rect width="610" height="100" x="-5" y="110" fill="url(#grad1)" /><rect width="610" height="100" x="-5" y="330" fill="url(#grad2)" /><text id="row1stText" x="55" y="380"></text><text id="row2ndText" x="55" y="420"></text><text x="55" y="210"><tspan id="seatText"></tspan><tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan><tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan></text>' + ((opt_ijData.level > 1) ? '<rect id="crew_right" class="crew" width="10" height="10" x="35" y="254" /><rect id="crew_left" class="crew" width="10" height="10" x="35" y="272" />' : '') + '</svg><p>';
+ switch (opt_ijData.level) {
+ case 1:
+ output += '一架飛機有一定量行數的乘客座位,每排都包含四個席位。';
+ break;
+ case 2:
+ output += '一架飛機除了有兩個座位供正副機師,還有一定量行數的乘客座位。每排都包含四個席位。';
+ break;
+ case 3:
+ output += '一架飛機除了有兩個座位供正副機師,還有一定量行數的頭等及經濟乘客座位。頭等艙每排都包含四個席位,經濟艙每排都包含五個席位。。';
+ break;
+ }
+ output += '</p><p>於下方寫出一條公式以計算飛機上的座位總數。</p><script src="../../blockly_compressed.js"><\/script><script src="../../blocks_compressed.js"><\/script><script src="../../javascript_compressed.js"><\/script><script src="../../msg/js/' + soy.$$escapeHtml(opt_ijData.lang) + '.js"><\/script><script src="blocks.js"><\/script>' + planepage.toolbox(null, null, opt_ijData) + '<div id="blockly"></div>';
+ return output;
+};
+
+
+planepage.toolbox = function(opt_data, opt_ignored, opt_ijData) {
+ return '<xml id="toolbox" style="display: none"><block type="math_number"></block><block type="math_arithmetic"><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block><block type="math_arithmetic"><field name="OP">MULTIPLY</field><value name="A"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="B"><shadow type="math_number"><field name="NUM">1</field></shadow></value></block>' + ((opt_ijData.level <= 2) ? '<block type="plane_get_rows"></block>' : '<block type="plane_get_rows1st"></block><block type="plane_get_rows2nd"></block>') + '</xml>';
+};
diff --git a/blockly/demos/plane/icon.png b/blockly/demos/plane/icon.png
new file mode 100644
index 0000000..0ebac70
--- /dev/null
+++ b/blockly/demos/plane/icon.png
Binary files differ
diff --git a/blockly/demos/plane/index.html b/blockly/demos/plane/index.html
new file mode 100644
index 0000000..dec1cd3
--- /dev/null
+++ b/blockly/demos/plane/index.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="google" value="notranslate">
+ <title>Blockly Demo:</title>
+ <link rel="stylesheet" href="style.css">
+ <script src="soy/soyutils.js"></script>
+ <script src="plane.js"></script>
+</head>
+<body>
+ <script>
+ document.write(planepage.start({}, null,
+ {lang: Plane.LANG,
+ level: Plane.LEVEL,
+ maxLevel: Plane.MAX_LEVEL}));
+ </script>
+</body>
+</html>
diff --git a/blockly/demos/plane/plane.js b/blockly/demos/plane/plane.js
new file mode 100644
index 0000000..99e5c17
--- /dev/null
+++ b/blockly/demos/plane/plane.js
@@ -0,0 +1,445 @@
+/**
+ * Blockly Demos: Plane Seat Calculator
+ *
+ * Copyright 2012 Google Inc.
+ * https://developers.google.com/blockly/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @fileoverview JavaScript for Blockly's Plane Seat Calculator demo.
+ * @author fraser@google.com (Neil Fraser)
+ */
+'use strict';
+
+/**
+ * Create a namespace for the application.
+ */
+var Plane = {};
+
+/**
+ * Lookup for names of supported languages. Keys should be in ISO 639 format.
+ */
+Plane.LANGUAGE_NAME = {
+ 'ar': 'العربية',
+ 'be-tarask': 'Taraškievica',
+ 'br': 'Brezhoneg',
+ 'ca': 'Català',
+ 'da': 'Dansk',
+ 'de': 'Deutsch',
+ 'el': 'Ελληνικά',
+ 'en': 'English',
+ 'es': 'Español',
+ 'fa': 'فارسی',
+ 'fr': 'Français',
+ 'he': 'עברית',
+ 'hrx': 'Hunsrik',
+ 'hu': 'Magyar',
+ 'ia': 'Interlingua',
+ 'is': 'Íslenska',
+ 'it': 'Italiano',
+ 'ja': '日本語',
+ 'ko': '한국어',
+ 'ms': 'Bahasa Melayu',
+ 'nb': 'Norsk Bokmål',
+ 'nl': 'Nederlands, Vlaams',
+ 'pl': 'Polski',
+ 'pms': 'Piemontèis',
+ 'pt-br': 'Português Brasileiro',
+ 'ro': 'Română',
+ 'ru': 'Русский',
+ 'sc': 'Sardu',
+ 'sv': 'Svenska',
+ 'th': 'ภาษาไทย',
+ 'tr': 'Türkçe',
+ 'uk': 'Українська',
+ 'vi': 'Tiếng Việt',
+ 'zh-hans': '简体中文',
+ 'zh-hant': '正體中文'
+};
+
+/**
+ * List of RTL languages.
+ */
+Plane.LANGUAGE_RTL = ['ar', 'fa', 'he'];
+
+/**
+ * Main Blockly workspace.
+ * @type {Blockly.WorkspaceSvg}
+ */
+Plane.workspace = null;
+
+/**
+ * Extracts a parameter from the URL.
+ * If the parameter is absent default_value is returned.
+ * @param {string} name The name of the parameter.
+ * @param {string} defaultValue Value to return if paramater not found.
+ * @return {string} The parameter value or the default value if not found.
+ */
+Plane.getStringParamFromUrl = function(name, defaultValue) {
+ var val = location.search.match(new RegExp('[?&]' + name + '=([^&]+)'));
+ return val ? decodeURIComponent(val[1].replace(/\+/g, '%20')) : defaultValue;
+};
+
+/**
+ * Extracts a numeric parameter from the URL.
+ * If the parameter is absent or less than min_value, min_value is
+ * returned. If it is greater than max_value, max_value is returned.
+ * @param {string} name The name of the parameter.
+ * @param {number} minValue The minimum legal value.
+ * @param {number} maxValue The maximum legal value.
+ * @return {number} A number in the range [min_value, max_value].
+ */
+Plane.getNumberParamFromUrl = function(name, minValue, maxValue) {
+ var val = Number(Plane.getStringParamFromUrl(name, 'NaN'));
+ return isNaN(val) ? minValue : Math.min(Math.max(minValue, val), maxValue);
+};
+
+/**
+ * Get the language of this user from the URL.
+ * @return {string} User's language.
+ */
+Plane.getLang = function() {
+ var lang = Plane.getStringParamFromUrl('lang', '');
+ if (Plane.LANGUAGE_NAME[lang] === undefined) {
+ // Default to English.
+ lang = 'en';
+ }
+ return lang;
+};
+
+/**
+ * Is the current language (Plane.LANG) an RTL language?
+ * @return {boolean} True if RTL, false if LTR.
+ */
+Plane.isRtl = function() {
+ return Plane.LANGUAGE_RTL.indexOf(Plane.LANG) != -1;
+};
+
+/**
+ * Load blocks saved in session/local storage.
+ * @param {string} defaultXml Text representation of default blocks.
+ */
+Plane.loadBlocks = function(defaultXml) {
+ try {
+ var loadOnce = window.sessionStorage.loadOnceBlocks;
+ } catch(e) {
+ // Firefox sometimes throws a SecurityError when accessing sessionStorage.
+ // Restarting Firefox fixes this, so it looks like a bug.
+ var loadOnce = null;
+ }
+ if (loadOnce) {
+ // Language switching stores the blocks during the reload.
+ delete window.sessionStorage.loadOnceBlocks;
+ var xml = Blockly.Xml.textToDom(loadOnce);
+ Blockly.Xml.domToWorkspace(xml, Plane.workspace);
+ } else if (defaultXml) {
+ // Load the editor with default starting blocks.
+ var xml = Blockly.Xml.textToDom(defaultXml);
+ Blockly.Xml.domToWorkspace(xml, Plane.workspace);
+ }
+ Plane.workspace.clearUndo();
+};
+
+/**
+ * Save the blocks and reload with a different language.
+ */
+Plane.changeLanguage = function() {
+ // Store the blocks for the duration of the reload.
+ // This should be skipped for the index page, which has no blocks and does
+ // not load Blockly.
+ // MSIE 11 does not support sessionStorage on file:// URLs.
+ if (typeof Blockly != 'undefined' && window.sessionStorage) {
+ var xml = Blockly.Xml.workspaceToDom(Plane.workspace);
+ var text = Blockly.Xml.domToText(xml);
+ window.sessionStorage.loadOnceBlocks = text;
+ }
+
+ var languageMenu = document.getElementById('languageMenu');
+ var newLang = encodeURIComponent(
+ languageMenu.options[languageMenu.selectedIndex].value);
+ var search = window.location.search;
+ if (search.length <= 1) {
+ search = '?lang=' + newLang;
+ } else if (search.match(/[?&]lang=[^&]*/)) {
+ search = search.replace(/([?&]lang=)[^&]*/, '$1' + newLang);
+ } else {
+ search = search.replace(/\?/, '?lang=' + newLang + '&');
+ }
+
+ window.location = window.location.protocol + '//' +
+ window.location.host + window.location.pathname + search;
+};
+
+/**
+ * Gets the message with the given key from the document.
+ * @param {string} key The key of the document element.
+ * @return {string} The textContent of the specified element,
+ * or an error message if the element was not found.
+ */
+Plane.getMsg = function(key) {
+ var element = document.getElementById(key);
+ if (element) {
+ var text = element.textContent;
+ // Convert newline sequences.
+ text = text.replace(/\\n/g, '\n');
+ return text;
+ } else {
+ return '[Unknown message: ' + key + ']';
+ }
+};
+
+/**
+ * User's language (e.g. "en").
+ * @type {string}
+ */
+Plane.LANG = Plane.getLang();
+
+Plane.MAX_LEVEL = 3;
+Plane.LEVEL = Plane.getNumberParamFromUrl('level', 1, Plane.MAX_LEVEL);
+
+Plane.rows1st = 0;
+Plane.rows2nd = 0;
+
+/**
+ * Redraw the rows when the slider has moved.
+ * @param {number} value New slider position.
+ */
+Plane.sliderChange = function(value) {
+ var newRows = Math.round(value * 410 / 20);
+ Plane.redraw(newRows);
+};
+
+/**
+ * Change the text of a label.
+ * @param {string} id ID of element to change.
+ * @param {string} text New text.
+ */
+Plane.setText = function(id, text) {
+ var el = document.getElementById(id);
+ while (el.firstChild) {
+ el.removeChild(el.firstChild);
+ }
+ el.appendChild(document.createTextNode(text));
+};
+
+/**
+ * Display a checkmark or cross next to the answer.
+ * @param {?boolean} ok True for checkmark, false for cross, null for nothing.
+ */
+Plane.setCorrect = function(ok) {
+ var yes = document.getElementById('seatYes');
+ var no = document.getElementById('seatNo');
+ yes.style.display = 'none';
+ no.style.display = 'none';
+ if (ok === true) {
+ yes.style.display = 'block';
+ } else if (ok === false) {
+ no.style.display = 'block';
+ }
+};
+
+/**
+ * Initialize Blockly and the SVG plane.
+ */
+Plane.init = function() {
+ Plane.initLanguage();
+
+ // Fixes viewport for small screens.
+ var viewport = document.querySelector('meta[name="viewport"]');
+ if (viewport && screen.availWidth < 725) {
+ viewport.setAttribute('content',
+ 'width=725, initial-scale=.35, user-scalable=no');
+ }
+
+ Plane.workspace = Blockly.inject('blockly',
+ {media: '../../media/',
+ rtl: Plane.isRtl(),
+ toolbox: document.getElementById('toolbox')});
+
+ var defaultXml =
+ '<xml>' +
+ ' <block type="plane_set_seats" deletable="false" x="70" y="70">' +
+ ' </block>' +
+ '</xml>';
+ Plane.loadBlocks(defaultXml);
+
+ Plane.workspace.addChangeListener(Plane.recalculate);
+ Plane.workspace.addChangeListener(Blockly.Events.disableOrphans);
+
+ // Initialize the slider.
+ var svg = document.getElementById('plane');
+ Plane.rowSlider = new Slider(60, 330, 425, svg, Plane.sliderChange);
+ Plane.rowSlider.setValue(0.225);
+
+ // Draw five 1st class rows.
+ Plane.redraw(5);
+};
+
+/**
+ * Initialize the page language.
+ */
+Plane.initLanguage = function() {
+ // Set the page title with the content of the H1 title.
+ document.title += ' ' + document.getElementById('title').textContent;
+
+ // Set the HTML's language and direction.
+ // document.dir fails in Mozilla, use document.body.parentNode.dir instead.
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=151407
+ var rtl = Plane.isRtl();
+ document.head.parentElement.setAttribute('dir', rtl ? 'rtl' : 'ltr');
+ document.head.parentElement.setAttribute('lang', Plane.LANG);
+
+ // Sort languages alphabetically.
+ var languages = [];
+ for (var lang in Plane.LANGUAGE_NAME) {
+ languages.push([Plane.LANGUAGE_NAME[lang], lang]);
+ }
+ var comp = function(a, b) {
+ // Sort based on first argument ('English', 'Русский', '简体字', etc).
+ if (a[0] > b[0]) return 1;
+ if (a[0] < b[0]) return -1;
+ return 0;
+ };
+ languages.sort(comp);
+ // Populate the language selection menu.
+ var languageMenu = document.getElementById('languageMenu');
+ languageMenu.options.length = 0;
+ for (var i = 0; i < languages.length; i++) {
+ var tuple = languages[i];
+ var lang = tuple[tuple.length - 1];
+ var option = new Option(tuple[0], lang);
+ if (lang == Plane.LANG) {
+ option.selected = true;
+ }
+ languageMenu.options.add(option);
+ }
+ languageMenu.addEventListener('change', Plane.changeLanguage, true);
+};
+
+/**
+ * Use the blocks to calculate the number of seats.
+ * Display the calculated number.
+ */
+Plane.recalculate = function() {
+ // Find the 'set' block and use it as the formula root.
+ var rootBlock = null;
+ var blocks = Plane.workspace.getTopBlocks(false);
+ for (var i = 0, block; block = blocks[i]; i++) {
+ if (block.type == 'plane_set_seats') {
+ rootBlock = block;
+ }
+ }
+ var seats = NaN;
+ Blockly.JavaScript.init(Plane.workspace);
+ var code = Blockly.JavaScript.blockToCode(rootBlock);
+ try {
+ seats = eval(code);
+ } catch (e) {
+ // Allow seats to remain NaN.
+ }
+ Plane.setText('seatText',
+ Plane.getMsg('Plane_seats').replace(
+ '%1', isNaN(seats) ? '?' : seats));
+ Plane.setCorrect(isNaN(seats) ? null : (Plane.answer() == seats));
+
+ // Update blocks to show values.
+ function updateBlocks(blocks) {
+ for (var i = 0, block; block = blocks[i]; i++) {
+ block.customUpdate && block.customUpdate();
+ }
+ }
+ updateBlocks(Plane.workspace.getAllBlocks());
+ updateBlocks(Plane.workspace.flyout_.workspace_.getAllBlocks());
+};
+
+/**
+ * Calculate the correct answer.
+ * @return {number} Number of seats.
+ */
+Plane.answer = function() {
+ if (Plane.LEVEL == 1) {
+ return Plane.rows1st * 4;
+ } else if (Plane.LEVEL == 2) {
+ return 2 + (Plane.rows1st * 4);
+ } else if (Plane.LEVEL == 3) {
+ return 2 + (Plane.rows1st * 4) + (Plane.rows2nd * 5);
+ }
+ throw 'Unknown level.';
+};
+
+/**
+ * Redraw the SVG to show a new number of rows.
+ * @param {number} newRows
+ */
+Plane.redraw = function(newRows) {
+ var rows1st = Plane.rows1st;
+ var rows2nd = Plane.rows2nd;
+ var svg = document.getElementById('plane');
+ if (newRows != rows1st) {
+ while (newRows < rows1st) {
+ var row = document.getElementById('row1st' + rows1st);
+ row.parentNode.removeChild(row);
+ rows1st--;
+ }
+ while (newRows > rows1st) {
+ rows1st++;
+ var row = document.createElementNS('http://www.w3.org/2000/svg', 'use');
+ row.setAttribute('id', 'row1st' + rows1st);
+ // Row of 4 seats.
+ row.setAttribute('x', (rows1st - 1) * 20);
+ row.setAttributeNS('http://www.w3.org/1999/xlink',
+ 'xlink:href', '#row1st');
+ svg.appendChild(row);
+ }
+
+ if (Plane.LEVEL == 3) {
+ newRows = Math.floor((21 - newRows) * 1.11);
+ while (newRows < rows2nd) {
+ var row = document.getElementById('row2nd' + rows2nd);
+ row.parentNode.removeChild(row);
+ rows2nd--;
+ }
+ while (newRows > rows2nd) {
+ rows2nd++;
+ var row = document.createElementNS('http://www.w3.org/2000/svg',
+ 'use');
+ row.setAttribute('id', 'row2nd' + rows2nd);
+ row.setAttribute('x', 400 - (rows2nd - 1) * 18);
+ row.setAttributeNS('http://www.w3.org/1999/xlink',
+ 'xlink:href', '#row2nd');
+ svg.appendChild(row);
+ }
+ }
+
+ if (Plane.LEVEL < 3) {
+ Plane.setText('row1stText',
+ Plane.getMsg('Plane_rows').replace('%1', rows1st));
+ } else {
+ Plane.setText('row1stText',
+ Plane.getMsg('Plane_rows1').replace('%1', rows1st));
+ Plane.setText('row2ndText',
+ Plane.getMsg('Plane_rows2').replace('%1', rows2nd));
+ }
+
+ Plane.rows1st = rows1st;
+ Plane.rows2nd = rows2nd;
+ Plane.recalculate();
+ }
+};
+
+window.addEventListener('load', Plane.init);
+
+// Load the user's language pack.
+document.write('<script src="generated/' + Plane.LANG + '.js"></script>\n');
diff --git a/blockly/demos/plane/slider.js b/blockly/demos/plane/slider.js
new file mode 100644
index 0000000..2df67b8
--- /dev/null
+++ b/blockly/demos/plane/slider.js
@@ -0,0 +1,287 @@
+/**
+ * Blockly Demos: SVG Slider
+ *
+ * Copyright 2012 Google Inc.
+ * https://developers.google.com/blockly/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @fileoverview A slider control in SVG.
+ * @author fraser@google.com (Neil Fraser)
+ */
+'use strict';
+
+
+/**
+ * Object representing a horizontal slider widget.
+ * @param {number} x The horizontal offset of the slider.
+ * @param {number} y The vertical offset of the slider.
+ * @param {number} width The total width of the slider.
+ * @param {!Element} svgParent The SVG element to append the slider to.
+ * @param {Function=} opt_changeFunc Optional callback function that will be
+ * called when the slider is moved. The current value is passed.
+ * @constructor
+ */
+var Slider = function(x, y, width, svgParent, opt_changeFunc) {
+ this.KNOB_Y_ = y - 12;
+ this.KNOB_MIN_X_ = x + 8;
+ this.KNOB_MAX_X_ = x + width - 8;
+ this.TARGET_OVERHANG_ = 20;
+ this.value_ = 0.5;
+ this.changeFunc_ = opt_changeFunc;
+ this.animationTasks_ = [];
+
+ // Draw the slider.
+ /*
+ <line class="sliderTrack" x1="10" y1="35" x2="140" y2="35" />
+ <rect style="opacity: 0" x="5" y="25" width="150" height="20" />
+ <path id="knob"
+ transform="translate(67, 23)"
+ d="m 8,0 l -8,8 v 12 h 16 v -12 z" />
+ <circle style="opacity: 0" r="20" cy="35" cx="75"></circle>
+ */
+ var track = document.createElementNS(Slider.SVG_NS_, 'line');
+ track.setAttribute('class', 'sliderTrack');
+ track.setAttribute('x1', x);
+ track.setAttribute('y1', y);
+ track.setAttribute('x2', x + width);
+ track.setAttribute('y2', y);
+ svgParent.appendChild(track);
+ this.track_ = track;
+ var rect = document.createElementNS(Slider.SVG_NS_, 'rect');
+ rect.setAttribute('style', 'opacity: 0');
+ rect.setAttribute('x', x - this.TARGET_OVERHANG_);
+ rect.setAttribute('y', y - this.TARGET_OVERHANG_);
+ rect.setAttribute('width', width + 2 * this.TARGET_OVERHANG_);
+ rect.setAttribute('height', 2 * this.TARGET_OVERHANG_);
+ rect.setAttribute('rx', this.TARGET_OVERHANG_);
+ rect.setAttribute('ry', this.TARGET_OVERHANG_);
+ svgParent.appendChild(rect);
+ this.trackTarget_ = rect;
+ var knob = document.createElementNS(Slider.SVG_NS_, 'path');
+ knob.setAttribute('class', 'sliderKnob');
+ knob.setAttribute('d', 'm 0,0 l -8,8 v 12 h 16 v -12 z');
+ svgParent.appendChild(knob);
+ this.knob_ = knob;
+ var circle = document.createElementNS(Slider.SVG_NS_, 'circle');
+ circle.setAttribute('style', 'opacity: 0');
+ circle.setAttribute('r', this.TARGET_OVERHANG_);
+ circle.setAttribute('cy', y);
+ svgParent.appendChild(circle);
+ this.knobTarget_ = circle;
+ this.setValue(0.5);
+
+ // Find the root SVG object.
+ while (svgParent && svgParent.nodeName.toLowerCase() != 'svg') {
+ svgParent = svgParent.parentNode;
+ }
+ this.SVG_ = svgParent;
+
+ // Bind the events to this slider.
+ Slider.bindEvent_(this.knobTarget_, 'mousedown', this, this.knobMouseDown_);
+ Slider.bindEvent_(this.knobTarget_, 'touchstart', this, this.knobMouseDown_);
+ Slider.bindEvent_(this.trackTarget_, 'mousedown', this, this.rectMouseDown_);
+ Slider.bindEvent_(this.SVG_, 'mouseup', null, Slider.knobMouseUp_);
+ Slider.bindEvent_(this.SVG_, 'touchend', null, Slider.knobMouseUp_);
+ Slider.bindEvent_(this.SVG_, 'mousemove', null, Slider.knobMouseMove_);
+ Slider.bindEvent_(this.SVG_, 'touchmove', null, Slider.knobMouseMove_);
+ Slider.bindEvent_(document, 'mouseover', null, Slider.mouseOver_);
+};
+
+
+Slider.SVG_NS_ = 'http://www.w3.org/2000/svg';
+
+Slider.activeSlider_ = null;
+Slider.startMouseX_ = 0;
+Slider.startKnobX_ = 0;
+
+/**
+ * Start a drag when clicking down on the knob.
+ * @param {!Event} e Mouse-down event.
+ * @private
+ */
+Slider.prototype.knobMouseDown_ = function(e) {
+ if (e.type == 'touchstart') {
+ if (e.changedTouches.length != 1) {
+ return;
+ }
+ Slider.touchToMouse_(e)
+ }
+ Slider.activeSlider_ = this;
+ Slider.startMouseX_ = this.mouseToSvg_(e).x;
+ Slider.startKnobX_ = 0;
+ var transform = this.knob_.getAttribute('transform');
+ if (transform) {
+ var r = transform.match(/translate\(\s*([-\d.]+)/);
+ if (r) {
+ Slider.startKnobX_ = Number(r[1]);
+ }
+ }
+ // Stop browser from attempting to drag the knob or
+ // from scrolling/zooming the page.
+ e.preventDefault();
+};
+
+/**
+ * Stop a drag when clicking up anywhere.
+ * @param {Event} e Mouse-up event.
+ * @private
+ */
+Slider.knobMouseUp_ = function(e) {
+ Slider.activeSlider_ = null;
+};
+
+/**
+ * Stop a drag when the mouse enters a node not part of the SVG.
+ * @param {Event} e Mouse-up event.
+ * @private
+ */
+Slider.mouseOver_ = function(e) {
+ if (!Slider.activeSlider_) {
+ return;
+ }
+ var node = e.target;
+ // Find the root SVG object.
+ do {
+ if (node == Slider.activeSlider_.SVG_) {
+ return;
+ }
+ } while (node = node.parentNode);
+ Slider.knobMouseUp_(e);
+};
+
+/**
+ * Drag the knob to follow the mouse.
+ * @param {!Event} e Mouse-move event.
+ * @private
+ */
+Slider.knobMouseMove_ = function(e) {
+ var thisSlider = Slider.activeSlider_;
+ if (!thisSlider) {
+ return;
+ }
+ if (e.type == 'touchmove') {
+ if (e.changedTouches.length != 1) {
+ return;
+ }
+ Slider.touchToMouse_(e)
+ }
+ var x = thisSlider.mouseToSvg_(e).x - Slider.startMouseX_ +
+ Slider.startKnobX_;
+ thisSlider.setValue((x - thisSlider.KNOB_MIN_X_) /
+ (thisSlider.KNOB_MAX_X_ - thisSlider.KNOB_MIN_X_));
+};
+
+/**
+ * Jump to a new value when the track is clicked.
+ * @param {!Event} e Mouse-down event.
+ * @private
+ */
+Slider.prototype.rectMouseDown_ = function(e) {
+ if (e.type == 'touchstart') {
+ if (e.changedTouches.length != 1) {
+ return;
+ }
+ Slider.touchToMouse_(e)
+ }
+ var x = this.mouseToSvg_(e).x;
+ this.animateValue((x - this.KNOB_MIN_X_) /
+ (this.KNOB_MAX_X_ - this.KNOB_MIN_X_));
+};
+
+/**
+ * Returns the slider's value (0.0 - 1.0).
+ * @return {number} Current value.
+ */
+Slider.prototype.getValue = function() {
+ return this.value_;
+};
+
+/**
+ * Animates the slider's value (0.0 - 1.0).
+ * @param {number} value New value.
+ */
+Slider.prototype.animateValue = function(value) {
+ // Clear any ongoing animations.
+ while (this.animationTasks_.length) {
+ clearTimeout(this.animationTasks_.pop());
+ }
+ var duration = 200; // Milliseconds to animate for.
+ var steps = 10; // Number of steps to animate.
+ var oldValue = this.getValue();
+ var thisSlider = this;
+ var stepFunc = function(i) {
+ return function() {
+ var newVal = i * (value - oldValue) / (steps - 1) + oldValue;
+ thisSlider.setValue(newVal);
+ };
+ }
+ for (var i = 0; i < steps; i++) {
+ this.animationTasks_.push(setTimeout(stepFunc(i), i * duration / steps));
+ }
+};
+
+/**
+ * Sets the slider's value (0.0 - 1.0).
+ * @param {number} value New value.
+ */
+Slider.prototype.setValue = function(value) {
+ this.value_ = Math.min(Math.max(value, 0), 1);
+ var x = this.KNOB_MIN_X_ +
+ (this.KNOB_MAX_X_ - this.KNOB_MIN_X_) * this.value_;
+ this.knob_.setAttribute('transform',
+ 'translate(' + x + ',' + this.KNOB_Y_ + ')');
+ this.knobTarget_.setAttribute('cx', x);
+ this.changeFunc_ && this.changeFunc_(this.value_);
+};
+
+/**
+ * Convert the mouse coordinates into SVG coordinates.
+ * @param {!Object} e Object with x and y mouse coordinates.
+ * @return {!Object} Object with x and y properties in SVG coordinates.
+ * @private
+ */
+Slider.prototype.mouseToSvg_ = function(e) {
+ var svgPoint = this.SVG_.createSVGPoint();
+ svgPoint.x = e.clientX;
+ svgPoint.y = e.clientY;
+ var matrix = this.SVG_.getScreenCTM().inverse();
+ return svgPoint.matrixTransform(matrix);
+};
+
+/**
+ * Bind an event to a function call.
+ * @param {!Node} node Node upon which to listen.
+ * @param {string} name Event name to listen to (e.g. 'mousedown').
+ * @param {Object} thisObject The value of 'this' in the function.
+ * @param {!Function} func Function to call when event is triggered.
+ * @private
+ */
+Slider.bindEvent_ = function(node, name, thisObject, func) {
+ var wrapFunc = function(e) {
+ func.apply(thisObject, arguments);
+ };
+ node.addEventListener(name, wrapFunc, false);
+};
+
+/**
+ * Map the touch event's properties to be compatible with a mouse event.
+ * @param {TouchEvent} e Event to modify.
+ */
+Slider.touchToMouse_ = function(e) {
+ var touchPoint = e.changedTouches[0];
+ e.clientX = touchPoint.clientX;
+ e.clientY = touchPoint.clientY;
+};
diff --git a/blockly/demos/plane/soy/COPYING b/blockly/demos/plane/soy/COPYING
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/blockly/demos/plane/soy/COPYING
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/blockly/demos/plane/soy/README b/blockly/demos/plane/soy/README
new file mode 100644
index 0000000..e3447f2
--- /dev/null
+++ b/blockly/demos/plane/soy/README
@@ -0,0 +1,45 @@
+// Copyright 2009 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+
+Contents:
+
++ SoyToJsSrcCompiler.jar
+ Executable jar that compiles template files into JavaScript files.
+
++ SoyMsgExtractor.jar
+ Executable jar that extracts messages from template files into XLF files.
+
++ soyutils.js
+ Helper utilities required by all JavaScript code that SoyToJsSrcCompiler
+ generates. Equivalent functionality to soyutils_usegoog.js, but this
+ version does not need Closure Library.
+
+
+Instructions:
+
++ A simple Hello World for JavaScript:
+ http://code.google.com/closure/templates/docs/helloworld_js.html
+
++ Complete documentation:
+ http://code.google.com/closure/templates/
+
++ Closure Templates project on Google Code:
+ http://code.google.com/p/closure-templates/
+
+
+Notes:
+
++ Closure Templates requires Java 6 or higher:
+ http://www.java.com/
diff --git a/blockly/demos/plane/soy/SoyMsgExtractor.jar b/blockly/demos/plane/soy/SoyMsgExtractor.jar
new file mode 100644
index 0000000..d7d2619
--- /dev/null
+++ b/blockly/demos/plane/soy/SoyMsgExtractor.jar
Binary files differ
diff --git a/blockly/demos/plane/soy/SoyToJsSrcCompiler.jar b/blockly/demos/plane/soy/SoyToJsSrcCompiler.jar
new file mode 100644
index 0000000..540a070
--- /dev/null
+++ b/blockly/demos/plane/soy/SoyToJsSrcCompiler.jar
Binary files differ
diff --git a/blockly/demos/plane/soy/soyutils.js b/blockly/demos/plane/soy/soyutils.js
new file mode 100644
index 0000000..bde8e41
--- /dev/null
+++ b/blockly/demos/plane/soy/soyutils.js
@@ -0,0 +1,2767 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @fileoverview
+ * Utility functions and classes for Soy.
+ *
+ * <p>
+ * The top portion of this file contains utilities for Soy users:<ul>
+ * <li> soy.StringBuilder: Compatible with the 'stringbuilder' code style.
+ * <li> soy.renderElement: Render template and set as innerHTML of an element.
+ * <li> soy.renderAsFragment: Render template and return as HTML fragment.
+ * </ul>
+ *
+ * <p>
+ * The bottom portion of this file contains utilities that should only be called
+ * by Soy-generated JS code. Please do not use these functions directly from
+ * your hand-writen code. Their names all start with '$$'.
+ *
+ * @author Garrett Boyer
+ * @author Mike Samuel
+ * @author Kai Huang
+ * @author Aharon Lanin
+ */
+
+
+// COPIED FROM nogoog_shim.js
+
+// Create closure namespaces.
+var goog = goog || {};
+
+
+goog.DEBUG = false;
+
+
+goog.inherits = function(childCtor, parentCtor) {
+ /** @constructor */
+ function tempCtor() {}
+ tempCtor.prototype = parentCtor.prototype;
+ childCtor.superClass_ = parentCtor.prototype;
+ childCtor.prototype = new tempCtor();
+ childCtor.prototype.constructor = childCtor;
+};
+
+
+// Just enough browser detection for this file.
+if (!goog.userAgent) {
+ goog.userAgent = (function() {
+ var userAgent = "";
+ if ("undefined" !== typeof navigator && navigator
+ && "string" == typeof navigator.userAgent) {
+ userAgent = navigator.userAgent;
+ }
+ var isOpera = userAgent.indexOf('Opera') == 0;
+ return {
+ jscript: {
+ /**
+ * @type {boolean}
+ */
+ HAS_JSCRIPT: 'ScriptEngine' in this
+ },
+ /**
+ * @type {boolean}
+ */
+ OPERA: isOpera,
+ /**
+ * @type {boolean}
+ */
+ IE: !isOpera && userAgent.indexOf('MSIE') != -1,
+ /**
+ * @type {boolean}
+ */
+ WEBKIT: !isOpera && userAgent.indexOf('WebKit') != -1
+ };
+ })();
+}
+
+if (!goog.asserts) {
+ goog.asserts = {
+ /**
+ * @param {*} condition Condition to check.
+ */
+ assert: function (condition) {
+ if (!condition) {
+ throw Error('Assertion error');
+ }
+ },
+ /**
+ * @param {...*} var_args
+ */
+ fail: function (var_args) {}
+ };
+}
+
+
+// Stub out the document wrapper used by renderAs*.
+if (!goog.dom) {
+ goog.dom = {};
+ /**
+ * @param {Document=} d
+ * @constructor
+ */
+ goog.dom.DomHelper = function(d) {
+ this.document_ = d || document;
+ };
+ /**
+ * @return {!Document}
+ */
+ goog.dom.DomHelper.prototype.getDocument = function() {
+ return this.document_;
+ };
+ /**
+ * Creates a new element.
+ * @param {string} name Tag name.
+ * @return {!Element}
+ */
+ goog.dom.DomHelper.prototype.createElement = function(name) {
+ return this.document_.createElement(name);
+ };
+ /**
+ * Creates a new document fragment.
+ * @return {!DocumentFragment}
+ */
+ goog.dom.DomHelper.prototype.createDocumentFragment = function() {
+ return this.document_.createDocumentFragment();
+ };
+}
+
+
+if (!goog.format) {
+ goog.format = {
+ insertWordBreaks: function(str, maxCharsBetweenWordBreaks) {
+ str = String(str);
+
+ var resultArr = [];
+ var resultArrLen = 0;
+
+ // These variables keep track of important state inside str.
+ var isInTag = false; // whether we're inside an HTML tag
+ var isMaybeInEntity = false; // whether we might be inside an HTML entity
+ var numCharsWithoutBreak = 0; // number of chars since last word break
+ var flushIndex = 0; // index of first char not yet flushed to resultArr
+
+ for (var i = 0, n = str.length; i < n; ++i) {
+ var charCode = str.charCodeAt(i);
+
+ // If hit maxCharsBetweenWordBreaks, and not space next, then add <wbr>.
+ if (numCharsWithoutBreak >= maxCharsBetweenWordBreaks &&
+ // space
+ charCode != 32) {
+ resultArr[resultArrLen++] = str.substring(flushIndex, i);
+ flushIndex = i;
+ resultArr[resultArrLen++] = goog.format.WORD_BREAK;
+ numCharsWithoutBreak = 0;
+ }
+
+ if (isInTag) {
+ // If inside an HTML tag and we see '>', it's the end of the tag.
+ if (charCode == 62) {
+ isInTag = false;
+ }
+
+ } else if (isMaybeInEntity) {
+ switch (charCode) {
+ // Inside an entity, a ';' is the end of the entity.
+ // The entity that just ended counts as one char, so increment
+ // numCharsWithoutBreak.
+ case 59: // ';'
+ isMaybeInEntity = false;
+ ++numCharsWithoutBreak;
+ break;
+ // If maybe inside an entity and we see '<', we weren't actually in
+ // an entity. But now we're inside and HTML tag.
+ case 60: // '<'
+ isMaybeInEntity = false;
+ isInTag = true;
+ break;
+ // If maybe inside an entity and we see ' ', we weren't actually in
+ // an entity. Just correct the state and reset the
+ // numCharsWithoutBreak since we just saw a space.
+ case 32: // ' '
+ isMaybeInEntity = false;
+ numCharsWithoutBreak = 0;
+ break;
+ }
+
+ } else { // !isInTag && !isInEntity
+ switch (charCode) {
+ // When not within a tag or an entity and we see '<', we're now
+ // inside an HTML tag.
+ case 60: // '<'
+ isInTag = true;
+ break;
+ // When not within a tag or an entity and we see '&', we might be
+ // inside an entity.
+ case 38: // '&'
+ isMaybeInEntity = true;
+ break;
+ // When we see a space, reset the numCharsWithoutBreak count.
+ case 32: // ' '
+ numCharsWithoutBreak = 0;
+ break;
+ // When we see a non-space, increment the numCharsWithoutBreak.
+ default:
+ ++numCharsWithoutBreak;
+ break;
+ }
+ }
+ }
+
+ // Flush the remaining chars at the end of the string.
+ resultArr[resultArrLen++] = str.substring(flushIndex);
+
+ return resultArr.join('');
+ },
+ /**
+ * String inserted as a word break by insertWordBreaks(). Safari requires
+ * <wbr></wbr>, Opera needs the 'shy' entity, though this will give a
+ * visible hyphen at breaks. Other browsers just use <wbr>.
+ * @type {string}
+ * @private
+ */
+ WORD_BREAK: goog.userAgent.WEBKIT
+ ? '<wbr></wbr>' : goog.userAgent.OPERA ? '&shy;' : '<wbr>'
+ };
+}
+
+
+if (!goog.i18n) {
+ goog.i18n = {
+ bidi: {
+ /**
+ * Check the directionality of a piece of text, return true if the piece
+ * of text should be laid out in RTL direction.
+ * @param {string} text The piece of text that need to be detected.
+ * @param {boolean=} opt_isHtml Whether {@code text} is HTML/HTML-escaped.
+ * Default: false.
+ * @return {boolean}
+ * @private
+ */
+ detectRtlDirectionality: function(text, opt_isHtml) {
+ text = soyshim.$$bidiStripHtmlIfNecessary_(text, opt_isHtml);
+ return soyshim.$$bidiRtlWordRatio_(text)
+ > soyshim.$$bidiRtlDetectionThreshold_;
+ }
+ }
+ };
+}
+
+/**
+ * Directionality enum.
+ * @enum {number}
+ */
+goog.i18n.bidi.Dir = {
+ RTL: -1,
+ UNKNOWN: 0,
+ LTR: 1
+};
+
+
+/**
+ * Convert a directionality given in various formats to a goog.i18n.bidi.Dir
+ * constant. Useful for interaction with different standards of directionality
+ * representation.
+ *
+ * @param {goog.i18n.bidi.Dir|number|boolean} givenDir Directionality given in
+ * one of the following formats:
+ * 1. A goog.i18n.bidi.Dir constant.
+ * 2. A number (positive = LRT, negative = RTL, 0 = unknown).
+ * 3. A boolean (true = RTL, false = LTR).
+ * @return {goog.i18n.bidi.Dir} A goog.i18n.bidi.Dir constant matching the given
+ * directionality.
+ */
+goog.i18n.bidi.toDir = function(givenDir) {
+ if (typeof givenDir == 'number') {
+ return givenDir > 0 ? goog.i18n.bidi.Dir.LTR :
+ givenDir < 0 ? goog.i18n.bidi.Dir.RTL : goog.i18n.bidi.Dir.UNKNOWN;
+ } else {
+ return givenDir ? goog.i18n.bidi.Dir.RTL : goog.i18n.bidi.Dir.LTR;
+ }
+};
+
+
+/**
+ * Utility class for formatting text for display in a potentially
+ * opposite-directionality context without garbling. Provides the following
+ * functionality:
+ *
+ * @param {goog.i18n.bidi.Dir|number|boolean} dir The context
+ * directionality as a number
+ * (positive = LRT, negative = RTL, 0 = unknown).
+ * @constructor
+ */
+goog.i18n.BidiFormatter = function(dir) {
+ this.dir_ = goog.i18n.bidi.toDir(dir);
+};
+
+
+/**
+ * Returns 'dir="ltr"' or 'dir="rtl"', depending on {@code text}'s estimated
+ * directionality, if it is not the same as the context directionality.
+ * Otherwise, returns the empty string.
+ *
+ * @param {string} text Text whose directionality is to be estimated.
+ * @param {boolean=} opt_isHtml Whether {@code text} is HTML / HTML-escaped.
+ * Default: false.
+ * @return {string} 'dir="rtl"' for RTL text in non-RTL context; 'dir="ltr"' for
+ * LTR text in non-LTR context; else, the empty string.
+ */
+goog.i18n.BidiFormatter.prototype.dirAttr = function (text, opt_isHtml) {
+ var dir = soy.$$bidiTextDir(text, opt_isHtml);
+ return dir && dir != this.dir_ ? dir < 0 ? 'dir="rtl"' : 'dir="ltr"' : '';
+};
+
+/**
+ * Returns the trailing horizontal edge, i.e. "right" or "left", depending on
+ * the global bidi directionality.
+ * @return {string} "left" for RTL context and "right" otherwise.
+ */
+goog.i18n.BidiFormatter.prototype.endEdge = function () {
+ return this.dir_ < 0 ? 'left' : 'right';
+};
+
+/**
+ * Returns the Unicode BiDi mark matching the context directionality (LRM for
+ * LTR context directionality, RLM for RTL context directionality), or the
+ * empty string for neutral / unknown context directionality.
+ *
+ * @return {string} LRM for LTR context directionality and RLM for RTL context
+ * directionality.
+ */
+goog.i18n.BidiFormatter.prototype.mark = function () {
+ return (
+ (this.dir_ > 0) ? '\u200E' /*LRM*/ :
+ (this.dir_ < 0) ? '\u200F' /*RLM*/ :
+ '');
+};
+
+/**
+ * Returns a Unicode BiDi mark matching the context directionality (LRM or RLM)
+ * if the directionality or the exit directionality of {@code text} are opposite
+ * to the context directionality. Otherwise returns the empty string.
+ *
+ * @param {string} text The input text.
+ * @param {boolean=} opt_isHtml Whether {@code text} is HTML / HTML-escaped.
+ * Default: false.
+ * @return {string} A Unicode bidi mark matching the global directionality or
+ * the empty string.
+ */
+goog.i18n.BidiFormatter.prototype.markAfter = function (text, opt_isHtml) {
+ var dir = soy.$$bidiTextDir(text, opt_isHtml);
+ return soyshim.$$bidiMarkAfterKnownDir_(this.dir_, dir, text, opt_isHtml);
+};
+
+/**
+ * Formats a string of unknown directionality for use in HTML output of the
+ * context directionality, so an opposite-directionality string is neither
+ * garbled nor garbles what follows it.
+ *
+ * @param {string} str The input text.
+ * @param {boolean=} placeholder This argument exists for consistency with the
+ * Closure Library. Specifying it has no effect.
+ * @return {string} Input text after applying the above processing.
+ */
+goog.i18n.BidiFormatter.prototype.spanWrap = function(str, placeholder) {
+ str = String(str);
+ var textDir = soy.$$bidiTextDir(str, true);
+ var reset = soyshim.$$bidiMarkAfterKnownDir_(this.dir_, textDir, str, true);
+ if (textDir > 0 && this.dir_ <= 0) {
+ str = '<span dir="ltr">' + str + '</span>';
+ } else if (textDir < 0 && this.dir_ >= 0) {
+ str = '<span dir="rtl">' + str + '</span>';
+ }
+ return str + reset;
+};
+
+/**
+ * Returns the leading horizontal edge, i.e. "left" or "right", depending on
+ * the global bidi directionality.
+ * @return {string} "right" for RTL context and "left" otherwise.
+ */
+goog.i18n.BidiFormatter.prototype.startEdge = function () {
+ return this.dir_ < 0 ? 'right' : 'left';
+};
+
+/**
+ * Formats a string of unknown directionality for use in plain-text output of
+ * the context directionality, so an opposite-directionality string is neither
+ * garbled nor garbles what follows it.
+ * As opposed to {@link #spanWrap}, this makes use of unicode BiDi formatting
+ * characters. In HTML, its *only* valid use is inside of elements that do not
+ * allow mark-up, e.g. an 'option' tag.
+ *
+ * @param {string} str The input text.
+ * @param {boolean=} placeholder This argument exists for consistency with the
+ * Closure Library. Specifying it has no effect.
+ * @return {string} Input text after applying the above processing.
+ */
+goog.i18n.BidiFormatter.prototype.unicodeWrap = function(str, placeholder) {
+ str = String(str);
+ var textDir = soy.$$bidiTextDir(str, true);
+ var reset = soyshim.$$bidiMarkAfterKnownDir_(this.dir_, textDir, str, true);
+ if (textDir > 0 && this.dir_ <= 0) {
+ str = '\u202A' + str + '\u202C';
+ } else if (textDir < 0 && this.dir_ >= 0) {
+ str = '\u202B' + str + '\u202C';
+ }
+ return str + reset;
+};
+
+
+if (!goog.string) {
+ goog.string = {
+ /**
+ * Converts \r\n, \r, and \n to <br>s
+ * @param {*} str The string in which to convert newlines.
+ * @param {boolean=} opt_xml Whether to use XML compatible tags.
+ * @return {string} A copy of {@code str} with converted newlines.
+ */
+ newLineToBr: function(str, opt_xml) {
+
+ str = String(str);
+
+ // This quick test helps in the case when there are no chars to replace,
+ // in the worst case this makes barely a difference to the time taken.
+ if (!goog.string.NEWLINE_TO_BR_RE_.test(str)) {
+ return str;
+ }
+
+ return str.replace(/(\r\n|\r|\n)/g, opt_xml ? '<br />' : '<br>');
+ },
+ urlEncode: encodeURIComponent,
+ /**
+ * Regular expression used within newlineToBr().
+ * @type {RegExp}
+ * @private
+ */
+ NEWLINE_TO_BR_RE_: /[\r\n]/
+ };
+}
+
+/**
+ * Utility class to facilitate much faster string concatenation in IE,
+ * using Array.join() rather than the '+' operator. For other browsers
+ * we simply use the '+' operator.
+ *
+ * @param {Object|number|string|boolean=} opt_a1 Optional first initial item
+ * to append.
+ * @param {...Object|number|string|boolean} var_args Other initial items to
+ * append, e.g., new goog.string.StringBuffer('foo', 'bar').
+ * @constructor
+ */
+goog.string.StringBuffer = function(opt_a1, var_args) {
+ /**
+ * Internal buffer for the string to be concatenated.
+ * @type {string|Array}
+ * @private
+ */
+ this.buffer_ = goog.userAgent.jscript.HAS_JSCRIPT ? [] : '';
+
+ if (opt_a1 != null) {
+ this.append.apply(this, arguments);
+ }
+};
+
+
+/**
+ * Length of internal buffer (faster than calling buffer_.length).
+ * Only used for IE.
+ * @type {number}
+ * @private
+ */
+goog.string.StringBuffer.prototype.bufferLength_ = 0;
+
+/**
+ * Appends one or more items to the string.
+ *
+ * Calling this with null, undefined, or empty arguments is an error.
+ *
+ * @param {Object|number|string|boolean} a1 Required first string.
+ * @param {Object|number|string|boolean=} opt_a2 Optional second string.
+ * @param {...Object|number|string|boolean} var_args Other items to append,
+ * e.g., sb.append('foo', 'bar', 'baz').
+ * @return {goog.string.StringBuffer} This same StringBuilder object.
+ */
+goog.string.StringBuffer.prototype.append = function(a1, opt_a2, var_args) {
+
+ if (goog.userAgent.jscript.HAS_JSCRIPT) {
+ if (opt_a2 == null) { // no second argument (note: undefined == null)
+ // Array assignment is 2x faster than Array push. Also, use a1
+ // directly to avoid arguments instantiation, another 2x improvement.
+ this.buffer_[this.bufferLength_++] = a1;
+ } else {
+ var arr = /**@type {Array.<number|string|boolean>}*/(this.buffer_);
+ arr.push.apply(arr, arguments);
+ this.bufferLength_ = this.buffer_.length;
+ }
+
+ } else {
+
+ // Use a1 directly to avoid arguments instantiation for single-arg case.
+ this.buffer_ += a1;
+ if (opt_a2 != null) { // no second argument (note: undefined == null)
+ for (var i = 1; i < arguments.length; i++) {
+ this.buffer_ += arguments[i];
+ }
+ }
+ }
+
+ return this;
+};
+
+
+/**
+ * Clears the string.
+ */
+goog.string.StringBuffer.prototype.clear = function() {
+
+ if (goog.userAgent.jscript.HAS_JSCRIPT) {
+ this.buffer_.length = 0; // reuse array to avoid creating new object
+ this.bufferLength_ = 0;
+
+ } else {
+ this.buffer_ = '';
+ }
+};
+
+
+/**
+ * Returns the concatenated string.
+ *
+ * @return {string} The concatenated string.
+ */
+goog.string.StringBuffer.prototype.toString = function() {
+
+ if (goog.userAgent.jscript.HAS_JSCRIPT) {
+ var str = this.buffer_.join('');
+ // Given a string with the entire contents, simplify the StringBuilder by
+ // setting its contents to only be this string, rather than many fragments.
+ this.clear();
+ if (str) {
+ this.append(str);
+ }
+ return str;
+
+ } else {
+ return /** @type {string} */ (this.buffer_);
+ }
+};
+
+
+if (!goog.soy) goog.soy = {
+ /**
+ * Helper function to render a Soy template and then set the
+ * output string as the innerHTML of an element. It is recommended
+ * to use this helper function instead of directly setting
+ * innerHTML in your hand-written code, so that it will be easier
+ * to audit the code for cross-site scripting vulnerabilities.
+ *
+ * @param {Function} template The Soy template defining element's content.
+ * @param {Object=} opt_templateData The data for the template.
+ * @param {Object=} opt_injectedData The injected data for the template.
+ * @param {(goog.dom.DomHelper|Document)=} opt_dom The context in which DOM
+ * nodes will be created.
+ */
+ renderAsElement: function(
+ template, opt_templateData, opt_injectedData, opt_dom) {
+ return /** @type {!Element} */ (soyshim.$$renderWithWrapper_(
+ template, opt_templateData, opt_dom, true /* asElement */,
+ opt_injectedData));
+ },
+ /**
+ * Helper function to render a Soy template into a single node or
+ * a document fragment. If the rendered HTML string represents a
+ * single node, then that node is returned (note that this is
+ * *not* a fragment, despite them name of the method). Otherwise a
+ * document fragment is returned containing the rendered nodes.
+ *
+ * @param {Function} template The Soy template defining element's content.
+ * @param {Object=} opt_templateData The data for the template.
+ * @param {Object=} opt_injectedData The injected data for the template.
+ * @param {(goog.dom.DomHelper|Document)=} opt_dom The context in which DOM
+ * nodes will be created.
+ * @return {!Node} The resulting node or document fragment.
+ */
+ renderAsFragment: function(
+ template, opt_templateData, opt_injectedData, opt_dom) {
+ return soyshim.$$renderWithWrapper_(
+ template, opt_templateData, opt_dom, false /* asElement */,
+ opt_injectedData);
+ },
+ /**
+ * Helper function to render a Soy template and then set the output string as
+ * the innerHTML of an element. It is recommended to use this helper function
+ * instead of directly setting innerHTML in your hand-written code, so that it
+ * will be easier to audit the code for cross-site scripting vulnerabilities.
+ *
+ * NOTE: New code should consider using goog.soy.renderElement instead.
+ *
+ * @param {Element} element The element whose content we are rendering.
+ * @param {Function} template The Soy template defining the element's content.
+ * @param {Object=} opt_templateData The data for the template.
+ * @param {Object=} opt_injectedData The injected data for the template.
+ */
+ renderElement: function(
+ element, template, opt_templateData, opt_injectedData) {
+ element.innerHTML = template(opt_templateData, null, opt_injectedData);
+ },
+ data: {}
+};
+
+
+/**
+ * A type of textual content.
+ *
+ * This is an enum of type Object so that these values are unforgeable.
+ *
+ * @enum {!Object}
+ */
+goog.soy.data.SanitizedContentKind = {
+
+ /**
+ * A snippet of HTML that does not start or end inside a tag, comment, entity,
+ * or DOCTYPE; and that does not contain any executable code
+ * (JS, {@code <object>}s, etc.) from a different trust domain.
+ */
+ HTML: {},
+
+ /**
+ * Executable Javascript code or expression, safe for insertion in a
+ * script-tag or event handler context, known to be free of any
+ * attacker-controlled scripts. This can either be side-effect-free
+ * Javascript (such as JSON) or Javascript that entirely under Google's
+ * control.
+ */
+ JS: goog.DEBUG ? {sanitizedContentJsStrChars: true} : {},
+
+ /**
+ * A sequence of code units that can appear between quotes (either kind) in a
+ * JS program without causing a parse error, and without causing any side
+ * effects.
+ * <p>
+ * The content should not contain unescaped quotes, newlines, or anything else
+ * that would cause parsing to fail or to cause a JS parser to finish the
+ * string its parsing inside the content.
+ * <p>
+ * The content must also not end inside an escape sequence ; no partial octal
+ * escape sequences or odd number of '{@code \}'s at the end.
+ */
+ JS_STR_CHARS: {},
+
+ /** A properly encoded portion of a URI. */
+ URI: {},
+
+ /**
+ * Repeated attribute names and values. For example,
+ * {@code dir="ltr" foo="bar" onclick="trustedFunction()" checked}.
+ */
+ ATTRIBUTES: goog.DEBUG ? {sanitizedContentHtmlAttribute: true} : {},
+
+ // TODO: Consider separating rules, declarations, and values into
+ // separate types, but for simplicity, we'll treat explicitly blessed
+ // SanitizedContent as allowed in all of these contexts.
+ /**
+ * A CSS3 declaration, property, value or group of semicolon separated
+ * declarations.
+ */
+ CSS: {},
+
+ /**
+ * Unsanitized plain-text content.
+ *
+ * This is effectively the "null" entry of this enum, and is sometimes used
+ * to explicitly mark content that should never be used unescaped. Since any
+ * string is safe to use as text, being of ContentKind.TEXT makes no
+ * guarantees about its safety in any other context such as HTML.
+ */
+ TEXT: {}
+};
+
+
+
+/**
+ * A string-like object that carries a content-type.
+ *
+ * IMPORTANT! Do not create these directly, nor instantiate the subclasses.
+ * Instead, use a trusted, centrally reviewed library as endorsed by your team
+ * to generate these objects. Otherwise, you risk accidentally creating
+ * SanitizedContent that is attacker-controlled and gets evaluated unescaped in
+ * templates.
+ *
+ * @constructor
+ */
+goog.soy.data.SanitizedContent = function() {
+ throw Error('Do not instantiate directly');
+};
+
+
+/**
+ * The context in which this content is safe from XSS attacks.
+ * @type {goog.soy.data.SanitizedContentKind}
+ */
+goog.soy.data.SanitizedContent.prototype.contentKind;
+
+
+/**
+ * The already-safe content.
+ * @type {string}
+ */
+goog.soy.data.SanitizedContent.prototype.content;
+
+
+/** @override */
+goog.soy.data.SanitizedContent.prototype.toString = function() {
+ return this.content;
+};
+
+
+var soy = { esc: {} };
+var soydata = {};
+soydata.VERY_UNSAFE = {};
+var soyshim = { $$DEFAULT_TEMPLATE_DATA_: {} };
+/**
+ * Helper function to render a Soy template into a single node or a document
+ * fragment. If the rendered HTML string represents a single node, then that
+ * node is returned. Otherwise a document fragment is created and returned
+ * (wrapped in a DIV element if #opt_singleNode is true).
+ *
+ * @param {Function} template The Soy template defining the element's content.
+ * @param {Object=} opt_templateData The data for the template.
+ * @param {(goog.dom.DomHelper|Document)=} opt_dom The context in which DOM
+ * nodes will be created.
+ * @param {boolean=} opt_asElement Whether to wrap the fragment in an
+ * element if the template does not render a single element. If true,
+ * result is always an Element.
+ * @param {Object=} opt_injectedData The injected data for the template.
+ * @return {!Node} The resulting node or document fragment.
+ * @private
+ */
+soyshim.$$renderWithWrapper_ = function(
+ template, opt_templateData, opt_dom, opt_asElement, opt_injectedData) {
+
+ var dom = opt_dom || document;
+ var wrapper = dom.createElement('div');
+ wrapper.innerHTML = template(
+ opt_templateData || soyshim.$$DEFAULT_TEMPLATE_DATA_, undefined,
+ opt_injectedData);
+
+ // If the template renders as a single element, return it.
+ if (wrapper.childNodes.length == 1) {
+ var firstChild = wrapper.firstChild;
+ if (!opt_asElement || firstChild.nodeType == 1 /* Element */) {
+ return /** @type {!Node} */ (firstChild);
+ }
+ }
+
+ // If we're forcing it to be a single element, return the wrapper DIV.
+ if (opt_asElement) {
+ return wrapper;
+ }
+
+ // Otherwise, create and return a fragment.
+ var fragment = dom.createDocumentFragment();
+ while (wrapper.firstChild) {
+ fragment.appendChild(wrapper.firstChild);
+ }
+ return fragment;
+};
+
+
+/**
+ * Returns a Unicode BiDi mark matching bidiGlobalDir (LRM or RLM) if the
+ * directionality or the exit directionality of text are opposite to
+ * bidiGlobalDir. Otherwise returns the empty string.
+ * If opt_isHtml, makes sure to ignore the LTR nature of the mark-up and escapes
+ * in text, making the logic suitable for HTML and HTML-escaped text.
+ * @param {number} bidiGlobalDir The global directionality context: 1 if ltr, -1
+ * if rtl, 0 if unknown.
+ * @param {number} dir text's directionality: 1 if ltr, -1 if rtl, 0 if unknown.
+ * @param {string} text The text whose directionality is to be estimated.
+ * @param {boolean=} opt_isHtml Whether text is HTML/HTML-escaped.
+ * Default: false.
+ * @return {string} A Unicode bidi mark matching bidiGlobalDir, or
+ * the empty string when text's overall and exit directionalities both match
+ * bidiGlobalDir, or bidiGlobalDir is 0 (unknown).
+ * @private
+ */
+soyshim.$$bidiMarkAfterKnownDir_ = function(
+ bidiGlobalDir, dir, text, opt_isHtml) {
+ return (
+ bidiGlobalDir > 0 && (dir < 0 ||
+ soyshim.$$bidiIsRtlExitText_(text, opt_isHtml)) ? '\u200E' : // LRM
+ bidiGlobalDir < 0 && (dir > 0 ||
+ soyshim.$$bidiIsLtrExitText_(text, opt_isHtml)) ? '\u200F' : // RLM
+ '');
+};
+
+
+/**
+ * Strips str of any HTML mark-up and escapes. Imprecise in several ways, but
+ * precision is not very important, since the result is only meant to be used
+ * for directionality detection.
+ * @param {string} str The string to be stripped.
+ * @param {boolean=} opt_isHtml Whether str is HTML / HTML-escaped.
+ * Default: false.
+ * @return {string} The stripped string.
+ * @private
+ */
+soyshim.$$bidiStripHtmlIfNecessary_ = function(str, opt_isHtml) {
+ return opt_isHtml ? str.replace(soyshim.$$BIDI_HTML_SKIP_RE_, ' ') : str;
+};
+
+
+/**
+ * Simplified regular expression for am HTML tag (opening or closing) or an HTML
+ * escape - the things we want to skip over in order to ignore their ltr
+ * characters.
+ * @type {RegExp}
+ * @private
+ */
+soyshim.$$BIDI_HTML_SKIP_RE_ = /<[^>]*>|&[^;]+;/g;
+
+
+/**
+ * A practical pattern to identify strong LTR character. This pattern is not
+ * theoretically correct according to unicode standard. It is simplified for
+ * performance and small code size.
+ * @type {string}
+ * @private
+ */
+soyshim.$$bidiLtrChars_ =
+ 'A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02B8\u0300-\u0590\u0800-\u1FFF' +
+ '\u2C00-\uFB1C\uFDFE-\uFE6F\uFEFD-\uFFFF';
+
+
+/**
+ * A practical pattern to identify strong neutral and weak character. This
+ * pattern is not theoretically correct according to unicode standard. It is
+ * simplified for performance and small code size.
+ * @type {string}
+ * @private
+ */
+soyshim.$$bidiNeutralChars_ =
+ '\u0000-\u0020!-@[-`{-\u00BF\u00D7\u00F7\u02B9-\u02FF\u2000-\u2BFF';
+
+
+/**
+ * A practical pattern to identify strong RTL character. This pattern is not
+ * theoretically correct according to unicode standard. It is simplified for
+ * performance and small code size.
+ * @type {string}
+ * @private
+ */
+soyshim.$$bidiRtlChars_ = '\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC';
+
+
+/**
+ * Regular expressions to check if a piece of text is of RTL directionality
+ * on first character with strong directionality.
+ * @type {RegExp}
+ * @private
+ */
+soyshim.$$bidiRtlDirCheckRe_ = new RegExp(
+ '^[^' + soyshim.$$bidiLtrChars_ + ']*[' + soyshim.$$bidiRtlChars_ + ']');
+
+
+/**
+ * Regular expressions to check if a piece of text is of neutral directionality.
+ * Url are considered as neutral.
+ * @type {RegExp}
+ * @private
+ */
+soyshim.$$bidiNeutralDirCheckRe_ = new RegExp(
+ '^[' + soyshim.$$bidiNeutralChars_ + ']*$|^http://');
+
+
+/**
+ * Check the directionality of the a piece of text based on the first character
+ * with strong directionality.
+ * @param {string} str string being checked.
+ * @return {boolean} return true if rtl directionality is being detected.
+ * @private
+ */
+soyshim.$$bidiIsRtlText_ = function(str) {
+ return soyshim.$$bidiRtlDirCheckRe_.test(str);
+};
+
+
+/**
+ * Check the directionality of the a piece of text based on the first character
+ * with strong directionality.
+ * @param {string} str string being checked.
+ * @return {boolean} true if all characters have neutral directionality.
+ * @private
+ */
+soyshim.$$bidiIsNeutralText_ = function(str) {
+ return soyshim.$$bidiNeutralDirCheckRe_.test(str);
+};
+
+
+/**
+ * This constant controls threshold of rtl directionality.
+ * @type {number}
+ * @private
+ */
+soyshim.$$bidiRtlDetectionThreshold_ = 0.40;
+
+
+/**
+ * Returns the RTL ratio based on word count.
+ * @param {string} str the string that need to be checked.
+ * @return {number} the ratio of RTL words among all words with directionality.
+ * @private
+ */
+soyshim.$$bidiRtlWordRatio_ = function(str) {
+ var rtlCount = 0;
+ var totalCount = 0;
+ var tokens = str.split(' ');
+ for (var i = 0; i < tokens.length; i++) {
+ if (soyshim.$$bidiIsRtlText_(tokens[i])) {
+ rtlCount++;
+ totalCount++;
+ } else if (!soyshim.$$bidiIsNeutralText_(tokens[i])) {
+ totalCount++;
+ }
+ }
+
+ return totalCount == 0 ? 0 : rtlCount / totalCount;
+};
+
+
+/**
+ * Regular expressions to check if the last strongly-directional character in a
+ * piece of text is LTR.
+ * @type {RegExp}
+ * @private
+ */
+soyshim.$$bidiLtrExitDirCheckRe_ = new RegExp(
+ '[' + soyshim.$$bidiLtrChars_ + '][^' + soyshim.$$bidiRtlChars_ + ']*$');
+
+
+/**
+ * Regular expressions to check if the last strongly-directional character in a
+ * piece of text is RTL.
+ * @type {RegExp}
+ * @private
+ */
+soyshim.$$bidiRtlExitDirCheckRe_ = new RegExp(
+ '[' + soyshim.$$bidiRtlChars_ + '][^' + soyshim.$$bidiLtrChars_ + ']*$');
+
+
+/**
+ * Check if the exit directionality a piece of text is LTR, i.e. if the last
+ * strongly-directional character in the string is LTR.
+ * @param {string} str string being checked.
+ * @param {boolean=} opt_isHtml Whether str is HTML / HTML-escaped.
+ * Default: false.
+ * @return {boolean} Whether LTR exit directionality was detected.
+ * @private
+ */
+soyshim.$$bidiIsLtrExitText_ = function(str, opt_isHtml) {
+ str = soyshim.$$bidiStripHtmlIfNecessary_(str, opt_isHtml);
+ return soyshim.$$bidiLtrExitDirCheckRe_.test(str);
+};
+
+
+/**
+ * Check if the exit directionality a piece of text is RTL, i.e. if the last
+ * strongly-directional character in the string is RTL.
+ * @param {string} str string being checked.
+ * @param {boolean=} opt_isHtml Whether str is HTML / HTML-escaped.
+ * Default: false.
+ * @return {boolean} Whether RTL exit directionality was detected.
+ * @private
+ */
+soyshim.$$bidiIsRtlExitText_ = function(str, opt_isHtml) {
+ str = soyshim.$$bidiStripHtmlIfNecessary_(str, opt_isHtml);
+ return soyshim.$$bidiRtlExitDirCheckRe_.test(str);
+};
+
+
+// =============================================================================
+// COPIED FROM soyutils_usegoog.js
+
+
+// -----------------------------------------------------------------------------
+// StringBuilder (compatible with the 'stringbuilder' code style).
+
+
+/**
+ * Utility class to facilitate much faster string concatenation in IE,
+ * using Array.join() rather than the '+' operator. For other browsers
+ * we simply use the '+' operator.
+ *
+ * @param {Object} var_args Initial items to append,
+ * e.g., new soy.StringBuilder('foo', 'bar').
+ * @constructor
+ */
+soy.StringBuilder = goog.string.StringBuffer;
+
+
+// -----------------------------------------------------------------------------
+// soydata: Defines typed strings, e.g. an HTML string {@code "a<b>c"} is
+// semantically distinct from the plain text string {@code "a<b>c"} and smart
+// templates can take that distinction into account.
+
+/**
+ * A type of textual content.
+ *
+ * This is an enum of type Object so that these values are unforgeable.
+ *
+ * @enum {!Object}
+ */
+soydata.SanitizedContentKind = goog.soy.data.SanitizedContentKind;
+
+
+/**
+ * Content of type {@link soydata.SanitizedContentKind.HTML}.
+ *
+ * The content is a string of HTML that can safely be embedded in a PCDATA
+ * context in your app. If you would be surprised to find that an HTML
+ * sanitizer produced {@code s} (e.g. it runs code or fetches bad URLs) and
+ * you wouldn't write a template that produces {@code s} on security or privacy
+ * grounds, then don't pass {@code s} here.
+ *
+ * @constructor
+ * @extends {goog.soy.data.SanitizedContent}
+ */
+soydata.SanitizedHtml = function() {
+ goog.soy.data.SanitizedContent.call(this); // Throws an exception.
+};
+goog.inherits(soydata.SanitizedHtml, goog.soy.data.SanitizedContent);
+
+/** @override */
+soydata.SanitizedHtml.prototype.contentKind = soydata.SanitizedContentKind.HTML;
+
+
+/**
+ * Content of type {@link soydata.SanitizedContentKind.JS}.
+ *
+ * The content is Javascript source that when evaluated does not execute any
+ * attacker-controlled scripts.
+ *
+ * @constructor
+ * @extends {goog.soy.data.SanitizedContent}
+ */
+soydata.SanitizedJs = function() {
+ goog.soy.data.SanitizedContent.call(this); // Throws an exception.
+};
+goog.inherits(soydata.SanitizedJs, goog.soy.data.SanitizedContent);
+
+/** @override */
+soydata.SanitizedJs.prototype.contentKind =
+ soydata.SanitizedContentKind.JS;
+
+
+/**
+ * Content of type {@link soydata.SanitizedContentKind.JS_STR_CHARS}.
+ *
+ * The content can be safely inserted as part of a single- or double-quoted
+ * string without terminating the string.
+ *
+ * @constructor
+ * @extends {goog.soy.data.SanitizedContent}
+ */
+soydata.SanitizedJsStrChars = function() {
+ goog.soy.data.SanitizedContent.call(this); // Throws an exception.
+};
+goog.inherits(soydata.SanitizedJsStrChars, goog.soy.data.SanitizedContent);
+
+/** @override */
+soydata.SanitizedJsStrChars.prototype.contentKind =
+ soydata.SanitizedContentKind.JS_STR_CHARS;
+
+
+/**
+ * Content of type {@link soydata.SanitizedContentKind.URI}.
+ *
+ * The content is a URI chunk that the caller knows is safe to emit in a
+ * template.
+ *
+ * @constructor
+ * @extends {goog.soy.data.SanitizedContent}
+ */
+soydata.SanitizedUri = function() {
+ goog.soy.data.SanitizedContent.call(this); // Throws an exception.
+};
+goog.inherits(soydata.SanitizedUri, goog.soy.data.SanitizedContent);
+
+/** @override */
+soydata.SanitizedUri.prototype.contentKind = soydata.SanitizedContentKind.URI;
+
+
+/**
+ * Content of type {@link soydata.SanitizedContentKind.ATTRIBUTES}.
+ *
+ * The content should be safely embeddable within an open tag, such as a
+ * key="value" pair.
+ *
+ * @constructor
+ * @extends {goog.soy.data.SanitizedContent}
+ */
+soydata.SanitizedHtmlAttribute = function() {
+ goog.soy.data.SanitizedContent.call(this); // Throws an exception.
+};
+goog.inherits(soydata.SanitizedHtmlAttribute, goog.soy.data.SanitizedContent);
+
+/** @override */
+soydata.SanitizedHtmlAttribute.prototype.contentKind =
+ soydata.SanitizedContentKind.ATTRIBUTES;
+
+
+/**
+ * Content of type {@link soydata.SanitizedContentKind.CSS}.
+ *
+ * The content is non-attacker-exploitable CSS, such as {@code color:#c3d9ff}.
+ *
+ * @constructor
+ * @extends {goog.soy.data.SanitizedContent}
+ */
+soydata.SanitizedCss = function() {
+ goog.soy.data.SanitizedContent.call(this); // Throws an exception.
+};
+goog.inherits(soydata.SanitizedCss, goog.soy.data.SanitizedContent);
+
+/** @override */
+soydata.SanitizedCss.prototype.contentKind =
+ soydata.SanitizedContentKind.CSS;
+
+
+/**
+ * Unsanitized plain text string.
+ *
+ * While all strings are effectively safe to use as a plain text, there are no
+ * guarantees about safety in any other context such as HTML. This is
+ * sometimes used to mark that should never be used unescaped.
+ *
+ * @param {*} content Plain text with no guarantees.
+ * @constructor
+ * @extends {goog.soy.data.SanitizedContent}
+ */
+soydata.UnsanitizedText = function(content) {
+ /** @override */
+ this.content = String(content);
+};
+goog.inherits(soydata.UnsanitizedText, goog.soy.data.SanitizedContent);
+
+/** @override */
+soydata.UnsanitizedText.prototype.contentKind =
+ soydata.SanitizedContentKind.TEXT;
+
+
+/**
+ * Creates a factory for SanitizedContent types.
+ *
+ * This is a hack so that the soydata.VERY_UNSAFE.ordainSanitized* can
+ * instantiate Sanitized* classes, without making the Sanitized* constructors
+ * publicly usable. Requiring all construction to use the VERY_UNSAFE names
+ * helps callers and their reviewers easily tell that creating SanitizedContent
+ * is not always safe and calls for careful review.
+ *
+ * @param {function(new: T, string)} ctor A constructor.
+ * @return {!function(*): T} A factory that takes content and returns a
+ * new instance.
+ * @template T
+ * @private
+ */
+soydata.$$makeSanitizedContentFactory_ = function(ctor) {
+ /** @constructor */
+ function InstantiableCtor() {}
+ InstantiableCtor.prototype = ctor.prototype;
+ return function(content) {
+ var result = new InstantiableCtor();
+ result.content = String(content);
+ return result;
+ };
+};
+
+
+// -----------------------------------------------------------------------------
+// Sanitized content ordainers. Please use these with extreme caution (with the
+// exception of markUnsanitizedText). A good recommendation is to limit usage
+// of these to just a handful of files in your source tree where usages can be
+// carefully audited.
+
+
+/**
+ * Protects a string from being used in an noAutoescaped context.
+ *
+ * This is useful for content where there is significant risk of accidental
+ * unescaped usage in a Soy template. A great case is for user-controlled
+ * data that has historically been a source of vulernabilities.
+ *
+ * @param {*} content Text to protect.
+ * @return {!soydata.UnsanitizedText} A wrapper that is rejected by the
+ * Soy noAutoescape print directive.
+ */
+soydata.markUnsanitizedText = function(content) {
+ return new soydata.UnsanitizedText(content);
+};
+
+
+/**
+ * Takes a leap of faith that the provided content is "safe" HTML.
+ *
+ * @param {*} content A string of HTML that can safely be embedded in
+ * a PCDATA context in your app. If you would be surprised to find that an
+ * HTML sanitizer produced {@code s} (e.g. it runs code or fetches bad URLs)
+ * and you wouldn't write a template that produces {@code s} on security or
+ * privacy grounds, then don't pass {@code s} here.
+ * @return {!soydata.SanitizedHtml} Sanitized content wrapper that
+ * indicates to Soy not to escape when printed as HTML.
+ */
+soydata.VERY_UNSAFE.ordainSanitizedHtml =
+ soydata.$$makeSanitizedContentFactory_(soydata.SanitizedHtml);
+
+
+/**
+ * Takes a leap of faith that the provided content is "safe" (non-attacker-
+ * controlled, XSS-free) Javascript.
+ *
+ * @param {*} content Javascript source that when evaluated does not
+ * execute any attacker-controlled scripts.
+ * @return {!soydata.SanitizedJs} Sanitized content wrapper that indicates to
+ * Soy not to escape when printed as Javascript source.
+ */
+soydata.VERY_UNSAFE.ordainSanitizedJs =
+ soydata.$$makeSanitizedContentFactory_(soydata.SanitizedJs);
+
+
+// TODO: This function is probably necessary, either externally or internally
+// as an implementation detail. Generally, plain text will always work here,
+// as there's no harm to unescaping the string and then re-escaping when
+// finally printed.
+/**
+ * Takes a leap of faith that the provided content can be safely embedded in
+ * a Javascript string without re-esacping.
+ *
+ * @param {*} content Content that can be safely inserted as part of a
+ * single- or double-quoted string without terminating the string.
+ * @return {!soydata.SanitizedJsStrChars} Sanitized content wrapper that
+ * indicates to Soy not to escape when printed in a JS string.
+ */
+soydata.VERY_UNSAFE.ordainSanitizedJsStrChars =
+ soydata.$$makeSanitizedContentFactory_(soydata.SanitizedJsStrChars);
+
+
+/**
+ * Takes a leap of faith that the provided content is "safe" to use as a URI
+ * in a Soy template.
+ *
+ * This creates a Soy SanitizedContent object which indicates to Soy there is
+ * no need to escape it when printed as a URI (e.g. in an href or src
+ * attribute), such as if it's already been encoded or if it's a Javascript:
+ * URI.
+ *
+ * @param {*} content A chunk of URI that the caller knows is safe to
+ * emit in a template.
+ * @return {!soydata.SanitizedUri} Sanitized content wrapper that indicates to
+ * Soy not to escape or filter when printed in URI context.
+ */
+soydata.VERY_UNSAFE.ordainSanitizedUri =
+ soydata.$$makeSanitizedContentFactory_(soydata.SanitizedUri);
+
+
+/**
+ * Takes a leap of faith that the provided content is "safe" to use as an
+ * HTML attribute.
+ *
+ * @param {*} content An attribute name and value, such as
+ * {@code dir="ltr"}.
+ * @return {!soydata.SanitizedHtmlAttribute} Sanitized content wrapper that
+ * indicates to Soy not to escape when printed as an HTML attribute.
+ */
+soydata.VERY_UNSAFE.ordainSanitizedHtmlAttribute =
+ soydata.$$makeSanitizedContentFactory_(soydata.SanitizedHtmlAttribute);
+
+
+/**
+ * Takes a leap of faith that the provided content is "safe" to use as CSS
+ * in a style attribute or block.
+ *
+ * @param {*} content CSS, such as {@code color:#c3d9ff}.
+ * @return {!soydata.SanitizedCss} Sanitized CSS wrapper that indicates to
+ * Soy there is no need to escape or filter when printed in CSS context.
+ */
+soydata.VERY_UNSAFE.ordainSanitizedCss =
+ soydata.$$makeSanitizedContentFactory_(soydata.SanitizedCss);
+
+
+// -----------------------------------------------------------------------------
+// Public utilities.
+
+
+/**
+ * Helper function to render a Soy template and then set the output string as
+ * the innerHTML of an element. It is recommended to use this helper function
+ * instead of directly setting innerHTML in your hand-written code, so that it
+ * will be easier to audit the code for cross-site scripting vulnerabilities.
+ *
+ * NOTE: New code should consider using goog.soy.renderElement instead.
+ *
+ * @param {Element} element The element whose content we are rendering.
+ * @param {Function} template The Soy template defining the element's content.
+ * @param {Object=} opt_templateData The data for the template.
+ * @param {Object=} opt_injectedData The injected data for the template.
+ */
+soy.renderElement = goog.soy.renderElement;
+
+
+/**
+ * Helper function to render a Soy template into a single node or a document
+ * fragment. If the rendered HTML string represents a single node, then that
+ * node is returned (note that this is *not* a fragment, despite them name of
+ * the method). Otherwise a document fragment is returned containing the
+ * rendered nodes.
+ *
+ * NOTE: New code should consider using goog.soy.renderAsFragment
+ * instead (note that the arguments are different).
+ *
+ * @param {Function} template The Soy template defining the element's content.
+ * @param {Object=} opt_templateData The data for the template.
+ * @param {Document=} opt_document The document used to create DOM nodes. If not
+ * specified, global document object is used.
+ * @param {Object=} opt_injectedData The injected data for the template.
+ * @return {!Node} The resulting node or document fragment.
+ */
+soy.renderAsFragment = function(
+ template, opt_templateData, opt_document, opt_injectedData) {
+ return goog.soy.renderAsFragment(
+ template, opt_templateData, opt_injectedData,
+ new goog.dom.DomHelper(opt_document));
+};
+
+
+/**
+ * Helper function to render a Soy template into a single node. If the rendered
+ * HTML string represents a single node, then that node is returned. Otherwise,
+ * a DIV element is returned containing the rendered nodes.
+ *
+ * NOTE: New code should consider using goog.soy.renderAsElement
+ * instead (note that the arguments are different).
+ *
+ * @param {Function} template The Soy template defining the element's content.
+ * @param {Object=} opt_templateData The data for the template.
+ * @param {Document=} opt_document The document used to create DOM nodes. If not
+ * specified, global document object is used.
+ * @param {Object=} opt_injectedData The injected data for the template.
+ * @return {!Element} Rendered template contents, wrapped in a parent DIV
+ * element if necessary.
+ */
+soy.renderAsElement = function(
+ template, opt_templateData, opt_document, opt_injectedData) {
+ return goog.soy.renderAsElement(
+ template, opt_templateData, opt_injectedData,
+ new goog.dom.DomHelper(opt_document));
+};
+
+
+// -----------------------------------------------------------------------------
+// Below are private utilities to be used by Soy-generated code only.
+
+
+/**
+ * Builds an augmented map. The returned map will contain mappings from both
+ * the base map and the additional map. If the same key appears in both, then
+ * the value from the additional map will be visible, while the value from the
+ * base map will be hidden. The base map will be used, but not modified.
+ *
+ * @param {!Object} baseMap The original map to augment.
+ * @param {!Object} additionalMap A map containing the additional mappings.
+ * @return {!Object} An augmented map containing both the original and
+ * additional mappings.
+ */
+soy.$$augmentMap = function(baseMap, additionalMap) {
+
+ // Create a new map whose '__proto__' field is set to baseMap.
+ /** @constructor */
+ function TempCtor() {}
+ TempCtor.prototype = baseMap;
+ var augmentedMap = new TempCtor();
+
+ // Add the additional mappings to the new map.
+ for (var key in additionalMap) {
+ augmentedMap[key] = additionalMap[key];
+ }
+
+ return augmentedMap;
+};
+
+
+/**
+ * Checks that the given map key is a string.
+ * @param {*} key Key to check.
+ * @return {string} The given key.
+ */
+soy.$$checkMapKey = function(key) {
+ if ((typeof key) != 'string') {
+ throw Error(
+ 'Map literal\'s key expression must evaluate to string' +
+ ' (encountered type "' + (typeof key) + '").');
+ }
+ return key;
+};
+
+
+/**
+ * Gets the keys in a map as an array. There are no guarantees on the order.
+ * @param {Object} map The map to get the keys of.
+ * @return {Array.<string>} The array of keys in the given map.
+ */
+soy.$$getMapKeys = function(map) {
+ var mapKeys = [];
+ for (var key in map) {
+ mapKeys.push(key);
+ }
+ return mapKeys;
+};
+
+
+/**
+ * Gets a consistent unique id for the given delegate template name. Two calls
+ * to this function will return the same id if and only if the input names are
+ * the same.
+ *
+ * <p> Important: This function must always be called with a string constant.
+ *
+ * <p> If Closure Compiler is not being used, then this is just this identity
+ * function. If Closure Compiler is being used, then each call to this function
+ * will be replaced with a short string constant, which will be consistent per
+ * input name.
+ *
+ * @param {string} delTemplateName The delegate template name for which to get a
+ * consistent unique id.
+ * @return {string} A unique id that is consistent per input name.
+ *
+ * @consistentIdGenerator
+ */
+soy.$$getDelTemplateId = function(delTemplateName) {
+ return delTemplateName;
+};
+
+
+/**
+ * Map from registered delegate template key to the priority of the
+ * implementation.
+ * @type {Object}
+ * @private
+ */
+soy.$$DELEGATE_REGISTRY_PRIORITIES_ = {};
+
+/**
+ * Map from registered delegate template key to the implementation function.
+ * @type {Object}
+ * @private
+ */
+soy.$$DELEGATE_REGISTRY_FUNCTIONS_ = {};
+
+
+/**
+ * Registers a delegate implementation. If the same delegate template key (id
+ * and variant) has been registered previously, then priority values are
+ * compared and only the higher priority implementation is stored (if
+ * priorities are equal, an error is thrown).
+ *
+ * @param {string} delTemplateId The delegate template id.
+ * @param {string} delTemplateVariant The delegate template variant (can be
+ * empty string).
+ * @param {number} delPriority The implementation's priority value.
+ * @param {Function} delFn The implementation function.
+ */
+soy.$$registerDelegateFn = function(
+ delTemplateId, delTemplateVariant, delPriority, delFn) {
+
+ var mapKey = 'key_' + delTemplateId + ':' + delTemplateVariant;
+ var currPriority = soy.$$DELEGATE_REGISTRY_PRIORITIES_[mapKey];
+ if (currPriority === undefined || delPriority > currPriority) {
+ // Registering new or higher-priority function: replace registry entry.
+ soy.$$DELEGATE_REGISTRY_PRIORITIES_[mapKey] = delPriority;
+ soy.$$DELEGATE_REGISTRY_FUNCTIONS_[mapKey] = delFn;
+ } else if (delPriority == currPriority) {
+ // Registering same-priority function: error.
+ throw Error(
+ 'Encountered two active delegates with the same priority ("' +
+ delTemplateId + ':' + delTemplateVariant + '").');
+ } else {
+ // Registering lower-priority function: do nothing.
+ }
+};
+
+
+/**
+ * Retrieves the (highest-priority) implementation that has been registered for
+ * a given delegate template key (id and variant). If no implementation has
+ * been registered for the key, then the fallback is the same id with empty
+ * variant. If the fallback is also not registered, and allowsEmptyDefault is
+ * true, then returns an implementation that is equivalent to an empty template
+ * (i.e. rendered output would be empty string).
+ *
+ * @param {string} delTemplateId The delegate template id.
+ * @param {string} delTemplateVariant The delegate template variant (can be
+ * empty string).
+ * @param {boolean} allowsEmptyDefault Whether to default to the empty template
+ * function if there's no active implementation.
+ * @return {Function} The retrieved implementation function.
+ */
+soy.$$getDelegateFn = function(
+ delTemplateId, delTemplateVariant, allowsEmptyDefault) {
+
+ var delFn = soy.$$DELEGATE_REGISTRY_FUNCTIONS_[
+ 'key_' + delTemplateId + ':' + delTemplateVariant];
+ if (! delFn && delTemplateVariant != '') {
+ // Fallback to empty variant.
+ delFn = soy.$$DELEGATE_REGISTRY_FUNCTIONS_['key_' + delTemplateId + ':'];
+ }
+
+ if (delFn) {
+ return delFn;
+ } else if (allowsEmptyDefault) {
+ return soy.$$EMPTY_TEMPLATE_FN_;
+ } else {
+ throw Error(
+ 'Found no active impl for delegate call to "' + delTemplateId + ':' +
+ delTemplateVariant + '" (and not allowemptydefault="true").');
+ }
+};
+
+
+/**
+ * Private helper soy.$$getDelegateFn(). This is the empty template function
+ * that is returned whenever there's no delegate implementation found.
+ *
+ * @param {Object.<string, *>=} opt_data
+ * @param {soy.StringBuilder=} opt_sb
+ * @param {Object.<string, *>=} opt_ijData
+ * @return {string}
+ * @private
+ */
+soy.$$EMPTY_TEMPLATE_FN_ = function(opt_data, opt_sb, opt_ijData) {
+ return '';
+};
+
+
+// -----------------------------------------------------------------------------
+// Escape/filter/normalize.
+
+
+/**
+ * Escapes HTML special characters in a string. Escapes double quote '"' in
+ * addition to '&', '<', and '>' so that a string can be included in an HTML
+ * tag attribute value within double quotes.
+ * Will emit known safe HTML as-is.
+ *
+ * @param {*} value The string-like value to be escaped. May not be a string,
+ * but the value will be coerced to a string.
+ * @return {string} An escaped version of value.
+ */
+soy.$$escapeHtml = function(value) {
+ // TODO: Perhaps we should just ignore the contentKind property and instead
+ // look only at the constructor.
+ if (value && value.contentKind &&
+ value.contentKind === goog.soy.data.SanitizedContentKind.HTML) {
+ goog.asserts.assert(
+ value.constructor === soydata.SanitizedHtml);
+ return value.content;
+ }
+ return soy.esc.$$escapeHtmlHelper(value);
+};
+
+
+/**
+ * Strips unsafe tags to convert a string of untrusted HTML into HTML that
+ * is safe to embed.
+ *
+ * @param {*} value The string-like value to be escaped. May not be a string,
+ * but the value will be coerced to a string.
+ * @return {string} A sanitized and normalized version of value.
+ */
+soy.$$cleanHtml = function(value) {
+ if (value && value.contentKind &&
+ value.contentKind === goog.soy.data.SanitizedContentKind.HTML) {
+ goog.asserts.assert(
+ value.constructor === soydata.SanitizedHtml);
+ return value.content;
+ }
+ return soy.$$stripHtmlTags(value, soy.esc.$$SAFE_TAG_WHITELIST_);
+};
+
+
+/**
+ * Escapes HTML special characters in a string so that it can be embedded in
+ * RCDATA.
+ * <p>
+ * Escapes HTML special characters so that the value will not prematurely end
+ * the body of a tag like {@code <textarea>} or {@code <title>}. RCDATA tags
+ * cannot contain other HTML entities, so it is not strictly necessary to escape
+ * HTML special characters except when part of that text looks like an HTML
+ * entity or like a close tag : {@code </textarea>}.
+ * <p>
+ * Will normalize known safe HTML to make sure that sanitized HTML (which could
+ * contain an innocuous {@code </textarea>} don't prematurely end an RCDATA
+ * element.
+ *
+ * @param {*} value The string-like value to be escaped. May not be a string,
+ * but the value will be coerced to a string.
+ * @return {string} An escaped version of value.
+ */
+soy.$$escapeHtmlRcdata = function(value) {
+ if (value && value.contentKind &&
+ value.contentKind === goog.soy.data.SanitizedContentKind.HTML) {
+ goog.asserts.assert(
+ value.constructor === soydata.SanitizedHtml);
+ return soy.esc.$$normalizeHtmlHelper(value.content);
+ }
+ return soy.esc.$$escapeHtmlHelper(value);
+};
+
+
+/**
+ * Matches any/only HTML5 void elements' start tags.
+ * See http://www.w3.org/TR/html-markup/syntax.html#syntax-elements
+ * @type {RegExp}
+ * @private
+ */
+soy.$$HTML5_VOID_ELEMENTS_ = new RegExp(
+ '^<(?:area|base|br|col|command|embed|hr|img|input' +
+ '|keygen|link|meta|param|source|track|wbr)\\b');
+
+
+/**
+ * Removes HTML tags from a string of known safe HTML.
+ * If opt_tagWhitelist is not specified or is empty, then
+ * the result can be used as an attribute value.
+ *
+ * @param {*} value The HTML to be escaped. May not be a string, but the
+ * value will be coerced to a string.
+ * @param {Object.<string, number>=} opt_tagWhitelist Has an own property whose
+ * name is a lower-case tag name and whose value is {@code 1} for
+ * each element that is allowed in the output.
+ * @return {string} A representation of value without disallowed tags,
+ * HTML comments, or other non-text content.
+ */
+soy.$$stripHtmlTags = function(value, opt_tagWhitelist) {
+ if (!opt_tagWhitelist) {
+ // If we have no white-list, then use a fast track which elides all tags.
+ return String(value).replace(soy.esc.$$HTML_TAG_REGEX_, '')
+ // This is just paranoia since callers should normalize the result
+ // anyway, but if they didn't, it would be necessary to ensure that
+ // after the first replace non-tag uses of < do not recombine into
+ // tags as in "<<foo>script>alert(1337)</<foo>script>".
+ .replace(soy.esc.$$LT_REGEX_, '&lt;');
+ }
+
+ // Escapes '[' so that we can use [123] below to mark places where tags
+ // have been removed.
+ var html = String(value).replace(/\[/g, '&#91;');
+
+ // Consider all uses of '<' and replace whitelisted tags with markers like
+ // [1] which are indices into a list of approved tag names.
+ // Replace all other uses of < and > with entities.
+ var tags = [];
+ html = html.replace(
+ soy.esc.$$HTML_TAG_REGEX_,
+ function(tok, tagName) {
+ if (tagName) {
+ tagName = tagName.toLowerCase();
+ if (opt_tagWhitelist.hasOwnProperty(tagName) &&
+ opt_tagWhitelist[tagName]) {
+ var start = tok.charAt(1) === '/' ? '</' : '<';
+ var index = tags.length;
+ tags[index] = start + tagName + '>';
+ return '[' + index + ']';
+ }
+ }
+ return '';
+ });
+
+ // Escape HTML special characters. Now there are no '<' in html that could
+ // start a tag.
+ html = soy.esc.$$normalizeHtmlHelper(html);
+
+ var finalCloseTags = soy.$$balanceTags_(tags);
+
+ // Now html contains no tags or less-than characters that could become
+ // part of a tag via a replacement operation and tags only contains
+ // approved tags.
+ // Reinsert the white-listed tags.
+ html = html.replace(
+ /\[(\d+)\]/g, function(_, index) { return tags[index]; });
+
+ // Close any still open tags.
+ // This prevents unclosed formatting elements like <ol> and <table> from
+ // breaking the layout of containing HTML.
+ return html + finalCloseTags;
+};
+
+
+/**
+ * Throw out any close tags that don't correspond to start tags.
+ * If {@code <table>} is used for formatting, embedded HTML shouldn't be able
+ * to use a mismatched {@code </table>} to break page layout.
+ *
+ * @param {Array.<string>} tags an array of tags that will be modified in place
+ * include tags, the empty string, or concatenations of empty tags.
+ * @return {string} zero or more closed tags that close all elements that are
+ * opened in tags but not closed.
+ * @private
+ */
+soy.$$balanceTags_ = function(tags) {
+ var open = [];
+ for (var i = 0, n = tags.length; i < n; ++i) {
+ var tag = tags[i];
+ if (tag.charAt(1) === '/') {
+ var openTagIndex = open.length - 1;
+ // NOTE: This is essentially lastIndexOf, but it's not supported in IE.
+ while (openTagIndex >= 0 && open[openTagIndex] != tag) {
+ openTagIndex--;
+ }
+ if (openTagIndex < 0) {
+ tags[i] = ''; // Drop close tag.
+ } else {
+ tags[i] = open.slice(openTagIndex).reverse().join('');
+ open.length = openTagIndex;
+ }
+ } else if (!soy.$$HTML5_VOID_ELEMENTS_.test(tag)) {
+ open.push('</' + tag.substring(1));
+ }
+ }
+ return open.reverse().join('');
+};
+
+
+/**
+ * Escapes HTML special characters in an HTML attribute value.
+ *
+ * @param {*} value The HTML to be escaped. May not be a string, but the
+ * value will be coerced to a string.
+ * @return {string} An escaped version of value.
+ */
+soy.$$escapeHtmlAttribute = function(value) {
+ if (value && value.contentKind) {
+ // NOTE: We don't accept ATTRIBUTES here because ATTRIBUTES is
+ // actually not the attribute value context, but instead k/v pairs.
+ if (value.contentKind === goog.soy.data.SanitizedContentKind.HTML) {
+ // NOTE: After removing tags, we also escape quotes ("normalize") so that
+ // the HTML can be embedded in attribute context.
+ goog.asserts.assert(
+ value.constructor === soydata.SanitizedHtml);
+ return soy.esc.$$normalizeHtmlHelper(soy.$$stripHtmlTags(value.content));
+ }
+ }
+ return soy.esc.$$escapeHtmlHelper(value);
+};
+
+
+/**
+ * Escapes HTML special characters in a string including space and other
+ * characters that can end an unquoted HTML attribute value.
+ *
+ * @param {*} value The HTML to be escaped. May not be a string, but the
+ * value will be coerced to a string.
+ * @return {string} An escaped version of value.
+ */
+soy.$$escapeHtmlAttributeNospace = function(value) {
+ if (value && value.contentKind) {
+ if (value.contentKind === goog.soy.data.SanitizedContentKind.HTML) {
+ goog.asserts.assert(value.constructor ===
+ soydata.SanitizedHtml);
+ return soy.esc.$$normalizeHtmlNospaceHelper(
+ soy.$$stripHtmlTags(value.content));
+ }
+ }
+ return soy.esc.$$escapeHtmlNospaceHelper(value);
+};
+
+
+/**
+ * Filters out strings that cannot be a substring of a valid HTML attribute.
+ *
+ * Note the input is expected to be key=value pairs.
+ *
+ * @param {*} value The value to escape. May not be a string, but the value
+ * will be coerced to a string.
+ * @return {string} A valid HTML attribute name part or name/value pair.
+ * {@code "zSoyz"} if the input is invalid.
+ */
+soy.$$filterHtmlAttributes = function(value) {
+ // NOTE: Explicitly no support for SanitizedContentKind.HTML, since that is
+ // meaningless in this context, which is generally *between* html attributes.
+ if (value &&
+ value.contentKind === goog.soy.data.SanitizedContentKind.ATTRIBUTES) {
+ goog.asserts.assert(value.constructor ===
+ soydata.SanitizedHtmlAttribute);
+ // Add a space at the end to ensure this won't get merged into following
+ // attributes, unless the interpretation is unambiguous (ending with quotes
+ // or a space).
+ return value.content.replace(/([^"'\s])$/, '$1 ');
+ }
+ // TODO: Dynamically inserting attributes that aren't marked as trusted is
+ // probably unnecessary. Any filtering done here will either be inadequate
+ // for security or not flexible enough. Having clients use kind="attributes"
+ // in parameters seems like a wiser idea.
+ return soy.esc.$$filterHtmlAttributesHelper(value);
+};
+
+
+/**
+ * Filters out strings that cannot be a substring of a valid HTML element name.
+ *
+ * @param {*} value The value to escape. May not be a string, but the value
+ * will be coerced to a string.
+ * @return {string} A valid HTML element name part.
+ * {@code "zSoyz"} if the input is invalid.
+ */
+soy.$$filterHtmlElementName = function(value) {
+ // NOTE: We don't accept any SanitizedContent here. HTML indicates valid
+ // PCDATA, not tag names. A sloppy developer shouldn't be able to cause an
+ // exploit:
+ // ... {let userInput}script src=http://evil.com/evil.js{/let} ...
+ // ... {param tagName kind="html"}{$userInput}{/param} ...
+ // ... <{$tagName}>Hello World</{$tagName}>
+ return soy.esc.$$filterHtmlElementNameHelper(value);
+};
+
+
+/**
+ * Escapes characters in the value to make it valid content for a JS string
+ * literal.
+ *
+ * @param {*} value The value to escape. May not be a string, but the value
+ * will be coerced to a string.
+ * @return {string} An escaped version of value.
+ * @deprecated
+ */
+soy.$$escapeJs = function(value) {
+ return soy.$$escapeJsString(value);
+};
+
+
+/**
+ * Escapes characters in the value to make it valid content for a JS string
+ * literal.
+ *
+ * @param {*} value The value to escape. May not be a string, but the value
+ * will be coerced to a string.
+ * @return {string} An escaped version of value.
+ */
+soy.$$escapeJsString = function(value) {
+ if (value &&
+ value.contentKind === goog.soy.data.SanitizedContentKind.JS_STR_CHARS) {
+ // TODO: It might still be worthwhile to normalize it to remove
+ // unescaped quotes, null, etc: replace(/(?:^|[^\])['"]/g, '\\$
+ goog.asserts.assert(value.constructor ===
+ soydata.SanitizedJsStrChars);
+ return value.content;
+ }
+ return soy.esc.$$escapeJsStringHelper(value);
+};
+
+
+/**
+ * Encodes a value as a JavaScript literal.
+ *
+ * @param {*} value The value to escape. May not be a string, but the value
+ * will be coerced to a string.
+ * @return {string} A JavaScript code representation of the input.
+ */
+soy.$$escapeJsValue = function(value) {
+ // We surround values with spaces so that they can't be interpolated into
+ // identifiers by accident.
+ // We could use parentheses but those might be interpreted as a function call.
+ if (value == null) { // Intentionally matches undefined.
+ // Java returns null from maps where there is no corresponding key while
+ // JS returns undefined.
+ // We always output null for compatibility with Java which does not have a
+ // distinct undefined value.
+ return ' null ';
+ }
+ if (value.contentKind == goog.soy.data.SanitizedContentKind.JS) {
+ goog.asserts.assert(value.constructor ===
+ soydata.SanitizedJs);
+ return value.content;
+ }
+ switch (typeof value) {
+ case 'boolean': case 'number':
+ return ' ' + value + ' ';
+ default:
+ return "'" + soy.esc.$$escapeJsStringHelper(String(value)) + "'";
+ }
+};
+
+
+/**
+ * Escapes characters in the string to make it valid content for a JS regular
+ * expression literal.
+ *
+ * @param {*} value The value to escape. May not be a string, but the value
+ * will be coerced to a string.
+ * @return {string} An escaped version of value.
+ */
+soy.$$escapeJsRegex = function(value) {
+ return soy.esc.$$escapeJsRegexHelper(value);
+};
+
+
+/**
+ * Matches all URI mark characters that conflict with HTML attribute delimiters
+ * or that cannot appear in a CSS uri.
+ * From <a href="http://www.w3.org/TR/CSS2/grammar.html">G.2: CSS grammar</a>
+ * <pre>
+ * url ([!#$%&*-~]|{nonascii}|{escape})*
+ * </pre>
+ *
+ * @type {RegExp}
+ * @private
+ */
+soy.$$problematicUriMarks_ = /['()]/g;
+
+/**
+ * @param {string} ch A single character in {@link soy.$$problematicUriMarks_}.
+ * @return {string}
+ * @private
+ */
+soy.$$pctEncode_ = function(ch) {
+ return '%' + ch.charCodeAt(0).toString(16);
+};
+
+/**
+ * Escapes a string so that it can be safely included in a URI.
+ *
+ * @param {*} value The value to escape. May not be a string, but the value
+ * will be coerced to a string.
+ * @return {string} An escaped version of value.
+ */
+soy.$$escapeUri = function(value) {
+ if (value && value.contentKind === goog.soy.data.SanitizedContentKind.URI) {
+ goog.asserts.assert(value.constructor ===
+ soydata.SanitizedUri);
+ return soy.$$normalizeUri(value);
+ }
+ // Apostophes and parentheses are not matched by encodeURIComponent.
+ // They are technically special in URIs, but only appear in the obsolete mark
+ // production in Appendix D.2 of RFC 3986, so can be encoded without changing
+ // semantics.
+ var encoded = soy.esc.$$escapeUriHelper(value);
+ soy.$$problematicUriMarks_.lastIndex = 0;
+ if (soy.$$problematicUriMarks_.test(encoded)) {
+ return encoded.replace(soy.$$problematicUriMarks_, soy.$$pctEncode_);
+ }
+ return encoded;
+};
+
+
+/**
+ * Removes rough edges from a URI by escaping any raw HTML/JS string delimiters.
+ *
+ * @param {*} value The value to escape. May not be a string, but the value
+ * will be coerced to a string.
+ * @return {string} An escaped version of value.
+ */
+soy.$$normalizeUri = function(value) {
+ return soy.esc.$$normalizeUriHelper(value);
+};
+
+
+/**
+ * Vets a URI's protocol and removes rough edges from a URI by escaping
+ * any raw HTML/JS string delimiters.
+ *
+ * @param {*} value The value to escape. May not be a string, but the value
+ * will be coerced to a string.
+ * @return {string} An escaped version of value.
+ */
+soy.$$filterNormalizeUri = function(value) {
+ if (value && value.contentKind == goog.soy.data.SanitizedContentKind.URI) {
+ goog.asserts.assert(value.constructor ===
+ soydata.SanitizedUri);
+ return soy.$$normalizeUri(value);
+ }
+ return soy.esc.$$filterNormalizeUriHelper(value);
+};
+
+
+/**
+ * Escapes a string so it can safely be included inside a quoted CSS string.
+ *
+ * @param {*} value The value to escape. May not be a string, but the value
+ * will be coerced to a string.
+ * @return {string} An escaped version of value.
+ */
+soy.$$escapeCssString = function(value) {
+ return soy.esc.$$escapeCssStringHelper(value);
+};
+
+
+/**
+ * Encodes a value as a CSS identifier part, keyword, or quantity.
+ *
+ * @param {*} value The value to escape. May not be a string, but the value
+ * will be coerced to a string.
+ * @return {string} A safe CSS identifier part, keyword, or quanitity.
+ */
+soy.$$filterCssValue = function(value) {
+ if (value && value.contentKind === goog.soy.data.SanitizedContentKind.CSS) {
+ goog.asserts.assert(value.constructor ===
+ soydata.SanitizedCss);
+ return value.content;
+ }
+ // Uses == to intentionally match null and undefined for Java compatibility.
+ if (value == null) {
+ return '';
+ }
+ return soy.esc.$$filterCssValueHelper(value);
+};
+
+
+/**
+ * Sanity-checks noAutoescape input for explicitly tainted content.
+ *
+ * SanitizedContentKind.TEXT is used to explicitly mark input that was never
+ * meant to be used unescaped.
+ *
+ * @param {*} value The value to filter.
+ * @return {string} The value, that we dearly hope will not cause an attack.
+ */
+soy.$$filterNoAutoescape = function(value) {
+ if (value && value.contentKind === goog.soy.data.SanitizedContentKind.TEXT) {
+ // Fail in development mode.
+ goog.asserts.fail(
+ 'Tainted SanitizedContentKind.TEXT for |noAutoescape: `%s`',
+ [value.content]);
+ // Return innocuous data in production.
+ return 'zSoyz';
+ }
+ return String(value);
+};
+
+
+// -----------------------------------------------------------------------------
+// Basic directives/functions.
+
+
+/**
+ * Converts \r\n, \r, and \n to <br>s
+ * @param {*} str The string in which to convert newlines.
+ * @return {string} A copy of {@code str} with converted newlines.
+ */
+soy.$$changeNewlineToBr = function(str) {
+ return goog.string.newLineToBr(String(str), false);
+};
+
+
+/**
+ * Inserts word breaks ('wbr' tags) into a HTML string at a given interval. The
+ * counter is reset if a space is encountered. Word breaks aren't inserted into
+ * HTML tags or entities. Entites count towards the character count; HTML tags
+ * do not.
+ *
+ * @param {*} str The HTML string to insert word breaks into. Can be other
+ * types, but the value will be coerced to a string.
+ * @param {number} maxCharsBetweenWordBreaks Maximum number of non-space
+ * characters to allow before adding a word break.
+ * @return {string} The string including word breaks.
+ */
+soy.$$insertWordBreaks = function(str, maxCharsBetweenWordBreaks) {
+ return goog.format.insertWordBreaks(String(str), maxCharsBetweenWordBreaks);
+};
+
+
+/**
+ * Truncates a string to a given max length (if it's currently longer),
+ * optionally adding ellipsis at the end.
+ *
+ * @param {*} str The string to truncate. Can be other types, but the value will
+ * be coerced to a string.
+ * @param {number} maxLen The maximum length of the string after truncation
+ * (including ellipsis, if applicable).
+ * @param {boolean} doAddEllipsis Whether to add ellipsis if the string needs
+ * truncation.
+ * @return {string} The string after truncation.
+ */
+soy.$$truncate = function(str, maxLen, doAddEllipsis) {
+
+ str = String(str);
+ if (str.length <= maxLen) {
+ return str; // no need to truncate
+ }
+
+ // If doAddEllipsis, either reduce maxLen to compensate, or else if maxLen is
+ // too small, just turn off doAddEllipsis.
+ if (doAddEllipsis) {
+ if (maxLen > 3) {
+ maxLen -= 3;
+ } else {
+ doAddEllipsis = false;
+ }
+ }
+
+ // Make sure truncating at maxLen doesn't cut up a unicode surrogate pair.
+ if (soy.$$isHighSurrogate_(str.charAt(maxLen - 1)) &&
+ soy.$$isLowSurrogate_(str.charAt(maxLen))) {
+ maxLen -= 1;
+ }
+
+ // Truncate.
+ str = str.substring(0, maxLen);
+
+ // Add ellipsis.
+ if (doAddEllipsis) {
+ str += '...';
+ }
+
+ return str;
+};
+
+/**
+ * Private helper for $$truncate() to check whether a char is a high surrogate.
+ * @param {string} ch The char to check.
+ * @return {boolean} Whether the given char is a unicode high surrogate.
+ * @private
+ */
+soy.$$isHighSurrogate_ = function(ch) {
+ return 0xD800 <= ch && ch <= 0xDBFF;
+};
+
+/**
+ * Private helper for $$truncate() to check whether a char is a low surrogate.
+ * @param {string} ch The char to check.
+ * @return {boolean} Whether the given char is a unicode low surrogate.
+ * @private
+ */
+soy.$$isLowSurrogate_ = function(ch) {
+ return 0xDC00 <= ch && ch <= 0xDFFF;
+};
+
+
+// -----------------------------------------------------------------------------
+// Bidi directives/functions.
+
+
+/**
+ * Cache of bidi formatter by context directionality, so we don't keep on
+ * creating new objects.
+ * @type {!Object.<!goog.i18n.BidiFormatter>}
+ * @private
+ */
+soy.$$bidiFormatterCache_ = {};
+
+
+/**
+ * Returns cached bidi formatter for bidiGlobalDir, or creates a new one.
+ * @param {number} bidiGlobalDir The global directionality context: 1 if ltr, -1
+ * if rtl, 0 if unknown.
+ * @return {goog.i18n.BidiFormatter} A formatter for bidiGlobalDir.
+ * @private
+ */
+soy.$$getBidiFormatterInstance_ = function(bidiGlobalDir) {
+ return soy.$$bidiFormatterCache_[bidiGlobalDir] ||
+ (soy.$$bidiFormatterCache_[bidiGlobalDir] =
+ new goog.i18n.BidiFormatter(bidiGlobalDir));
+};
+
+
+/**
+ * Estimate the overall directionality of text. If opt_isHtml, makes sure to
+ * ignore the LTR nature of the mark-up and escapes in text, making the logic
+ * suitable for HTML and HTML-escaped text.
+ * @param {string} text The text whose directionality is to be estimated.
+ * @param {boolean=} opt_isHtml Whether text is HTML/HTML-escaped.
+ * Default: false.
+ * @return {number} 1 if text is LTR, -1 if it is RTL, and 0 if it is neutral.
+ */
+soy.$$bidiTextDir = function(text, opt_isHtml) {
+ if (!text) {
+ return 0;
+ }
+ return goog.i18n.bidi.detectRtlDirectionality(text, opt_isHtml) ? -1 : 1;
+};
+
+
+/**
+ * Returns 'dir="ltr"' or 'dir="rtl"', depending on text's estimated
+ * directionality, if it is not the same as bidiGlobalDir.
+ * Otherwise, returns the empty string.
+ * If opt_isHtml, makes sure to ignore the LTR nature of the mark-up and escapes
+ * in text, making the logic suitable for HTML and HTML-escaped text.
+ * @param {number} bidiGlobalDir The global directionality context: 1 if ltr, -1
+ * if rtl, 0 if unknown.
+ * @param {string} text The text whose directionality is to be estimated.
+ * @param {boolean=} opt_isHtml Whether text is HTML/HTML-escaped.
+ * Default: false.
+ * @return {soydata.SanitizedHtmlAttribute} 'dir="rtl"' for RTL text in non-RTL
+ * context; 'dir="ltr"' for LTR text in non-LTR context;
+ * else, the empty string.
+ */
+soy.$$bidiDirAttr = function(bidiGlobalDir, text, opt_isHtml) {
+ return soydata.VERY_UNSAFE.ordainSanitizedHtmlAttribute(
+ soy.$$getBidiFormatterInstance_(bidiGlobalDir).dirAttr(text, opt_isHtml));
+};
+
+
+/**
+ * Returns a Unicode BiDi mark matching bidiGlobalDir (LRM or RLM) if the
+ * directionality or the exit directionality of text are opposite to
+ * bidiGlobalDir. Otherwise returns the empty string.
+ * If opt_isHtml, makes sure to ignore the LTR nature of the mark-up and escapes
+ * in text, making the logic suitable for HTML and HTML-escaped text.
+ * @param {number} bidiGlobalDir The global directionality context: 1 if ltr, -1
+ * if rtl, 0 if unknown.
+ * @param {string} text The text whose directionality is to be estimated.
+ * @param {boolean=} opt_isHtml Whether text is HTML/HTML-escaped.
+ * Default: false.
+ * @return {string} A Unicode bidi mark matching bidiGlobalDir, or the empty
+ * string when text's overall and exit directionalities both match
+ * bidiGlobalDir, or bidiGlobalDir is 0 (unknown).
+ */
+soy.$$bidiMarkAfter = function(bidiGlobalDir, text, opt_isHtml) {
+ var formatter = soy.$$getBidiFormatterInstance_(bidiGlobalDir);
+ return formatter.markAfter(text, opt_isHtml);
+};
+
+
+/**
+ * Returns str wrapped in a <span dir="ltr|rtl"> according to its directionality
+ * - but only if that is neither neutral nor the same as the global context.
+ * Otherwise, returns str unchanged.
+ * Always treats str as HTML/HTML-escaped, i.e. ignores mark-up and escapes when
+ * estimating str's directionality.
+ * @param {number} bidiGlobalDir The global directionality context: 1 if ltr, -1
+ * if rtl, 0 if unknown.
+ * @param {*} str The string to be wrapped. Can be other types, but the value
+ * will be coerced to a string.
+ * @return {string} The wrapped string.
+ */
+soy.$$bidiSpanWrap = function(bidiGlobalDir, str) {
+ var formatter = soy.$$getBidiFormatterInstance_(bidiGlobalDir);
+ return formatter.spanWrap(str + '', true);
+};
+
+
+/**
+ * Returns str wrapped in Unicode BiDi formatting characters according to its
+ * directionality, i.e. either LRE or RLE at the beginning and PDF at the end -
+ * but only if str's directionality is neither neutral nor the same as the
+ * global context. Otherwise, returns str unchanged.
+ * Always treats str as HTML/HTML-escaped, i.e. ignores mark-up and escapes when
+ * estimating str's directionality.
+ * @param {number} bidiGlobalDir The global directionality context: 1 if ltr, -1
+ * if rtl, 0 if unknown.
+ * @param {*} str The string to be wrapped. Can be other types, but the value
+ * will be coerced to a string.
+ * @return {string} The wrapped string.
+ */
+soy.$$bidiUnicodeWrap = function(bidiGlobalDir, str) {
+ var formatter = soy.$$getBidiFormatterInstance_(bidiGlobalDir);
+ return formatter.unicodeWrap(str + '', true);
+};
+
+
+// -----------------------------------------------------------------------------
+// Generated code.
+
+
+
+
+// START GENERATED CODE FOR ESCAPERS.
+
+/**
+ * @type {function (*) : string}
+ */
+soy.esc.$$escapeUriHelper = function(v) {
+ return encodeURIComponent(String(v));
+};
+
+/**
+ * Maps charcters to the escaped versions for the named escape directives.
+ * @type {Object.<string, string>}
+ * @private
+ */
+soy.esc.$$ESCAPE_MAP_FOR_ESCAPE_HTML__AND__NORMALIZE_HTML__AND__ESCAPE_HTML_NOSPACE__AND__NORMALIZE_HTML_NOSPACE_ = {
+ '\x00': '\x26#0;',
+ '\x22': '\x26quot;',
+ '\x26': '\x26amp;',
+ '\x27': '\x26#39;',
+ '\x3c': '\x26lt;',
+ '\x3e': '\x26gt;',
+ '\x09': '\x26#9;',
+ '\x0a': '\x26#10;',
+ '\x0b': '\x26#11;',
+ '\x0c': '\x26#12;',
+ '\x0d': '\x26#13;',
+ ' ': '\x26#32;',
+ '-': '\x26#45;',
+ '\/': '\x26#47;',
+ '\x3d': '\x26#61;',
+ '`': '\x26#96;',
+ '\x85': '\x26#133;',
+ '\xa0': '\x26#160;',
+ '\u2028': '\x26#8232;',
+ '\u2029': '\x26#8233;'
+};
+
+/**
+ * A function that can be used with String.replace..
+ * @param {string} ch A single character matched by a compatible matcher.
+ * @return {string} A token in the output language.
+ * @private
+ */
+soy.esc.$$REPLACER_FOR_ESCAPE_HTML__AND__NORMALIZE_HTML__AND__ESCAPE_HTML_NOSPACE__AND__NORMALIZE_HTML_NOSPACE_ = function(ch) {
+ return soy.esc.$$ESCAPE_MAP_FOR_ESCAPE_HTML__AND__NORMALIZE_HTML__AND__ESCAPE_HTML_NOSPACE__AND__NORMALIZE_HTML_NOSPACE_[ch];
+};
+
+/**
+ * Maps charcters to the escaped versions for the named escape directives.
+ * @type {Object.<string, string>}
+ * @private
+ */
+soy.esc.$$ESCAPE_MAP_FOR_ESCAPE_JS_STRING__AND__ESCAPE_JS_REGEX_ = {
+ '\x00': '\\x00',
+ '\x08': '\\x08',
+ '\x09': '\\t',
+ '\x0a': '\\n',
+ '\x0b': '\\x0b',
+ '\x0c': '\\f',
+ '\x0d': '\\r',
+ '\x22': '\\x22',
+ '\x26': '\\x26',
+ '\x27': '\\x27',
+ '\/': '\\\/',
+ '\x3c': '\\x3c',
+ '\x3d': '\\x3d',
+ '\x3e': '\\x3e',
+ '\\': '\\\\',
+ '\x85': '\\x85',
+ '\u2028': '\\u2028',
+ '\u2029': '\\u2029',
+ '$': '\\x24',
+ '(': '\\x28',
+ ')': '\\x29',
+ '*': '\\x2a',
+ '+': '\\x2b',
+ ',': '\\x2c',
+ '-': '\\x2d',
+ '.': '\\x2e',
+ ':': '\\x3a',
+ '?': '\\x3f',
+ '[': '\\x5b',
+ ']': '\\x5d',
+ '^': '\\x5e',
+ '{': '\\x7b',
+ '|': '\\x7c',
+ '}': '\\x7d'
+};
+
+/**
+ * A function that can be used with String.replace..
+ * @param {string} ch A single character matched by a compatible matcher.
+ * @return {string} A token in the output language.
+ * @private
+ */
+soy.esc.$$REPLACER_FOR_ESCAPE_JS_STRING__AND__ESCAPE_JS_REGEX_ = function(ch) {
+ return soy.esc.$$ESCAPE_MAP_FOR_ESCAPE_JS_STRING__AND__ESCAPE_JS_REGEX_[ch];
+};
+
+/**
+ * Maps charcters to the escaped versions for the named escape directives.
+ * @type {Object.<string, string>}
+ * @private
+ */
+soy.esc.$$ESCAPE_MAP_FOR_ESCAPE_CSS_STRING_ = {
+ '\x00': '\\0 ',
+ '\x08': '\\8 ',
+ '\x09': '\\9 ',
+ '\x0a': '\\a ',
+ '\x0b': '\\b ',
+ '\x0c': '\\c ',
+ '\x0d': '\\d ',
+ '\x22': '\\22 ',
+ '\x26': '\\26 ',
+ '\x27': '\\27 ',
+ '(': '\\28 ',
+ ')': '\\29 ',
+ '*': '\\2a ',
+ '\/': '\\2f ',
+ ':': '\\3a ',
+ ';': '\\3b ',
+ '\x3c': '\\3c ',
+ '\x3d': '\\3d ',
+ '\x3e': '\\3e ',
+ '@': '\\40 ',
+ '\\': '\\5c ',
+ '{': '\\7b ',
+ '}': '\\7d ',
+ '\x85': '\\85 ',
+ '\xa0': '\\a0 ',
+ '\u2028': '\\2028 ',
+ '\u2029': '\\2029 '
+};
+
+/**
+ * A function that can be used with String.replace..
+ * @param {string} ch A single character matched by a compatible matcher.
+ * @return {string} A token in the output language.
+ * @private
+ */
+soy.esc.$$REPLACER_FOR_ESCAPE_CSS_STRING_ = function(ch) {
+ return soy.esc.$$ESCAPE_MAP_FOR_ESCAPE_CSS_STRING_[ch];
+};
+
+/**
+ * Maps charcters to the escaped versions for the named escape directives.
+ * @type {Object.<string, string>}
+ * @private
+ */
+soy.esc.$$ESCAPE_MAP_FOR_NORMALIZE_URI__AND__FILTER_NORMALIZE_URI_ = {
+ '\x00': '%00',
+ '\x01': '%01',
+ '\x02': '%02',
+ '\x03': '%03',
+ '\x04': '%04',
+ '\x05': '%05',
+ '\x06': '%06',
+ '\x07': '%07',
+ '\x08': '%08',
+ '\x09': '%09',
+ '\x0a': '%0A',
+ '\x0b': '%0B',
+ '\x0c': '%0C',
+ '\x0d': '%0D',
+ '\x0e': '%0E',
+ '\x0f': '%0F',
+ '\x10': '%10',
+ '\x11': '%11',
+ '\x12': '%12',
+ '\x13': '%13',
+ '\x14': '%14',
+ '\x15': '%15',
+ '\x16': '%16',
+ '\x17': '%17',
+ '\x18': '%18',
+ '\x19': '%19',
+ '\x1a': '%1A',
+ '\x1b': '%1B',
+ '\x1c': '%1C',
+ '\x1d': '%1D',
+ '\x1e': '%1E',
+ '\x1f': '%1F',
+ ' ': '%20',
+ '\x22': '%22',
+ '\x27': '%27',
+ '(': '%28',
+ ')': '%29',
+ '\x3c': '%3C',
+ '\x3e': '%3E',
+ '\\': '%5C',
+ '{': '%7B',
+ '}': '%7D',
+ '\x7f': '%7F',
+ '\x85': '%C2%85',
+ '\xa0': '%C2%A0',
+ '\u2028': '%E2%80%A8',
+ '\u2029': '%E2%80%A9',
+ '\uff01': '%EF%BC%81',
+ '\uff03': '%EF%BC%83',
+ '\uff04': '%EF%BC%84',
+ '\uff06': '%EF%BC%86',
+ '\uff07': '%EF%BC%87',
+ '\uff08': '%EF%BC%88',
+ '\uff09': '%EF%BC%89',
+ '\uff0a': '%EF%BC%8A',
+ '\uff0b': '%EF%BC%8B',
+ '\uff0c': '%EF%BC%8C',
+ '\uff0f': '%EF%BC%8F',
+ '\uff1a': '%EF%BC%9A',
+ '\uff1b': '%EF%BC%9B',
+ '\uff1d': '%EF%BC%9D',
+ '\uff1f': '%EF%BC%9F',
+ '\uff20': '%EF%BC%A0',
+ '\uff3b': '%EF%BC%BB',
+ '\uff3d': '%EF%BC%BD'
+};
+
+/**
+ * A function that can be used with String.replace..
+ * @param {string} ch A single character matched by a compatible matcher.
+ * @return {string} A token in the output language.
+ * @private
+ */
+soy.esc.$$REPLACER_FOR_NORMALIZE_URI__AND__FILTER_NORMALIZE_URI_ = function(ch) {
+ return soy.esc.$$ESCAPE_MAP_FOR_NORMALIZE_URI__AND__FILTER_NORMALIZE_URI_[ch];
+};
+
+/**
+ * Matches characters that need to be escaped for the named directives.
+ * @type RegExp
+ * @private
+ */
+soy.esc.$$MATCHER_FOR_ESCAPE_HTML_ = /[\x00\x22\x26\x27\x3c\x3e]/g;
+
+/**
+ * Matches characters that need to be escaped for the named directives.
+ * @type RegExp
+ * @private
+ */
+soy.esc.$$MATCHER_FOR_NORMALIZE_HTML_ = /[\x00\x22\x27\x3c\x3e]/g;
+
+/**
+ * Matches characters that need to be escaped for the named directives.
+ * @type RegExp
+ * @private
+ */
+soy.esc.$$MATCHER_FOR_ESCAPE_HTML_NOSPACE_ = /[\x00\x09-\x0d \x22\x26\x27\x2d\/\x3c-\x3e`\x85\xa0\u2028\u2029]/g;
+
+/**
+ * Matches characters that need to be escaped for the named directives.
+ * @type RegExp
+ * @private
+ */
+soy.esc.$$MATCHER_FOR_NORMALIZE_HTML_NOSPACE_ = /[\x00\x09-\x0d \x22\x27\x2d\/\x3c-\x3e`\x85\xa0\u2028\u2029]/g;
+
+/**
+ * Matches characters that need to be escaped for the named directives.
+ * @type RegExp
+ * @private
+ */
+soy.esc.$$MATCHER_FOR_ESCAPE_JS_STRING_ = /[\x00\x08-\x0d\x22\x26\x27\/\x3c-\x3e\\\x85\u2028\u2029]/g;
+
+/**
+ * Matches characters that need to be escaped for the named directives.
+ * @type RegExp
+ * @private
+ */
+soy.esc.$$MATCHER_FOR_ESCAPE_JS_REGEX_ = /[\x00\x08-\x0d\x22\x24\x26-\/\x3a\x3c-\x3f\x5b-\x5e\x7b-\x7d\x85\u2028\u2029]/g;
+
+/**
+ * Matches characters that need to be escaped for the named directives.
+ * @type RegExp
+ * @private
+ */
+soy.esc.$$MATCHER_FOR_ESCAPE_CSS_STRING_ = /[\x00\x08-\x0d\x22\x26-\x2a\/\x3a-\x3e@\\\x7b\x7d\x85\xa0\u2028\u2029]/g;
+
+/**
+ * Matches characters that need to be escaped for the named directives.
+ * @type RegExp
+ * @private
+ */
+soy.esc.$$MATCHER_FOR_NORMALIZE_URI__AND__FILTER_NORMALIZE_URI_ = /[\x00- \x22\x27-\x29\x3c\x3e\\\x7b\x7d\x7f\x85\xa0\u2028\u2029\uff01\uff03\uff04\uff06-\uff0c\uff0f\uff1a\uff1b\uff1d\uff1f\uff20\uff3b\uff3d]/g;
+
+/**
+ * A pattern that vets values produced by the named directives.
+ * @type RegExp
+ * @private
+ */
+soy.esc.$$FILTER_FOR_FILTER_CSS_VALUE_ = /^(?!-*(?:expression|(?:moz-)?binding))(?:[.#]?-?(?:[_a-z0-9-]+)(?:-[_a-z0-9-]+)*-?|-?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[a-z]{1,2}|%)?|!important|)$/i;
+
+/**
+ * A pattern that vets values produced by the named directives.
+ * @type RegExp
+ * @private
+ */
+soy.esc.$$FILTER_FOR_FILTER_NORMALIZE_URI_ = /^(?:(?:https?|mailto):|[^&:\/?#]*(?:[\/?#]|$))/i;
+
+/**
+ * A pattern that vets values produced by the named directives.
+ * @type RegExp
+ * @private
+ */
+soy.esc.$$FILTER_FOR_FILTER_HTML_ATTRIBUTES_ = /^(?!style|on|action|archive|background|cite|classid|codebase|data|dsync|href|longdesc|src|usemap)(?:[a-z0-9_$:-]*)$/i;
+
+/**
+ * A pattern that vets values produced by the named directives.
+ * @type RegExp
+ * @private
+ */
+soy.esc.$$FILTER_FOR_FILTER_HTML_ELEMENT_NAME_ = /^(?!script|style|title|textarea|xmp|no)[a-z0-9_$:-]*$/i;
+
+/**
+ * A helper for the Soy directive |escapeHtml
+ * @param {*} value Can be of any type but will be coerced to a string.
+ * @return {string} The escaped text.
+ */
+soy.esc.$$escapeHtmlHelper = function(value) {
+ var str = String(value);
+ return str.replace(
+ soy.esc.$$MATCHER_FOR_ESCAPE_HTML_,
+ soy.esc.$$REPLACER_FOR_ESCAPE_HTML__AND__NORMALIZE_HTML__AND__ESCAPE_HTML_NOSPACE__AND__NORMALIZE_HTML_NOSPACE_);
+};
+
+/**
+ * A helper for the Soy directive |normalizeHtml
+ * @param {*} value Can be of any type but will be coerced to a string.
+ * @return {string} The escaped text.
+ */
+soy.esc.$$normalizeHtmlHelper = function(value) {
+ var str = String(value);
+ return str.replace(
+ soy.esc.$$MATCHER_FOR_NORMALIZE_HTML_,
+ soy.esc.$$REPLACER_FOR_ESCAPE_HTML__AND__NORMALIZE_HTML__AND__ESCAPE_HTML_NOSPACE__AND__NORMALIZE_HTML_NOSPACE_);
+};
+
+/**
+ * A helper for the Soy directive |escapeHtmlNospace
+ * @param {*} value Can be of any type but will be coerced to a string.
+ * @return {string} The escaped text.
+ */
+soy.esc.$$escapeHtmlNospaceHelper = function(value) {
+ var str = String(value);
+ return str.replace(
+ soy.esc.$$MATCHER_FOR_ESCAPE_HTML_NOSPACE_,
+ soy.esc.$$REPLACER_FOR_ESCAPE_HTML__AND__NORMALIZE_HTML__AND__ESCAPE_HTML_NOSPACE__AND__NORMALIZE_HTML_NOSPACE_);
+};
+
+/**
+ * A helper for the Soy directive |normalizeHtmlNospace
+ * @param {*} value Can be of any type but will be coerced to a string.
+ * @return {string} The escaped text.
+ */
+soy.esc.$$normalizeHtmlNospaceHelper = function(value) {
+ var str = String(value);
+ return str.replace(
+ soy.esc.$$MATCHER_FOR_NORMALIZE_HTML_NOSPACE_,
+ soy.esc.$$REPLACER_FOR_ESCAPE_HTML__AND__NORMALIZE_HTML__AND__ESCAPE_HTML_NOSPACE__AND__NORMALIZE_HTML_NOSPACE_);
+};
+
+/**
+ * A helper for the Soy directive |escapeJsString
+ * @param {*} value Can be of any type but will be coerced to a string.
+ * @return {string} The escaped text.
+ */
+soy.esc.$$escapeJsStringHelper = function(value) {
+ var str = String(value);
+ return str.replace(
+ soy.esc.$$MATCHER_FOR_ESCAPE_JS_STRING_,
+ soy.esc.$$REPLACER_FOR_ESCAPE_JS_STRING__AND__ESCAPE_JS_REGEX_);
+};
+
+/**
+ * A helper for the Soy directive |escapeJsRegex
+ * @param {*} value Can be of any type but will be coerced to a string.
+ * @return {string} The escaped text.
+ */
+soy.esc.$$escapeJsRegexHelper = function(value) {
+ var str = String(value);
+ return str.replace(
+ soy.esc.$$MATCHER_FOR_ESCAPE_JS_REGEX_,
+ soy.esc.$$REPLACER_FOR_ESCAPE_JS_STRING__AND__ESCAPE_JS_REGEX_);
+};
+
+/**
+ * A helper for the Soy directive |escapeCssString
+ * @param {*} value Can be of any type but will be coerced to a string.
+ * @return {string} The escaped text.
+ */
+soy.esc.$$escapeCssStringHelper = function(value) {
+ var str = String(value);
+ return str.replace(
+ soy.esc.$$MATCHER_FOR_ESCAPE_CSS_STRING_,
+ soy.esc.$$REPLACER_FOR_ESCAPE_CSS_STRING_);
+};
+
+/**
+ * A helper for the Soy directive |filterCssValue
+ * @param {*} value Can be of any type but will be coerced to a string.
+ * @return {string} The escaped text.
+ */
+soy.esc.$$filterCssValueHelper = function(value) {
+ var str = String(value);
+ if (!soy.esc.$$FILTER_FOR_FILTER_CSS_VALUE_.test(str)) {
+ return 'zSoyz';
+ }
+ return str;
+};
+
+/**
+ * A helper for the Soy directive |normalizeUri
+ * @param {*} value Can be of any type but will be coerced to a string.
+ * @return {string} The escaped text.
+ */
+soy.esc.$$normalizeUriHelper = function(value) {
+ var str = String(value);
+ return str.replace(
+ soy.esc.$$MATCHER_FOR_NORMALIZE_URI__AND__FILTER_NORMALIZE_URI_,
+ soy.esc.$$REPLACER_FOR_NORMALIZE_URI__AND__FILTER_NORMALIZE_URI_);
+};
+
+/**
+ * A helper for the Soy directive |filterNormalizeUri
+ * @param {*} value Can be of any type but will be coerced to a string.
+ * @return {string} The escaped text.
+ */
+soy.esc.$$filterNormalizeUriHelper = function(value) {
+ var str = String(value);
+ if (!soy.esc.$$FILTER_FOR_FILTER_NORMALIZE_URI_.test(str)) {
+ return '#zSoyz';
+ }
+ return str.replace(
+ soy.esc.$$MATCHER_FOR_NORMALIZE_URI__AND__FILTER_NORMALIZE_URI_,
+ soy.esc.$$REPLACER_FOR_NORMALIZE_URI__AND__FILTER_NORMALIZE_URI_);
+};
+
+/**
+ * A helper for the Soy directive |filterHtmlAttributes
+ * @param {*} value Can be of any type but will be coerced to a string.
+ * @return {string} The escaped text.
+ */
+soy.esc.$$filterHtmlAttributesHelper = function(value) {
+ var str = String(value);
+ if (!soy.esc.$$FILTER_FOR_FILTER_HTML_ATTRIBUTES_.test(str)) {
+ return 'zSoyz';
+ }
+ return str;
+};
+
+/**
+ * A helper for the Soy directive |filterHtmlElementName
+ * @param {*} value Can be of any type but will be coerced to a string.
+ * @return {string} The escaped text.
+ */
+soy.esc.$$filterHtmlElementNameHelper = function(value) {
+ var str = String(value);
+ if (!soy.esc.$$FILTER_FOR_FILTER_HTML_ELEMENT_NAME_.test(str)) {
+ return 'zSoyz';
+ }
+ return str;
+};
+
+/**
+ * Matches all tags, HTML comments, and DOCTYPEs in tag soup HTML.
+ * By removing these, and replacing any '<' or '>' characters with
+ * entities we guarantee that the result can be embedded into a
+ * an attribute without introducing a tag boundary.
+ *
+ * @type {RegExp}
+ * @private
+ */
+soy.esc.$$HTML_TAG_REGEX_ = /<(?:!|\/?([a-zA-Z][a-zA-Z0-9:\-]*))(?:[^>'"]|"[^"]*"|'[^']*')*>/g;
+
+/**
+ * Matches all occurrences of '<'.
+ *
+ * @type {RegExp}
+ * @private
+ */
+soy.esc.$$LT_REGEX_ = /</g;
+
+/**
+ * Maps lower-case names of innocuous tags to 1.
+ *
+ * @type {Object.<string,number>}
+ * @private
+ */
+soy.esc.$$SAFE_TAG_WHITELIST_ = {'b': 1, 'br': 1, 'em': 1, 'i': 1, 's': 1, 'sub': 1, 'sup': 1, 'u': 1};
+
+// END GENERATED CODE
diff --git a/blockly/demos/plane/style.css b/blockly/demos/plane/style.css
new file mode 100644
index 0000000..16e2c6f
--- /dev/null
+++ b/blockly/demos/plane/style.css
@@ -0,0 +1,97 @@
+body {
+ background-color: #fff;
+ font-family: sans-serif;
+ margin-top: 0;
+}
+h1 {
+ font-weight: normal;
+ font-size: 140%;
+}
+.farSide {
+ text-align: right;
+}
+html[dir="RTL"] .farSide {
+ text-align: left;
+}
+.tab {
+ padding: 6px 12px;
+ text-decoration: none;
+ color: #000;
+}
+#selected {
+ font-weight: bold;
+ background-color: #ddd;
+ border-radius: 20px;
+}
+
+/* Pulse the language menu once to draw attention to it. */
+#languageBorder {
+ border-radius: 4px;
+ animation: pulse 2s ease-in-out forwards;
+ animation-delay: 2s;
+}
+@keyframes pulse {
+ 0% { background-color: #fff }
+ 50% { background-color: #f00 }
+ 100% { background-color: #fff }
+}
+
+#blockly {
+ height: 300px;
+ width: 100%;
+ border-style: solid;
+ border-color: #ddd;
+ border-width: 0 1px 1px 0;
+}
+
+/* SVG Plane. */
+#plane {
+ overflow: hidden;
+}
+#fuselage {
+ fill: #fff;
+ stroke: #000;
+}
+#wing, #tail {
+ fill: #ddd;
+ stroke: #444;
+}
+.crew {
+ fill: #f44;
+ stroke: #000;
+}
+.seat1st {
+ fill: #88f;
+ stroke: #000;
+}
+.seat2nd {
+ fill: #8b8;
+ stroke: #000;
+}
+#seatYes, #seatNo {
+ font-size: 40pt;
+}
+text {
+ font-family: sans-serif;
+ font-size: 20pt;
+ fill: #444;
+}
+html[dir="RTL"] #plane text {
+ text-anchor: end;
+}
+
+/* Slider. */
+.sliderTrack {
+ stroke: #aaa;
+ stroke-width: 6px;
+ stroke-linecap: round;
+}
+.sliderKnob {
+ fill: #ddd;
+ stroke: #bbc;
+ stroke-width: 1px;
+ stroke-linejoin: round;
+}
+.sliderKnob:hover {
+ fill: #eee;
+}
diff --git a/blockly/demos/plane/template.soy b/blockly/demos/plane/template.soy
new file mode 100644
index 0000000..5b19e99
--- /dev/null
+++ b/blockly/demos/plane/template.soy
@@ -0,0 +1,225 @@
+{namespace planepage}
+
+/**
+ * This is a Closure Template.
+ *
+ * See the README.txt for details.
+ */
+
+/**
+ * Translated messages for use in JavaScript.
+ */
+{template .messages}
+ <div style="display: none">
+ <span id="Plane_rows">{msg meaning="Plane.rows" desc="page text - Total number of rows of seats on an airplane.\n\nParameters:\n* %1 - number of rows of seats on an airplane. It is always an integer greater than or equal to zero."}Rows: %1{/msg}</span>
+ <span id="Plane_getRows">{msg meaning="Plane.getRows" desc="block text - The number of rows on the airplane, to be used in a mathematical equation, such as: 'seats = 4 x '''rows (5)''''.\n\nParameters:\n* %1 - number of rows of seats on an airplane. It is always an integer greater than or equal to zero."}rows (%1){/msg}</span>
+ <span id="Plane_rows1">{msg meaning="Plane.rows1" desc="page text - The number of rows of first-class seats on the airplane. You can see the block at [http://blockly-share.appspot.com/static/apps/plane/plane.html?lang=en&level=3].\n\nParameters:\n* %1 - number of rows of first-class seats on an airplane. It is always an integer greater than or equal to zero."}1st class rows: %1{/msg}</span>
+ <span id="Plane_getRows1">{msg meaning="Plane.getRows1" desc="block text - The number of rows of first-class seats on the, to be used in a mathematical equation. See [http://blockly-share.appspot.com/static/apps/plane/plane.html?lang=en&level=3].\n\nParameters:\n* %1 - number of rows of first-class seats on an airplane. It is always an integer greater than or equal to zero."}1st class rows (%1){/msg}</span>
+ <span id="Plane_rows2">{msg meaning="Plane.rows2" desc="page text - The number of rows of second-class seats on the airplane. %1 is an integer greater or equal to zero. See [http://blockly-share.appspot.com/static/apps/plane/plane.html?lang=en&level=3].\n\nParameters:\n* %1 - number of rows of second-class seats on an airplane. It is always an integer greater than or equal to zero."}2nd class rows: %1{/msg}</span>
+ <span id="Plane_getRows2">{msg meaning="Plane.getRows2" desc="block text - The number of rows of second-class (also called 'economy class') seats on the airplane, to be used in a mathematical expression.\n\nParameters:\n* %1 - number of rows of second-class seats on an airplane. It is always an integer greater than or equal to zero."}2nd class rows (%1){/msg}</span>
+ <span id="Plane_seats">{msg meaning="Plane.seats" desc="page text - The total number of seats on the airplane.\n\nParameters:\n* %1 - number of seats on an airplane. It is always either the next message or an integer greater than or equal to zero."}Seats: %1{/msg}</span>
+ <span id="Plane_placeholder">{msg meaning="Plane.placeholder" desc="page text - A word or symbol indicating that this numeric value has not yet been determined."}?{/msg}</span>
+ <span id="Plane_setSeats">{msg meaning="Plane.setSeats" desc="block text - The first half of a mathematical equation determining the number of seats in an airplane, such as: ''''seats =''' 4 x rows'."}seats ={/msg}</span>
+ </div>
+{/template}
+
+/**
+ * Web page structure.
+ */
+{template .start}
+ {call .messages /}
+ <table width="100%">
+ <tr>
+ <td>
+ <h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt;{sp}
+ <a href="../index.html">Demos</a>&rlm; &gt;{sp}
+ <span id="title">
+ {msg meaning="Plane.plane" desc="title - Specifies that this is Blockly's '''Plane''' (airplane) tutorial. The word 'plane' was chosen over 'airplane' in English because it is shorter and less formal."}
+ Plane Seat Calculator
+ {/msg}
+ </span>
+ {sp}&nbsp;{sp}
+ {for $i in range(1, $ij.maxLevel + 1)}
+ {sp}
+ {if $i == $ij.level}
+ <span class="tab" id="selected">{$i}</span>
+ {else}
+ {if $i < $ij.level}
+ <a class="tab previous" href="?lang={$ij.lang}&level={$i}">{$i}</a>
+ {else}
+ <a class="tab" href="?lang={$ij.lang}&level={$i}">{$i}</a>
+ {/if}
+ {/if}
+ {/for}
+ </h1>
+ </td>
+ <td class="farSide">
+ <span {if $ij.lang == 'en'}id="languageBorder"{/if} style="padding: 10px">
+ <select id="languageMenu"></select>
+ </span>
+ </td>
+ </tr>
+ </table>
+
+ <script src="slider.js"></script>
+ <svg
+ id="plane"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ version="1.1"
+ width="600"
+ height="320"
+ viewBox="0 110 600 320">
+ <defs>
+ <g id="row1st">
+ <rect
+ class="seat1st"
+ width="10" height="10"
+ x="75" y="243" />
+ <rect
+ class="seat1st"
+ width="10" height="10"
+ x="75" y="254" />
+ <rect
+ class="seat1st"
+ width="10" height="10"
+ x="75" y="272" />
+ <rect
+ class="seat1st"
+ width="10" height="10"
+ x="75" y="283" />
+ </g>
+ <g id="row2nd">
+ <rect
+ class="seat2nd"
+ width="10" height="8"
+ x="75" y="243" />
+ <rect
+ class="seat2nd"
+ width="10" height="8"
+ x="75" y="251" />
+ <rect
+ class="seat2nd"
+ width="10" height="8"
+ x="75" y="269" />
+ <rect
+ class="seat2nd"
+ width="10" height="8"
+ x="75" y="277" />
+ <rect
+ class="seat2nd"
+ width="10" height="8"
+ x="75" y="285" />
+ </g>
+ <linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%">
+ <stop offset="0%" style="stop-color:#fff;stop-opacity:0" />
+ <stop offset="100%" style="stop-color:#fff;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%">
+ <stop offset="0%" style="stop-color:#fff;stop-opacity:0" />
+ <stop offset="100%" style="stop-color:#fff;stop-opacity:1" />
+ </linearGradient>
+ </defs>
+ <path
+ d="m 214,270 l 159,-254 31,-16 -74,189 0,162 74,189 -31,16 z"
+ id="wing" />
+ <path
+ d="m 577,270 22,-93 -27,6 -44,88 44,88 27,6 z"
+ id="tail" />
+ <path
+ d="m 577,270 l -94,24 h -407 c -38,0 -75,-13 -75,-26 c 0,-13 38,-26 75,-26 h 407 z"
+ id="fuselage" />
+ <rect
+ width="610"
+ height="100"
+ x="-5"
+ y="110"
+ fill="url(#grad1)" />
+ <rect
+ width="610"
+ height="100"
+ x="-5"
+ y="330"
+ fill="url(#grad2)" />
+ <text id="row1stText" x="55" y="380"></text>
+ <text id="row2ndText" x="55" y="420"></text>
+ <text x="55" y="210">
+ <tspan id="seatText"></tspan>
+ <tspan id="seatYes" style="fill: #0c0;" dy="10">&#x2713;</tspan>
+ <tspan id="seatNo" style="fill: #f00;" dy="10">&#x2717;</tspan>
+ </text>
+ {if $ij.level > 1}
+ <rect
+ id="crew_right" class="crew"
+ width="10" height="10"
+ x="35" y="254" />
+ <rect
+ id="crew_left" class="crew"
+ width="10" height="10"
+ x="35" y="272" />
+ {/if}
+ </svg>
+
+ <p>
+ {switch $ij.level}
+ {case 1}
+ {msg meaning="Plane.description1" desc="instructions - Note that in [http://blockly-share.appspot.com/static/apps/plane/plane.html?lang=en&level=1 this level], there is only one type of seat on the plane."}An airplane has a number of rows of passenger seats. Each row contains four seats.{/msg}
+ {case 2}
+ {msg meaning="Plane.description2" desc="instructions - Note that in [http://blockly-share.appspot.com/static/apps/plane/plane.html?lang=en&level=2 this level], there are two types of seats on this plane."}An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.{/msg}
+ {case 3}
+ {msg meaning="Plane.description3" desc="instructions - Note that in [http://blockly-share.appspot.com/static/apps/plane/plane.html?lang=en&level=3 this level], there are three types of seats on this plane. Be sure to use the same terms for '1st class' and '2nd class' as you did for the earlier messages."}An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.{/msg}
+ {/switch}
+ </p>
+ <p>
+ {msg meaning="Plane.instructions" desc="page text - This text appears below the airplane graphic and above the space for the user to create the formula. The number of rows an the graphic may be changed by the user with a slider. See [http://blockly-share.appspot.com/static/apps/plane/plane.html?lang=en&level=1] for a picture."}Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).{/msg}
+ </p>
+
+ <script src="../../blockly_compressed.js"></script>
+ <script src="../../blocks_compressed.js"></script>
+ <script src="../../javascript_compressed.js"></script>
+ <script src="../../msg/js/{$ij.lang}.js"></script>
+ <script src="blocks.js"></script>
+ {call .toolbox /}
+ <div id="blockly"></div>
+{/template}
+
+/**
+ * Toolboxes for each level.
+ */
+{template .toolbox}
+ <xml id="toolbox" style="display: none">
+ <block type="math_number"></block>
+ <block type="math_arithmetic">
+ <value name="A">
+ <shadow type="math_number">
+ <field name="NUM">1</field>
+ </shadow>
+ </value>
+ <value name="B">
+ <shadow type="math_number">
+ <field name="NUM">1</field>
+ </shadow>
+ </value>
+ </block>
+ <block type="math_arithmetic">
+ <field name="OP">MULTIPLY</field>
+ <value name="A">
+ <shadow type="math_number">
+ <field name="NUM">1</field>
+ </shadow>
+ </value>
+ <value name="B">
+ <shadow type="math_number">
+ <field name="NUM">1</field>
+ </shadow>
+ </value>
+ </block>
+ {if $ij.level <= 2}
+ <block type="plane_get_rows"></block>
+ {else}
+ <block type="plane_get_rows1st"></block>
+ <block type="plane_get_rows2nd"></block>
+ {/if}
+ </xml>
+{/template}
diff --git a/blockly/demos/plane/xlf/extracted_msgs.xlf b/blockly/demos/plane/xlf/extracted_msgs.xlf
new file mode 100644
index 0000000..6a4fd44
--- /dev/null
+++ b/blockly/demos/plane/xlf/extracted_msgs.xlf
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" xml:space="preserve" source-language="en">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <note priority="1" from="description">page text - Total number of rows of seats on an airplane.\n\nParameters:\n* %1 - number of rows of seats on an airplane. It is always an integer greater than or equal to zero.</note>
+ <note priority="1" from="meaning">Plane.rows</note>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <note priority="1" from="description">block text - The first half of a mathematical equation determining the number of seats in an airplane, such as: ''''seats =''' 4 x rows'.</note>
+ <note priority="1" from="meaning">Plane.setSeats</note>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <note priority="1" from="description">instructions - Note that in [http://blockly-share.appspot.com/static/apps/plane/plane.html?lang=en&amp;level=3 this level], there are three types of seats on this plane. Be sure to use the same terms for '1st class' and '2nd class' as you did for the earlier messages.</note>
+ <note priority="1" from="meaning">Plane.description3</note>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <note priority="1" from="description">page text - A word or symbol indicating that this numeric value has not yet been determined.</note>
+ <note priority="1" from="meaning">Plane.placeholder</note>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <note priority="1" from="description">page text - This text appears below the airplane graphic and above the space for the user to create the formula. The number of rows an the graphic may be changed by the user with a slider. See [http://blockly-share.appspot.com/static/apps/plane/plane.html?lang=en&amp;level=1] for a picture.</note>
+ <note priority="1" from="meaning">Plane.instructions</note>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <note priority="1" from="description">instructions - Note that in [http://blockly-share.appspot.com/static/apps/plane/plane.html?lang=en&amp;level=2 this level], there are two types of seats on this plane.</note>
+ <note priority="1" from="meaning">Plane.description2</note>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <note priority="1" from="description">block text - The number of rows of first-class seats on the, to be used in a mathematical equation. See [http://blockly-share.appspot.com/static/apps/plane/plane.html?lang=en&amp;level=3].\n\nParameters:\n* %1 - number of rows of first-class seats on an airplane. It is always an integer greater than or equal to zero.</note>
+ <note priority="1" from="meaning">Plane.getRows1</note>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <note priority="1" from="description">page text - The number of rows of second-class seats on the airplane. %1 is an integer greater or equal to zero. See [http://blockly-share.appspot.com/static/apps/plane/plane.html?lang=en&amp;level=3].\n\nParameters:\n* %1 - number of rows of second-class seats on an airplane. It is always an integer greater than or equal to zero.</note>
+ <note priority="1" from="meaning">Plane.rows2</note>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <note priority="1" from="description">page text - The total number of seats on the airplane.\n\nParameters:\n* %1 - number of seats on an airplane. It is always either the next message or an integer greater than or equal to zero.</note>
+ <note priority="1" from="meaning">Plane.seats</note>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <note priority="1" from="description">title - Specifies that this is Blockly's '''Plane''' (airplane) tutorial. The word 'plane' was chosen over 'airplane' in English because it is shorter and less formal.</note>
+ <note priority="1" from="meaning">Plane.plane</note>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <note priority="1" from="description">block text - The number of rows on the airplane, to be used in a mathematical equation, such as: 'seats = 4 x '''rows (5)''''.\n\nParameters:\n* %1 - number of rows of seats on an airplane. It is always an integer greater than or equal to zero.</note>
+ <note priority="1" from="meaning">Plane.getRows</note>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <note priority="1" from="description">page text - The number of rows of first-class seats on the airplane. You can see the block at [http://blockly-share.appspot.com/static/apps/plane/plane.html?lang=en&amp;level=3].\n\nParameters:\n* %1 - number of rows of first-class seats on an airplane. It is always an integer greater than or equal to zero.</note>
+ <note priority="1" from="meaning">Plane.rows1</note>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <note priority="1" from="description">instructions - Note that in [http://blockly-share.appspot.com/static/apps/plane/plane.html?lang=en&amp;level=1 this level], there is only one type of seat on the plane.</note>
+ <note priority="1" from="meaning">Plane.description1</note>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <note priority="1" from="description">block text - The number of rows of second-class (also called 'economy class') seats on the airplane, to be used in a mathematical expression.\n\nParameters:\n* %1 - number of rows of second-class seats on an airplane. It is always an integer greater than or equal to zero.</note>
+ <note priority="1" from="meaning">Plane.getRows2</note>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_ar.xlf b/blockly/demos/plane/xlf/translated_msgs_ar.xlf
new file mode 100644
index 0000000..c9b8e16
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_ar.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="ar">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>الصفوف: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>المقاعد =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>طائرة بمقعدين في مقطورة الطيّار (للطيار ومساعده) وعدد من المقاعد في صفوف الدرجة الأولى والثانية. كل صف من صفوف الدرجة الأولى يحتوي على أربعة مقاعد. ويحتوي كل صف في الدرجة الثانية على خمسة مقاعد.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>؟</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>لبناء صيغة (أدناه) تقوم بحساب إجمالي عدد المقاعد في الطائرة عند تغيير الصفوف (أعلاه).</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>طائرة بمقعدين في مقطورة الطيّار (للطيار ومساعده) وعدد من الصفوف يحتوي كل صف على أربعة مقاعد.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>صفوف الطبقة الأولى (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>صفوف الفئة الثانية: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>المقاعد: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>آلة حاسبة لمقعد الطائرة</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>الصفوف (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>صفوف الطبقة الأولى: %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>هنالك طائرة تحتوي على عدد من صفوف مقاعد الركاب. كل صف يحتوي على أربعة مقاعد.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>صفوف الفئة الثانية: (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_be-tarask.xlf b/blockly/demos/plane/xlf/translated_msgs_be-tarask.xlf
new file mode 100644
index 0000000..4580b5f
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_be-tarask.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="be-tarask">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>Радкоў: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>месцаў =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>Самалёт мае два месцы ў кабіне экіпажа (пілот і другі пілот), і некалькі пасажырскіх шэрагаў месцаў 1-га кляса і 2-га кляса. Кожны шэраг 1-га кляса утрымлівае чатыры месцы. Кожны шэраг 2-га кляса ўтрымлівае пяць месцаў.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>Пабудаваць формулу (ніжэй), якая падлічвае агульную колькасьць месцаў у самалёце пры зьмене радоў (гл. вышэй).</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Самалёт мае два месцы ў кабіне экіпажа (пілот і другі пілот), і некалькі шэрагаў пасажырскіх сядзеньняў. Кожны шэраг утрымлівае чатыры месцы.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>радкі першага клясу (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>Радкі другога клясу: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>Месцаў: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>Калькулятар месцаў у самалёце</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>радкоў (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>Радкі першага клясу: %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Самалёт мае некалькі шэрагаў пасажырскіх сядзеньняў. Кожная шэраг утрымлівае чатыры месцы.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>радкі другога клясу (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_br.xlf b/blockly/demos/plane/xlf/translated_msgs_br.xlf
new file mode 100644
index 0000000..4a7fc0c
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_br.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="br">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>Renkennadoù : %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>azezennoù =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>En un nijerez ez eus div azezenn el logell leviañ(evit al loman hag an eil loman), hag un toullad renkennadoù azezennoù tremenidi kentañ hag eil klas. Peder azezenn zo e pep renkennad kentañ klas. Pemp azezenn zo e pemp renkennad eil klas.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>Sevel ur formulenn (amañ dindan) evit jediñ an niver a azezennoù en holl en nijerez pa vez kemmet an niver a renkennadoù (amañ a-us).</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>En un nijerez ez eus div azezenn el logell leviañ(evit al loman hag an eil loman), hag ur toullad renkennadoù azezennoù evit an dremenidi. Peder azezenn zo e pep renkennad.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>Renkennadoù kentañ klas (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>Renkennadoù eil klas : %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>Azezennoù : %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>Jederez azezenn nijerez</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>renkennadoù (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>Renkennadoù kentañ klas : %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Un nijerez he deus un toullad renkennadoù azezennoù evit ar veajourien. Peder azezenn a zo e pep renkennad.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>Renkennadoù eil klas (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_ca.xlf b/blockly/demos/plane/xlf/translated_msgs_ca.xlf
new file mode 100644
index 0000000..17dfe65
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_ca.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="ca">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>Files: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>seients =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>Un avió té dos seients en la cabina de vol (pel pilot i copilot) i un nombre de files per seients de passatgers de primera classe i de segona classe. Cada fila de primera classe conté quatre seients. Cada fila de segona classe conté cinc seients.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>Construïu una fórmula (a sota) que calculi el nombre total de seients de l'avió a mida que canviïn les files (a dalt).</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Un avió té dos seients en la cabina de vol (pel pilot i pel copilot) i un nombre de files de seients de passatgers. Cada fila conté quatre seients.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>files de primera classe (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>files de segona classe: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>Seients: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>Calculadora de seients d'avió</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>files (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>files de primera classe: %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Un avió té un nombre de files de seients de passatgers. Cada fila conté quatre seients.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>files de segona classe (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_da.xlf b/blockly/demos/plane/xlf/translated_msgs_da.xlf
new file mode 100644
index 0000000..752fe24
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_da.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="da">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>Rækker: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>sæder =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>Et fly har to pladser i cockpittet (til pilot og med-pilot), og et antal rækker af 1. klasses og 2. klasses passagersæder. Hver 1. klasses række indeholder fire sæder. Hver 2. klasses række indeholder fem sæder.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>Opbyg en formel (nedenfor), der beregner det samlede antal pladser på flyet, hvis antal rækker ændres (ovenfor).</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Et fly har to pladser i cockpittet (til pilot og med-pilot), og et antal rækker af passagersæder. Hver række indeholder fire sæder.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>1. klasse rækker (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>2. klasse rækker: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>Sæder: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>Flysædelommeregner</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>rækker (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>1. klasse rækker: %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Et fly har et antal rækker af passagersæder. Hver række indeholder fire sæder.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>2. klasse rækker (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_de.xlf b/blockly/demos/plane/xlf/translated_msgs_de.xlf
new file mode 100644
index 0000000..f06bc77
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_de.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="de">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>Reihen: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>Sitze =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>Ein Flugzeug hat zwei Sitze im Pilotenstand (für den Piloten und Co-Piloten) und eine Anzahl an Reihen mit Passagiersitzen der 1. und 2. Klasse. Jede 1.-Klasse-Reihe enthält vier Sitze. Jede 2.-Klasse-Reihe enthält fünf Sitze.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>Erstelle eine Formel (unten), die die gesamte Anzahl an Sitzen im Flugzeug berechnet, wenn die Reihen (oben) geändert werden.</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Ein Flugzeug hat zwei Sitze im Pilotenstand (für den Piloten und Co-Piloten) und eine Anzahl an Reihen mit Passagiersitzen. Jede Reihe enthält vier Sitze.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>Reihen der 1. Klasse (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>Reihen der 2. Klasse: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>Sitze: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>Flugzeugsitzrechner</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>Reihen (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>Reihen der 1. Klasse: %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Ein Flugzeug hat eine Anzahl an Reihen mit Passagiersitzen. Jede Reihe enthält vier Sitze.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>Reihen der 2. Klasse (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_el.xlf b/blockly/demos/plane/xlf/translated_msgs_el.xlf
new file mode 100644
index 0000000..5acb291
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_el.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="el">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>Σειρές: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>καθίσματα =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>Ένα αεροπλάνο έχει δύο καθίσματα στον θάλαμο διακυβέρνησης (για τον κυβερνήτη και τον συγκυβερνήτη), καθώς και έναν αριθμό σειρών καθισμάτων για την 1η και 2η θέση. Κάθε σειρά της 1ης θέσης έχει τέσσερα καθίσματα και κάθε σειρά της 2ης θέσης έχει πέντε καθίσματα.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>;</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>Φτιάξε έναν τύπο (κάτω) που θα υπολογίζει τον συνολικό αριθμό καθισμάτων του αεροπλάνου καθώς αλλάζουν οι σειρές (πάνω).</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Ένα αεροπλάνο έχει δύο καθίσματα στον θάλαμο διακυβέρνησης (για τον κυβερνήτη και τον συγκυβερνήτη), καθώς και έναν αριθμό από σειρές καθισμάτων επιβατών. Κάθε σειρά έχει τέσσερα καθίσματα.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>Σειρές 1ης θέσης (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>Σειρές 2ης θέσης: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>Καθίσματα: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>Υπολογισμός Θέσεων Σε Αεροπλάνο</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>σειρές (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>Σειρές 1ης θέσης: %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Ένα αεροπλάνο έχει έναν συγκεκριμένο αριθμό σειρών καθισμάτων επιβατών. Κάθε σειρά έχει τέσσερα καθίσματα.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>Σειρές 2ης θέσης (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_en.xlf b/blockly/demos/plane/xlf/translated_msgs_en.xlf
new file mode 100644
index 0000000..e471a00
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_en.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="en">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>Rows: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>seats =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>1st class rows (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>2nd class rows: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>Seats: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>Plane Seat Calculator</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>rows (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>1st class rows: %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>An airplane has a number of rows of passenger seats. Each row contains four seats.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>2nd class rows (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_es.xlf b/blockly/demos/plane/xlf/translated_msgs_es.xlf
new file mode 100644
index 0000000..e2022b5
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_es.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="es">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>Filas: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>asientos =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>Un avión tiene dos asientos en la cabina de vuelo (para el piloto y co-piloto), y un número de filas de asientos para pasajeros de primera y segunda clase. Cada fila de la primera clase contiene cuatro asientos. Cada fila de la segunda clase contiene cinco asientos.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>Construir una fórmula (abajo) que calcule el número total de asientos en el avión cuando las filas sean cambiadas (arriba).</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Un avión tiene dos asientos en la cabina de vuelo (para el piloto y co-piloto), y un número de filas de asientos de pasajeros. Cada fila contiene cuatro asientos.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>Filas de primera clase: (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>Filas de segunda clase: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>Asientos: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>Calculadora de asientos de avión</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>filas (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>Filas de primera clase: %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Un avión  tiene un número de filas de asientos de pasajeros. Cada fila contiene cuatro asientos.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>Filas de segunda clase: (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_et.xlf b/blockly/demos/plane/xlf/translated_msgs_et.xlf
new file mode 100644
index 0000000..d88be0a
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_et.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="en">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>Ridu: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>istmete arv =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>Lennuki kokpitis on kaks istet (üks kummalegi piloodile), mingi arv ridu 1. klassi reisijatele ja mingi arv ridu 2. klassi reisijatele. Igas 1. klassi reas on neli istet, igas 2. klassi reas viis istet.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>Ehita plokkidest valem, mis arvutab istmete arvu lennukis õigesti sõltumata ridade arvust (seda saad muuta lennuki juures oleva liuguriga).</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Lennuki kokpitis on kaks istet (üks kummalegi piloodile) ja mingi arv istemridu reisijatele. Igas reas on neli istet.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>1. klassi ridu (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>2. klassi ridu: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>Istmeid: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>Lennukiistmete kalkulaator</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>rows (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>1. klassi ridu: %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Lennukis on reisijate istmed mitmes reas. Igas reas on neli istet.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>2. klassi ridu (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_fa.xlf b/blockly/demos/plane/xlf/translated_msgs_fa.xlf
new file mode 100644
index 0000000..264ec31
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_fa.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="fa">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>ردیف: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>صندلی‌ها =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>یک هواپیما دو صندلی در کابین خلبان دارد (برای خلبان و کمک خلبان) و تهداد از صندلی‌ها مسافرین درجه یک و درجه دو. هر ردیف درجه یک شامل چهار صندلی است. هر ردیف درجه دو شامل پنج صندلی است.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>؟</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>یک فرمول بسازید (پایین) که تعداد کل صندلی‌های هواپیما با تغییر ردیف را حساب کند (بالا).</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>یک هواپیما دو صندلی در عرشهٔ پرواز دارد (برای خلبان و کمک خلبان) و تعدادی صندلی مسافرین. هر ردیف شامل چهار صندلی است.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>اولین کلاس ردیف‌ها (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>دومین کلاس ردیف: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>صندلی‌ها: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>محاسبه‌گر صندلی‌های هواپیما</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>ردیف‌ها (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>اولین ردیف کلاس: %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>یک هواپیما تعداد از صندلی‌های مسافرین را دارد. هر ردیف شمال چهار صندلی است.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>دومین کلاس ردیف‌ها (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_fr.xlf b/blockly/demos/plane/xlf/translated_msgs_fr.xlf
new file mode 100644
index 0000000..9485da2
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_fr.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="fr">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>Rangées : %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>sièges =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>Un avion a deux sièges dans la cabine de pilotage (pour le pilote et le copilote), et un certain nombre de rangées de sièges passager de première et seconde classes. Chaque rangée de première classe contient quatre sièges. Chaque rangée de seconde classe contient cinq sièges.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>Construire une formule (ci-dessous) qui calcule le nombre total de sièges dans l’avion quand le nombre de rangées est modifié (ci-dessus).</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Un avion a deux sièges dans le poste de pilotage (pour le pilote et le copilote), et un certain nombre de rangées de sièges passager. Chaque rangée contient quatre sièges.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>rangées de première classe (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>rangées de seconde classe : %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>Sièges : %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>Calculateur de sièges d’avion</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>rangées (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>rangées de première classe : %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Un avion a un nombre de rangées de sièges passager. Chaque rangée contient quatre sièges.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>rangées de seconde classe (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_he.xlf b/blockly/demos/plane/xlf/translated_msgs_he.xlf
new file mode 100644
index 0000000..55ac148
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_he.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="he">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>שורות: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>מושבים =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>במטוס יש שני מושבים עבור הצוות (בשביל הטייס וטייס המשנה), ומספר שורות מושבים במחלקת הנוסעים הראשונה ובמחלקת הנוסעים השנייה. כל שורה במחלקה הראשונה מכילה ארבעה מושבים. כל שורה במחלקה השנייה מכילה חמישה מושבים.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>בנה נוסחה (למטה) אשר תחשב את סך כל המושבים במטוס בהתאם לשינוי מספר השורות (למעלה).</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>במטוס יש שני מושבים עבור הצוות (בשביל הטייס וטייס המשנה), ומספר שורות עם מושבי נוסעים. בכל שורה יש ארבעה מושבים.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>שורות במחלקה ראשונה (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>שורות במחלקה שנייה: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>מושבים: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>מחשבון מושב במטוס</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>שורות (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>שורות במחלקה ראשונה: %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>במטוס יש מספר שורות עם מושבי נוסעים. בכל שורה יש ארבעה מושבים.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>שורות במחלקה שנייה: (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_hrx.xlf b/blockly/demos/plane/xlf/translated_msgs_hrx.xlf
new file mode 100644
index 0000000..263d305
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_hrx.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="hrx">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>Reihe: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>Sitze =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>En Fluchzeich hot zwooi Sitze im Pilotstand (für den Pilot und Co-Pilot) und en Oonzohl an Reihe mit Passagiersitze der 1. und 2. Klasse. Jede 1.-Klasse-Reih enthält vier Sitze. Jede 2.-Klasse-Reih enthält fünf Sitze.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>Erstell en Formel (unne), die die gesamte Oonzohl an Sitze im Fluchzeich berechnet, wenn die Reihe (uwe) geännert sin.</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>En Fluchzeich hot zwooi Sitze im Pilotestand (für den Pilot und Co-Pilot) und en Oonzohl an Reihe mit Passagiersitze. Jede Reih enthält vier Sitze.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>Reihe von der 1. Klasse (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>Reihe von der 2. Klasse: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>Sitz: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>Fluchzeichsitzrechner</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>Reihe (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>Reihe von der 1. Klasse: %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>En Fluchzeich hot en Oonzohl an Reihe mit Passagiersitze. Jede Reih enthält vier Sitze.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>Reihe von der 2. Klasse (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_hu.xlf b/blockly/demos/plane/xlf/translated_msgs_hu.xlf
new file mode 100644
index 0000000..c44d1aa
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_hu.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="hu">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>Sorok száma: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>Ülések száma =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>Egy repülőgépnek 2 ülése van a pilótafülkében (a pilótának és a másodpilótának), az utasok 1. és 2. osztályon utazhatnak. Az 1. osztályon négy szék van egy sorban. A 2. osztályon öt szék van egy sorban.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>Készítsd el a képletet (lent) amivel kiszámolható, hogy hány ülés van összesen a repülőgépen annak függvényében, ahogy (fent) állítod a sorok számát.</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Egy repülőgépnek 2 ülése van a pilótafülkében (a pilótának és a másodpilótának), az utasok több sorban ülnek az utastérben. Az utastér minden sorában négy szék van.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>1. osztály sorai (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>2. osztály: %1 sor</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>Ülések száma összesen: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>Repülőgép alkalmazás</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>Sorok száma (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>1. osztály: %1 sor</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Egy repülőgépen az utasok több sorban ülnek az utastérben. Az utastér minden sorában négy szék van.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>2. osztály sorai (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_ia.xlf b/blockly/demos/plane/xlf/translated_msgs_ia.xlf
new file mode 100644
index 0000000..83ae2c6
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_ia.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="ia">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>Filas: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>sedes =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>Un avion ha duo sedes in le cabina (pro le pilota e le copilota) e un numero de filas de sedes pro passageros del prime classe e del secunde classes. Cata fila del prime classe contine quatro sedes. Cata fila del secunde classe contine cinque sedes.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>Construe un formula (ci infra) que calcula le numero total de sedes in le avion quando le numero de filas es cambiate (ci supra).</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Un avion ha duo sedes in le cabina (pro le pilota e le copilota) e un numero de filas de sedes pro passageros. Cata fila contine quatro sedes.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>filas de prime classe (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>Filas de secunde classe: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>Sedes: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>Calculator de sedias de avion</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>filas (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>Filas de prime classe: %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Un avion ha un numero de filas de sedes pro passageros. Cata fila contine quatro sedes.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>filas de secunde classe (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_is.xlf b/blockly/demos/plane/xlf/translated_msgs_is.xlf
new file mode 100644
index 0000000..3810f4b
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_is.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="is">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>Raðir: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>sæti =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>Flugvél er með tvö sæti í stjórnklefa (fyrir flugmanninn og aðstoðarflugmanninn) og einhvern fjölda sætaraða fyrir farþega á 1. og 2. farrými. Hver sætaröð á 1. farrými hefur fjögur sæti. Hver sætaröð á 2. farrými hefur fimm sæti.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>Búðu til formúlu (hér fyrir neðan) sem reiknar heildarfjölda sæta í flugvélinni eftir því sem röðunum er breytt (hér fyrir ofan).</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Flugvél er með tvö sæti í stjórnklefa (fyrir flugmanninn og aðstoðarflugmanninn) og einhvern fjölda sætaraða fyrir farþega. Hver sætaröð hefur fjögur sæti.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>raðir 1. farrými (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>Raðir 2. farrými: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>Sæti: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>Flugsætareiknir</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>raðir (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>Raðir 1. farrými: %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Flugvél er með einhvern fjölda sætaraða fyrir farþega. Í hverri röð eru fjögur sæti.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>raðir 2. farrými (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_it.xlf b/blockly/demos/plane/xlf/translated_msgs_it.xlf
new file mode 100644
index 0000000..27bad0d
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_it.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="it">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>File: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>sedili =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>Un aereo ha due posti nella cabina di pilotaggio (per il pilota e il co-pilota), e un numero di file in prima e seconda classe, con i posti a sedere dei passeggeri. Ogni fila della prima classe contiene quattro posti. Quelle invece della seconda classe, ne contengono cinque.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>Costruisci una formula (sotto) che calcola il numero totale di posti a sedere su un aeroplano, così come cambiano le file di posti (sopra).</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Un aeroplano ha due posti a sedere nella cabina di pilotaggio (per il pilota e co-pilota), e un numero di file con i posti a sedere dei passeggeri. Ogni fila contiene quattro posti.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>file 1ª classe (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>File 2ª classe: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>Sedili: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>Calcolo posti aereo</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>file (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>File 1ª classe: %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Un aeroplano ha un numero di file contenenti i posti a sedere dei passeggeri. Ogni fila, contiene quattro posti a sedere.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>File 2ª classe (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_ja.xlf b/blockly/demos/plane/xlf/translated_msgs_ja.xlf
new file mode 100644
index 0000000..b04624a
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_ja.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="ja">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>列の数: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>座席の数 =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>飛行機には、操縦室の 2 つの座席 (操縦士と副操縦士) と、ファーストクラスとセカンドクラスの乗客の座席の列があります。それぞれの列に、ファーストクラスでは 4 つの座席、セカンドクラスでは 5 つの座席があります。</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>飛行機の座席の数を計算する式を、上で列の数を変更しても正しくなるように、下に入力してください。</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>飛行機には、操縦室の 2 つの座席 (操縦士と副操縦士) と、乗客の座席の列があります。それぞれの列に 4 つの座席があります。</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>ファーストクラスの列数 (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>セカンドクラスの列数: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>座席の数: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>飛行機座席計算機</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>列の数 (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>ファーストクラスの列数: %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>飛行機に乗客の座席の列があります。それぞれの列に 4 つの座席があります。</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>セカンドクラスの列数 (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_ko.xlf b/blockly/demos/plane/xlf/translated_msgs_ko.xlf
new file mode 100644
index 0000000..07e2328
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_ko.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="ko">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>행 수: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>좌석수 =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>비행기는 비행 갑판(조종사와 부조종사용)에서 좌석 두 개가 있고, 1등석과 2등석 승객 좌석의 행 수가 있습니다. 각 1등석 행에는 시트 네 개가 포함되어 있습니다. 각 2등석 행에는 시트 다섯 개가 포함되어 있습니다.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>행이 바뀐(위) 비행기에 좌석의 총 수를 계산하는 공식(아래)을 구축하세요.</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>비행기는 비행 갑판(조종사와 부조종사용)에서 좌석 두 개가 있고, 승객 좌석의 행 수가 있습니다. 각 행에는 시트 네 개가 포함되어 있습니다.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>1등석 행 수 (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>2등석 행 수: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>좌석 수: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>비행기 좌석 계산기</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>행 수 (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>1등석 행 수: %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>비행기는 승객 좌석의 행 수가 있습니다. 각 행에는 시트 네 개가 포함되어 있습니다.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>2등석 행 수 (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_ms.xlf b/blockly/demos/plane/xlf/translated_msgs_ms.xlf
new file mode 100644
index 0000000..c34f084
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_ms.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="ms">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>Baris: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>tempat duduk =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>Sebuah kapal terbang mempunyai tempat duduk di kokpit (untuk juruterbang dan pembantunya) dan sebilangan baris tempat duduk penumpang kelas pertama dan kelas kedua. Setiap baris kelas pertama mengandungi empat tempat duduk. Setiap baris kelas pertama mengandungi lima tempat duduk.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>Wujudkan formula (di bawah) yang mengira jumlah tempat duduk di dalam kapal terbang sedangkan baris-barisnya diubah (di atas).</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Sebuah kapal terbang mempunyai tempat duduk di kokpit (untuk juruterbang dan pembantunya) dan sebilangan baris tempat duduk penumpang. Setiap baris mengandungi empat tempat duduk.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>baris kelas pertama (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>Baris kelas kedua: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>Tempat duduk: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>Pengira Tempat Duduk Kapal Terbang</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>baris (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>Baris kelas pertama: %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Sebuah kapal terbang mempunyai sebilangan baris tempat duduk penumpang. Setiap baris mengandungi empat tempat duduk.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>baris kelas kedua (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_nb.xlf b/blockly/demos/plane/xlf/translated_msgs_nb.xlf
new file mode 100644
index 0000000..99c9c6a
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_nb.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="nb">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>Rader: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>seter =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>Et fly har to seter i cockpit (for piloten og andrepiloten), og et antall rader med passasjerseter på første og andre klasse. Hver av radene på første klasse har fire seter. Hver av radene på andre klasse har fem seter.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>Bygg en formel (under) som beregner det totale antall seter på flyet etter hvert som radene endres (over).</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Et fly har to seter i cockpit (for piloten og andrepiloten), og et antall rader med passasjerseter. Hver rad inneholder fire seter.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>Rader i første klasse (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>Rader i andre klasse: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>Seter: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>Flysetekalkulator</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>rader (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>Rader i første klasse: %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Et fly har et antall rader med passasjerseter. Hver rad inneholder fire seter.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>Rader i andre klasse (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_nl.xlf b/blockly/demos/plane/xlf/translated_msgs_nl.xlf
new file mode 100644
index 0000000..6f36fa0
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_nl.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="nl">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>Rijen: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>stoelen=</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>Een vliegtuig heeft twee stoelen in de cockpit (voor de piloot en de copiloot) en een aantal rijen voor 1e klasse en 2e klasse passagiers. Iedere rij in de 1e klasse heeft vier stoelen. Iedere rij in de 2e klasse heeft vijf stoelen.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>Maak hieronder een formule die het totale aantal stoelen in het vliegtuig berekent als het aantal rijen hierboven wordt aangepast.</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Een vliegtuig heeft twee stoelen in de cockpit (voor de piloot en de copiloot) en een aantal rijen met stoelen voor passagiers. Iedere rij bevat vier stoelen.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>Rijen 1e klas (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>Rijen 2e klas: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>Zitplaatsen: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>Vliegtuigstoelencalculator</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>rijen (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>Rijen 1e klas: %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Een vliegtuig heeft een aantal rijen met stoelen. Iedere rij heeft vier stoelen.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>Rijen 2e klas (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_pl.xlf b/blockly/demos/plane/xlf/translated_msgs_pl.xlf
new file mode 100644
index 0000000..4c8b044
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_pl.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="pl">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>Rzędów: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>siedzeń =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>Samolot ma dwa miejsca w kabinie pilotów (dla pierwszego i drugiego pilota) oraz rzędy siedzeń dla pasażerów pierwszej i drugiej klasy. Każdy rząd pierwszej klasy składa się z czterech siedzeń. Każdy rząd drugiej klasy składa się z pięciu siedzeń.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>Zbuduj wzór (poniżej), który pozwala obliczyć łączną liczbę siedzeń w samolocie w funkcji zmieniającej się liczby rzędów (powyżej).</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Samolot ma dwa miejsca w kabinie pilotów (dla pierwszego i drugiego pilota) oraz rzędy siedzeń dla pasażerów. Każdy taki rząd składa się z czterech siedzeń.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>Rzędów w pierwszej klasie (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>Rzędów w drugiej klasie: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>Siedzeń: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>Kalkulator miejsc w samolocie.</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>rzędów (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>Rzędów w pierwszej klasie: %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Samolot ma kilka rzędów siedzeń pasażerów. Każdy rząd zawiera cztery miejsca.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>Rzędów w drugiej klasie (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_pms.xlf b/blockly/demos/plane/xlf/translated_msgs_pms.xlf
new file mode 100644
index 0000000..0fef912
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_pms.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="pms">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>Linie: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>sedij =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>N'avion a l'ha doi sedij ant la cabin-a ëd pilotage (për ël pilòta e ël cò-pilòta) e un chèich nùmer ëd file ëd sedij pr'ij passagé ëd prima e sconda classa. Minca fila ëd prima classa a conten quatr sedij. Minca fila ëd seconda classa a conten sinch sedij.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>Fabriché na fórmola (sì-sota) ch'a fa 'l cont dël nùmer total ëd sedij ant l'avion cand che ël nùmer dle file a cangia (sì-dzora).</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>N'avion a l'ha doi sedij ant la cabin-a ëd pilotage (për ël pilòta e ël cò-pilòta), e un chèich nùmer ëd file ëd sedij pr'ij passagé. Minca fila a conten quatr sedij.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>linie ëd prima classa (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>linie ëd seconda classa: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>Sedij: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>Calcolator ëd sedij d'avion</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>linie (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>linie ëd prima classa: %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>N'avion a l'ha un nùmer ëd file ëd sedij da passëgé. Minca fila a l'ha quatr sedij.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>linie ëd seconda classa (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_pt-br.xlf b/blockly/demos/plane/xlf/translated_msgs_pt-br.xlf
new file mode 100644
index 0000000..7bdd9cc
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_pt-br.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="pt-br">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>Filas: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>assentos =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>Um avião tem dois assentos na cabine de comando (para o piloto e o copiloto) e um número de filas de assentos na primeira e na segunda classe. Cada fila da primeira classe contém quatro assentos. Cada fila da segunda classe contém cinco assentos.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>Elabore uma fórmula (abaixo) que calcule o número total de assentos no avião a medida que as filas são alteradas (acima).</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Um avião tem dois assentos na cabine de comando (para o piloto e o copiloto) e um número de filas de assentos para os passageiros. Cada fila contém quatro assentos.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>filas na primeira classe (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>filas na segunda classe: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>Assentos: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>Calculadora de Assentos em Avião</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>filas (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>filas na primeira classe: %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Um avião tem um número de filas de assentos para os passageiros. Cada fila contém quatro assentos.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>filas na segunda classe (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_ro.xlf b/blockly/demos/plane/xlf/translated_msgs_ro.xlf
new file mode 100644
index 0000000..614a3bd
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_ro.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="ro">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>Rânduri: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>scaune =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>Un avion are două scaune în carlingă (pentru pilot și copilot) și un număr de rânduri cu scaune de clasa I și clasa a II-a pentru pasageri. Fiecare rând de clasa I conține patru scaune. Fiecare rând de clasa a II-a conține cinci scaune.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>Construiește o formulă (mai jos) care calculează numărul total de locuri dintr-un avion în timp ce rândurile se schimbă (mai sus).</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Un avion are două scaune în carlingă (pentru pilot și copilot) și un număr de rânduri cu scaune pentru pasageri. Fiecare rând conține patru scaune.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>rânduri de clasa I (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>rânduri de clasa a II-a: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>Scaune: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>Calculator pentru locurile dintr-un avion</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>rânduri (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>rânduri de clasa I: %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Un avion are un număr de rânduri cu scaune pentru pasageri. Fiecare rând conține patru scaune.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>rânduri de clasa a II-a (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_ru.xlf b/blockly/demos/plane/xlf/translated_msgs_ru.xlf
new file mode 100644
index 0000000..d25b254
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_ru.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="ru">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>Рядов: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>места =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>В самолёте 2 места для пилота и его помощника, несколько рядов с пассажирскими местами первого класса, а также несколько рядов с пассажирскими местами второго класса. В каждом ряду первого класса 4 места. В каждом ряду второго класса 5 мест.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>Постройте формулу в области ниже, которая поможет рассчитать общее количество мест в самолёте (как на рисунке выше).</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>В самолёте 2 места для пилота и его помощника, а также несколько рядов с пассажирскими местами. В каждом ряду 4 места.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>ряды 1-го класса (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>Рядов 2-го класса: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>Мест: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>Калькулятор посадочных мест в самолёте</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>ряды (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>Рядов 1-го класса: %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>В самолёте несколько рядов с пассажирскими местами. В каждом ряду 4 места.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>ряды 2-го класса (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_sc.xlf b/blockly/demos/plane/xlf/translated_msgs_sc.xlf
new file mode 100644
index 0000000..6328123
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_sc.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="sc">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>Fileras: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>cadironis =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>Unu aparèchiu tenit duus cadironis in sa cabina de cumandu (po su pilota e su co-pilota), e unas cantu fileras de cadironis po passigeris de prima classi e de segunda classi. Dònnia filera de prima classi tenit cuatru cadironis. Dònnia filera de segunda classi tenit cincu cadironis.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>Cuncorda una formula (innoi asuta) chi cumpudit su numeru totali de postus a setzi in s'aparechiu, a segunda de comenti mudant is fileras de postus (innoi in susu)</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Unu aparèchiu tenit duus cadironis in sa cabina de cumandu (po su pilota e su co-pilota), e unas cantu fileras de cadironis po passigeris. Dònnia filera tenit cuatru cadironis.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>fileras de primu classi (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>fileras de segunda classi: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>Cadironis: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>Fai su contu de is cadironis de unu aparèchiu</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>fileras (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>fileras de primu classi: %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Unu aparèchiu tenit unas cantu fileras de cadironis po passigeris. Dònnia filera tenit cuatru cadironis.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>fileras de segunda classi (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_sv.xlf b/blockly/demos/plane/xlf/translated_msgs_sv.xlf
new file mode 100644
index 0000000..f3d836f
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_sv.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="sv">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>Rader: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>säten =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>Ett flygplan har två säten i cockpiten (ett för piloten och ett för andrepiloten) och ett antal rader med passagerarsäten i första och andra klass. Varje rad i första klass innehåller fyra säten. Varje rad i andra klass innehåller fem säten.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>Bygg en formel (nedan) som beräknar det totala antalet säten på flygplanet när raderna ändras (ovan).</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Ett flygplan har två säten i cockpiten (ett för piloten och ett för andrepiloten) och ett antal rader med passagerarsäten. Varje rad innehåller fyra säten.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>Rader i första klass (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>Rader i andra klass: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>Säten: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>Plansäteskalkylator</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>rader (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>Rader i första klass: %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Ett flygplan har ett antal rader med passagerarsäten. Varje rad innehåller fyra säten.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>Rader i andra klass (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_th.xlf b/blockly/demos/plane/xlf/translated_msgs_th.xlf
new file mode 100644
index 0000000..0967d4d
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_th.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="th">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>%1 แถว</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>จำนวนที่นั่ง =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>ภายในเครื่องบินจะมีที่นั่งนักบินอยู่ 2 ที่ (สำหรับนักบิน และผู้ช่วยนักบิน) และจะมีแถวที่นั่งสำหรับผู้โดยสาร "ชั้นเฟิร์สคลาส" และ "ชั้นธุรกิจ" อยู่จำนวนหนึ่ง โดยในชั้นเฟิร์สคลาสจะมีแถวละ 4 ที่นั่ง ส่วนในชั้นธุรกิจจะมีแถวละ 5 ที่นั่ง</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>สร้างสูตรคำนวณ (ด้านล่าง) เพื่อคำนวณหาจำนวนที่นั่งทั้งหมดบนเครื่องบิน ตามจำนวนแถวที่เปลี่ยนไป (ด้านบน)</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>ภายในเครื่องบินจะมีที่นั่งนักบินอยู่ 2 ที่ (สำหรับนักบิน และผู้ช่วยนักบิน) และมีแถวที่นั่งผู้โดยสารอยู่จำนวนหนึ่ง ในแต่ละแถวจะมี 4 ที่นั่ง</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>จำนวนแถวชั้นเฟิร์สคลาส (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>ชั้นธุรกิจ %1 แถว</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>คำนวณได้ทั้งหมด %1 ที่นั่ง</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>ระบบคำนวณที่นั่งบนเครื่องบิน</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>จำนวนแถว (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>ชั้นเฟิร์สคลาส %1 แถว</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>ภายในเครื่องบินประกอบไปด้วยแถวของที่นั่งผู้โดยสาร ในแต่ละแถวจะมี 4 ที่นั่ง</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>จำนวนแถวชั้นธุรกิจ (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_tr.xlf b/blockly/demos/plane/xlf/translated_msgs_tr.xlf
new file mode 100644
index 0000000..678541a
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_tr.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="tr">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>Sıralar: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>koltuklar =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>Bir uçağın uçuş güvertesinde iki koltuğu (pilot ve yardımcı pilot için), ve belirli sayıda birinci sınıf ve ikinci sınıf yolcu koltuğu sırası vardır. Her birinci sınıf sıra dört koltuk içerir. Her ikinci sınıf sıra beş koltuk içerir.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>Sıralar(üstte) değiştikçe uçaktaki toplam koltuk sayısını hesaplayan bir formül(altta) oluşturun.</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Bir uçağın uçuş güvertesinde iki koltuğu (pilot ve yardımcı pilot için), ve belirli sayıda koltuk sırası vardır. Her sıra dört koltuk içerir.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>Birinci sınıf sıralar (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>İkinci sınıf sıralar: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>Koltuklar: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>Uçak Koltuğu Hesaplayıcı</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>sıralar (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>Birinci sınıf sıralar: (%1)</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Bir uçağın belirli sayıda koltuk sırası vardır. Her sıra dört koltuk içerir.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>İkinci sınıf sıralar (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_uk.xlf b/blockly/demos/plane/xlf/translated_msgs_uk.xlf
new file mode 100644
index 0000000..d5e7682
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_uk.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="uk">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>Рядки: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>місць=</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>Літак має два місця в кабіні екіпажу (пілот і другий пілот), і кілька рядів 1-го класу 2-го класу пасажирських місць. Кожний ряд 1-го класу містить чотири місця. Кожен ряд 2-го класу містить п'ять місць.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>Побудувати формулу (нижче), яка обчислює кількість місць на літаку при зміні рядків (див. вище).</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Літак має два місця в кабіні екіпажу (пілот і другий пілот), і кілька рядів пасажирських сидінь. Кожен рядок містить чотири місця.</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>рядів 1-го класу (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>рядів 2-го класу: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>Місць: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>Калькулятор місць у літаку</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>рядки (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>рядів 1-го класу: %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Літак має кілька рядів пасажирських сидінь. Кожен ряд містить чотири місця.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>рядів 2-го класу (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_vi.xlf b/blockly/demos/plane/xlf/translated_msgs_vi.xlf
new file mode 100644
index 0000000..1f4ef6f
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_vi.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="vi">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>Số hàng ghế: %1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>Tính số chỗ ngồi =</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>Một chiếc máy bay này có hai chỗ ngồi ở sàn (cho phi công trưởng và phi công phó), và một số hàng ghế hạng 1 và hạng 2. Mỗi hàng hạng 1 có bốn chỗ ngồi. Mỗi hàng hạng 2 có năm chỗ ngồi.</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>Dưới đây hãy tạo công thức tính số chỗ ngồi trên máy bay để nó thay đổi tùy theo số lượng hàng ghế (hình trên).</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Một máy bay có hai ghế trong buồng lái (dành cho phi công trưởng và phi công phụ), và một loạt hàng ghế cho hành khách. Mỗi hàng có bốn ghế (bốn chỗ ngồi).</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>số hàng hạng nhất (%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>Hàng hạng hai: %1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>Số chỗ ngồi: %1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>Máy bay ghế máy tính</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>đếm số hàng ghế (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>Hàng hạng nhất: %1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>Máy bay có một số hàng ghế hành khách. Mỗi hàng có bốn chỗ ngồi.</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>số hàng hạng hai (%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_zh-hans.xlf b/blockly/demos/plane/xlf/translated_msgs_zh-hans.xlf
new file mode 100644
index 0000000..2cbb7e8
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_zh-hans.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="zh-hans">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>行:%1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>座位=</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>一架飞机除了有两个座位供正副驾驶员,还有一定量行数的头等及经济乘客座位。头等每行共四座,经济每行共五座。</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>于下方写出一条公式以计算飞机上的座位总数。</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>一架飞机除了有两个座位供正副驾驶员,还有一定量行数的乘客座位。每行共四座。</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>头等行(%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>经济等行:%1</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>座位:%1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>飞机座位计算器</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>行 (%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>头等行:%1</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>一架飞机有一定量行数的乘客座位,每行共四座。</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>经济等行(%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/plane/xlf/translated_msgs_zh-hant.xlf b/blockly/demos/plane/xlf/translated_msgs_zh-hant.xlf
new file mode 100644
index 0000000..2dadf6d
--- /dev/null
+++ b/blockly/demos/plane/xlf/translated_msgs_zh-hant.xlf
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" source-language="en" target-language="zh-hant">
+ <body>
+ <trans-unit id="286555642257111053" datatype="html">
+ <source>Rows: %1</source>
+ <target>排:%1</target>
+ </trans-unit>
+ <trans-unit id="990695256953568910" datatype="html">
+ <source>seats =</source>
+ <target>座位=</target>
+ </trans-unit>
+ <trans-unit id="1327005465775917626" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of 1st class and 2nd class passenger seats. Each 1st class row contains four seats. Each 2nd class row contains five seats.</source>
+ <target>一架飛機除了有兩個座位供正副機師,還有一定量行數的頭等及經濟乘客座位。頭等艙每排都包含四個席位,經濟艙每排都包含五個席位。。</target>
+ </trans-unit>
+ <trans-unit id="1649099567159388799" datatype="html">
+ <source>?</source>
+ <target>?</target>
+ </trans-unit>
+ <trans-unit id="3872872459414039837" datatype="html">
+ <source>Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).</source>
+ <target>於下方寫出一條公式以計算飛機上的座位總數。</target>
+ </trans-unit>
+ <trans-unit id="4755413400587385256" datatype="html">
+ <source>An airplane has two seats in the flight deck (for the pilot and co-pilot), and a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>一架飛機除了有兩個座位供正副機師,還有一定量行數的乘客座位。每排都包含四個席位。</target>
+ </trans-unit>
+ <trans-unit id="5622822520334788359" datatype="html">
+ <source>1st class rows (%1)</source>
+ <target>頭等艙(%1)</target>
+ </trans-unit>
+ <trans-unit id="6523489254328705062" datatype="html">
+ <source>2nd class rows: %1</source>
+ <target>經濟艙:%1 排</target>
+ </trans-unit>
+ <trans-unit id="6636919311618748816" datatype="html">
+ <source>Seats: %1</source>
+ <target>座位:%1</target>
+ </trans-unit>
+ <trans-unit id="6646116297668869388" datatype="html">
+ <source>Plane Seat Calculator</source>
+ <target>飛機座位計算器</target>
+ </trans-unit>
+ <trans-unit id="7030918043298347994" datatype="html">
+ <source>rows (%1)</source>
+ <target>排(%1)</target>
+ </trans-unit>
+ <trans-unit id="7091637686507441682" datatype="html">
+ <source>1st class rows: %1</source>
+ <target>頭等艙:%1 排</target>
+ </trans-unit>
+ <trans-unit id="7784699858027886282" datatype="html">
+ <source>An airplane has a number of rows of passenger seats. Each row contains four seats.</source>
+ <target>一架飛機有一定量行數的乘客座位,每排都包含四個席位。</target>
+ </trans-unit>
+ <trans-unit id="8347578891541780742" datatype="html">
+ <source>2nd class rows (%1)</source>
+ <target>經濟艙(%1)</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
diff --git a/blockly/demos/prettify.css b/blockly/demos/prettify.css
new file mode 100644
index 0000000..d44b3a2
--- /dev/null
+++ b/blockly/demos/prettify.css
@@ -0,0 +1 @@
+.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} \ No newline at end of file
diff --git a/blockly/demos/prettify.js b/blockly/demos/prettify.js
new file mode 100644
index 0000000..7b99049
--- /dev/null
+++ b/blockly/demos/prettify.js
@@ -0,0 +1,30 @@
+!function(){var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;
+(function(){function S(a){function d(e){var b=e.charCodeAt(0);if(b!==92)return b;var a=e.charAt(1);return(b=r[a])?b:"0"<=a&&a<="7"?parseInt(e.substring(1),8):a==="u"||a==="x"?parseInt(e.substring(2),16):e.charCodeAt(1)}function g(e){if(e<32)return(e<16?"\\x0":"\\x")+e.toString(16);e=String.fromCharCode(e);return e==="\\"||e==="-"||e==="]"||e==="^"?"\\"+e:e}function b(e){var b=e.substring(1,e.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),e=[],a=
+b[0]==="^",c=["["];a&&c.push("^");for(var a=a?1:0,f=b.length;a<f;++a){var h=b[a];if(/\\[bdsw]/i.test(h))c.push(h);else{var h=d(h),l;a+2<f&&"-"===b[a+1]?(l=d(b[a+2]),a+=2):l=h;e.push([h,l]);l<65||h>122||(l<65||h>90||e.push([Math.max(65,h)|32,Math.min(l,90)|32]),l<97||h>122||e.push([Math.max(97,h)&-33,Math.min(l,122)&-33]))}}e.sort(function(e,a){return e[0]-a[0]||a[1]-e[1]});b=[];f=[];for(a=0;a<e.length;++a)h=e[a],h[0]<=f[1]+1?f[1]=Math.max(f[1],h[1]):b.push(f=h);for(a=0;a<b.length;++a)h=b[a],c.push(g(h[0])),
+h[1]>h[0]&&(h[1]+1>h[0]&&c.push("-"),c.push(g(h[1])));c.push("]");return c.join("")}function s(e){for(var a=e.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),c=a.length,d=[],f=0,h=0;f<c;++f){var l=a[f];l==="("?++h:"\\"===l.charAt(0)&&(l=+l.substring(1))&&(l<=h?d[l]=-1:a[f]=g(l))}for(f=1;f<d.length;++f)-1===d[f]&&(d[f]=++x);for(h=f=0;f<c;++f)l=a[f],l==="("?(++h,d[h]||(a[f]="(?:")):"\\"===l.charAt(0)&&(l=+l.substring(1))&&l<=h&&
+(a[f]="\\"+d[l]);for(f=0;f<c;++f)"^"===a[f]&&"^"!==a[f+1]&&(a[f]="");if(e.ignoreCase&&m)for(f=0;f<c;++f)l=a[f],e=l.charAt(0),l.length>=2&&e==="["?a[f]=b(l):e!=="\\"&&(a[f]=l.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return a.join("")}for(var x=0,m=!1,j=!1,k=0,c=a.length;k<c;++k){var i=a[k];if(i.ignoreCase)j=!0;else if(/[a-z]/i.test(i.source.replace(/\\u[\da-f]{4}|\\x[\da-f]{2}|\\[^UXux]/gi,""))){m=!0;j=!1;break}}for(var r={b:8,t:9,n:10,v:11,
+f:12,r:13},n=[],k=0,c=a.length;k<c;++k){i=a[k];if(i.global||i.multiline)throw Error(""+i);n.push("(?:"+s(i)+")")}return RegExp(n.join("|"),j?"gi":"g")}function T(a,d){function g(a){var c=a.nodeType;if(c==1){if(!b.test(a.className)){for(c=a.firstChild;c;c=c.nextSibling)g(c);c=a.nodeName.toLowerCase();if("br"===c||"li"===c)s[j]="\n",m[j<<1]=x++,m[j++<<1|1]=a}}else if(c==3||c==4)c=a.nodeValue,c.length&&(c=d?c.replace(/\r\n?/g,"\n"):c.replace(/[\t\n\r ]+/g," "),s[j]=c,m[j<<1]=x,x+=c.length,m[j++<<1|1]=
+a)}var b=/(?:^|\s)nocode(?:\s|$)/,s=[],x=0,m=[],j=0;g(a);return{a:s.join("").replace(/\n$/,""),d:m}}function H(a,d,g,b){d&&(a={a:d,e:a},g(a),b.push.apply(b,a.g))}function U(a){for(var d=void 0,g=a.firstChild;g;g=g.nextSibling)var b=g.nodeType,d=b===1?d?a:g:b===3?V.test(g.nodeValue)?a:d:d;return d===a?void 0:d}function C(a,d){function g(a){for(var j=a.e,k=[j,"pln"],c=0,i=a.a.match(s)||[],r={},n=0,e=i.length;n<e;++n){var z=i[n],w=r[z],t=void 0,f;if(typeof w==="string")f=!1;else{var h=b[z.charAt(0)];
+if(h)t=z.match(h[1]),w=h[0];else{for(f=0;f<x;++f)if(h=d[f],t=z.match(h[1])){w=h[0];break}t||(w="pln")}if((f=w.length>=5&&"lang-"===w.substring(0,5))&&!(t&&typeof t[1]==="string"))f=!1,w="src";f||(r[z]=w)}h=c;c+=z.length;if(f){f=t[1];var l=z.indexOf(f),B=l+f.length;t[2]&&(B=z.length-t[2].length,l=B-f.length);w=w.substring(5);H(j+h,z.substring(0,l),g,k);H(j+h+l,f,I(w,f),k);H(j+h+B,z.substring(B),g,k)}else k.push(j+h,w)}a.g=k}var b={},s;(function(){for(var g=a.concat(d),j=[],k={},c=0,i=g.length;c<i;++c){var r=
+g[c],n=r[3];if(n)for(var e=n.length;--e>=0;)b[n.charAt(e)]=r;r=r[1];n=""+r;k.hasOwnProperty(n)||(j.push(r),k[n]=q)}j.push(/[\S\s]/);s=S(j)})();var x=d.length;return g}function v(a){var d=[],g=[];a.tripleQuotedStrings?d.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?d.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,
+q,"'\"`"]):d.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&g.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var b=a.hashComments;b&&(a.cStyleComments?(b>1?d.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):d.push(["com",/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),g.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,q])):d.push(["com",
+/^#[^\n\r]*/,q,"#"]));a.cStyleComments&&(g.push(["com",/^\/\/[^\n\r]*/,q]),g.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));if(b=a.regexLiterals){var s=(b=b>1?"":"\n\r")?".":"[\\S\\s]";g.push(["lang-regex",RegExp("^(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*("+("/(?=[^/*"+b+"])(?:[^/\\x5B\\x5C"+b+"]|\\x5C"+s+"|\\x5B(?:[^\\x5C\\x5D"+b+"]|\\x5C"+
+s+")*(?:\\x5D|$))+/")+")")])}(b=a.types)&&g.push(["typ",b]);b=(""+a.keywords).replace(/^ | $/g,"");b.length&&g.push(["kwd",RegExp("^(?:"+b.replace(/[\s,]+/g,"|")+")\\b"),q]);d.push(["pln",/^\s+/,q," \r\n\t\u00a0"]);b="^.[^\\s\\w.$@'\"`/\\\\]*";a.regexLiterals&&(b+="(?!s*/)");g.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,
+q],["pun",RegExp(b),q]);return C(d,g)}function J(a,d,g){function b(a){var c=a.nodeType;if(c==1&&!x.test(a.className))if("br"===a.nodeName)s(a),a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)b(a);else if((c==3||c==4)&&g){var d=a.nodeValue,i=d.match(m);if(i)c=d.substring(0,i.index),a.nodeValue=c,(d=d.substring(i.index+i[0].length))&&a.parentNode.insertBefore(j.createTextNode(d),a.nextSibling),s(a),c||a.parentNode.removeChild(a)}}function s(a){function b(a,c){var d=
+c?a.cloneNode(!1):a,e=a.parentNode;if(e){var e=b(e,1),g=a.nextSibling;e.appendChild(d);for(var i=g;i;i=g)g=i.nextSibling,e.appendChild(i)}return d}for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),d;(d=a.parentNode)&&d.nodeType===1;)a=d;c.push(a)}for(var x=/(?:^|\s)nocode(?:\s|$)/,m=/\r\n?|\n/,j=a.ownerDocument,k=j.createElement("li");a.firstChild;)k.appendChild(a.firstChild);for(var c=[k],i=0;i<c.length;++i)b(c[i]);d===(d|0)&&c[0].setAttribute("value",d);var r=j.createElement("ol");
+r.className="linenums";for(var d=Math.max(0,d-1|0)||0,i=0,n=c.length;i<n;++i)k=c[i],k.className="L"+(i+d)%10,k.firstChild||k.appendChild(j.createTextNode("\u00a0")),r.appendChild(k);a.appendChild(r)}function p(a,d){for(var g=d.length;--g>=0;){var b=d[g];F.hasOwnProperty(b)?D.console&&console.warn("cannot override language handler %s",b):F[b]=a}}function I(a,d){if(!a||!F.hasOwnProperty(a))a=/^\s*</.test(d)?"default-markup":"default-code";return F[a]}function K(a){var d=a.h;try{var g=T(a.c,a.i),b=g.a;
+a.a=b;a.d=g.d;a.e=0;I(d,b)(a);var s=/\bMSIE\s(\d+)/.exec(navigator.userAgent),s=s&&+s[1]<=8,d=/\n/g,x=a.a,m=x.length,g=0,j=a.d,k=j.length,b=0,c=a.g,i=c.length,r=0;c[i]=m;var n,e;for(e=n=0;e<i;)c[e]!==c[e+2]?(c[n++]=c[e++],c[n++]=c[e++]):e+=2;i=n;for(e=n=0;e<i;){for(var p=c[e],w=c[e+1],t=e+2;t+2<=i&&c[t+1]===w;)t+=2;c[n++]=p;c[n++]=w;e=t}c.length=n;var f=a.c,h;if(f)h=f.style.display,f.style.display="none";try{for(;b<k;){var l=j[b+2]||m,B=c[r+2]||m,t=Math.min(l,B),A=j[b+1],G;if(A.nodeType!==1&&(G=x.substring(g,
+t))){s&&(G=G.replace(d,"\r"));A.nodeValue=G;var L=A.ownerDocument,o=L.createElement("span");o.className=c[r+1];var v=A.parentNode;v.replaceChild(o,A);o.appendChild(A);g<l&&(j[b+1]=A=L.createTextNode(x.substring(t,l)),v.insertBefore(A,o.nextSibling))}g=t;g>=l&&(b+=2);g>=B&&(r+=2)}}finally{if(f)f.style.display=h}}catch(u){D.console&&console.log(u&&u.stack||u)}}var D=window,y=["break,continue,do,else,for,if,return,while"],E=[[y,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],
+"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],M=[E,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],N=[E,"abstract,assert,boolean,byte,extends,final,finally,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],
+O=[N,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,internal,into,is,let,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var,virtual,where"],E=[E,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],P=[y,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],
+Q=[y,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],W=[y,"as,assert,const,copy,drop,enum,extern,fail,false,fn,impl,let,log,loop,match,mod,move,mut,priv,pub,pure,ref,self,static,struct,true,trait,type,unsafe,use"],y=[y,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],R=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,
+V=/\S/,X=v({keywords:[M,O,E,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",P,Q,y],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),F={};p(X,["default-code"]);p(C([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",
+/^<xmp\b[^>]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);p(C([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],
+["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);p(C([],[["atv",/^[\S\s]+/]]),["uq.val"]);p(v({keywords:M,hashComments:!0,cStyleComments:!0,types:R}),["c","cc","cpp","cxx","cyc","m"]);p(v({keywords:"null,true,false"}),["json"]);p(v({keywords:O,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:R}),
+["cs"]);p(v({keywords:N,cStyleComments:!0}),["java"]);p(v({keywords:y,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]);p(v({keywords:P,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]);p(v({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]);p(v({keywords:Q,
+hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]);p(v({keywords:E,cStyleComments:!0,regexLiterals:!0}),["javascript","js"]);p(v({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes",hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);p(v({keywords:W,cStyleComments:!0,multilineStrings:!0}),["rc","rs","rust"]);
+p(C([],[["str",/^[\S\s]+/]]),["regex"]);var Y=D.PR={createSimpleLexer:C,registerLangHandler:p,sourceDecorator:v,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ",prettyPrintOne:D.prettyPrintOne=function(a,d,g){var b=document.createElement("div");b.innerHTML="<pre>"+a+"</pre>";b=b.firstChild;g&&J(b,g,!0);K({h:d,j:g,c:b,i:1});
+return b.innerHTML},prettyPrint:D.prettyPrint=function(a,d){function g(){for(var b=D.PR_SHOULD_USE_CONTINUATION?c.now()+250:Infinity;i<p.length&&c.now()<b;i++){for(var d=p[i],j=h,k=d;k=k.previousSibling;){var m=k.nodeType,o=(m===7||m===8)&&k.nodeValue;if(o?!/^\??prettify\b/.test(o):m!==3||/\S/.test(k.nodeValue))break;if(o){j={};o.replace(/\b(\w+)=([\w%+\-.:]+)/g,function(a,b,c){j[b]=c});break}}k=d.className;if((j!==h||e.test(k))&&!v.test(k)){m=!1;for(o=d.parentNode;o;o=o.parentNode)if(f.test(o.tagName)&&
+o.className&&e.test(o.className)){m=!0;break}if(!m){d.className+=" prettyprinted";m=j.lang;if(!m){var m=k.match(n),y;if(!m&&(y=U(d))&&t.test(y.tagName))m=y.className.match(n);m&&(m=m[1])}if(w.test(d.tagName))o=1;else var o=d.currentStyle,u=s.defaultView,o=(o=o?o.whiteSpace:u&&u.getComputedStyle?u.getComputedStyle(d,q).getPropertyValue("white-space"):0)&&"pre"===o.substring(0,3);u=j.linenums;if(!(u=u==="true"||+u))u=(u=k.match(/\blinenums\b(?::(\d+))?/))?u[1]&&u[1].length?+u[1]:!0:!1;u&&J(d,u,o);r=
+{h:m,c:d,j:u,i:o};K(r)}}}i<p.length?setTimeout(g,250):"function"===typeof a&&a()}for(var b=d||document.body,s=b.ownerDocument||document,b=[b.getElementsByTagName("pre"),b.getElementsByTagName("code"),b.getElementsByTagName("xmp")],p=[],m=0;m<b.length;++m)for(var j=0,k=b[m].length;j<k;++j)p.push(b[m][j]);var b=q,c=Date;c.now||(c={now:function(){return+new Date}});var i=0,r,n=/\blang(?:uage)?-([\w.]+)(?!\S)/,e=/\bprettyprint\b/,v=/\bprettyprinted\b/,w=/pre|xmp/i,t=/^code$/i,f=/^(?:pre|code|xmp)$/i,
+h={};g()}};typeof define==="function"&&define.amd&&define("google-code-prettify",[],function(){return Y})})();}()
diff --git a/blockly/demos/resizable/icon.png b/blockly/demos/resizable/icon.png
new file mode 100644
index 0000000..4355275
--- /dev/null
+++ b/blockly/demos/resizable/icon.png
Binary files differ
diff --git a/blockly/demos/resizable/index.html b/blockly/demos/resizable/index.html
new file mode 100644
index 0000000..e2ee1e0
--- /dev/null
+++ b/blockly/demos/resizable/index.html
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Blockly Demo: Resizable Blockly (Part 1)</title>
+ <style>
+ html, body {
+ height: 100%;
+ margin: 0;
+ }
+ body {
+ background-color: #fff;
+ font-family: sans-serif;
+ overflow: hidden;
+ }
+ h1 {
+ font-weight: normal;
+ font-size: 140%;
+ }
+ table {
+ height: 100%;
+ width: 100%;
+ }
+ #blocklyArea {
+ height: 99%;
+ background: #fc9;
+ text-align: center;
+ }
+ </style>
+</head>
+<body>
+ <table>
+ <tr>
+ <td>
+ <h1><a href="https://developers.google.com/blockly/">Blockly</a> &gt;
+ <a href="../index.html">Demos</a> &gt; Resizable Blockly (Part 1)</h1>
+
+ <p>The first step in creating a resizable Blockly workspace is to use
+ CSS or tables to create an area for it.
+ Next, <a href="overlay.html">inject Blockly</a> over that area.</p>
+
+ <p>&rarr; More info on <a href="https://developers.google.com/blockly/guides/configure/web/resizable">injecting resizable Blockly</a>&hellip;</p>
+ </td>
+ </tr>
+ <tr>
+ <td id="blocklyArea">
+ Blockly will be positioned here.
+ </td>
+ </tr>
+ </table>
+</body>
+</html>
diff --git a/blockly/demos/resizable/overlay.html b/blockly/demos/resizable/overlay.html
new file mode 100644
index 0000000..2d9f41f
--- /dev/null
+++ b/blockly/demos/resizable/overlay.html
@@ -0,0 +1,93 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Blockly Demo: Resizable Blockly (Part 2)</title>
+ <script src="../../blockly_compressed.js"></script>
+ <script src="../../blocks_compressed.js"></script>
+ <script src="../../msg/js/en.js"></script>
+ <style>
+ html, body {
+ height: 100%;
+ margin: 0;
+ }
+ body {
+ background-color: #fff;
+ font-family: sans-serif;
+ overflow: hidden;
+ }
+ h1 {
+ font-weight: normal;
+ font-size: 140%;
+ }
+ table {
+ height: 100%;
+ width: 100%;
+ }
+ #blocklyArea {
+ height: 99%;
+ }
+ </style>
+</head>
+<body>
+ <table>
+ <tr>
+ <td>
+ <h1><a href="https://developers.google.com/blockly/">Blockly</a> &gt;
+ <a href="../index.html">Demos</a> &gt; Resizable Blockly (Part 2)</h1>
+
+ <p>
+ Once an <a href="index.html">area is defined</a>, Blockly can be
+ injected and positioned over the area.
+ A resize handler keeps it in position as the page changes.
+ </p>
+
+ <p>&rarr; More info on <a href="https://developers.google.com/blockly/guides/configure/web/resizable">injecting resizable Blockly</a>&hellip;</p>
+ </td>
+ </tr>
+ <tr>
+ <td id="blocklyArea">
+ </td>
+ </tr>
+ </table>
+
+ <div id="blocklyDiv" style="position: absolute"></div>
+
+ <xml id="toolbox" style="display: none">
+ <block type="controls_if"></block>
+ <block type="logic_compare"></block>
+ <block type="controls_repeat_ext"></block>
+ <block type="math_number"></block>
+ <block type="math_arithmetic"></block>
+ <block type="text"></block>
+ <block type="text_print"></block>
+ </xml>
+
+ <script>
+ var blocklyArea = document.getElementById('blocklyArea');
+ var blocklyDiv = document.getElementById('blocklyDiv');
+ var workspace = Blockly.inject(blocklyDiv,
+ {media: '../../media/',
+ toolbox: document.getElementById('toolbox')});
+ var onresize = function(e) {
+ // Compute the absolute coordinates and dimensions of blocklyArea.
+ var element = blocklyArea;
+ var x = 0;
+ var y = 0;
+ do {
+ x += element.offsetLeft;
+ y += element.offsetTop;
+ element = element.offsetParent;
+ } while (element);
+ // Position blocklyDiv over blocklyArea.
+ blocklyDiv.style.left = x + 'px';
+ blocklyDiv.style.top = y + 'px';
+ blocklyDiv.style.width = blocklyArea.offsetWidth + 'px';
+ blocklyDiv.style.height = blocklyArea.offsetHeight + 'px';
+ };
+ window.addEventListener('resize', onresize, false);
+ onresize();
+ Blockly.svgResize(workspace);
+ </script>
+</body>
+</html>
diff --git a/blockly/demos/rtl/icon.png b/blockly/demos/rtl/icon.png
new file mode 100644
index 0000000..e177e32
--- /dev/null
+++ b/blockly/demos/rtl/icon.png
Binary files differ
diff --git a/blockly/demos/rtl/index.html b/blockly/demos/rtl/index.html
new file mode 100644
index 0000000..fd84feb
--- /dev/null
+++ b/blockly/demos/rtl/index.html
@@ -0,0 +1,204 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="google" value="notranslate">
+ <title>Blockly Demo: RTL</title>
+ <script src="../../blockly_compressed.js"></script>
+ <script src="../../blocks_compressed.js"></script>
+ <script src="../../msg/js/ar.js"></script>
+ <style>
+ body {
+ background-color: #fff;
+ font-family: sans-serif;
+ }
+ h1 {
+ font-weight: normal;
+ font-size: 140%;
+ }
+ #blocklyDiv {
+ height: 600px;
+ width: 800px;
+ }
+ </style>
+ <script>
+ function init() {
+ var workspace = Blockly.inject('blocklyDiv',
+ {media: '../../media/',
+ rtl: true,
+ toolbox: document.getElementById('toolbox')});
+ Blockly.Xml.domToWorkspace(document.getElementById('startBlocks'),
+ workspace);
+ //window.onbeforeunload = function() {
+ // return 'Leaving this page will result in the loss of your work.';
+ //};
+ }
+ </script>
+</head>
+<body onload="init()">
+ <h1><a href="https://developers.google.com/blockly/">Blockly</a> &gt;
+ <a href="../index.html">Demos</a> &gt; Right-to-Left</h1>
+
+ <div id="blocklyDiv"></div>
+
+ <xml id="toolbox" style="display: none">
+ <category name="منطق">
+ <block type="controls_if"></block>
+ <block type="logic_compare"></block>
+ <block type="logic_operation"></block>
+ <block type="logic_negate"></block>
+ <block type="logic_boolean"></block>
+ <block type="logic_null"></block>
+ <block type="logic_ternary"></block>
+ </category>
+ <category name="الحلقات">
+ <block type="controls_repeat_ext">
+ <value name="TIMES">
+ <block type="math_number">
+ <field name="NUM">10</field>
+ </block>
+ </value>
+ </block>
+ <block type="controls_whileUntil"></block>
+ <block type="controls_for">
+ <value name="FROM">
+ <block type="math_number">
+ <field name="NUM">1</field>
+ </block>
+ </value>
+ <value name="TO">
+ <block type="math_number">
+ <field name="NUM">10</field>
+ </block>
+ </value>
+ <value name="BY">
+ <block type="math_number">
+ <field name="NUM">1</field>
+ </block>
+ </value>
+ </block>
+ <block type="controls_forEach"></block>
+ <block type="controls_flow_statements"></block>
+ </category>
+ <category name="رياضيات">
+ <block type="math_number"></block>
+ <block type="math_arithmetic"></block>
+ <block type="math_single"></block>
+ <block type="math_trig"></block>
+ <block type="math_constant"></block>
+ <block type="math_number_property"></block>
+ <block type="math_round"></block>
+ <block type="math_on_list"></block>
+ <block type="math_modulo"></block>
+ <block type="math_constrain">
+ <value name="LOW">
+ <block type="math_number">
+ <field name="NUM">1</field>
+ </block>
+ </value>
+ <value name="HIGH">
+ <block type="math_number">
+ <field name="NUM">100</field>
+ </block>
+ </value>
+ </block>
+ <block type="math_random_int">
+ <value name="FROM">
+ <block type="math_number">
+ <field name="NUM">1</field>
+ </block>
+ </value>
+ <value name="TO">
+ <block type="math_number">
+ <field name="NUM">100</field>
+ </block>
+ </value>
+ </block>
+ <block type="math_random_float"></block>
+ </category>
+ <category name="نص">
+ <block type="text"></block>
+ <block type="text_join"></block>
+ <block type="text_append">
+ <value name="TEXT">
+ <block type="text"></block>
+ </value>
+ </block>
+ <block type="text_length"></block>
+ <block type="text_isEmpty"></block>
+ <block type="text_indexOf"></block>
+ <block type="text_charAt"></block>
+ <block type="text_changeCase"></block>
+ <block type="text_trim"></block>
+ <block type="text_print"></block>
+ <block type="text_prompt_ext">
+ <value name="TEXT">
+ <block type="text"></block>
+ </value>
+ </block>
+ </category>
+ <category name="قوائم">
+ <block type="lists_create_empty"></block>
+ <block type="lists_create_with"></block>
+ <block type="lists_repeat">
+ <value name="NUM">
+ <block type="math_number">
+ <field name="NUM">5</field>
+ </block>
+ </value>
+ </block>
+ <block type="lists_length"></block>
+ <block type="lists_isEmpty"></block>
+ <block type="lists_indexOf"></block>
+ <block type="lists_getIndex"></block>
+ <block type="lists_setIndex"></block>
+ </category>
+ <category name="لون">
+ <block type="colour_picker"></block>
+ <block type="colour_rgb"></block>
+ <block type="colour_blend"></block>
+ </category>
+ <category name="متغيرات" custom="VARIABLE"></category>
+ <category name="إجراءات" custom="PROCEDURE"></category>
+ </xml>
+
+ <xml id="startBlocks" style="display: none">
+ <block type="controls_if" inline="false" x="-100" y="50">
+ <value name="IF0">
+ <block type="logic_compare" inline="true">
+ <field name="OP">LT</field>
+ <value name="A">
+ <block type="variables_get">
+ <field name="VAR">x</field>
+ </block>
+ </value>
+ <value name="B">
+ <block type="math_number">
+ <field name="NUM">256</field>
+ </block>
+ </value>
+ </block>
+ </value>
+ <statement name="DO0">
+ <block type="variables_set" inline="false">
+ <field name="VAR">x</field>
+ <value name="VALUE">
+ <block type="math_number">
+ <field name="NUM">0</field>
+ </block>
+ </value>
+ <next>
+ <block type="text_print" inline="false">
+ <value name="TEXT">
+ <block type="text">
+ <field name="TEXT">أكثر من لعبة</field>
+ </block>
+ </value>
+ </block>
+ </next>
+ </block>
+ </statement>
+ </block>
+ </xml>
+</body>
+</html>
diff --git a/blockly/demos/storage/icon.png b/blockly/demos/storage/icon.png
new file mode 100644
index 0000000..b8c50b2
--- /dev/null
+++ b/blockly/demos/storage/icon.png
Binary files differ
diff --git a/blockly/demos/storage/index.html b/blockly/demos/storage/index.html
new file mode 100644
index 0000000..57cad33
--- /dev/null
+++ b/blockly/demos/storage/index.html
@@ -0,0 +1,94 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Blockly Demo: Cloud Storage</title>
+ <script src="/storage.js"></script>
+ <script src="../../blockly_compressed.js"></script>
+ <script src="../../blocks_compressed.js"></script>
+ <script src="../../msg/js/en.js"></script>
+ <style>
+ body {
+ background-color: #fff;
+ font-family: sans-serif;
+ }
+ h1 {
+ font-weight: normal;
+ font-size: 140%;
+ }
+ #sorry {
+ padding: 1ex;
+ background-color: #f9edbe;
+ border: solid 1px #f0c36d;
+ }
+ </style>
+</head>
+<body>
+ <h1><a href="https://developers.google.com/blockly/">Blockly</a> &gt;
+ <a href="../index.html">Demos</a> &gt; Cloud Storage</h1>
+
+ <p>This is a simple demo of cloud storage using App Engine.</p>
+
+ <script>
+ if ('BlocklyStorage' in window) {
+ BlocklyStorage.HTTPREQUEST_ERROR = 'There was a problem with the request.\n';
+ BlocklyStorage.LINK_ALERT = 'Share your blocks with this link:\n\n%1';
+ BlocklyStorage.HASH_ERROR = 'Sorry, "%1" doesn\'t correspond with any saved Blockly file.';
+ BlocklyStorage.XML_ERROR = 'Could not load your saved file.\n'+
+ 'Perhaps it was created with a different version of Blockly?';
+ } else {
+ document.write('<p id="sorry">Sorry, cloud storage is not available. This demo must be hosted on App Engine.</p>');
+ }
+ </script>
+
+ <p>&rarr; More info on <a href="https://developers.google.com/blockly/guides/configure-blockly/web/cloud-storage">Cloud Storage</a>&hellip;</p>
+
+ <p>
+ <button onclick="BlocklyStorage.link()">Save Blocks</button>
+ </p>
+
+ <div id="blocklyDiv" style="height: 480px; width: 600px;"></div>
+
+ <xml id="toolbox" style="display: none">
+ <category name="Logic">
+ <block type="controls_if"></block>
+ <block type="logic_compare"></block>
+ <block type="logic_operation"></block>
+ <block type="logic_negate"></block>
+ <block type="logic_boolean"></block>
+ </category>
+ <category name="Loops">
+ <block type="controls_repeat_ext">
+ <value name="TIMES">
+ <block type="math_number">
+ <field name="NUM">10</field>
+ </block>
+ </value>
+ </block>
+ <block type="controls_whileUntil"></block>
+ </category>
+ <category name="Math">
+ <block type="math_number"></block>
+ <block type="math_arithmetic"></block>
+ <block type="math_single"></block>
+ </category>
+ <category name="Text">
+ <block type="text"></block>
+ <block type="text_length"></block>
+ <block type="text_print"></block>
+ </category>
+ </xml>
+
+ <script>
+ var workspace = Blockly.inject('blocklyDiv',
+ {media: '../../media/',
+ toolbox: document.getElementById('toolbox')});
+
+ // An href with #key trigers an AJAX call to retrieve saved blocks.
+ if ('BlocklyStorage' in window && window.location.hash.length > 1) {
+ BlocklyStorage.retrieveXml(window.location.hash.substring(1));
+ }
+ </script>
+
+</body>
+</html>
diff --git a/blockly/demos/toolbox/icon.png b/blockly/demos/toolbox/icon.png
new file mode 100644
index 0000000..336f390
--- /dev/null
+++ b/blockly/demos/toolbox/icon.png
Binary files differ
diff --git a/blockly/demos/toolbox/index.html b/blockly/demos/toolbox/index.html
new file mode 100644
index 0000000..4e81c02
--- /dev/null
+++ b/blockly/demos/toolbox/index.html
@@ -0,0 +1,343 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Blockly Demo: Toolbox</title>
+ <script src="../../blockly_compressed.js"></script>
+ <script src="../../blocks_compressed.js"></script>
+ <script src="../../msg/js/en.js"></script>
+ <style>
+ body {
+ background-color: #fff;
+ font-family: sans-serif;
+ }
+ h1 {
+ font-weight: normal;
+ font-size: 140%;
+ }
+ </style>
+</head>
+<body>
+ <h1><a href="https://developers.google.com/blockly/">Blockly</a> &gt;
+ <a href="../index.html">Demos</a> &gt; Toolbox</h1>
+
+ <p>This is a demo of a complex category structure for the toolbox.</p>
+
+ <p>&rarr; More info on the <a href="https://developers.google.com/blockly/guides/configure/web/toolbox">Toolbox</a>&hellip;</p>
+
+ <div id="blocklyDiv" style="height: 600px; width: 800px;"></div>
+
+ <xml id="toolbox" style="display: none">
+ <category name="Logic">
+ <category name="If">
+ <block type="controls_if"></block>
+ <block type="controls_if">
+ <mutation else="1"></mutation>
+ </block>
+ <block type="controls_if">
+ <mutation elseif="1" else="1"></mutation>
+ </block>
+ </category>
+ <category name="Boolean">
+ <block type="logic_compare"></block>
+ <block type="logic_operation"></block>
+ <block type="logic_negate"></block>
+ <block type="logic_boolean"></block>
+ <block type="logic_null"></block>
+ <block type="logic_ternary"></block>
+ </category>
+ </category>
+ <category name="Loops">
+ <block type="controls_repeat_ext">
+ <value name="TIMES">
+ <block type="math_number">
+ <field name="NUM">10</field>
+ </block>
+ </value>
+ </block>
+ <block type="controls_whileUntil"></block>
+ <block type="controls_for">
+ <field name="VAR">i</field>
+ <value name="FROM">
+ <block type="math_number">
+ <field name="NUM">1</field>
+ </block>
+ </value>
+ <value name="TO">
+ <block type="math_number">
+ <field name="NUM">10</field>
+ </block>
+ </value>
+ <value name="BY">
+ <block type="math_number">
+ <field name="NUM">1</field>
+ </block>
+ </value>
+ </block>
+ <block type="controls_forEach"></block>
+ <block type="controls_flow_statements"></block>
+ </category>
+ <category name="Math">
+ <block type="math_number"></block>
+ <block type="math_arithmetic"></block>
+ <block type="math_single"></block>
+ <block type="math_trig"></block>
+ <block type="math_constant"></block>
+ <block type="math_number_property"></block>
+ <block type="math_round"></block>
+ <block type="math_on_list"></block>
+ <block type="math_modulo"></block>
+ <block type="math_constrain">
+ <value name="LOW">
+ <block type="math_number">
+ <field name="NUM">1</field>
+ </block>
+ </value>
+ <value name="HIGH">
+ <block type="math_number">
+ <field name="NUM">100</field>
+ </block>
+ </value>
+ </block>
+ <block type="math_random_int">
+ <value name="FROM">
+ <block type="math_number">
+ <field name="NUM">1</field>
+ </block>
+ </value>
+ <value name="TO">
+ <block type="math_number">
+ <field name="NUM">100</field>
+ </block>
+ </value>
+ </block>
+ <block type="math_random_float"></block>
+ </category>
+ <category name="Lists">
+ <block type="lists_create_empty"></block>
+ <block type="lists_create_with"></block>
+ <block type="lists_repeat">
+ <value name="NUM">
+ <block type="math_number">
+ <field name="NUM">5</field>
+ </block>
+ </value>
+ </block>
+ <block type="lists_length"></block>
+ <block type="lists_isEmpty"></block>
+ <block type="lists_indexOf"></block>
+ <block type="lists_getIndex"></block>
+ <block type="lists_setIndex"></block>
+ </category>
+ <category name="Variables" custom="VARIABLE"></category>
+ <category name="Functions" custom="PROCEDURE"></category>
+ <sep></sep>
+ <category name="Library" expanded="true">
+ <category name="Randomize">
+ <block type="procedures_defnoreturn">
+ <mutation>
+ <arg name="list"></arg>
+ </mutation>
+ <field name="NAME">randomize</field>
+ <statement name="STACK">
+ <block type="controls_for" inline="true">
+ <field name="VAR">x</field>
+ <value name="FROM">
+ <block type="math_number">
+ <field name="NUM">1</field>
+ </block>
+ </value>
+ <value name="TO">
+ <block type="lists_length" inline="false">
+ <value name="VALUE">
+ <block type="variables_get">
+ <field name="VAR">list</field>
+ </block>
+ </value>
+ </block>
+ </value>
+ <value name="BY">
+ <block type="math_number">
+ <field name="NUM">1</field>
+ </block>
+ </value>
+ <statement name="DO">
+ <block type="variables_set" inline="false">
+ <field name="VAR">y</field>
+ <value name="VALUE">
+ <block type="math_random_int" inline="true">
+ <value name="FROM">
+ <block type="math_number">
+ <field name="NUM">1</field>
+ </block>
+ </value>
+ <value name="TO">
+ <block type="lists_length" inline="false">
+ <value name="VALUE">
+ <block type="variables_get">
+ <field name="VAR">list</field>
+ </block>
+ </value>
+ </block>
+ </value>
+ </block>
+ </value>
+ <next>
+ <block type="variables_set" inline="false">
+ <field name="VAR">temp</field>
+ <value name="VALUE">
+ <block type="lists_getIndex" inline="true">
+ <mutation statement="false" at="true"></mutation>
+ <field name="MODE">GET</field>
+ <field name="WHERE">FROM_START</field>
+ <value name="AT">
+ <block type="variables_get">
+ <field name="VAR">y</field>
+ </block>
+ </value>
+ <value name="VALUE">
+ <block type="variables_get">
+ <field name="VAR">list</field>
+ </block>
+ </value>
+ </block>
+ </value>
+ <next>
+ <block type="lists_setIndex" inline="false">
+ <value name="AT">
+ <block type="variables_get">
+ <field name="VAR">y</field>
+ </block>
+ </value>
+ <value name="LIST">
+ <block type="variables_get">
+ <field name="VAR">list</field>
+ </block>
+ </value>
+ <value name="TO">
+ <block type="lists_getIndex" inline="true">
+ <mutation statement="false" at="true"></mutation>
+ <field name="MODE">GET</field>
+ <field name="WHERE">FROM_START</field>
+ <value name="AT">
+ <block type="variables_get">
+ <field name="VAR">x</field>
+ </block>
+ </value>
+ <value name="VALUE">
+ <block type="variables_get">
+ <field name="VAR">list</field>
+ </block>
+ </value>
+ </block>
+ </value>
+ <next>
+ <block type="lists_setIndex" inline="false">
+ <value name="AT">
+ <block type="variables_get">
+ <field name="VAR">x</field>
+ </block>
+ </value>
+ <value name="LIST">
+ <block type="variables_get">
+ <field name="VAR">list</field>
+ </block>
+ </value>
+ <value name="TO">
+ <block type="variables_get">
+ <field name="VAR">temp</field>
+ </block>
+ </value>
+ </block>
+ </next>
+ </block>
+ </next>
+ </block>
+ </next>
+ </block>
+ </statement>
+ </block>
+ </statement>
+ </block>
+ </category>
+ <category name="Jabberwocky">
+ <block type="text_print">
+ <value name="TEXT">
+ <block type="text">
+ <field name="TEXT">'Twas brillig, and the slithy toves</field>
+ </block>
+ </value>
+ <next>
+ <block type="text_print">
+ <value name="TEXT">
+ <block type="text">
+ <field name="TEXT"> Did gyre and gimble in the wabe:</field>
+ </block>
+ </value>
+ <next>
+ <block type="text_print">
+ <value name="TEXT">
+ <block type="text">
+ <field name="TEXT">All mimsy were the borogroves,</field>
+ </block>
+ </value>
+ <next>
+ <block type="text_print">
+ <value name="TEXT">
+ <block type="text">
+ <field name="TEXT"> And the mome raths outgrabe.</field>
+ </block>
+ </value>
+ </block>
+ </next>
+ </block>
+ </next>
+ </block>
+ </next>
+ </block>
+ <block type="text_print">
+ <value name="TEXT">
+ <block type="text">
+ <field name="TEXT">"Beware the Jabberwock, my son!</field>
+ </block>
+ </value>
+ <next>
+ <block type="text_print">
+ <value name="TEXT">
+ <block type="text">
+ <field name="TEXT"> The jaws that bite, the claws that catch!</field>
+ </block>
+ </value>
+ <next>
+ <block type="text_print">
+ <value name="TEXT">
+ <block type="text">
+ <field name="TEXT">Beware the Jubjub bird, and shun</field>
+ </block>
+ </value>
+ <next>
+ <block type="text_print">
+ <value name="TEXT">
+ <block type="text">
+ <field name="TEXT"> The frumious Bandersnatch!"</field>
+ </block>
+ </value>
+ </block>
+ </next>
+ </block>
+ </next>
+ </block>
+ </next>
+ </block>
+ </category>
+ </category>
+ </xml>
+
+ <script>
+ var workspace = Blockly.inject('blocklyDiv',
+ {media: '../../media/',
+ toolbox: document.getElementById('toolbox')});
+ </script>
+
+</body>
+</html>