Created
November 8, 2008 11:48
-
-
Save travisjeffery/23061 to your computer and use it in GitHub Desktop.
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
CmdUtils.CreateCommand({ | |
name: "delicious", | |
icon: "http://delicious.com/favicon.ico", | |
author: { | |
name: "Travis Jeffery", | |
email: "eatsleepgolf@gmail.com" | |
}, | |
license: "GPL", | |
description: "Post to Delicious.", | |
help: "Select the command press space and insert all the tags you want.", | |
takes: { | |
"tags": noun_arb_text | |
}, | |
preview: function(pblock, tags) { | |
document = context.focusedWindow.document; | |
pblock.innerHTML = "url: " + document.location + "<br />" + | |
"description: " + document.title + "<br />" + | |
"tags: " + tags.text; | |
}, | |
execute: function(tags) { | |
var document = context.focusedWindow.document; | |
var params = { | |
url: document.location, | |
description: document.title, | |
tags: tags.text | |
}; | |
var url = "https://api.del.icio.us/v1/posts/add?"; | |
var http = new XMLHttpRequest(); | |
for (key in params) { | |
url += "&" + key + "=" + params[key]; | |
} | |
http.open("POST", url, true); | |
http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); | |
http.setRequestHeader("Content-length", params.length); | |
http.setRequestHeader("Connection", "close"); | |
http.send(params); | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment