Skip to content

Instantly share code, notes, and snippets.

@alexey-bass
Created June 29, 2010 11:39
Show Gist options
  • Save alexey-bass/457104 to your computer and use it in GitHub Desktop.
Save alexey-bass/457104 to your computer and use it in GitHub Desktop.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>GoogleD3vF3st</title>
<style type="text/css">
textarea {width: 100%;}
</style>
</head>
<body>
<div>
<textarea id="source"></textarea><br />
<textarea id="result"></textarea>
</div>
<div>
<button onclick="D3vF3st.bin2dec();">bin2dec</button>
<button onclick="D3vF3st.char2text();">char2text</button>
<button onclick="D3vF3st.switchText();">switchText</button>
<button onclick="D3vF3st.bin2dec(); D3vF3st.switchText(); D3vF3st.char2text();">bin2text</button>
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript">
D3vF3st = {
bin2dec: function()
{
var $data = $.trim($('#source').val()).split(' ')
, $result = '';
for (var $i = 0; $i < $data.length; $i++)
$result += parseInt($data[$i], 2) + ' ';
$('#result').val($result);
},
char2text: function()
{
var $data = $.trim($('#source').val()).split(' ')
, $result = '';
for (var $i = 0; $i < $data.length; $i++)
$result += String.fromCharCode($data[$i]);
$('#result').val($result);
},
switchText: function()
{
$('#source').val($('#result').val());
}
};
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment