Changeset 4272


Ignore:
Timestamp:
01/16/14 12:11:34 (10 years ago)
Author:
sroth
Message:

Adjusted function postAnnotation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DASISH/t5.6/client/trunk/chrome/markingcollection/content/markingcollection/annotator-service/annotation-service.js

    r3599 r4272  
    22    // default value for REST service
    33    var default_backend = "http://pelle.ssd.gu.se:8080/exist/rest/db/annotation-framework/api/annotations.xql";
    4        
     4
    55    return {
    6         getDefaultBackend: function(){
     6        getDefaultBackend: function() {
    77            return default_backend;
    88        },
    9                
    10         getBackend: function(){
     9        getBackend: function() {
    1110            // selected_state values: "" (empty value as long as Settings Dialog has not been opened) OR "WM_REST_DEFAULT" OR "WM_REST_UserDefined"
    1211            // 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", "");
    1413            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 {
    1716                return default_backend;
    1817            }
    1918        },
    20        
    2119        getAnnotations: function(params, callback) {
    2220            $.ajax({
    2321                type: "GET",
    24                 url: this.getBackend()+'/annotations',
    25                 data:params,
     22                url: this.getBackend() + '/annotations',
     23                data: params,
    2624                dataType: "xml",
    2725                success: function(xml) {
     
    2927
    3028                    $xml = $(xml);
    31                     $xml.find('annotation').each(function(){             
     29                    $xml.find('annotation').each(function() {
    3230                        var annotation = $.xml2json(this);
    33                        
     31
    3432                        annotations.push(annotation);
    3533                    });
     
    3937            });
    4038        },
    41         getAnnotation: function(aid, callback){
     39        getAnnotation: function(aid, callback) {
    4240            $.ajax({
    4341                type: "GET",
    44                 url: this.getBackend()+'/'+aid,
     42                url: this.getBackend() + '/' + aid,
    4543                dataType: "xml",
    46                 success: function(xml) {         
     44                success: function(xml) {
    4745                    var annotation = $xml.find('annotation');
    48                    
     46
    4947                    callback.call(undefined, annotation);
    5048                }
     
    5250        },
    5351        postAnnotation: function(annotation) {
    54             $.ajax({
     52            return $.ajax({
    5553                type: "POST",
    56                 url: this.getBackend()+'?store=true',
     54                url: this.getBackend() + '/api/annotations?store=true',
    5755                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                }
    5965            });
    6066        },
    61         setBackend:function(url) {this.backend = url;}
     67        setBackend: function(url) {
     68            this.backend = url;
     69        }
    6270    }
    6371}());
Note: See TracChangeset for help on using the changeset viewer.