Mihai Tibrea Mihai Tibrea - 3 months ago 38x
JSON Question

Annotator.js load annotations from json

I am trying to develop a website in which i need some annotations.
I have found a great js library, annotator.js, but i can't seem to be able to start it.

I am trying to highlight some annotations when the page is loaded, but i can't seem to get it right. I do receive a JS error saying .slice is not a function, but no matter how i change the json object, i cant get it to work.

Can anyone help me understand how it works ? I have been through their documentation but i dont seem to be able to load anything.

THis is what i have so far:

<div id="annon">
Lorem ipsum

var annotator = $('#annon').annotator();
"quote": "Lorem",
"endOffset": 5,
"startOffset": 0,
"end": "/",
"start": "/"
"text": "Lorem", "id": 1
,"total": 1}


Well, I managed to get the annotated word to light up. I have done testing in the browser to play around with the structure of the object so that i can correct the RANGE property in particular. This is my solution:

"id": "39fc339cf058bd22176771b3e3187329",
"created": "2011-05-24T18:52:08.036814",
"updated": "2011-05-26T12:17:05.012544",
"text": "This is a comment",                
"quote": "Lorem",         
  "start": "/div[1]",         
  "end": "/div[1]",           
  "startOffset": 17,                    
  "endOffset": 22                     

What i am having problems undestanding is why the startOffset is 17 considering LOREM is the first word in the div.

If anyone can explain that, that would be great !

LE I have identified the problem with 17-22. It was the actual spaces in the div, which my IDE added when i've put them on a new line.