Changeset 4714
- Timestamp:
- 03/15/14 19:32:43 (11 years ago)
- Location:
- DASISH/t5.6/client/trunk/chrome/markingcollection/content/markingcollection/annotator-service
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
DASISH/t5.6/client/trunk/chrome/markingcollection/content/markingcollection/annotator-service/annotation-service.js
r4708 r4714 91 91 } 92 92 }, 93 postAnnotation: function(annotation, oid ) {94 return$.ajax({93 postAnnotation: function(annotation, oid, callback) { 94 $.ajax({ 95 95 type: "POST", 96 96 url: this.getBackend() + '/api/annotations?store=true', … … 127 127 // Database insert request is true if successful 128 128 // Firebug.Console.log(rtn); 129 callback.call(undefined, aid); 130 annotationProxy.log('called cache stuff'); 129 131 } 130 132 }); … … 157 159 } 158 160 }); 161 }, 162 postCache: function(targetURL, cacheMetadata, cache){ 163 var data = new FormData(); 164 data.append('metadata', cacheMetadata); 165 data.append('cache', cache); 166 annotationProxy.log('-POST '+targetURL+'/cached'); 167 $.ajax({ 168 type: "POST", 169 url: targetURL, 170 data: data, 171 cache: false, 172 contentType: false, 173 processData: false, 174 success: function(xml, textStatus, jqXHR) { 175 annotationProxy.log('RESULT FROM CACHE STUFF'); 176 annotationProxy.log("Status Code POST request: " + jqXHR.status); 177 annotationProxy.log("Response Body: " + jqXHR.responseText); 178 }, 179 error: function(jqXHR, status, thrownError) { 180 // Handle any errors 181 182 annotationProxy.log("+ + + + + + + + + + + + + + + + + + + + + + + +"); 183 annotationProxy.log("Faild to POST cache for : " + targetURL); 184 annotationProxy.log("Status Code: " + jqXHR.status); 185 annotationProxy.log("Error : " + thrownError); 186 187 } 188 }); 189 }, 190 getTargets : function(aid, callback){ 191 $.ajax({ 192 type: "GET", 193 url: this.getBackend() + '/api/annotations/'+aid, 194 dataType: "xml", 195 success: function(xml, textStatus, jqXHR) { 196 var targets = Array(); 197 198 $xml = $.parseXML(jqXHR.responseText); 199 annotationProxy.log($xml); 200 201 jQuery($xml).find('targetInfo').each(function() { 202 annotationProxy.log(this); 203 annotationProxy.log(this.getAttribute('ref')); 204 205 targets.push(this.getAttribute('ref')); 206 }); 207 callback.call(undefined, targets); 208 } 209 }); 159 210 }, 160 211 setBackend: function(url) { -
DASISH/t5.6/client/trunk/chrome/markingcollection/content/markingcollection/annotator-service/annotations.wired.marker.js
r4707 r4714 64 64 postAnnotation: function(om_object) { 65 65 var annotation = om_object2annotation(om_object); 66 annotationFramework.postAnnotation(annotation, om_object.oid); 66 annotationFramework.postAnnotation(annotation, om_object.oid, 67 function(aid){ 68 annotationProxy.log('Annotation posted and returned AID: '+aid); 69 annotationProxy.log('Geting target list for posting cache...'); 70 annotationFramework.getTargets(aid, 71 function(targets){ 72 var htmlDump = annotationProxy.getCurrentHtmlDocument(); 73 var cacheMetadata = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n\ 74 <cashedRepresentationInfo xmlns="http://www.dasish.eu/ns/addit" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" URI="https://lux17.mpi.nl/ds/webannotator/api/cached/00000000-0000-0000-0000-000000000051" xsi:schemaLocation="http://www.dasish.eu/ns/addit https://svn.clarin.eu/DASISH/t5.6/schema/trunk/annotator-schema/src/main/resources/DASISH-schema.xsd">\n\ 75 <mimeType>text/plain</mimeType>\n\ 76 <tool>DWAN</tool>\n\ 77 <type>html</type>\n\ 78 </cashedRepresentationInfo>'; 79 annotationProxy.log(cacheMetadata); 80 $.each(targets, function(index, targetURL){ 81 var xpointer = encodeURIComponent(om_object_xpointer(om_object)); 82 targetURL += '/fragment/placeholderForFragment/cached'; 83 84 annotationFramework.postCache(targetURL, htmlDump, cacheMetadata); 85 }); 86 }); 87 }); 88 67 89 }, 68 90 updateAnnotation: function(om_object) { … … 82 104 return rtn[0].dasish_aid; 83 105 }, 106 getCurrentHtmlDocument : function(){ 107 var xmlS = new XMLSerializer(); 108 var temp = xmlS.serializeToString(document); 109 return temp; 110 111 }, 84 112 log: function(message) { 85 113 //log to console -
DASISH/t5.6/client/trunk/chrome/markingcollection/content/markingcollection/annotator-service/conversion.utils.js
r4709 r4714 147 147 } 148 148 149 function om_object_xpointer(om_object){ 150 var path = {}; 151 152 om_object.bgn_dom.match(/(.+)\(([0-9]+)\)\(([0-9]+)\)/); 153 path.start = RegExp.$1; 154 path.startOffset = RegExp.$2; 155 path.startType = RegExp.$3; 156 157 om_object.end_dom.match(/(.+)\(([0-9]+)\)\(([0-9]+)\)/); 158 path.end = RegExp.$1; 159 path.endOffset = RegExp.$2; 160 path.endType = RegExp.$3; 161 162 var xpointer = "xpointer(start-point(string-range(" + path.start + "/text()[1],''," + path.startOffset + "))"; 163 xpointer += "/range-to(string-range(" + path.end + "/text()[1],''," + path.endOffset + ")))"; 164 165 return xpointer; 166 } 167 149 168 function om_object_annotation_body(om_object){ 150 169 /*{
Note: See TracChangeset
for help on using the changeset viewer.