//FF - this class is overridden by toolbar //IE - this class catches all the calls IE didn't catch. var _TPI = { Result : "", ResetResult : function() { this.Result = ""; }, SetResult : function(strResult) { this.Result += strResult; }, GetResult : function(bIsMultipleResponse) { return _TPIHelper.GetResult(this.Result,bIsMultipleResponse); }, ExecuteApiFunction : function(strFuncName,strParam) { //do nothing } } //Wrapped JS function for IE to return Result function _TPISetResult(strXmlResult) { _TPI.SetResult(strXmlResult); } //Helper object with service functions for interaction with the toolbar. var _TPIHelper = { //This function interacts directly with toolbar, by calling JS functions, //which IE interprets as navigation, and FF gets the function itself. //arguments : [0] - boolean isMultiple response // [1] - function name // [2]..[n] function arguments ExecuteFunction : function() { _TPI.ResetResult(); var bIsMultipleResponse = arguments[0]; var strHref = "javascript:_TPI.ExecuteApiFunction("; for(var i=1;i"; var oRootXML = null; var bIsMulty = false; if(window.ActiveXObject) { oRootXML = new ActiveXObject("Microsoft.XMLDOM"); oRootXML.async = "false"; oRootXML.loadXML(strResult); oRootXML = oRootXML.documentElement; } else { var parser = new DOMParser(); oRootXML = parser.parseFromString(strResult, "text/xml"); oRootXML = oRootXML.documentElement; } if(oRootXML.childNodes.length > 1 || bIsMultipleResponse) { bIsMulty = true; arrResult = new Array(); } for(var z=0;z/g, '>'); strXML = strXML.replace(/\'/g, '''); strXML = strXML.replace(/\"/g, '"'); return strXML; }, //Returns correct XML defining toolbar button BuildButtonXml : function(buttonLabel,buttonIcon,buttonTooltip,xmlData, optionsDisplayText,optionsDisplayIcon,uniqueComponentID) { var strXML = ''; return strXML; }, //Returns correct XML defining toolbar RSS component BuildRssXml : function(buttonLabel,buttonIcon,rssFeedUrl,buttonNewMessagesIcon,optionsDisplayText, optionsDisplayIcon,refreshIntervalInMinutes,uniqueComponentID) { var strXML = ''; strXML += 'TrueTrueTrue'; strXML += 'FULLTrue'; strXML += ''+this.ToLegalXML(uniqueComponentID)+''; strXML += ''+this.ToLegalXML(optionsDisplayText)+''; strXML += ''+this.ToLegalXML(optionsDisplayIcon)+''; strXML += ''+this.ToLegalXML(buttonLabel)+''; strXML += ''+this.ToLegalXML(rssFeedUrl)+''; strXML += ''+this.ToLegalXML(buttonIcon)+''; strXML += ''+this.ToLegalXML(buttonNewMessagesIcon)+''; strXML += 'False'; strXML += ''+this.ToLegalXML(refreshIntervalInMinutes)+''; strXML += ''; strXML += 'ADJUSTIVE'; strXML += ''; return strXML; }, //Returns correct XML defining toolbar RadioSation BuildRadioStationXml : function(name,url,contantType,mediaType,uniqueComponentID) { var strXML = ''; strXML += ''+this.ToLegalXML(uniqueComponentID)+''; strXML += ''+this.ToLegalXML(name)+''; strXML += ''+this.ToLegalXML(url)+''; strXML += ''+mediaType+''; strXML += ''+contantType+''; strXML += ''; return strXML; } } //User object to interact with toolbar / toolbars var TPI = { Toolbar : function(strCTID) { this.CTID = strCTID; if(this.CTID) { this.IsLatestApi = _TPIHelper.ExecuteFunction(false,"IsLatestApi",strCTID).returnValue; this.IsToolbarInstalled = -1; } this.Refresh = function() { if(this.CTID) { if(this.IsLatestApi) { return _TPIHelper.ExecuteFunction(false,"RefreshToolbarByCTID",this.CTID); } else { var bResult = RefreshToolbarByCTID(this.CTID); return _TPIHelper.GetOldApiResult(bResult); } } else { return this.NoCTID(); } }; this.IsVisible = function() { if(this.CTID) { if(this.IsLatestApi) { return _TPIHelper.ExecuteFunction(false,"IsToolbarVisible",this.CTID); } else { var bResult = IsToolbarInstalled(this.CTID) return _TPIHelper.GetOldApiResult(bResult); } } else { return this.NoCTID(); } }; this.AddComponentByXML = function(strXML) { if(this.CTID) { if(this.IsLatestApi) { return _TPIHelper.ExecuteFunction(false,"AddComponentByXML",strXML,this.CTID); } else { var bResult = AddComponentByXML(strXML,this.CTID) return _TPIHelper.GetOldApiResult(bResult); } } else { return this.NoCTID(); } }; this.GetInfo = function() { if(this.CTID) { if(this.IsLatestApi) { return _TPIHelper.ExecuteFunction(false,"GetToolbarInfo",this.CTID); } else { if(!this.GetIsToolbarInstalled()) { return this.NoToolbarInstalled(); } return this.UnsupportedCommand() } } else { return this.NoCTID(); } }; this.AddGadget = function(buttonLabel,buttonIcon,buttonTooltip,linkTargetUrl, width,height,defaultTarget,optionsDisplayText,optionsDisplayIcon,uniqueComponentID) { if(this.CTID) { //parameters checks if(buttonLabel == "" && buttonIcon == "" && optionsDisplayIcon == "" && optionsDisplayText == "") { return this.ParametersError(); } if(typeof linkTargetUrl == "undefined" || linkTargetUrl == "") { return this.ParametersError(); } if(typeof width == "undefined" || width == "" || height == "undefined" || height == "") { return this.ParametersError(); } if(typeof optionsDisplayText == "undefined" || optionsDisplayText == "") { optionsDisplayText = buttonLabel; } if(typeof optionsDisplayIcon == "undefined" || optionsDisplayIcon == "") { optionsDisplayIcon = buttonIcon; } if(typeof uniqueComponentID == "undefined" || uniqueComponentID == "") { uniqueComponentID = "gadget" + linkTargetUrl + width + height; } if(typeof defaultTarget == "undefined" || defaultTarget == "") { linkTarget = "_SELF"; } var xmlData = "POP_HTML"+_TPIHelper.ToLegalXML(linkTargetUrl)+""; xmlData += ""+_TPIHelper.ToLegalXML(defaultTarget)+""+width+""+height+""; var strXML = _TPIHelper.BuildButtonXml(buttonLabel,buttonIcon,buttonTooltip,xmlData, optionsDisplayText,optionsDisplayIcon,uniqueComponentID); return this.AddComponentByXML(strXML); } else { return this.NoCTID(); } }; this.AddRSS = function(buttonLabel,buttonIcon,rssFeedUrl,buttonNewMessagesIcon,optionsDisplayText, optionsDisplayIcon,refreshIntervalInMinutes,uniqueComponentID) { if(this.CTID) { //parameters checks if(buttonLabel == "" && buttonIcon == "" && optionsDisplayIcon == "" && optionsDisplayText == "") { return this.ParametersError(); } if(typeof rssFeedUrl == "undefined" || rssFeedUrl == "") { return this.ParametersError(); } if(typeof optionsDisplayText == "undefined" || optionsDisplayText == "") { optionsDisplayText = buttonLabel; } if(typeof optionsDisplayIcon == "undefined" || optionsDisplayIcon == "") { optionsDisplayIcon = buttonIcon; } if(typeof buttonNewMessagesIcon == "undefined" || buttonNewMessagesIcon == "") { buttonNewMessagesIcon = buttonIcon; } if(typeof uniqueComponentID == "undefined" || uniqueComponentID == "") { uniqueComponentID = "rss" + rssFeedUrl; } if(typeof refreshIntervalInMinutes == "undefined" || refreshIntervalInMinutes == "") { refreshIntervalInMinutes = "120"; } var strXML = _TPIHelper.BuildRssXml(buttonLabel,buttonIcon,rssFeedUrl,buttonNewMessagesIcon,optionsDisplayText, optionsDisplayIcon,refreshIntervalInMinutes,uniqueComponentID); return this.AddComponentByXML(strXML); } else { return this.NoCTID(); } }; this.AddLinkButton = function(buttonLabel,buttonIcon,buttonTooltip,linkTargetUrl, linkTarget,optionsDisplayText,optionsDisplayIcon,uniqueComponentID) { if(this.CTID) { //parameters checks if(buttonLabel == "" && buttonIcon == "" && optionsDisplayIcon == "" && optionsDisplayText == "") { return this.ParametersError(); } if(typeof linkTargetUrl == "undefined" || linkTargetUrl == "") { return this.ParametersError(); } if(typeof optionsDisplayText == "undefined" || optionsDisplayText == "") { optionsDisplayText = buttonLabel; } if(typeof optionsDisplayIcon == "undefined" || optionsDisplayIcon == "") { optionsDisplayIcon = buttonIcon; } if(typeof uniqueComponentID == "undefined" || uniqueComponentID == "") { uniqueComponentID = "button" + linkTargetUrl; } if(typeof linkTarget == "undefined" || linkTarget == "") { linkTarget = "SELF"; } var xmlData = "LINK"+_TPIHelper.ToLegalXML(linkTargetUrl)+""+_TPIHelper.ToLegalXML(linkTarget)+""; var strXML = _TPIHelper.BuildButtonXml(buttonLabel,buttonIcon,buttonTooltip,xmlData, optionsDisplayText,optionsDisplayIcon,uniqueComponentID); return this.AddComponentByXML(strXML); } else { return this.NoCTID(); } }; this.AddRadioStation = function(name,url,contantType,mediaType,uniqueComponentID) { if(!name || !url) { return this.ParametersError(); } if(!contantType) { contantType = "MP"; } if(!mediaType) { mediaType = "STREAM"; } if(!uniqueComponentID) { uniqueComponentID = url; } var strXML = _TPIHelper.BuildRadioStationXml(name,url,contantType,mediaType,uniqueComponentID); if(this.CTID) { if(this.IsLatestApi) { return _TPIHelper.ExecuteFunction(false,"AddRadioStation",strXML,this.CTID); } else { if(!this.GetIsToolbarInstalled()) { return this.NoToolbarInstalled(); } return this.UnsupportedCommand() } } else { return this.NoCTID(); } }; //builds xml for response parser, for unsupported command this.UnsupportedCommand = function() { var strXmlResult = "false2"; return _TPIHelper.GetResult(strXmlResult); }; //builds xml for response parser, for input parameters error this.ParametersError = function() { var strXmlResult = "false3"; return _TPIHelper.GetResult(strXmlResult); }; this.NoToolbarInstalled = function() { var strXmlResult = "false0"; return _TPIHelper.GetResult(strXmlResult); }; this.NoCTID = function() { var strXmlResult = "false6"; return _TPIHelper.GetResult(strXmlResult); }; this.GetIsToolbarInstalled = function() { if(this.IsToolbarInstalled == -1) { this.IsToolbarInstalled = IsToolbarInstalled(this.CTID); } return this.IsToolbarInstalled; } }, //Helper manager to interract with multiple toolbars Manager : function() { this.GetAllToolbarsInfo = function() { // underscore is to tell the return object parser that the return object is array. return _TPIHelper.ExecuteFunction(true,"GetAllToolbarsInfo"); }; this.AddAlert = function(alertId) { return _TPIHelper.ExecuteFunction(false,"AddAlert", alertId); } } } // ======================= Older API Functions ======================== //this is a blank object //this object is used to catch all the calls //that the toolbars(IE & Firefox) didn't catch var EBToolbarApi = { Result : false, ResetResult : function() { this.SetResult(false); }, SetResult : function(bValue) { this.Result = bValue; }, GetResult : function() { return this.Result; }, RefreshAllToolbars : function() { //do nothing... }, RefreshToolbarByCTID : function(strCTID) { //do nothing... }, IsToolbarInstalled : function(strCTID) { //do nothing... }, AddComponentByXML : function(strXML,strCTID) { //do nothing... } } //wrapped function to set result (for IE) function EBSetResult(bValue) { EBToolbarApi.SetResult(bValue); } //------------------------------------------------------------------- /***** Public API Functions *****/ /******************************** - IMPORTTANT - **********************************/ // // // The functions should be called the earliset at the onload event of the page // // // /**********************************************************************************/ /************************************************/ /* bool RefreshAllToolbars() */ /* This function refreshes all toolbars. */ /************************************************/ function RefreshAllToolbars() { EBToolbarApi.ResetResult(); if(_TPIHelper.GetBrowser() == "IE7") { var frameSrc = 'about:blank#javascript:EBToolbarApi.RefreshAllToolbars();'; _TPIHelper.NavigateInIFrame(frameSrc); } else { location.href = 'javascript:EBToolbarApi.RefreshAllToolbars();'; } return EBToolbarApi.GetResult(); } /************************************************/ /* bool RefreshToolbarByCTID(strCTID) */ /* This function refreshes the toolbar by CTID.*/ /************************************************/ function RefreshToolbarByCTID(strCTID) { EBToolbarApi.ResetResult(); if(_TPIHelper.GetBrowser() == "IE7") { var frameSrc = 'about:blank#javascript:EBToolbarApi.RefreshToolbarByCTID(\'' + strCTID + '\');'; _TPIHelper.NavigateInIFrame(frameSrc); } else { location.href = 'javascript:EBToolbarApi.RefreshToolbarByCTID(\'' + strCTID + '\');'; } return EBToolbarApi.GetResult(); } /************************************************/ /* bool IsToolbarInstalled(strCTID) */ /* This function returns true if the toolbar */ /* with the given CTID is installed. */ /************************************************/ function IsToolbarInstalled(strCTID) { EBToolbarApi.ResetResult(); if(_TPIHelper.GetBrowser() == "IE7") { var frameSrc = 'about:blank#javascript:EBToolbarApi.IsToolbarInstalled(\'' + strCTID + '\');'; _TPIHelper.NavigateInIFrame(frameSrc); } else { location.href = 'javascript:EBToolbarApi.IsToolbarInstalled(\'' + strCTID + '\');'; } return EBToolbarApi.GetResult(); } /************************************************/ /* bool AddComponentByXML(strXML,strCTID) */ /* This function returns true if the toolbar */ /* with the given CTID is installed. */ /************************************************/ function AddComponentByXML(strXML,strCTID) { EBToolbarApi.ResetResult(); if(_TPIHelper.GetBrowser() == "IE7") { var frameSrc = "about:blank#javascript:EBToolbarApi.AddComponentByXML(\""+strXML+"\",\"CTID="+strCTID.toUpperCase()+"\");"; _TPIHelper.NavigateInIFrame(frameSrc); } else { location.href = 'javascript:EBToolbarApi.AddComponentByXML("'+strXML+'","CTID='+strCTID.toUpperCase()+'");'; } return EBToolbarApi.GetResult(); }