Skip to content

Instantly share code, notes, and snippets.

@psyomn
Created September 13, 2013 18:22
Show Gist options
  • Select an option

  • Save psyomn/6554232 to your computer and use it in GitHub Desktop.

Select an option

Save psyomn/6554232 to your computer and use it in GitHub Desktop.
Silly implementation for a javascriptish Greek keyboard
<html>
<head>
<style type="text/css">
.main{
margin-top:50px;
margin-bottom:100px;
margin-left:auto;
margin-right:auto;
width:700px;
border:#DDDDDD 1px solid;
padding:15px;
text-align:center;
}
.l{
position:fixed;
top:50px;
right:10px;
width:130px;
border:#DDDDDD 1px solid;
background-color:white;
padding:15px;
font-size:12px;
}
.l2{
position:fixed;
top:160px;
right:10px;
width:130px;
border:#DDDDDD 1px solid;
background-color:white;
padding:15px;
font-size:12px;
}
.l3{
position:fixed;
top:5 0px;
left:10px;
width:130px;
border:#DDDDDD 1px solid;
background-color:white;
padding:15px;
font-size:12px;
}
h1{
text-align:center;
}
h2{
letter-spacing:15px;
font-size:17px;
color:#555555;
}
textarea{
width:500px;
height:200px;
}
</style>
<script type="text/javascript">
/****************************************************************************
* Auth: Simon Symeonidis
* Date: March 2010 (the weather is a little better . . .)
* --------------------------------------------------------------------------
* Notes: I think the code is quite straightforward, but if you have any
* questions you may give me a shout at
*
* lethaljellybean AT gmail dot com
*
* by email
*
***********************************************************.( '_')/\('_' ).*/
// The conversion array . . .
var l = new Array();
// Main letters - Letters with accents
l["a"] = "α"; l["A"] = "Α"; l[";a"] = "ά"; l[";A"] = "Ά";
l["b"] = "β"; l["B"] = "Β"; l[";e"] = "έ"; l[";E"] = "Έ";
l["c"] = "ψ"; l["C"] = "Ψ"; l[";i"] = "ί"; l[";I"] = "Ί";
l["d"] = "δ"; l["D"] = "Δ"; l[";o"] = "ό"; l[";O"] = "Ό";
l["e"] = "ε"; l["E"] = "Ε"; l[";y"] = "ύ"; l[";Y"] = "Ύ";
l["f"] = "φ"; l["F"] = "Φ"; l[";h"] = "ή"; l[";H"] = "Ή";
l["g"] = "γ"; l["G"] = "Γ"; l[";v"] = "ώ"; l[";V"] = "Ώ";
l["h"] = "η"; l["H"] = "Η"; l[";"] = ";";
l["i"] = "ι"; l["I"] = "Ι";
l["j"] = "ξ"; l["J"] = "Ξ";
l["k"] = "κ"; l["K"] = "Κ";
l["l"] = "λ"; l["L"] = "Λ";
l["m"] = "μ"; l["M"] = "Μ";
l["n"] = "ν"; l["N"] = "Ν";
l["o"] = "ο"; l["O"] = "Ο";
l["p"] = "π"; l["P"] = "Π";
l["q"] = ";"; l["Q"] = ":";
l["r"] = "ρ"; l["R"] = "Ρ";
l["s"] = "σ"; l["S"] = "Σ";
l["t"] = "τ"; l["T"] = "Τ";
l["u"] = "θ"; l["U"] = "Θ";
l["v"] = "ω"; l["V"] = "Ω";
l["w"] = "ς";
l["x"] = "χ"; l["X"] = "Χ";
l["y"] = "υ"; l["Y"] = "Υ";
l["z"] = "ζ"; l["Z"] = "Ζ";
function c(o){ // c for change
var t = o.value; // main textarea
var c = ""; // c ontainer
var d = document.getElementById('o'); // the other textarea to store results
var i = 0; // for looping
for(i=0; i<t.length; i++){
if(l[t[i]]){
if(t[i] == ";" && i+1<t.length && l[t[i]+t[i+1]]){ // time to add accent
c += l[t[i]+t[i+1]]; // t[i] = ; and t[i+1] is the letter to accent, all this converted by l[c]
i++; // ignore the capitalized letter
}
else
c += l[t[i]];
}
else
c += t[i];
}
d.value = c;
}
</script>
</head>
<body>
<div class="wrap">
<div class="l">Για τόνους, γράψετε ';' και μετά το γράμμα στα Αγγλικά. ΠΧ: ;a</div>
<div class="l2">Ευχαριστούμε που χρησιμοποιήσατε αυτήν την ιστοσελίδα!</div>
<div class="l3">Note: You will not be able to have the text in Greek if you have not got Greek support...</div>
<div class="main">
<h1> Ελληνικό Πληκτρολόγιο! </h1>
<h2> Γράψετε εδώ στα Αγγλικά! </h2>
<textarea id="i" onkeyup="c(this)"></textarea>
<h2> Αποτελέσματα </h2>
<textarea id="o"></textarea>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment