-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
46 lines (46 loc) · 1.83 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> reSpell.js (demo) </title>
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
</head>
<body>
<div class="w3-panel w3-animate-right w3-card-4 w3-container">
<br>
<h1 class="w3-border w3-border-black w3-padding"> re<span><i><b>Spell</b></span></i>.js </h1>
<input id="input" type="number" onkeyup="Spell()" maxlength="36" placeholder="input a number...">
<br class="w3-hide-medium w3-hide-large"> <br class="w3-hide-medium w3-hide-large">
<button onclick="randomNumber()" class="w3-btn w3-border w3-border-black w3-mobile"> Random number </button>
<button onclick="speak()" class="w3-btn w3-border w3-border-black w3-mobile w3-r"> Read output (TTS) </button>
<h3 id="output" class="w3-card w3-padding">Waiting for your input...</h3>
<br>
</div>
<script src="reSpell.js"> </script>
<script>
function randomNumber() {
rnd = ""; limit = Math.floor(Math.random() * 66) + 1;
for (i = 1; i <= limit; i++ ) {
rnd += Math.floor(Math.random() * 9).toString().replace(/\b(0(?!\b))+/g, "");
}
cN = Math.floor(Math.random() * 10);
if (cN == 5 && rnd.length <= 35) { rnd = "-"+ rnd; }
document.getElementById("input").value = rnd;
document.getElementById("output").innerHTML = reSpell(rnd);
}
function Spell() {
n = document.getElementById("input").value;
document.getElementById("output").innerHTML = reSpell(n);
}
function speak() {
if ('speechSynthesis' in window) {
s = new SpeechSynthesisUtterance();
s.text = document.getElementById("output").innerHTML;
window.speechSynthesis.speak(s);
} else {
alert("TTS is not supported in your browser");
}
}
</script>
</body>
</html>