Created
June 10, 2011 11:36
-
-
Save rufuspollock/1018659 to your computer and use it in GitHub Desktop.
Example of using Annotator in OpenShakespeare.org
This file contains hidden or 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
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