зеркало из https://github.com/mozilla/lightbeam.git
infobar: pull the version number from package.json (fix #579)
https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/self
This commit is contained in:
Родитель
656bd7a060
Коммит
f16ec2bcd0
|
@ -143,12 +143,18 @@ function onLoad(connections) {
|
|||
console.debug('aggregate::onLoad end, took %s ms', Date.now() - startTime);
|
||||
}
|
||||
|
||||
function updateUIFromMetadata(metadata) {
|
||||
console.debug("in aggregate metadata");
|
||||
global.updateUIFromMetadata(metadata);
|
||||
}
|
||||
|
||||
function updateUIFromPrefs(prefs) {
|
||||
console.debug("in aggregate prefs");
|
||||
global.updateUIFromPrefs(prefs);
|
||||
}
|
||||
|
||||
aggregate.on('load', onLoad);
|
||||
aggregate.on("updateUIFromMetadata", updateUIFromMetadata);
|
||||
aggregate.on("updateUIFromPrefs", updateUIFromPrefs);
|
||||
|
||||
// Constants for indexes of properties in array format
|
||||
|
|
|
@ -30,8 +30,14 @@ self.port.on('init', function () {
|
|||
global.aggregate.emit('load', global.allConnections);
|
||||
});
|
||||
|
||||
self.port.on("updateUIFromMetadata", function (metadata) {
|
||||
console.debug("Got add-on metadata", metadata);
|
||||
global.aggregate.emit("updateUIFromMetadata", metadata);
|
||||
});
|
||||
|
||||
self.port.on("updateUIFromPrefs", function (prefs) {
|
||||
console.debug("Got set prefs", prefs);
|
||||
global.aggregate.emit("updateUIFromPrefs", prefs);
|
||||
});
|
||||
|
||||
})(this);
|
||||
|
|
|
@ -204,7 +204,7 @@
|
|||
<div class="graph-view-help">
|
||||
<header class="large-header"><img src="image/lightbeam_icon_about.png" /> About Lightbeam</header>
|
||||
<div>
|
||||
<div class="grey-label all-cap-header">Version</div> 1.0<br />
|
||||
<div class="grey-label all-cap-header">Version</div> <span id="version-number"></span><br />
|
||||
<div class="grey-label all-cap-header">By</div> Mozilla Foundation<br />
|
||||
</div>
|
||||
<section>
|
||||
|
|
|
@ -479,6 +479,10 @@ global.singularOrPluralNoun = function singularOrPluralNoun(num, str) {
|
|||
return (num > 1) ? str + "s" : str;
|
||||
};
|
||||
|
||||
function updateUIFromMetadata(event) {
|
||||
document.querySelector('#version-number').textContent = event.version;
|
||||
}
|
||||
|
||||
function updateUIFromPrefs(event) {
|
||||
if ("contributeData" in event && event.contributeData) {
|
||||
var toggleBtn = document.querySelector(".share-btn");
|
||||
|
@ -510,5 +514,6 @@ function updateUIFromPrefs(event) {
|
|||
}
|
||||
|
||||
// Exports
|
||||
global.updateUIFromMetadata = updateUIFromMetadata;
|
||||
global.updateUIFromPrefs = updateUIFromPrefs;
|
||||
})(this);
|
||||
|
|
|
@ -5,9 +5,8 @@
|
|||
/* global require, exports, console */
|
||||
'use strict';
|
||||
|
||||
const {
|
||||
data
|
||||
} = require("sdk/self");
|
||||
const self = require("sdk/self");
|
||||
const data = self.data;
|
||||
const tabs = require('sdk/tabs');
|
||||
const {
|
||||
isPrivate
|
||||
|
@ -187,6 +186,7 @@ function attachToLightbeamPage(worker) {
|
|||
}
|
||||
|
||||
function onUIReady() {
|
||||
worker.port.emit("updateUIFromMetadata", { version: self.version });
|
||||
worker.port.emit("updateUIFromPrefs", prefs);
|
||||
worker.port.emit("passStoredConnections", getAllConnections());
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче