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
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
57
  
58
  
59
  
60
  
61
  
62
  
63
  
64
  
65
  
66
  
67
  
68
  
69
  
70
  
71
  
72
  
73
  
74
  
75
  
76
  
77
  
78
  
79
  
80
  
81
  
82
  
83
  
84
  
85
  
86
  
87
  
88
  
89
  
90
  
91
  
92
  
93
  
94
  
95
  
96
  
97
  
98
  
99
  
100
  
101
  
102
  
103
  
104
  
105
  
106
  
107
  
108
  
109
  
110
  
111
  
112
  
113
  
114
  
115
  
116
  
117
  
118
  
119
  
120
  
121
  
122
  
123
  
124
  
125
  
126
  
127
  
128
  
129
  
130
  
131
  
132
  
133
  
134
  
135
  
136
  
137
  
138
  
139
  
140
  
141
  
142
  
143
  
144
  
145
  
146
  
147
  
148
  
149
  
150
  
151
  
152
  
153
  
154
  
155
  
156
  
157
  
158
  
159
  
160
  
161
  
162
  
163
  
164
  
165
  
166
  
167
  
168
  
169
  
170
  
171
  
172
  
173
  
174
  
175
  
176
  
177
  
178
  
179
  
180
  
181
  
182
  
183
  
184
  
185
  
186
  
187
  
188
  
189
  
190
  
191
  
192
  
193
  
194
  
195
  
196
  
197
  
198
  
199
  
200
  
201
  
202
  
203
  
204
  
205
  
206
  
207
  
208
  
209
  
210
  
211
  
212
  
213
  
214
  
215
  
216
  
217
  
218
  
219
  
220
  
221
  
222
  
223
  
224
  
225
  
226
  
227
  
228
  
229
  
230
  
231
  
232
  
233
  
234
  
235
  
236
  
237
  
238
  
239
  
240
  
241
  
242
  
243
  
244
  
245
  
246
  
247
  
248
  
249
  
250
  
251
  
252
  
253
  
254
  
255
  
256
  
257
  
258
  
259
  
260
  
261
  
262
  
263
  
264
  
265
  
266
  
267
  
268
  
269
  
270
  
271
  
272
  
273
  
274
  
275
  
276
  
277
  
278
  
279
  
280
  
281
  
282
  
283
  
284
  
285
  
286
  
287
  
288
  
289
  
290
  
291
  
292
  
293
  
294
  
295
  
296
  
297
  
298
  
299
  
300
  
301
  
302
  
303
  
304
  
305
  
306
  
307
  
308
  
309
  
310
  
311
  
312
  
313
  
314
  
315
  
316
  
317
  
318
  
319
  
320
  
321
  
322
  
323
  
324
  
325
  
326
  
327
  
328
  
329
  
330
  
331
  
332
  
333
  
334
  
335
  
336
  
337
  
338
  
339
  
340
  
341
  
342
  
343
  
344
  
345
  
346
  
347
  
348
  
349
  
350
  
351
  
352
  
353
  
354
  
355
  
356
  
357
  
358
  
359
  
360
  
361
  
362
  
363
  
364
  
365
  
366
  
367
  
368
  
369
  
370
  
371
  
372
  
373
  
374
  
375
  
376
  
377
  
378
  
379
  
380
  
381
  
382
  
383
  
384
  
385
  
386
  
387
  
388
  
389
  
390
  
391
  
392
  
393
  
394
  
395
  
396
  
397
  
398
  
399
  
400
  
401
  
402
  
403
  
404
  
405
  
406
  
407
  
408
  
409
  
410
  
411
  
412
  
413
  
414
  
415
  
416
  
417
  
418
  
419
  
420
  
421
  
422
  
423
  
424
  
425
  
426
  
427
  
428
  
429
  
430
  
431
  
432
  
433
  
434
  
435
  
436
  
437
  
438
  
439
  
440
  
441
  
442
  
443
  
444
  
445
  
446
  
447
  
448
  
449
  
450
  
451
  
452
  
453
  
454
  
455
  
456
  
457
  
458
  
459
  
460
  
461
  
462
  
463
  
464
  
465
  
466
  
467
  
468
  
469
  
470
  
471
  
472
  
473
  
474
  
475
  
476
  
477
  
478
  
479
  
480
  
481
  
