Created
May 4, 2012 04:26
-
-
Save luizfonseca/2592017 to your computer and use it in GitHub Desktop.
Don't ask me why I made this.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/> | |
<title>LOL JavaScript</title> | |
<script type="text/javascript" language="javascript" charset="utf-8"> | |
//<![CDATA[ | |
LOL = { | |
showMeYourBin: function(string){ | |
var b = new Array(); | |
var last = string.length; | |
for (var i = 0; i < last; i++){ | |
var d = string.charCodeAt(i); | |
if (d < 128){ | |
b[i] = LOL.decimal2Bin(d); | |
} else { | |
var c = string.charAt(i); | |
alert( "Ops, " + c + " is not a valid ASCII character :(." ); | |
} | |
} | |
return b; | |
}, | |
decimal2Bin: function(dec){ | |
var b = ''; | |
for (var i = 0; i < 8; i++){ | |
b = ( dec % 2 ) + b; | |
dec = Math.floor( dec / 2); | |
} | |
return b; | |
}, | |
bin2Decimal: function(bin){ | |
var binary = parseInt(bin, 2); | |
var decimal = binary.toString(10); | |
return decimal; | |
}, | |
makeFun: function(val){ | |
console.log(val); | |
console.log(LOL.showMeYourBin(val)); | |
var damn = LOL.showMeYourBin(val); | |
var final_str = new Array(); | |
var result = new Array(); | |
// proposital name :D | |
for (var i = 0; i < damn.length; i++){ | |
var tmp_str = damn[i].split(""); | |
for (var j = 0; j < tmp_str.length; j++){ | |
if (tmp_str[j] == 0) { | |
final_str[j] = "[+[]]"; | |
} | |
else if (tmp_str[j] == 1){ | |
final_str[j] = "(++[[]][+[]])"; | |
} | |
} | |
result[i] = final_str.join("+"); | |
} | |
if (result.length){ | |
var target = document.getElementById("result"); | |
target.innerHTML = "Here is your result (write it down! :D): <div class='look'>" + result.join('+') + "</div>"; | |
} | |
}, | |
messWithTheFun: function(str){ | |
var wtf = str.toString().trim(); | |
var bla = eval(wtf); | |
console.log(bla.split()); | |
} | |
} | |
//]]> | |
</script> | |
</head> | |
<body> | |
<header> | |
<h1>Just a LOL javascript test :D</h1> | |
</header> | |
<section> | |
<form action="" method="post" accept-charset="utf-8" onsubmit="return false;"> | |
<input type="text" name="str" value="" placeholder="Put your text here" id="str"/> | |
<p><input type="submit" value="Continue →" onclick="LOL.makeFun(document.getElementById('str').value)"/></p> | |
</form> | |
<div id="result"> | |
</div> | |
<h2>Ok, you wanna know wtf they sent to you, put the strange code here:</h2> | |
<form action="action" method="post" accept-charset="utf-8" onsubmit="return false;"> | |
<input type="text" name="strto" value="" placeholder="put the strange code here" id="strto"/> | |
<p><input type="submit" value="Continue →" onclick="LOL.messWithTheFun(document.getElementById('strto').value)"/></p> | |
</form> | |
<div id="mess_result"> | |
</div> | |
</section> | |
<footer> | |
</footer> | |
</body> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment