Skip to content

Commit

Permalink
adding code to initialize view program page and setting up editor
Browse files Browse the repository at this point in the history
  • Loading branch information
jpelay committed Nov 23, 2023
1 parent ee142e8 commit e2d8246
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 52 deletions.
3 changes: 2 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1523,7 +1523,8 @@ def view_program(user, id):
javascript_page_options=dict(
page='view-program',
lang=g.lang,
level=int(result['level'])),
level=int(result['level']),
code=code),
**arguments_dict)


Expand Down
9 changes: 7 additions & 2 deletions static/js/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ export interface InitializeViewProgramPageOptions {
readonly page: 'view-program';
readonly level: number;
readonly lang: string;
readonly code: string;
}

export function initializeViewProgramPage(options: InitializeViewProgramPageOptions) {
Expand All @@ -344,13 +345,17 @@ export function initializeViewProgramPage(options: InitializeViewProgramPageOpti
// We need to enable the main editor for the program page as well
const dir = $("body").attr("dir");
theGlobalEditor = editorCreator.initializeEditorWithGutter($('#editor'), EditorType.MAIN, dir);
initializeTranslation({
keywordLanguage: options.lang,
level: options.level});
attachMainEditorEvents(theGlobalEditor);
theGlobalEditor.contents = options.code;
error.setEditor(theGlobalEditor);
initializeDebugger({
editor: theGlobalEditor,
level: theLevel,
level: options.level,
language: theLanguage,
keywordLanguage: theKeywordLanguage,
keywordLanguage: options.lang,
});
}

Expand Down
88 changes: 43 additions & 45 deletions static/js/appbundle.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions static/js/appbundle.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion templates/incl/editor-and-output.html
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
<button id="debug_button" class="green-btn" onclick='hedyApp.runit({{ level }}, "{{ g.lang }}", {{_('already_program_running')|default(None)|tojson}}, "debug")'>🐞</button>
<button id="debug_restart" class="green-btn hidden" onclick='hedyApp.runit({{ level }}, "{{ g.lang }}", {{_('already_program_running')|default(None)|tojson}}, "debug")'>🔄</button>
<button id="debug_stop" class="green-btn hidden" onclick="hedyApp.stopDebug()">🛑</button>
<button id="debug_continue" class="green-btn" onclick='hedyApp.runit({{ level }}, "{{ g.lang }}", {{_('already_program_running')|default(None)|tojson}}, "continue")'><div class="{% if g.dir == "rtl" %}rotate-180{% endif %}"></div></button>
<button id="debug_continue" class="green-btn hidden" onclick='hedyApp.runit({{ level }}, "{{ g.lang }}", {{_('already_program_running')|default(None)|tojson}}, "continue")'><div class="{% if g.dir == "rtl" %}rotate-180{% endif %}"></div></button>
</div>
<button id="next_parson_button" max_exercise="{{ parsons_exercises }}" class="green-btn ltr:ml-auto rtl:mr-auto" style="display: none;">{{_('next_exercise')}}</button>
{% if show_edit_button %}
Expand Down

0 comments on commit e2d8246

Please sign in to comment.