Added storage

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

@ -54,39 +54,8 @@ img {
margin: 5px 0 0 24px;
}
.empty {
#empty {
color: #999;
font-style: italic;
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() {
self.port.on('displayApps', function(message) {
var detectedApps = document.getElementById('detected-apps');
var
detectedApps = document.getElementById('detected-apps')
empty = document.getElementById('empty');
detectedApps.innerHTML = '';
if ( message.tabCache.count > 0 ) {
empty.style.display = 'none';
for ( appName in message.tabCache.appsDetected ) {
confidence = message.tabCache.appsDetected[appName].confidenceTotal;
version = message.tabCache.appsDetected[appName].version;
@ -29,6 +33,8 @@
detectedApps.innerHTML = detectedApps.innerHTML + html;
}
} else {
empty.style.display = 'block';
}
self.port.emit('resize', document.body.offsetHeight);

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

@ -9,6 +9,7 @@
headersCache = {},
categoryNames = {},
data = require('sdk/self').data,
ss = require('sdk/simple-storage'),
tabs = require('sdk/tabs'),
panel = require('sdk/panel').Panel({
width: 250,
@ -24,11 +25,7 @@
});
tabs.on('open', function(tab) {
tabCache[tab.id] = {
count: 0,
appsDetected: [],
analyzed: []
};
tabCache[tab.id] = { count: 0, appsDetected: [] };
});
tabs.on('close', function(tab) {
@ -75,6 +72,18 @@
init: function(callback) {
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.categories = json.categories;
@ -83,11 +92,7 @@
}
for each ( var tab in tabs ) {
tabCache[tab.id] = {
count: 0,
appsDetected: [],
analyzed: []
};
tabCache[tab.id] = { count: 0, appsDetected: [] };
}
var httpRequestObserver = {
@ -125,11 +130,21 @@
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() {
var count = w.detected[tabs.activeTab.url] ? Object.keys(w.detected[tabs.activeTab.url]).length.toString() : '0';
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].appsDetected = w.detected[tabs.activeTab.url];