-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
101 lines (98 loc) · 2.5 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Novel Generator</title>
</head>
<body>
<style>
#add {
font-size: 30px;
color: #FFF;
text-align: center;
cursor: pointer;
background: #0998E9;
position: fixed;
top: 2%;
left: 0;
width: 100vw;
height: 50px;
padding: 12px 0 0;
}
#add:hover {
background: #0089DA;
}
#add:active {
background: #0080CB;
}
#generate {
font-size: 30px;
color: #FFF;
text-align: center;
cursor: pointer;
background: #0498E9;
position: fixed;
top: 10%;
left: 0;
width: 100vw;
height: 50px;
padding: 12px 0 0;
}
#generate:hover {
background: #0489DA;
}
#generate:active {
background: #0480CB;
}
#text, #text:focus {
font-family: Menlo, Consolas, monospace;
font-size: 15px;
color: #000;
background: #FFF;
border: 1px solid black;
outline: none;
resize: none;
position: fixed;
top: 20%;
width: 98vw;
height: 30vh;
padding: 10px;
margin: 0;
overflow: scroll;
}
#generatedText {
font-family: Menlo, Consolas, monospace;
font-size: 15px;
color: #000;
background: #FFF;
border: 1px solid black;
outline: none;
resize: none;
position: fixed;
top: 55%;
width: 98vw;
height: 40vh;
padding: 10px;
margin: 0;
overflow: scroll;
}
</style>
<div id="add">Add</div>
<div id="generate">Generate</div>
<textarea id="text" autocorrect="off" autocomplete="off" autofocus="autofocus"></textarea>
<textarea id="generatedText" onkeydown="return false"></textarea>
<script type="text/javascript" src="./ngram.js"></script>
<script type="text/javascript">
const ngram = new NGram(4);
document.getElementById('add').addEventListener('click', () => {
const content = document.getElementById('text').value;
if (!content) return;
ngram.add(content);
document.getElementById('text').value = "";
});
document.getElementById('generate').addEventListener('click', () => {
document.getElementById('generatedText').value = ngram.generate(1000);
});
</script>
</body>
</html>