Added cat translator

Who wouldn't want to talk to these adorable cat AIs?
This commit is contained in:
Pi 2023-04-02 18:59:07 -07:00 committed by GitHub
parent c79c99fb26
commit 0a5354fb1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

59
translate.html Normal file
View file

@ -0,0 +1,59 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Cat.cpp translator</title>
<style>
* {
color: black;
background: white;
}
@media (prefers-color-scheme: dark) {
* {
color: white;
background: #222;
}
}
body {
display: flex;
flex-direction: column;
align-items: center;
}
textarea {
width: 80%;
}
</style>
</head>
<body>
<p>Input</p>
<textarea id="meow" rows="10"></textarea>
<br />
<br />
<br />
<br />
<p>Output</p>
<textarea id="purr" rows="10" readonly></textarea>
<script>
function catTalksHuman(meow) {
var purr = "";
meow.split(" ").map(function (kitten) {
purr += String.fromCharCode(parseInt(kitten, 2));
});
return purr;
}
meow.addEventListener("keyup", () => {
var miao = meow.value;
miao = miao
.replaceAll(/meow ?/g, "0")
.replaceAll(/purr ?/g, "1")
.replaceAll(/~! ?/g, "");
purr.value = catTalksHuman(miao);
});
</script>
</body>
</html>