CmdUtils.CreateCommand({ name: "delicious", homepage: "http://ryan.codecrate.com/", author: { name: "Ryan Sonnek", email: "ryan@codecrate.com"}, contributors: ["Ryan Sonnek"], license: "MIT", description: "Tags the current site using delicious", icon: "http://delicious.com/favicon.ico", help: "Save the current url to delicious with the tags input by the user. Any selected text on the page will be recorded as the note.", takes: {notes: noun_arb_text}, modifiers: { tagged: noun_arb_text, entitled: noun_arb_text }, preview: function(pblock, notes, mods) { var params = this.post_params(notes, mods); html = "title: " + params.description + "
"; html += "tags: " + params.tags + "
"; html += "note: " + params.extended + "
"; pblock.innerHTML = html; }, execute: function(notes, mods) { jQuery.ajax({ type: "POST", dataType: "xml", url: "https://api.del.icio.us/v1/posts/add", data: this.post_params(notes, mods), error: function() { displayMessage("Error saving bookmark to delicious"); }, success: function(xml) { var result = jQuery(xml).find("result"); var code = result.attr("code"); if (code == "done") { displayMessage("Bookmark saved to delicious!"); } else { displayMessage("Error saving bookmark to delicious: " + code); } } }); }, post_params: function(notes, mods) { var document = context.focusedWindow.document; var params = { url: document.location, description: mods.entitled.text || document.title, extended: notes.text, tags: mods.tagged.text }; return params; } })