Fossil

Diff
Login

Differences From Artifact [a1e2db28f1]:

To Artifact [e891d48cf6]:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

19
20
21
22
23
24
25
/**
    This file contains a WhAjaj extension for use with Fossil/JSON.

    Author: Stephan Beal (sgbeal@googlemail.com)

    License: Public Domain
*/

/**
    Constructor for a new AJAJ client. ajajOpt may be an optional object
    suitable for passing to the WhAjaj.Connector() constructor.
    
    On returning, this.ajaj is-a WhAjaj.Connector instance which can 
    be used to send requests to the back-end (though the convenience 
    functions of this class are the preferred way to do it). Clients 
    are encouraged to use FossilAjaj.sendRequest() (and friends) instead 
    of the underlying WhAjaj.Connector API, since this class' API 
    contains SP-specific request-calling functions.

*/
function FossilAjaj(ajajOpt)
{
    this.ajaj = new WhAjaj.Connector(ajajOpt);
    return this;
}










|
|




|

|
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/**
    This file contains a WhAjaj extension for use with Fossil/JSON.

    Author: Stephan Beal (sgbeal@googlemail.com)

    License: Public Domain
*/

/**
    Constructor for a new Fossil AJAJ client. ajajOpt may be an optional
    object suitable for passing to the WhAjaj.Connector() constructor.
    
    On returning, this.ajaj is-a WhAjaj.Connector instance which can 
    be used to send requests to the back-end (though the convenience 
    functions of this class are the preferred way to do it). Clients 
    are encouraged to use FossilAjaj.sendCommand() (and friends) instead 
    of the underlying WhAjaj.Connector API, since this class' API 
    contains Fossil-specific request-calling handling (e.g. of authentication
    info) whereas WhAjaj is more generic.
*/
function FossilAjaj(ajajOpt)
{
    this.ajaj = new WhAjaj.Connector(ajajOpt);
    return this;
}

42
43
44
45
46
47
48
49
50
51
52
53
54

55
56
57
58
59
60
61
62
63
64
    
    This function constructs a Fossil/JSON request envelope based
    on the given arguments and adds this.authToken and a requestId
    to it.
*/
FossilAjaj.prototype.sendCommand = function(command, payload, ajajOpt) {
    var req;
    
    if(payload || this.authToken) {
        req = {
            payload:payload || undefined,
            requestId:this.generateRequestId(),
            authToken:this.authToken || undefined

        };
    }
    ajajOpt = ajajOpt || {};
    if(command) ajajOpt.url = this.ajaj.derivedOption('url',ajajOpt) + command;
    if( 0 && this.authToken ) {
        if( req ) req.authToken = this.authToken;
        else { // GET request: extend ajajOpt.urlParam
            var urlArgs = ajajOpt.urlParam;
            if( 'string' === typeof urlArgs ) {
                ajajOpt.urlParam += '&authToken='+encodeUriComponent(this.authToken);







|
|

|
|
|
>


|







43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
    
    This function constructs a Fossil/JSON request envelope based
    on the given arguments and adds this.authToken and a requestId
    to it.
*/
FossilAjaj.prototype.sendCommand = function(command, payload, ajajOpt) {
    var req;
    ajajOpt = ajajOpt || {};
    if(payload || this.authToken || ajajOpt.jsonp) {
        req = {
            payload:payload,
            requestId:('function' === typeof this.generateRequestId) ? this.generateRequestId() : undefined,
            authToken:this.authToken || undefined,
            jsonp:('string' === typeof ajajOpt.jsonp) ? ajajOpt.jsonp : undefined
        };
    }
    
    if(command) ajajOpt.url = this.ajaj.derivedOption('url',ajajOpt) + command;
    if( 0 && this.authToken ) {
        if( req ) req.authToken = this.authToken;
        else { // GET request: extend ajajOpt.urlParam
            var urlArgs = ajajOpt.urlParam;
            if( 'string' === typeof urlArgs ) {
                ajajOpt.urlParam += '&authToken='+encodeUriComponent(this.authToken);