<!doctype html>
<head>
<meta charset="utf-8">
<title>Thesaurus Search via Yql - RJM Programming - 2014</title>
<link href='//www.rjmprogramming.com.au/PHP/emboss_h1.css' rel='stylesheet' type='text/css'>
<script type='text/javascript'>
window.onload = initAll;
var myxhr = false;
var url = "";
var dprefix = "http://www.thefreedictionary.com/";
var gt=null;
var iother=0;
function gtlook() {
if (gt != null) {
//var y = (gt.contentWindow || gt.contentDocument);
//if (y.document) { y = y.document; }
alert(gt.document.body.innerHTML.length);
}
gt.close();
gt=null;
}
function onblurdo() {
//url='./yql_thesaurus.php?language=' + document.getElementById('language').value + '&selname=' + this.value;
url = "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20thesaurus%20where%20key%3D%225r3uguAhHMoAQJIlShGL%22%20and%20word%3D%22" + document.getElementById('selname').value.replace(/ /g,'%20') + "%22%20and%20language%3D%22" + document.getElementById('language').value + "%22&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=";
if (document.getElementById('language').value == "fr_FR") dprefix = "http://www.systranet.com/dictionary/fr-en/";
if (document.getElementById('language').value == "de_DE") dprefix = "http://www.dict.cc/?s=";
if (document.getElementById('language').value == "es_ES") dprefix = "http://www.wordreference.com/es/en/translation.asp?spen=";
if (document.getElementById('language').value == "it_IT") dprefix = "http://www.wordreference.com/iten/";
//var omif=document.getElementById('mif');
//omif.src = url;
//omif.style.display='block';
if (myxhr) {
//console.log("prehere");
myxhr.onreadystatechange = setThesaurusWords;
myxhr.open("GET", url, true);
myxhr.send(null);
} else {
alert("Not able to create XMLHttpRequest ... sadly.");
}
}
function onblurd2() {
if (1 == 1) {
var lng=document.getElementById('language').value;
var si2=document.getElementById('selnam2').value;
var ln2=document.getElementById('languag2').value;
var sis=document.getElementById('selname').value;
if (si2 != '') {
if (27 == 78) { setTimeout(gtlook, 5000); gt=window.open('https://translate.google.com/#' + ln2.substring(0,2) + '/' + lng.substring(0,2) + '/' + encodeURIComponent(si2), si2, 'left=100,top=100,width=100,height=100'); }
if (23==23) {
document.getElementById('mif').style.display='block';
document.getElementById('mif').src='./yql_thesaurus.php?language=' + lng + '&languag2=' + ln2 + '&selname=&selnam2=' + si2;
}
}
if (sis != '') { window.open('./yql_thesaurus.php?language=' + lng + '&selname=' + sis, 'mif'); }
} else if (1 == 7) {
//url='./yql_thesaurus.php?language=' + document.getElementById('language').value + '&selname=' + this.value;
url = "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20thesaurus%20where%20key%3D%225r3uguAhHMoAQJIlShGL%22%20and%20word%3D%22" + document.getElementById('selnam2').value.replace(/ /g,'%20') + "%22%20and%20language%3D%22" + document.getElementById('languag2').value + "%22&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=";
if (document.getElementById('languag2').value == "fr_FR") dprefix = "http://www.systranet.com/dictionary/fr-en/";
if (document.getElementById('languag2').value == "de_DE") dprefix = "http://www.dict.cc/?s=";
if (document.getElementById('languag2').value == "es_ES") dprefix = "http://www.wordreference.com/es/en/translation.asp?spen=";
if (document.getElementById('languag2').value == "it_IT") dprefix = "http://www.wordreference.com/iten/";
//var omif=document.getElementById('mif');
//omif.src = url;
//omif.style.display='block';
if (myxhr) {
//console.log("prehere");
myxhr.onreadystatechange = setThesaurusWords;
myxhr.open("GET", url, true);
myxhr.send(null);
} else {
alert("Not able to create XMLHttpRequest ... sadly.");
}
}
}
function initAll() {
document.getElementById("selname").onblur = onblurdo;
document.getElementById("selnam2").onblur = onblurd2;
if (window.XMLHttpRequest) {
myxhr = new window.XMLHttpRequest;
}
else {
try {
myxhr = new ActiveXObject("Msxml2.XMLHTTP");
} catch (othermicrosoft) {
try {
myxhr = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
myxhr = false;
}
}
}
checkget();
}
function setThesaurusWords() {
var i, ii, myline, mywords, preword, mylist, endbit="", secgotest;
if (myxhr.readyState == 4) {
if (myxhr.status == 200) {
//console.log("here");
if (myxhr.responseText) {
mylist = myxhr.responseText.split('"synonyms":"');
secgotest = document.body.innerHTML.split("<br><div ");
if (secgotest.length > 1) {
document.body.innerHTML = secgotest[0];
}
endbit = endbit + "<br><div align='center' id='mydiv'><table style='border:8px blue solid;' border=5 cellspacing=8 cellpadding=8><thead><tr><th>Similar Meaning</th><th>Opposite Meaning</th></tr><tbody>";
for (i=1; i<mylist.length; i++) {
myline = mylist[i].split('"');
mywords = myline[0].split("|");
for (ii=0; ii<mywords.length; ii++) {
preword = mywords[ii].split(" (");
if (mywords[ii].indexOf(" (antonym)") !== -1) {
endbit = endbit + "<tr><td style='background-color:white;'></td><td style='background-color:white;'><a style='text-decoration:none;' target=_blank title='" + mywords[ii].replace(" (antonym)", "") + "' href='" + dprefix + preword[0].replace(" (antonym)", "") + "'>" + mywords[ii].replace(" (antonym)", "") + "</a></td></tr>";
} else {
endbit = endbit + "<tr><td style='background-color:white;'><a style='text-decoration:none;' target=_blank title='" + mywords[ii].replace(" (antonym)", "") + "' href='" + dprefix + preword[0].replace(" (antonym)", "") + "'>" + mywords[ii].replace(" (antonym)", "") + "</a></td><td style='background-color:white;'></td></tr>";
}
}
}
endbit = endbit + "</tbody></table></div>";
document.body.innerHTML = document.body.innerHTML + endbit;
}
} //else {
//console.log("Problem: " + myxhr.status);
//alert("Problem: " + myxhr.status);
//}
}
}
function checkget() {
var startwith = location.search.split('startwith=')[1] ? location.search.split('startwith=')[1].split('&')[0] : "";
if (startwith != "") {
var workedstr=decodeURIComponent(startwith);
var wstr=workedstr.toLowerCase().replace("+", " ").replace("+", " ").replace("+", " ").replace("+", " ").replace("+", " ").replace("+", " ").replace("+", " ").replace("+", " ").replace("+", " ").replace("+", " ");
document.getElementById('selname').value=wstr;
//document.getElementById('myform').submit();
//document.body.click();
onblurdo();
}
}
</script>
</head>
<body align='center' style=" background-color: cyan;" onclick=" if (iother == 0) { var lng=document.getElementById('language').value; var si2=document.getElementById('selnam2').value; var ln2=document.getElementById('languag2').value; var sis=document.getElementById('selname').value; if (si2 != '') { if (27 == 78) { setTimeout(gtlook, 5000); gt=window.open('https://translate.google.com/#' + ln2.substring(0,2) + '/' + lng.substring(0,2) + '/' + encodeURIComponent(si2), si2, 'left=100,top=100,width=100,height=100'); } if (23==23) { window.open('./yql_thesaurus.php?language=' + lng + '&languag2=' + ln2 + '&selname=&selnam2=' + si2, 'mif'); } } if (si2 != '') { sis=document.getElementById('selname').value; } if (sis != '') { window.open('./yql_thesaurus.php?language=' + lng + '&selname=' + sis, 'mif'); } } iother=0; ">
<br><h1 align='center'> Thesaurus Search</h1>
<div align='center'>
<form id="myform" method="POST" style=" background-color: lightgray;" action="#">
<br> <select onclick=" iother=1; var ii=1; " onchange=" document.getElementById('span2').innerHTML=this.value.replace('es_ES','Spanish').replace('fr_FR','French').replace('de_DE','German').replace('en_US','English').replace('it_IT','Italian') + ' Word to Translate to ' + document.getElementById('language').value.replace('es_ES','Spanish').replace('fr_FR','French').replace('de_DE','German').replace('en_US','English').replace('it_IT','Italian') + ':'; " onclick=" iother=3; var i=1;" id="language" name="language"><option value="en_US">English</option><option value="es_ES">Spanish</option><option value="de_DE">German</option><option value="fr_FR">French</option><option value="it_IT">Italian</option></select> <i>Thesaurus</i> Search: <input style=" background-color: yellow;" type="text" onclick=" iother=5; this.value=''; document.getElementById('selnam2').value=''; document.getElementById('aselname').innerHTML=''; " name="selname" id="selname" onblur=" onblurdo(); " /> <a target=_blank href="#" title="lookup" id="aselname"></a><br>
<br> <select onclick=" iother=2; var ii=1; " onchange=" document.getElementById('span2').style.display='inline'; document.getElementById('selnam2').style.display='inline'; document.getElementById('span2').innerHTML=this.value.replace('es_ES','Spanish').replace('fr_FR','French').replace('de_DE','German').replace('en_US','English').replace('it_IT','Italian') + ' Word to Translate to ' + document.getElementById('language').value.replace('es_ES','Spanish').replace('fr_FR','French').replace('de_DE','German').replace('en_US','English').replace('it_IT','Italian') + ':'; document.getElementById('selnam2').focus(); " onclick="iother=4; var i=1;" id="languag2" name="languag2"><option value="">But know the word in ...</option><option value="en_US">English</option><option value="es_ES">Spanish</option><option value="de_DE">German</option><option value="fr_FR">French</option><option value="it_IT">Italian</option></select> <span id='span2' style='display:none;'><i>Thesaurus</i> Search:</span> <input style="display:none; background-color: yellow;" type="text" onclick=" iother=6; this.value=''; document.getElementById('aselname').innerHTML=''; document.getElementById('selname').value=''; " name="selnam2" id="selnam2" onblur=" onblurd2(); " /><br><br>
<p name="info" id="info">... Results go below ...</p><br><iframe id="mif" src="javascript:false;" style="display:none; width:100%; height:900px; background-color: lightgreen;"></iframe>
</form>
</div>
<script>
var ua = navigator.userAgent;
var isiPad = /iPad/i.test(ua) || /iPhone OS 3_1_2/i.test(ua) || /iPhone OS 3_2_2/i.test(ua);
if (isiPad) {
document.getElementById('myform').innerHTML = document.getElementById('myform').innerHTML.replace("best to tab or click/touch out", "best to finish with keyboard button, not Go button");
}
</script>
</body>
</html>