topical media & game development
game-javascript-casual-decoder-game.htm / htm
<!-- TWO STEPS TO INSTALL DECODER RING:
1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document -->
<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Colin Russell (niloc12@hotmail.com) -->
<!-- Web Site: http://www.geocities.com/niloc12.geo -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
var wt = ""; //temporary holder
var et = ""; //encoded text
var all = "";
var all2 = "";
var alpha2 = "abcdefghijklmnopqrstuvwxyz";
var a = "a"; var b = "b"; var c = "c"; var d = "d";
var e = "e"; var f = "f"; var g = "g"; var h = "h";
var i = "i"; var j = "j"; var k = "k"; var l = "l";
var m = "m"; var n = "n"; var o = "o"; var p = "p";
var q = "q"; var r = "r"; var s = "s"; var t = "t";
var u = "u"; var v = "v"; var w = "w"; var x = "x";
var y = "y"; var z = "z";
var alpha = new Array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');
function encode() {
wt = "";
et = "";
all = "";
var theText = document.f1.ta1.value.toLowerCase();
var num = document.f1.tb1.value;
i2 = 0;
for (i = 0; i < num; i++) {
i2 = i2 + 1;
if (i2 == 26) i2 = 0;
}
a = alpha[i2]; i2 = next(i2);
b = alpha[i2]; i2 = next(i2);
c = alpha[i2]; i2 = next(i2);
d = alpha[i2]; i2 = next(i2);
e = alpha[i2]; i2 = next(i2);
f = alpha[i2]; i2 = next(i2);
g = alpha[i2]; i2 = next(i2);
h = alpha[i2]; i2 = next(i2);
i = alpha[i2]; i2 = next(i2);
j = alpha[i2]; i2 = next(i2);
k = alpha[i2]; i2 = next(i2);
l = alpha[i2]; i2 = next(i2);
m = alpha[i2]; i2 = next(i2);
n = alpha[i2]; i2 = next(i2);
o = alpha[i2]; i2 = next(i2);
p = alpha[i2]; i2 = next(i2);
q = alpha[i2]; i2 = next(i2);
r = alpha[i2]; i2 = next(i2);
s = alpha[i2]; i2 = next(i2);
t = alpha[i2]; i2 = next(i2);
u = alpha[i2]; i2 = next(i2);
v = alpha[i2]; i2 = next(i2);
w = alpha[i2]; i2 = next(i2);
x = alpha[i2]; i2 = next(i2);
y = alpha[i2]; i2 = next(i2);
z = alpha[i2]; i2 = next(i2);
var all = a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+r+s+t+u+v+w+x+y+z;
all = all.split("");
encode2(all);
}
function next(x) {
if (x == 25) x = -1;
x = x + 1;
return x;
}
function encode2(all2) {
var temp2 = document.f1.ta1.value.toLowerCase();
temp2 = temp2.split("");
var q = 0;
while (q < temp2.length) {
wt = temp2[q];
var where = alpha2.indexOf(wt);
if (where == -1) { et += wt; }
if (where != -1) { et += all2[where]; }
q = q + 1;
}
document.f1.ta1.value = et;
}
function decode() {
wt = "";
et = "";
all = "";
all3 = "";
var theText = document.f1.ta1.value.toLowerCase();
var num = document.f1.tb1.value;
i2 = 0;
for (i = 0; i < num; i++) {
i2 = i2 + 1;
if (i2 == 26) i2 = 0;
}
a = alpha[i2]; i2 = next(i2);
b = alpha[i2]; i2 = next(i2);
c = alpha[i2]; i2 = next(i2);
d = alpha[i2]; i2 = next(i2);
e = alpha[i2]; i2 = next(i2);
f = alpha[i2]; i2 = next(i2);
g = alpha[i2]; i2 = next(i2);
h = alpha[i2]; i2 = next(i2);
i = alpha[i2]; i2 = next(i2);
j = alpha[i2]; i2 = next(i2);
k = alpha[i2]; i2 = next(i2);
l = alpha[i2]; i2 = next(i2);
m = alpha[i2]; i2 = next(i2);
n = alpha[i2]; i2 = next(i2);
o = alpha[i2]; i2 = next(i2);
p = alpha[i2]; i2 = next(i2);
q = alpha[i2]; i2 = next(i2);
r = alpha[i2]; i2 = next(i2);
s = alpha[i2]; i2 = next(i2);
t = alpha[i2]; i2 = next(i2);
u = alpha[i2]; i2 = next(i2);
v = alpha[i2]; i2 = next(i2);
w = alpha[i2]; i2 = next(i2);
x = alpha[i2]; i2 = next(i2);
y = alpha[i2]; i2 = next(i2);
z = alpha[i2]; i2 = next(i2);
var all = a+b+c+d+e+f+g+h+i+j+k+l
+m+n+o+p+q+r+s+t+u+v+w+x+y+z;
all3 = all;
all = all.split("");
decode2(all3);
}
function decode2(all2) {
var alpha2 = "abcdefghijklmnopqrstuvwxyz";
alpha2 = alpha2.split("");
var temp2 = document.f1.ta1.value.toLowerCase();
temp2 = temp2.split("");
var v = 0;
while (v < temp2.length) {
wt = temp2[v];
var where = all2.indexOf(wt);
if (where == -1) { et += wt; }
if (where != -1) { et += alpha2[where]; }
v = v + 1;
}
document.f1.ta1.value = et;
}
// End -->
</script>
</HEAD>
<!-- STEP TWO: Copy this code into the BODY of your HTML document -->
<BODY>
<center>
<form name=f1>
<textarea name=ta1 cols=40 rows=20>
</textarea>
<p>
Key Value: <input type="text" size=10 name="tb1" value=""><br>
<input type="button" value="Encode Message" onClick="encode(); return false;">
<input type="button" value="Decode Message" onClick="decode(); return false;">
</form>
</center>
<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>
<!-- Script Size: 4.59 KB -->
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.