Created
December 6, 2015 16:20
-
-
Save nootanghimire/057304932c6a18e94e4d 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
var url = "https://mozilla-nepal.org/translation-helper-pootle/translate.php?string="; | |
document.onclick = function (e) { | |
var elem, evt = e ? e:event; | |
if (evt.srcElement) elem = evt.srcElement; | |
else if (evt.target) elem = evt.target; | |
if(elem.nodeName == "INPUT" || elem.nodeName == "TEXTAREA") { | |
var s = (elem.getAttribute("id")); | |
s = s.split('_')[1]; | |
var strUntranslated = document.getElementById("msgset_"+s+"_singular").textContent; | |
//console.log(strUntranslated); | |
var xhttp = new XMLHttpRequest(); | |
xhttp.onreadystatechange = function() { | |
if (xhttp.readyState == 4 && xhttp.status == 200) { | |
if (elem.value==""){ | |
elem.value=xhttp.responseText; | |
} | |
} | |
} | |
//text = text.replace(/&/g, ""); | |
xhttp.open("GET", url+strUntranslated, true); | |
console.log(url+strUntranslated); | |
xhttp.send(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment