ch04
This commit is contained in:
125
Chapter ZIPs/JavaScript/ch04/greg/greg.css
Executable file
125
Chapter ZIPs/JavaScript/ch04/greg/greg.css
Executable file
@@ -0,0 +1,125 @@
|
||||
body { background-color: #000040;
|
||||
background-image: url(background.gif);
|
||||
color: #88ffff;
|
||||
font-family: Verdana, Arial, sans-serif;
|
||||
}
|
||||
#container { margin-left: auto;
|
||||
margin-right: auto;
|
||||
width:80%;
|
||||
min-width:700px;
|
||||
}
|
||||
|
||||
|
||||
#logo {
|
||||
text-align:center;
|
||||
margin: 0;
|
||||
font-family: Geneva, Arial, Helvetica, sans-serif;
|
||||
padding-top: 30px;
|
||||
padding-bottom: 20px;
|
||||
|
||||
}
|
||||
#nav {
|
||||
float: left;
|
||||
width: 200px;
|
||||
padding-top: 10px;
|
||||
text-align:left;
|
||||
color: #88FFFF;
|
||||
font-size: 12px;
|
||||
}
|
||||
#nav a {text-decoration:none;
|
||||
margin: 15px;
|
||||
display: block;
|
||||
color: #88FFFF;
|
||||
font-size: 12px;
|
||||
}
|
||||
#content {
|
||||
margin-left: 150px;
|
||||
padding: 30px;
|
||||
overflow:auto;
|
||||
border: medium groove #88FFFF;
|
||||
line-height: 135%;
|
||||
|
||||
}
|
||||
|
||||
.floatright {padding-left:20px;
|
||||
float:right;
|
||||
}
|
||||
.floatleft {
|
||||
float:left;
|
||||
padding: 30px 0px 20px;
|
||||
}
|
||||
#footer { font-size: .60em;
|
||||
font-style: italic;
|
||||
text-align: center;
|
||||
border-top: 2px double #000040;
|
||||
padding-top: 20px;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
h2 { text-transform: uppercase;
|
||||
color: #88ffff;
|
||||
font-size: 1.2em;
|
||||
border-bottom: 1px none;
|
||||
margin-right: 20px;
|
||||
}
|
||||
h3 {
|
||||
color: #88ffff;
|
||||
font-size: 1.2em;
|
||||
border-bottom: 1px solid #000000;
|
||||
margin-right: auto;
|
||||
text-align: left;
|
||||
padding-top: 10px;
|
||||
padding-right: 20px;
|
||||
padding-bottom: 10px;
|
||||
padding-left: 20px;
|
||||
line-height: 120%;
|
||||
}
|
||||
.details { padding-left:20%;
|
||||
padding-right:20%;
|
||||
}
|
||||
|
||||
|
||||
img {border:0; }
|
||||
|
||||
|
||||
.content {
|
||||
margin: 20px;
|
||||
padding: 20px;
|
||||
height: 3700px;
|
||||
width: 500px;
|
||||
}
|
||||
a {text-decoration:none;
|
||||
margin: 15px;
|
||||
display: block;
|
||||
color: #88FFFF;
|
||||
font-size: 12px;
|
||||
}
|
||||
a:hover {
|
||||
color: #000040;
|
||||
background-color: #88ffff;
|
||||
}
|
||||
span {
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
font-family: "Courier New", Courier, mono;
|
||||
color: #88ffff;
|
||||
background-position: center center;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
table {
|
||||
border-collapse: collapse
|
||||
}
|
||||
td {
|
||||
border: 2px solid #88ffff;
|
||||
width: 5em;
|
||||
color: #88ffff;
|
||||
}
|
||||
.nobdr {
|
||||
border: none;
|
||||
cell-padding: 5px;
|
||||
}
|
||||
p {
|
||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||
font-size: 12px;
|
||||
}
|
70
Chapter ZIPs/JavaScript/ch04/greg/greg_encoder.html
Executable file
70
Chapter ZIPs/JavaScript/ch04/greg/greg_encoder.html
Executable file
@@ -0,0 +1,70 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Greg's Gambits | Secret Message Encoder</title>
|
||||
<link href="greg.css" rel="stylesheet" type="text/css" />
|
||||
<script type="text/javascript">
|
||||
function encodeIt()
|
||||
{
|
||||
document.getElementById("message").innerHTML = ("<h2> </h2>");
|
||||
var msg= prompt("Enter your message." , " ");
|
||||
var newmsg = " ";
|
||||
var upCaseCode = 155;
|
||||
var newCode = 0;
|
||||
var lowCaseCode = 219;
|
||||
var specialCode = 3;
|
||||
//the loop encodes each letter in the message string
|
||||
for (var j = 0; j < msg.length; j++)
|
||||
{
|
||||
//check for upppercase letters and encode them
|
||||
if ((msg.charCodeAt(j) >= 65) && (msg.charCodeAt(j) <= 90))
|
||||
{ newcode = (upCaseCode - msg.charCodeAt(j)); }
|
||||
else
|
||||
//check for lowercase letters and encode them
|
||||
if ((msg.charCodeAt(j) >= 97) && (msg.charCodeAt(j) <= 122))
|
||||
{ newcode = (lowCaseCode - msg.charCodeAt(j)); }
|
||||
else
|
||||
//check for numbers and special characters and encode them
|
||||
if (((msg.charCodeAt(j) > 90) && (msg.charCodeAt(j) < 97)) || (msg.charCodeAt(j) < 65))
|
||||
{ newcode = (msg.charCodeAt(j) + specialCode); }
|
||||
//add each encoded character to the new message
|
||||
newmsg = newmsg + " " + String.fromCharCode(newcode);
|
||||
}
|
||||
//display the encoded message on the web page
|
||||
document.getElementById("secret").innerHTML = ("<h2>" + newmsg + "</h2>");
|
||||
//decide if original message should be shown
|
||||
var choice = prompt("Do you want the original message displayed? Yes or No?", " ");
|
||||
if ((choice.charAt(0) == 'y') || (choice.charAt(0) == 'Y'))
|
||||
{
|
||||
document.getElementById("message").innerHTML = ("<h2>" + msg + "</h2>");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="container">
|
||||
<img src="images/superhero.jpg" width="120" height="120" class="floatleft" />
|
||||
<h1 id="logo"><em>The Secret Message Encoder</em></h1>
|
||||
<p> </p>
|
||||
<div id="nav">
|
||||
<p><a href="index.html">Home</a>
|
||||
<a href="greg.html">About Greg</a>
|
||||
<a href="play_games.html">Play a Game</a>
|
||||
<a href="sign.html">Sign In</a>
|
||||
<a href="contact.html">Contact Us</a></p>
|
||||
</div>
|
||||
<div id="content">
|
||||
<h2>Write A Message and Encode It</h1>
|
||||
<p><input type="button" id="encode" value="Enter your message" onclick="encodeIt();" /></p>
|
||||
<table cellpadding="2" width = "90%" align = "center" border="1">
|
||||
<tr> <td align="center" id="secret"><p>encoded message</p></td> </tr>
|
||||
<tr> <td align="center" id="message"> </td> </tr> </table>
|
||||
</div>
|
||||
<div id="footer">Copyright © 2013 Greg's Gambits<br />
|
||||
<a href="mailto:yourfirstname@yourlastname.com">yourfirstname@yourlastname.com</a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
BIN
Chapter ZIPs/JavaScript/ch04/greg/images/superhero.jpg
Executable file
BIN
Chapter ZIPs/JavaScript/ch04/greg/images/superhero.jpg
Executable file
Binary file not shown.
After Width: | Height: | Size: 5.0 KiB |
46
Chapter ZIPs/JavaScript/ch04/greg/play_games.html
Executable file
46
Chapter ZIPs/JavaScript/ch04/greg/play_games.html
Executable file
@@ -0,0 +1,46 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<title>Greg's Gambits | Games Menu</title>
|
||||
<link href="greg.css" rel="stylesheet" type="text/css" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
|
||||
<img src="../images/superhero.jpg" width="120" height="120" class="floatleft" />
|
||||
<h1 id="logo"><em>Play A Game</em></h1>
|
||||
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
<div id="nav">
|
||||
<p><a href="index.html">Home</a>
|
||||
<a href="greg.html">About Greg</a>
|
||||
<a href="play_games.html">Play a Game</a>
|
||||
<a href="sign.html">Sign In</a>
|
||||
<a href="contact.html">Contact Us</a></p>
|
||||
</div>
|
||||
<div id="content">
|
||||
<p>Menu of Available Games </p>
|
||||
<table width="90%" border="0" cellpadding="5">
|
||||
<tr>
|
||||
<td width="50%"><a href="greg_tales.html">Greg's Tales</a> </td>
|
||||
<td width="50%"><a href ="gregs_fortune.html">Madame Vadoma Sees All</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="50%"><a href="greg_encoder.html">The Secret Message Encoder</a> </td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<p> </p>
|
||||
</div>
|
||||
<div id="footer">Copyright © 2013 Greg's Gambits<br />
|
||||
<a href="mailto:yourfirstname@yourlastname.com">yourfirstname@yourlastname.com</a></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user