chore: add JS/ESLint toolchain, refactor onclick to event delegation
- Add ESLint config for web/ui (flat config, golangci-lint-compatible) - Add js-lint task to mise.toml (npm run lint in web/ui) - Add ESLint check to check-toolchain.sh - Add .golangci.yml for golangci-lint v2 with correct exclusions - Refactor app.js: replace inline onclick with data-action + event delegation - Add null checks and HTTP status checks to browseWavs - Add web/ui/node_modules/ to .gitignore
This commit is contained in:
+17
-3
@@ -46,8 +46,8 @@ function renderResults(items) {
|
||||
<span>${r.downloads.toLocaleString()} downloads</span>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button class="btn-dl" onclick="downloadItem('${esc(r.identifier)}')">Download ISOs</button>
|
||||
<button class="btn-list" onclick="listItem('${esc(r.identifier)}')">List Files</button>
|
||||
<button class="btn-dl" data-action="download" data-identifier="${esc(r.identifier)}">Download ISOs</button>
|
||||
<button class="btn-list" data-action="list" data-identifier="${esc(r.identifier)}">List Files</button>
|
||||
</div>
|
||||
<div id="list-${sanitize(r.identifier)}" class="file-list"></div>
|
||||
</div>
|
||||
@@ -218,7 +218,7 @@ async function browseWavs() {
|
||||
list.innerHTML = data.map(f => `
|
||||
<div class="wav-item" data-file="${esc(f)}">
|
||||
<span class="wav-name" title="${esc(f)}">${esc(f)}</span>
|
||||
<button class="wav-play-btn" onclick="playWav('${esc(f)}')">Play</button>
|
||||
<button class="wav-play-btn" data-action="play" data-wav="${esc(f)}">Play</button>
|
||||
</div>
|
||||
`).join('');
|
||||
} catch (e) {
|
||||
@@ -332,3 +332,17 @@ function formatBytes(bytes) {
|
||||
|
||||
// Initial load
|
||||
doSearch();
|
||||
|
||||
// Event delegation for dynamically generated buttons
|
||||
document.addEventListener('click', function(e) {
|
||||
const btn = e.target.closest('[data-action]');
|
||||
if (!btn) return;
|
||||
const action = btn.dataset.action;
|
||||
if (action === 'download') {
|
||||
downloadItem(btn.dataset.identifier);
|
||||
} else if (action === 'list') {
|
||||
listItem(btn.dataset.identifier);
|
||||
} else if (action === 'play') {
|
||||
playWav(btn.dataset.wav);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
const globals = require('globals');
|
||||
|
||||
module.exports = [
|
||||
{
|
||||
files: ['**/*.js'],
|
||||
languageOptions: {
|
||||
ecmaVersion: 2022,
|
||||
sourceType: 'script',
|
||||
globals: {
|
||||
...globals.browser,
|
||||
AudioContext: 'readonly',
|
||||
requestAnimationFrame: 'readonly',
|
||||
cancelAnimationFrame: 'readonly',
|
||||
fetch: 'readonly',
|
||||
EventSource: 'readonly',
|
||||
document: 'readonly',
|
||||
console: 'readonly',
|
||||
setTimeout: 'readonly',
|
||||
Math: 'readonly',
|
||||
JSON: 'readonly',
|
||||
location: 'readonly',
|
||||
encodeURIComponent: 'readonly',
|
||||
decodeURIComponent: 'readonly',
|
||||
parseInt: 'readonly',
|
||||
Number: 'readonly',
|
||||
Promise: 'readonly',
|
||||
Object: 'readonly',
|
||||
Array: 'readonly',
|
||||
Map: 'readonly',
|
||||
process: 'readonly',
|
||||
__dirname: 'readonly',
|
||||
require: 'readonly',
|
||||
module: 'readonly',
|
||||
exports: 'readonly'
|
||||
}
|
||||
},
|
||||
rules: {
|
||||
"no-unused-vars": ["warn", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" }],
|
||||
"no-redeclare": "warn",
|
||||
"no-unreachable": "warn",
|
||||
"eqeqeq": ["error", "always"],
|
||||
"prefer-const": "warn"
|
||||
}
|
||||
}
|
||||
];
|
||||
Generated
+1098
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "akai-utils-web-ui",
|
||||
"version": "1.0.0",
|
||||
"description": "Web UI for AKAI Utils",
|
||||
"scripts": {
|
||||
"lint": "eslint *.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^9.0.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user