So I have 2 textareas, 1 holds the user's input, which is expected to hold emoji's, or whitespace. The second one is a read only textarea that holds the output. The purpose of this program is to take in an emoji string and convert it into a regular (text) string using a cipher in the form of a dictionary.
Javascript:
const cipher = {
"": "A",
"":"B",
"":"C",
"⚡":"D",
"":"E",
"":"F",
"":"G",
"":"H",
"":"I",
"":"J",
"":"K",
"":"L",
"":"M",
"️":"N",
"":"O",
"":"P",
"":"Q",
"":"R",
"":"S",
"":"T",
"":"U",
"":"V",
"":"W",
"":"X",
"":"Y",
"":"Z"
}
function convert(){
var input = document.getElementById("input").value;
var outputTextarea = document.getElementById("output");
var output = "";
console.clear();
for(var i = 0; i < input.length; i++){
var char = input.charAt(i);
if(char in cipher){
output += cipher[char];
}else{
output += char;
}
}
outputTextarea.value = output;
}
HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Emoji Custom Cipher</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="label-div"><label for="input">Emoji Input</label><div>
<textarea id="input"></textarea>
<br>
<br>
<button onclick="convert()">Convert</button>
<br>
<br>
<div class="label-div"><label for="output">Text Output</label><div>
<textarea id="output" readonly></textarea>
<script src="script.js"></script>
</body>
</html>
At first I was planning on having it search up the emoji using the char code, but whenever I printed out the char code it printed two things, and I ended up not being able to search it up in the cipher, but when I try to search it up via the char, it doesn't work either.