PageSourceSearch

https://ynlf.gov.cn/_dwr/engine.js

js ynlf.gov.cn collected 2026-10-03 00:28:39 UTC 46,845 bytes, 1,319 lines download raw bytes

1/**
2 * Declare an object to which we can add real functions.
3 */
4if (dwr == null) var dwr = {};
5if (dwr.engine == null) dwr.engine = {};
6if (DWREngine == null) var DWREngine = dwr.engine;
7
8/**
9 * Set an alternative error handler from the default alert box.
10 * @see /dwr/browser/engine/errors
11 */
12dwr.engine.setErrorHandler = function(handler) {
13  dwr.engine._errorHandler = handler;
14};
15
16/**
17 * Set an alternative warning handler from the default alert box.
18 * @see /dwr/browser/engine/errors
19 */
20dwr.engine.setWarningHandler = function(handler) {
21  dwr.engine._warningHandler = handler;
22};
23
24/**
25 * Setter for the text/html handler - what happens if a DWR request gets an HTML
26 * reply rather than the expected Javascript. Often due to login timeout
27 */
28dwr.engine.setTextHtmlHandler = function(handler) {
29  dwr.engine._textHtmlHandler = handler;
30};
31
32/**
33 * Set a default timeout value for all calls. 0 (the default) turns timeouts off.
34 * @see /dwr/browser/engine/errors
35 */
36dwr.engine.setTimeout = function(timeout) {
37  dwr.engine._timeout = timeout;
38};
39
40/**
41 * The Pre-Hook is called before any DWR remoting is done.
42 * @see /dwr/browser/engine/hooks
43 */
44dwr.engine.setPreHook = function(handler) {
45  dwr.engine._preHook = handler;
46};
47
48/**
49 * The Post-Hook is called after any DWR remoting is done.
50 * @see /dwr/browser/engine/hooks
51 */
52dwr.engine.setPostHook = function(handler) {
53  dwr.engine._postHook = handler;
54};
55
56/**
57 * Custom headers for all DWR calls
58 * @see /dwr/????
59 */
60dwr.engine.setHeaders = function(headers) {
61  dwr.engine._headers = headers;
62};
63
64/**
65 * Custom parameters for all DWR calls
66 * @see /dwr/????
67 */
68dwr.engine.setParameters = function(parameters) {
69  dwr.engine._parameters = parameters;
70};
71
72/** XHR remoting type constant. See dwr.engine.set[Rpc|Poll]Type() */
73dwr.engine.XMLHttpRequest = 1;
74
75/** XHR remoting type constant. See dwr.engine.set[Rpc|Poll]Type() */
76dwr.engine.IFrame = 2;
77
78/** XHR remoting type constant. See dwr.engine.setRpcType() */
79dwr.engine.ScriptTag = 3;
80
81/**
82 * Set the preferred remoting type.
83 * @param newType One of dwr.engine.XMLHttpRequest or dwr.engine.IFrame or dwr.engine.ScriptTag
84 * @see /dwr/browser/engine/options
85 */
86dwr.engine.setRpcType = function(newType) {
87  if (newType != dwr.engine.XMLHttpRequest && newType != dwr.engine.IFrame && newType != dwr.engine.ScriptTag) {
88    dwr.engine._handleError(null, { name:"dwr.engine.invalidRpcType", message:"RpcType must be one of dwr.engine.XMLHttpRequest or dwr.engine.IFrame or dwr.engine.ScriptTag" });
89    return;
90  }
91  dwr.engine._rpcType = newType;
92};
93
94/**
95 * Which HTTP method do we use to send results? Must be one of "GET" or "POST".
96 * @see /dwr/browser/engine/options
97 */
98dwr.engine.setHttpMethod = function(httpMethod) {
99  if (httpMethod != "GET" && httpMethod != "POST") {
100    dwr.engine._handleError(null, { name:"dwr.engine.invalidHttpMethod", message:"Remoting method must be one of GET or POST" });
101    return;
102  }
103  dwr.engine._httpMethod = httpMethod;
104};
105
106/**
107 * Ensure that remote calls happen in the order in which they were sent? (Default: false)
108 * @see /dwr/browser/engine/ordering
109 */
110dwr.engine.setOrdered = function(ordered) {
111  dwr.engine._ordered = ordered;
112};
113
114/**
115 * Do we ask the XHR object to be asynchronous? (Default: true)
116 * @see /dwr/browser/engine/options
117 */
118dwr.engine.setAsync = function(async) {
119  dwr.engine._async = async;
120};
121
122/**
123 * Does DWR poll the server for updates? (Default: false)
124 * @see /dwr/browser/engine/options
125 */
126dwr.engine.setActiveReverseAjax = function(activeReverseAjax) {
127  if (activeReverseAjax) {
128    // Bail if we are already started
129    if (dwr.engine._activeReverseAjax) return;
130    dwr.engine._activeReverseAjax = true;
131    dwr.engine._poll();
132  }
133  else {
134    // Can we cancel an existing request?
135    if (dwr.engine._activeReverseAjax && dwr.engine._pollReq) dwr.engine._pollReq.abort();
136    dwr.engine._activeReverseAjax = false;
137  }
138  // TODO: in iframe mode, if we start, stop, start then the second start may
139  // well kick off a second iframe while the first is still about to return
140  // we should cope with this but we don't
141};
142
143/**
144 * The default message handler.
145 * @see /dwr/browser/engine/errors
146 */
147dwr.engine.defaultErrorHandler = function(message, ex) {
148  dwr.engine._debug("Error: " + ex.name + ", " + ex.message, true);
149  /*if (message == null || message == "") alert("A server error has occured.");
150  // Ignore NS_ERROR_NOT_AVAILABLE if Mozilla is being narky
151  else if (message.indexOf("0x80040111") != -1) dwr.engine._debug(message);
152  else if (message.indexOf("Failed to read input") == -1 && 
153    message.indexOf("Not Implemented") == -1 && 
154    message.indexOf("Service Unavailable") == -1 ) alert(message);
155    */
156    dwr.engine._debug(message);
157};
158
159/**
160 * The default warning handler.
161 * @see /dwr/browser/engine/errors
162 */
163dwr.engine.defaultWarningHandler = function(message, ex) {
164  dwr.engine._debug(message);
165};
166
167/**
168 * For reduced latency you can group several remote calls together using a batch.
169 * @see /dwr/browser/engine/batch
170 */
171dwr.engine.beginBatch = function() {
172  if (dwr.engine._batch) {
173    dwr.engine._handleError(null, { name:"dwr.engine.batchBegun", message:"Batch already begun" });
174    return;
175  }
176  dwr.engine._batch = dwr.engine._createBatch();
177};
178
179/**
180 * Finished grouping a set of remote calls together. Go and execute them all.
181 * @see /dwr/browser/engine/batch
182 */
183dwr.engine.endBatch = function(options) {
184  var batch = dwr.engine._batch;
185  if (batch == null) {
186    dwr.engine._handleError(null, { name:"dwr.engine.batchNotBegun", message:"No batch in progress" });
187    return;
188  }
189  dwr.engine._batch = null;
190  if (batch.map.callCount == 0) return;
191
192  // The hooks need to be merged carefully to preserve ordering
193  if (options) dwr.engine._mergeBatch(batch, options);
194
195  // In ordered mode, we don't send unless the list of sent items is empty
196  if (dwr.engine._ordered && dwr.engine._batchesLength != 0) {
197    dwr.engine._batchQueue[dwr.engine._batchQueue.length] = batch;
198  }
199  else {
200    dwr.engine._sendData(batch);
201  }
202};
203
204/** @deprecated */
205dwr.engine.setPollMethod = function(type) { dwr.engine.setPollType(type); };
206dwr.engine.setMethod = function(type) { dwr.engine.setRpcType(type); };
207dwr.engine.setVerb = function(verb) { dwr.engine.setHttpMethod(verb); };
208dwr.engine.setPollType = function() { dwr.engine._debug("Manually setting the Poll Type is not supported"); };
209
210//==============================================================================
211// Only private stuff below here
212//==============================================================================
213
214/** The original page id sent from the server */
215dwr.engine._origScriptSessionId = "D8DA66145890D86AEBF74875D43AECAF";
216
217/** The session cookie name */
218dwr.engine._sessionCookieName = "JSESSIONID"; // JSESSIONID
219
220/** Is GET enabled for the benefit of Safari? */
221dwr.engine._allowGetForSafariButMakeForgeryEasier = "false";
222
223/** The script prefix to strip in the case of scriptTagProtection. */
224dwr.engine._scriptTagProtection = "throw 'allowScriptTagRemoting is false.';";
225
226/** The default path to the DWR servlet */
227dwr.engine._defaultPath = "/system/dwr";
228
229/** Do we use XHR for reverse ajax because we are not streaming? */
230dwr.engine._pollWithXhr = "false";
231
232/** The read page id that we calculate */
233dwr.engine._scriptSessionId = null;
234
235/** The function that we use to fetch/calculate a session id */
236dwr.engine._getScriptSessionId = function() {
237  if (dwr.engine._scriptSessionId == null) {
238    dwr.engine._scriptSessionId = dwr.engine._origScriptSessionId + Math.floor(Math.random() * 1000);
239  }
240  return dwr.engine._scriptSessionId;
241};
242
243/** A function to call if something fails. */
244dwr.engine._errorHandler = dwr.engine.defaultErrorHandler;
245
246/** For debugging when something unexplained happens. */
247dwr.engine._warningHandler = dwr.engine.defaultWarningHandler;
248
249/** A function to be called before requests are marshalled. Can be null. */
250dwr.engine._preHook = null;
251
252/** A function to be called after replies are received. Can be null. */
253dwr.engine._postHook = null;
254
255/** An map of the batches that we have sent and are awaiting a reply on. */
256dwr.engine._batches = {};
257
258/** A count of the number of outstanding batches. Should be == to _batches.length unless prototype has messed things up */
259dwr.engine._batchesLength = 0;
260
261/** In ordered mode, the array of batches waiting to be sent */
262dwr.engine._batchQueue = [];
263
264/** What is the default rpc type */
265dwr.engine._rpcType = dwr.engine.XMLHttpRequest;
266
267/** What is the default remoting method (ie GET or POST) */
268dwr.engine._httpMethod = "POST";
269
270/** Do we attempt to ensure that calls happen in the order in which they were sent? */
271dwr.engine._ordered = false;
272
273/** Do we make the calls async? */
274dwr.engine._async = true;
275
276/** The current batch (if we are in batch mode) */
277dwr.engine._batch = null;
278
279/** The global timeout */
280dwr.engine._timeout = 0;
281
282/** ActiveX objects to use when we want to convert an xml string into a DOM object. */
283dwr.engine._DOMDocument = ["Msxml2.DOMDocument.6.0", "Msxml2.DOMDocument.5.0", "Msxml2.DOMDocument.4.0", "Msxml2.DOMDocument.3.0", "MSXML2.DOMDocument", "MSXML.DOMDocument", "Microsoft.XMLDOM"];
284
285/** The ActiveX objects to use when we want to do an XMLHttpRequest call. */
286dwr.engine._XMLHTTP = ["Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"];
287
288/** Are we doing comet or polling? */
289dwr.engine._activeReverseAjax = false;
290
291/** The iframe that we are using to poll */
292dwr.engine._outstandingIFrames = [];
293
294/** The xhr object that we are using to poll */
295dwr.engine._pollReq = null;
296
297/** How many milliseconds between internal comet polls */
298dwr.engine._pollCometInterval = 200;
299
300/** How many times have we re-tried to poll? */
301dwr.engine._pollRetries = 0;
302dwr.engine._maxPollRetries = 0;
303
304/** Do we do a document.reload if we get a text/html reply? */
305dwr.engine._textHtmlHandler = null;
306
307/** If you wish to send custom headers with every request */
308dwr.engine._headers = null;
309
310/** If you wish to send extra custom request parameters with each request */
311dwr.engine._parameters = null;
312
313/** Undocumented interceptors - do not use */
314dwr.engine._postSeperator = "&";
315dwr.engine._defaultInterceptor = function(data) { return data; };
316dwr.engine._urlRewriteHandler = dwr.engine._defaultInterceptor;
317dwr.engine._contentRewriteHandler = dwr.engine._defaultInterceptor;
318dwr.engine._replyRewriteHandler = dwr.engine._defaultInterceptor;
319
320/** Batch ids allow us to know which batch the server is answering */
321dwr.engine._nextBatchId = 0;
322
323/** A list of the properties that need merging from calls to a batch */
324dwr.engine._propnames = [ "rpcType", "httpMethod", "async", "timeout", "errorHandler", "warningHandler", "textHtmlHandler" ];
325
326/** Do we stream, or can be hacked to do so? */
327dwr.engine._partialResponseNo = 0;
328dwr.engine._partialResponseYes = 1;
329dwr.engine._partialResponseFlush = 2;
330
331/** Is this page in the process of unloading? */
332dwr.engine._unloading = false;
333
334/**
335 * @private Send a request. Called by the Javascript interface stub
336 * @param path part of URL after the host and before the exec bit without leading or trailing /s
337 * @param scriptName The class to execute
338 * @param methodName The method on said class to execute
339 * @param func The callback function to which any returned data should be passed
340 *       if this is null, any returned data will be ignored
341 * @param vararg_params The parameters to pass to the above class
342 */
343dwr.engine._execute = function(path, scriptName, methodName, vararg_params) {
344  var singleShot = false;
345  if (dwr.engine._batch == null) {
346    dwr.engine.beginBatch();
347    singleShot = true;
348  }
349  var batch = dwr.engine._batch;
350  // To make them easy to manipulate we copy the arguments into an args array
351  var args = [];
352  for (var i = 0; i < arguments.length - 3; i++) {
353    args[i] = arguments[i + 3];
354  }
355  // All the paths MUST be to the same servlet
356  if (batch.path == null) {
357    batch.path = path;
358  }
359  else {
360    if (batch.path != path) {
361      dwr.engine._handleError(batch, { name:"dwr.engine.multipleServlets", message:"Can't batch requests to multiple DWR Servlets." });
362      return;
363    }
364  }
365  // From the other params, work out which is the function (or object with
366  // call meta-data) and which is the call parameters
367  var callData;
368  var lastArg = args[args.length - 1];
369  if (typeof lastArg == "function" || lastArg == null) callData = { callback:args.pop() };
370  else callData = args.pop();
371
372  // Merge from the callData into the batch
373  dwr.engine._mergeBatch(batch, callData);
374  batch.handlers[batch.map.callCount] = {
375    exceptionHandler:callData.exceptionHandler,
376    callback:callData.callback
377  };
378
379  // Copy to the map the things that need serializing
380  var prefix = "c" + batch.map.callCount + "-";
381  batch.map[prefix + "scriptName"] = scriptName;
382  batch.map[prefix + "methodName"] = methodName;
383  batch.map[prefix + "id"] = batch.map.callCount;
384  var refctx = [];
385  for (i = 0; i < args.length; i++) {
386    dwr.engine._serializeAll(batch, refctx, args[i], prefix + "param" + i);
387  }
388
389  // Now we have finished remembering the call, we incr the call count
390  batch.map.callCount++;
391  if (singleShot) dwr.engine.endBatch();
392};
393
394/** @private Poll the server to see if there is any data waiting */
395dwr.engine._poll = function() {
396  if (!dwr.engine._activeReverseAjax) return;
397
398  var batch = dwr.engine._createBatch();
399  batch.map.id = 0; // TODO: Do we need this??
400  batch.map.callCount = 1;
401  batch.isPoll = true;
402  if (dwr.engine._pollWithXhr == "true") {
403    batch.rpcType = dwr.engine.XMLHttpRequest;
404    batch.map.partialResponse = dwr.engine._partialResponseNo;
405  }
406  else {
407    if (navigator.userAgent.indexOf("Gecko/") != -1) {
408      batch.rpcType = dwr.engine.XMLHttpRequest;
409      batch.map.partialResponse = dwr.engine._partialResponseYes;
410    }
411    else {
412      batch.rpcType = dwr.engine.XMLHttpRequest;
413      batch.map.partialResponse = dwr.engine._partialResponseNo;
414    }
415  }
416  batch.httpMethod = "POST";
417  batch.async = true;
418  batch.timeout = 0;
419  batch.path = dwr.engine._defaultPath;
420  batch.preHooks = [];
421  batch.postHooks = [];
422  batch.errorHandler = dwr.engine._pollErrorHandler;
423  batch.warningHandler = dwr.engine._pollErrorHandler;
424  batch.handlers[0] = {
425    callback:function(pause) {
426      dwr.engine._pollRetries = 0;
427      setTimeout(dwr.engine._poll, pause);
428    }
429  };
430
431  // Send the data
432  dwr.engine._sendData(batch);
433  if (batch.rpcType == dwr.engine.XMLHttpRequest && batch.map.partialResponse == dwr.engine._partialResponseYes) {
434    dwr.engine._checkCometPoll();
435  }
436};
437
438/** Try to recover from polling errors */
439dwr.engine._pollErrorHandler = function(msg, ex) {
440  // if anything goes wrong then just silently try again (up to 3x) after 10s
441  dwr.engine._pollRetries++;
442  dwr.engine._debug("Reverse Ajax poll failed (pollRetries=" + dwr.engine._pollRetries + "): " + ex.name + " : " + ex.message);
443  if (dwr.engine._pollRetries < dwr.engine._maxPollRetries) {
444    setTimeout(dwr.engine._poll, 10000);
445  }
446  else {
447    dwr.engine._activeReverseAjax = false;
448    dwr.engine._debug("Giving up.");
449  }
450};
451
452/** @private Generate a new standard batch */
453dwr.engine._createBatch = function() {
454  var batch = {
455    map:{
456      callCount:0,
457      page:window.location.pathname + window.location.search,
458      httpSessionId:dwr.engine._getJSessionId(),
459      scriptSessionId:dwr.engine._getScriptSessionId()
460    },
461    charsProcessed:0, paramCount:0,
462    parameters:{}, headers:{},
463    isPoll:false, handlers:{}, preHooks:[], postHooks:[],
464    rpcType:dwr.engine._rpcType,
465    httpMethod:dwr.engine._httpMethod,
466    async:dwr.engine._async,
467    timeout:dwr.engine._timeout,
468    errorHandler:dwr.engine._errorHandler,
469    warningHandler:dwr.engine._warningHandler,
470    textHtmlHandler:dwr.engine._textHtmlHandler
471  };
472  if (dwr.engine._preHook) batch.preHooks.push(dwr.engine._preHook);
473  if (dwr.engine._postHook) batch.postHooks.push(dwr.engine._postHook);
474  var propname, data;
475  if (dwr.engine._headers) {
476    for (propname in dwr.engine._headers) {
477      data = dwr.engine._headers[propname];
478      if (typeof data != "function") batch.headers[propname] = data;
479    }
480  }
481  if (dwr.engine._parameters) {
482    for (propname in dwr.engine._parameters) {
483      data = dwr.engine._parameters[propname];
484      if (typeof data != "function") batch.parameters[propname] = data;
485    }
486  }
487  return batch;
488};
489
490/** @private Take further options and merge them into */
491dwr.engine._mergeBatch = function(batch, overrides) {
492  var propname, data;
493  for (var i = 0; i < dwr.engine._propnames.length; i++) {
494    propname = dwr.engine._propnames[i];
495    if (overrides[propname] != null) batch[propname] = overrides[propname];
496  }
497  if (overrides.preHook != null) batch.preHooks.unshift(overrides.preHook);
498  if (overrides.postHook != null) batch.postHooks.push(overrides.postHook);
499  if (overrides.headers) {
500    for (propname in overrides.headers) {
501      data = overrides.headers[propname];
502      if (typeof data != "function") batch.headers[propname] = data;
503    }
504  }
505  if (overrides.parameters) {
506    for (propname in overrides.parameters) {
507      data = overrides.parameters[propname];
508      if (typeof data != "function") batch.map["p-" + propname] = "" + data;
509    }
510  }
511};
512
513/** @private What is our session id? */
514dwr.engine._getJSessionId =  function() {
515  var cookies = document.cookie.split(';');
516  for (var i = 0; i < cookies.length; i++) {
517    var cookie = cookies[i];
518    while (cookie.charAt(0) == ' ') cookie = cookie.substring(1, cookie.length);
519    if (cookie.indexOf(dwr.engine._sessionCookieName + "=") == 0) {
520      return cookie.substring(dwr.engine._sessionCookieName.length + 1, cookie.length);
521    }
522  }
523  return "";
524};
525
526/** @private Check for reverse Ajax activity */
527dwr.engine._checkCometPoll = function() {
528  for (var i = 0; i < dwr.engine._outstandingIFrames.length; i++) {
529    var text = "";
530    var iframe = dwr.engine._outstandingIFrames[i];
531    try {
532      text = dwr.engine._getTextFromCometIFrame(iframe);
533    }
534    catch (ex) {
535      dwr.engine._handleWarning(iframe.batch, ex);
536    }
537    if (text != "") dwr.engine._processCometResponse(text, iframe.batch);
538  }
539  if (dwr.engine._pollReq) {
540    var req = dwr.engine._pollReq;
541    var text = req.responseText;
542    if (text != null) dwr.engine._processCometResponse(text, req.batch);
543  }
544
545  // If the poll resources are still there, come back again
546  if (dwr.engine._outstandingIFrames.length > 0 || dwr.engine._pollReq) {
547    setTimeout(dwr.engine._checkCometPoll, dwr.engine._pollCometInterval);
548  }
549};
550
551/** @private Extract the whole (executed an all) text from the current iframe */
552dwr.engine._getTextFromCometIFrame = function(frameEle) {
553  var body = frameEle.contentWindow.document.body;
554  if (body == null) return "";
555  var text = body.innerHTML;
556  // We need to prevent IE from stripping line feeds
557  if (text.indexOf("<PRE>") == 0 || text.indexOf("<pre>") == 0) {
558    text = text.substring(5, text.length - 7);
559  }
560  return text;
561};
562
563/** @private Some more text might have come in, test and execute the new stuff */
564dwr.engine._processCometResponse = function(response, batch) {
565  if (batch.charsProcessed == response.length) return;
566  if (response.length == 0) {
567    batch.charsProcessed = 0;
568    return;
569  }
570
571  var firstStartTag = response.indexOf("//#DWR-START#", batch.charsProcessed);
572  if (firstStartTag == -1) {
573    // dwr.engine._debug("No start tag (search from " + batch.charsProcessed + "). skipping '" + response.substring(batch.charsProcessed) + "'");
574    batch.charsProcessed = response.length;
575    return;
576  }
577  // if (firstStartTag > 0) {
578  //   dwr.engine._debug("Start tag not at start (search from " + batch.charsProcessed + "). skipping '" + response.substring(batch.charsProcessed, firstStartTag) + "'");
579  // }
580
581  var lastEndTag = response.lastIndexOf("//#DWR-END#");
582  if (lastEndTag == -1) {
583    // dwr.engine._debug("No end tag. unchanged charsProcessed=" + batch.charsProcessed);
584    return;
585  }
586
587  // Skip the end tag too for next time, remembering CR and LF
588  if (response.charCodeAt(lastEndTag + 11) == 13 && response.charCodeAt(lastEndTag + 12) == 10) {
589    batch.charsProcessed = lastEndTag + 13;
590  }
591  else {
592    batch.charsProcessed = lastEndTag + 11;
593  }
594
595  var exec = response.substring(firstStartTag + 13, lastEndTag);
596
597  dwr.engine._receivedBatch = batch;
598  dwr.engine._eval(exec);
599  dwr.engine._receivedBatch = null;
600};
601
602/** @private Actually send the block of data in the batch object. */
603dwr.engine._sendData = function(batch) {
604  batch.map.batchId = dwr.engine._nextBatchId;
605  dwr.engine._nextBatchId++;
606  dwr.engine._batches[batch.map.batchId] = batch;
607  dwr.engine._batchesLength++;
608  batch.completed = false;
609
610  for (var i = 0; i < batch.preHooks.length; i++) {
611    batch.preHooks[i]();
612  }
613  batch.preHooks = null;
614  // Set a timeout
615  if (batch.timeout && batch.timeout != 0) {
616    batch.timeoutId = setTimeout(function() { dwr.engine._abortRequest(batch); }, batch.timeout);
617  }
618  // Get setup for XMLHttpRequest if possible
619  if (batch.rpcType == dwr.engine.XMLHttpRequest) {
620    if (window.XMLHttpRequest) {
621      batch.req = new XMLHttpRequest();
622    }
623    // IE5 for the mac claims to support window.ActiveXObject, but throws an error when it's used
624    else if (window.ActiveXObject && !(navigator.userAgent.indexOf("Mac") >= 0 && navigator.userAgent.indexOf("MSIE") >= 0)) {
625      batch.req = dwr.engine._newActiveXObject(dwr.engine._XMLHTTP);
626    }
627  }
628
629  var prop, request;
630  if (batch.req) {
631    // Proceed using XMLHttpRequest
632    if (batch.async) {
633      batch.req.onreadystatechange = function() {
634        if (typeof dwr != 'undefined') dwr.engine._stateChange(batch);
635      };
636    }
637    // If we're polling, record this for monitoring
638    if (batch.isPoll) {
639      dwr.engine._pollReq = batch.req;
640      // In IE XHR is an ActiveX control so you can't augment it like this
641      if (!(document.all && !window.opera)) batch.req.batch = batch;
642    }
643    // Workaround for Safari 1.x POST bug
644    var indexSafari = navigator.userAgent.indexOf("Safari/");
645    if (indexSafari >= 0) {
646      var version = navigator.userAgent.substring(indexSafari + 7);
647      if (parseInt(version, 10) < 400) {
648        if (dwr.engine._allowGetForSafariButMakeForgeryEasier == "true") batch.httpMethod = "GET";
649        else dwr.engine._handleWarning(batch, { name:"dwr.engine.oldSafari", message:"Safari GET support disabled. See allowGetForSafariButMakeForgeryEasier." });
650      }
651    }
652    batch.mode = batch.isPoll ? dwr.engine._ModePlainPoll : dwr.engine._ModePlainCall;
653    request = dwr.engine._constructRequest(batch);
654    try {
655      batch.req.open(batch.httpMethod, request.url, batch.async);
656      try {
657        for (prop in batch.headers) {
658          var value = batch.headers[prop];
659          if (typeof value == "string") batch.req.setRequestHeader(prop, value);
660        }
661        //if (!batch.headers["Content-Type"]) batch.req.setRequestHeader("Content-Type", "text/plain");
662        batch.req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
663      }
664      catch (ex) {
665        dwr.engine._handleWarning(batch, ex);
666      }
667      batch.req.send(request.body);
668      if (!batch.async) dwr.engine._stateChange(batch);
669    }
670    catch (ex) {
671      dwr.engine._handleError(batch, ex);
672    }
673  }
674  else if (batch.rpcType != dwr.engine.ScriptTag) {
675    var idname = batch.isPoll ? "dwr-if-poll-" + batch.map.batchId : "dwr-if-" + batch.map.batchId;
676    // Removed htmlfile implementation. Don't expect it to return before v3
677    batch.div = document.createElement("div");
678    // Add the div to the document first, otherwise IE 6 will ignore onload handler.
679    document.body.appendChild(batch.div);
680    batch.div.innerHTML = "<iframe src='javascript:void(0)' frameborder='0' style='width:0px;height:0px;border:0;' id='" + idname + "' name='" + idname + "' onload='dwr.engine._iframeLoadingComplete (" + batch.map.batchId + ");'></iframe>";
681    batch.document = document;
682    batch.iframe = batch.document.getElementById(idname);
683    batch.iframe.batch = batch;
684    batch.mode = batch.isPoll ? dwr.engine._ModeHtmlPoll : dwr.engine._ModeHtmlCall;
685    if (batch.isPoll) dwr.engine._outstandingIFrames.push(batch.iframe);
686    request = dwr.engine._constructRequest(batch);
687    if (batch.httpMethod == "GET") {
688      batch.iframe.setAttribute("src", request.url);
689    }
690    else {
691      batch.form = batch.document.createElement("form");
692      batch.form.setAttribute("id", "dwr-form");
693      batch.form.setAttribute("action", request.url);
694      batch.form.setAttribute("style", "display:none;");
695      batch.form.setAttribute("target", idname);
696      batch.form.target = idname;
697      batch.form.setAttribute("method", batch.httpMethod);
698      for (prop in batch.map) {
699        var value = batch.map[prop];
700        if (typeof value != "function") {
701          var formInput = batch.document.createElement("input");
702          formInput.setAttribute("type", "hidden");
703          formInput.setAttribute("name", prop);
704          formInput.setAttribute("value", value);
705          batch.form.appendChild(formInput);
706        }
707      }
708      batch.document.body.appendChild(batch.form);
709      batch.form.submit();
710    }
711  }
712  else {
713    batch.httpMethod = "GET"; // There's no such thing as ScriptTag using POST
714    batch.mode = batch.isPoll ? dwr.engine._ModePlainPoll : dwr.engine._ModePlainCall;
715    request = dwr.engine._constructRequest(batch);
716    batch.script = document.createElement("script");
717    batch.script.id = "dwr-st-" + batch.map["c0-id"];
718    batch.script.src = request.url;
719    document.body.appendChild(batch.script);
720  }
721};
722
723dwr.engine._ModePlainCall = "/call/plaincall/";
724dwr.engine._ModeHtmlCall = "/call/htmlcall/";
725dwr.engine._ModePlainPoll = "/call/plainpoll/";
726dwr.engine._ModeHtmlPoll = "/call/htmlpoll/";
727
728/** @private Work out what the URL should look like */
729dwr.engine._constructRequest = function(batch) {
730  // A quick string to help people that use web log analysers
731  var request = { url:batch.path + batch.mode, body:null };
732  if (batch.isPoll == true) {
733    request.url += "ReverseAjax.dwr";
734  }
735  else if (batch.map.callCount == 1) {
736    request.url += batch.map["c0-scriptName"] + "." + batch.map["c0-methodName"] + ".dwr";
737  }
738  else {
739    request.url += "Multiple." + batch.map.callCount + ".dwr";
740  }
741  // Play nice with url re-writing
742  var sessionMatch = location.href.match(/jsessionid=([^?]+)/);
743  if (sessionMatch != null) {
744    request.url += ";jsessionid=" + sessionMatch[1];
745  }
746
747  var prop;
748  if (batch.httpMethod == "GET") {
749    // Some browsers (Opera/Safari2) seem to fail to convert the callCount value
750    // to a string in the loop below so we do it manually here.
751    batch.map.callCount = "" + batch.map.callCount;
752    request.url += "?";
753    for (prop in batch.map) {
754      if (typeof batch.map[prop] != "function") {
755        request.url += encodeURIComponent(prop) + "=" + encodeURIComponent(batch.map[prop]) + "&";
756      }
757    }
758    request.url = request.url.substring(0, request.url.length - 1);
759  }
760  else {
761    // PERFORMANCE: for iframe mode this is thrown away.
762    request.body = "";
763    if (document.all && !window.opera) {
764      // Use array joining on IE (fastest)
765      var buf = [];
766      for (prop in batch.map) {
767        if (typeof batch.map[prop] != "function") {
768          buf.push(prop + "=" + encodeURIComponent(batch.map[prop]) + dwr.engine._postSeperator);
769        }
770      }
771      request.body = buf.join("");
772    }
773    else {
774      // Use string concat on other browsers (fastest)
775      for (prop in batch.map) {
776        if (typeof batch.map[prop] != "function") {
777          request.body += prop + "=" + encodeURIComponent(batch.map[prop]) + dwr.engine._postSeperator;
778        }
779      }
780    }
781    request.body = dwr.engine._contentRewriteHandler(request.body);
782  }
783  request.url = dwr.engine._urlRewriteHandler(request.url);
784  return request;
785};
786
787/** @private Called by XMLHttpRequest to indicate that something has happened */
788dwr.engine._stateChange = function(batch) {
789  var toEval;
790
791  if (batch.completed) {
792    dwr.engine._debug("Error: _stateChange() with batch.completed");
793    return;
794  }
795
796  var req = batch.req;
797  try {
798    if (req.readyState != 4) return;
799  }
800  catch (ex) {
801    dwr.engine._handleWarning(batch, ex);
802    // It's broken - clear up and forget this call
803    dwr.engine._clearUp(batch);
804    return;
805  }
806
807  if (dwr.engine._unloading) {
808    dwr.engine._debug("Ignoring reply from server as page is unloading.");
809    return;
810  }
811  
812  try {
813    var reply = req.responseText;
814    reply = dwr.engine._replyRewriteHandler(reply);
815    var status = req.status; // causes Mozilla to except on page moves
816
817    if (reply == null || reply == "") {
818      dwr.engine._handleWarning(batch, { name:"dwr.engine.missingData", message:"No data received from server" });
819    }
820    else if (status != 200) {
821      dwr.engine._handleError(batch, { name:"dwr.engine.http." + status, message:req.statusText });
822    }
823    else {
824      var contentType = req.getResponseHeader("Content-Type");
825      if (!contentType.match(/^text\/plain/) && !contentType.match(/^text\/javascript/)) {
826        if (contentType.match(/^text\/html/) && typeof batch.textHtmlHandler == "function") {
827          batch.textHtmlHandler({ status:status, responseText:reply, contentType:contentType });
828        }
829        else {
830          dwr.engine._handleWarning(batch, { name:"dwr.engine.invalidMimeType", message:"Invalid content type: '" + contentType + "'" });
831        }
832      }
833      else {
834        // Comet replies might have already partially executed
835        if (batch.isPoll && batch.map.partialResponse == dwr.engine._partialResponseYes) {
836          dwr.engine._processCometResponse(reply, batch);
837        }
838        else {
839          if (reply.search("//#DWR") == -1) {
840            dwr.engine._handleWarning(batch, { name:"dwr.engine.invalidReply", message:"Invalid reply from server" });
841          }
842          else {
843            toEval = reply;
844          }
845        }
846      }
847    }
848  }
849  catch (ex) {
850    dwr.engine._handleWarning(batch, ex);
851  }
852
853  dwr.engine._callPostHooks(batch);
854
855  // Outside of the try/catch so errors propogate normally:
856  dwr.engine._receivedBatch = batch;
857  if (toEval != null) toEval = toEval.replace(dwr.engine._scriptTagProtection, "");
858  dwr.engine._eval(toEval);
859  dwr.engine._receivedBatch = null;
860  dwr.engine._validateBatch(batch);
861  if (!batch.completed) dwr.engine._clearUp(batch);
862};
863
864/**
865 * @private This function is invoked when a batch reply is received.
866 * It checks that there is a response for every call in the batch. Otherwise,
867 * an error will be signaled (a call without a response indicates that the 
868 * server failed to send complete batch response). 
869 */
870dwr.engine._validateBatch = function(batch) {
871  // If some call left unreplied, report an error.
872  if (!batch.completed) {
873    for (var i = 0; i < batch.map.callCount; i++) {
874      if (batch.handlers[i] != null) {
875        dwr.engine._handleWarning(batch, { name:"dwr.engine.incompleteReply", message:"Incomplete reply from server" });
876        break;
877      }
878    }
879  }
880}
881
882/** @private Called from iframe onload, check batch using batch-id */
883dwr.engine._iframeLoadingComplete = function(batchId) {
884  // dwr.engine._checkCometPoll();
885  var batch = dwr.engine._batches[batchId];
886  if (batch) dwr.engine._validateBatch(batch);
887}
888
889/** @private Called by the server: Execute a callback */
890dwr.engine._remoteHandleCallback = function(batchId, callId, reply) {
891  var batch = dwr.engine._batches[batchId];
892  if (batch == null) {
893    dwr.engine._debug("Warning: batch == null in remoteHandleCallback for batchId=" + batchId, true);
894    return;
895  }
896  // Error handlers inside here indicate an error that is nothing to do
897  // with DWR so we handle them differently.
898  try {
899    var handlers = batch.handlers[callId];
900    batch.handlers[callId] = null;
901    if (!handlers) {
902      dwr.engine._debug("Warning: Missing handlers. callId=" + callId, true);
903    }
904    else if (typeof handlers.callback == "function") handlers.callback(reply);
905  }
906  catch (ex) {
907    dwr.engine._handleError(batch, ex);
908  }
909};
910
911/** @private Called by the server: Handle an exception for a call */
912dwr.engine._remoteHandleException = function(batchId, callId, ex) {
913  var batch = dwr.engine._batches[batchId];
914  if (batch == null) { dwr.engine._debug("Warning: null batch in remoteHandleException", true); return; }
915  var handlers = batch.handlers[callId];
916  batch.handlers[callId] = null;
917  if (handlers == null) { dwr.engine._debug("Warning: null handlers in remoteHandleException", true); return; }
918  if (ex.message == undefined) ex.message = "";
919  if (typeof handlers.exceptionHandler == "function") handlers.exceptionHandler(ex.message, ex);
920  else if (typeof batch.errorHandler == "function") batch.errorHandler(ex.message, ex);
921};
922
923/** @private Called by the server: The whole batch is broken */
924dwr.engine._remoteHandleBatchException = function(ex, batchId) {
925  var searchBatch = (dwr.engine._receivedBatch == null && batchId != null);
926  if (searchBatch) {
927    dwr.engine._receivedBatch = dwr.engine._batches[batchId];
928  }
929  if (ex.message == undefined) ex.message = "";
930  dwr.engine._handleError(dwr.engine._receivedBatch, ex);
931  if (searchBatch) {
932    dwr.engine._receivedBatch = null;
933    dwr.engine._clearUp(dwr.engine._batches[batchId]);
934  }
935};
936
937/** @private Called by the server: Reverse ajax should not be used */
938dwr.engine._remotePollCometDisabled = function(ex, batchId) {
939  dwr.engine.setActiveReverseAjax(false);
940  var searchBatch = (dwr.engine._receivedBatch == null && batchId != null);
941  if (searchBatch) {
942    dwr.engine._receivedBatch = dwr.engine._batches[batchId];
943  }
944  if (ex.message == undefined) ex.message = "";
945  dwr.engine._handleError(dwr.engine._receivedBatch, ex);
946  if (searchBatch) {
947    dwr.engine._receivedBatch = null;
948    dwr.engine._clearUp(dwr.engine._batches[batchId]);
949  }
950};
951
952/** @private Called by the server: An IFrame reply is about to start */
953dwr.engine._remoteBeginIFrameResponse = function(iframe, batchId) {
954  if (iframe != null) dwr.engine._receivedBatch = iframe.batch;
955  dwr.engine._callPostHooks(dwr.engine._receivedBatch);
956};
957
958/** @private Called by the server: An IFrame reply is just completing */
959dwr.engine._remoteEndIFrameResponse = function(batchId) {
960  dwr.engine._clearUp(dwr.engine._receivedBatch);
961  dwr.engine._receivedBatch = null;
962};
963
964/** @private This is a hack to make the context be this window */
965dwr.engine._eval = function(script) {
966  if (script == null) return null;
967  if (script == "") { dwr.engine._debug("Warning: blank script", true); return null; }
968  // dwr.engine._debug("Exec: [" + script + "]", true);
969  return eval(script);
970};
971
972/** @private Called as a result of a request timeout */
973dwr.engine._abortRequest = function(batch) {
974  if (batch && !batch.completed) {
975    dwr.engine._clearUp(batch);
976    if (batch.req) batch.req.abort();
977    dwr.engine._handleError(batch, { name:"dwr.engine.timeout", message:"Timeout" });
978  }
979};
980
981/** @private call all the post hooks for a batch */
982dwr.engine._callPostHooks = function(batch) {
983  if (batch.postHooks) {
984    for (var i = 0; i < batch.postHooks.length; i++) {
985      batch.postHooks[i]();
986    }
987    batch.postHooks = null;
988  }
989};
990
991/** @private A call has finished by whatever means and we need to shut it all down. */
992dwr.engine._clearUp = function(batch) {
993  if (!batch) { dwr.engine._debug("Warning: null batch in dwr.engine._clearUp()", true); return; }
994  if (batch.completed) { dwr.engine._debug("Warning: Double complete", true); return; }
995
996  // IFrame tidyup
997  if (batch.div) batch.div.parentNode.removeChild(batch.div);
998  if (batch.iframe) {
999    // If this is a poll frame then stop comet polling
1000    for (var i = 0; i < dwr.engine._outstandingIFrames.length; i++) {
1001      if (dwr.engine._outstandingIFrames[i] == batch.iframe) {
1002        dwr.engine._outstandingIFrames.splice(i, 1);
1003      }
1004    }
1005    batch.iframe.parentNode.removeChild(batch.iframe);
1006  }
1007  if (batch.form) batch.form.parentNode.removeChild(batch.form);
1008
1009  // XHR tidyup: avoid IE handles increase
1010  if (batch.req) {
1011    // If this is a poll frame then stop comet polling
1012    if (batch.req == dwr.engine._pollReq) dwr.engine._pollReq = null;
1013    delete batch.req;
1014  }
1015
1016  // Timeout tidyup
1017  if (batch.timeoutId != null) {
1018    clearTimeout(batch.timeoutId);
1019    delete batch.timeoutId;
1020  }
1021
1022  if (batch.map && (batch.map.batchId || batch.map.batchId == 0)
1022) {
1023    delete dwr.engine._batches[batch.map.batchId];
1024    dwr.engine._batchesLength--;
1025  }
1026
1027  batch.completed = true;
1028
1029  // If there is anything on the queue waiting to go out, then send it.
1030  // We don't need to check for ordered mode, here because when ordered mode
1031  // gets turned off, we still process *waiting* batches in an ordered way.
1032  if (dwr.engine._batchQueue.length != 0) {
1033    var sendbatch = dwr.engine._batchQueue.shift();
1034    dwr.engine._sendData(sendbatch);
1035  }
1036};
1037
1038/** @private Abort any XHRs in progress at page unload (solves zombie socket problems in IE). */
1039dwr.engine._unloader = function() {
1040  dwr.engine._unloading = true;
1041
1042  // Empty queue of waiting ordered requests
1043  dwr.engine._batchQueue.length = 0;
1044
1045  // Abort any ongoing XHRs and clear their batches
1046  for (var batchId in dwr.engine._batches) {
1047    var batch = dwr.engine._batches[batchId];
1048    // Only process objects that look like batches (avoid prototype additions!)
1049    if (batch && batch.map) {
1050      if (batch.req) {
1051        batch.req.abort();
1052      }
1053      dwr.engine._clearUp(batch);
1054    }
1055  }
1056};
1057// Now register the unload handler
1058if (window.addEventListener) window.addEventListener('unload', dwr.engine._unloader, false);
1059else if (window.attachEvent) window.attachEvent('onunload', dwr.engine._unloader);
1060
1061/** @private Generic error handling routing to save having null checks everywhere */
1062dwr.engine._handleError = function(batch, ex) {
1063  if (typeof ex == "string") ex = { name:"unknown", message:ex };
1064  if (ex.message == null) ex.message = "";
1065  if (ex.name == null) ex.name = "unknown";
1066  if (batch && typeof batch.errorHandler == "function") batch.errorHandler(ex.message, ex);
1067  else if (dwr.engine._errorHandler) dwr.engine._errorHandler(ex.message, ex);
1068  if (batch) dwr.engine._clearUp(batch);
1069};
1070
1071/** @private Generic error handling routing to save having null checks everywhere */
1072dwr.engine._handleWarning = function(batch, ex) {
1073  if (typeof ex == "string") ex = { name:"unknown", message:ex };
1074  if (ex.message == null) ex.message = "";
1075  if (ex.name == null) ex.name = "unknown";
1076  if (batch && typeof batch.warningHandler == "function") batch.warningHandler(ex.message, ex);
1077  else if (dwr.engine._warningHandler) dwr.engine._warningHandler(ex.message, ex);
1078  if (batch) dwr.engine._clearUp(batch);
1079};
1080
1081/**
1082 * @private Marshall a data item
1083 * @param batch A map of variables to how they have been marshalled
1084 * @param referto An array of already marshalled variables to prevent recurrsion
1085 * @param data The data to be marshalled
1086 * @param name The name of the data being marshalled
1087 */
1088dwr.engine._serializeAll = function(batch, referto, data, name) {
1089  if (data == null) {
1090    batch.map[name] = "null:null";
1091    return;
1092  }
1093
1094  switch (typeof data) {
1095  case "boolean":
1096    batch.map[name] = "boolean:" + data;
1097    break;
1098  case "number":
1099    batch.map[name] = "number:" + data;
1100    break;
1101  case "string":
1102    batch.map[name] = "string:" + encodeURIComponent(data);
1103    break;
1104  case "object":
1105    var objstr = Object.prototype.toString.call(data);
1106    if (objstr == "[object String]") batch.map[name] = "String:" + encodeURIComponent(data);
1107    else if (objstr == "[object Boolean]") batch.map[name] = "Boolean:" + data;
1108    else if (objstr == "[object Number]") batch.map[name] = "Number:" + data;
1109    else if (objstr == "[object Date]") batch.map[name] = "Date:" + data.getTime();
1110    else if (objstr == "[object Array]") batch.map[name] = dwr.engine._serializeArray(batch, referto, data, name);
1111    else batch.map[name] = dwr.engine._serializeObject(batch, referto, data, name);
1112    break;
1113  case "function":
1114    // We just ignore functions.
1115    break;
1116  default:
1117    dwr.engine._handleWarning(null, { name:"dwr.engine.unexpectedType", message:"Unexpected type: " + typeof data + ", attempting default converter." });
1118    batch.map[name] = "default:" + data;
1119    break;
1120  }
1121};
1122
1123/** @private Have we already converted this object? */
1124dwr.engine._lookup = function(referto, data, name) {
1125  var lookup;
1126  // Can't use a map: 
1127  for (var i = 0; i < referto.length; i++) {
1128    if (referto[i].data == data) {
1129      lookup = referto[i];
1130      break;
1131    }
1132  }
1133  if (lookup) return "reference:" + lookup.name;
1134  referto.push({ data:data, name:name });
1135  return null;
1136};
1137
1138/** @private Marshall an object */
1139dwr.engine._serializeObject = function(batch, referto, data, name) {
1140  var ref = dwr.engine._lookup(referto, data, name);
1141  if (ref) return ref;
1142
1143  // This check for an HTML is not complete, but is there a better way?
1144  // Maybe we should add: data.hasChildNodes typeof "function" == true
1145  if (data.nodeName && data.nodeType) {
1146    return dwr.engine._serializeXml(batch, referto, data, name);
1147  }
1148
1149  // treat objects as an associative arrays
1150  var reply = "Object_" + dwr.engine._getObjectClassName(data) + ":{";
1151  var element;
1152  for (element in data) {
1153    if (typeof data[element] != "function") {
1154      batch.paramCount++;
1155      var childName = "c" + dwr.engine._batch.map.callCount + "-e" + batch.paramCount;
1156      dwr.engine._serializeAll(batch, referto, data[element], childName);
1157
1158      reply += encodeURIComponent(element) + ":reference:" + childName + ", ";
1159    }
1160  }
1161
1162  if (reply.substring(reply.length - 2) == ", ") {
1163    reply = reply.substring(0, reply.length - 2);
1164  }
1165  reply += "}";
1166
1167  return reply;
1168};
1169
1170/** @private Returns the classname of supplied argument obj */
1171dwr.engine._errorClasses = { "Error":Error, "EvalError":EvalError, "RangeError":RangeError, "ReferenceError":ReferenceError, "SyntaxError":SyntaxError, "TypeError":TypeError, "URIError":URIError };
1172dwr.engine._getObjectClassName = function(obj) {
1173  // Try to find the classname by stringifying the object's constructor
1174  // and extract <class> from "function <class>".
1175  if (obj && obj.constructor && obj.constructor.toString)
1176  {
1177    var str = obj.constructor.toString();
1178    var regexpmatch = str.match(/function\s+(\w+)/);
1179    if (regexpmatch && regexpmatch.length == 2) {
1180      return regexpmatch[1];
1181    }
1182  }
1183
1184  // Now manually test against the core Error classes, as these in some 
1185  // browsers successfully match to the wrong class in the 
1186  // Object.toString() test we will do later
1187  if (obj && obj.constructor) {
1188    for (var errorname in dwr.engine._errorClasses) {
1189      if (obj.constructor == dwr.engine._errorClasses[errorname]) return errorname;
1190    }
1191  }
1192
1193  // Try to find the classname by calling Object.toString() on the object
1194  // and extracting <class> from "[object <class>]"
1195  if (obj) {
1196    var str = Object.prototype.toString.call(obj);
1197    var regexpmatch = str.match(/\[object\s+(\w+)/);
1198    if (regexpmatch && regexpmatch.length==2) {
1199      return regexpmatch[1];
1200    }
1201  }
1202
1203  // Supplied argument was probably not an object, but what is better?
1204  return "Object";
1205};
1206
1207/** @private Marshall an object */
1208dwr.engine._serializeXml = function(batch, referto, data, name) {
1209  var ref = dwr.engine._lookup(referto, data, name);
1210  if (ref) return ref;
1211
1212  var output;
1213  if (window.XMLSerializer) output = new XMLSerializer().serializeToString(data);
1214  else if (data.toXml) output = data.toXml;
1215  else output = data.innerHTML;
1216
1217  return "XML:" + encodeURIComponent(output);
1218};
1219
1220/** @private Marshall an array */
1221dwr.engine._serializeArray = function(batch, referto, data, name) {
1222  var ref = dwr.engine._lookup(referto, data, name);
1223  if (ref) return ref;
1224
1225  if (document.all && !window.opera) {
1226    // Use array joining on IE (fastest)
1227    var buf = ["Array:["];
1228    for (var i = 0; i < data.length; i++) {
1229      if (i != 0) buf.push(",");
1230      batch.paramCount++;
1231      var childName = "c" + dwr.engine._batch.map.callCount + "-e" + batch.paramCount;
1232      dwr.engine._serializeAll(batch, referto, data[i], childName);
1233      buf.push("reference:");
1234      buf.push(childName);
1235    }
1236    buf.push("]");
1237    reply = buf.join("");
1238  }
1239  else {
1240    // Use string concat on other browsers (fastest)
1241    var reply = "Array:[";
1242    for (var i = 0; i < data.length; i++) {
1243      if (i != 0) reply += ",";
1244      batch.paramCount++;
1245      var childName = "c" + dwr.engine._batch.map.callCount + "-e" + batch.paramCount;
1246      dwr.engine._serializeAll(batch, referto, data[i], childName);
1247      reply += "reference:";
1248      reply += childName;
1249    }
1250    reply += "]";
1251  }
1252
1253  return reply;
1254};
1255
1256/** @private Convert an XML string into a DOM object. */
1257dwr.engine._unserializeDocument = function(xml) {
1258  var dom;
1259  if (window.DOMParser) {
1260    var parser = new DOMParser();
1261    dom = parser.parseFromString(xml, "text/xml");
1262    if (!dom.documentElement || dom.documentElement.tagName == "parsererror") {
1263      var message = dom.documentElement.firstChild.data;
1264      message += "\n" + dom.documentElement.firstChild.nextSibling.firstChild.data;
1265      throw message;
1266    }
1267    return dom;
1268  }
1269  else if (window.ActiveXObject) {
1270    dom = dwr.engine._newActiveXObject(dwr.engine._DOMDocument);
1271    dom.loadXML(xml); // What happens on parse fail with IE?
1272    return dom;
1273  }
1274  else {
1275    var div = document.createElement("div");
1276    div.innerHTML = xml;
1277    return div;
1278  }
1279};
1280
1281/** @param axarray An array of strings to attempt to create ActiveX objects from */
1282dwr.engine._newActiveXObject = function(axarray) {
1283  var returnValue;  
1284  for (var i = 0; i < axarray.length; i++) {
1285    try {
1286      returnValue = new ActiveXObject(axarray[i]);
1287      break;
1288    }
1289    catch (ex) { /* ignore */ }
1290  }
1291  return returnValue;
1292};
1293
1294/** @private Used internally when some message needs to get to the programmer */
1295dwr.engine._debug = function(message, stacktrace) {
1296  var written = false;
1297  try {
1298    if (window.console) {
1299      if (stacktrace && window.console.trace) window.console.trace();
1300      window.console.log(message);
1301      written = true;
1302    }
1303    else if (window.opera && window.opera.postError) {
1304      window.opera.postError(message);
1305      written = true;
1306    }
1307  }
1308  catch (ex) { /* ignore */ }
1309
1310  if (!written) {
1311    var debug = document.getElementById("dwr-debug");
1312    if (debug) {
1313      var contents = message + "<br/>" + debug.innerHTML;
1314      if (contents.length > 2048) contents = contents.substring(0, 2048);
1315      debug.innerHTML = contents;
1316    }
1317  }
1318};
1319

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.