-
Notifications
You must be signed in to change notification settings - Fork 81
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
fix: Accordion state #1544
fix: Accordion state #1544
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 3 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @karatmate)
game/static/game/js/game.js
line 24 at r2 (raw file):
document.addEventListener("DOMContentLoaded", function() { var dataElement = document.getElementById('data');
var
is an old way of declaring variables in Js - instead, you can use let
and const
. Please use:
let
when the variable needs to be changed later on in the code.const
when declaring a constant which only needs to be read / queried and not changed.
Please perform this change throughout the code you've added.
game/static/game/js/game.js
line 26 at r2 (raw file):
var dataElement = document.getElementById('data'); var currentEpisode = dataElement ? dataElement.getAttribute('data-episode') : null;
You've got some extra whitespaces here - please remove them 🙂
game/static/game/js/game.js
line 36 at r2 (raw file):
var currentLevelId = LEVEL_ID; var currentEpisode = this.determineEpisodeFromLevel(currentLevelId); localStorage.setItem('currentEpisode', currentEpisode);
Here you are getting the level ID, then determining the episode based on the level ID.
LEVEL_ID comes from game.html.
You'll notice that game.html also has a var called EPISODE
- maybe you can get the ID directly from that instead of getting the LEVEL ID, and that way you might not even need the determineEpisodeFromLevel
function anymore.
Code quote:
var currentLevelId = LEVEL_ID;
var currentEpisode = this.determineEpisodeFromLevel(currentLevelId);
localStorage.setItem('currentEpisode', currentEpisode);
game/templates/game/game.html
line 92 at r2 (raw file):
}); </script>
Please double-check whether you need this, it seems you're already doing that in game.js
anyway, right?
Code quote:
<script>
document.addEventListener("DOMContentLoaded", function(){
var dataElement = document.getElementById('data');
var currentEpisode = dataElement ? dataElement.getAttribute('data-episode') : null;
if (currentEpisode) {
localStorage.setItem('currentEpisode', currentEpisode);
}
});
</script>
game/templates/game/level_selection.html
line 44 at r2 (raw file):
</script> <script>
Since level_selection.js
is imported in the line directly after this script, could you try moving this JS code to level_selection.js
and see if it still works? In general, when following this kind of software architecture, it's better to keep JS code in JS files instead of HTML files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 4 files reviewed, 5 unresolved discussions (waiting on @faucomte97)
game/static/game/js/game.js
line 24 at r2 (raw file):
Previously, faucomte97 (Florian Aucomte) wrote…
var
is an old way of declaring variables in Js - instead, you can uselet
andconst
. Please use:
let
when the variable needs to be changed later on in the code.const
when declaring a constant which only needs to be read / queried and not changed.Please perform this change throughout the code you've added.
Done.
game/static/game/js/game.js
line 26 at r2 (raw file):
Previously, faucomte97 (Florian Aucomte) wrote…
You've got some extra whitespaces here - please remove them 🙂
Done.
game/static/game/js/game.js
line 36 at r2 (raw file):
Previously, faucomte97 (Florian Aucomte) wrote…
Here you are getting the level ID, then determining the episode based on the level ID.
LEVEL_ID comes from game.html.
You'll notice that game.html also has a var calledEPISODE
- maybe you can get the ID directly from that instead of getting the LEVEL ID, and that way you might not even need thedetermineEpisodeFromLevel
function anymore.
Done.
game/templates/game/game.html
line 92 at r2 (raw file):
Previously, faucomte97 (Florian Aucomte) wrote…
Please double-check whether you need this, it seems you're already doing that in
game.js
anyway, right?
Done.
game/templates/game/level_selection.html
line 44 at r2 (raw file):
Previously, faucomte97 (Florian Aucomte) wrote…
Since
level_selection.js
is imported in the line directly after this script, could you try moving this JS code tolevel_selection.js
and see if it still works? In general, when following this kind of software architecture, it's better to keep JS code in JS files instead of HTML files.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 4 files at r3, 2 of 2 files at r4, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @karatmate)
Description
How Has This Been Tested?
Locally in my computer
Checklist:
This change is