Skip to content

Commit

Permalink
add a slgiht delay to play button to stop local loading
Browse files Browse the repository at this point in the history
  • Loading branch information
TodePond committed Jan 31, 2025
1 parent ad698c7 commit 91bb679
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ <h1>🍝 welcome to nudel</h1>
(we use them all in nudel)
</p>
<p>
<button id="about-yes-button">play</button>
<button id="about-yes-button" class="loading">play</button>
</p>
</form>
</dialog>
Expand Down
17 changes: 16 additions & 1 deletion src/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const aboutButton = document.querySelector('#about-button');
const helpButton = document.querySelector('#help-button');
const aboutDialog = document.querySelector('#about-dialog');
const playButton = document.querySelector('#about-yes-button');
console.log(playButton);

menuButton.addEventListener('click', (e) => {
menuContainer.classList.toggle('open');
Expand All @@ -20,7 +19,12 @@ helpButton?.addEventListener('click', () => {
nudelAlert('Coming soon');
});

let playButtonClicked = false;
playButton.addEventListener('click', () => {
if (playButton.classList.contains('loading')) {
playButtonClicked = true;
return;
}
const runButtons = document.querySelectorAll('.run');
runButtons.forEach((runButton) => runButton.click());
});
Expand Down Expand Up @@ -51,3 +55,14 @@ html.addEventListener('click', (e) => {
}
}
})();

// This is to stop people running their old local code
// TODO: make this actually happen after the editors have been updated with the most recent content
setTimeout(() => {
playButton.classList.remove('loading');
if (playButtonClicked) {
setTimeout(() => {
playButton.click();
}, 1000);
}
}, 1000);

0 comments on commit 91bb679

Please sign in to comment.