Skip to content

Commit

Permalink
Fix language selection on page refresh on the test page.
Browse files Browse the repository at this point in the history
  • Loading branch information
drgrice1 committed Oct 8, 2024
1 parent 5a120cd commit 3dc8d37
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions public/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ const codeMirrorElt = document.querySelector('.pg-codemirror-editor');

if (codeMirrorElt instanceof HTMLElement) {
const sourceInput = document.getElementsByName('editor-source')[0];
const pgEditor = new PGCodeMirrorEditor.View(codeMirrorElt, { source: sourceInput.value });
const languageSelector = document.getElementById('select-language');
const pgEditor = new PGCodeMirrorEditor.View(codeMirrorElt, {
source: sourceInput.value,
language: languageSelector?.value ?? 'pg'
});

document.getElementById('load-file')?.addEventListener('click', () => {
const file = document.getElementsByName('problem-file')[0]?.files?.[0];
Expand All @@ -18,7 +22,6 @@ if (codeMirrorElt instanceof HTMLElement) {
}
});

const languageSelector = document.getElementById('select-language');
languageSelector?.addEventListener('change', () => {
pgEditor.setLanguage(languageSelector.value);
});
Expand Down

0 comments on commit 3dc8d37

Please sign in to comment.