Loading static/js/jslinux.api.mjs +23 −5 Original line number Diff line number Diff line Loading @@ -178,14 +178,12 @@ export function onEnterPressed(handler) { } /** * Types the given command into the terminal and simulates an Enter press * The command will then be executed, and the output will be shown in the terminal * @param {string} command A command to execute * Simulates a press of the enter button */ export async function runCommand(command) { async function pressEnter() { const textarea = document.querySelector(".term_textarea") // We append \n to simulate the Enter press textarea.value = command + "\n" textarea.value += "\n" // Now we just have to trigger an input event to activate the JSLinux event handler, see // https://thewebdev.info/2021/05/02/how-to-programmatically-trigger-a-change-event-on-an-input-with-javascript/ Loading @@ -195,6 +193,26 @@ export async function runCommand(command) { await prompt() } /** * Types the given command into the terminal and simulates an Enter press * The command will then be executed, and the output will be shown in the terminal * @param {string} command A command to execute */ export async function runCommand(command) { document.querySelector(".term_textarea").value = command await pressEnter() } /** * Checks if the user has entered a command but not yet executed it. If that is the case, * press enter, and wait for it to complete. */ export async function runUnexecutedCommand() { if(getCurrentPrompt() === null) { await pressEnter() } } /** * Enables auto-focus to the terminal whenever a key is pressed. * This allows the user to click on an exercise completion button and then seamlessly continue Loading Loading
static/js/jslinux.api.mjs +23 −5 Original line number Diff line number Diff line Loading @@ -178,14 +178,12 @@ export function onEnterPressed(handler) { } /** * Types the given command into the terminal and simulates an Enter press * The command will then be executed, and the output will be shown in the terminal * @param {string} command A command to execute * Simulates a press of the enter button */ export async function runCommand(command) { async function pressEnter() { const textarea = document.querySelector(".term_textarea") // We append \n to simulate the Enter press textarea.value = command + "\n" textarea.value += "\n" // Now we just have to trigger an input event to activate the JSLinux event handler, see // https://thewebdev.info/2021/05/02/how-to-programmatically-trigger-a-change-event-on-an-input-with-javascript/ Loading @@ -195,6 +193,26 @@ export async function runCommand(command) { await prompt() } /** * Types the given command into the terminal and simulates an Enter press * The command will then be executed, and the output will be shown in the terminal * @param {string} command A command to execute */ export async function runCommand(command) { document.querySelector(".term_textarea").value = command await pressEnter() } /** * Checks if the user has entered a command but not yet executed it. If that is the case, * press enter, and wait for it to complete. */ export async function runUnexecutedCommand() { if(getCurrentPrompt() === null) { await pressEnter() } } /** * Enables auto-focus to the terminal whenever a key is pressed. * This allows the user to click on an exercise completion button and then seamlessly continue Loading