Capitals in Greek with accents

by GiorgosK

HTML

<div class="container">
  <h4>Without <code>lang</code> attribute:</h4>
  <p class="caps">ένα</p>

  <h4>With <code>lang</code> attribute:</h4>
  <p lang="el" class="caps">ένα</p>

  <div lang="el">
    <div>
      <h4>With <code>lang</code> attribute in ancestor:</h4>
      <p class="caps">ένα</p>
    </div>
  </div>

  <div class="caps">
    <div>
      <h4>Without <code>lang</code> attribute and caps applied in ancestor:</h4>
      <p>ένα</p>
    </div>
  </div>

  <div lang="el" class="caps">
    <div>
      <h4>With <code>lang</code> attribute and caps applied in ancestor:</h4>
      <p>ένα</p>
    </div>
  </div>

</div>

CSS

.caps {
  text-transform: uppercase;
}

JavaScript

replaceAccented();
	function replaceAccented(){
    var e = document.getElementsByTagName('*'), l = e.length, i;
    if( typeof getComputedStyle == "undefined")
        getComputedStyle = function(e) {return e.currentStyle;};
    for( i=0; i<l; i++) {
        if( getComputedStyle(e[i]).textTransform == "uppercase") {
            // do stuff with e[i] here.
            e[i].innerHTML = greekReplaceAccented(e[i].innerHTML);
        }
    }
  }
	function greekReplaceAccented(str) {
		var charList = {'Ά':'Α','ά':'α','Έ':'Ε','έ':'ε','Ή':'Η','ή':'η','Ί':'Ι','ί':'ι','ΐ':'ϊ','Ό':'Ο'
    								,'ό':'ο','Ύ':'Υ','ύ':'υ','ΰ':'ϋ','Ώ':'Ω','ώ':'ω','ς':'Σ' 
		};
		return str.replace(/./g, function(c) {return c in charList? charList[c] : c}) ;
	}

	function greekUppercase(str) {
		var charList = {'α':'Α', 'β':'Β', 'γ':'Γ', 'δ':'Δ', 'ε':'Ε', 'ζ':'Ζ', 'η':'Η', 'θ':'Θ', 'ι':'Ι', 'κ':'Κ', 'λ':'Λ', 'μ':'Μ',
						'ν':'Ν', 'ξ':'Ξ', 'ο':'Ο', 'π':'Π', 'ρ':'Ρ', 'σ':'Σ', 'τ':'Τ', 'υ':'Υ', 'φ':'Φ', 'χ':'Χ', 'ψ':'Ψ', 'ω':'Ω', 
						'ς':'Σ', 'ά':'Α', 'έ':'Ε', 'ή':'Η', 'ί':'Ι', 'ό':'Ο', 'ύ':'Υ', 'ώ':'Ω', 'ϊ':'Ϊ', 'ϋ':'Ϋ', 'ΐ':'Ϊ', 'ΰ':'Ϋ', 
		};
		return str.replace(/./g, function(c) {return c in charList? charList[c] : c}) ;
	}