Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

708 lines (570 sloc) 15.477 kb
<html>
<link rel="search" type="application/opensearchdescription+xml" title="Red" href="RedSearchPlugin.xml">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<script type="text/javascript">
//////////////////
// Global vars
///////////////////
var matchedKeyword = "";
// set by showLeftMenu
var keyword;
var query;
// Set by leftFrame
var searchSessionId = "";
String.prototype.startsWith = function(str)
{return (this.match("^"+str)==str)}
function getXMLHttpRequest()
{
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
else
{
// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
}
// give the query from window.location i.e. current url
// returns "" if no query found
function getQuery()
{
var locationStr = String(window.location);
var hashLocation = locationStr.indexOf("#");
if (hashLocation != -1)
{
var anchorPart = locationStr.substr(hashLocation + 1);
var query = anchorPart;
return query;
}
else
{
return "";
}
}
// checks if query contains any keyword from keywordsArray
// it will return match if query contains # befor any word
function containsKeyword(query, keywordsArray)
{
var len = keywordsArray.length;
query = unescape(query);
// replace spaces(" ") with "+" for easy split
// TODO: Fix bug...
// Replaces only one instanc of space
// replace all
query = query.replace(" ", "+");
query = query.replace(" ", "+");
query = query.replace(" ", "+");
var queryParts = query.split("+");
for (var j=0;j<queryParts.length;j++)
{
var queryPart = queryParts[j];
if (queryPart.startsWith("#"))
{
// match found
// removing #
matchedKeyword = queryPart.substr(1, queryPart.length - 1);
return true;
}
}
for (var i=0;i<len;i++)
{
var keyword = keywordsArray[i];
for (var j=0;j<queryParts.length;j++)
{
var queryPart = queryParts[j];
if (queryPart == keyword)
{
matchedKeyword = queryPart;
// match found
return true;
}
}
}
return false;
}
function getCookie(c_name)
{
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name + "=");
if (c_start!=-1)
{
c_start=c_start + c_name.length+1;
c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1) c_end=document.cookie.length;
return unescape(document.cookie.substring(c_start,c_end));
}
}
return "";
}
function getKeywordsArrayLocal()
{
var username = getCookie("username");
var keywordsStr = localStorage.getItem(username+".keywords", "");
if (keywordsStr != null)
{
var keywords = keywordsStr.split(",");
}
else
{
//alert("no keywords");
return null;
}
return keywords;
}
function setKeywordsArrayLocal(keywords)
{
var username = getCookie("username");
localStorage.setItem(username+".keywords", keywords);
localStorage.setItem(username+".lastUpdateDateTime", new Date());
}
function needKeywordsUpdate()
{
var username = getCookie("username");
var lastUpdateDateTimeStr = localStorage.getItem(username+".lastUpdateDateTime");
if (lastUpdateDateTimeStr == null)
{
var lastUpdateDateTime = new Date(0);
}
else
{
var lastUpdateDateTime = new Date(lastUpdateDateTimeStr);
}
var currentDateTime = new Date();
var noOfDaysToExpire = 1;
var millisInDay = 86400000;
var refreshDateTime = new Date(lastUpdateDateTime.getTime() + (noOfDaysToExpire * millisInDay));
if (currentDateTime > refreshDateTime)
{
// needs refresh
return true;
}
else if(String(window.location).indexOf("update=f") != -1)
{
return true;
}
return false;
}
// synchrounous http call
// wait for it
function updateKeywordsArray()
{
var xmlhttp = getXMLHttpRequest();
/*
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{
// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
*/
// making the call syncronous
xmlhttp.open("GET","keywords.php?action=enlist",false); // false
xmlhttp.send(null);
var lines = xmlhttp.responseText.split("\n");
var keywords = new Array();
for (var i=0;i<lines.length;i++)
{
var line = lines[i];
if (line.length > 0)
{
keywords.push(line);
}
}
setKeywordsArrayLocal(keywords);
return keywords;
}
function getKeywordsArray()
{
var keywords = getKeywordsArrayLocal();
if (getKeywordsArrayLocal() == null)
{
keywords = updateKeywordsArray();
}
else if (needKeywordsUpdate())
{
keywords = updateKeywordsArray();
}
return keywords;
}
function getDefaultSearchEngineUrl()
{
//return "http://www.google.com/search?q=" + "{searchTerms}";
return "testSearchPage.htm?q=" + "{searchTerms}";
}
function checkUrlForAnchor()
{
if (this.url == (window.location + ""))
{
return;
}
else
{
this.url = window.location + "";
}
var searchFrame = document.getElementById("searchFrame");
var query = getQuery();
if (query != "")
{
// if query contains hot keywords
// then use custom search page otherwise forward to default search engine
var keywordsArray = getKeywordsArray();
if ( containsKeyword(query, keywordsArray) )
{
//var searchUrl = "http://www.google.com/search?q=" + query;
var searchUrl = "testSearchPage.htm?q=" + query;
// For version 1.0 only google search will be supported as default search
searchFrame.src = searchUrl;
showLeftMenu(matchedKeyword, query);
}
else
{
var searchUrl = getDefaultSearchEngineUrl();
// following timeOut is used so that user is redirected to search engine from where user can click
// back button to come back to this page
setTimeout(function(url){window.location=url},1, searchUrl.replace("{searchTerms}", query));
}
}
else
{
//searchFrame.src = "http://www.google.com/";
searchFrame.src = "testSearchPage.htm";
showLeftMenu("");
}
}
function loaded()
{
checkUrlForAnchor();
// following check is added to track changes in anchor (after #) part of
// the url
// Changes in anchor does no cause page reload so it is important to check anchor regularly for any changes
setInterval('checkUrlForAnchor()',100);
}
function getBrowser()
{
var userAgent = navigator.userAgent.toLowerCase();
// assumed default
if (userAgent.indexOf('firefox') > -1)
{
return "firefox";
}
else if (userAgent.indexOf('chrome') > -1)
{
return "chrome";
}
else if (userAgent.indexOf('safari') > -1)
{
return "safari";
}
else if (userAgent.indexOf('msie') > -1)
{
return "ie";
}
}
function showDebug(msg)
{
//document.title = msg;
// var debugText = document.getElementById("debugText");
//debugText.innerHTML = msg;
}
////////////////
// For Chrome which doesn't seem to support drop
////////////////
var dropTrackerId=-1;
var curDropX, curDropY;
function dropTracker()
{
var overlayDropText = document.getElementById("overlayDropText");
if (overlayDropText.value != "")
{
clearInterval(dropTrackerId);
dropTrackerId = -1;
var url = overlayDropText.value;
overlayDropText.value = "";
linkDropped(curDropX, curDropY, url);
}
}
function overlayDropTextDragEnter(event)
{
curDropX = event.clientX;
curDropY = event.clientY;
linkEnter(curDropX, curDropY);
linkDragging(curDropX, curDropY);
if (getBrowser() == "chrome" && dropTrackerId == -1)
{
dropTracker();
dropTrackerId = setInterval(dropTracker, 20);
}
}
function overlayDropTextDragOver(event)
{
curDropX = event.clientX;
curDropY = event.clientY;
linkDragging(curDropX, curDropY);
}
function overlayDropTextDragLeave(event)
{
if (dropTrackerId != -1)
{
clearInterval(dropTrackerId);
dropTrackerId = -1;
}
linkExit();
}
///////////////
// Not used for now
// Will be used in future if decided to use ondrop
// but ondrop does not work in chrome
function overlayDropTextDragdrop(event)
{
var overlayDropText = document.getElementById("overlayDropText");
var url = overlayDropText.value;
overlayDropText.value = "";
linkDropped(event.clientX, event.clientY, url);
}
function hideOverlayText()
{
var overlayDropText = document.getElementById("overlayDropText");
overlayDropText.style.visibility = 'hidden';
}
function showOverlayText()
{
var overlayDropText = document.getElementById("overlayDropText");
overlayDropText.style.visibility = 'visible';
}
//////////////////////////////////
// Following functions will be called
// at appropriate times
//////////////////////////////////
linkEnterEventHandler = function(){};
linkDraggingEventHandler = function(){};
linkExitEventHandler = function(){};
linkDroppedEventHandler = function(){};
var xOffset;
var yOffset;
function linkEnter(x, y)
{
xOffset = document.getElementById("dummy").offsetLeft;
yOffset = document.getElementById("dummy").offsetTop;
//document.title = "Enter";
linkEnterEventHandler(x, y);
}
function linkDragging(x, y)
{
x = x - xOffset;
y = y - yOffset;
showDebug(x +","+y);
linkDraggingEventHandler(x, y);
}
function linkExit()
{
document.title = "Exit";
linkExitEventHandler();
}
function linkDropped(x, y, url)
{
x = x - xOffset;
y = y - yOffset;
linkDroppedEventHandler(x, y, url);
}
function getTargetFrame()
{
return "searchFrame";
}
</script>
<style>
*{margin:0px;padding:0px;}
table,td,tr{padding:0px;margin:0px;}
body{width:100%;height:100%;font:80% helvetica, arial, sans-serif;}
#bodyDiv{width:100%;height:100%;}
#topTable{width:100%;height:100%;border:0px;padding:0px;border-spacing:0px;}
#topTable tr{border:2px solid;}
#lefttd{width:250px;}
#righttd{}
#searchFrame{width:100%;height:100%;border:0px;z-index:10;}
#leftDiv{position:relative;width:100%;height:100%;background-image:url('img/backBar.gif');text-align:left;vertical-align:top;}
*{z-index:0;}
#overlayDropText{position:absolute;z-index:3;left:0px;top:0px;border:0px;width:100%;height:100%;background-color:transparent;color:transparent;font-size:0px;cursor:default;}
#leftDivContent{position:relative;width:100%;height:100%;}
#leftDivContent table{width:100%;height:100%;border-spacing:0px;}
#debugText{}
#leftDivFrame{position:absolute;top:0px;left:0px;border:0px;width:100%;height:100%;z-index:0;overflow-x:hidden;}
#leftLogo{display:block;margin:0px;}
#leftLogo a {text-deoration:none;}
#leftLogo a img{border:0px;width:25px;height:25px;}
#titleAndQuery{display:inline;}
#pageTitle{font-size:120%;font-weight:bold;color:#313131;}
#restQuery{font-size:70%;color:#515151;}
#commonLinks{padding:5px;height:20px;}
#commonLinks span{display:inline;border:1px solid;}
#commonLinksFrame{border:0px;width:100%;height:100%;}
#sessionNav{font-size:70%;text-align:center;}
#shadowLeftDivContent{display:none;}
</style>
</head>
<body onload="alert'loaded'()">
<div id="bodyDiv">
<table id="topTable">
<tr>
<td id="lefttd">
<div id="leftDiv" onmouseover="hideOverlayText()" onmouseout="showOverlayText()">
<div id="leftDivContent">
<table>
<tr style="height:20px;">
<td>
<table border=0>
<tr>
<td style="width:35px;height:35px;margin:0px;vertical-align:middle;text-align:center;">
<span id="leftLogo">
<a href="index.php">
<img src="img/logo.png" />
</a>
</span>
</td>
<td>
<span id="pageTitle">
<!--{pageTitle}-->
</span>
<br />
<span id="restQuery">
<!--{restQuery}-->
</span>
</td>
</tr>
<tr>
<td colspan=3>
<div id="commonLinks">
<!--{commonLinks}-->
<iframe id="commonLinksFrame" src="about:blank"></iframe>
</div>
</td>
</tr>
<tr>
<td colspan=3>
<div id="sessionNav">
<a href="#" style="float:left;" onclick="prevSession();return false;">&lt;&lt;Prev</a>
<span style="font-weight:bold;">Session</span>
<a href="#" style="float:right;" onclick="nextSession();return false;">Next&gt;&gt;</a>
</div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<div id="dummy" style="position:relative;top:0px;left:0px;width:100%;height:100%;">
<input id="overlayDropText" type="text" value="" />
<!-- Following nbsp is a hack to make drag drop work in chrome -->
&nbsp;
<iframe id="leftDivFrame" src="about:blank"></iframe>
</div>
</td>
</tr>
</table>
</div>
</div>
</td>
<td id="righttd"><iframe name="searchFrame" id="searchFrame" src="about:blank"></iframe></td>
</tr>
</table>
</div>
</body>
<script>
var shadowLeftDivContentHTML = document.getElementById("leftDivContent").innerHTML;
function setSidebarTitle(title)
{
var titleDiv = document.getElementById("pageTitle");
titleDiv.innerHTML = "#"+title;
}
function setRestQuery(value)
{
var restQueryDiv = document.getElementById("restQuery");
if (value != null)
{
restQueryDiv.innerHTML = unescape(value);
}
}
function setCommonLinksFrameSrc(url)
{
var commonLinksFrame = document.getElementById("commonLinksFrame");
commonLinksFrame.src = url;
}
function setSessionNavigation()
{
}
function setLeftFrameSrc(frameUrl)
{
var leftFrame = document.getElementById("leftDivFrame");
leftFrame.src = frameUrl;
}
function showLeftMenu(keyword, query)
{
// set global var
window.keyword = keyword;
window.query = query;
// get session Id for this keyword and query
var xmlhttp = getXMLHttpRequest();
xmlhttp.onreadystatechange=function()
{
//alert(xmlhttp.readyState+","+xmlhttp.responseText);
if (xmlhttp.readyState==4) // && xmlhttp.status==200)
{
// set session id in hidden input variable
//alert(xmlhttp.responseText);
}
}
// making asyncronous call
xmlhttp.open("GET", "session.php?action=getSessionByKeyword&keyword="+keyword+"&query="+query, true); // false
xmlhttp.send(null);
if (keyword == "")
{
setSidebarTitle("[Home]");
setRestQuery(query);
var frameUrl = "leftFrame.php?keyword="+keyword+"&query="+query;
setLeftFrameSrc(frameUrl);
setCommonLinksFrameSrc("commonLinks.php?keyword="+keyword);
}
else
{
setSidebarTitle(keyword);
setRestQuery(query);
var frameUrl = "leftFrame.php?keyword="+keyword+"&query="+query;
setLeftFrameSrc(frameUrl);
setCommonLinksFrameSrc("commonLinks.php?keyword="+keyword);
}
var overlayDropText = document.getElementById("overlayDropText");
overlayDropText.ondragenter=overlayDropTextDragEnter;
overlayDropText.ondragover=overlayDropTextDragOver;
overlayDropText.ondragleave=overlayDropTextDragLeave;
/////////////
// Firefox supports ondrop
// but used for clearing interval i.e. clearing tracker which checks if drop is completed
overlayDropText.ondrop=overlayDropTextDragdrop;
}
function prevSession()
{
// alert("Previus session");
// setCommonLinksFrameSrc("commonLinks.php?keyword=");
var frameUrl = "leftFrame.php?keyword="+keyword+"&query="+query+"&searchSessionId="+searchSessionId+"&navigateTo="+"prev";
setLeftFrameSrc(frameUrl);
}
function nextSession()
{
var frameUrl = "leftFrame.php?keyword="+keyword+"&query="+query+"&searchSessionId="+searchSessionId+"&navigateTo="+"next";
setLeftFrameSrc(frameUrl);
}
////////////////
// Calling loaded here since
// waiting for body.onLoad will make us
// wait for iframes
////////////////
loaded();
</script>
</html>
Jump to Line
Something went wrong with that request. Please try again.