This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
| Handlebars.registerHelper("linkify", function (message) { | |
| function doIt(match) { | |
| return "<a target='_blank' href='" + match + "'>" + match + "</a>"; | |
| }; | |
| console.log("linkifying..."); | |
| console.log("here: " + message.replace(REGEX, doIt)); | |
| return new Handlebars.SafeString(message.replace(REGEX, doIt)); | |
| }); |
This file contains hidden or 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
| var mystring = "hey there, here is the link http://www.mozilla.org yah!"; | |
| REGEX = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/; | |
| function doIt(match) { | |
| return "<a href='" + match + "'> " + match + "</a>"; | |
| } | |
| console.log(mystring.replace(REGEX, doIt)); |
This file contains hidden or 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
| main.js | |
| ======= | |
| const sp = require("sdk/simple-prefs"); | |
| const keys = require("keys"); | |
| sp.on("hotkey", keys.hotkeyCheck(showHotkey, pan)); | |
| keys.js |
This file contains hidden or 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
| def findSeq(str): | |
| # A list to store the words. | |
| seq = [] | |
| # Create words from the given string and | |
| # store in seq. | |
| word = str[0] | |
| for i in range(len(str)-1): | |
| current = ord(str[i]) | |
| next = ord(str[i+1]) | |
| if current <= next: |