File Organization
The KWordle application consists of these key files:Core Components
Game State Management
The entire game state is managed through a singlegameState object defined in main.js:2-13:
Letter States
The game uses a state system for tracking letter correctness (main.js:17-24):
- Style grid cells and keyboard keys
- Track which letters have been guessed
- Show visual indicators (■, □, ×) for correct, present, and absent letters
Main Functions
Game Initialization
initGame() (main.js:37) - Initializes or resets the game:
- Resets game state
- Creates a 6×5 letter grid
- Initializes keyboard tracking
- Selects a random target word
- Updates the UI
Input Handling
handleKeyInput(key) (main.js:123) - Central input handler:
- Processes keyboard and on-screen keyboard input
- Handles letter entry, backspace, and enter
- Validates and submits guesses
Guess Validation
checkGuess(guess) (main.js:243) - Two-pass algorithm:
- First pass: Mark all correct position letters (green/dark gray)
- Second pass: Mark present letters in wrong positions (light gray)
Statistics Tracking
loadStatistics() (main.js:447) and saveStatistics() (main.js:463) manage game statistics in localStorage:
UI Components
Letter Grid
The grid is dynamically generated inupdateGrid() (main.js:301) with:
- 6 rows of 5 cells each
- Visual indicators for letter states
- Optimized contrast for e-ink displays
Virtual Keyboard
The keyboard is generated inupdateKeyboard() (main.js:355) with:
- QWERTY layout across 3 rows
- Special keys: ✓ (Enter) and ← (Backspace)
- Language-specific letters (e.g., Å, Ä, Ö for Swedish)
- State indicators on each key
Indicator Key
A legend atmain.js:94 explains the symbols:
- ■ = Correct spot
- □ = Wrong spot
- × = Not in word
Language Support
Supported languages are defined inlanguageList (main.js:15):
js/words.js as two arrays per language:
wordList- Words that can be selected as answersaccepted- All valid 5-letter words that can be guessed
Installation & Deployment
The application is deployed usingkwordle.sh, which:
- Copies files from
/mnt/us/documents/kwordleto/var/local/mesquite/kwordle - Registers the app in Kindle’s
appreg.dbSQLite database - Launches the app via LIPC (Lab126 IPC)
Integration with Kindle
Chromebar Configuration
The application configures Kindle’s Chromebar inindex.html:14-52 with:
- App title and ID
- System menu with reload option
- Close and more buttons
Widget Configuration
Theconfig.xml file defines:
- App ID:
xyz.kurizu.kwordle - Permissions for local storage and messaging
- Network settings and cookie jar configuration
- Gesture support (tap and swipe)
- LocalStorage quota: 25MB
Event Flow
- Page Load:
onPageLoad()(main.js:565) sets up keyboard listeners and initializes the game - User Input: Physical or virtual keyboard triggers
handleKeyInput() - Letter Entry: Letters are added to current row until filled
- Guess Submission: Enter key validates word and checks against target
- State Update: Grid and keyboard states are updated with results
- Game End: Statistics are saved when game is won or lost
- New Game: Reset button calls
initGame()to start fresh