Skip to content

Commit

Permalink
shortcut key
Browse files Browse the repository at this point in the history
  • Loading branch information
juzerali committed Aug 1, 2020
1 parent e59ea46 commit 92777a8
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions index.js
Expand Up @@ -150,6 +150,7 @@ function createNewGame() {
}

function showCreateWidget() {
$(document).off("keyup");
window.location.hash = "";
document.getElementById("create-new-game-widget").className = "";
document.getElementById("game-window").className = "hidden";
Expand All @@ -159,14 +160,19 @@ function showCreateWidget() {
function showGameWindow() {
document.getElementById("create-new-game-widget").className = "hidden"
document.getElementById("game-window").className = ""
$(document).on("keyup", (e) => {
if(e.key == "D" || e.key == "d" || e.key == " ") {
window.draw();
}
});
}

function randomId() {
return (Math.random() * Math.pow(10,16)).toString(36);
}

window.speaker = function (number) {
if(!window.SpeechSynthesisUtterance) return new NoopSpeaker();
if(!window.SpeechSynthesisUtterance || window.APP.isMuted()) return new NoopSpeaker();
return new ChromeSpeaker();
}

Expand Down Expand Up @@ -201,4 +207,23 @@ class ChromeSpeaker {

class NoopSpeaker {
speak(number) {}
}
}

class App {
constructor() {
this.muted = false;
}

mute() {
this.muted = true
}
unmute() {
this.muted = false
}

isMuted() {
return this.muted;
}
}

window.APP = new App;

0 comments on commit 92777a8

Please sign in to comment.