Created
November 3, 2008 12:32
-
-
Save source-data/21865 to your computer and use it in GitHub Desktop.
Ubiquity command open-doi
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({ | |
//to install this command, visit http://gist.github.com/21865 | |
//code is part of http://code.google.com/p/tl-ubiquity-commands/ | |
name: "open-doi", | |
takes: {"selected text": noun_arb_text}, | |
preview: function(pblock, directObject){ | |
if (directObject.text){ | |
var m = directObject.text.match(/(doi:)?.*?\b(10\.\d{4}\/\S+)/i); | |
if (!m){pblock.innerHTML="The selection <pre>"+directObject.text+"</pre> does not include a recognized doi !";} | |
else {pblock.innerHTML="press Return to go to the document associated with <i>"+m[2]+"</i>.";} | |
} else {pblock.innerHTML="Select or type a text that includes a doi..."} | |
}, | |
execute: function(directObject){ | |
if (directObject.text){ | |
var m = directObject.text.match(/(doi:)?.*?\b(10\.\d{4}\/\S+)/i); | |
if (m){Utils.openUrlInBrowser("http://dx.doi.org/"+m[2])} | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment