Added storage

main
Elbert Alias 11 years ago
parent 7ca88a6e18
commit 769136d20f

@ -54,39 +54,8 @@ img {
margin: 5px 0 0 24px; margin: 5px 0 0 24px;
} }
.empty { #empty {
color: #999; color: #999;
font-style: italic; font-style: italic;
text-align: center; text-align: center;
} }
#buttons {
margin-top: 12px;
overflow: hidden;
}
#buttons button {
height: 32px;
}
#analyze-headers {
float: left;
width: 158px;
}
#analyze-headers.pending {
background-image: url('../images/pending2.gif');
background-position: center center;
background-repeat: no-repeat;
text-indent: -999px;
}
#options {
background-image: url('../images/options.png');
background-position: center center;
background-repeat: no-repeat;
float: right;
height: 32px;
min-width: 32px;
width: 32px;
}

@ -1,10 +1,14 @@
(function() { (function() {
self.port.on('displayApps', function(message) { self.port.on('displayApps', function(message) {
var detectedApps = document.getElementById('detected-apps'); var
detectedApps = document.getElementById('detected-apps')
empty = document.getElementById('empty');
detectedApps.innerHTML = ''; detectedApps.innerHTML = '';
if ( message.tabCache.count > 0 ) { if ( message.tabCache.count > 0 ) {
empty.style.display = 'none';
for ( appName in message.tabCache.appsDetected ) { for ( appName in message.tabCache.appsDetected ) {
confidence = message.tabCache.appsDetected[appName].confidenceTotal; confidence = message.tabCache.appsDetected[appName].confidenceTotal;
version = message.tabCache.appsDetected[appName].version; version = message.tabCache.appsDetected[appName].version;
@ -29,6 +33,8 @@
detectedApps.innerHTML = detectedApps.innerHTML + html; detectedApps.innerHTML = detectedApps.innerHTML + html;
} }
} else {
empty.style.display = 'block';
} }
self.port.emit('resize', document.body.offsetHeight); self.port.emit('resize', document.body.offsetHeight);

@ -7,6 +7,8 @@
<link rel="stylesheet" href="css/panel.css"> <link rel="stylesheet" href="css/panel.css">
</head> </head>
<body> <body>
<div id="empty" data-l10n-id="noAppsDetected"></div>
<div id="detected-apps"></div> <div id="detected-apps"></div>
</body> </body>
</html> </html>

@ -9,6 +9,7 @@
headersCache = {}, headersCache = {},
categoryNames = {}, categoryNames = {},
data = require('sdk/self').data, data = require('sdk/self').data,
ss = require('sdk/simple-storage'),
tabs = require('sdk/tabs'), tabs = require('sdk/tabs'),
panel = require('sdk/panel').Panel({ panel = require('sdk/panel').Panel({
width: 250, width: 250,
@ -24,11 +25,7 @@
}); });
tabs.on('open', function(tab) { tabs.on('open', function(tab) {
tabCache[tab.id] = { tabCache[tab.id] = { count: 0, appsDetected: [] };
count: 0,
appsDetected: [],
analyzed: []
};
}); });
tabs.on('close', function(tab) { tabs.on('close', function(tab) {
@ -75,6 +72,18 @@
init: function(callback) { init: function(callback) {
var json = JSON.parse(data.load('apps.json')); var json = JSON.parse(data.load('apps.json'));
try {
var version = require('sdk/self').version;
if ( !ss.storage.version ) {
w.driver.goToURL({ url: w.config.websiteURL + 'installed', medium: 'install' });
} else if ( version !== ss.storage.version ) {
w.driver.goToURL({ url: w.config.websiteURL + 'upgraded', medium: 'upgrade' });
}
ss.storage.version = version;
} catch(e) { }
w.apps = json.apps; w.apps = json.apps;
w.categories = json.categories; w.categories = json.categories;
@ -83,11 +92,7 @@
} }
for each ( var tab in tabs ) { for each ( var tab in tabs ) {
tabCache[tab.id] = { tabCache[tab.id] = { count: 0, appsDetected: [] };
count: 0,
appsDetected: [],
analyzed: []
};
} }
var httpRequestObserver = { var httpRequestObserver = {
@ -125,11 +130,21 @@
httpRequestObserver.init(); httpRequestObserver.init();
}, },
goToURL: function(args) {
var url = args.url + ( typeof args.medium === 'undefined' ? '' : '?utm_source=firefox&utm_medium=' + args.medium + '&utm_campaign=extensions');
tabs.open(url);
},
displayApps: function() { displayApps: function() {
var count = w.detected[tabs.activeTab.url] ? Object.keys(w.detected[tabs.activeTab.url]).length.toString() : '0'; var count = w.detected[tabs.activeTab.url] ? Object.keys(w.detected[tabs.activeTab.url]).length.toString() : '0';
w.log('display apps'); w.log('display apps');
if ( tabCache[tabs.activeTab.id] === undefined ) {
tabCache[tabs.activeTab.id] = { count: 0, appsDetected: [] };
}
tabCache[tabs.activeTab.id].count = count; tabCache[tabs.activeTab.id].count = count;
tabCache[tabs.activeTab.id].appsDetected = w.detected[tabs.activeTab.url]; tabCache[tabs.activeTab.id].appsDetected = w.detected[tabs.activeTab.url];