html
html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<p>Warning: This code works only with letters.</p>
<br/>
<p>text to translate:</p>
<input type="text" id="inp"/>
<p>steps (max. 6):</p>
<input type="valuet" id="stepsinput"/>
<div>
<p id="box"></p>
</div>
<button id="but" onclick="crypt()">Click me to translate!</button>
</body>
</html>
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
4
5
#box{
width:80%;
height:50px;
}
Enter to Rename, Shift+Enter to Preview
js
js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// I use s- to mark that something is only in the script. That's not necessary, but it helps me.
function toascii(letter){
return letter.charCodeAt(0);
}
function fromascii(letter){
return String.fromCharCode(letter);
}
function crypt(){
sbox = document.getElementById("box");
sinp = document.getElementById("inp").value;
ssteps = document.getElementById("stepsinput").value;
if(ssteps>6){
alert("This number of steps is not allowed!")
}
ssteps++;
var soutput = "";
for(i=0;i<sinp.length;i++){
var isinp = sinp.charAt(i);
var x;
// isinp, because it's in the for-loop
wrk = toascii(isinp);
wrk += ssteps-1;
if(wrk>122 || (wrk>90 && wrk<97)){
wrk -= 26;
}
soutput = soutput + fromascii(wrk);
}
sbox.innerHTML=soutput;
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run