<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<!--
Nick Montfort
Original Python program:
8 January 2009, Taroko Gorge National Park, Taiwan and Eva Air Flight 28
This JavaScript version, with links:
22 November 2017
Copyright (c) 2009-2017 Nick Montfort <nickm@nickm.com>
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: BLANCHEDALMOND;
color: DIMGRAY;
margin: 0 24pt 0 24pt;
font-family: Garamond;
font-size: 15pt;
background-image:url(https://i.pinimg.com/736x/5d/fb/eb/5dfbeb8e8803b03955f3d926757bac44--visual-design-behance.jpg);
background-size:800px 800px;
background-repeat:no-repeat;
}
div {
height: 16pt;
}
a {
color: deepskyblue;
text-decoration: none;
}
/* ]]> */
</style>
<script type="text/javascript">
var t=0;
var n=0;
var paths=0;
var above='the student,you,we,everyone,nobody,Charlie'.split(',');
var below='book,chapter,paragraph,sentence,word,letter,punctuation mark,section'.split(',');
var trans='write,read,acknowledge,encounter,understand,plan,recite,examine'.split(',');
var imper='be,read,ignore,find,have,observe,notice,examine'.split(',');
var intrans='wait,beg,think,listen,speak,disappear,reappear,hide'.split(',');
var s='s,'.split(',');
var punct='.,?,!,?!,;,:'.split(',');
var texture='soft,hard,coarse,fine,indecipherable,basic'.split(',');
function rand_range(max) {
return Math.floor(Math.random()*(max+1));
}
function choose(array) {
return array[rand_range(array.length-1)];
}
function path() {
var p=rand_range(1);
var words=choose(above);
if (words.includes('the student')) {
words+=s[p]+' '+choose(trans)+s[(p+1)%2];
} else if(words.includes('everyone')||words.includes('nobody')||words.includes('Charlie')) {
words+=' ' + choose(trans) + 's';
}
else{
words+=' ' + choose(trans);
}
words+=' the '+choose(below)+choose(s)+choose(punct);
return words;
}
function site() {
var words='';
var p=rand_range(1);
if (rand_range(2)==1) {
words+=choose(above);
if(words.includes('the student')) {
words+=s[p]+' '+choose(intrans)+s[(p+1)%2];
} else if (words.includes('everyone')||words.includes('nobody')||words.includes('Charlie')){
words+=' '+choose(intrans)+'s';
}
else {
words+=' '+choose(intrans);
}
}
else {
words+=choose(below) + 's ' + choose(intrans);
}
words+=choose(punct);
return words;
}
function cave() {
var adjs=('outside of,'+choose(texture)+',red,yellow,orange,white,black,blue,green,chartreuse').split(',');
var target=1+rand_range(3);
while (adjs.length>target) {
adjs.splice(rand_range(adjs.length),1);
}
var words='\u00a0\u00a0'+choose(imper)+' the '+adjs.join(' ')+' \u2014';
return words;
}
function do_line() {
var main=document.getElementById('main');
if (t<=26) {
t+=1;
} else {
main.removeChild(document.getElementById('main').childNodes.item(1));
}
if (n===0) {
text=' ';
} else if (n==1) {
paths=2+rand_range(2);
text=path();
} else if (n<paths) {
text=site();
} else if (n==paths) {
text=path();
} else if (n==paths+1) {
text=' ';
} else if (n==paths+2) {
text=cave();
} else {
text=' ';
n=0;
}
n+=1;
text=text.substring(0,1).toUpperCase()+text.substring(1,text.length);
last=document.createElement('div');
last.appendChild(document.createTextNode(text));
main.appendChild(last);
}
function poem() {
setInterval(do_line, 1200);
}
</script>
<title>To Read a Book</title>
</head>
<body onload="poem()">
<div style="float:right; margin-top:12px; color:black; height:60pt">
<div>To Read a Book : Charlie Barth</div>
<a href="https://nickm.com/taroko_gorge/">Original by Nick Montfort</a><br/>
</div>
<div id="main"></div>
</body>
</html>