inputのテキストエリアに英語を入力するとエンテ・イスラ語に、エンテ・イスラ語を入力すると英語に変換
Created
June 4, 2013 15:03
-
-
Save anonymous/5706605 to your computer and use it in GitHub Desktop.
英語<->エンテ・イスラ語変換
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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