
Cut And
Paste Code For Lesson 18
This week we'll
look at the (final?!?) version of our email encoder/decoder!
We'll also look
at some wonderful examples of JavaScript used by our frinds at ESRI!
(Thanks
to Ty Fitzpatrick.)
Link to ESRI samples using the public api for java scrip:
https://developers.arcgis.com/javascript/jssamples/
ESRI's
online editor and samples:
https://developers.arcgis.com/javascript/jshelp/intro_firstmap_amd.html
Click here
to go back to our lessons page.
Improved email encoder/decoder:
<html>
<head>
<title> Easy,
safe, email encoding.</title>
<meta name="GENERATOR"
content="Namo WebEditor v5.0">
<meta
name="description" content="An extremely simple yet secure way
to encode your emails.">
<meta name="keywords"
content="code encoding encryption data credit card encryption security
computer internet technology cryptography decryption website algorithm
privacy passkey cypher padlock safe private confidential">
<meta
name="author" content="Walt Noon">
</head>
<body
background="http://www.noonco.com/encoder/Web_background_fade.jpg">
<p> <a
href="http://www.noonco,com"><span style="font-size:18pt;"><font
face="Vijaya" color="#CCCCCC">Home</font></span></a>
<font
face="Vijaya" color="#CCCCCC"><span style="font-size:18pt;">/FAQ
/ </span></font><a href="http://www.bouyee.com"><span
style="font-size:18pt;"><font face="Vijaya" color="#CCCCCC">Send
Secure Images</font></span></a></p>
<hr>
<p
align="center">
<font
face="Vijaya" color="#CCCCCC"><span style="font-size:36pt;">Redlands
Conservatory Email Encoding Page...<br></span><span style="font-size:24pt;">This
page can be used to encode personal information in your emails, and keep
it
away from prying eyes!<br>Simply cut and paste the generated code
into your
email and send it to a friend.<br>Your friend can then return
to this page to decode
your secret note! <br>Note: Your
personal information is secure:<br>This
program
is running on your computer, and nothing entered
is transmitted
over the web!<br></span></font>
</p>
<table
align="center" border="0" width="50%" cellpadding="50">
<tr>
<td
width="619" background="http://www.noonco.com/encoder/gradient-black-to-white-center-wallpaper-4.jpg">
<p>
<font
face="Comic Sans MS"><span style="font-size:16pt;"> Encoder:</span></font>
</p>
<form
name="EnterName">
<font
face="Comic Sans MS">Enter your message to encode below:
<br><br>
<textarea
id="messageII" rows="4" cols="50">
</textarea>
<br><br>
Optional: Enter a "key" to lock the message:
<br><br>
<input
type=text name="keyII" size=6>
<br><br></font>
<p>
<font
face="Comic Sans MS"> </font>
</form>
<font
face="Comic Sans MS"><button onclick="myFunctionII()">Click
to encode a message.</button>
<br><br>
Your encoded message:
</font><br><br>
<textarea
id="outputII" rows="4" cols="50">
</textarea>
<p
id="demo"></p>
<script>
function
myFunctionII() {
person
= document.getElementById("messageII").value;
person
= person + " "; //add a space to the end of any note
key
= EnterName.keyII.value;
//change
the key into a number.
key2
= 0;
var
n = key.length;
for
(i = 0; i < n; i = i + 1) {
key2
= key2 + key.charCodeAt(i);
}
//create
the ascii code, offset by any key that was entered.
var
encoded = "";
var
n = person.length;
for
(i = 0; i < n; i = i + 1) {
key2
= key2 + 12 // changes the value of key2 each letter to prevent easy decription
encoded
= encoded + (person.charCodeAt(i) + key2) + " ";
}
document.getElementById("outputII").innerHTML
=
encoded;
}
</script>
</td>
<td
width="619">
<p> </p>
</td>
<td
width="619" background="http://www.noonco.com/encoder/gradient-black-to-white-center-wallpaper-4.jpg">
<p> <span
style="font-size:16pt;">Decoder:</span></p>
<form
name="Decode">
<font
face="Comic Sans MS">Enter your message to decode below:
<br><br>
<textarea
id="message" rows="4" cols="50">
</textarea>
<br><br>
Optional: Enter a "key" to unlock the message:
<br><br>
<input
type=text name="key" size=6>
<br><br></font>
<p>
<font
face="Comic Sans MS"> </font>
</form>
<font
face="Comic Sans MS"><button onclick="myFunction()">Click
to decode a message.</button>
<br><br>
Your decoded message:
</font><br><br>
<textarea
id="output" rows="4" cols="50">
</textarea>
<p
id="demo"></p>
<script>
function
myFunction() {
person
= document.getElementById("message").value;
key
= Decode.key.value;
//change
the key into a number.
key2
= 0;
var
n = key.length;
for
(i = 0; i < n; i = i + 1) {
key2
= key2 + key.charCodeAt(i);
}
//create
the ascii code, offset by any key that was entered.
var
encoded = "";
var
n = person.length;
var
tempcharacter = "";
for
(i = 0; i < n; i = i + 1) {
if
(person.charAt(i) != " ") {
tempcharacter
= tempcharacter + person.charAt(i);
}
else {
key2
= key2 + 12 // changes the value of key2 each letter to prevent easy decription
tempcharacter
= String.fromCharCode(Number(tempcharacter - key2));
encoded
= encoded + tempcharacter;
tempcharacter
= "";
}
}
document.getElementById("output").innerHTML
=
encoded;
}
</script>
</td>
</tr>
</table>
<p> </p>
</body>
</html>