refactor(es modules): dissolve general.js

This commit is contained in:
Azgaar 2022-06-30 00:17:28 +03:00
parent 9206f46c42
commit 2e4d142cf7
90 changed files with 802 additions and 749 deletions

22
src/scripts/speaker.ts Normal file
View file

@ -0,0 +1,22 @@
import {getInputNumber} from "utils/nodeUtils";
export function assignSpeakerBehavior() {
Array.from(document.getElementsByClassName("speaker")).forEach($speaker => {
const $sibling = $speaker.previousElementSibling;
$speaker.addEventListener("click", () => {
if ($sibling instanceof HTMLInputElement) {
speak($sibling.value);
}
});
});
}
function speak(str: string) {
const speaker = new SpeechSynthesisUtterance(str);
const voices = speechSynthesis.getVoices();
if (voices.length) {
const voiceId = getInputNumber("speakerVoice");
speaker.voice = voices[voiceId];
}
speechSynthesis.speak(speaker);
}