482
  
483
  
484
  
485
  
486
  
487
  
488
  
489
  
490
  
491
  
492
  
493
  
494
  
495
  
496
  
497
  
498
  
499
  
500
  
501
  
502
  
503
  
504
  
505
  
506
  
507
  
508
  
509
  
510
  
511
  
512
  
513
  
514
  
515
  
516
  
517
  
518
  
519
  
520
  
521
  
522
  
523
  
524
  
525
  
526
  
527
  
528
  
529
  
530
  
531
  
532
  
533
  
534
  
535
  
536
  
537
  
538
  
539
  
540
  
541
  
542
  
543
  
544
  
545
  
546
  
547
  
548
  
549
  
550
  
551
  
552
  
553
  
554
  
555
  
556
  
557
  
558
  
559
  
560
  
561
  
562
  
563
  
564
  
565
  
566
  
567
  
568
  
569
  
570
  
571
  
572
  
573
  
574
  
575
  
576
  
577
  
578
  
579
  
580
  
581
  
582
  
583
  
584
  
585
  
586
  
587
  
588
  
589
  
590
  
591
  
592
  
593
  
594
  
595
  
596
  
597
  
598
  
599
  
600
  
601
  
602
  
603
  
604
  
605
  
606
  
607
  
608
  
609
  
610
  
611
  
612
  
613
  
614
  
615
  
616
  
617
  
618
  
619
  
620
  
621
  
622
  
623
  
624
  
625
  
626
  
627
  
628
  
629
  
630
  
631
  
632
  
633
  
634
  
635
  
636
  
637
  
/*global ROXEN, YAHOO */ 
/* jshint indent: 2 */ 
 
/** 
 * Module interface to the new Action File System 
 * 
 * @module afs 
 * @class AFS 
 * @namespace ROXEN 
 * @static 
 */ 
