Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Minor Overhaul and Refactor
This pull request adds quite a bit complexity to the code base but enables greater flexibility for adding additional game modes. As is, the boilerplate addresses some open and closed issues, and implements a robust state management system. In some regards, how game modes are built has become simpler and follows a straightforward pattern of usage that's reminiscent to the original branch, while adding many UI/UX enhancements.
That being said, some features have been dropped, making this a breaking revision. I do not intend to keep it that way and would like to reimplement those features with some help. Hopefully the lack of comments and increased complexity doesn't scare contributors away. I apologize in advance for that, which is why this description is so long winded. I will greatly appreciate any feedback, suggestions, and overall insight anyone can give.
Breaking Changes (Dropped Features)
I fully intend to bring back text-based results that can be copied to the clipboard. I'd like to do so in a way that's simply structured, intuitive, easily digestible, and accessible. The goal is to address the known issue of the emoji results.
Possible Solutions
I looked into ways to convert HTML into images that could be copied to clipboard or downloaded. For now, I only have two ideas that would keep this repo dependency free.
New Class Features
Warning
Due to browser CORS policies, module imports must be server via a development server. I recommend using an IDE that can serve pages on localhost.
Note
All the duplicated feature code was consolidated into 3 classes:
WordGen
,Prompts
, andKeyboard
.WordGen
Behavior
The word list generator's behavior remains relatively unchanged. Most changes removed duplication by adding options to the main feature methods.
Constructor
Important
The
WordGen
class now accepts an optionalSeed
parameter passed through the constructor. The currentDate.toLocalString()
is used by default.WordGen( )
WordGen( Seed: string )
Properties
string
WordGen( ).seed
string
WordGen( ).seed
Date
WordGen( ).date
Date.toLocalString()
of todaynumber
WordGen.EPOC
Methods
Tip
difficulty
parameter can be of type'easy'
,'medium'
, or'hard'
. Default is'medium'
Caution
amount
parameter can be any number. Default is 5Please be aware of out-of-range amounts. I'll address this in a future update.
string[]
chooseWords( )
'medium'
words with a length of 5string[]
chooseWords(difficulty: string)
string[]
chooseWords(difficulty: string, amount: number)
string[]
shuffle( )
'medium'
difficulty settingstring[]
shuffle(difficulty: string)
Keyboard
Behavior
Letter inputs and backspace are captured on
mousedown
andkeydown
events, while submit or enter, is captured onmouseup
andkeyup
events. All events captured callpreventDefault()
to block expected browser behaviors. Input events from the keyboard are matched by ReGex, as before, to block any non-character inputs, with the exception of backspace and enter. Letter inputs insert the character to an output string, raising achange
event. Backspace removes the last character of the output string, also raising achange
event. Submit or enter raises ansubmit
event. (More information on events below).Constructor
Important
The
Keyboard
class accepts an emptyDOM Element
which it will populate.Keyboard ( keyboard: HTMLDivElement )
Events
Note
Deleting all characters will return an empty string.
'change'
on('change', callback(event))
output: string
'submit'
on('submit', callback(event))
output: string
Methods
Note
All onscreen keys exhibit a combination of states defined by the default CSS behavior or defined classes, DOM attributes, and styles pragmatically toggled. Different states are used to remedy user pain points and mitigate potential user error.
void
enableInput( )
void
clear( )
Prompts
Behavior
The new behavior of the Prompts class is fairly complex, but it uses the previous implementation's ideas as a base line. Most of the changes made ensure proper state management, enhanced UI/UX, and a better-defined data model for evaluation results.
I'll refrain from explaining all nuanced behaviors, but I will list some technical and functional highlights.
Constructor
Important
The
Prompts
class accepts an emptyDOM Element
which it will populate.Prompts( Prompts: HTMLDivElement )
Events
'load'
onLoad( callback(event))
difficulty: string
'ready'
onReady(callback())
void
'select'
on('select', callback(event))
selectedPlayer: PromptButton, selectedWord: string
'play'
on('play', callback(event))
activePlayer: PromptButton, activeWord: string
'stopped'
on('stopped', callback(event))
stoppedPlayer: PromptButton, activeWord: string
'ended'
on('ended', callback(event))
ctivePlayer: PromptButton, activeWord: string
'evaluate'
on('evaluate', callback(event))
result : prompt result
'complete'
on('complete', callback(event))
results: prompts results
Methods
void
addWords(level:string, ...words: string[] )
level
should be hanged todifficulty
for consistency and clarityvoid
evaluatePrompt( submission: string )
void
clear( )
Other Changes
Changes to results page look
Changes to results data model
Project structure modifications
Folder Changes
/levelOneNew
,/levelTwoNew
, and/levelThreeNew
to/easy
,/medium
, and/hard
, respectively./core
folder in/assets/scripts
/dictionary
folder in/assets/scripts/core
File Structure Changes
/scripts
/core
/dictionary
easy.js
- Exports const array of all easy wordsmedium.js
- Exports const array of all medium wordshard.js
- Exports const array of all hard wordskeyboard.js
- ExportsKeyboard
classprompts.js
- ExportsPrompts
classutils.js
- Exportscyrb128
andsfc32
const functionsword-gen.js
- ExportsWordGen
classword-list.js
- Re-exports word const arraysdaily_challange.js
practice.js
results.js
spelloff.js
youtube.js