PageSourceSearch

https://polosbn.bnnonline.it/SebinaOpac/sebinayou/js/libs/1.0.engine_DM.js

js bnnonline.it collected 2026-10-02 04:54:16 UTC 47,544 bytes, 1,338 lines download raw bytes

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

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.