home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 2006-03-23 | 56.1 KB | 2,029 lines
var cityListXML = new Array(); var TopicBreadCrum = ""; var displayMySitesIfNoPacks = true; var PackSearcherID = "0"; // this means all Web packs except websites var SiteSearcherID = "-1"; var selectAll = true; var channelNumber = new Array(); var channelDescription = new Array(); var channelSubscriptionIDs = new Array(); var channelSubscriptionNames = new Array(); /** Our function that initializes when the page is finished loading. */ function InitRSH() { MM_preloadImages('images/webaroo_search_f2.gif','images/webaroo_contents_f2.gif','images/webaroo_prefs_f2.gif','images/webaroo_help_f2.gif'); // initialize the DHTML History framework dhtmlHistory.initialize(); // add ourselves as a DHTML History listener dhtmlHistory.addListener(HandleHistoryChange); if (dhtmlHistory.isFirstLoad()) { historyStorage.put("SearchIndex", 0); // 0 indicates everything HandleHistoryChange(window.location.href, ""); } else { GetStoredInfo(); } } function GetStoredInfo() { var searchOptionIndex = historyStorage.get("SearchIndex"); if (searchOptionIndex != null) { document.frmSearch.searchOption[searchOptionIndex].checked = true; } else { searchOptionIndex = 0; SetSearchIndex(searchOptionIndex); } var searchValue = historyStorage.get("SearchValue"); var searchName = historyStorage.get("SearchName"); if (searchValue != null) { SetAllSearchOptions(searchValue, searchName, searchOptionIndex, 0); } channelNumber = historyStorage.get("ChannelNos"); channelDescription = historyStorage.get("ChannelNames"); if (channelNumber == null) { GetChannelList(); } channelSubscriptionNames = historyStorage.get("SubscriptionNames"); channelSubscriptionIDs = historyStorage.get("SubscriptionIds"); if (channelSubscriptionNames == null) { GetSubInfo(); } } function GetSubInfo() { for(var j =0; j<channelNumber.length;j++) { if(channelNumber[j] =='-1') // ignore mysites continue; // Also get for the other channels, right now its only for channel 1 var url="/webaroo/e29f1fe6/citylist?channelid=" + channelNumber[j]; SendSynchornousRequest(url, PopulateSubInfo, j); } historyStorage.put("SubscriptionNames", channelSubscriptionNames); historyStorage.put("SubscriptionIds", channelSubscriptionIDs); } function PopulateSubInfo(cityResults, channelIndex) { var subNames = new Array(); var subIds = new Array(); cityListXML[channelIndex] = cityResults; if(!cityResults) return; var result = cityResults.getElementsByTagName('subscription'); if(result.length < 1) return; for (var j=0;j<result.length;j++) { if (result[j].nodeType != 1) continue; var subName = result[j].getAttribute("name"); subNames[j] = subName; var subId = result[j].getAttribute("id"); subIds[j] = doubleUrlEncode(subId); } if(channelSubscriptionIDs == null) // This code is for refresh on the search browse UI page { channelSubscriptionIDs = new Array(); channelSubscriptionNames = new Array(); } channelSubscriptionIDs[channelIndex] = subIds; channelSubscriptionNames[channelIndex] = subNames; } function ChangeTabDisplayMode(isShow) { var displayMode; if (isShow) { displayMode="block"; } else { displayMode="none"; } document.getElementById('browseTabs').style.display=displayMode; document.getElementById('browseTitle').style.display=displayMode; } function HighlightTab(tabName) { var tabClass = "tab" var activeClass = tabClass + " activeTab"; var packTab = document.getElementById('tabRooPack'); var siteTab = document.getElementById('tabWebSite'); if (tabName == "pack") { packTab.className = activeClass; siteTab.className = tabClass; } else { packTab.className = tabClass; siteTab.className = activeClass; } } function StoreSearchOptionIndex() { var searchOptionIndex = document.frmSearch.searchOption[0].checked ? 0 : 1; historyStorage.put("SearchIndex", searchOptionIndex); } function SetSearchIndex(searchIndex) { document.frmSearch.searchOption[searchIndex].checked = true; historyStorage.put("SearchIndex", searchIndex); } function SetSearchOptions(id, displayName, addToHistory) { SetAllSearchOptions(id, displayName, 1, addToHistory); } function SetAllSearchOptions(id, displayName, index, addToHistory) { document.getElementById('spanOnly').style.display = "inline"; document.frmSearch.searchOption[1].value = id; document.frmSearch.searchOption[index].checked = true; var onlyLabel = document.getElementById('elemOnly'); onlyLabel.innerHTML = displayName; if (addToHistory == 1) { historyStorage.put("SearchName", displayName); historyStorage.put("SearchValue", id); StoreSearchOptionIndex(); } } function GetBrowseMySiteAsynchronously(addToHistory) { displayMySitesIfNoPacks = false; // Clear the tables ClearAllTables(); if(selectAll) { document.frmSearch.searchOption[0].checked = true; selectAll = false; } ChangeTabDisplayMode(true); HighlightTab("site"); // Hide the other div block ShowDataLoading(); var url="/webaroo/e29f1fe6/browsemysites"; SendAsynchornousRequest(url, "", mySitesPopulate, ""); if (addToHistory == 1) { dhtmlHistory.add(url, ""); } } function mySitesPopulate(browseMySitesXML, data) { // Clear the tables ClearAllTables(); // Render the mysites in table browsemysitetable var tablemysite = document.getElementById('browsemysitetable'); var htmldata =''; var listObject = browseMySitesXML.getElementsByTagName('Response'); var rowkeys = new Array(); var rowvalues = new Array(); var keys = new Array(); var values = new Array(); var newRow; // Add the first Header Row keys[0] = "innerHTML"; keys[1] = "className"; values[0] = '<b>Web Sites</b>'; values[1] = "resultBoldTitle"; newRow = AddRowToTable('browsemysitetable',rowkeys ,rowvalues,keys,values); if (listObject[0].childNodes.length > 0) { keys[1] = "align"; values[0] = 'Site Name'; values[1] = "left"; newRow = AddRowToTable('browsemysitetable',rowkeys ,rowvalues,keys,values); keys[0] = "innerHTML"; keys[1] = "align"; values[0] = 'Site URL'; values[1] = "left"; AddCellToRow(newRow,keys,values); keys[0] = "innerHTML"; keys[1] = "align"; values[0] = 'Last Updated On'; values[1] = "left"; AddCellToRow(newRow,keys,values); // Add a empty Row keys[0] = "innerHTML"; keys[1] = "align"; values[0] = " "; values[1] = "left"; AddRowToTable('browsemysitetable',rowkeys ,rowvalues,keys,values); AddRowToTable('browsemysitetable',rowkeys ,rowvalues,keys,values); for (var j=0;j<listObject[0].childNodes.length;j++) { if (listObject[0].childNodes[j].nodeType != 1) continue; var siteName = listObject[0].childNodes[j].getElementsByTagName('SiteName'); var siteURL = listObject[0].childNodes[j].getElementsByTagName('Url'); var siteCachedUrl = listObject[0].childNodes[j].getElementsByTagName('CachedUrl'); var siteLastUpdatedOn = listObject[0].childNodes[j].getElementsByTagName('LastUpdated'); var siteSubscriptionId = listObject[0].childNodes[j].getElementsByTagName('Id'); var siteNameStr = siteName[0].firstChild.nodeValue; var siteURLStr = siteURL[0].firstChild.nodeValue; var siteCachedUrlStr = siteCachedUrl[0].firstChild.nodeValue; var siteLastUpdatedOnStr = siteLastUpdatedOn[0].firstChild.nodeValue; var siteSubscriptionStr = siteSubscriptionId[0].firstChild.nodeValue;; keys[0] = "innerHTML"; keys[1] = "align"; // Wrap the SiteNameStr if its more than 20 characters if(siteNameStr.length > 20) siteNameStr = TruncateString(siteNameStr,20); values[0] = siteNameStr; values[1] = "left"; newRow = AddRowToTable('browsemysitetable',rowkeys ,rowvalues,keys,values); keys[0] = "innerHTML"; keys[1] = "class"; // Wrap the SiteURLStr if its more than 80 characters if(siteURLStr.length > 70) siteURLStr = WrapString(siteURLStr,70); values[0] = '<a href="' + siteCachedUrlStr + '">' + siteURLStr+ '</a>'; values[1] = "resultLink"; AddCellToRow(newRow,keys,values); keys[0] = "innerHTML"; keys[1] = "align"; values[0] = '<font style="font-size: 10px;">' + siteLastUpdatedOnStr + '</font>'; values[1] = "left"; AddCellToRow(newRow,keys,values); // Add 2 empty Rows keys[0] = "innerHTML"; keys[1] = "align"; values[0] = " "; values[1] = "left"; AddRowToTable('browsemysitetable',rowkeys ,rowvalues,keys,values); AddRowToTable('browsemysitetable',rowkeys ,rowvalues,keys,values); } // Hide message below search box document.getElementById('NoContentMessage').style.display = "none"; } else { var rowkeys = new Array(); var rowvalues =new Array(); keys[0] = "innerHTML"; keys[1] = "align"; var url = "/webaroo/e29f1fe6/content"; values[0] = 'No Web Sites available in your library. Go to the <a href="' + url + '">Content</a> page to add a Web Site. If you have already added a Web Site, please wait for the updates to complete.'; values[1] = "left"; AddRowToTable('browsemysitetable',rowkeys ,rowvalues,keys,values); document.frmSearch.searchOption[0].checked = true; // Also show the message below search box document.getElementById('NoContentMessage').style.display = "inline"; } // Show the radio button irrespective of content status SetSearchOptions(SiteSearcherID, "Only Web Sites", 1); // Hide the other div block ShowMySite(); } function GetChannelList() { // URL is /getChannelList // XML Format // <Channel> // <number></number> // <Description></Description> // </Channel> var url="/webaroo/e29f1fe6/channellist"; processXMLData(url); var channelList = xmlContent; channelNumber = new Array(); channelDescription = new Array(); var Channel = channelList.getElementsByTagName('subscription'); if(Channel.length >0) { for (var j=0;j<Channel.length;j++) { channelNumber[j] = Channel[j].getAttribute('id'); channelDescription[j] = Channel[j].getAttribute('name'); } } // Sort the channels in numerically increasing order var tempchannelNumber = new Array(); var tempchannelDescription = new Array(); var AddedMySiteChannelFlag = false; tempchannelNumber[0] = "-1"; tempchannelDescription[0]="MySites"; for (var j=0;j<Channel.length;j++) { if(channelNumber[j]==-1) { AddedMySiteChannelFlag = true; continue; } var k = tempchannelNumber.length - 1; for(;((k >= 0) && (tempchannelNumber[k] > channelNumber[j])); k--) { tempchannelNumber[k+1] = tempchannelNumber[k]; tempchannelDescription[k+1] = tempchannelDescription[k]; } tempchannelNumber[k+1] = channelNumber[j]; tempchannelDescription[k+1] = channelDescription[j]; } // copy back to original channelNumber = tempchannelNumber; channelDescription = tempchannelDescription; historyStorage.put("ChannelNos", channelNumber); historyStorage.put("ChannelNames", channelDescription); } function GetTopicsAsynchronously(addToHistory) { // Clear tables ClearAllTables(); if(selectAll) { document.frmSearch.searchOption[0].checked = true; selectAll = false; } ChangeTabDisplayMode(true); HighlightTab("pack"); ShowDataLoading(); // First find out how many channels, user is subscribed to GetChannelList(); // Show the Web Pack title var keys = new Array(); var values = new Array(); var innertext = '<b>Web Packs</b>'; keys[0]='innerHTML'; keys[1]='className'; values[0]= innertext; values[1]='resultBoldTitle'; var rootitleelem = document.getElementById('browsetitletable'); var curRow=rootitleelem.insertRow(-1); AddCellToRow(curRow,keys,values); // put empty row values[0]= ' '; curRow=rootitleelem.insertRow(-1); AddCellToRow(curRow,keys,values); var url =""; for(var j =0; j<channelNumber.length;j++) { if(channelNumber.length ==1) { // Just make a dummy call for channel 1 url="/webaroo/e29f1fe6/citylist?channelid=1"; SendSynchornousRequest(url, topicPopulate, j); } else { if(channelNumber[j] =='-1') // ignore mysites continue; // Also get for the other channels, right now its only for channel 1 url="/webaroo/e29f1fe6/citylist?channelid=" + channelNumber[j]; SendSynchornousRequest(url, topicPopulate, j); } } if (addToHistory == 1) { dhtmlHistory.add(url, ""); } } function HandleHistoryChange(newUrl, historyData) { var currentLocation = window.location.href.split("#"); if (currentLocation[0].indexOf("/webaroo/e29f1fe6/search") == -1) { return; } var newUrlParts = newUrl.split("#"); var newLocation = (newUrlParts.length > 1) ? newUrlParts[1] : newUrlParts[0]; document.title = 'Webaroo Search'; document.frmSearch.txtSearch.value = ""; if (currentLocation.length > 1) { if (currentLocation[1] == "") { GetTopicsAsynchronously(0); } else if (currentLocation[1].indexOf("/webaroo/e29f1fe6/searchresult") != -1) { if ((historyData != null) && (historyData != "")) { goToNext(newLocation, 0); } else { GetTopicsAsynchronously(0); } } else if (currentLocation[1].indexOf("/webaroo/e29f1fe6/topicresult") != -1) { if ((historyData != null) && (historyData != "")) { TopicBreadCrum = historyData; topicNext(newLocation, 0); } else { GetTopicsAsynchronously(0); } } else if (currentLocation[1].indexOf("/toptopics") != -1) { // Splitting "/toptopics?flt=FLT&slt=SLT&level=LEVEL&topic=TOPIC[&subtopic=SUBTOPIC]&searcherid=SEARCHID" var currentUrl = newLocation.split("&"); var index = 4; var currentSubTopic = ""; var urlPart = currentUrl[0].split("="); var currentFlt = urlPart[1]; urlPart = currentUrl[1].split("="); var currentSlt = urlPart[1]; urlPart = currentUrl[2].split("="); var currentLevel = parseInt(urlPart[1]); urlPart = currentUrl[3].split("="); var currentTopic = doubleUrlDecode(urlPart[1]); if (currentLevel == 2) { urlPart = currentUrl[index].split("="); currentSubTopic = doubleUrlDecode(urlPart[1]); ++index; } urlPart = currentUrl[index].split("="); var currentSearchId = urlPart[1]; urlPart = currentUrl[index +1].split("="); var channelIndex = urlPart[1]; var subIndex = GetSubIndex(currentSearchId,channelIndex); if (subIndex == -1) { GetStoredInfo(); subIndex = GetSubIndex(currentSearchId,channelIndex); if (subIndex == -1) { return; } } ShowTopTopics(0, currentFlt, currentSlt, currentLevel, currentTopic, currentSubTopic, 0, subIndex,channelIndex) } else if (currentLocation[1].indexOf("/webaroo/e29f1fe6/browsemysites") != -1) { GetBrowseMySiteAsynchronously(0); } else if (currentLocation[1].indexOf("/webaroo/e29f1fe6/citylist") != -1) { GetTopicsAsynchronously(0); } else if (currentLocation[1].indexOf("/webaroo/e29f1fe6/topics") != -1) { // Splitting "/webaroo/e29f1fe6/topics?searcherid=SEARCHID to get search id var currentUrl = newLocation.split("&"); var urlPart = currentUrl[0].split("="); var currentSearchId = urlPart[1]; urlPart = currentUrl[1].split("="); var channelIndex = -1; if (urlPart[0].toLowerCase() == "channelindex") { channelIndex = urlPart[1]; } else // Channel id { var channelId = urlPart[1]; channelIndex = GetChannelIndex(channelId); if (channelIndex == -1) { GetStoredInfo(); channelIndex = GetChannelIndex(channelId); if (channelIndex == -1) { return; } } } var subIndex = GetSubIndex(currentSearchId,channelIndex); if (subIndex == -1) { GetStoredInfo(); subIndex = GetSubIndex(currentSearchId,channelIndex); if (subIndex == -1) { return; } } refreshBUI(0, subIndex,channelIndex); } else if(currentLocation[1].indexOf("/renderCityListWithClearTable") != -1) { // Splittinh "/showplaces?channelIndex=CHANNELINDEX to get channelIndex var currentUrl = newLocation.split("="); var channelIndex = currentUrl[1]; renderCityListWithClearTable(channelIndex); } } else { GetTopicsAsynchronously(0); } } function GetSubIndex(subId,channelIndex) { var subIds = channelSubscriptionIDs[channelIndex]; if(subIds == null) return -1; var subIndex = -1; for (var i=0; i < subIds.length; ++i) { if (subIds[i] == subId) { subIndex = i; break; } } return subIndex; } function ClearAllTables() { ClearBrowseTables(); ClearSearchTables(); } function ClearEditorPickTable() { ClearTable('EditorPicks'); } function ClearSearchTables() { ClearTable('topTitle'); ClearTable('searchResult'); ClearTable('nextpage'); ClearTable('bottomTitle'); } function ClearBrowseTables() { ClearTable('browsetitletable'); ClearTable('BrowsePacksEntry'); ClearTable('topicList'); ClearTable('EditorPicks'); ClearTable('browsemysitetable'); } function search() { var varSearchValue = trim(document.frmSearch.txtSearch.value); if(IsStartKeyword(varSearchValue)) { alert("Please enter a valid search term."); document.frmSearch.txtSearch.focus(); return false; } else { if(varSearchValue.length==0) { alert("Please enter a valid search term"); document.frmSearch.txtSearch.focus(); return false; } else { var searchUrl = (document.frmSearch.searchOption[1].checked) ? "&searcherid=" + document.frmSearch.searchOption[1].value : ""; var url = "/webaroo/e29f1fe6/searchresult?main=1&txtSearch="+doubleUrlEncode(document.frmSearch.txtSearch.value) + searchUrl; goToNext(url, 1); return true; } } } function goToNext(urlStr, addToHistory) { var currentUrl = urlStr.split("&searcherid="); var searchOptionIndex = (currentUrl.length > 1) ? 1 : 0; SetSearchIndex(searchOptionIndex); // Show the data loading message here ... ShowDataLoading(); if (addToHistory == 1) { dhtmlHistory.add(urlStr, "From_goToNext"); window.scrollTo(0,0); } SendAsynchornousRequest(urlStr,"",renderSearchResults,addToHistory); } //Construct the specific list of Choices for the Browser function renderSearchResults(searchResults,addToHistory) { var message = searchResults.getElementsByTagName('message'); var searchresult = searchResults.getElementsByTagName('searchresult'); var result = searchResults.getElementsByTagName('result'); var searchResultTable = document.getElementById('searchResult'); var keys = new Array(); var values = new Array(); var messageText = message[0].firstChild.nodeValue; ClearAllTables(); var totalHits = searchresult[0].getAttribute('totalhits'); var nextoffset = searchresult[0].getAttribute('nextoffset'); var prevoffset = searchresult[0].getAttribute('prevoffset'); var sessionid = searchresult[0].getAttribute('sessionid'); var query = searchresult[0].getAttribute('query'); var searchId = searchresult[0].getAttribute('searcherid'); //escape is used because, accented charaters are getting distorted in the search result in the subsequent pages var searchUrlPart = "&txtSearch=" + escape(doubleUrlEncode(query)) + ((searchId != "") ? "&searcherid=" + doubleUrlEncode(searchId) : ""); // Extra escape is not needed for hyper links. It is needed if resulting url is used as parameter to JS function e.g. searchUrlPart var searchUrlForPage = "&txtSearch=" + doubleUrlEncode(query) + ((searchId != "") ? "&searcherid=" + doubleUrlEncode(searchId) : ""); var prevLink = ""; var nextLink = ""; var firstLink = ""; var secondLink = ""; var thirdLink = ""; var fourthLink = ""; var fifthLink = ""; var countOfSearchPages = 0; var nextPage = document.getElementById('nextpage'); document.title = 'Webaroo Search - ' + query; document.frmSearch.txtSearch.value = query; var next = 0; if((parseInt(nextoffset)-1)%10 == 0) { //a page with no less than 10 results next = parseInt(nextoffset); } else if ((parseInt(nextoffset))%10 == 0) { next = parseInt(nextoffset)+1; } else { //when results are less than 10; the last page; //doing this just to keep nextoffset 10*n+1; else it'll be a problem next = parseInt(nextoffset) + 11 -(parseInt(nextoffset)%10); } var totalResults = parseInt(totalHits); var k=-4; var count = 0; var current = next-10; values[0]=""; if(parseInt(prevoffset) != 0) { var linkToPrePage = "/webaroo/e29f1fe6/searchresult?sid="+sessionid+"&offset="+ parseInt(prevoffset) + searchUrlPart; values[0] += "<a href=\"javascript:goToNext('"+linkToPrePage+"', 1)\">«</a> "; values[0] += " "; } var pageIds = GetPageNumbers(parseInt(nextoffset),parseInt(totalHits)); for(var i=0;i<5;i++) { var pageIdoffset = (pageIds[i]-1)*10 +1; // rendering of all except last page if( ((nextoffset%10)==1)&& (pageIdoffset <= parseInt(totalHits))) { if( (pageIdoffset != parseInt(nextoffset)-10) ) { var linkToPages = "/webaroo/e29f1fe6/searchresult?sid="+sessionid+"&offset="+ pageIdoffset + searchUrlPart; values[0] += "<a href=\"javascript:goToNext('"+linkToPages+"', 1)\">"+ pageIds[i] +"</a>"; values[0] += " "; } else { //current page. Hence no link (href) values[0] += ""+pageIds[i]; values[0] += " "; } } else if(pageIdoffset <= parseInt(totalHits)) // last page rendering { if((pageIdoffset >= parseInt(nextoffset)-10)&&(pageIdoffset <= parseInt(totalHits))) { //current page. Hence no link (href) values[0] += ""+pageIds[i]; values[0] += " "; } else { var linkToPages = "/webaroo/e29f1fe6/searchresult?sid="+sessionid+"&offset="+ pageIdoffset + searchUrlPart; values[0] += "<a href=\"javascript:goToNext('"+linkToPages+"', 1)\">"+ pageIds[i] +"</a>"; values[0] += " "; } } } if(next < parseInt(totalHits)) { var linkToNextPage = "/webaroo/e29f1fe6/searchresult?sid="+sessionid+"&offset="+ next + searchUrlPart; values[0] += " <a href=\"javascript:goToNext('"+linkToNextPage+"', 1)\">»</a>"; } var nextPageLinkText = values[0]; var topTitleTable = document.getElementById('topTitle'); keys[0] = "innerHTML"; keys[1] = "width"; keys[2] = "align"; keys[3] = "bgcolor"; keys[4] = "bordertopbottom"; messageText = RenderSpecialHTMLCharacterCode(messageText); values[0] = "<font style=\"font:bold 10px verdana,arial,sans-serif;\">" + messageText+"</font>"; values[1] = "600"; values[2] = "left"; values[3] = "#ffcc88"; values[4] = ""; var rowTitle = topTitleTable.insertRow(-1); AddCellToRow(rowTitle, keys, values); if(nextPageLinkText !="") values[0]=nextPageLinkText; else values[0]=" "; values[1] = "200"; values[2] = "right"; AddCellToRow(rowTitle, keys, values); keys[3] = ""; keys[4] = ""; values[0] = "<br>"; AddCellToRow(topTitleTable.insertRow(-1), keys, values); for (var j=0;j<result.length;j++) { if (result[j].nodeType != 1) continue; var currentNodeObject=result[j]; var excerpt; var title; var url; var originalUrl; var packagename; for (var k=0;k<currentNodeObject.childNodes.length;k++) { if (currentNodeObject.childNodes[k].nodeType != 1) continue; switch(currentNodeObject.childNodes[k].nodeName) { case 'excerpt': if(currentNodeObject.childNodes[k].firstChild) excerpt=currentNodeObject.childNodes[k].firstChild.nodeValue; else excerpt=" "; break; case 'title': title=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'url': url=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'originalurl': originalurl=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'packagename': packagename=currentNodeObject.childNodes[k].firstChild.nodeValue; break; } } keys[0] = "innerHTML"; keys[1] = "width"; keys[2] = "align"; values[0] = "<a class=\"resultLink\" href=\"/webaroo/e29f1fe6/page?name="+packagename+"&chunkid="+url + searchUrlForPage +"&url="+doubleUrlEncode(originalurl) +"\">"+title+"</a> [<a target=\"_blank\" href=\"" + originalurl + "\">Online Link</a>]"; values[1] = "100"; values[2] = "left"; AddCellToRow(searchResultTable.insertRow(-1), keys, values); values[0] = "<font class=\"resultParagraph\">" + WrapIfOneWord(excerpt,80) + "</font>"; values[1] = "100"; values[2] = "left"; AddCellToRow(searchResultTable.insertRow(-1), keys, values); values[0] = "<font class=\"resultSite\" size=\"1px\">"+TruncateString(originalurl,90)+"</font>"; values[1] = "50"; values[2] = "left"; AddCellToRow(searchResultTable.insertRow(-1), keys, values); keys[0] = "innerHTML"; keys[1] = "width"; keys[2] = "align"; values[0] = "<br>"; values[1] = "100"; values[2] = "left"; AddCellToRow(searchResultTable.insertRow(-1), keys, values); } if(nextPageLinkText !="") { var bottomTitleTable = document.getElementById('bottomTitle'); keys[0] = "innerHTML"; keys[1] = "width"; keys[2] = "align"; keys[3] = "bgcolor"; keys[4] = "bordertopbottom"; values[0] = " "; values[1] = "600"; values[2] = "left"; values[3] = "#ffcc88"; values[4] = ""; var rowTitle = bottomTitleTable.insertRow(-1); AddCellToRow(rowTitle, keys, values); values[0]=nextPageLinkText; values[1] = "200"; values[2] = "right"; AddCellToRow(rowTitle, keys, values); } ChangeTabDisplayMode(false); ShowRooPack(); ShowSearchResults(); } function syncXml(url) { var tempDoc; if (window.XMLHttpRequest) { tempDoc=new XMLHttpRequest(); //Need this if this is to be done asynchronously tempDoc.open("POST",url,false); tempDoc.send("dummy"); } // code for IE else if (window.ActiveXObject) { tempDoc=new ActiveXObject("Microsoft.XMLHTTP"); if(tempDoc) { //Need this if this is to be done asynchronously tempDoc.open("POST",url,false); tempDoc.send("dummy"); } } checkXml(tempDoc); return tempDoc.responseXML; } function checkXml(oneXml) { // Once Data is Downloaded... if (oneXml.readyState==4) { // if "OK" if (oneXml.status==200) { return true; } else { alert(xml_get_problem); return false; } } } function ShowRooPack() { document.getElementById('loading').style.display="none"; document.getElementById('browseUIContentPack').style.display="block"; document.getElementById('browseMySite').style.display="none"; } function ShowDataLoading() { document.getElementById('loading').style.display="block"; document.getElementById('browseUIContentPack').style.display="none"; document.getElementById('browseMySite').style.display="none"; document.getElementById('SearchResultDiv').style.display="none"; document.getElementById('bottomTitleDiv').style.display="none"; } function ShowSearchResults() { document.getElementById('loading').style.display="none"; document.getElementById('SearchResultDiv').style.display="block"; document.getElementById('bottomTitleDiv').style.display="block"; } function ShowMySite() { document.getElementById('loading').style.display="none"; document.getElementById('browseUIContentPack').style.display="none"; document.getElementById('browseMySite').style.display="block"; } function topicPopulate(cityList, channelIndex) { cityListXML[channelIndex] = cityList; renderCityList(cityListXML[channelIndex],channelIndex); } function refreshBUI(addToHistory, subIndex,channelIndex) { var subId = channelSubscriptionIDs[channelIndex][subIndex]; var subName = channelSubscriptionNames[channelIndex][subIndex]; // Clear tables ClearAllTables(); SetSearchOptions(subId, "Only " + subName, 1); // Show the Data Loading form and hide others ShowDataLoading(); var url="/webaroo/e29f1fe6/topics?searcherid=" + subId; var tpXml=syncXml(url); var epurl="/webaroo/e29f1fe6/editorpick?searcherid=" + subId; var epXml=syncXml(epurl); renderTopics(tpXml, subIndex,channelIndex); renderEP(epXml); ConstructBreadCrum("", "", 0, "", "", subIndex,channelIndex); // no flt/slt, level 0, no topic/subtopic, subscription ChangeTabDisplayMode(true); ShowRooPack(); if (addToHistory == 1) { url = url + "&channelIndex=" + channelIndex; dhtmlHistory.add(url, ""); window.scrollTo(0,0); } } function ConstructBreadCrum(flt, slt, level, topic, subTopic, subIndex,channelIndex) { var keys = new Array(); var values = new Array(); ClearTable('browsetitletable'); var rootitleelem = document.getElementById('browsetitletable'); var breadCrums = new Array(); breadCrums[0] = "Web Packs"; // This should be dynamic depending on channel //Channel 0 is "Places", 1 is Music etc.. breadCrums[1] = channelDescription[channelIndex]; breadCrums[2] = channelSubscriptionNames[channelIndex][subIndex]; breadCrums[3] = ModifyValue(topic, false); breadCrums[4] = ModifyValue(subTopic, false); var innertext = '<a href="javascript:GetTopicsAsynchronously(1)">' + breadCrums[0] + '</a> > '; innertext += '<a href="javascript:GetTopicsAsynchronously(1)">' + breadCrums[1] + '</a> > '; if (level > 0) { innertext += '<a href="javascript:refreshBUI(1, ' + subIndex + ','+channelIndex+')">' + breadCrums[2] + '</a> > '; TopicBreadCrum = innertext; if (level > 1) { innertext += "<a href=\"javascript:ShowTopTopics(0, '" + flt + "','" + flt + "', 1, '" + topic + "', '', 1, " + subIndex + ","+channelIndex+")\">" + breadCrums[3] + "</a> > "; TopicBreadCrum = innertext; innertext += '<b>' + breadCrums[4] + '</b> '; TopicBreadCrum += "<a href=\"javascript:ShowTopTopics(0, '" + flt + "','" + slt + "', 2, '" + topic + "', '" + subTopic + "', 1, " + subIndex + ","+channelIndex+")\">" + breadCrums[4] + "</a> "; } else { innertext += '<b>' + breadCrums[3] + '</b> '; TopicBreadCrum += "<a href=\"javascript:ShowTopTopics(0, '" + flt + "','" + flt + "', 1, '" + topic + "', '', 1, " + subIndex + ","+channelIndex+")\">" + breadCrums[3] + "</a> "; } } else { innertext += '<b>' + breadCrums[2] + '</b> '; } innertext += '<br/>'; keys[0] = "innerHTML"; keys[1] = 'className'; values[0] = innertext; values[1]="breadCrumTitle"; var curRow=rootitleelem.insertRow(-1); AddCellToRow(curRow, keys, values); } function renderTopics(topicXml, subIndex,channelIndex) { var keys = new Array(); var values = new Array(); ClearTable('topicList'); // Hide the text below search box for no content message // Not needed here as would be taken care in upper parent function //check and remove //document.getElementById('NoContentMessage').style.display = "none"; var placetitleelem = document.getElementById('browsetitletable'); var innertext = ''; keys[0] = "innerHTML"; keys[1] = 'className'; values[0] = innertext; values[1]="resultLink"; var curRow=placetitleelem.insertRow(-1); AddCellToRow(curRow, keys, values); var message = topicXml.getElementsByTagName('message'); var result = topicXml.getElementsByTagName('topic'); var levelNode=topicXml.getElementsByTagName('level'); var level=levelNode[0].firstChild.nodeValue; var messageText = message[0].firstChild.nodeValue; var topicTab=document.getElementById('topicList'); if(result.length < 1) return false; var parentTopic = ""; if(level == 'two') { var parentNode=topicXml.getElementsByTagName('parent'); parentTopic=parentNode[0].firstChild.nodeValue; } // insert few empty rows in Topic table keys[0]="innerHTML"; keys[1] ='nowrap'; keys[2] ='align'; values[0]= "<br/>"; values[1] = false; values[2] = "left"; AddCellToRow(topicTab.insertRow(-1),keys,values); // Add a Cell keys[0]="innerHTML"; values[0]= "<br/>"; var curcell = AddCellToRow(topicTab.insertRow(-1),keys,values); var topiclinetext =""; for (var j=0;j<result.length;j++) { if (result[j].nodeType != 1) continue; var currentNodeObject=result[j]; var display=""; var subTopiCount=""; var fltCode=""; var sltCode=""; for (var k=0;k<currentNodeObject.childNodes.length;k++) { if (currentNodeObject.childNodes[k].nodeType != 1) continue; switch(currentNodeObject.childNodes[k].nodeName) { case 'display': display=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'subtopiccount': subTopicCount=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'flt': fltCode=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'slt': sltCode=currentNodeObject.childNodes[k].firstChild.nodeValue; break; } } // Show the Topic List in the Row now var cellHtml=""; if(level == 'two') { if(j+1 != result.length) cellHtml="<a href=\"javascript:ShowTopTopics(1, '"+fltCode+"','"+sltCode+"', 2, '" + ModifyValue(parentTopic, true) + "', '" + ModifyValue(display, true) + "', 1, " + subIndex + "," + channelIndex + ")\">"+display+"</a> | "; else cellHtml="<a href=\"javascript:ShowTopTopics(1, '"+fltCode+"','"+sltCode+"', 2, '" + ModifyValue(parentTopic, true) + "', '" + ModifyValue(display, true) + "', 1, " + subIndex + "," +channelIndex +")\">"+display+"</a> "; } else { var topicsAlreadyPresent = (subTopicCount > 0) ? 0 : 1; if(j+1 != result.length) cellHtml="<a class=\"resultLink2\" href=\"javascript:ShowTopTopics(" + topicsAlreadyPresent + ", '"+fltCode+"','"+fltCode+"', 1, '" + ModifyValue(display, true) + "', '', 1, " + subIndex + ","+channelIndex+")\">"+display+"</a> | "; else cellHtml="<a class=\"resultLink2\" href=\"javascript:ShowTopTopics(" + topicsAlreadyPresent + ", '"+fltCode+"','"+fltCode+"', 1, '" + ModifyValue(display, true) + "', '', 1, " + subIndex + ","+channelIndex+")\">"+display+"</a> "; } topiclinetext += cellHtml; } keys[0] ='innerHTML'; keys[1] ='nowrap'; keys[2] ='align'; keys[3] ='className'; values[0] = topiclinetext; values[1] = false; values[2] = "left"; values[3]='resultLink'; AssignValueToKey(curcell, keys, values); // Add a empty row now values[0] = "<br>"; values[1] = "100"; values[2] = "left"; AddCellToRow(topicTab.insertRow(-1), keys, values); return true; } // TODO: Hack. Don't use this function. Find an alternative. // To replace "'" in string to "%" and vice versa. function ModifyValue(value, change) { var re = change ? /'/g : /%/g; var str = change ? "%" : "'"; return value.replace(re, str); } function renderCityListWithClearTable(channelIndex,addToHistory) { ClearAllTables(); if(addToHistory ==1) { var hurl = "/renderCityListWithClearTable?channelIndex=" + channelIndex; dhtmlHistory.add(hurl, ""); } renderCityList(cityListXML[channelIndex],channelIndex); } function renderCityList(cityResults,channelIndex) { var select= new Array(); var cName = new Array(); var keys = new Array(); var values = new Array(); var curRow; var index = 0; var webPackSearcherId = '0'; var subNames = new Array(); var subIds = new Array(); if(!cityResults) return; ShowDataLoading(); // Set the text "Web Packs" var rootitleelem = document.getElementById('browsetitletable'); var message = cityResults.getElementsByTagName('message'); var result = cityResults.getElementsByTagName('subscription'); // Get the table element var cityTab=document.getElementById('BrowsePacksEntry'); if(result.length < 1) { if((displayMySitesIfNoPacks)&& CheckIfSiteExists()) { displayMySitesIfNoPacks = false; selectAll = true; GetBrowseMySiteAsynchronously(0); } else { var rowkeys = new Array(); var rowvalues =new Array(); keys[0] = "innerHTML"; keys[1] = "align"; var url = "/webaroo/e29f1fe6/content"; values[0] = 'No Web Packs available in your library. Go to the <a href="' + url +'">Content</a> page to add a Web Pack. If you have already added a Web Pack, please wait for the updates to complete.'; // i18N issue values[1] = 'left'; curRow=rootitleelem.insertRow(-1); AddCellToRow(curRow, keys, values); document.frmSearch.searchOption[0].checked = true; // Also show the message below search box document.getElementById('NoContentMessage').style.display = "inline"; // No results // Show the rooPack back ShowRooPack(); } // Show the radio button irrespective of the content status SetSearchOptions(webPackSearcherId, "Only Web Packs", 1); return; } // Show the radio button irrespective of the content status SetSearchOptions(webPackSearcherId, "Only Web Packs", 1); displayMySitesIfNoPacks = false; // Also hide the text below search box document.getElementById('NoContentMessage').style.display = "none"; // Also set the text "Places" keys[0] = "innerHTML"; keys[1] = "className"; // Get this text from channel Name var channelText = channelDescription[channelIndex]; innertext = "<span class=\"channel_name\">" + channelText + "</span>"; values[0] = innertext; values[1]='resultLink'; curRow=cityTab.insertRow(-1); AddCellToRow(curRow, keys, values); // Put a dummy Row curRow=cityTab.insertRow(-1); var htmlcode =" "; for (var j=0;j<result.length;j++) { if (result[j].nodeType != 1) continue; var subName = result[j].getAttribute("name"); subNames[j] = subName; var subId = result[j].getAttribute("id"); subIds[j] = doubleUrlEncode(subId); index = j; if(j+1 != result.length) htmlcode += '<a class="results" href="javascript:refreshBUI(1, ' + index + ','+channelIndex+')" >'+subName+'</a> | '; else htmlcode += '<a class="results" href="javascript:refreshBUI(1, ' + index + ','+channelIndex+')" >'+subName+'</a> '; index++; } channelSubscriptionIDs[channelIndex] = subIds; channelSubscriptionNames[channelIndex] = subNames; historyStorage.put("SubscriptionNames", channelSubscriptionNames); historyStorage.put("SubscriptionIds", channelSubscriptionIDs); // Also put it on the page keys[0] = "innerHTML"; keys[1] = "width"; keys[2] = "align"; keys[3] = "className"; keys[4] = "nowrap"; values[0] = htmlcode; values[1] = "100"; values[2] = "left"; values[3] = "resultLink3"; values[4] = false; AddCellToRow(curRow, keys, values); // put empty row values[0] = ' '; curRow=cityTab.insertRow(-1); AddCellToRow(curRow, keys, values); ShowRooPack(); } function CheckIfSiteExists() { var url="/webaroo/e29f1fe6/browsemysites"; processXMLData(url); var browseMySitesXML = xmlContent; var listObject = browseMySitesXML.getElementsByTagName('Response'); if (listObject[0].childNodes.length > 0) return true; else return false; } function ShowTopTopics(topicsAlreadyPresent, flt, slt, level, topic, subTopic, addToHistory, subIndex,channelIndex) { var subId = channelSubscriptionIDs[channelIndex][subIndex]; var subName = channelSubscriptionNames[channelIndex][subIndex]; SetSearchOptions(subId, "Only " + subName, 1); if (topicsAlreadyPresent == 0) { ClearEditorPickTable(); // Also Clear the search Result ClearSearchTables(); ClearTable('browsetitletable'); ClearTable('BrowsePacksEntry'); var url = "/webaroo/e29f1fe6/topics?flt=" + flt + "&searcherid=" + subId; sendXMLData(url, ""); renderTopics(xmlContent, subIndex,channelIndex); } ConstructBreadCrum(flt, slt, level, topic, subTopic, subIndex,channelIndex); var urlRes = "/webaroo/e29f1fe6/topicresult?flt=" + flt + "&slt=" + slt + "&top=" + "5" + "&searcherid=" + subId; sendXMLData(urlRes, ""); renderTopicResults(xmlContent, true); if (addToHistory == 1) { var hurl = "/toptopics?flt=" + flt + "&slt=" + slt + "&level=" + level + "&topic=" + doubleUrlEncode(topic) + ((level == 2) ? ("&subtopic=" + doubleUrlEncode(subTopic)) : "") + "&searcherid=" + subId+ "&channelIndex=" + channelIndex; dhtmlHistory.add(hurl, ""); } ChangeTabDisplayMode(true); ShowRooPack(); } function topicNext(url, addToHistory) { SetSearchIndex(1); // Show data loading ShowDataLoading(); sendXMLData(url, ""); ClearBrowseTables(); renderTopicResults(xmlContent, false); ChangeTabDisplayMode(false); ShowRooPack(); ShowSearchResults(); if (addToHistory == 1) { dhtmlHistory.add(url, TopicBreadCrum); window.scrollTo(0,0); } } function renderTopicResults(topicResults, isTopTopics) { var message = topicResults.getElementsByTagName('message'); var searchresult = topicResults.getElementsByTagName('searchresult'); var result = topicResults.getElementsByTagName('result'); var searchResultTable = (isTopTopics) ? document.getElementById('EditorPicks') : document.getElementById('searchResult'); var keys = new Array(); var values = new Array(); var messageText = message[0].firstChild.nodeValue; if (isTopTopics) { ClearEditorPickTable(); } ClearSearchTables(); var totalHits = searchresult[0].getAttribute('totalhits'); var nextoffset = searchresult[0].getAttribute('nextoffset'); var prevoffset = searchresult[0].getAttribute('prevoffset'); var sessionid = searchresult[0].getAttribute('sessionid'); var searchId = searchresult[0].getAttribute('searcherid'); var flt = searchresult[0].getAttribute('flt'); var slt = searchresult[0].getAttribute('slt'); var topicInfoUrlPart = "&flt=" + flt + "&slt=" + slt + "&searcherid=" + doubleUrlEncode(searchId); var nextPage = document.getElementById('nextpage'); var nextPageLinkText ; if (!isTopTopics) { var topTitleTable = document.getElementById('topTitle'); keys[0] = "innerHTML"; keys[1] = "width"; keys[2] = "align"; keys[3] = "bordertopbottom"; keys[4] = "bgcolor"; values[0] = "<font style=\"font:bold 10px verdana,arial,sans-serif;\">" + messageText + "<br />" + TopicBreadCrum +"</font>"; values[1] = "600"; values[2] = "left"; values[3] = ""; values[4] = "#ffcc88"; var rowTitle = topTitleTable.insertRow(-1); AddCellToRow(rowTitle, keys, values); var prevLink = ""; var nextLink = ""; var firstLink = ""; var secondLink = ""; var thirdLink = ""; var fourthLink = ""; var fifthLink = ""; var countOfSearchPages = 0; var next = 0; if((parseInt(nextoffset)-1)%10 == 0) { //a page with no less than 10 results next = parseInt(nextoffset); } else if ((parseInt(nextoffset))%10 == 0) { next = parseInt(nextoffset)+1; } else { //when results are less than 10; the last page; //doing this just to keep nextoffset 10*n+1; else it'll be a problem next = parseInt(nextoffset) + 11 -(parseInt(nextoffset)%10); } var totalResults = parseInt(totalHits); var k=-4; var count = 0; var current = next-10; values[0]=""; if(parseInt(prevoffset) != 0) { var linkToPrePage = "/webaroo/e29f1fe6/topicresult?sid=" + sessionid + "&offset=" + prevoffset + topicInfoUrlPart; values[0] += "<a href=\"javascript:topicNext('"+linkToPrePage+"', 1)\">«</a> "; values[0] += " "; } var pageIds = GetPageNumbers(parseInt(nextoffset),parseInt(totalHits)); for(var i=0;i<5;i++) { var pageIdoffset = (pageIds[i]-1)*10 +1; if( ((nextoffset%10)==1)&& (pageIdoffset <= parseInt(totalHits))) { if(pageIdoffset == parseInt(nextoffset)-10) { //current page. Hence no link (href) values[0] += ""+pageIds[i]; values[0] += " "; } else if(pageIdoffset <= parseInt(totalHits)) { var linkToPages = "/webaroo/e29f1fe6/topicresult?sid=" + sessionid + "&offset=" + pageIdoffset + topicInfoUrlPart; values[0] += "<a href=\"javascript:topicNext('"+linkToPages+"', 1)\">"+ pageIds[i] +"</a>"; values[0] += " "; } } else if(pageIdoffset <= parseInt(totalHits)) // last page rendering { if((pageIdoffset >= parseInt(nextoffset)-10)&&(pageIdoffset <= parseInt(totalHits))) { //current page. Hence no link (href) values[0] += ""+pageIds[i]; values[0] += " "; } else { var linkToPages = "/webaroo/e29f1fe6/topicresult?sid=" + sessionid + "&offset=" + pageIdoffset + topicInfoUrlPart; values[0] += "<a href=\"javascript:topicNext('"+linkToPages+"', 1)\">"+ pageIds[i] +"</a>"; values[0] += " "; } } } if(next < parseInt(totalHits)) { var linkToNextPage = "/webaroo/e29f1fe6/topicresult?sid=" + sessionid+ "&offset=" + next + topicInfoUrlPart; values[0] += " <a href=\"javascript:topicNext('"+linkToNextPage+"', 1)\">»</a>"; } nextPageLinkText = values[0]; values[1] = "200"; values[2] = "right"; values[3] = ""; values[4] = "#ffcc88"; AddCellToRow(rowTitle, keys, values); keys[0] = "innerHTML"; keys[1] = "width"; keys[2] = "align"; keys[3] = ""; keys[4] = ""; values[0] = "<br>"; AddCellToRow(topTitleTable.insertRow(-1), keys, values); var bottomTitleTable = document.getElementById('bottomTitle'); keys[0] = "innerHTML"; keys[1] = "width"; keys[2] = "align"; keys[3] = "bordertopbottom"; keys[4] = "bgcolor"; values[0] = " "; values[1] = "600"; values[2] = "left"; values[3] = ""; values[4] = "#ffcc88"; rowTitle = bottomTitleTable.insertRow(-1); AddCellToRow(rowTitle, keys, values); if(nextPageLinkText!="") values[0] = nextPageLinkText; else values[0] = " "; values[1] = "200"; values[2] = "right"; AddCellToRow(rowTitle, keys, values); keys[2] = ""; keys[3] = ""; keys[4] = ""; } else { // Change background color of next link table keys[0] = "innerHTML"; keys[1] = "width"; keys[2] = "align"; keys[3] = "nowrap"; values[0] = "<b>"+messageText+"</b>"; values[1] = "100"; values[2] = "left"; values[3] = false; var rowTitle = searchResultTable.insertRow(-1); AddCellToRow(rowTitle, keys, values); keys[0] = "innerHTML"; keys[1] = "width"; keys[2] = "align"; values[0] = "<br/>"; values[1] = "100"; values[2] = "center"; AddCellToRow(searchResultTable.insertRow(-1), keys, values); if( parseInt(totalHits) > 5) { ClearTable('nextpage'); var nextPageTable = document.getElementById('nextpage'); var href = "/webaroo/e29f1fe6/topicresult?flt=" + flt + "&slt=" + slt + "&searcherid=" + searchId; var nxtMsg= "<a href=\"javascript:topicNext('"+href+"', 1)\" > More »</a>"; keys[0] = "innerHTML"; keys[1] = "width"; keys[2] = "align"; values[0] = nxtMsg; values[1] = "100"; values[2] = "right"; AddCellToRow(nextPageTable.insertRow(-1), keys, values); } } for (var j=0;j<result.length;j++) { if (result[j].nodeType != 1) continue; var currentNodeObject=result[j]; var excerpt; var title; var url; var originalUrl; var packagename; for (var k=0;k<currentNodeObject.childNodes.length;k++) { if (currentNodeObject.childNodes[k].nodeType != 1) continue; switch(currentNodeObject.childNodes[k].nodeName) { case 'excerpt': if(currentNodeObject.childNodes[k].firstChild != null) excerpt=currentNodeObject.childNodes[k].firstChild.nodeValue; else excerpt=" "; break; case 'title': title=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'url': url=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'originalurl': originalurl=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'packagename': packagename=currentNodeObject.childNodes[k].firstChild.nodeValue; } } keys[0] = "innerHTML"; keys[1] = "width"; keys[2] = "align"; values[0] = "<a class=\"resultLink\" href=\"/webaroo/e29f1fe6/page?name="+packagename+"&chunkid="+url + topicInfoUrlPart + "&url="+doubleUrlEncode(originalurl) + "\">"+title+"</a> [<a target=\"_blank\" href=\"" + originalurl + "\">Online Link</a>]"; values[1] = "100"; values[2] = "left"; AddCellToRow(searchResultTable.insertRow(-1), keys, values); values[0] = "<font class=\"resultParagraph\" >" + WrapIfOneWord(excerpt,80) + "</font>"; values[1] = "100"; values[2] = "left"; AddCellToRow(searchResultTable.insertRow(-1), keys, values); values[0] = "<font class=\"resultSite\" size=\"1px\">"+TruncateString(originalurl,90)+"</font>"; values[1] = "50"; values[2] = "left"; AddCellToRow(searchResultTable.insertRow(-1), keys, values); values[0] = "<br>"; values[1] = "100"; values[2] = "left"; AddCellToRow(searchResultTable.insertRow(-1), keys, values); } keys[0] = "innerHTML"; keys[1] = "width"; keys[2] = "align"; values[0] = "<br>"; values[1] = "100"; values[2] = "left"; AddCellToRow(searchResultTable.insertRow(-1), keys, values); } function renderEP(epResults) { var message = epResults.getElementsByTagName('message'); var searchresult = epResults.getElementsByTagName('editorpics'); var result = epResults.getElementsByTagName('result'); if(result.length <= 0) return false; var searchResultTable = document.getElementById('EditorPicks'); var keys = new Array(); var values = new Array(); var messageText = message[0].firstChild.nodeValue; ClearEditorPickTable(); ClearSearchTables(); keys[0] = "innerHTML"; keys[1] = "width"; keys[2] = "align"; values[0] = "<b>"+messageText+"</b>"; values[1] = "100"; values[2] = "left"; AddCellToRow(searchResultTable.insertRow(-1), keys, values); keys[0] = "innerHTML"; keys[1] = "width"; keys[2] = "align"; values[0] = "<br/>"; values[1] = "100"; values[2] = "center"; AddCellToRow(searchResultTable.insertRow(-1), keys, values); for (var j=0;j<result.length;j++) { if (result[j].nodeType != 1) continue; var currentNodeObject=result[j]; var excerpt=""; var title; var url; var originalUrl; var packagename; for (var k=0;k<currentNodeObject.childNodes.length;k++) { if (currentNodeObject.childNodes[k].nodeType != 1) continue; switch(currentNodeObject.childNodes[k].nodeName) { case 'excerpt': if(currentNodeObject.childNodes[k].firstChild) excerpt=currentNodeObject.childNodes[k].firstChild.nodeValue; else excerpt = " "; break; case 'title': title=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'url': url=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'originalurl': originalurl=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'packagename': packagename=currentNodeObject.childNodes[k].firstChild.nodeValue; } } keys[0] = "innerHTML"; keys[1] = "width"; keys[2] = "align"; values[0] = "<a class=\"resultLink\" href=\"/webaroo/e29f1fe6/page?name="+packagename+"&chunkid="+url+"&url="+doubleUrlEncode(originalurl)+" \">"+title+"</a> [<a target=\"_blank\" href=\"" + originalurl + "\">Online Link</a>]"; values[1] = "100"; values[2] = "left"; AddCellToRow(searchResultTable.insertRow(-1), keys, values); values[0] = "<font class=\"resultParagraph\" >" + WrapIfOneWord(excerpt,80) +"</font>"; values[1] = "50"; values[2] = "left"; AddCellToRow(searchResultTable.insertRow(-1), keys, values); keys[0] = "innerHTML"; keys[1] = "width"; keys[2] = "align"; values[0] = "<font class=\"resultSite\" size=\"1px\">"+TruncateString(originalurl,90)+"</font>"; values[1] = "100"; values[2] = "left"; AddCellToRow(searchResultTable.insertRow(-1), keys, values); // insert a blank row values[0] = " "; values[1] = "100"; values[2] = "center"; AddCellToRow(searchResultTable.insertRow(-1), keys, values); } values[0] = " "; values[1] = "100"; values[2] = "center"; AddCellToRow(searchResultTable.insertRow(-1), keys, values); } function searchTopic(topic) { if(document.frmEP.txtEditorPick.value == "") { document.location.href = "/webaroo/e29f1fe6/browseui?main=1&txtBrowseui="+document.frmEP.city_select_form_list.options[document.frmEP.city_select_form_list_box.selectedIndex].value+" " + topic; } else { document.location.href = "/webaroo/e29f1fe6/browseui?main=1&txtBrowseui="+document.frmEP.txtEditorPick.value+" "+ topic; } } function searchEditorPick() { document.frmEP.action="/webaroo/e29f1fe6/search"; var ind=document.frmEP.city_select_form_list.options[document.frmEP.city_select_form_list.selectedIndex].value; document.frmEP.txtEditorPick.value=ind; document.frmEP.submit(); } function IsStartKeyword(strText) { arrKeyword = new Array('*','~','AND','OR') for (intLoop = 0;intLoop < arrKeyword.length;intLoop++) { if((strText.indexOf(arrKeyword[intLoop])==0) && (strText.length==arrKeyword[intLoop].length)) { return true; break; } } return false; } function trim(str) { return((""+str).replace(/^\s*([\s\S]*\S+)\s*$|^\s*$/,'$1') ); } function SetEmptyText() { var arrQueryString = (location.search).split('&'); for(i = 0; i<arrQueryString.length; i++) { if(arrQueryString[i].indexOf("txtBrowseui=") < 0) { continue; } document.frmSearch.txtSearch.value = " "; break; } } function SetSearchText() { var done=0; var arrQueryString = (location.search).split('&'); for(i = 0; i<arrQueryString.length; i++) { if(arrQueryString[i].indexOf("txtSearch=") < 0) { continue; } document.frmSearch.txtSearch.value = unescape((arrQueryString[i].split('='))[1]).replace(/\+/g, " "); done=1; break; } if(done==0) { for(i = 0; i<arrQueryString.length; i++) { if(arrQueryString[i].indexOf("txtBrowseui=") < 0) { continue; } document.frmSearch.txtSearch.value = unescape((arrQueryString[i].split('='))[1]).replace(/\+/g, " "); done=1; break; } } } function changepage(page) { parent.document.location.href=page; } function GetPageNumbers(nextoffset, totalResults) { var numarray = new Array(5); var currentPageID = parseInt(nextoffset/10); var lastPageID = parseInt((totalResults+9)/10); if(nextoffset <= 40) { //case for first three pages numarray[0] =1; numarray[1] =2; numarray[2] =3; numarray[3] =4; numarray[4] =5; } else if ((totalResults - nextoffset) < 20) { //case for last three pages numarray[0] =lastPageID -4; numarray[1] =lastPageID -3; numarray[2] =lastPageID -2; numarray[3] =lastPageID -1; numarray[4] =lastPageID; } else { numarray[0] =currentPageID -2; numarray[1] =currentPageID -1; numarray[2] =currentPageID; numarray[3] =currentPageID +1; numarray[4] =currentPageID +2; } return numarray; } function WrapIfOneWord (message , characterlimit) { var wordText; var remainingmessage = message; var newMessage =""; var startIndex,endIndex; if(message.length > characterlimit) { startIndex = 0; do { endIndex = remainingmessage.indexOf(" "); if(endIndex==-1) { wordText = remainingmessage; } else { wordText = remainingmessage.substring(startIndex,endIndex); remainingmessage = remainingmessage.substring(endIndex +1); } if(wordText.length > characterlimit) { var newWord =""; var tempWord =""; for(var i=0;i<wordText.length;i=i+characterlimit) { tempWord = wordText.substring(i,i+characterlimit) + " <br>"; newWord = newWord + tempWord; } wordText = newWord; } newMessage = newMessage + " " + wordText; }while(endIndex!=-1) return newMessage; } else return message; } function GetChannelIndex(channelID) { if (channelNumber != null) { for(var i=0;i<channelNumber.length;i++) { if(channelID == channelNumber[i]) return i; } } return -1; }