PK
5x chrome/content/overlay.xul
PK
ʽ5z|' ' chrome/content/starter.js// Throbber Button extension
// Adds back throbber URL functionality that was removed in Firefox 2.0a3
// Initial Developer: Aaron Pauls
// Contributors:
// See license.txt for source license information.
var ThrobberButton = {
prefService: null, // Prefs service
bundle: null, // Stringbundle containing locale-specific strings
sThrobberURL: null, // Primary throbber URL
sTooltipPrefix: null, // Prefix added to front of throbber tooltip
bProcessClick: false, // Accept clicks on throbber - true in FF 2+, false in 1.x
bAltClick: false, // Indicates if Alt was used in combination with clicking throbber
// Startup: called ONCE during the browser window "load" event
Startup: function()
{
this.bAltClick= false;
// Load pref service
this.prefService= Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService)
.getBranch("browser.throbber.");
if (this.prefService==null) { alert("ThrobberButton prefService not initialized"); return; }
// Get localized strings
this.bundle= document.getElementById("throbberbundle");
if (this.bundle==null) { alert("ThrobberButton bundle not initialized"); return; }
try { this.sTooltipPrefix= this.bundle.getString("urlPrefix"); }
catch (e) { this.sTooltipPrefix= ""; }
// Check browser version
var appinfo= Components.classes['@mozilla.org/xre/app-info;1']
.getService(Components.interfaces.nsIXULAppInfo);
if (appinfo!=null && appinfo.name=="Firefox" && appinfo.version.substring(0,2)=="1.") // Firefox 1.x
this.bProcessClick= false;
else
this.bProcessClick= true;
// Verify throbber icon is being displayed
if (document.getElementById("navigator-throbber")==null)
this.NotifyNoThrobber();
// Observer for browser.throbber.* prefs
this.prefService.QueryInterface(Components.interfaces.nsIPrefBranch2);
this.prefService.addObserver("", this, false);
// Manually set up the first time
this.CheckURL();
this.UpdateTooltip();
},
// Shutdown: called ONCE during the browser window "unload" event
Shutdown: function()
{
this.prefService.removeObserver("", this);
this.prefService= null;
},
// observe: Subclassed observer function to watch pref changes in browser.throbber
observe: function(subject, topic, data)
{
if (topic=="nsPref:changed" && data=="url") // If a pref we care about was changed...
{
this.CheckURL();
this.UpdateTooltip();
}
},
// GetThrobberCharPref: Get the throbber pref, returning null if not found
GetThrobberCharPref: function(sName)
{
try { return this.prefService.getCharPref(sName); }
catch (e) { return null; }
},
// CheckURL: Store the main URL for easy access
CheckURL: function()
{
try { this.sThrobberURL= this.prefService.getCharPref("url"); }
catch (e) { this.sThrobberURL= ""; }
},
// UpdateTooltip: Set the tooltip to the domain name of the URL
UpdateTooltip: function()
{
var sTooltip;
var iLeftIndex, iRightIndex;
sTooltip= this.sThrobberURL;
if (sTooltip.length > 0)
{
// Remove stuff on and before //
iLeftIndex= sTooltip.indexOf("//");
if (iLeftIndex>=0 && iLeftIndex+2<=sTooltip.length)
iLeftIndex= iLeftIndex + 2;
else
iLeftIndex= 0;
// Remove stuff on and after the first / (following the first //)
iRightIndex= sTooltip.indexOf("/",iLeftIndex);
if (iRightIndex<0 || iRightIndex