-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathperverbs editing.html
106 lines (96 loc) · 3.67 KB
/
perverbs editing.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
102
103
104
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<!--
Modern Perverbs, copyright (c) 2014 Nick Montfort <[email protected]>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-->
<style type="text/css">
/* <![CDATA[ */
body {
background: #fff;
color: #000;
margin: 0 0 0 18pt;
font-family: Optima, sans-serif;
font-size: 13pt;
}
a {
color: #117;
text-decoration: none;
}
/* ]]> */
</style>
<!-- Kat's notes:
Document functions include...
- .getElementbyId
- .createElement
- .createTextNode
main's functions include...
- .removeChild
- .appendChild
last's functions include... (? what is this variable's type?)
- .appendChild
miscellaneous functions...
- Math.floor
- Math.random
- rand_range (written by author)
- slice
- setInterval
On load (this is a body element?), the function produce_litany() is called.
-->
<script type="text/javascript">
var t = 0;
// All but the last character ends up as the beginning of the output.
// The last character is tacked onto the very end.
var left = ["I love.", "It's dinnertime.","There’s a party —.", "All roads lead.", "Welcome!", "Keep your data.", "For those we have lost,.", "The sun never sets.", "There’s no place…", "Can one simply walk?", "No man is.", "Right or wrong,.", "Tell it.", "The Internet is."];
var middle = ["from", "in", "to", "to the", "in", "for", "into", "", "like"];
// This ends up as the end of the output, except for the very last character.
var right = ["my whole being", "my pants", "Rome", "jungle", "the Cloud", "ever ever on", "those we can yet save", "home", "Mordor", "an island", "my country", "hand", "series of tubes"];
function rand_range(max) {
"use strict";
return Math.floor(Math.random() * (max + 1));
}
function litany() {
"use strict";
var last, text, l, m, r, main = document.getElementById('main');
if (t <= 24) {
t += 1;
} else {
main.removeChild(document.getElementById('main').firstChild);
}
last = document.createElement('div');
l = rand_range(left.length - 1); // picks a random sting from the list of left phrases
m = rand_range(middle.length - 1);
r = rand_range(right.length - 2); // picks a random string from the list of right phrases
if (r >= l) {
r += 1;
}
text = left[l].slice(0, left[l].length - 1) + " " + middle[m] + " " + right[r] + left[l].slice(-1); // [left phrase w/o punctuation] [space] [right phrase] [left phrase's punctuation]
last.appendChild(document.createTextNode(text));
main.appendChild(last);
}
function produce_litany() {
"use strict";
litany();
setInterval(litany, 2500);
}</script>
<title>Modern Perverbs</title>
</head>
<body onload="produce_litany();">
<div style="float:right; background:#999; margin-left:6px; border-left:thin #000 solid; border-bottom:thin #000 solid; padding:9px">
<div>Modern Perverbs<br><a href="http://nickm.com">Nick Montfort</a></div>
</div>
<div id="main" style="padding-top:18px;"></div>
</body>
</html>