-
-
Notifications
You must be signed in to change notification settings - Fork 88
feat: display available date for packs on boostercreator #228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
010242c
feat: display available date for packs on boostercreator
nolddor 0b4e391
fix: minor typo
nolddor a96480f
fix: indentation
nolddor 001a9af
chore: add bigger margin for text
nolddor d137df0
feat: localize shown text
nolddor a6a8472
chore: change customevent name
nolddor bffc567
chore: return earlier when possible
nolddor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| 'use strict'; | ||
|
|
||
| ( ( () => | ||
| { | ||
| /** @type {HTMLSelectElement} */ | ||
| const gameSelector = document.querySelector( '#booster_game_selector' ); | ||
|
|
||
| if( !gameSelector ) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| // Add a `div` container to display the booster pack available date | ||
| const availableDateContainer = document.createElement( 'div' ); | ||
| availableDateContainer.id = 'booster_available_date'; | ||
| gameSelector.after( availableDateContainer ); | ||
|
|
||
| // Add an event listener to catch the details about the choosen booster pack | ||
| // This data is sent by `boostercreator_injected.js` when the game selector changes | ||
| gameSelector.addEventListener( 'steamdb-booster-game-change', function( event ) | ||
| { | ||
| /** @type {CustomEvent<{ available_at_time?: string }>} */ | ||
| const customEvent = /** @type {CustomEvent} */ ( event ); | ||
| displayBoosterAvailableDate( customEvent.detail?.available_at_time ); | ||
| } ); | ||
|
|
||
|
|
||
| /** | ||
| * @param {string | undefined} availableDate | ||
| */ | ||
| function displayBoosterAvailableDate( availableDate ) | ||
| { | ||
| if( availableDate ) | ||
| { | ||
| availableDateContainer.textContent = _t( 'boostercreator_available_at_date', [ availableDate ] ); | ||
| } | ||
| else | ||
| { | ||
| availableDateContainer.textContent = ''; | ||
| } | ||
| } | ||
|
|
||
| // Inject a script into the page, so we can access page Steam variables | ||
| const script = document.createElement( 'script' ); | ||
| script.id = 'steamdb_boostercreator'; | ||
| script.type = 'text/javascript'; | ||
| script.src = GetLocalResource( 'scripts/community/boostercreator_injected.js' ); | ||
| document.head.appendChild( script ); | ||
| } )() ); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| 'use strict'; | ||
|
|
||
| /** @type {HTMLSelectElement} */ | ||
| const gameSelector = document.querySelector( '#booster_game_selector' ); | ||
|
|
||
| if( gameSelector ) | ||
| { | ||
| // Add an event listener to catch when the game selector changes and emit new rgBoosterData | ||
| gameSelector.addEventListener( 'change', emitBoosterAvailableDate ); | ||
|
|
||
| // Emit rgBoosterData for current selection when the script loads | ||
| emitBoosterAvailableDate(); | ||
| } | ||
|
|
||
| function emitBoosterAvailableDate( ) | ||
| { | ||
| const selectedGame = gameSelector.value; | ||
| const rgBoosterData = window.CBoosterCreatorPage.sm_rgBoosterData[ selectedGame ]; | ||
|
|
||
| gameSelector.dispatchEvent( new CustomEvent( 'steamdb-booster-game-change', { detail: rgBoosterData } ) ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| #booster_available_date { | ||
| color: #d94126; | ||
| margin-top: 8px; | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.