On second look, that code is restricted to running only within the one button.
I at first thought that it was getting all of the SVG elements from all over the page, which would have been bad.
Go ahead and use it, and take out the hideInitialOverlay() function. We have no easy to access documentation to explain why that was there in the first place, so remove it, and it can be added back in later on if required.
Do you remember why initialOverlayClickHandler was required?
Could you even find the appropriate posts where we dealt with the issue?
There are some bug-tracking techniques that can help to provide such answers, and systems of development that make it easier to find answers to such things.
Version control and bug reports are something that we havenât been doing. Without that, well just have to accept more work if we come across a situation where that solution is once again needed.
You would have resolved that by not redefining button. Decide if the function needs to have button passed to it. If it does then get rid of the var statement. If it doesnât, then remove button from the function parameters and keep the var statement.
Thatâs right. The problem there is that the button exists from the function parameter, and you are attempting to also create a new variable with the same button name.
function showPause(button) {
var player = button.querySelector("audio");
player.isPlaying = function () {
return player.paused === false;
};
if (player.isPlaying()) {
showPauseButton(button);
}
}
function showSpeaker(button) {
var player = button.querySelector("audio");
player.isPlaying = function () {
return player.paused === false;
};
if (player.isPlaying()) {
showSpeakerButton(button);
}
}