Skip to content

Instantly share code, notes, and snippets.

@kwijibo
Created May 2, 2009 17:36
Show Gist options
  • Save kwijibo/105637 to your computer and use it in GitHub Desktop.
Save kwijibo/105637 to your computer and use it in GitHub Desktop.
CmdUtils.CreateCommand({
name: "openvocab-property",
takes: {"term": noun_arb_text},
homepage: "http://kwijibo.talis.com/",
author: { name: "Keith Alexander", email: "keith.alexander@talis.com"},
license: "MPL",
description: "Brings up the form to edit or create a property named after the selected or inputed text on http://open.vocab.org. nb: propertiesmost be lower case",
buildUrl: function(term){
var uri = "http://open.vocab.org/terms/"+term.text.replace('/ /g', '');
return "http://open.vocab.org/forms/editprop?uri=" + encodeURIComponent(uri)
},
preview: function(previewBlock, term) {
previewBlock.innerHTML = "finding openvocab:" + term.text ;
var baseURI = this.buildUrl(term);
jQuery.ajax({
type: "GET",
url: baseURI,
datatype: "string",
error: function(responseData) {
previewBlock.innerHTML = "<em>Error:" + responseData + "</em>";
},
success: function(responseData) {
previewBlock.innerHTML = responseData;
jQuery("*", previewBlock).css({"fontSize":"8pt", "color": "white"});
jQuery("#header, #footer, #search", previewBlock).hide();
jQuery("form td *", previewBlock).css({"width": "50%"});
}
});
},
execute: function(term) {
var uri = this.buildUrl(term);
Utils.openUrlInBrowser(uri);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment