home *** CD-ROM | disk | FTP | other *** search
- // core callback for mlist
- function cbGetShopMList(status, mlist)
- {
- if (status==objCoreGlobal.GET_APPDATA_SUCCEED)
- {
- mlist = mlist.substr(mlist.indexOf("var ")+4);
- eval(mlist);
- return true;
- }
- if (status==objCoreGlobal.GET_APPDATA_TIMEOUT)
- {}
- return false;
- }
-
- function shouldDisplayToolbar( url )
- {
- if ( gState == false)
- return false;
-
- var newSite = getHostName( url );
- if ( isShoppingSite( newSite ) )
- {
- if(newSite.indexOf("kavamedia.com")>0)
- if(!(url.indexOf("kavamedia.com/philips")>0))
- return false;
- return true;
- }
- else
- return false;
- }
-
- function isShoppingSite( site )
- {
- if ( shoppingSites.indexOf(" " + site + " " ) >= 0 )
- return true;
-
- var ind = site.indexOf(".");
- var truncatedSite = site.substr( ind+1, site.length );
-
- if ( shoppingSites.indexOf(" " + truncatedSite + " " ) >= 0 )
- return true;
- return false;
- }
-
- function onAolBeforeNavigate(newURL)
- {
- nonQCPPURL = stripQCPP( newURL );
- var newDomain = getURLDomain(nonQCPPURL);
- // ignore javascript: urls
- if ( newURL.indexOf("javascript:") == 0 )
- return true;
-
- if ( newDomain != gActiveDomain )
- {
- if ( shouldDisplayToolbar( newURL ) )
- return true; // don't change the state of the bar. If it's still showing, keep showing it
- showBar( false); // hide it
- }
- return true; // keep showing it
- }
- function onAolNavigateComplete(newURL){}
- function onAolFrameNavigateComplete(newURL){}
- function onAolFrameDocumentComplete(newURL) {}
- function onAolDocumentComplete(newURL)
- {
- if ( objCoreGlobal.WinX < SA_MIN_WIN_WIDTH || objCoreGlobal.WinY < SA_MIN_WIN_HEIGHT )
- {
- gState = false;
- showBar( false);
- return false;
- }
- else
- gState = true;
-
- nonQCPPURL = stripQCPP( newURL );
- gActiveURL = nonQCPPURL;
- gActiveDomain = getURLDomain( nonQCPPURL );
-
- if ( shouldDisplayToolbar( nonQCPPURL ) )
- showBar( true);
- else
- showBar( false);
- }
-
- function stripQCPP( url )
- {
- if ( url == null || url == "" )
- return "";
- var re = new RegExp("http://qcpp.aol.com/[^/]+/", "gi" );
- var newURL = url.replace(re, "http://" );
- return newURL;
- }
-
- function getURLDomain(url)
- {
- url = stripQCPP(url);
- var ind = url.indexOf("://");
- if (ind == -1)
- ind = 0;
- else
- ind += 3;
-
- var suburl = url.substr(ind);
- // get host from suburl
- var hostInd = suburl.indexOf(":");
- var hostIndSlash = suburl.indexOf("/");
-
- if ( (hostInd > 0) && (hostInd < hostIndSlash) )
- {}
- else
- hostInd = hostIndSlash;
-
- var host = (hostInd == -1) ? suburl : suburl.substring(0, hostInd);
- var firstDot = host.lastIndexOf(".");
- if ((firstDot != -1) && (firstDot != 0))
- {
- var secondDot = host.lastIndexOf(".", firstDot - 1);
- if (secondDot != -1)
- return host.substr(secondDot + 1, host.length);
- }
- return host;
- }
-
- function getHostName(url)
- {
- url = stripQCPP(url);
- var ind = url.indexOf("://");
- if (ind == -1)
- ind = 0;
- else
- ind += 3;
-
- var suburl = url.substr(ind);
- var hostInd = suburl.indexOf(":");
- var hostIndSlash = suburl.indexOf("/");
- if ( (hostInd > 0) && (hostInd < hostIndSlash) )
- {
- }
- else
- hostInd = hostIndSlash;
- var host = (hostInd == -1) ? suburl : suburl.substring(0, hostInd);
- return host;
- }
-
- function showBar(show)
- {
- if ( ! show )
- objCoreGlobal.ShowBar(false, 0, "");
- else
- objCoreGlobal.ShowBar(true, HEIGHT_WINDOW, "../toolbar/channels/shop/shop.html");
- }