Skip to content

Instantly share code, notes, and snippets.

@eriwen
Created April 17, 2009 04:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eriwen/96853 to your computer and use it in GitHub Desktop.
Save eriwen/96853 to your computer and use it in GitHub Desktop.
DZone command for Mozilla Ubiquity
CmdUtils.CreateCommand({
names: ["dzone", "dz"],
homepage: "http://eriwen.com/extras/dzone.html",
icon: "http://www.dzone.com/favicon.ico",
author: { name: "Eric Wendelin", email: "emwendelin@gmail.com" },
license: "GPL",
description: "Submit the current page to DZone",
help: "Running this command will submit the current page to DZone",
_title: function() {
var doc = Application.activeWindow.activeTab.document;
return doc.title;
},
_location: function() {
var doc = Application.activeWindow.activeTab.document;
return doc.location;
},
_selection: function() {
return CmdUtils.getWindow().getSelection();
},
preview: function(pblock) {
var previewHtml = _('Submit "<em>${title}</em>" to DZone');
//TODO add selected text
//previewHtml += _('<p>With description: <blockquote>' + selectedText + '</blockquote></p>');
pblock.innerHTML = CmdUtils.renderTemplate(previewHtml, {title: this._title()});
},
execute: function() {
var urlBase = "http://www.dzone.com/links/add.html";
var urlParam = "?url=" + this._location();
var titleParam = "&title=" + this._title();
var dzoneUrl = urlBase + urlParam + titleParam;
var description = this._selection();
if (description)
dzoneUrl += "&description=" + description;
Utils.openUrlInBrowser(dzoneUrl);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment