-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathOKview.html
executable file
·98 lines (93 loc) · 4.03 KB
/
OKview.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>OKview</title>
<style>
html, body, #input_label {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
body, #input_label {
display: flex;
justify-content: center;
align-items: center;
}
#input {
border: 0;
outline: 0;
display: block;
font-size: 10vmax;
max-width: 100%;
text-align:center;
}
#output, #splash {
max-width: 45rem;
}
.invisible {
display: none!important;
}
#download, #splash-button {
display: inline-block;
background: #AAA;
padding: 0.5rem 1rem;
border-radius: 0.25rem;
border: 1px solid #333;
text-decoration: none;
font-family: sans-serif;
color: #000;
}
#download:hover, #splash-button:hover {
background: #CCC;
cursor: pointer;
}
#download:active, #splash-button:active {
background: #444;
color: #FFF;
}
</style>
</head>
<body>
<div id="splash">
<h1>OKview</h1>
<p> This is an automatic writing app based on the one sentence description of "Grandview" provided on <a href="https://en.wikipedia.org/wiki/Surrealist_automatism#Contemporary_techniques">wikipedia</a>. </p>
<p> As you type, the word you're writing will disappear once you hit space or enter -- but do not fear! It's being saved for later! Hit escape to see what you've come up with. </p>
<button id="splash-button">continue</button autofocus>
</div>
<label id="input_label" class="invisible">
<input type="text" id="input" autofocus />
</label>
<div id="output-container" class="invisible">
<pre id="output"></pre>
<a href="" id="download" download>download</a>
</div>
<script>
let input = document.getElementById("input");
let outputContainer = document.getElementById("output-container");
let output = document.getElementById("output");
let splash = document.getElementById("splash");
let splashBtn = document.getElementById("splash-button");
let downloadBtn = document.getElementById("download");
input.addEventListener("keydown", function(evt) {
console.log(evt);
if (evt.keyCode === 32 || evt.keyCode === 13) {
output.innerHTML += this.value.trim() + (evt.keyCode === 13 ? "\n" : " ");
this.value = "";
} else if (evt.keyCode === 27) {
document.getElementById("input_label").classList.add("invisible");
outputContainer.classList.remove("invisible");
var file = new Blob([output.innerHTML], {type: "text/plain"});
downloadBtn.href = URL.createObjectURL(file);
downloadBtn.download = "automatic_writing.txt";
}
});
splashBtn.addEventListener("click", function() {
splash.classList.add("invisible");
document.getElementById("input_label").classList.remove("invisible");
input.focus();
});
</script>
</body>
</html>