ba44b435e7
Inline Hyperscript Refactoring: - Body tag keyboard handlers: 20→8 lines (using helper functions) - Zoom control handlers: 85→35 lines (using zoom._hs) - PDF modal card selection: 90→6 lines (3 identical blocks eliminated) New Hyperscript Files: - zoom._hs: handleZoomInput, handleZoomReset, initZoomControl - pdf-modal._hs: selectPdfCard, handlePdfCardKey JavaScript Elimination (232 lines removed): - cv-functions.js: REMOVED - hyperscript defs are globally available - scroll-at-bottom-handler.js: REMOVED - duplicate of handleScroll() - footer-buttons-interaction.js: REMOVED - moved to hyperscript Added Tests: - 32-hyperscript-multi-src.test.mjs: Verifies multi-file loading - 33-keyboard-shortcuts-refactored.test.mjs: Keyboard shortcuts - 34-hyperscript-refactor-comprehensive.test.mjs: Full test suite Key Findings: - No hyperscript multi-file bug in 0.9.14 - Hyperscript def statements are globally accessible - Previous refactoring failures were syntax errors, not library bugs
44 lines
1.6 KiB
Plaintext
44 lines
1.6 KiB
Plaintext
-- File: keyboard._hs
|
|
-- Purpose: Keyboard shortcut handlers for CV application
|
|
-- Last Updated: 2025-11-30
|
|
|
|
-- ==============================================================================
|
|
-- TOGGLE SHORTCUT HELPER
|
|
-- ==============================================================================
|
|
-- Helper function to toggle a checkbox by ID (tries primary ID, then menu ID)
|
|
-- Called from inline keyboard handler in body tag
|
|
def handleToggleShortcut(toggleId, menuToggleId)
|
|
set toggle to document.getElementById(toggleId)
|
|
if toggle is null
|
|
set toggle to document.getElementById(menuToggleId)
|
|
end
|
|
if toggle is not null
|
|
set toggle.checked to (not toggle.checked)
|
|
send change to toggle
|
|
end
|
|
end
|
|
|
|
-- ==============================================================================
|
|
-- MODAL SHORTCUT HELPER
|
|
-- ==============================================================================
|
|
-- Helper function to open a modal dialog by ID
|
|
def openModalShortcut(modalId)
|
|
set modal to document.getElementById(modalId)
|
|
if modal is not null
|
|
call modal.showModal()
|
|
end
|
|
end
|
|
|
|
-- ==============================================================================
|
|
-- REFERENCE: Full keyboard handler logic
|
|
-- ==============================================================================
|
|
-- NOTE: The actual keydown handler MUST stay inline in body tag because
|
|
-- hyperscript event handlers need direct access to the event context.
|
|
-- The inline handler uses the helper functions above.
|
|
--
|
|
-- Keyboard shortcuts:
|
|
-- '?' - Open shortcuts modal
|
|
-- 'L' - Toggle CV length (short/long)
|
|
-- 'I' - Toggle icons visibility
|
|
-- 'V' - Toggle visual theme (default/clean)
|