-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
59 lines (52 loc) · 1.84 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
47
48
49
50
51
52
53
54
55
56
57
58
59
<html lang="en">
<head>
<meta charset="utf-8">
<title>Get Words Example</title>
<meta name="description" content="Get Words Example. Parse words from page.">
<!-- <script src="./index.js"></script> -->
<script type="module">
// const GetWords = window.GetWords
import GetWords from './index.js'
function output() {
const g = new GetWords();
const words = g.getWords(document.querySelector('#text-input').value);
const wordCounts = g.getWordCounts(words);
const formattedText = Object.entries(wordCounts).map(([key, value]) => `${key}: ${value}`).join('<br><br>')
document.querySelector('#output').innerHTML = formattedText
}
window.output = output
async function setDefaultTextInput() {
const txt = await(await fetch('./example/lorem-ipsum.txt')).text()
document.querySelector('#text-input').value = txt
}
function onLoad() {
setDefaultTextInput()
}
window.addEventListener('load', onLoad)
</script>
<style>
* {
text-align: center;
max-width: 100%;
}
</style>
</head>
<body>
<h1>Get Words Example</h1>
<div>
<h2>Tools</h2>
<div>
<textarea id="text-input" rows="10" cols="50"></textarea>
<div style="margin: 10px 0;">
<input type="button" value="Update Output" onclick="output()">
</div>
</div>
</div>
<div>
<h2>Output</h2>
<div id="output">
<!-- OUTPUT -->
</div>
</div>
</body>
</html>