Name: Anonymous 2010-07-04 17:10
i have a meta search site using frames and want to see if any of this is useful to me. the original coder is german so suche = search etc..
/* torrents.to javascript :) */
var myConn = new XHConn();
var flashTimer = null;
var flashState = flashCount = 0;
var __tto_disable_okusearch = false;
$ = function(el){ return document.getElementById(el); }
ce = function(el){ return document.createElement(el); }
window.onload = function()
{
$("skyscraperBox").style.display = "block";
$("bannerBox").style.display = "block";
$("link").target="_blank";
dl = document.getElementsByTagName("a");
for(i in dl)
{
clnm = dl[i].className+"";
if(clnm.substring(0,12) == "target_blank")
{
dl[i].target = "_blank";
}
}
};
function sbku(ttoe)
{
if(__tto_disable_okusearch)return;
if(ttoe.keyCode == 13)
{
if(checkData())
{
setUrl($("link"));
document.location = $("link").href;
}
}
}
function rateSite(sid)
{
rating = $("rateSelect_"+sid).value;
if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.\nYou will not be able to vote:(");
var fnWhenDone = function (oXML) {
response = eval(oXML.responseText);
if(response == "ok")
{
$("rateButton_"+sid).innerHTML = "THX!";
$("rateButton_"+sid).style.fontWeight = "bolder";
$("rateButton_"+sid).href = "javascript:void(0);";
}
else
{
$("rateButton_"+sid).innerHTML = "NOPE";
$("rateButton_"+sid).style.fontWeight = "bolder";
$("rateButton_"+sid).href = "javascript:void(0);";
}
$("rateSelect_"+sid).disabled = true;
};
myConn.connect("/php/rate.php", "GET", "sid="+sid+"&rating="+rating, fnWhenDone);
}
function reportSite(sid)
{
if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.\nYou will not be able to report:(");
var fnWhenDone = function (oXML) {
response = eval(oXML.responseText);
$("reportLink_"+sid).innerHTML = "thanks for your help!";
$("reportLink_"+sid).href = "javascript:void(0);";
};
myConn.connect("/php/report.php", "GET", "sid="+sid, fnWhenDone);
}
function showSiteInfo(sid,hin,hout)
{
if(child2remove = $("rateBox_"+sid))
{
$("showRateBox_"+sid).src="/img/open.gif";
$("site_"+sid).removeChild(child2remove);
}
else
{
$("showRateBox_"+sid).src="/img/close.gif";
rateBox = ce("div");
rateBox.className = "rateBox";
rateBox.id = "rateBox_"+sid;
leftCol = ce("div");
leftCol.className = "leftCol";
hitsOut = ce("div");
hitsOut.className = "hBox";
hoTitle = ce("span");
hoTitle.innerHTML = "<img src=\"/img/hitsout.gif\" alt=\"\" />";
hoTitle.className = "hTitle";
hoCount = ce("span");
hoCount.className = "hocount";
hoCount.innerHTML = hout;
hitsOut.appendChild(hoTitle);
hitsOut.appendChild(hoCount);
hitsIn = ce("div");
hitsIn.className = "hBox";
hiTitle = ce("span");
hiTitle.innerHTML = "<img src=\"/img/hitsin.gif\" alt=\"\" />";
hiTitle.className = "hTitle";
hiCount = ce("span");
hiCount.className = "hicount";
hiCount.innerHTML = hin;
hitsIn.appendChild(hiTitle);
hitsIn.appendChild(hiCount);
leftCol.appendChild(hitsOut);
leftCol.appendChild(hitsIn);
rightCol = ce("div");
rightCol.className = "rightCol";
rateButton = ce("a");
rateButton.className = "rateLink";
rateButton.id = "rateButton_"+sid;
rateButton.innerHTML = "RATE";
rateButton.href = "javascript:rateSite("+sid+")";
rightCol.appendChild(rateButton);
rateSelect = ce("select");
rateSelect.className = "rateSelect";
rateSelect.id = "rateSelect_"+sid;
rOption0 = ce("option");
rOption0.value = "5";
rOption0.innerHTML = "awesome";
rOption1 = ce("option");
rOption1.value = "4";
rOption1.innerHTML = "nice";
rOption2 = ce("option");
rOption2.value = "3";
rOption2.innerHTML = "useful";
rOption3 = ce("option");
rOption3.value = "2";
rOption3.innerHTML = "poor";
rOption4 = ce("option");
rOption4.value = "1";
rOption4.innerHTML = "crappy";
rateSelect.appendChild(rOption0);
rateSelect.appendChild(rOption1);
rateSelect.appendChild(rOption2);
rateSelect.appendChild(rOption3);
rateSelect.appendChild(rOption4);
rightCol.appendChild(rateSelect);
tmp = ce("br");
tmp.style.clear = "both";
rightCol.appendChild(tmp);
reportLink = ce("a");
reportLink.className = "repLink";
reportLink.id = "reportLink_"+sid;
reportLink.innerHTML = "report broken link!";
reportLink.href = "javascript:reportSite("+sid+")";
rightCol.appendChild(reportLink);
rateBox.appendChild(leftCol);
rateBox.appendChild(rightCol);
tmp = ce("br");
tmp.style.clear = "both";
rateBox.appendChild(tmp);
$("site_"+sid).appendChild(rateBox);
}
}
function setUrl(a)
{
/* opera kann kein onfocus() :/ */
qy = $("suche").value;
while(qy.indexOf(" ") > -1){ qy = qy.replace(" ","+"); }
qy = escape(qy);
a.href = "http://torrents.to/search/"+ $("site").value + "/" + qy + ".html";
}
function checkData()
{
if($("suche").value.length == 0 || $("suche").value == "search torrents")
{
$("suche").value = "";
flash("suche");
return false;
}
if($("site").value == "choose")
{
flash("site");
return false;
}
return true;
}
function flash(el)
{
if(flashState == 1)
{
$(el).style.backgroundColor = "#FFF";
flashState = 0;
}
else
{
$(el).style.backgroundColor = "#F00";
flashState = 1;
}
if(flashCount == 5)
{
$(el).focus();
clearTimeout(flashTimer);
flashCount = flashState = 0;
}
else
{
flashTimer = setTimeout("flash('"+el+"')",50);
flashCount++;
}
}