You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
1.8 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>Encoding Converter</title>
<meta charset="UTF-8">
<!-- CSS -->
<link rel="stylesheet" href="./enconv.css">
</head>
<body>
<!-- adding glitch effect to text -->
<div>
<h1>Encoding Converter</h1>
<p>Type a word, click 'convert' and let the magic begin!</p>
</div>
<!-- adding table with all encodings -->
<form>
<label for="input">Input:</label>
<input type="text" id="input" name="input" placeholder="Type a word...">
<button onclick="convert();">Convert</button>
</form>
<!-- adding table with all encodings -->
<table id="result">
<tr>
<th>Binary</th>
<th>Hexadecimal</th>
<th>Decimal</th>
<th>Cyrillic</th>
<th>Emoji</th>
</tr>
</table>
</body>
<!-- adding the js converter function -->
<script>
var d = {
'a': 'a',
'b': 'b',
'c': 'ts',
'd': 'd',
'e': 'e',
'f': 'f',
'g': 'g',
'h': 'h',
'i': 'i',
'k': 'k',
'l': 'l',
'm': 'm',
'n': 'n',
'o': 'o',
'p': 'p',
'q': 'ya',
'r': 'r',
's': 's',
't': 't',
'u': 'u',
'v': 'dzh',
'w': 'v',
'y': 'y',
'z': 'zh',
'`': 'ch',
']': 'sht',
'[': 'sh',
'|': 'yu',
}
function convert(){
event.preventDefault();
var charles = document.getElementById("input").value;
var charlesBinary="";
var charlesHex="";
var charlesDc="";
var charlesCY="";
for (var i=0;i<charles.length;i++){
console.log(i,charles.charCodeAt(i));
charlesBinary=charlesBinary+charles.charCodeAt(i).toString(2);
charlesHex=charlesHex+charles.charCodeAt(i).toString(16);
charlesDc=charlesDc+charles.charCodeAt(i).toString(10);
charlesCY=charlesCY+d[charles[i]];
}
console.log(charles,charlesBinary,charlesHex,charlesDc,charlesCY);
}
</script>
</html>