Skip to content

Instantly share code, notes, and snippets.

diff -r afca0bffe6e1 parser-demo/da.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/parser-demo/da.js Fri Mar 27 14:39:56 2009 +0100
@@ -0,0 +1,16 @@
+// set up our parsers
+
+var da = new Parser('da');
+da.roles = [
+ {role: 'goal', delimiter: 'til'},
+ {role: 'source', delimiter: 'fra'},
function absolutifyUrls(data, sourceUrl) {
var relRe = /:\/\//;
var domainRe = /.*?\/\/[^?/]*/;
var pathRe = /.*\//;
if (sourceUrl.length-sourceUrl.replace(/\//g,"").length==2) {
sourceUrl += "/";
}
if (typeof(data)=="string") {
data = jQuery("<div>"+data+"</div>");
} else if (typeof(data)=="object") {
function absolutifyUrls(data, sourceUrl) {
var relRe = /:\/\//;
var domainRe = /.*?\/\/[^?/]*/;
var pathRe = /.*\//;
if (sourceUrl.length-sourceUrl.replace(/\//g,"").length==2) {
sourceUrl += "/";
}
if (typeof(data)=="string") {
data = jQuery("<div>"+data+"</div>");
} else if (typeof(data)=="object") {
CmdUtils.CreateCommand({
name: "selector",
description: "Finds a selector that will match element currently hovered, and highlights all matches",
execute: function() {
var d = CmdUtils.getDocumentInsecure();
myId = function(me){ return me.id ? '#' + me.id : '' }
myTag = function(me){ return me.tagName ? me.tagName.toLowerCase() : '' }
myClass = function(me){ return me.className ? '.' + me.className.split(' ').join('.') : '' }
breadcrumbs = function breadcrumbs(me){
jetpack.tabs.onReady(function(doc){
if (this.url.match(/^https:\/\/jetpack.mozillalabs.com\//))
$("*",doc).css({"font-family":"Times"});
});
var klass = "_jetpackNotification";
jetpack.tabs.onReady(function(doc){
$("body",doc).append('<div id="'+klass+'" style="position: fixed; bottom: 0; right: 0; height: 0; width: 151px;"><div style="height: 40px; width: 150px; background: #ddd; border: #999 solid; border-width: 1px 0 0 1px"></div></div>');
});
function notify(options) {
var doc = jetpack.tabs.focused.contentDocument;
$("#"+klass+" div", doc).text(options.body).parent().animate({"height":41},"slow", function(){
setTimeout(function(el){$(el).animate({"height":0},"slow")},3000,this);
});
// NOTE: Remember to fill in login credentials - in the future, this will be stored persistently via simple_storage probably...
Components.utils.import("resource://jetpack/ubiquity-modules/utils.js");
var TwitterJetpack = {
last: 0,
queue: [],
request: { type: "GET",
url: "http://twitter.com/statuses/friends_timeline.json",
dataType: "json",
error: function() {jetpack.notifications.show({"title":"TwitterJetpack","body":"Error fechting updates"});},
We couldn’t find that file to show.
@cers
cers / x.js
Created September 21, 2009 12:20
/* This is a template command. */
CmdUtils.CreateCommand({
names: ["example"],
icon: "http://www.mozilla.com/favicon.ico",
description: "A short description of your command.",
help: "How to use your command.",
author: {name: "Your Name", email: "you@mozilla.com"},
license: "GPL",
homepage: "http://labs.mozilla.com/",
arguments: [{role: 'object', nountype: noun_arb_text}],
@cers
cers / x.js
Created September 24, 2009 23:16
CmdUtils.makeSearchCommand({
name: "MovieZoo",
url: "http://www.moviezoo.dk/alle-produkter/soeg/{QUERY}",
parser: {
container: "table.nyhedsbrev_tabel2",
title: "tr:nth-child(2) tr tr:first-child b",
href: function(c) {return jQuery("a.nyhedsbrev",c).attr("href");},
preview: function(c) {var p = ""; jQuery("table table tr:not(:first)",c).each(function(){p += jQuery(this).text()+"<br>";});return p;},
thumbnail: "img.lister_img",
maxResults: 3