From 109b67e9783456093a12e3593ea694dbb99f8703 Mon Sep 17 00:00:00 2001 From: Elbert Alias Date: Mon, 17 Feb 2014 19:44:10 +1100 Subject: [PATCH] Hide toolbar button by default, toggle between button and URL bar --- drivers/firefox-sdk/lib/driver.js | 77 +++++++++++++++------ drivers/firefox-sdk/locale/de-DE.properties | 1 + drivers/firefox-sdk/locale/en-GB.properties | 1 + drivers/firefox-sdk/locale/en-US.properties | 1 + drivers/firefox-sdk/locale/es-ES.properties | 1 + drivers/firefox-sdk/locale/fr-FR.properties | 1 + drivers/firefox-sdk/locale/nl-NL.properties | 1 + drivers/firefox-sdk/package.json | 1 + 8 files changed, 63 insertions(+), 21 deletions(-) diff --git a/drivers/firefox-sdk/lib/driver.js b/drivers/firefox-sdk/lib/driver.js index d70c108e8..1125c6a0e 100644 --- a/drivers/firefox-sdk/lib/driver.js +++ b/drivers/firefox-sdk/lib/driver.js @@ -15,26 +15,21 @@ ss = require('sdk/simple-storage'), sp = require("sdk/simple-prefs"), tabs = require('sdk/tabs'), - panel = require('sdk/panel').Panel({ - width: 250, - height: 50, - contentURL: data.url('panel.html'), - contentScriptFile: data.url('js/panel.js'), - position: { right: 30, top: 30 } - }), - widget = require('sdk/widget').Widget({ - id: 'wappalyzer', - label: 'Wappalyzer', - contentURL: data.url('images/icon32.png'), - panel: panel - }), + panel, + widget, initTab, addIcon, - removeIcons; + removeIcons, + createPanel, + createWidget; initTab = function(tab) { tabCache[tab.id] = { count: 0, appsDetected: [] }; + if ( !sp.prefs.urlbar ) { + createWidget(); + } + tab.on('ready', function(tab) { var worker = tab.attach({ contentScriptFile: data.url('js/tab.js') @@ -66,10 +61,6 @@ w.driver.displayApps(); }); - panel.port.on('resize', function(height) { - panel.height = height; - }); - addIcon = function(url) { var icon = doc.createElement('image'), @@ -121,6 +112,35 @@ } while ( icons.length ); }; + createPanel = function() { + if ( panel ) { + panel.destroy(); + } + + panel = require('sdk/panel').Panel({ + width: 250, + height: 50, + contentURL: data.url('panel.html'), + contentScriptFile: data.url('js/panel.js'), + position: { right: 30, top: 30 } + }); + + panel.port.on('resize', function(height) { + panel.height = height; + }); + } + + createWidget = function() { + createPanel(); + + widget = require('sdk/widget').Widget({ + id: 'wappalyzer', + label: 'Wappalyzer', + contentURL: data.url('images/icon32.png'), + panel: panel + }); + } + w.driver = { /** * Log messages to console @@ -135,6 +155,12 @@ init: function(callback) { var json = JSON.parse(data.load('apps.json')); + if ( sp.prefs.urlbar ) { + createPanel(); + } else { + createWidget(); + } + try { var version = require('sdk/self').version; @@ -161,6 +187,14 @@ sp.on('urlbar', function() { if ( !sp.prefs.urlbar ) { removeIcons(); + + createWidget(); + } else { + widget.destroy(); + + createPanel(); + + w.driver.displayApps(); } }); @@ -215,6 +249,7 @@ w.log('display apps'); if ( tabCache[tabs.activeTab.id] === undefined ) { + console.log(tabs); initTab(tabs.activeTab); } @@ -234,13 +269,13 @@ } } - widget.contentURL = data.url('images/icon32.png'); - if ( count > 0 ) { // Find the main application to display var i, appName, found = false; - widget.contentURL = data.url('images/icon32_hot.png'), + if ( !sp.prefs.urlbar ) { + widget.contentURL = data.url('images/icon32_hot.png'); + } w.driver.categoryOrder.forEach(function(match) { for ( appName in w.detected[url] ) { diff --git a/drivers/firefox-sdk/locale/de-DE.properties b/drivers/firefox-sdk/locale/de-DE.properties index f3851f4b3..d7076a1e5 100755 --- a/drivers/firefox-sdk/locale/de-DE.properties +++ b/drivers/firefox-sdk/locale/de-DE.properties @@ -6,6 +6,7 @@ categories = Kategorienverwaltung tracking_title = Tracken tracking_description = Sende anonyme Reports über gefundene Applikationen zu Forschungszwecken an wappalyzer.com urlbar_title = Display icons in URL bar +urlbar_description = Uncheck to display toolbar button. feedback = Feedback github = Github diff --git a/drivers/firefox-sdk/locale/en-GB.properties b/drivers/firefox-sdk/locale/en-GB.properties index 2bc0ee937..c317a710d 100755 --- a/drivers/firefox-sdk/locale/en-GB.properties +++ b/drivers/firefox-sdk/locale/en-GB.properties @@ -6,6 +6,7 @@ categories = Categories tracking_title = Tracking tracking_description = Anonymously send reports on detected applications to wappalyzer.com for analysis urlbar_title = Display icons in URL bar +urlbar_description = Uncheck to display toolbar button. feedback = Feedback github = Github diff --git a/drivers/firefox-sdk/locale/en-US.properties b/drivers/firefox-sdk/locale/en-US.properties index 2692e2ae6..842fece0d 100755 --- a/drivers/firefox-sdk/locale/en-US.properties +++ b/drivers/firefox-sdk/locale/en-US.properties @@ -6,6 +6,7 @@ categories = Categories tracking_title = Tracking research_description = Anonymously send reports on detected applications to wappalyzer.com for analysis urlbar_title = Display icons in URL bar +urlbar_description = Uncheck to display toolbar button. feedback = Feedback github = Github diff --git a/drivers/firefox-sdk/locale/es-ES.properties b/drivers/firefox-sdk/locale/es-ES.properties index e215f0227..a7c2e4640 100755 --- a/drivers/firefox-sdk/locale/es-ES.properties +++ b/drivers/firefox-sdk/locale/es-ES.properties @@ -6,6 +6,7 @@ categories = Categorías tracking_title = Seguimiento tracking_description = Enviar informes anónimos sobre las aplicaciones detectadas a wappalyzer.com para análisis urlbar_title = Display icons in URL bar +urlbar_description = Uncheck to display toolbar button. feedback = Opinión github = Github diff --git a/drivers/firefox-sdk/locale/fr-FR.properties b/drivers/firefox-sdk/locale/fr-FR.properties index aa8b9827b..a6bb86820 100644 --- a/drivers/firefox-sdk/locale/fr-FR.properties +++ b/drivers/firefox-sdk/locale/fr-FR.properties @@ -6,6 +6,7 @@ categories = Gérer les catégories tracking_title = Traçage tracking_description = Envoyer anonymement des rapports sur les applications détectées à wappalyzer.com pour la recherche urlbar_title = Display icons in URL bar +urlbar_description = Uncheck to display toolbar button. feedback = Donner votre avis github = Github diff --git a/drivers/firefox-sdk/locale/nl-NL.properties b/drivers/firefox-sdk/locale/nl-NL.properties index 6907ed06d..d4bb72534 100755 --- a/drivers/firefox-sdk/locale/nl-NL.properties +++ b/drivers/firefox-sdk/locale/nl-NL.properties @@ -6,6 +6,7 @@ categories = Beheer categorien tracking_title = Tracking tracking_description = Verzend anonieme informatie over applicaties naar wappalyzer.com voor onderzoek urlbar_title = Display icons in URL bar +urlbar_description = Uncheck to display toolbar button. feedback = Feedback github = Github diff --git a/drivers/firefox-sdk/package.json b/drivers/firefox-sdk/package.json index 3a477e8ef..dfe818965 100644 --- a/drivers/firefox-sdk/package.json +++ b/drivers/firefox-sdk/package.json @@ -18,6 +18,7 @@ }, { "name": "urlbar", "title": "Display icons in URL bar", + "description": "Uncheck to display toolbar button.", "type": "bool", "value": true }]