Oleh: frankly_labs | Juni 7, 2008

ENKRIPSI DENGAN KODE ASCII

<!– Langkah pertama: paste kan kode ini pada head dokumen HTML    –>

<HEAD>

<SCRIPT LANGUAGE=”JavaScript”>
function Encrypt(theText) {
output = new String;
Temp = new Array();
Temp2 = new Array();
TextSize = theText.length;
for (i = 0; i < TextSize; i++) {
rnd = Math.round(Math.random() * 122) + 68;
Temp[i] = theText.charCodeAt(i) + rnd;
Temp2[i] = rnd;
}
for (i = 0; i < TextSize; i++) {
output += String.fromCharCode(Temp[i], Temp2[i]);
}
return output;
}
function unEncrypt(theText) {
output = new String;
Temp = new Array();
Temp2 = new Array();
TextSize = theText.length;
for (i = 0; i < TextSize; i++) {
Temp[i] = theText.charCodeAt(i);
Temp2[i] = theText.charCodeAt(i + 1);
}
for (i = 0; i < TextSize; i = i+2) {
output += String.fromCharCode(Temp[i] – Temp2[i]);
}
return output;
}
</script>
</HEAD>

<!– Langkah kedua : paste kan kode ini pada body dokumen HTML    –>

<BODY>

<center>
<form name=encform onsubmit=”return false;”>
<textarea name=box1 rows=5 cols=50>The quick brown fox jumps over the lazy dog</textarea>
<p>
<input type=button value=”Encrypt Box1 to Box2″ onClick=”this.form.box2.value=Encrypt(this.form.box1.value);”>
<p>
<textarea name=box2 rows=5 cols=50></textarea>
<p>
<input type=button value=”Decrypt Box2 to Box3″ onClick=”this.form.box3.value=unEncrypt(this.form.box2.value);”>
<p>
<textarea name=box3 rows=5 cols=50></textarea>
</form>
</center>

Oleh: frankly_labs | Juni 4, 2008

Mencegah Klik Kanan

<script language=”javascript”>
var popup=”Maaf, Anda tidak diperkenankan untuk klik kanan”;
function noway(go) {
if (document.all) {
if (event.button == 2) {
alert(popup);
return false;
}
}
if (document.layers) {
if (go.which == 3) {
alert(popup);
return false;
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=noway;
</script>

Oleh: frankly_labs | Juni 4, 2008

Membuat Teks Berjalan Pada Status Bar

<script language=”javascript”>
var speed = 10
var pause = 1500
var timerID = null
var bannerRunning = false
var ar = new Array()

ar[0] = “Indonesia Maju Bersama”
ar[1] = “Berantas KKN dan sejahterakan rakyat”
ar[2] = “Indonesia Bangkit”
ar[3] = “Indonesia Aman Sentosa”
ar[4] = “Bangkit Indonesiaku”
ar[5] = “Bangkitlah…………”

var message = 0
var state = “”

clearState()
function stopBanner() {
        // if banner is currently running
        if (bannerRunning)
        // stop the banner
        clearTimeout(timerID)
        // timer is now stopped
        timerRunning = false
}
function startBanner() {
        // make sure the banner is stopped
        stopBanner()
        // start the banner from the current position
        showBanner()
}
function clearState() {
        // initialize to empty string
        state = “”
        // create string of same length containing 0 digits
        for (var i = 0; i < ar[message].length; ++i) {
        state += “0″
        }
}
function showBanner() {
        // if the current message is done
        if (getString()) {
        // increment message
        message++
        // if new message is out of range wrap around to first message
        if (ar.length <= message)
        message = 0
        // new message is first displayed as empty string
        clearState()
        // display next character after pause milliseconds
        timerID = setTimeout(“showBanner()”, pause)
        }
        else {
        // initialize to empty string
        var str = “”
        // built string to be displayed (only character selected thus far are displayed)
        for (var j = 0; j < state.length; ++j) {
        str += (state.charAt(j) == “1″) ? ar[message].charAt(j) : “     “
        }
        // partial string is placed in status bar
        window.status = str
        // add another character after speed milliseconds
        timerID = setTimeout(“showBanner()”, speed)
        }
}
function getString() {
        // set variable to true (it will stay true unless proven otherwise)
        var full = true
        // set variable to false if a free space is found in string (a not-displayed char)
        for (var j = 0; j < state.length; ++j) {
        // if character at index j of current message has not been placed in displayed string
        if (state.charAt(j) == 0)
        full = false
        }
        // return true immediately if no space found (avoid infinitive loop later)
        if (full) return true
        // search for random until free space found (braoken up via break statement)
        while (1) {
        // a random number (between 0 and state.length – 1 == message.length – 1)
        var num = getRandom(ar[message].length)
        // if free space found break infinitive loop
        if (state.charAt(num) == “0″)
        break
        }
        // replace the 0 character with 1 character at place found
        state = state.substring(0, num) + “1″ + state.substring(num + 1, state.length)
        // return false because the string was not full (free space was found)
        return false
}
function getRandom(max) {
        // create instance of current date
        var now = new Date()
        // create a random number (good generator)
        var num = now.getTime() * now.getSeconds() * Math.random()
        // cut random number to value between 0 and max – 1, inclusive
        return num % max
}
startBanner()
</script>

Kategori