|
|
@ -10,8 +10,8 @@
|
|
|
|
Window,
|
|
|
|
Window,
|
|
|
|
Tab,
|
|
|
|
Tab,
|
|
|
|
Panel,
|
|
|
|
Panel,
|
|
|
|
Widget,
|
|
|
|
Button,
|
|
|
|
widget, // Keep track of a global widget instance. A widget per window does not work.
|
|
|
|
button,
|
|
|
|
UrlBar;
|
|
|
|
UrlBar;
|
|
|
|
|
|
|
|
|
|
|
|
exports.main = function(options, callbacks) {
|
|
|
|
exports.main = function(options, callbacks) {
|
|
|
@ -40,21 +40,28 @@
|
|
|
|
this.window = win;
|
|
|
|
this.window = win;
|
|
|
|
this.tabs = {};
|
|
|
|
this.tabs = {};
|
|
|
|
this.urlBar = null;
|
|
|
|
this.urlBar = null;
|
|
|
|
this.widget = null;
|
|
|
|
|
|
|
|
|
|
|
|
if ( button ) {
|
|
|
|
|
|
|
|
button.destroy();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( require('sdk/simple-prefs').prefs.urlbar ) {
|
|
|
|
if ( require('sdk/simple-prefs').prefs.urlbar ) {
|
|
|
|
this.urlBar = new UrlBar(this.window);
|
|
|
|
this.urlBar = new UrlBar(this.window);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.widget = widget || ( widget = new Widget() );
|
|
|
|
button = new Button();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
require('sdk/simple-prefs').on('urlbar', function() {
|
|
|
|
require('sdk/simple-prefs').on('urlbar', function() {
|
|
|
|
self.destroy();
|
|
|
|
self.destroy();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( button ) {
|
|
|
|
|
|
|
|
button.destroy();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( require('sdk/simple-prefs').prefs.urlbar ) {
|
|
|
|
if ( require('sdk/simple-prefs').prefs.urlbar ) {
|
|
|
|
self.urlBar = new UrlBar(this.window);
|
|
|
|
self.urlBar = new UrlBar(this.window);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
self.widget = widget || ( widget = new Widget() );
|
|
|
|
button = new Button();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
self.displayApps();
|
|
|
|
self.displayApps();
|
|
|
@ -120,8 +127,8 @@
|
|
|
|
this.urlBar.panel.get().port.emit('displayApps', message);
|
|
|
|
this.urlBar.panel.get().port.emit('displayApps', message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( this.widget ) {
|
|
|
|
if ( button ) {
|
|
|
|
this.widget.setIcon();
|
|
|
|
button.setIcon();
|
|
|
|
|
|
|
|
|
|
|
|
if ( count ) {
|
|
|
|
if ( count ) {
|
|
|
|
var
|
|
|
|
var
|
|
|
@ -133,7 +140,7 @@
|
|
|
|
for ( appName in w.detected[url] ) {
|
|
|
|
for ( appName in w.detected[url] ) {
|
|
|
|
w.apps[appName].cats.forEach(function(cat) {
|
|
|
|
w.apps[appName].cats.forEach(function(cat) {
|
|
|
|
if ( cat == match && !found ) {
|
|
|
|
if ( cat == match && !found ) {
|
|
|
|
self.widget.setIcon(appName);
|
|
|
|
button.setIcon(appName);
|
|
|
|
|
|
|
|
|
|
|
|
found = true;
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -142,7 +149,7 @@
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.widget.panel.get().port.emit('displayApps', message);
|
|
|
|
button.panel.get().port.emit('displayApps', message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -152,12 +159,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
this.urlBar = null;
|
|
|
|
this.urlBar = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( this.widget ) {
|
|
|
|
|
|
|
|
this.widget.destroy();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.widget = null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Tab = function(tab) {
|
|
|
|
Tab = function(tab) {
|
|
|
@ -190,7 +191,12 @@
|
|
|
|
height: 50,
|
|
|
|
height: 50,
|
|
|
|
contentURL: require('sdk/self').data.url('panel.html'),
|
|
|
|
contentURL: require('sdk/self').data.url('panel.html'),
|
|
|
|
contentScriptFile: require('sdk/self').data.url('js/panel.js'),
|
|
|
|
contentScriptFile: require('sdk/self').data.url('js/panel.js'),
|
|
|
|
position: { right: 30, top: 30 }
|
|
|
|
position: { right: 30, top: 30 },
|
|
|
|
|
|
|
|
onHide: function() {
|
|
|
|
|
|
|
|
if ( button ) {
|
|
|
|
|
|
|
|
button.get().state('window', { checked: false });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
this.panel.port.on('resize', function(height) {
|
|
|
|
this.panel.port.on('resize', function(height) {
|
|
|
@ -212,31 +218,37 @@
|
|
|
|
this.panel.destroy();
|
|
|
|
this.panel.destroy();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Widget = function() {
|
|
|
|
Button = function() {
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
|
|
|
|
this.panel = new Panel();
|
|
|
|
this.panel = new Panel();
|
|
|
|
|
|
|
|
|
|
|
|
this.widget = require('sdk/widget').Widget({
|
|
|
|
this.button = require('sdk/ui/button/toggle').ToggleButton({
|
|
|
|
id: 'wappalyzer',
|
|
|
|
id: 'wappalyzer',
|
|
|
|
label: 'Wappalyzer',
|
|
|
|
label: 'Wappalyzer',
|
|
|
|
contentURL: require('sdk/self').data.url('images/icon32.png'),
|
|
|
|
icon: './images/icon32.png',
|
|
|
|
panel: this.panel.get()
|
|
|
|
onChange: function(state) {
|
|
|
|
|
|
|
|
if ( state.checked ) {
|
|
|
|
|
|
|
|
self.panel.get().show({ position: self.button });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Widget.prototype.setIcon = function(appName) {
|
|
|
|
Button.prototype.setIcon = function(appName) {
|
|
|
|
var url = typeof appName === 'undefined' ? 'images/icon32_hot.png' : 'images/icons/' + appName + '.png';
|
|
|
|
var url = typeof appName === 'undefined' ? './images/icon32.png' : './images/icons/' + appName + '.png';
|
|
|
|
|
|
|
|
|
|
|
|
this.get().contentURL = require('sdk/self').data.url(url);
|
|
|
|
this.button.icon = url;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Widget.prototype.get = function() {
|
|
|
|
Button.prototype.get = function() {
|
|
|
|
return this.widget;
|
|
|
|
return this.button;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Widget.prototype.destroy = function() {
|
|
|
|
Button.prototype.destroy = function() {
|
|
|
|
this.panel.destroy();
|
|
|
|
this.panel.destroy();
|
|
|
|
|
|
|
|
|
|
|
|
this.widget.destroy();
|
|
|
|
this.button.destroy();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
UrlBar = function(window) {
|
|
|
|
UrlBar = function(window) {
|
|
|
@ -249,7 +261,7 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Can't get document from sdk/windows. Use active window instead.
|
|
|
|
// Can't get document from sdk/windows. Use active window instead.
|
|
|
|
// This breaks switching between URL bar and widget with multiple windows open
|
|
|
|
// This breaks switching between URL bar and button with multiple windows open
|
|
|
|
this.document = Cc['@mozilla.org/appshell/window-mediator;1'].getService(Ci.nsIWindowMediator)
|
|
|
|
this.document = Cc['@mozilla.org/appshell/window-mediator;1'].getService(Ci.nsIWindowMediator)
|
|
|
|
.getMostRecentWindow('navigator:browser').document;
|
|
|
|
.getMostRecentWindow('navigator:browser').document;
|
|
|
|
|
|
|
|
|
|
|
|