Changeset 4272
- Timestamp:
- 01/16/14 12:11:34 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
DASISH/t5.6/client/trunk/chrome/markingcollection/content/markingcollection/annotator-service/annotation-service.js
r3599 r4272 2 2 // default value for REST service 3 3 var default_backend = "http://pelle.ssd.gu.se:8080/exist/rest/db/annotation-framework/api/annotations.xql"; 4 4 5 5 return { 6 getDefaultBackend: function() {6 getDefaultBackend: function() { 7 7 return default_backend; 8 8 }, 9 10 getBackend: function(){ 9 getBackend: function() { 11 10 // selected_state values: "" (empty value as long as Settings Dialog has not been opened) OR "WM_REST_DEFAULT" OR "WM_REST_UserDefined" 12 11 // user-specified value for REST service 13 var selected_state = nsPreferences.copyUnicharPref("wiredmarker.marker.initdata.url", "");12 var selected_state = nsPreferences.copyUnicharPref("wiredmarker.marker.initdata.url", ""); 14 13 if (selected_state === "WM_REST_UserDefined") { 15 return nsPreferences.copyUnicharPref("wiredmarker.marker.initdata.url_format", "");16 } else{14 return nsPreferences.copyUnicharPref("wiredmarker.marker.initdata.url_format", ""); 15 } else { 17 16 return default_backend; 18 17 } 19 18 }, 20 21 19 getAnnotations: function(params, callback) { 22 20 $.ajax({ 23 21 type: "GET", 24 url: this.getBackend() +'/annotations',25 data: params,22 url: this.getBackend() + '/annotations', 23 data: params, 26 24 dataType: "xml", 27 25 success: function(xml) { … … 29 27 30 28 $xml = $(xml); 31 $xml.find('annotation').each(function() {29 $xml.find('annotation').each(function() { 32 30 var annotation = $.xml2json(this); 33 31 34 32 annotations.push(annotation); 35 33 }); … … 39 37 }); 40 38 }, 41 getAnnotation: function(aid, callback) {39 getAnnotation: function(aid, callback) { 42 40 $.ajax({ 43 41 type: "GET", 44 url: this.getBackend() +'/'+aid,42 url: this.getBackend() + '/' + aid, 45 43 dataType: "xml", 46 success: function(xml) { 44 success: function(xml) { 47 45 var annotation = $xml.find('annotation'); 48 46 49 47 callback.call(undefined, annotation); 50 48 } … … 52 50 }, 53 51 postAnnotation: function(annotation) { 54 $.ajax({52 return $.ajax({ 55 53 type: "POST", 56 url: this.getBackend() +'?store=true',54 url: this.getBackend() + '/api/annotations?store=true', 57 55 dataType: "xml", 58 data:annotation 56 data: annotation, 57 contentType: "application/xml", 58 complete: function(jqXHR, status, responseText) { 59 if (typeof Firebug !== 'undefined' && Firebug.Console) { 60 Firebug.Console.log("+ + + + + + + + + + + + + + + + + + + + + + + +"); 61 Firebug.Console.log("Status Code: " + jqXHR.status); 62 Firebug.Console.log("Response Body: " + jqXHR.responseText); 63 } 64 } 59 65 }); 60 66 }, 61 setBackend:function(url) {this.backend = url;} 67 setBackend: function(url) { 68 this.backend = url; 69 } 62 70 } 63 71 }());
Note: See TracChangeset
for help on using the changeset viewer.