rapid-router 5.4.1__py2.py3-none-any.whl → 7.6.8__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- example_project/rapid_router_test_settings.py +164 -0
- example_project/settings.py +152 -0
- example_project/urls.py +15 -0
- example_project/{example_project/wsgi.py → wsgi.py} +2 -1
- game/__init__.py +1 -1
- game/admin.py +43 -4
- game/app_settings.py +3 -7
- game/character.py +26 -18
- game/decor.py +172 -97
- game/end_to_end_tests/base_game_test.py +44 -33
- game/end_to_end_tests/editor_page.py +17 -2
- game/end_to_end_tests/game_page.py +127 -45
- game/end_to_end_tests/selenium_test_case.py +1 -20
- game/end_to_end_tests/test_cow_crashes.py +3 -5
- game/end_to_end_tests/test_language_dropdown.py +14 -0
- game/end_to_end_tests/test_level_editor.py +290 -0
- game/end_to_end_tests/test_level_failures.py +1 -1
- game/end_to_end_tests/test_level_selection.py +79 -0
- game/end_to_end_tests/test_play_through.py +240 -102
- game/end_to_end_tests/test_python_levels.py +44 -13
- game/end_to_end_tests/test_saving_workspace.py +22 -0
- game/forms.py +9 -2
- game/level_management.py +38 -29
- game/messages.py +1218 -203
- game/migrations/0001_squashed_0025_levels_ordering_pt1.py +19 -1
- game/migrations/0026_levels_pt2.py +13 -2
- game/migrations/0032_cannot_turn_left_level.py +13 -2
- game/migrations/0033_recursion_level.py +13 -2
- game/migrations/0034_joes_level.py +13 -2
- game/migrations/0035_disable_route_score_level_70.py +0 -2
- game/migrations/0036_level_score_73.py +0 -2
- game/migrations/0037_level_score_79.py +0 -2
- game/migrations/0038_level_score_40.py +0 -1
- game/migrations/0042_level_score_73.py +0 -2
- game/migrations/0048_add_cow_field_and_blocks.py +0 -2
- game/migrations/0049_level_score_34.py +0 -2
- game/migrations/0050_level_score_40.py +0 -2
- game/migrations/0051_level_score_49.py +0 -1
- game/migrations/0076_level_locked_for_class.py +19 -0
- game/migrations/0077_alter_level_next_level.py +52 -0
- game/migrations/0078_add_block_types.py +23 -0
- game/migrations/0079_populate_block_type_add_cow_blocks.py +60 -0
- game/migrations/0080_level_disable_algorithm_score.py +18 -0
- game/migrations/0081_first_12_levels_no_algo_score.py +29 -0
- game/migrations/0082_level_43_solution.py +16 -0
- game/migrations/0083_add_cows_to_existing_levels.py +195 -0
- game/migrations/0084_alter_block_block_type.py +18 -0
- game/migrations/0085_add_new_blocks.py +53 -0
- game/migrations/0086_loop_levels.py +482 -0
- game/migrations/0087_workspace_python_view_enabled.py +18 -0
- game/migrations/0088_rename_episodes.py +35 -0
- game/migrations/0089_episodes_in_development.py +30 -0
- game/migrations/0090_add_missing_model_solutions.py +144 -0
- game/migrations/0091_disable_algo_score_if_no_model_solution.py +46 -0
- game/migrations/0092_disable_algo_score_in_custom_levels.py +28 -0
- game/migrations/0093_alter_level_character_name.py +18 -0
- game/migrations/0094_add_hint_lesson_subtitle_to_levels.py +28 -0
- game/migrations/0095_level_commands.py +18 -0
- game/migrations/0096_alter_level_commands.py +18 -0
- game/migrations/0097_add_python_den_levels.py +1515 -0
- game/migrations/0098_add_episode_link_fields.py +44 -0
- game/migrations/0099_python_episodes_links.py +103 -0
- game/migrations/0100_reorder_python_levels.py +179 -0
- game/migrations/0101_rename_episodes.py +45 -0
- game/migrations/0102_reoder_episodes_13_14.py +136 -0
- game/migrations/0103_level_1015_solution.py +26 -0
- game/migrations/0104_remove_level_direct_drive.py +17 -0
- game/migrations/0105_delete_invalid_attempts.py +18 -0
- game/migrations/0106_fields_to_snake_case.py +48 -0
- game/migrations/0107_rename_worksheet_link_episode_student_worksheet_link.py +18 -0
- game/migrations/0108_episode_indy_worksheet_link.py +18 -0
- game/migrations/0109_create_episodes_23_and_24.py +99 -0
- game/migrations/0110_remove_episode_indy_worksheet_link_and_more.py +100 -0
- game/migrations/0111_create_worksheets.py +149 -0
- game/migrations/0112_worksheet_locked_classes.py +21 -0
- game/migrations/0113_level_needs_approval.py +18 -0
- game/migrations/0114_default_and_non_student_levels_no_approval.py +31 -0
- game/migrations/0115_level_level__default_does_not_need_approval.py +22 -0
- game/migrations/0116_update_worksheet_video_links.py +68 -0
- game/migrations/0117_update_solutions_to_if_else.py +61 -0
- game/models.py +157 -16
- game/permissions.py +34 -19
- game/python_den_urls.py +26 -0
- game/random_road.py +43 -127
- game/serializers.py +12 -17
- game/static/django_reverse_js/js/reverse.js +171 -0
- game/static/game/css/LilitaOne-Regular.ttf +0 -0
- game/static/game/css/backgrounds.css +14 -10
- game/static/game/css/dataTables.custom.css +4 -2
- game/static/game/css/dataTables.jqueryui.css +561 -320
- game/static/game/css/editor.css +47 -0
- game/static/game/css/game.css +43 -49
- game/static/game/css/game_screen.css +116 -53
- game/static/game/css/jquery.dataTables.css +455 -251
- game/static/game/css/level_editor.css +10 -1
- game/static/game/css/level_selection.css +32 -3
- game/static/game/css/level_share.css +6 -5
- game/static/game/css/skulpt/codemirror.css +1 -0
- game/static/game/image/Python_Den_hero_student.png +0 -0
- game/static/game/image/Python_levels_page.svg +1954 -0
- game/static/game/image/characters/front_view/Electric_van.svg +448 -0
- game/static/game/image/characters/top_view/Electric_van.svg +448 -0
- game/static/game/image/characters/top_view/Sleigh.svg +436 -0
- game/static/game/image/decor/city/solar_panel.svg +1200 -0
- game/static/game/image/decor/farm/solar_panel.svg +86 -0
- game/static/game/image/decor/grass/solar_panel.svg +86 -0
- game/static/game/image/decor/snow/barn.svg +1788 -0
- game/static/game/image/decor/snow/cfc.svg +1050 -147
- game/static/game/image/decor/snow/crops.svg +7370 -0
- game/static/game/image/decor/snow/hospital.svg +1220 -0
- game/static/game/image/decor/snow/house1.svg +971 -0
- game/static/game/image/decor/snow/house2.svg +1574 -0
- game/static/game/image/decor/snow/school.svg +1071 -0
- game/static/game/image/decor/snow/shop.svg +3211 -0
- game/static/game/image/decor/snow/solar_panel.svg +173 -0
- game/static/game/image/electric_van.svg +448 -0
- game/static/game/image/icons/add_house.svg +26 -0
- game/static/game/image/icons/delete_house.svg +26 -0
- game/static/game/image/icons/description.svg +1 -0
- game/static/game/image/icons/hint.svg +1 -0
- game/static/game/image/icons/if_else.svg +3 -0
- game/static/game/image/icons/python.svg +1 -1
- game/static/game/image/if_else_example.png +0 -0
- game/static/game/image/pigeon.svg +684 -0
- game/static/game/image/python_den_header.svg +19 -0
- game/static/game/js/animation.js +84 -28
- game/static/game/js/blockly/msg/js/bg.js +52 -1
- game/static/game/js/blockly/msg/js/ca.js +52 -1
- game/static/game/js/blockly/msg/js/en-gb.js +52 -1
- game/static/game/js/blockly/msg/js/en.js +52 -1
- game/static/game/js/blockly/msg/js/es.js +52 -1
- game/static/game/js/blockly/msg/js/fr.js +52 -1
- game/static/game/js/blockly/msg/js/hi.js +52 -1
- game/static/game/js/blockly/msg/js/it.js +52 -1
- game/static/game/js/blockly/msg/js/pl.js +52 -1
- game/static/game/js/blockly/msg/js/pt-br.js +52 -1
- game/static/game/js/blockly/msg/js/ru.js +52 -1
- game/static/game/js/blockly/msg/js/ur.js +52 -1
- game/static/game/js/blocklyCompiler.js +550 -392
- game/static/game/js/blocklyControl.js +335 -302
- game/static/game/js/blocklyCustomBlocks.js +691 -458
- game/static/game/js/blocklyCustomisations.js +3 -1
- game/static/game/js/button.js +12 -0
- game/static/game/js/cow.js +15 -130
- game/static/game/js/drawing.js +313 -201
- game/static/game/js/editor.js +23 -0
- game/static/game/js/game.js +148 -139
- game/static/game/js/jquery.dataTables.min.js +3 -159
- game/static/game/js/level_editor.js +823 -448
- game/static/game/js/level_moderation.js +33 -2
- game/static/game/js/level_selection.js +62 -25
- game/static/game/js/loadLanguages.js +21 -0
- game/static/game/js/map.js +106 -36
- game/static/game/js/model.js +55 -107
- game/static/game/js/pathFinder.js +73 -72
- game/static/game/js/program.js +184 -193
- game/static/game/js/pythonControl.js +14 -1
- game/static/game/js/scoreboard.js +0 -37
- game/static/game/js/scoreboardSharedLevels.js +48 -0
- game/static/game/js/sharing.js +22 -10
- game/static/game/js/skulpt/codemirror.js +5 -4
- game/static/game/js/skulpt/skulpt-stdlib.js +1 -1
- game/static/game/js/sound.js +52 -5
- game/static/game/js/van.js +0 -7
- game/static/game/raphael_image/characters/top_view/Electric_van.svg +448 -0
- game/static/game/raphael_image/characters/top_view/Sleigh.svg +436 -0
- game/static/game/raphael_image/decor/city/solar_panel.svg +1200 -0
- game/static/game/raphael_image/decor/farm/solar_panel.svg +86 -0
- game/static/game/raphael_image/decor/grass/solar_panel.svg +86 -0
- game/static/game/raphael_image/decor/snow/barn.svg +1788 -0
- game/static/game/raphael_image/decor/snow/cfc.svg +1050 -147
- game/static/game/raphael_image/decor/snow/crops.svg +7370 -0
- game/static/game/raphael_image/decor/snow/hospital.svg +1220 -0
- game/static/game/raphael_image/decor/snow/house1.svg +971 -0
- game/static/game/raphael_image/decor/snow/house2.svg +1574 -0
- game/static/game/raphael_image/decor/snow/school.svg +1071 -0
- game/static/game/raphael_image/decor/snow/shop.svg +3211 -0
- game/static/game/raphael_image/decor/snow/solar_panel.svg +173 -0
- game/static/game/raphael_image/pigeon.svg +685 -0
- game/static/game/raphael_image/sleigh_wreckage.svg +430 -0
- game/static/game/sass/game.scss +22 -6
- game/static/game/sound/clown_horn.mp3 +0 -0
- game/static/game/sound/clown_horn.ogg +0 -0
- game/static/game/sound/electric_van_starting.mp3 +0 -0
- game/static/game/sound/electric_van_starting.ogg +0 -0
- game/static/game/sound/pigeon.mp3 +0 -0
- game/static/game/sound/pigeon.ogg +0 -0
- game/static/game/sound/sleigh_bells.mp3 +0 -0
- game/static/game/sound/sleigh_bells.ogg +0 -0
- game/static/game/sound/sleigh_crash.mp3 +0 -0
- game/static/game/sound/sleigh_crash.ogg +0 -0
- game/templates/game/base.html +35 -15
- game/templates/game/basenonav.html +23 -17
- game/templates/game/game.html +236 -111
- game/templates/game/level_editor.html +353 -275
- game/templates/game/level_moderation.html +19 -6
- game/templates/game/level_selection.html +75 -62
- game/templates/game/python_den_level_selection.html +291 -0
- game/templates/game/python_den_worksheet.html +101 -0
- game/templates/game/scoreboard.html +88 -65
- game/tests/test_level_editor.py +210 -35
- game/tests/test_level_moderation.py +6 -20
- game/tests/test_level_selection.py +332 -11
- game/tests/test_python_den_worksheet.py +85 -0
- game/tests/test_scoreboard.py +258 -66
- game/tests/utils/level.py +43 -3
- game/tests/utils/teacher.py +2 -2
- game/theme.py +21 -21
- game/urls.py +125 -78
- game/views/language_code_conversions.py +90 -0
- game/views/level.py +201 -63
- game/views/level_editor.py +109 -48
- game/views/level_moderation.py +29 -6
- game/views/level_selection.py +179 -56
- game/views/level_solutions.py +600 -106
- game/views/scoreboard.py +181 -66
- game/views/worksheet.py +25 -0
- rapid_router-7.6.8.dist-info/METADATA +174 -0
- {rapid_router-5.4.1.dist-info → rapid_router-7.6.8.dist-info}/RECORD +222 -242
- {rapid_router-5.4.1.dist-info → rapid_router-7.6.8.dist-info}/WHEEL +1 -1
- rapid_router-7.6.8.dist-info/licenses/LICENSE.md +3 -0
- example_project/example_project/__init__.py +0 -1
- example_project/example_project/settings.py +0 -54
- example_project/example_project/urls.py +0 -16
- example_project/manage.py +0 -10
- game/autoconfig.py +0 -59
- game/csp_config.py +0 -23
- game/locale/ar_SA/LC_MESSAGES/django.mo +0 -0
- game/locale/ar_SA/LC_MESSAGES/django.po +0 -405
- game/locale/ar_SA/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/ar_SA/LC_MESSAGES/djangojs.po +0 -743
- game/locale/bg_BG/LC_MESSAGES/django.mo +0 -0
- game/locale/bg_BG/LC_MESSAGES/django.po +0 -405
- game/locale/bg_BG/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/bg_BG/LC_MESSAGES/djangojs.po +0 -739
- game/locale/ca_ES/LC_MESSAGES/django.mo +0 -0
- game/locale/ca_ES/LC_MESSAGES/django.po +0 -405
- game/locale/ca_ES/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/ca_ES/LC_MESSAGES/djangojs.po +0 -740
- game/locale/cs_CZ/LC_MESSAGES/django.mo +0 -0
- game/locale/cs_CZ/LC_MESSAGES/django.po +0 -405
- game/locale/cs_CZ/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/cs_CZ/LC_MESSAGES/djangojs.po +0 -741
- game/locale/cy_GB/LC_MESSAGES/django.mo +0 -0
- game/locale/cy_GB/LC_MESSAGES/django.po +0 -405
- game/locale/cy_GB/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/cy_GB/LC_MESSAGES/djangojs.po +0 -743
- game/locale/de_DE/LC_MESSAGES/django.mo +0 -0
- game/locale/de_DE/LC_MESSAGES/django.po +0 -405
- game/locale/de_DE/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/de_DE/LC_MESSAGES/djangojs.po +0 -739
- game/locale/el_GR/LC_MESSAGES/django.mo +0 -0
- game/locale/el_GR/LC_MESSAGES/django.po +0 -405
- game/locale/el_GR/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/el_GR/LC_MESSAGES/djangojs.po +0 -739
- game/locale/en_GB/LC_MESSAGES/django.mo +0 -0
- game/locale/en_GB/LC_MESSAGES/django.po +0 -405
- game/locale/en_GB/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/en_GB/LC_MESSAGES/djangojs.po +0 -739
- game/locale/es_ES/LC_MESSAGES/django.mo +0 -0
- game/locale/es_ES/LC_MESSAGES/django.po +0 -405
- game/locale/es_ES/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/es_ES/LC_MESSAGES/djangojs.po +0 -739
- game/locale/fi_FI/LC_MESSAGES/django.mo +0 -0
- game/locale/fi_FI/LC_MESSAGES/django.po +0 -405
- game/locale/fi_FI/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/fi_FI/LC_MESSAGES/djangojs.po +0 -739
- game/locale/fr_FR/LC_MESSAGES/django.mo +0 -0
- game/locale/fr_FR/LC_MESSAGES/django.po +0 -405
- game/locale/fr_FR/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/fr_FR/LC_MESSAGES/djangojs.po +0 -739
- game/locale/gu_IN/LC_MESSAGES/django.mo +0 -0
- game/locale/gu_IN/LC_MESSAGES/django.po +0 -405
- game/locale/gu_IN/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/gu_IN/LC_MESSAGES/djangojs.po +0 -739
- game/locale/hi_IN/LC_MESSAGES/django.mo +0 -0
- game/locale/hi_IN/LC_MESSAGES/django.po +0 -405
- game/locale/hi_IN/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/hi_IN/LC_MESSAGES/djangojs.po +0 -739
- game/locale/id_ID/LC_MESSAGES/django.mo +0 -0
- game/locale/id_ID/LC_MESSAGES/django.po +0 -405
- game/locale/id_ID/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/id_ID/LC_MESSAGES/djangojs.po +0 -738
- game/locale/it_IT/LC_MESSAGES/django.mo +0 -0
- game/locale/it_IT/LC_MESSAGES/django.po +0 -405
- game/locale/it_IT/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/it_IT/LC_MESSAGES/djangojs.po +0 -739
- game/locale/ja_JP/LC_MESSAGES/django.mo +0 -0
- game/locale/ja_JP/LC_MESSAGES/django.po +0 -405
- game/locale/ja_JP/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/ja_JP/LC_MESSAGES/djangojs.po +0 -738
- game/locale/lol_US/LC_MESSAGES/django.mo +0 -0
- game/locale/lol_US/LC_MESSAGES/django.po +0 -405
- game/locale/lol_US/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/lol_US/LC_MESSAGES/djangojs.po +0 -739
- game/locale/nb_NO/LC_MESSAGES/django.mo +0 -0
- game/locale/nb_NO/LC_MESSAGES/django.po +0 -405
- game/locale/nb_NO/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/nb_NO/LC_MESSAGES/djangojs.po +0 -739
- game/locale/nl_NL/LC_MESSAGES/django.mo +0 -0
- game/locale/nl_NL/LC_MESSAGES/django.po +0 -405
- game/locale/nl_NL/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/nl_NL/LC_MESSAGES/djangojs.po +0 -739
- game/locale/pl_PL/LC_MESSAGES/django.mo +0 -0
- game/locale/pl_PL/LC_MESSAGES/django.po +0 -405
- game/locale/pl_PL/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/pl_PL/LC_MESSAGES/djangojs.po +0 -741
- game/locale/pt_BR/LC_MESSAGES/django.mo +0 -0
- game/locale/pt_BR/LC_MESSAGES/django.po +0 -405
- game/locale/pt_BR/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/pt_BR/LC_MESSAGES/djangojs.po +0 -739
- game/locale/pt_PT/LC_MESSAGES/django.mo +0 -0
- game/locale/pt_PT/LC_MESSAGES/django.po +0 -405
- game/locale/pt_PT/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/pt_PT/LC_MESSAGES/djangojs.po +0 -739
- game/locale/ro_RO/LC_MESSAGES/django.mo +0 -0
- game/locale/ro_RO/LC_MESSAGES/django.po +0 -405
- game/locale/ro_RO/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/ro_RO/LC_MESSAGES/djangojs.po +0 -740
- game/locale/ru_RU/LC_MESSAGES/django.mo +0 -0
- game/locale/ru_RU/LC_MESSAGES/django.po +0 -405
- game/locale/ru_RU/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/ru_RU/LC_MESSAGES/djangojs.po +0 -741
- game/locale/sv_SE/LC_MESSAGES/django.mo +0 -0
- game/locale/sv_SE/LC_MESSAGES/django.po +0 -405
- game/locale/sv_SE/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/sv_SE/LC_MESSAGES/djangojs.po +0 -739
- game/locale/tl_PH/LC_MESSAGES/django.mo +0 -0
- game/locale/tl_PH/LC_MESSAGES/django.po +0 -405
- game/locale/tl_PH/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/tl_PH/LC_MESSAGES/djangojs.po +0 -739
- game/locale/tlh_AA/LC_MESSAGES/django.mo +0 -0
- game/locale/tlh_AA/LC_MESSAGES/django.po +0 -405
- game/locale/tlh_AA/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/tlh_AA/LC_MESSAGES/djangojs.po +0 -739
- game/locale/tr_TR/LC_MESSAGES/django.mo +0 -0
- game/locale/tr_TR/LC_MESSAGES/django.po +0 -405
- game/locale/tr_TR/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/tr_TR/LC_MESSAGES/djangojs.po +0 -740
- game/locale/ur_IN/LC_MESSAGES/django.mo +0 -0
- game/locale/ur_IN/LC_MESSAGES/django.po +0 -405
- game/locale/ur_IN/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/ur_IN/LC_MESSAGES/djangojs.po +0 -739
- game/locale/ur_PK/LC_MESSAGES/django.mo +0 -0
- game/locale/ur_PK/LC_MESSAGES/django.po +0 -405
- game/locale/ur_PK/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/ur_PK/LC_MESSAGES/djangojs.po +0 -739
- game/static/game/image/actions/go.svg +0 -18
- game/static/game/image/icons/destination.svg +0 -9
- game/static/game/js/pqselect.min.js +0 -9
- game/static/game/js/widget-scroller.js +0 -906
- rapid_router-5.4.1.dist-info/LICENSE.md +0 -577
- rapid_router-5.4.1.dist-info/METADATA +0 -24
- {rapid_router-5.4.1.dist-info → rapid_router-7.6.8.dist-info}/top_level.txt +0 -0
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
var ocargo = ocargo || {};
|
|
4
4
|
|
|
5
5
|
ocargo.BlocklyControl = function () {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
6
|
+
this.blocklyCustomisations = new ocargo.BlocklyCustomisations();
|
|
7
|
+
this.blocklyCustomisations.setupDoubleclick();
|
|
8
|
+
this.blocklyCustomisations.setupLimitedBlocks();
|
|
9
|
+
this.blocklyDiv = document.getElementById("blockly_holder");
|
|
10
|
+
this.toolbox = document.getElementById("blockly_toolbox");
|
|
11
|
+
|
|
12
|
+
Blockly.inject(this.blocklyDiv, {
|
|
13
|
+
path: "/static/game/js/blockly/",
|
|
14
|
+
toolbox: BLOCKLY_XML,
|
|
15
|
+
trashcan: true,
|
|
16
|
+
scrollbars: true,
|
|
17
|
+
maxInstances: maxInstances,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Stop the flyout from closing automatically
|
|
21
|
+
Blockly.Flyout.autoClose = false;
|
|
22
|
+
|
|
23
|
+
this.blocklyCustomisations.addLimitedBlockListeners(Blockly.mainWorkspace);
|
|
24
|
+
this.blocklyCustomisations.addClickListenerToStartBlock();
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
ocargo.BlocklyControl.BLOCK_HEIGHT = 20;
|
|
@@ -33,166 +34,176 @@ ocargo.BlocklyControl.BLOCK_CHARACTER_WIDTH = 40;
|
|
|
33
34
|
ocargo.BlocklyControl.prototype.incorrectBlock = null;
|
|
34
35
|
ocargo.BlocklyControl.prototype.incorrectBlockColour = null;
|
|
35
36
|
|
|
36
|
-
ocargo.BlocklyControl.prototype.prepare = function(blocks) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
ocargo.BlocklyControl.prototype.prepare = function (blocks) {
|
|
38
|
+
try {
|
|
39
|
+
return {
|
|
40
|
+
success: true,
|
|
41
|
+
program: blocks
|
|
42
|
+
? ocargo.blocklyCompiler.mobileCompile(blocks)
|
|
43
|
+
: ocargo.blocklyCompiler.compile(),
|
|
44
|
+
};
|
|
45
|
+
} catch (error) {
|
|
46
|
+
return {
|
|
47
|
+
success: false,
|
|
48
|
+
error:
|
|
49
|
+
gettext("Your program doesn't look quite right...") +
|
|
50
|
+
"<br><br>" +
|
|
51
|
+
gettext(error),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
48
54
|
};
|
|
49
55
|
|
|
50
|
-
ocargo.BlocklyControl.prototype.redrawBlockly = function() {
|
|
51
|
-
|
|
56
|
+
ocargo.BlocklyControl.prototype.redrawBlockly = function () {
|
|
57
|
+
Blockly.svgResize(Blockly.mainWorkspace);
|
|
52
58
|
};
|
|
53
59
|
|
|
54
60
|
ocargo.BlocklyControl.prototype.clearIncorrectBlock = function () {
|
|
55
|
-
|
|
56
|
-
}
|
|
61
|
+
this.incorrectBlock = null;
|
|
62
|
+
};
|
|
57
63
|
|
|
58
64
|
function wasGameStarted(blocks) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
let gameStarted = false;
|
|
66
|
+
for (let block of blocks) {
|
|
67
|
+
if (block.type == "start") gameStarted = true;
|
|
68
|
+
}
|
|
69
|
+
return gameStarted;
|
|
64
70
|
}
|
|
65
71
|
|
|
66
|
-
ocargo.BlocklyControl.prototype.reset = function() {
|
|
72
|
+
ocargo.BlocklyControl.prototype.reset = function () {
|
|
73
|
+
let allBlocks = Blockly.mainWorkspace.getAllBlocks();
|
|
67
74
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (block.type != 'start') block.dispose(true)
|
|
72
|
-
}
|
|
75
|
+
for (let block of allBlocks) {
|
|
76
|
+
if (block.type != "start") block.dispose(true);
|
|
77
|
+
}
|
|
73
78
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
// Each time a game starts the clear function is called.
|
|
80
|
+
// Therefore a simple check is preformed to see if the level
|
|
81
|
+
// has a start button, if not then create a start button
|
|
82
|
+
if (!wasGameStarted(allBlocks)) {
|
|
83
|
+
let startBlock = this.createBlock("start");
|
|
84
|
+
// Generate the first block on the (100, 100) position
|
|
85
|
+
startBlock.moveBy(100, 100);
|
|
86
|
+
}
|
|
81
87
|
|
|
82
|
-
|
|
88
|
+
this.clearIncorrectBlock();
|
|
83
89
|
};
|
|
84
90
|
|
|
85
|
-
ocargo.BlocklyControl.prototype.deserialize = function(text) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
console.log(e);
|
|
106
|
-
this.reset();
|
|
91
|
+
ocargo.BlocklyControl.prototype.deserialize = function (text) {
|
|
92
|
+
try {
|
|
93
|
+
var oldXml = Blockly.Xml.workspaceToDom(Blockly.mainWorkspace);
|
|
94
|
+
|
|
95
|
+
var newXml = Blockly.Xml.textToDom(text);
|
|
96
|
+
Blockly.mainWorkspace.clear();
|
|
97
|
+
Blockly.Xml.domToWorkspace(newXml, Blockly.mainWorkspace);
|
|
98
|
+
var legal = this.removeIllegalBlocks();
|
|
99
|
+
|
|
100
|
+
if (!legal) {
|
|
101
|
+
ocargo.Drawing.startPopup(
|
|
102
|
+
gettext("Loading workspace"),
|
|
103
|
+
"",
|
|
104
|
+
gettext(
|
|
105
|
+
"Sorry, this workspace has blocks in it that aren't allowed in this level!"
|
|
106
|
+
),
|
|
107
|
+
true
|
|
108
|
+
);
|
|
109
|
+
Blockly.mainWorkspace.clear();
|
|
110
|
+
Blockly.Xml.domToWorkspace(oldXml, Blockly.mainWorkspace);
|
|
107
111
|
}
|
|
112
|
+
} catch (e) {
|
|
113
|
+
console.log(e);
|
|
114
|
+
this.reset();
|
|
115
|
+
}
|
|
108
116
|
};
|
|
109
117
|
|
|
110
|
-
ocargo.BlocklyControl.prototype.serialize = function() {
|
|
111
|
-
|
|
112
|
-
|
|
118
|
+
ocargo.BlocklyControl.prototype.serialize = function () {
|
|
119
|
+
var xml = Blockly.Xml.workspaceToDom(Blockly.mainWorkspace);
|
|
120
|
+
return Blockly.Xml.domToText(xml);
|
|
113
121
|
};
|
|
114
122
|
|
|
115
|
-
ocargo.BlocklyControl.prototype.removeIllegalBlocks = function() {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (!found) {
|
|
141
|
-
clean = false;
|
|
142
|
-
block.dispose();
|
|
143
|
-
}
|
|
144
|
-
} else {
|
|
145
|
-
startCount--;
|
|
146
|
-
if (isSafari && startCount < 0) {
|
|
147
|
-
block.dispose();
|
|
148
|
-
}
|
|
123
|
+
ocargo.BlocklyControl.prototype.removeIllegalBlocks = function () {
|
|
124
|
+
// Buggy blockly doesn't serialise properly on Safari.
|
|
125
|
+
var isSafari =
|
|
126
|
+
navigator.userAgent.indexOf("Safari") !== -1 &&
|
|
127
|
+
navigator.userAgent.indexOf("Chrome") === -1;
|
|
128
|
+
|
|
129
|
+
var blocks = Blockly.mainWorkspace.getAllBlocks();
|
|
130
|
+
blocks.sort(function (a, b) {
|
|
131
|
+
return a.id - b.id;
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
var startCount = 1;
|
|
135
|
+
var clean = true;
|
|
136
|
+
|
|
137
|
+
for (var i = 0; i < blocks.length; i++) {
|
|
138
|
+
var block = blocks[i];
|
|
139
|
+
|
|
140
|
+
if (block.type !== "start") {
|
|
141
|
+
var found = false;
|
|
142
|
+
for (var j = 0; j < BLOCKS.length; j++) {
|
|
143
|
+
if (BLOCKS[j].type == block.type) {
|
|
144
|
+
found = true;
|
|
145
|
+
break;
|
|
149
146
|
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (!found) {
|
|
150
|
+
clean = false;
|
|
151
|
+
block.dispose();
|
|
152
|
+
}
|
|
153
|
+
} else {
|
|
154
|
+
startCount--;
|
|
155
|
+
if (isSafari && startCount < 0) {
|
|
156
|
+
block.dispose();
|
|
157
|
+
}
|
|
150
158
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
159
|
+
}
|
|
160
|
+
if (startCount > 0) {
|
|
161
|
+
this.reset();
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
return clean;
|
|
156
165
|
};
|
|
157
166
|
|
|
158
|
-
ocargo.BlocklyControl.prototype.setCodeChangesAllowed = function(
|
|
159
|
-
|
|
167
|
+
ocargo.BlocklyControl.prototype.setCodeChangesAllowed = function (
|
|
168
|
+
changesAllowed
|
|
169
|
+
) {
|
|
170
|
+
this.blocklyDiv.style.pointerEvents = changesAllowed ? "" : "none";
|
|
160
171
|
};
|
|
161
172
|
|
|
162
|
-
ocargo.BlocklyControl.prototype.loadPreviousAttempt = function() {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
173
|
+
ocargo.BlocklyControl.prototype.loadPreviousAttempt = function () {
|
|
174
|
+
function decodeHTML(text) {
|
|
175
|
+
var e = document.createElement("div");
|
|
176
|
+
e.innerHTML = text;
|
|
177
|
+
return e.childNodes.length === 0 ? "" : e.childNodes[0].nodeValue;
|
|
178
|
+
}
|
|
179
|
+
// Use the user's last attempt if available
|
|
180
|
+
if (WORKSPACE) {
|
|
181
|
+
this.deserialize(decodeHTML(WORKSPACE));
|
|
182
|
+
}
|
|
172
183
|
|
|
173
|
-
|
|
184
|
+
this.redrawBlockly();
|
|
174
185
|
};
|
|
175
186
|
|
|
176
|
-
ocargo.BlocklyControl.prototype.createBlock = function(blockType) {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
187
|
+
ocargo.BlocklyControl.prototype.createBlock = function (blockType) {
|
|
188
|
+
var block = Blockly.mainWorkspace.newBlock(blockType);
|
|
189
|
+
// var block = Blockly.Block.obtain(Blockly.mainWorkspace, blockType);
|
|
190
|
+
block.initSvg();
|
|
191
|
+
block.render();
|
|
192
|
+
return block;
|
|
182
193
|
};
|
|
183
194
|
|
|
184
|
-
ocargo.BlocklyControl.prototype.addBlockToEndOfProgram = function(blockType) {
|
|
185
|
-
|
|
195
|
+
ocargo.BlocklyControl.prototype.addBlockToEndOfProgram = function (blockType) {
|
|
196
|
+
var blockToAdd = this.createBlock(blockType);
|
|
186
197
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
198
|
+
var block = this.startBlock();
|
|
199
|
+
while (block.nextConnection.targetBlock()) {
|
|
200
|
+
block = block.nextConnection.targetBlock();
|
|
201
|
+
}
|
|
191
202
|
|
|
192
|
-
|
|
203
|
+
block.nextConnection.connect(blockToAdd.previousConnection);
|
|
193
204
|
};
|
|
194
205
|
|
|
195
|
-
ocargo.BlocklyControl.prototype.disconnectedStartBlock = function() {
|
|
206
|
+
ocargo.BlocklyControl.prototype.disconnectedStartBlock = function () {
|
|
196
207
|
var emptyStart = this.startBlock().getChildren().length == 0;
|
|
197
208
|
if (emptyStart) {
|
|
198
209
|
if (this.totalBlocksCount() > 1) {
|
|
@@ -205,110 +216,121 @@ ocargo.BlocklyControl.prototype.disconnectedStartBlock = function() {
|
|
|
205
216
|
}
|
|
206
217
|
};
|
|
207
218
|
|
|
208
|
-
ocargo.BlocklyControl.prototype.startBlock = function() {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
219
|
+
ocargo.BlocklyControl.prototype.startBlock = function () {
|
|
220
|
+
return Blockly.mainWorkspace.getTopBlocks().filter(function (block) {
|
|
221
|
+
return block.type === "start";
|
|
222
|
+
})[0];
|
|
212
223
|
};
|
|
213
224
|
|
|
214
|
-
ocargo.BlocklyControl.prototype.procedureBlocks = function() {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
225
|
+
ocargo.BlocklyControl.prototype.procedureBlocks = function () {
|
|
226
|
+
return Blockly.mainWorkspace.getTopBlocks().filter(function (block) {
|
|
227
|
+
return block.type === "declare_proc";
|
|
228
|
+
});
|
|
218
229
|
};
|
|
219
230
|
|
|
220
|
-
ocargo.BlocklyControl.prototype.onEventDoBlocks = function() {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
231
|
+
ocargo.BlocklyControl.prototype.onEventDoBlocks = function () {
|
|
232
|
+
// find and return all top blocks that are event handler blocks
|
|
233
|
+
var startBlocks = [];
|
|
234
|
+
Blockly.mainWorkspace.getTopBlocks().forEach(function (block) {
|
|
235
|
+
if (block.type === "declare_event") {
|
|
236
|
+
startBlocks.push(block);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
return startBlocks;
|
|
229
240
|
};
|
|
230
241
|
|
|
231
|
-
ocargo.BlocklyControl.prototype.totalBlocksCount = function() {
|
|
232
|
-
|
|
242
|
+
ocargo.BlocklyControl.prototype.totalBlocksCount = function () {
|
|
243
|
+
return Blockly.mainWorkspace.getAllBlocks().length;
|
|
233
244
|
};
|
|
234
245
|
|
|
235
|
-
ocargo.BlocklyControl.prototype.activeBlocksCount = function() {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
n += count(startBlock.nextConnection.targetBlock());
|
|
246
|
+
ocargo.BlocklyControl.prototype.activeBlocksCount = function () {
|
|
247
|
+
var startBlock = this.startBlock();
|
|
248
|
+
var procedureBlocks = this.procedureBlocks();
|
|
249
|
+
var eventBlocks = this.onEventDoBlocks();
|
|
250
|
+
var n = 0;
|
|
251
|
+
var i;
|
|
243
252
|
|
|
244
|
-
|
|
245
|
-
for (i = 0; i < procedureBlocks.length; i++) {
|
|
246
|
-
n += 1 + count(procedureBlocks[i].inputList[1].connection.targetBlock());
|
|
247
|
-
}
|
|
253
|
+
n += count(startBlock.nextConnection.targetBlock());
|
|
248
254
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
255
|
+
// 1 includes the procedure declaration block
|
|
256
|
+
for (i = 0; i < procedureBlocks.length; i++) {
|
|
257
|
+
n += 1 + count(procedureBlocks[i].inputList[1].connection.targetBlock());
|
|
258
|
+
}
|
|
253
259
|
|
|
254
|
-
|
|
260
|
+
// 1 includes the on-event-do block
|
|
261
|
+
for (i = 0; i < eventBlocks.length; i++) {
|
|
262
|
+
n += 1 + count(eventBlocks[i].inputList[1].connection.targetBlock());
|
|
263
|
+
}
|
|
255
264
|
|
|
265
|
+
return n;
|
|
256
266
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
267
|
+
function count(block) {
|
|
268
|
+
if (!block) {
|
|
269
|
+
return 0;
|
|
270
|
+
}
|
|
261
271
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
if (elseCount === 1) {
|
|
292
|
-
var elseBlock = block.inputList[block.inputList.length - 1]
|
|
293
|
-
.connection.targetBlock();
|
|
294
|
-
n += count(elseBlock);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
var nextBlock = block.nextConnection.targetBlock();
|
|
298
|
-
n += count(nextBlock);
|
|
299
|
-
} else if (block.type === 'call_proc' || block.type === 'move_forwards' ||
|
|
300
|
-
block.type === 'turn_left' || block.type === 'turn_right' ||
|
|
301
|
-
block.type === 'turn_around' || block.type === 'wait' ||
|
|
302
|
-
block.type === 'deliver') {
|
|
303
|
-
var nextBlock = block.nextConnection.targetBlock();
|
|
304
|
-
n += count(nextBlock);
|
|
305
|
-
} else if (block.type === 'logic_negate') {
|
|
306
|
-
var conditionBlock = block.inputList[0].connection.targetBlock();
|
|
307
|
-
n += count(conditionBlock);
|
|
272
|
+
var n = 1;
|
|
273
|
+
|
|
274
|
+
if (
|
|
275
|
+
block.type === "controls_repeat_until" ||
|
|
276
|
+
block.type === "controls_repeat_while" ||
|
|
277
|
+
block.type === "controls_whileUntil"
|
|
278
|
+
) {
|
|
279
|
+
var conditionBlock = block.inputList[0].connection.targetBlock();
|
|
280
|
+
n += count(conditionBlock);
|
|
281
|
+
var bodyBlock = block.inputList[1].connection.targetBlock();
|
|
282
|
+
n += count(bodyBlock);
|
|
283
|
+
var nextBlock = block.nextConnection.targetBlock();
|
|
284
|
+
n += count(nextBlock);
|
|
285
|
+
} else if (block.type === "controls_repeat") {
|
|
286
|
+
var bodyBlock = block.inputList[1].connection.targetBlock();
|
|
287
|
+
n += count(bodyBlock);
|
|
288
|
+
var nextBlock = block.nextConnection.targetBlock();
|
|
289
|
+
n += count(nextBlock);
|
|
290
|
+
} else if (block.type === "controls_if") {
|
|
291
|
+
var elseCount = block.elseCount_ || 0;
|
|
292
|
+
|
|
293
|
+
for (var i = 0; i < block.inputList.length - elseCount; i++) {
|
|
294
|
+
var input = block.inputList[i];
|
|
295
|
+
if (input.name.indexOf("IF") === 0) {
|
|
296
|
+
var conditionBlock = input.connection.targetBlock();
|
|
297
|
+
n += count(conditionBlock);
|
|
298
|
+
} else if (input.name.indexOf("DO") === 0) {
|
|
299
|
+
var bodyBlock = input.connection.targetBlock();
|
|
300
|
+
n += count(bodyBlock);
|
|
308
301
|
}
|
|
309
|
-
|
|
310
|
-
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (elseCount === 1) {
|
|
305
|
+
var elseBlock =
|
|
306
|
+
block.inputList[block.inputList.length - 1].connection.targetBlock();
|
|
307
|
+
n += count(elseBlock);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
var nextBlock = block.nextConnection.targetBlock();
|
|
311
|
+
n += count(nextBlock);
|
|
312
|
+
} else if (
|
|
313
|
+
block.type === "call_proc" ||
|
|
314
|
+
block.type === "move_forwards" ||
|
|
315
|
+
block.type === "turn_left" ||
|
|
316
|
+
block.type === "turn_right" ||
|
|
317
|
+
block.type === "turn_around" ||
|
|
318
|
+
block.type === "wait" ||
|
|
319
|
+
block.type === "deliver" ||
|
|
320
|
+
block.type === "variables_numeric_set" ||
|
|
321
|
+
block.type === "variables_increment"
|
|
322
|
+
) {
|
|
323
|
+
var nextBlock = block.nextConnection.targetBlock();
|
|
324
|
+
n += count(nextBlock);
|
|
325
|
+
} else if (block.type === "logic_negate" || block.type === "logic_compare") {
|
|
326
|
+
var conditionBlock = block.inputList[0].connection.targetBlock();
|
|
327
|
+
n += count(conditionBlock);
|
|
328
|
+
} else if (block.type === "variables_get" || block.type === "math_number") {
|
|
329
|
+
n++
|
|
311
330
|
}
|
|
331
|
+
|
|
332
|
+
return n;
|
|
333
|
+
}
|
|
312
334
|
};
|
|
313
335
|
|
|
314
336
|
/************************/
|
|
@@ -316,90 +338,101 @@ ocargo.BlocklyControl.prototype.activeBlocksCount = function() {
|
|
|
316
338
|
/************************/
|
|
317
339
|
|
|
318
340
|
// Define custom select methods that select a block and its inputs
|
|
319
|
-
ocargo.BlocklyControl.prototype.setBlockSelected = function(block, selected) {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
341
|
+
ocargo.BlocklyControl.prototype.setBlockSelected = function (block, selected) {
|
|
342
|
+
if (!block instanceof Blockly.BlockSvg) {
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
323
345
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
346
|
+
block.inputList.forEach(
|
|
347
|
+
function (input) {
|
|
348
|
+
if (input.connection && input.type !== Blockly.NEXT_STATEMENT) {
|
|
349
|
+
var targetBlock = input.connection.targetBlock();
|
|
350
|
+
if (targetBlock) {
|
|
351
|
+
this.setBlockSelected(targetBlock, selected);
|
|
330
352
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
block.addSelect();
|
|
335
|
-
} else {
|
|
336
|
-
block.removeSelect();
|
|
337
|
-
}
|
|
338
|
-
};
|
|
353
|
+
}
|
|
354
|
+
}.bind(this)
|
|
355
|
+
);
|
|
339
356
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
}.bind(this));
|
|
357
|
+
if (selected) {
|
|
358
|
+
block.addSelect();
|
|
359
|
+
} else {
|
|
360
|
+
block.removeSelect();
|
|
361
|
+
}
|
|
346
362
|
};
|
|
347
363
|
|
|
348
|
-
ocargo.BlocklyControl.prototype.
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
for (var i = 0; i < repeats; i++) {
|
|
357
|
-
window.setTimeout(function () {
|
|
358
|
-
if (this.incorrectBlock) {
|
|
359
|
-
this.setBlockSelected(incorrectBlock, true);
|
|
360
|
-
}
|
|
361
|
-
}.bind(this), 2 * i * frequency);
|
|
362
|
-
window.setTimeout(function () {
|
|
363
|
-
if (this.incorrectBlock) {
|
|
364
|
-
this.setBlockSelected(incorrectBlock, false);
|
|
365
|
-
}
|
|
366
|
-
}.bind(this), (2 * i + 1) * frequency);
|
|
367
|
-
}
|
|
364
|
+
ocargo.BlocklyControl.prototype.clearAllSelections = function () {
|
|
365
|
+
Blockly.mainWorkspace.getAllBlocks().forEach(
|
|
366
|
+
function (block) {
|
|
367
|
+
if (!block.keepHighlighting) {
|
|
368
|
+
this.setBlockSelected(block, false);
|
|
369
|
+
}
|
|
370
|
+
}.bind(this)
|
|
371
|
+
);
|
|
368
372
|
};
|
|
369
373
|
|
|
370
|
-
ocargo.BlocklyControl.
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
374
|
+
ocargo.BlocklyControl.prototype.highlightIncorrectBlock = function (
|
|
375
|
+
incorrectBlock
|
|
376
|
+
) {
|
|
377
|
+
var frequency = 300;
|
|
378
|
+
var repeats = 3;
|
|
379
|
+
|
|
380
|
+
this.incorrectBlock = incorrectBlock;
|
|
381
|
+
this.incorrectBlockColour = incorrectBlock.getColour();
|
|
382
|
+
|
|
383
|
+
this.incorrectBlock.setColour(0);
|
|
384
|
+
for (var i = 0; i < repeats; i++) {
|
|
385
|
+
window.setTimeout(
|
|
386
|
+
function () {
|
|
387
|
+
if (this.incorrectBlock) {
|
|
388
|
+
this.setBlockSelected(incorrectBlock, true);
|
|
376
389
|
}
|
|
377
|
-
|
|
390
|
+
}.bind(this),
|
|
391
|
+
2 * i * frequency
|
|
392
|
+
);
|
|
393
|
+
window.setTimeout(
|
|
394
|
+
function () {
|
|
395
|
+
if (this.incorrectBlock) {
|
|
396
|
+
this.setBlockSelected(incorrectBlock, false);
|
|
397
|
+
}
|
|
398
|
+
}.bind(this),
|
|
399
|
+
(2 * i + 1) * frequency
|
|
400
|
+
);
|
|
401
|
+
}
|
|
378
402
|
};
|
|
379
403
|
|
|
380
|
-
ocargo.BlocklyControl.
|
|
381
|
-
|
|
382
|
-
|
|
404
|
+
ocargo.BlocklyControl.tryCatchSilently = function (f) {
|
|
405
|
+
return function () {
|
|
406
|
+
try {
|
|
407
|
+
f();
|
|
408
|
+
} catch (e) {
|
|
409
|
+
// Nothing
|
|
383
410
|
}
|
|
411
|
+
};
|
|
384
412
|
};
|
|
385
413
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
this.
|
|
389
|
-
|
|
414
|
+
ocargo.BlocklyControl.prototype.resetIncorrectBlock = function () {
|
|
415
|
+
if (this.incorrectBlock) {
|
|
416
|
+
this.incorrectBlock.setColour(this.incorrectBlockColour);
|
|
417
|
+
}
|
|
390
418
|
};
|
|
391
419
|
|
|
392
|
-
ocargo.BlockHandler
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
this.setBlockSelected(block, true);
|
|
396
|
-
this.selectedBlock = block;
|
|
397
|
-
}
|
|
420
|
+
ocargo.BlockHandler = function (id) {
|
|
421
|
+
this.id = id;
|
|
422
|
+
this.selectedBlock = null;
|
|
398
423
|
};
|
|
399
424
|
|
|
400
|
-
ocargo.BlockHandler.prototype.
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
425
|
+
ocargo.BlockHandler.prototype.selectBlock = function (block) {
|
|
426
|
+
if (block) {
|
|
427
|
+
this.deselectCurrent();
|
|
428
|
+
this.setBlockSelected(block, true);
|
|
429
|
+
this.selectedBlock = block;
|
|
430
|
+
}
|
|
405
431
|
};
|
|
432
|
+
|
|
433
|
+
ocargo.BlockHandler.prototype.deselectCurrent = function () {
|
|
434
|
+
if (this.selectedBlock) {
|
|
435
|
+
this.setBlockSelected(this.selectedBlock, false);
|
|
436
|
+
this.selectedBlock = null;
|
|
437
|
+
}
|
|
438
|
+
};
|