Changeset 3339
- Timestamp:
- 08/09/13 09:42:57 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
DASISH/t5.6/client/trunk/chrome/markingcollection/content/markingcollection/annotator-service/annotation-service.js
r3187 r3339 1 1 var annotationFramework = (function() { 2 2 // default value for REST service 3 var backend = "http://pelle.ssd.gu.se:8080/exist/rest/db/annotation-framework/api/annotations.xql"; 4 var selected_state = nsPreferences.copyUnicharPref("wiredmarker.marker.initdata.url",""); 5 // selected_state values: "" (empty value as long as Settings Dialog has not been opened) OR "WM_REST_DEFAULT" OR "WM_REST_UserDefined" 6 // user-specified value for REST service 7 if (selected_state === "WM_REST_UserDefined") { 8 var backend = nsPreferences.copyUnicharPref("wiredmarker.marker.initdata.url_format",""); 9 } 10 // alert("The following backend is used: " + backend); 11 // TODO: The above code is executed only when restarting the application (or when a new window is opened), 12 // however the settings will be changed without calling for a restart (or opening a new window). 13 // Solution to get the correct backend URL at any time? 14 3 var default_backend = "http://pelle.ssd.gu.se:8080/exist/rest/db/annotation-framework/api/annotations.xql"; 4 15 5 return { 6 getDefaultBackend: function(){ 7 return default_backend; 8 }, 9 10 getBackend: function(){ 11 // selected_state values: "" (empty value as long as Settings Dialog has not been opened) OR "WM_REST_DEFAULT" OR "WM_REST_UserDefined" 12 // user-specified value for REST service 13 var selected_state = nsPreferences.copyUnicharPref("wiredmarker.marker.initdata.url",""); 14 if (selected_state === "WM_REST_UserDefined") { 15 return nsPreferences.copyUnicharPref("wiredmarker.marker.initdata.url_format",""); 16 }else{ 17 return default_backend; 18 } 19 }, 20 16 21 getAnnotations: function(params, callback) { 17 22 $.ajax({ 18 23 type: "GET", 19 url: this. backend,24 url: this.getBackend()+'/annotations', 20 25 data:params, 21 26 dataType: "xml", … … 35 40 }); 36 41 }, 37 putAnnotation: function() { 42 getAnnotation: function(aid, callback){ 43 $.ajax({ 44 type: "GET", 45 url: this.getBackend()+'/'+aid, 46 dataType: "xml", 47 success: function(xml) { 48 49 $xml.find('annotation').each(function(){ 50 var annotation = $.xml2json(this); 51 }); 52 53 callback.call(undefined, annotation); 54 } 55 }); 56 }, 57 putAnnotation: function(annotation) { 38 58 $.ajax({ 39 59 type: "POST", 40 url: this.backend, 41 dataType: "xml" 60 url: this.getBackend()+'?store=true', 61 dataType: "xml", 62 data:annotation 42 63 }); 43 64 },
Note: See TracChangeset
for help on using the changeset viewer.