Skip to content

Instantly share code, notes, and snippets.

@samplereality
Created October 31, 2015 17:51
Show Gist options
  • Save samplereality/eee4c921b2ae57e82a3d to your computer and use it in GitHub Desktop.
Save samplereality/eee4c921b2ae57e82a3d to your computer and use it in GitHub Desktop.
Web implementation of Margaret Chisman's "Life is Random Walk"
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Life is a Random Walk</title>
<meta name="description" content="Life is Random Walk" />
<style type="text/css" media="screen">
body
{
color: black;
background-color: #fff;
margin: 0px
}
#page {
width: 45%;
margin-top: 125px;
margin-bottom: auto;
margin-left: 1.5em;
padding: 40px;
color: #333;
text-align: left;
line-height: 2;
font-size: 24px;
}
#horizon
{
background-color:transparent;
position: absolute;
top: 40%;
left: 0px;
width: 100%;
height: 1px;
overflow: visible;
visibility: visible;
display: block;
}
#content strong
{
font-family:Arial, Helvetica, sans-serif;
font-weight:bold;
}
#content
{
color:black;
text-align: left;
font-family: "Times New Roman", Times, serif;
/*background-color: #ff0;*/
margin-left: -400px;
position: fixed;
top: 10px;
left: 50%;
width: 800px;
height: 200px;
visibility: visible
}
.bodytext
{
font-size: 34px
}
#footer
{
font-size: 11px;
font-family: Verdana, Geneva, Arial, sans-serif;
text-align: center;
position: absolute;
bottom: 50px;
left: -100px;
width: 100%;
height: 20px;
visibility: visible;
display: block
}
.classname {
-moz-box-shadow:inset 0px 1px 0px 0px #ffffff;
-webkit-box-shadow:inset 0px 1px 0px 0px #ffffff;
box-shadow:inset 0px 1px 0px 0px #ffffff;
background-color:#ededed;
-moz-border-radius:6px;
-webkit-border-radius:6px;
border-radius:6px;
border:1px solid #dcdcdc;
display:inline-block;
color:#525252;
font-family:arial;
font-size:24px;
font-weight:bold;
padding:6px 24px;
text-decoration:none;
text-shadow:1px 1px 0px #ffffff;
margin-right:20px;
margin-left:10px;
}.classname:hover {
background-color:#ffff00;
}.classname:active {
position:relative;
top:1px;
}
#btn
{
/*padding-left: 10%;
border-left: 1px dashed #66c;*/
position: fixed;
text-align: right;
top: 0;
left: 70%;
width:30%;
margin-top: 150px;
padding-left: 10%;
/*background-color:#9C3;*/
text-align:left;
}
#footer a {
text-decoration:none;
color:#000;
font-weight:bold;
}
#footer a:hover {
background:#FF0;
}
#hidden {
visibility:hidden;
}
</style>
<script type="text/javascript" src="jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="rita.js"></script>
<script>
function capitalizeFirstLetter(string)
{
return string.charAt(0).toUpperCase() + string.slice(1);
}
lexicon = new RiLexicon();
window.onload = generate;
function generate()
{
ruthless = lexicon.randomWord('JJ',2);
turbulence = lexicon.randomWord('NN');
loving = lexicon.randomWord('VBG');
confusion = lexicon.randomWord('NN');
walks = ["walk", "pray", "meditate", "fast", "eat", "wait", "sing", "shout", "die", "sleep", "whisper", "cry", "sigh", "draw", "write"];
walk = walks[Math.floor(Math.random() * walks.length)];
ridiculously = lexicon.randomWord('RB');
first = ruthless.substr(0,1);
article = "A";
if (first === 'a' ||
first === 'e' ||
first === 'i' ||
first === 'o' ||
first === 'u') {
article = "An";
}
stanzaOne = article + " " + ruthless + " " + turbulence + " of " + loving + "\u000A";
stanzaTwo = "Sometimes results in " + confusion + "\u000A";
stanzaThree = "Yet I " + walk + " alone on a mountain\u000A";
stanzaFour = capitalizeFirstLetter(ridiculously);
result = "<em>Life is a Random Walk</em><P>" + stanzaOne + "<br>" + stanzaTwo + "<br>" + stanzaThree + "<br>" + stanzaFour;
changeTextSimple('apology', result);
}
function changeTextSimple(idElement, result){
document.getElementById(idElement).innerHTML = result;
}
</script>
</head>
<body>
<div id="hidden">
<img src="image.png" width="188" height="188" alt="thumb">
</div>
<div id="horizon">
<div id="content">
<div class="bodytext">
<span id="apology"></span>
<div id="btn">
<a href="#" onclick="generate()" class="classname">Another Walk</a>
</div>
</div>
</div>
</div>
<div id="footer">
Life is a Random Walk, implementation by <a href="http://www.twitter.com/samplereality">@samplereality</a>. Inspired by Margaret Chisman's computer poetry, as found in Richard Bailey's <em>Computer Poetry</em> (1973). Built for <a href="https://www.edx.org/course/electronic-literature-davidsonx-d004x">#D004x</a>.</div>
</body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment