Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rufuspollock/1018659 to your computer and use it in GitHub Desktop.
Save rufuspollock/1018659 to your computer and use it in GitHub Desktop.
Example of using Annotator in OpenShakespeare.org
jQuery(function ($) {
var elem = $('#text-to-annotate');
var account_id = '39fc339cf058bd22176771b3e3036609';
var annotator_store = '/annostore' + '/api';
var userid = '';
var options = {};
options.permissions = {};
options.permissions.user = {
'name': '194.104.70.73'
};
if(userid != '') {
elem.data('annotator:headers', {'x-annotator-user-id': userid});
options.permissions.user.id = userid;
options.permissions.permissions = {
'read': [],
'update': [userid],
'delete': [userid],
'admin': [userid]
}
}
var annotator = elem.annotator().data('annotator');
annotator.addPlugin('Store', {
prefix: annotator_store,
annotationData: {
'uri': 'http://openshakespeare.org/work/comedy_of_errors',
'account_id': account_id
},
loadFromSearch: {
'uri': 'http://openshakespeare.org/work/comedy_of_errors',
limit: -1
}
});
options.permissions.userId = function(user) {
if (user) {
return user.id;
}
};
options.permissions.userString = function(user) {
if (user) {
return user.name;
}
};
annotator.addPlugin('Permissions', options.permissions);
annotator.addPlugin('Tags');
// annotator.addPlugin('Markdown');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment