* use 'mozt' namespace in .js files
* style: '_' prefix for private attributes (common.js)
This commit is contained in:
parent
ddf1763b9a
commit
0d25df1d17
|
@ -6,17 +6,19 @@ Components.utils.import("resource://moztray/LibGtkStatusIcon.js");
|
|||
const MOZT_ICON_DIR = "chrome/skin/";
|
||||
const MOZT_ICON_FIREFOX = "firefox32.png";
|
||||
|
||||
moztray.Main = {
|
||||
mozt.Main = {
|
||||
|
||||
onLoad: function() {
|
||||
mozt.Debug.dump('Moztray GO !');
|
||||
|
||||
// initialization code
|
||||
this.initialized = null;
|
||||
this.strings = document.getElementById("moztray-strings");
|
||||
|
||||
try {
|
||||
// Set up preference change observer
|
||||
moztray.Utils.prefService.QueryInterface(Ci.nsIPrefBranch2);
|
||||
moztray.Utils.prefService.addObserver("", this, false);
|
||||
mozt.Utils.prefService.QueryInterface(Ci.nsIPrefBranch2);
|
||||
mozt.Utils.prefService.addObserver("", this, false);
|
||||
}
|
||||
catch (ex) {
|
||||
Components.utils.reportError(ex);
|
||||
|
@ -29,28 +31,28 @@ moztray.Main = {
|
|||
LibGtkStatusIcon.gtk_status_icon_set_from_file(this.tray_icon,
|
||||
icon_filename);
|
||||
|
||||
moztray.Debug.dump('Moztray LOADED !');
|
||||
mozt.Debug.dump('Moztray LOADED !');
|
||||
this.initialized = true;
|
||||
return true;
|
||||
},
|
||||
|
||||
onQuit: function() {
|
||||
// Remove observer
|
||||
moztray.Utils.prefService.removeObserver("", this);
|
||||
mozt.Utils.prefService.removeObserver("", this);
|
||||
LibGtkStatusIcon.shutdown();
|
||||
|
||||
moztray.Debug.dump('Moztray UNLOADED !');
|
||||
mozt.Debug.dump('Moztray UNLOADED !');
|
||||
this.initialized = false;
|
||||
},
|
||||
|
||||
observe: function(subject, topic, data) {
|
||||
// Observer for pref changes
|
||||
if (topic != "nsPref:changed") return;
|
||||
moztray.Debug.dump('Pref changed: '+data);
|
||||
mozt.Debug.dump('Pref changed: '+data);
|
||||
|
||||
switch(data) {
|
||||
// case 'enabled':
|
||||
// var enable = moztray.Utils.prefService.getBoolPref('enabled');
|
||||
// var enable = mozt.Utils.prefService.getBoolPref('enabled');
|
||||
// this._toggle(enable);
|
||||
// break;
|
||||
}
|
||||
|
@ -62,5 +64,5 @@ moztray.Main = {
|
|||
// should be sufficient for a delayed Startup (no need for window.setTimeout())
|
||||
// https://developer.mozilla.org/en/Extensions/Performance_best_practices_in_extensions
|
||||
// https://developer.mozilla.org/en/XUL_School/JavaScript_Object_Management.html
|
||||
window.addEventListener("load", function (e) { moztray.Main.onLoad(); }, false);
|
||||
window.addEventListener("unload", function(e) { moztray.Main.onQuit(); }, false);
|
||||
window.addEventListener("load", function (e) { mozt.Main.onLoad(); }, false);
|
||||
window.addEventListener("unload", function(e) { mozt.Main.onQuit(); }, false);
|
||||
|
|
|
@ -6,31 +6,31 @@
|
|||
* http://developer.mozilla.org/en/XUL_School/JavaScript_Object_Management.html
|
||||
*/
|
||||
|
||||
var EXPORTED_SYMBOLS = [ "moztray" ];
|
||||
var EXPORTED_SYMBOLS = [ "mozt" ];
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
|
||||
/**
|
||||
* moztray namespace.
|
||||
* mozt namespace.
|
||||
*/
|
||||
if ("undefined" == typeof(moztray)) {
|
||||
var moztray = {
|
||||
if ("undefined" == typeof(mozt)) {
|
||||
var mozt = {
|
||||
DEBUG_MODE: true,
|
||||
};
|
||||
};
|
||||
|
||||
moztray.Debug = {
|
||||
initialized: false,
|
||||
mozt.Debug = {
|
||||
_initialized: false,
|
||||
|
||||
/**
|
||||
* Object constructor.
|
||||
*/
|
||||
init: function() {
|
||||
if (this.initialized) return;
|
||||
this.consoleService = Cc['@mozilla.org/consoleservice;1'].getService(Ci.nsIConsoleService);
|
||||
if (this._initialized) return;
|
||||
this._consoleService = Cc['@mozilla.org/consoleservice;1'].getService(Ci.nsIConsoleService);
|
||||
this.dump("Moztray Debug initialized");
|
||||
this.initialized = true;
|
||||
this._initialized = true;
|
||||
},
|
||||
|
||||
/* Console logging functions */
|
||||
|
@ -40,12 +40,12 @@ moztray.Debug = {
|
|||
* IT'S IMPORTANT THAT DEBUG CALLS ARE WRITTEN ON A SINGLE LINE !
|
||||
*/
|
||||
dump: function(message) { // Debuging function -- prints to javascript console
|
||||
if(!moztray.DEBUG_MODE) return;
|
||||
this.consoleService.logStringMessage(message);
|
||||
if(!mozt.DEBUG_MODE) return;
|
||||
this._consoleService.logStringMessage(message);
|
||||
},
|
||||
|
||||
dumpObj: function(obj) {
|
||||
if(!moztray.DEBUG_MODE) return;
|
||||
if(!mozt.DEBUG_MODE) return;
|
||||
var str = "";
|
||||
for(i in obj) {
|
||||
try {
|
||||
|
@ -59,10 +59,10 @@ moztray.Debug = {
|
|||
|
||||
};
|
||||
// build it !
|
||||
moztray.Debug.init();
|
||||
mozt.Debug.init();
|
||||
|
||||
|
||||
moztray.Utils = {
|
||||
mozt.Utils = {
|
||||
|
||||
prefService: Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService)
|
||||
.getBranch("extensions.moztray."),
|
||||
|
|
Loading…
Reference in New Issue