This repository has been archived by the owner on Jul 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
catch-that-cat.html
65 lines (61 loc) · 1.87 KB
/
catch-that-cat.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
<!DOCTYPE html>
<html>
<head>
<title>Javascript Interactive Fiction/Adventure system</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, height=device-height">
<style type="text/css">
body {
Margin: 0; Padding: 0;
Background-color: white;
Color: black;
}
#output {
Width: 100%; Height: 100%;
Padding-bottom: 2em;
Overflow: auto;
}
#input-form {
Position: fixed;
Left: 0; Bottom: 0;
Width: 100%; Height: 2em;
}
#input { Width: 88%; Height: 2em; }
#submit { Width: 10%; Height: 2em; }
</style>
<script type="text/javascript" src="jaiffa.js"></script>
<script type="text/javascript" src="catch-that-cat.js"></script>
<script type="text/javascript">
window.onload = function () {
var parser = new jaiffa.VerbObjectParser(jaiffa._STORY);
jaiffa._STORY.start();
jaiffa._STORY.advance();
for (var i = 0; i < jaiffa.output_buffer.length; i++)
document.getElementById("output").innerHTML +=
"<p>" + jaiffa.output_buffer[i] + "</p>";
document.getElementById("output").lastChild
.scrollIntoView();
document.getElementById("output").scrollIntoView(false);
document.getElementById('input-form').onsubmit = function() {
jaiffa.output_buffer.length = 0;
parser.parse(document.getElementById('input').value);
document.getElementById('input').value = "";
jaiffa._STORY.advance();
for (var i = 0; i < jaiffa.output_buffer.length; i++)
document.getElementById("output").innerHTML +=
"<p>" + jaiffa.output_buffer[i] + "</p>";
document.getElementById("output").lastChild
.scrollIntoView();
document.getElementById("output").scrollIntoView(false);
return false;
}
}
</script>
</head>
<body>
<div id="output"></div>
<form id="input-form">
<input id="input" autofocus><input id="submit" type="submit" value="Do it">
</form>
</body>
</html>