This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Call eventlistener callback after a short delay | |
delayedEventListener(node, event, callback, useCapture) { | |
node.addEventListener(event, function handler(evt) { | |
node.removeEventListener(event, handler, useCapture); // remove the listener, not necessary | |
timer.setTimeout(function() { | |
try { | |
callback.call(self, evt); // call the main callback | |
} | |
catch(err) { } | |
}, someTime); // any amount of time to delay |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Syntax of a event listener | |
target.addEventListener(type, listener[, useCapture]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ViewPanel class | |
function ViewPanel(content, script) { | |
this.panel = Panel({ | |
width: sp.prefs['width'], | |
height: sp.prefs['height'], | |
contentURL: data.url(content), | |
contentScriptFile: data.url(script) | |
}); | |
// listeners on the prefs change |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ViewPanel class | |
function ViewPanel(content, script) { | |
this.panel = Panel({ | |
width: sp.prefs['width'], | |
height: sp.prefs['height'], | |
contentURL: data.url(content), | |
contentScriptFile: data.url(script) | |
}); | |
// Moved inside the class, better than fighting with closures again |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ViewPanel class | |
function ViewPanel(content, script) { | |
this.panel = Panel({ | |
width: sp.prefs['width'], | |
height: sp.prefs['height'], | |
contentURL: data.url(content), | |
contentScriptFile: data.url(script) | |
}); | |
// Using arrow functions to resolve scope issues |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { id, name, prefixURI, rootURI, metadata, | |
version, loadReason, preferencesBranch } = require('@loader/options'); | |
console.log('id: ' + id + | |
'\nname: ' + name + | |
'\nprefixURI: ' + prefixURI + | |
'\nrootURI: ' + rootURI + | |
'\nmetadata: ' + JSON.stringify(metadata) + | |
'\nversion: ' + version + | |
'\nloadReason: ' + loadReason + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
id: jid1-ddYLv0ZiWhMetw@jetpack | |
name: theGreatestAddon | |
prefixURI: resource://jid1-ddylv0ziwhmetw-at-jetpack/ | |
rootURI: jar:file:///var/folders/m5/53z6crb100z72tmcb_rldn280000gn/T/tmpcZX_yD.mozrunner/extensions/jid1-ddYLv0ZiWhMetw@jetpack.xpi!/ | |
metadata: {"description":"a basic add-on","license":"MPL 2.0","main":"main","name":"theGreatestAddon","version":"0.1","permissions":{}} | |
version: 0.1 | |
loadReason: install | |
preferencesBranch: jid1-ddYLv0ZiWhMetw@jetpack |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { uri, id, preferencesBranch, name, | |
loadReason, version, packed, isPrivate } = require('sdk/self'); | |
console.log('\nuri: ' + uri + | |
'\nid: ' + id + | |
'\npreferencesBranch: ' + preferencesBranch + | |
'\nname: ' + name + | |
'\nloadReason: ' + loadReason + | |
'\nversion: ' + version + | |
'\npacked: ' + packed + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uri: addon:jid1-ddYLv0ZiWhMetw@jetpack | |
id: jid1-ddYLv0ZiWhMetw@jetpack | |
preferencesBranch: jid1-ddYLv0ZiWhMetw@jetpack | |
name: theGreatestAddon | |
loadReason: install | |
version: 0.1 | |
packed: true | |
isPrivateBrowsingSupported: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Cc, Ci, Cu, components } = require('chrome'); | |
Cu.import('resource://gre/modules/NetUtil.jsm'); | |
// Create a file to write | |
let file = Cc['@mozilla.org/file/local;1']. | |
createInstance(Ci.nsILocalFile); | |
file.initWithPath('/Users/sunny/Desktop'); | |
file.append('test-file.txt'); | |
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666); |
OlderNewer