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
let chromeWindow = open('chrome://foo/content/'); | |
assert.ok(~windows().indexOf(chromeWindow), 'chrome URI works'); | |
let resourceWindow = open('resource://foo'); | |
assert.ok(~windows().indexOf(resourceWindow), 'resource URI works'); | |
// Wait for the window unload before ending test | |
close(chromeWindow).close(resourceWindow).then(done); |
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
var sec = document.body.id; | |
$('ul#nav-main-menu > li').each(function( index ) { | |
if ($(this).text().toUpperCase() == sec.toUpperCase()) { | |
$('#nav-main-menu [tabindex=0]').get(index).focus(); | |
} | |
}); |
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
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: |
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
main.js | |
======= | |
const sp = require("sdk/simple-prefs"); | |
const keys = require("keys"); | |
sp.on("hotkey", keys.hotkeyCheck(showHotkey, pan)); | |
keys.js |
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
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 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 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 |