////////// Assumes this is prefixed by flyobjects.js and the inline data /////////////
var FS_WINDOW_TYPE = "LINKS_LIST";
// Pre-Load Images
PlusNormal = new Image(13,13);
PlusHover = new Image(13,13);
MinusNormal = new Image(13,13);
MinusHover = new Image(13,13);
PlusSpace = new Image(13,13);
DownNormal = new Image(15,14);
DownHover = new Image(15,14);
UpNormal = new Image(15,14);
UpHover = new Image(15,14);
PlusNormal.src = 'popup-images/plus.gif';
PlusHover.src = 'popup-images/plus.gif';
MinusNormal.src = 'popup-images/minus.gif';
MinusHover.src = 'popup-images/minus.gif';
PlusSpace.src = 'popup-images/plus-space.gif';
DownNormal.src = 'popup-images/down.gif';
DownHover.src = 'popup-images/down.gif';
UpNormal.src = 'popup-images/up.gif';
UpHover.src = 'popup-images/up.gif';
bpIcon = new Image(21,18);
flyIcon = new Image(21,18);
bpIcon.src = "popup-images/bp-icon.gif"
flyIcon.src = "popup-images/fly-icon.gif";
//get HTML for categories
var sections = new Array();
function assembleVertSectionsHTML() {
//divide fscategories based on value of "boosterPackCategory" property
//create a sections array, which is an array of indexes in fscategories
//e.g. fscategories = (cat1, cat2, cat3, ...)
// sections = ((0,1,3), (2,6,4, ...), ...)
// grouped by boosterPackCategory
var i;
var s;
for (var cat in fscategories) {
if(fscategories[cat].boosterPackCategory) {
s = 1;
}
else {
s = 0;
}
//if a section has been started, add the cat to it
if (sections[s]) {
i = sections[s].length;
sections[s][i] = cat;
}
//otherwise, create a new section
else {
sections[s] = new Array();
sections[s][0] = cat;
}
}
var sectionsHTML = "";
var catimg;
for (var s in sections) {
if (s==1) {
catimg = bpIcon.src;
}
else {
catimg = "NULL";
}
sectionsHTML += assembleVertCatSectionHTML(sections[s], catimg);
}
return sectionsHTML;
}
function assembleVertCatSectionHTML(catindexes, catimg) {
var sectionHTML = "";
var cattopHTML;
var cat;
for (var i in catindexes) {
cat = catindexes[i];
fscategories[cat].initializeDisplayProperties();
if (fscategories[cat].keywords[0].categoryCode=="Searches") {
fscategories[cat].name = "Searches for " + fslinksenviro.src.substr(9, fslinksenviro.src.length-1);
}
cattopHTML = "";
cattopHTML += "" +
"" +
"";
cattopHTML += "" +
"" +
fscategories[cat].name + "";
if (catimg != "NULL") {
cattopHTML += " ";
}
cattopHTML += " (" + fscategories[cat].keywords.length + ")" +
" ";
cattopHTML += " |
" +
"";
var keyHTML = "" +
"" +
"";
sectionHTML += cattopHTML + keyHTML;
}
//var catbottomHTML = "";
//sectionHTML += catbottomHTML;
return sectionHTML;
}
//HTML of all keywords under a given category (fscategories[cat])
function assembleVertKeyListHTML(cat) {
var keylistHTML = "";
var catwidelistHTML = "";
with (fscategories[cat]) {
for (var k in keywords) {
keywords[k].initializeDisplayProperties(cat,k);
//fix searches text- should be done on the server side, this is a temporary fix
if (keywords[k].categoryCode == "Searches") {
var text = keywords[k].name;
if (text.substring(text.length-4, text.length) == " for") {
text = text.substr(0, text.length-4); //remove ' for'
keywords[k].name = text;
}
}
if (keywords[k].categoryWide) { //For cat-wide keywords, only display linktype with keyword text and providers
with (keywords[k]) {
linktypes[0].initializeDisplayProperties(cat,k,0);
var statusText = fscategories[cat].keywords[k].name;
if (linktypes[0].providers.length > 0)
statusText += " (provided by " + linktypes[0].providers[0].name + ")";
catwidelistHTML += "";
}
}
else {
keylistHTML += "" + keywords[k].name + "";
keylistHTML += " (" + keywords[k].linktypes.length + ")
";
keylistHTML += "";
}
}
}
if (keylistHTML && catwidelistHTML) {
keylistHTML = keylistHTML + "
" + catwidelistHTML;
}
else {
keylistHTML = keylistHTML + catwidelistHTML;
}
return keylistHTML;
}
//==============================================================
// Initial HTML Display Functions
//===============================================================
//need to preload PopupTopRounded and PopupBottomRounded images, because of weirdness with IE4
var vertTopHTML = "";
var vertBottomHTML = "";
function assembleVertTableHTML(insideHTML)
{
var HTML = vertTopHTML + insideHTML + vertBottomHTML;
return HTML;
}
function assembleVertKeywordCatWideHTML(catCode, text, globalID, URL, providers, providerListID, expandImageID, cat, k, l)
{
/*--------change search text----------*/
var keytext;
if (catCode == "Searches") {
var endindex = text.indexOf(" for \"", 0); //remove ' for "testing"'
if (endindex == -1) {
if (text.substring(text.length-4, text.length) == " for") {
endindex = text.length-4; //remove ' for'
}
else if (text.substring(text.length-5, text.length) == " for ") {
endindex = text.length-5; //remove ' for '
}
else {
endindex = text.length;
}
}
keytext = text.substr(0, endindex);
}
else {
keytext = text;
}
/*-------------------------------------*/
var statusText = fscategories[cat].keywords[k].name;
if (providers.length > 0)
statusText += " (provided by " + providers[0].name + ")";
var HTML = "" +
"";
}
else {
HTML += "onMouseOver=\"this.className='keycatwidehover'; setStatusText('" + escape(statusText) + "');\" " +
"onMouseOut=\"this.className='keycatwide'; clearStatusText();\" " +
"onMouseDown=\"this.className='keycatwideclick';\" onMouseUp=\"this.className='keycatwide';\">";
}
HTML += keytext + "" + "";
if (providers.length > 1) {
HTML += "
";
}
HTML += "
";
if (providers.length > 1) {
HTML += "";
}
return HTML;
}
function combineKeyAndCatWideHTML(keyHTML, catWideHTML) {
var keyListHTML = "";
if (keyHTML != "") {
keyListHTML = keyHTML;
if (catWideHTML != "") {
keyListHTML += "
" +
catWideHTML;
}
}
else if (catWideHTML != "") {
keyListHTML = catWideHTML;
}
return keyListHTML;
}
function assembleProviderHTML(text, globalID, URL, cat, k, l)
{
var statusText;
if (fscategories[cat].keywords[k].categoryWide) {
statusText = fscategories[cat].keywords[k].name + " (provided by " + text + ")";
}
else {
statusText = fscategories[cat].keywords[k].name + " - " + fscategories[cat].keywords[k].linktypes[l].name + " (provided by " + text + ")";
}
var HTML = "";
return HTML;
}
function flyswat_getStyleVersion()
{
return 1;
}
var autoUpdateLinks = false;
var gContentInitialized = false;
function flyswat_InitializeData(name, value)
{
if (name == "AutoUpdateListLinks")
{
if (value == "yes")
{
autoUpdateLinks = true;
}
else if (value == "no")
{
autoUpdateLinks = false;
}
gContentInitialized = true;
UpdateTitleContent();
}
}
//==============================================================================
// Vertical Panel Browse Display Functions
// showLinksListSubtitle, showSearchSubtitle,
// Vert_showBrowseLinks, Vert_catClick, Vert_catExpand,
// Vert_keyClick, Vert_keyExpand, Vert_ltClick, ltExpand
// (ltExpand is in BOTH_JS_CORE)
//==============================================================================
//space in pixels on each side of the subtitle
var subtitle_margin = 20;
//find minimum number of characters of the URL displayed
var min_chars = 22;
/*
var url = fslinksenviro.src;
var firstdot = url.indexOf('.');
var seconddot = url.indexOf('.', firstdot+1);
var min_chars;
if (seconddot <= 25) {
min_chars = seconddot;
}
else {
min_chars = firstdot;
}
window.alert(min_chars);
*/
function showLinksListSubtitle()
{
var text = fslinksenviro.src;
var url = fslinksenviro.src;
if (url.toLowerCase() != "(not flyswat accessible)") {
document.all.subtitleanchor.title = url;
document.all.subtitleanchor.href = "flyswat:nav:" + url;
}
var window_width = document.body.offsetWidth - (2*subtitle_margin);
document.all.subtitle.style.visibility = "hidden";
fitTextInObj(text, document.all.subtitleanchor, window_width);
document.all.subtitle.style.visibility = "visible";
}
function updateLinksListSubtitle()
{
var text = fslinksenviro.src;
var window_width = document.body.offsetWidth - (2*subtitle_margin);
document.all.subtitle.style.visibility = "hidden";
updateTextInObj(text, document.all.subtitleanchor, window_width);
document.all.subtitle.style.visibility = "visible";
}
function showSearchSubtitle()
{
var text = "Search for " + fslinksenviro.src.substr(9, fslinksenviro.src.length-9); //cut off the "JSEARCH: "
document.all.searchsubtitle.title = text;
var window_width = document.body.offsetWidth - (2*subtitle_margin);
document.all.searchsubtitle.style.visibility = "hidden";
fitTextInObj(text, document.all.searchsubtitle, window_width);
document.all.searchsubtitle.style.visibility = "visible";
}
function updateSearchSubtitle()
{
var text = "Search for " + fslinksenviro.src.substr(9, fslinksenviro.src.length-9); //cut off the "JSEARCH: "
var window_width = document.body.offsetWidth - (2*subtitle_margin);
document.all.searchsubtitle.style.visibility = "hidden";
updateTextInObj(text, document.all.searchsubtitle, window_width);
document.all.searchsubtitle.style.visibility = "visible";
}
//assumes text in object will not wrap to the next line
function fitTextInObj(text, obj, window_width) {
var window_width = document.body.offsetWidth - (2*subtitle_margin);
obj.innerText = text;
var text_width = parseInt(obj.offsetWidth);
var x = text.length;
if ((text_width < window_width) || (x <= min_chars)) { // display all text
obj.innerText = text;
}
else { // truncate text
//initialize variables
truncated_text = text.substr(0,x) + "...";
obj.innerText = truncated_text;
text_width = parseInt(obj.offsetWidth);
while((text_width >= window_width) && (x >= min_chars)) {
x = x-5;
truncated_text = text.substr(0,x) + "...";
obj.innerText = truncated_text;
text_width = obj.offsetWidth;
//window.alert("text_width=" + text_width + ", window_width=" + window_width);
}
truncated_text = text.substr(0,x) + "...";
obj.innerText = truncated_text;
}
}
function updateTextInObj(text, obj, window_width) {
var text_width = obj.offsetWidth;
//get text that is showing and its length
var truncated_text = obj.innerText;
var x = truncated_text.indexOf("...", 0);
if (x == -1)
x=truncated_text.length;
truncated_text = truncated_text.substr(0, x);
if (text_width < window_width) { // add characters
while ((text_width < window_width) && (x < text.length)) {
x = x+5;
truncated_text = text.substr(0,x) + "..."; //"AAAAA...";
obj.innerText = truncated_text;
text_width = obj.offsetWidth;
}
if (x >= text.length) {
truncated_text = text;
}
else {
//back up
x = x-5;
truncated_text = text.substr(0,x) + "...";
}
obj.innerText = truncated_text;
}
else { // remove characters
/*truncated_text = text.substr(0,x) + "..."; //"AAAAA...";
obj.innerText = truncated_text;
text_width = obj.offsetWidth;*/
while ((text_width >= window_width) && (x >= min_chars)) {
//window.alert('removing chars');
x = x-5;
truncated_text = text.substr(0,x) + "..."; //"AAAAA...";
obj.innerText = truncated_text;
text_width = obj.offsetWidth;
//window.alert("text_width=" + text_width + ", window_width=" + window_width);
}
if (x >= text.length) {
truncated_text = text;
}
else {
truncated_text = text.substr(0,x) + "...";
}
obj.innerText = truncated_text;
}
}
function UpdateTitleContent()
{
if (FS_WINDOW_TYPE == "LINKS_LIST") {
if (autoUpdateLinks)
{
document.all.pausebutton.checked = false;
document.all.subtitleanchor.className = "subtitletext";
document.body.className = "listbg";
document.all.resultstd.className = "listbg";
}
else
{
document.all.pausebutton.checked = true;
document.all.subtitleanchor.className = "subtitletextpause";
document.body.className = "listbgpause";
document.all.resultstd.className = "listbgpause";
}
}
}
function togglePause() {
if (document.all.pausebutton.checked) {
window.location.href="flyswat:listlinkssetpause";
document.all.subtitleanchor.className = "subtitletextpause";
document.body.className = "listbgpause";
}
else {
window.location.href="flyswat:listlinkssetupdate";
document.all.subtitleanchor.className = "subtitletext";
document.body.className = "listbg";
}
}
function fixSearchesCatText(cat) {
var text = "Other Searches for " + fslinksenviro.src.substr(9, fslinksenviro.src.length-1);
fscategories[cat].HTML = assembleVertCategoryHTML(text, fscategories[cat].globalID, cat);
}
function Vert_showBrowseLinks()
{
if (fslinksenviro.isValidLinksSet) {
Vert_showValidLinksSet();
}
else {
Vert_showErrorMessage();
}
}
function Vert_showErrorMessage() {
var errorHTML = "" +
"Unable to connect for one or both of the following reasons:
" +
"" +
"- No internet connection
" +
"Please make sure you are connected to the internet." +
"
" +
"- Cannot contact our servers
" +
"Please try again in a few moments." +
" " +
"
";
document.all.SearchResults.innerHTML = errorHTML;
}
//Display categories only,
//display keywords, linktypes and providers when clicked
function Vert_showValidLinksSet()
{
PutCatOnBottom("Searches");
var fsHTML = "";
//-- Show Categories --//
fsHTML += assembleVertSectionsHTML();
document.all.SearchResults.innerHTML = assembleVertTableHTML(fsHTML);
//autoExpand();
}
//==============================================================================
// Auto-Display Functions
// autoExpand, scrollVertPanel
//==============================================================================
//user clicks on topobjname and expands the subobjname below
// e.g. topobjname = "document.all.cat1"
// subobjname = "document.all.keylist1"
function scrollVertPanel(topobjname, subobjname)
{
var topobj = eval(topobjname);
var subobj = eval(subobjname);
var iOrigClientHeight = document.body.clientHeight;
var totalHeight = topobj.offsetHeight + subobj.offsetHeight;
if (totalHeight > iOrigClientHeight) {
topobj.scrollIntoView(1);
}
else {
var topobjTop = getOffsetTop(topobjname);
var i = (topobjTop + totalHeight) - (document.body.scrollTop + iOrigClientHeight);
if (i > 0)
document.body.scrollTop += i;
}
}
//add the offsetTop's of the element and each parent element to get the
//total offsetTop from the top of the page
function getOffsetTop(obj) {
var optxt = ".offsetParent";
var parentobj = eval(obj); //start with the object
var top = 0;
while (parentobj) {
//window.alert(parentobj.id + " - " + parentobj.offsetTop);
top += parentobj.offsetTop;
parentobj = eval(obj + optxt); //go through each parent
optxt += ".offsetParent";
}
return top;
}
//HTML of all link types under a given keyword (fscategories[cat].keywords[k])
function assembleLTListHTML(cat, k) {
var ltlistHTML = "";
with (fscategories[cat].keywords[k]) {
for (var l in linktypes) {
linktypes[l].initializeDisplayProperties(cat,k,l);
var statusText = name + " - " + linktypes[l].name;
if (linktypes[l].providers.length > 0)
statusText += " (provided by " + linktypes[l].providers[0].name + ")";
ltlistHTML += "";
}
}
return ltlistHTML;
}
function assembleProviderListHTML(cat, k, l) {
var provlistHTML = "";
var statusText;
with (fscategories[cat].keywords[k].linktypes[l]) {
for (var p in providers) {
providers[p].initializeDisplayProperties(cat,k,l,p);
statusText = fscategories[cat].keywords[k].name + " - " + fscategories[cat].keywords[k].linktypes[l].name + " (provided by " + providers[p].name + ")";
provlistHTML += "";
}
}
return provlistHTML;
}
//==============================================================
// Helper Functions
//===============================================================
//determine if browser is IE4
var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var using_ie4 = ((is_major == 4) && (agt.indexOf("msie 5.")==-1));
//txt must be escaped
function setStatusText(txt) {
//document.location="flyswat:setStatus(" + txt + ")";
}
function clearStatusText() {
//document.location="flyswat:setStatus()";
}
function hoverCatExpandImg(img) {
if (img.src == DownNormal.src) {
img.src = DownHover.src;
}
else if (img.src == UpNormal.src) {
img.src = UpHover.src;
}
}
function unhoverCatExpandImg(img) {
if (img.src == DownHover.src) {
img.src = DownNormal.src;
}
else if (img.src == UpHover.src) {
img.src = UpNormal.src;
}
}
function hoverLTExpandImg(img) {
if (img.src == PlusNormal.src) {
img.src = PlusHover.src;
}
else if (img.src == MinusNormal.src) {
img.src = MinusHover.src;
}
}
function unhoverLTExpandImg(img) {
if (img.src == PlusHover.src) {
img.src = PlusNormal.src;
}
else if (img.src == MinusHover.src) {
img.src = MinusNormal.src;
}
}
function assembleFSURL(cat, k, l, p)
{
with (fscategories[cat].keywords[k]) {
var catCode = categoryCode;
var ltType = linktypes[l].type;
var keyCode = code;
var keyMT = mt;
var provTag = "";
var bpID = fscategories[cat].bpID;
var bpRev = fscategories[cat].bpRev;
if (arguments.length == 4)
provTag = linktypes[l].providers[p].tag;
}
var fsurl = fslinksenviro.redURL + "?lt=" + safeEscape(ltType) +
"&cc=" + safeEscape(catCode) + "&kc=" + safeEscape(keyCode) +
"&pp=" + safeEscape(provTag) + "&r=" + safeEscape(fslinksenviro.requestID) +
"&m=" + safeEscape(keyMT) + "&sn=" + safeEscape(fssystemenviro.serialNum) +
"&dt=" + safeEscape(fslinksenviro.distTag) + "&bi=" + safeEscape(bpID) +
"&br=" + safeEscape(bpRev) + "&bp=";
if (fscategories[cat].boosterPackCategory) {
fsurl += "1";
}
else {
fsurl += "0";
}
return fsurl;
}
//------------------------------------------------------------
// function: safeEscape
// author: Leo
// comments: escape(str, 1) doesn't work!!
// And I can't get regex's to work
//------------------------------------------------------------
function safeEscape(str) {
escaped_str = escape(str);
if (escaped_str.indexOf("+") > -1) {
var arr = escaped_str.split("+");
escaped_str = arr.join("%2B");
}
return escaped_str;
}
//------------------------------------------------------------
// function: safeEscape2
// author: Mark
// comments: Had to implement because Javascript problem
// with variable names having '%' char in them
// so replacing with '$'.
//------------------------------------------------------------
function safeEscape2(str)
{
var iChar;
var iStrLen = str.length;
var newStr = "";
for (i = 0; i < iStrLen; i++)
{
iChar = str.charCodeAt(i);
if ((iChar < 48) || ((iChar > 57) && (iChar < 65)) || ((iChar > 90) && (iChar < 97)) || (iChar > 122))
{
newStr += "$" + iChar;
}
else
newStr += str.charAt(i);
}
return newStr;
}
//------------------------------------------------------------------
// Creates a global list of ID's
// A new ID is added for each new category, keyword, linktype,
// and provider, as well as at any other time.
//------------------------------------------------------------------
var globalIDList = new Array();
function setGlobalID(str) {
if (isMemberOf(str, globalIDList)) {
var i=1;
while (isMemberOf(str + i, globalIDList))
i += 1;
str = str + i;
}
globalIDList[globalIDList.length] = str;
return str;
}
//------------------------------------------------
// returns true if "element" is a member of
// "array", otherwise returns false
//------------------------------------------------
function isMemberOf(element, array)
{
for (var i=0; i < array.length; i++)
{
if (array[i] == element)
return true;
}
return false;
}
//==============================================================
// Show/Hide HTML Functions
//===============================================================
var showingProviderList = "";
function showhideProviderList(cat, k, l)
{
var lt = fscategories[cat].keywords[k].linktypes[l];
//closing an open provider list
if (lt.providerListShowing) {
lt.hideProviderList();
showingProviderList = "";
}
//opening a provider list
else {
//close the previously opened list
if (showingProviderList)
showingProviderList.hideProviderList();
lt.showProviderList(cat, k, l);
showingProviderList = lt;
}
if (FS_WINDOW_TYPE == "POPUP")
checkScrolling();
}
var showingLTList = "";
function showhideLTList(cat, k)
{
var keyword = fscategories[cat].keywords[k];
//closing an open lt list
if (keyword.ltListShowing) {
keyword.hideLTList();
if (FS_WINDOW_TYPE != "POPUP") {
showingLTList = "";
}
}
//opening a provider list
else {
keyword.showLTList(cat, k);
if (FS_WINDOW_TYPE != "POPUP") {
if (showingLTList)
showingLTList.hideLTList();
showingLTList = keyword;
}
}
if (FS_WINDOW_TYPE == "POPUP")
checkScrolling();
}
var showingKeyList = "";
function showhideKeyList(cat)
{
var category = fscategories[cat];
if (category.keyListShowing) {
category.hideKeyList();
showingKeyList = "";
}
else {
//close the previously opened list
if (showingKeyList)
showingKeyList.hideKeyList();
category.showKeyList(cat);
showingKeyList = category;
}
if (FS_WINDOW_TYPE == "POPUP")
checkScrolling();
}
//-----------------------------------------------------------------
// function: PutCatOnBottom
// author: Mark
// comments: Will take the fscategories array and put the
// category with "catcode" at the end of the array.
//-----------------------------------------------------------------
function PutCatOnBottom(catcode)
{
bSearchesNotFound = 1;
var cat = 0;
while ((cat < fscategories.length) && (bSearchesNotFound)) {
var catCode = fscategories[cat].keywords[0].categoryCode;
var iSearchesIndex = 0;
if (catCode == catcode) {
var searchCat = fscategories[cat];
bSearchesNotFound = 0;
iSearchesIndex = cat;
iSearchesIndex++;
for (var i = iSearchesIndex; i < fscategories.length; i++)
{
fscategories[i - 1] = fscategories[i];
}
fscategories[fscategories.length - 1] = searchCat;
}
cat++;
}
}
Flyswat Control Band