Skip to content

Instantly share code, notes, and snippets.

Created June 4, 2013 15:03
Show Gist options
  • Save anonymous/5706605 to your computer and use it in GitHub Desktop.
Save anonymous/5706605 to your computer and use it in GitHub Desktop.
英語<->エンテ・イスラ語変換

inputのテキストエリアに英語を入力するとエンテ・イスラ語に、エンテ・イスラ語を入力すると英語に変換

<!DOCTYPE html>
<meta charset="utf-8">
<style>
body { background-color: #edf; }
div { float: left; padding: 10px; }
textarea { font-size: 14pt; }
</style>
<script>
var eng = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
var ente = "AZYXEWVTISRLPNOMQKJHUGFDCBazyxewvtisrlpnomqkjhugfdcb";
var $ = document.getElementById.bind(document);
function translate () {
$("out").value = $("in").value.replace(/./g, function (c) {
var p = eng.indexOf(c);
return p < 0 ? c : ente[p];
});
}
function init () {
$("in").addEventListener("paste", translate);
$("in").addEventListener("keyup", translate);
$("in").focus();
}
</script>
<body onload="init()">
<span style="font-family: monospace;">英語 :ABCDEFGHIJKLMNOPQRSTUVWXYZ</span><br>
<span style="font-family: monospace;">エンテ:AZYXEWVTISRLPNOMQKJHUGFDCB</span><br>
<div>input<br><textarea id="in" rows="5" cols="40"></textarea></div>
<div>output<br><textarea id="out" rows="5" cols="40"></textarea></div>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment