Skip to content

Commit

Permalink
enter key now cycles through conversion options
Browse files Browse the repository at this point in the history
  • Loading branch information
sylviiu committed Jan 13, 2024
1 parent fffa9a1 commit 4ae66e2
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions html/afterload/conversionOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ const setupConvertDownload = (node, info, colorScheme) => {

const ffmpegCustomOptions = ffmpegOptions.querySelector(`#ffmpegCustomOptions`);

const downloadButton = ffmpegOptions.parentElement.lastElementChild.querySelector(`#confirmDownload`)

let buttons = ffmpegOptions.querySelectorAll(`.formatPreset`);

let currentSelected = null;
Expand Down Expand Up @@ -502,6 +504,22 @@ const setupConvertDownload = (node, info, colorScheme) => {
setPreset(usableOption ? ffmpegOptions.querySelector(`#${usableOption}`) || null : null, true); // set default preset

resetTrim(false)

const textboxes = ffmpegOptions.querySelectorAll(`input[type="text"]`);

textboxes.forEach((box, i) => {
box.onkeyup = (e) => {
const shift = (e.key == `Shift` || e.keyCode == 16);
const tab = (e.key == `Tab` || e.keyCode == 9);
const enter = (e.key == `Enter` || e.keyCode == 13);

if((shift && enter) || (enter && i == textboxes.length - 1)) {
downloadButton.click();
} else if(enter && i < textboxes.length - 1) {
textboxes[i+1].focus();
};
}
});

node.querySelector(`#conversionDiv`).appendChild(node.querySelector(`#outputExtension`) || listboxTemplate.querySelector(`#outputExtension`).cloneNode(true));
}
Expand Down

0 comments on commit 4ae66e2

Please sign in to comment.