|
@@ -4,20 +4,8 @@ var buttons = require('sdk/ui/button/action'),
|
|
self = require('sdk/self'),
|
|
self = require('sdk/self'),
|
|
pageMod = require('sdk/page-mod'),
|
|
pageMod = require('sdk/page-mod'),
|
|
clipboard = require('sdk/clipboard'),
|
|
clipboard = require('sdk/clipboard'),
|
|
- iconsOn = {
|
|
|
|
- '16': './icon-16-powerOn.png',
|
|
|
|
- '32': './icon-32-powerOn.png',
|
|
|
|
- '64': './icon-64-powerOn.png'
|
|
|
|
- },
|
|
|
|
- iconsOff = {
|
|
|
|
- '16': './icon-16-powerOff.png',
|
|
|
|
- '32': './icon-32-powerOff.png',
|
|
|
|
- '64': './icon-64-powerOff.png'
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
- workers = [],
|
|
|
|
|
|
|
|
- powerSwitch = false;
|
|
|
|
|
|
+ workers = [];
|
|
|
|
|
|
|
|
|
|
function detachWorker(worker, workerArray) {
|
|
function detachWorker(worker, workerArray) {
|
|
@@ -27,59 +15,52 @@ function detachWorker(worker, workerArray) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-pageMod.PageMod({
|
|
|
|
- include: [ '*', 'file://*' ],
|
|
|
|
- contentScriptFile: self.data.url('content_probeForSG.js'),
|
|
|
|
- contentScriptOptions: {'dataPath' : self.data.url('superglue-client') + '/'},
|
|
|
|
- onAttach: function(worker){
|
|
|
|
|
|
|
|
- workers.push(worker);
|
|
|
|
|
|
|
|
- worker.port.on('SuperGlue', function(request) {
|
|
|
|
- if(request.contentProbeForSG === 'isPowerOn?'){
|
|
|
|
- worker.port.emit('SuperGlue', { powerOn: powerSwitch })
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
|
|
- worker.port.on('SuperGlueClipboard', function(message){
|
|
|
|
-
|
|
|
|
- if(message.action === 'copy'){
|
|
|
|
- clipboard.set(message.value);
|
|
|
|
- }
|
|
|
|
|
|
+var button = buttons.ActionButton({
|
|
|
|
|
|
- if(message.action === 'paste'){
|
|
|
|
- worker.port.emit('SuperGlueClipboard', {
|
|
|
|
- action: 'pasteResponse',
|
|
|
|
- value: clipboard.get()
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
|
|
+ id: 'superglue-button',
|
|
|
|
+ label: 'SuperGlue',
|
|
|
|
+ icon: {
|
|
|
|
+ "16": "./icon-16.png",
|
|
|
|
+ "32": "./icon-32.png",
|
|
|
|
+ "64": "./icon-64.png"
|
|
|
|
+ },
|
|
|
|
+ onClick: function() {
|
|
|
|
|
|
- });
|
|
|
|
|
|
+
|
|
|
|
+ var worker = tabs.activeTab.attach({
|
|
|
|
+ contentScriptFile: self.data.url("content_probeForSG.js"),
|
|
|
|
+ contentScriptOptions: { "dataPath" : self.data.url("superglue-client") + "/" }
|
|
|
|
+ });
|
|
|
|
|
|
- worker.on('detach', function () {
|
|
|
|
- detachWorker(this, workers);
|
|
|
|
- });
|
|
|
|
|
|
+
|
|
|
|
+ workers.push(worker);
|
|
|
|
|
|
- }
|
|
|
|
-});
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ worker.port.on('SuperGlueClipboard', function(message){
|
|
|
|
|
|
-var button = buttons.ActionButton({
|
|
|
|
|
|
+ if(message.action === 'copy'){
|
|
|
|
+ clipboard.set(message.value);
|
|
|
|
+ }
|
|
|
|
|
|
- id: 'superglue-button',
|
|
|
|
- label: 'SuperGlue',
|
|
|
|
- icon: iconsOff,
|
|
|
|
- onClick: function() {
|
|
|
|
|
|
+ if(message.action === 'paste'){
|
|
|
|
+ worker.port.emit('SuperGlueClipboard', {
|
|
|
|
+ action: 'pasteResponse',
|
|
|
|
+ value: clipboard.get()
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
|
|
- powerSwitch = !powerSwitch;
|
|
|
|
|
|
+ });
|
|
|
|
|
|
- for(var i = 0, l = workers.length; i < l; i++){
|
|
|
|
- workers[i].port.emit('SuperGlueState', { contentProbeForSG: 'updateStatusOfSG' })
|
|
|
|
- }
|
|
|
|
|
|
+ worker.on('detach', function () {
|
|
|
|
+ detachWorker(this, workers);
|
|
|
|
+ });
|
|
|
|
|
|
- button.state(button, { icon: powerSwitch ? iconsOn : iconsOff });
|
|
|
|
-
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
});
|
|
});
|
|
|
|
|