|
|
@@ -44,8 +44,11 @@ document.querySelector('#content').innerHTML = `<h1>Gauntlet Settings</h1> |
|
|
*/ |
|
|
*/ |
|
|
async function addKeySetter(keybind: Keybind) |
|
|
async function addKeySetter(keybind: Keybind) |
|
|
{ |
|
|
{ |
|
|
|
|
|
// If no display name was provided, simply give it the title case version of the function name |
|
|
if (keybind.displayName === null) |
|
|
if (keybind.displayName === null) |
|
|
keybind.displayName = pretty(keybind.functionName); |
|
|
keybind.displayName = pretty(keybind.functionName); |
|
|
|
|
|
|
|
|
|
|
|
// Create the "Set" button |
|
|
const setKeyInput: HTMLInputElement = document.createElement('input'); |
|
|
const setKeyInput: HTMLInputElement = document.createElement('input'); |
|
|
setKeyInput.type = 'button'; |
|
|
setKeyInput.type = 'button'; |
|
|
setKeyInput.value = 'Set'; |
|
|
setKeyInput.value = 'Set'; |
|
|
@@ -58,10 +61,12 @@ async function addKeySetter(keybind: Keybind) |
|
|
await setStorageValue(keybind.functionName, key); |
|
|
await setStorageValue(keybind.functionName, key); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// Set up a table row so that each of the buttons and text fields line up |
|
|
const tr: HTMLTableRowElement = document.createElement('tr'); |
|
|
const tr: HTMLTableRowElement = document.createElement('tr'); |
|
|
const td1: HTMLTableDataCellElement = document.createElement('td'); |
|
|
const td1: HTMLTableDataCellElement = document.createElement('td'); |
|
|
td1.innerHTML += `<label>${keybind.displayName}</label>`; |
|
|
td1.innerHTML += `<label>${keybind.displayName}</label>`; |
|
|
const td2: HTMLTableDataCellElement = document.createElement('td'); |
|
|
const td2: HTMLTableDataCellElement = document.createElement('td'); |
|
|
|
|
|
// Give the text field the value of its currently stored key |
|
|
td2.innerHTML += |
|
|
td2.innerHTML += |
|
|
`<input type="text" id="${keybind.functionName}-key" value="${await getStorageValue(keybind.functionName) || '?'}">`; |
|
|
`<input type="text" id="${keybind.functionName}-key" value="${await getStorageValue(keybind.functionName) || '?'}">`; |
|
|
const td3: HTMLTableDataCellElement = document.createElement('td'); |
|
|
const td3: HTMLTableDataCellElement = document.createElement('td'); |
|
|
@@ -100,8 +105,19 @@ async function setSwitchers(e: MouseEvent): Promise<void> |
|
|
for (let i = 0; i < keybinds.length; i++) |
|
|
for (let i = 0; i < keybinds.length; i++) |
|
|
await addKeySetter(keybinds[i]); |
|
|
await addKeySetter(keybinds[i]); |
|
|
|
|
|
|
|
|
// Other settings |
|
|
|
|
|
|
|
|
// Set known values |
|
|
(document.querySelector('#jump-point') as HTMLInputElement).value = await getStorageValue('jp'); |
|
|
(document.querySelector('#jump-point') as HTMLInputElement).value = await getStorageValue('jp'); |
|
|
|
|
|
(document.querySelector('#prep-password') as HTMLInputElement).value = |
|
|
|
|
|
await getStorageValue('password') ?? ''; |
|
|
|
|
|
const switchers: string[] = await getStorageValue('switchers'); |
|
|
|
|
|
if (switchers) { |
|
|
|
|
|
const switchersList = document.querySelector('#switchers') as HTMLTextAreaElement; |
|
|
|
|
|
for (let i = 0; i < switchers.length; i++) { |
|
|
|
|
|
switchersList.value += `${switchers[i]}\n`; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Other settings |
|
|
document.querySelector('#set-jump-point').addEventListener('click', setJumpPoint); |
|
|
document.querySelector('#set-jump-point').addEventListener('click', setJumpPoint); |
|
|
document.querySelector('#set-prep-password').addEventListener('click', setPassword); |
|
|
document.querySelector('#set-prep-password').addEventListener('click', setPassword); |
|
|
document.querySelector('#set-switchers').addEventListener('click', setSwitchers); |
|
|
document.querySelector('#set-switchers').addEventListener('click', setSwitchers); |