/** * @file: translator.js.php * @description: translator javascript * @copyright: sellturnkey.com **/ var ms = true; var bingAppId = '6E1096F30E370EB3DF5CA1F01F768BB2C71F0B31'; var sayItType= 'google'; //check submitted data function checkQuickData () { document.getElementById("translate_info").style.display = "none"; var fromTo = getQuickTo (); var temp = fromTo.split (":"); from = temp[0]; to = temp[1]; var text = getQuickText (); text = text.substr (0, 1000); if (to == '') { alert ("Error: please select target language!"); document.getElementById("form-to").focus (); return false; } if (text == '') { return false; } //google getTranslated (text, from, to, "translate_result"); document.getElementById("branding").style.display = "block"; //microsoft if (ms) { if (from == "xx") from = "xx"; if (from == "zh-CN") from = "zh-CHS" if (to == "zh-CN") to = "zh-CHS" if (from == "zh-TW") from = "zh-CHT" if (to == "zh-TW") to = "zh-CHT" if (from == "iw") from = "he" if (to == "iw") to = "he" getTranslatedMS (text, from, to, "translate_result_ms"); document.getElementById("brandingms").style.display = "block"; } return false; } //waiting for translation Waiting = { interval : 1000, lastKeypress : null, interceptKeypress : function() { this.lastKeypress = new Date().getTime(); var that = this; setTimeout(function() { var currentTime = new Date().getTime(); if(currentTime - that.lastKeypress > that.interval) { that.sendRequest(); } }, that.interval + 100); }, sendRequest : function() { checkQuickData (); } }