ROXEN.AFS = function () { 
 
  // 1 - Log AFS calls and responses. 
  // 2 - Also log calls to tagged callbacks, i.e. the single-response 
  //     callbacks passed to call(). 
  // 3 - Also log calls to global and error callbacks. 
  var debug_log = parseInt(ROXEN.getQueryVariable(window.location.href, 
                                                  "__afs-debug"), 10); 
 
  var session = ROXEN.config.session; 
 
  /** 
   * AFS actions path prefix. 
   */ 
  var actions_prefix = "/actions/"; 
 
  /** 
   * AFS session variable name in action URLs. 
   */ 
  var session_var = "session_id"; 
 
  /** 
   * How long a poll for new msgs is held by the server. 
   * A value of 0 disables blocking polls. 
   * A value of -1 means automatic (parameters decided by server). 
   * A value of -2 disables polling altogether. 
   * 
   * @property poll_timeout 
   * @type {Int} 
   * @private 
   */ 
  var poll_timeout = -1; // Auto mode. 
 
  /** 
   * Seconds to wait after the last AFS response before issuing 
   * another poll. When the client is idle, this is effectively the 
   * interval between polls. 
   * 
   * @property poll_delay 
   * @type {Int} 
   * @private 
   */ 
  var poll_delay = 30; 
 
  /** 
   * Seconds to wait after a low-level AFS error before issuing 
   * another poll. 
   * 
   * @property poll_error_delay 
   * @type {Int} 
   * @private 
   */ 
  var poll_error_delay = 30; 
 
  // True as long as the last AFS call was successful. 
  var connection_ok = false; 
 
  // Number of ongoing AFS calls. 
  var open_connections = 0; 
 
  var poll_delay_timeout_id; 
 
  // Maps the tag for the ongoing calls to the callback function and an 
  // optional group identifier when the response comes. 
  var tagged_callbacks = {}; 
 
  // Track groups of connections so they can aborted. 
  var groups = {}; 
 
  // Counter to produce unique tags. 
  var tag_count = 0; 
 
  // Set of callback functions that will receive all AFS responses. 
  var global_callbacks = []; 
 
  // Set of callback functions that get called when there are 
  // low-level AFS errors (connection errors or JSON format errors). 
  var error_callbacks = []; 
 
  // Set on init(). 
  var is_initialized = false; 
 
  function encode_afs_args (args) 
  { 
    var query = []; 
    var json_args = {}, got_json_args = false; 
 
    // Send strings as ordinary variables. Everything else is sent as 
    // json in the special __afs variable. That way it's possible to 
    // send variables that are parsed by the server outside the main 
    // afs query handler. 
 
    for (var name in args) 
      if (args.hasOwnProperty (name)) { 
        var val = args[name]; 
        if (YAHOO.lang.isString (val)) 
          // Assume the name only contains ordinary characters. May 
          // escape it later should it be a problem. 
          query.push (name + "=" + ROXEN.escapeURIComponent (val)); 
        else { 
          json_args[name] = val; 
          got_json_args = true; 
        } 
      } 
 
    if (got_json_args) 
      query.push ("__afs=" + ROXEN.escapeURIComponent(YAHOO.lang.JSON.stringify (json_args))); 
 
    return query.join ("&"); 
  } 
 
  function request_failure (resp) 
  { 
    ROXEN.log("ROXEN.AFS: connection error: " + 
              resp.status + " " + resp.statusText); 
 
    for (var i = 0; i < error_callbacks.length; i++) { 
      var cb = error_callbacks[i]; 
      if (debug_log > 2) 
        ROXEN.log ("  AFS calling error callback: " + cb.name); 
      try { 
        cb (resp); 
      } catch (err) { 
        ROXEN.log ("AFS: error in callback " + cb.name + ": " + err); 
        if (ROXEN.debug) 
          throw err; 
      } 
    } 
 
    // Forget all ongoing calls since we cannot hope to receive any 
    // useful responses to them anyway after this. 
    tagged_callbacks = {}; 
    groups = {}; 
 
    if (open_connections) { 
      open_connections = 0; 
      restart_poll (true); 
    } 
 
    connection_ok = false; 
  } 
 
  function json_parse_failure (err) 
  { 
    ROXEN.log("ROXEN.AFS: JSON parse error: " + err); 
 
    for (var i = 0; i < error_callbacks.length; i++) { 
      var cb = error_callbacks[i]; 
      if (debug_log > 2) 
        ROXEN.log ("  AFS calling error callback: " + cb.name); 
      // FIXME: Need a flag to tell it apart from a connection error? 
 
      try { 
        cb (err); 
      } catch (e) { 
        ROXEN.log ("AFS: error in callback " + cb.name + ": " + e); 
        if (ROXEN.debug) 
          throw e; 
      } 
    } 
 
    // Forget all ongoing calls since we cannot hope to receive any 
    // useful responses to them anyway after this. 
    tagged_callbacks = {}; 
    groups = {}; 
 
    if (open_connections) { 
      open_connections = 0; 
      restart_poll (true); 
    } 
 
    connection_ok = false; 
  } 
 
  function request_success (resp) 
  { 
    var msgs, cb, ct; 
 
    // YAHOO.util.Connect.asyncRequest follows redirect transparently and 
    // we want to detect the case when this is a redirect to a login page. 
    ct = resp.getResponseHeader["Content-Type"]; 
    if (ct && !ct.match(/application\/json/)) { 
      json_parse_failure(new Error("ContentTypeError")); 
      return; 
    } 
 
    try { 
      msgs = YAHOO.lang.JSON.parse(resp.responseText); 
    } 
    catch (err) { 
      json_parse_failure (err); 
      return; 
    } 
    msgs._etag = resp.getResponseHeader.Etag || resp.getResponseHeader.ETag; 
 
    for (var i = 0; i < msgs.length; i++) { 
      var msg = msgs[i]; 
      var tag = msg.tag; 
 
      if (tag) { 
        if (debug_log) 
          ROXEN.log ("AFS response: " + msg.msg_type + ", tag " + tag); 
 
        var ent = tagged_callbacks[tag]; 
        cb = ent && ent[0]; 
        if (ent === undefined) 
          ROXEN.log ("ROXEN.AFS: Warning: Got AFS response with " + 
                     "unknown tag: " + msg.msg_type); 
        else if (cb == -1) { 
          if (debug_log > 1) 
            ROXEN.log ("  AFS tagged callback was canceled"); 
          delete tagged_callbacks[tag]; 
        } else { 
          if (debug_log > 1) 
            ROXEN.log ("  AFS calling tagged callback: " + cb.name); 
          if (ROXEN.debug) 
            cb(msg); 
          else { 
            try { 
              cb(msg); 
            } catch (err) { 
              ROXEN.log("AFS: error in callback " + cb.name + ": " + err); 
            } 
          } 
          // Assume no more than one response with a given tag. See 
          // also AFS.ClientSession.push_response. 
          delete tagged_callbacks[tag]; 
          var group = ent[1]; 
          if (group) { 
            var g = groups[group]; 
            g.splice(g.indexOf(tag), 1); 
          } 
        } 
      } 
 
      else { 
        if (debug_log) 
          ROXEN.log ("AFS response: " + msg.msg_type); 
      } 
 
      for (var j = 0; j < global_callbacks.length; j++) { 
        cb = global_callbacks[j]; 
        if (debug_log > 2) 
          ROXEN.log ("  AFS calling global callback: " + cb.name); 
        try { 
          cb (msg); 
        } catch (err) { 
          ROXEN.log ("AFS: error in callback " + cb.name + ": " + err); 
          if (ROXEN.debug) 
            throw err; 
        } 
      } 
    } 
 
    if (open_connections > 0) { 
      open_connections--; 
      if (!open_connections) restart_poll (false); 
    } 
 
    connection_ok = true; 
  } 
 
  /** 
   * Calls an AFS action. 
   * 
   * @param {String}   action Requested action name. 
   * @param {Object}   args   Action arguments. "session_id" (or whatever 
   *                          name the session variable is given) and "tag" 
   *                          arguments get added to it. 
   * @param {Function} fn     Optional callback function to run when the 
   *                          corresponding AFS response comes back. 
   *                          It gets a single argument that is the 
   *                          response message in JSON. If this isn't 
   *                          given then the AFS action is untagged, 
   *                          and any response it produces will be 
   *                          sent to the global callbacks only. 
   * @param {Object}   scope  Scope correction (optional). 
   * @param {String}   group  Group identifier (optional). 
   * @return {Object}         Returns the connection object. 
   */ 
  function call(action, args, fn, scope, group) { 
    return call_or_post(action, "GET", args, 0, fn, scope, group); 
  } 
 
  function post(action, args, postargs, fn, scope, group) { 
    if (ROXEN.isString(postargs)) { 
      //  ID or name of a <form> tag that should be encoded 
      YAHOO.util.Connect.setForm(postargs); 
      postargs = undefined; 
    } else if (!ROXEN.isObject(postargs)) { 
      postargs = { }; 
    } 
 
    var postdata = [ ]; 
    if (postargs) { 
      var item = 0; 
      for (var idx in postargs) 
        if (postargs.hasOwnProperty(idx)) { 
          postdata[item++] = 
            encodeURIComponent(idx) + "=" + encodeURIComponent(postargs[idx]); 
        } 
    } 
    return call_or_post(action, "POST", args, postdata.join("&"), fn, scope); 
  } 
 
  function post_files(action, args, files, fn, scope, group) 
  { 
    //  File should come from the browser's FileList API. We will use FormData 
    //  together with XHR to post directly to the server without involving YUI. 
 
    //  Prepare AFS call 
    if (!ROXEN.isObject(args)) 
      args = { }; 
    if (scope) 
      fn = ROXEN.bind(scope, fn); 
    if (fn) { 
      var tag = ++tag_count + ""; 
      if (debug_log) 
        ROXEN.log ("AFS call: " + action + " " + 
                   YAHOO.lang.JSON.stringify (args) + 
                   ", callback " + fn.name + ", tag " + tag); 
      args.tag = tag; 
      tagged_callbacks[tag] = [ fn, group ]; 
    } else if (debug_log) { 
      ROXEN.log ("AFS call: " + action + " " + 
                 YAHOO.lang.JSON.stringify (args)); 
    } 
    if (fn && group) { 
      if (!groups[group]) groups[group] = [ ]; 
      groups[group].push(args.tag); 
    } 
 
    args[session_var] = session; 
    open_connections++; 
 
    //  Initiate transfer 
    var url = actions_prefix + action + "?" + encode_afs_args(args); 
    var fd = new FormData(); 
    for (var i = 0; i < files.length; i++) 
      fd.append("upload-file-" + i, files[i]); 
    var xhr = new XMLHttpRequest(); 
    xhr.open("POST", url, true); 
    xhr.onreadystatechange = function() { 
      if (xhr.readyState === 4) { 
        if (xhr.status === 200) { 
          //  Invoke success callback 
          request_success(xhr); 
        } else if (xhr.status === 0 || xhr.status >= 400) { 
          //  Invoke failure callback 
          request_failure(xhr); 
        } 
      } 
    }; 
    xhr.send(fd); 
  } 
 
  function call_or_post(action, method, args, postdata, fn, scope, group) { 
    if (!ROXEN.isObject(args)) { 
      args = {}; 
    } 
 
    if (scope) 
      fn = ROXEN.bind (scope, fn); 
 
    if (fn) { 
      var tag = ++tag_count+""; 
      if (debug_log) 
        ROXEN.log ("AFS call: " + action + " " + 
                   YAHOO.lang.JSON.stringify (args) + 
                   ", callback " + fn.name + ", tag " + tag); 
      args.tag = tag; 
      tagged_callbacks[tag] = [ fn, group ]; 
    } 
    else { 
      if (debug_log) 
        ROXEN.log ("AFS call: " + action + " " + 
                   YAHOO.lang.JSON.stringify (args)); 
    } 
 
    args[session_var] = session; 
 
    open_connections++; 
    var url = actions_prefix + action + "?" + encode_afs_args (args); 
    var con = YAHOO.util.Connect.asyncRequest ( method, url, 
                                                { cache: false, 
                                                  success: request_success, 
                                                  failure: request_failure }, 
                                                postdata); 
    if (fn && group) { 
      if (!groups[group]) groups[group] = [ ]; 
      groups[group].push(args.tag); 
    } 
 
    return con; 
  } 
 
  /** 
   * Abort all requests created with specified group. 
   * 
   * @param {String} group 
   *   Group identifier. 
   */ 
  function abort(group_name) { 
    var group = groups[group_name]; 
    if (!group) return; 
    for (var i = 0; i < group.length; i++) { 
      tagged_callbacks[group[i]][0] = -1; 
    } 
    delete groups[group_name]; 
  } 
 
 
  /** 
   * Returns the status of the AFS connection, without querying the 
   * server. 
   * 
   * @return {Boolean} 
   *   Returns true if the last AFS call returned successfully, false 
   *   otherwise. 
   */ 
  function has_connection() 
  { 
    return connection_ok; 
  } 
 
  /** 
   * Adds a global callback, i.e. a callback that will be called for 
   * every AFS response from the server. 
   * 
   * @param {Function} fn 
   *   Callback function. It will be called with a single argument 
   *   that is the AFS response message in JSON. 
   * @param {Object} scope 
   *   Optional scope correction. 
   * @return {Function} 
   *   Returns the function actually added, which can be used in a later 
   *   call to remove_global_callback. 
   */ 
  function add_global_callback (fn, scope) 
  { 
    if (scope) 
      fn = ROXEN.bind (scope, fn); 
    global_callbacks.push (fn); 
    return fn; 
  } 
 
  /** 
   * Removes a callback from the set of global callbacks. 
   * 
   * @param {Function} fn 
   *   Callback to remove. Nothing happens if it doesn't match any 
   *   registered callback. 
   */ 
  function remove_global_callback (fn) 
  { 
    for (var i = 0; i < global_callbacks.length; i++) 
      if (global_callbacks[i] === fn) { 
        global_callbacks.splice (i, 1); 
        break; 
      } 
  } 
 
  /** 
   * Adds a callback that will be called whenever there is a low-level 
   * AFS error; either a connection error or a syntax error in a JSON 
   * response. 
   * 
   * @param {Function} fn 
   *   Callback function. It will be called with a single argument 
   *   which is either a YAHOO.util.Connect.asyncRequest or XMLHttpRequest 
   *   failure handler response, or an exception object thrown by 
   *   YAHOO.lang.JSON.parse. 
   * @param {Object} scope 
   *   Optional scope correction. 
   * @return {Function} 
   *   Returns the function actually added, which can be used in a later 
   *   call to remove_global_callback. 
   */ 
  function add_error_callback (fn, scope) 
  { 
    if (scope) 
      fn = ROXEN.bind (scope, fn); 
    error_callbacks.push (fn); 
    return fn; 
  } 
 
  /** 
   * Removes a callback from the set of callbacks called for low-level 
   * AFS errors. 
   * 
   * @param {Function} fn 
   *   Callback to remove. Nothing happens if it doesn't match any 
   *   registered callback. 
   */ 
  function remove_error_callback (fn) 
  { 
    for (var i = 0; i < error_callbacks.length; i++) 
      if (error_callbacks[i] === fn) { 
        error_callbacks.splice (i, 1); 
        break; 
      } 
  } 
 
  function poll_callback (response) 
  { 
    if (poll_timeout == -1 && !ROXEN.isUndefined (response.poll_interval)) 
      poll_delay = response.poll_interval; 
  } 
 
  function restart_poll (after_error) 
  { 
    if (poll_timeout >= -1 && !poll_delay_timeout_id) { 
      var delay = (after_error ? poll_error_delay : poll_delay) * 1000; 
      if (debug_log > 2) 
        ROXEN.log ("AFS poll delay " + delay + " ms"); 
      poll_delay_timeout_id = 
        window.setTimeout (function () { 
          poll_delay_timeout_id = undefined; 
          call ("poll", 
                {timeout  : poll_timeout, 
                 interval : poll_delay}, 
                poll_callback); 
        }, delay); 
    } 
  } 
 
  /** 
   * (Re)initializes the AFS lib. All open connections are forgotten, 
   * and a poll action is started right away (provided polling is 
   * enabled). 
   * 
   * Global and error callbacks are not forgotten, and responses from 
   * old open connections can still be delivered to them (subject to 
   * change if necessary). 
   * 
   * @param {String}   actions_prefix   Path prefix for all AFS actions. 
   *                                    If not provided /actions/ is used. 
   * @param {String}   session_var      Session variable name. Will be set to 
   *                                    "session_var" If not provided. 
   * @param {Number}   poll_timeout     Poll timeout in seconds, or -1 for 
   *                                    auto mode (default), and -2 to disable. 
   */ 
  function init(options) 
  { 
    if (options) { 
      if (options.actions_prefix) 
        actions_prefix = options.actions_prefix; 
      if (options.session_var) 
        session_var = options.session_var; 
      if (options.poll_timeout) 
        poll_timeout = options.poll_timeout; 
    } 
 
    if (debug_log) 
      ROXEN.log ("AFS init"); 
 
    connection_ok = false; 
    open_connections = 0; 
    tagged_callbacks = {}; 
 
    if (poll_delay_timeout_id) { 
      clearTimeout (poll_delay_timeout_id); 
      poll_delay_timeout_id = undefined; 
    } 
 
    if (poll_timeout >= -1 && !open_connections) 
      call ("poll", 
            {timeout  : poll_timeout, 
             interval : poll_delay}, 
            poll_callback); 
 
    is_initialized = true; 
  } 
 
  /** 
   * Will return true after init() has been called once. 
   */ 
  function initialized() { 
    return is_initialized; 
  } 
 
  /** 
   * Makes an asynchronous GET request to any URL. 
   * 
   * Note that this really has nothing to do with AFS. 
   * 
   * @method request 
   * @param {String}   url   Requested URL. 
   * @param {Function} fn    Callback function to run when done. 
   *                         fn's argument list is (result, status). 
   *                         status is AFS_REQUEST_SUCCESS or 
   *                         AFS_REQUEST_FAILURE. 
   * @param {Object}   scope Scope correction (optional). 
   * @return {Object}        Returns the connection object. 
   */ 
  function request(url, fn, scope) { 
    var cb = { 
      cache: false, 
      success: function (o) { 
        fn.call(scope, o, "AFS_REQUEST_SUCCESS"); 
      }, 
      failure: function  (o) { 
        ROXEN.log("ROXEN.AFS: connection error: " + 
                   o.status + " " + o.statusText); 
        fn.call(scope, o, "AFS_REQUEST_FAILURE"); 
      } 
    }; 
    return YAHOO.util.Connect.asyncRequest("GET", url, cb); 
  } 
 
  return { 
    call: call, 
    post: post, 
    post_files: post_files, 
    abort: abort, 
    has_connection: has_connection, 
    add_global_callback: add_global_callback, 
    remove_global_callback: remove_global_callback, 
    add_error_callback: add_error_callback, 
    remove_error_callback: remove_error_callback, 
    init: init, 
    initialized: initialized, 
    request: request 
  }; 
}();