1 | /*** |
---|
2 | * |
---|
3 | * @param {object} annotation annotation object from webservice |
---|
4 | * @returns {annotationToOmObject.om_object} an object for Wired Marker |
---|
5 | */ |
---|
6 | function annotation2om_object(annotation){ |
---|
7 | var om_object = { |
---|
8 | oid :"", |
---|
9 | doc_title :"http://localhost/annotation/test/test-service.html", |
---|
10 | doc_url :"http://localhost/annotation/test/test-service.html", |
---|
11 | con_url :"http://localhost/annotation/test/test-service.html", |
---|
12 | bgn_dom :"", |
---|
13 | end_dom :"", |
---|
14 | oid_title :"http://localhost/annotation/test/test-service.html", |
---|
15 | oid_property :"<PROPERTY><HYPER_ANCHOR>http://localhost/annotation/test/test-service.html#hyperanchor1.3%3A%2Fhtml%5B1%5D%2Fbody%5B1%5D%2Fdiv%5B2%5D%2Fp%5B1%5D(0)(3)(Ane)%26%2Fhtml%5B1%5D%2Fbody%5B1%5D%2Fdiv%5B2%5D%2Fp%5B1%5D(45)(3)(ter)%26background-color%3A%20rgb(%2044%2C%20254%2C%20%2081)%3Bcolor%3Argb(0%2C0%2C0)%3B</HYPER_ANCHOR><NOTE>text om en författare</NOTE></PROPERTY>", |
---|
16 | oid_mode :"0", |
---|
17 | oid_type :"text", |
---|
18 | oid_txt :"An example text about Douglas Adams; a writer", |
---|
19 | oid_img :null, |
---|
20 | oid_date :"" |
---|
21 | }; |
---|
22 | |
---|
23 | om_object.oid = hashCode(annotation['xml:id']); |
---|
24 | console.log(annotation.targetSources.targetSource); |
---|
25 | om_object.oid_property = "<PROPERTY><HYPER_ANCHOR>"+annotation.targetSources.targetSource.id+"</HYPER_ANCHOR><NOTE>"+annotation.body+"</NOTE></PROPERTY>"; |
---|
26 | |
---|
27 | if(annotation.type.toLowerCase() === 'note'){ |
---|
28 | om_object.oid_txt = annotation.body; |
---|
29 | om_object.oid_type = 'text'; |
---|
30 | } |
---|
31 | var d = new Date(annotation.timeStamp); |
---|
32 | om_object.oid_date = (d.getMonth()+1)+'/'+d.getDate()+'/'+d.getFullYear()+' '+d.getHours()+':'+d.getMinutes()+':'+d.getSeconds(); |
---|
33 | |
---|
34 | return om_object; |
---|
35 | } |
---|
36 | |
---|
37 | function om_object2annotation(om_object){ |
---|
38 | var annotation = {}; |
---|
39 | |
---|
40 | return annotation; |
---|
41 | } |
---|
42 | |
---|
43 | function annotation2xml(annotation){ |
---|
44 | |
---|
45 | } |
---|
46 | |
---|
47 | function hashCode(str){ |
---|
48 | var hash = 0; |
---|
49 | if (str.length == 0) return hash; |
---|
50 | for (i = 0; i < str.length; i++) { |
---|
51 | char = str.charCodeAt(i); |
---|
52 | hash = ((hash<<5)-hash)+char; |
---|
53 | hash = hash & hash; // Convert to 32bit integer |
---|
54 | } |
---|
55 | return hash; |
---|
56 | } |
---|
57 | |
---|
58 | |
---|
59 | |
---|
60 | |
---|
61 | |
---|
62 | /* |
---|
63 | From SQL-lite for wired-marker |
---|
64 | <PROPERTY> |
---|
65 | <HYPER_ANCHOR>http://localhost/annotation/test/test-service.html#hyperanchor1.3%3A%2Fhtml%5B1%5D%2Fbody%5B1%5D%2Fdiv%5B2%5D%2Fp%5B1%5D(0)(3)(Ane)%26%2Fhtml%5B1%5D%2Fbody%5B1%5D%2Fdiv%5B2%5D%2Fp%5B1%5D(45)(3)(ter)%26background-color%3A%20rgb(%2044%2C%20254%2C%20%2081)%3Bcolor%3Argb(0%2C0%2C0)%3B</HYPER_ANCHOR> |
---|
66 | <NOTE>text om en fï¿œrfattare</NOTE> |
---|
67 | </PROPERTY> |
---|
68 | unescaped: http://localhost/annotation/test/test-service.html#hyperanchor1.3:/html[1]/body[1]/div[2]/p[1](0)(3)(Ane)&/html[1]/body[1]/div[2]/p[1](45)(3)(ter)&background-color: rgb( 44, 254, 81);color:rgb(0,0,0);text om en fï¿œrfattare |
---|
69 | */ |
---|