function WysiwygConverter() { } WysiwygConverter._path = '/confluence/oss/dwr'; WysiwygConverter.hashCode = function(callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'hashCode', callback); } WysiwygConverter.indexOf = function(p0, callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'indexOf', p0, callback); } WysiwygConverter.equals = function(p0, callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'equals', p0, callback); } WysiwygConverter.toString = function(callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'toString', callback); } WysiwygConverter.addAdvisor = function(p0, callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'addAdvisor', p0, callback); } WysiwygConverter.addAdvisor = function(p0, p1, callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'addAdvisor', p0, p1, callback); } WysiwygConverter.setTargetSource = function(p0, callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'setTargetSource', p0, callback); } WysiwygConverter.isProxyTargetClass = function(callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'isProxyTargetClass', callback); } WysiwygConverter.getProxyTargetClass = function(callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'getProxyTargetClass', callback); } WysiwygConverter.setExposeProxy = function(p0, callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'setExposeProxy', p0, callback); } WysiwygConverter.isExposeProxy = function(callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'isExposeProxy', callback); } WysiwygConverter.getExposeProxy = function(callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'getExposeProxy', callback); } WysiwygConverter.isFrozen = function(callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'isFrozen', callback); } WysiwygConverter.convertXHtmlToWikiMarkup = function(p0, p1, callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'convertXHtmlToWikiMarkup', p0, p1, callback); } WysiwygConverter.convertWikiMarkupToXHtml = function(p0, p1, callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'convertWikiMarkupToXHtml', p0, p1, callback); } WysiwygConverter.convertXHtmlToWikiMarkupWithoutPage = function(p0, p1, callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'convertXHtmlToWikiMarkupWithoutPage', p0, p1, callback); } WysiwygConverter.convertWikiMarkupToXHtmlWithoutPage = function(p0, p1, callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'convertWikiMarkupToXHtmlWithoutPage', p0, p1, callback); } WysiwygConverter.convertToPreview = function(p0, p1, p2, p3, callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'convertToPreview', p0, p1, p2, p3, callback); } WysiwygConverter.getUserWysiwygPreference = function(callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'getUserWysiwygPreference', callback); } WysiwygConverter.getTargetSource = function(callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'getTargetSource', callback); } WysiwygConverter.getProxiedInterfaces = function(callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'getProxiedInterfaces', callback); } WysiwygConverter.addAdvice = function(p0, p1, callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'addAdvice', p0, p1, callback); } WysiwygConverter.addAdvice = function(p0, callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'addAdvice', p0, callback); } WysiwygConverter.addInterceptor = function(p0, callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'addInterceptor', p0, callback); } WysiwygConverter.addInterceptor = function(p0, p1, callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'addInterceptor', p0, p1, callback); } WysiwygConverter.isInterfaceProxied = function(p0, callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'isInterfaceProxied', p0, callback); } WysiwygConverter.removeAdvice = function(p0, callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'removeAdvice', p0, callback); } WysiwygConverter.addAfterReturningAdvice = function(p0, callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'addAfterReturningAdvice', p0, callback); } WysiwygConverter.addBeforeAdvice = function(p0, callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'addBeforeAdvice', p0, callback); } WysiwygConverter.addThrowsAdvice = function(p0, callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'addThrowsAdvice', p0, callback); } WysiwygConverter.removeAdvisor = function(p0, callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'removeAdvisor', p0, callback); } WysiwygConverter.removeAdvisor = function(p0, callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'removeAdvisor', p0, callback); } WysiwygConverter.getAdvisors = function(callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'getAdvisors', callback); } WysiwygConverter.replaceAdvisor = function(p0, p1, callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'replaceAdvisor', p0, p1, callback); } WysiwygConverter.toProxyConfigString = function(callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'toProxyConfigString', callback); } WysiwygConverter.isProxyClass = function(p0, callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'isProxyClass', p0, callback); } WysiwygConverter.getProxyClass = function(p0, p1, callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'getProxyClass', p0, p1, callback); } WysiwygConverter.getInvocationHandler = function(p0, callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'getInvocationHandler', p0, callback); } WysiwygConverter.newProxyInstance = function(p0, p1, p2, callback) { DWREngine._execute(WysiwygConverter._path, 'WysiwygConverter', 'newProxyInstance', p0, p1, p2, callback); } function AjaxUserProfileEditor() { } AjaxUserProfileEditor._path = '/confluence/oss/dwr'; AjaxUserProfileEditor.getUserAccessor = function(callback) { DWREngine._execute(AjaxUserProfileEditor._path, 'AjaxUserProfileEditor', 'getUserAccessor', callback); } AjaxUserProfileEditor.setUserAccessor = function(p0, callback) { DWREngine._execute(AjaxUserProfileEditor._path, 'AjaxUserProfileEditor', 'setUserAccessor', p0, callback); } AjaxUserProfileEditor.setConfluenceWysiwygConverter = function(p0, callback) { DWREngine._execute(AjaxUserProfileEditor._path, 'AjaxUserProfileEditor', 'setConfluenceWysiwygConverter', p0, callback); } AjaxUserProfileEditor.setPreferenceUserEditWysiwyg = function(p0, callback) { DWREngine._execute(AjaxUserProfileEditor._path, 'AjaxUserProfileEditor', 'setPreferenceUserEditWysiwyg', p0, callback); } AjaxUserProfileEditor.getPreferenceUserEditWysiwyg = function(callback) { DWREngine._execute(AjaxUserProfileEditor._path, 'AjaxUserProfileEditor', 'getPreferenceUserEditWysiwyg', callback); } function DraftAjax() { } DraftAjax._path = '/confluence/oss/dwr'; DraftAjax.setDraftManager = function(p0, callback) { DWREngine._execute(DraftAjax._path, 'DraftAjax', 'setDraftManager', p0, callback); } DraftAjax.getDraftSaveInterval = function(callback) { DWREngine._execute(DraftAjax._path, 'DraftAjax', 'getDraftSaveInterval', callback); } DraftAjax.setConfluenceWysiwygConverter = function(p0, callback) { DWREngine._execute(DraftAjax._path, 'DraftAjax', 'setConfluenceWysiwygConverter', p0, callback); } DraftAjax.saveDraft = function(p0, p1, callback) { DWREngine._execute(DraftAjax._path, 'DraftAjax', 'saveDraft', p0, p1, callback); } DraftAjax.findDraft = function(p0, p1, callback) { DWREngine._execute(DraftAjax._path, 'DraftAjax', 'findDraft', p0, p1, callback); } function HeartbeatAjax() { } HeartbeatAjax._path = '/confluence/oss/dwr'; HeartbeatAjax.setDraftManager = function(p0, callback) { DWREngine._execute(HeartbeatAjax._path, 'HeartbeatAjax', 'setDraftManager', p0, callback); } HeartbeatAjax.getHeartbeatInterval = function(callback) { DWREngine._execute(HeartbeatAjax._path, 'HeartbeatAjax', 'getHeartbeatInterval', callback); } HeartbeatAjax.startActivity = function(p0, p1, callback) { DWREngine._execute(HeartbeatAjax._path, 'HeartbeatAjax', 'startActivity', p0, p1, callback); } HeartbeatAjax.stopActivity = function(p0, p1, callback) { DWREngine._execute(HeartbeatAjax._path, 'HeartbeatAjax', 'stopActivity', p0, p1, callback); } HeartbeatAjax.setHeartbeatManager = function(p0, callback) { DWREngine._execute(HeartbeatAjax._path, 'HeartbeatAjax', 'setHeartbeatManager', p0, callback); } if (DWREngine == null) var DWREngine = {}; DWREngine.setErrorHandler = function(handler) { DWREngine._errorHandler = handler; }; DWREngine.setWarningHandler = function(handler) { DWREngine._warningHandler = handler; }; DWREngine.setTimeout = function(timeout) { DWREngine._timeout = timeout; }; DWREngine.setPreHook = function(handler) { DWREngine._preHook = handler; }; DWREngine.setPostHook = function(handler) { DWREngine._postHook = handler; }; DWREngine.XMLHttpRequest = 1; DWREngine.IFrame = 2; DWREngine.setMethod = function(newMethod) { if (newMethod != DWREngine.XMLHttpRequest && newMethod != DWREngine.IFrame) { DWREngine._handleError("Remoting method must be one of DWREngine.XMLHttpRequest or DWREngine.IFrame"); return; } DWREngine._method = newMethod; }; DWREngine.setVerb = function(verb) { if (verb != "GET" && verb != "POST") { DWREngine._handleError("Remoting verb must be one of GET or POST"); return; } DWREngine._verb = verb; }; DWREngine.setOrdered = function(ordered) { DWREngine._ordered = ordered; }; DWREngine.setAsync = function(async) { DWREngine._async = async; }; DWREngine.setTextHtmlHandler = function(handler) { DWREngine._textHtmlHandler = handler; } DWREngine.defaultMessageHandler = function(message) { if (typeof message == "object" && message.name == "Error" && message.description) { alert("Error: " + message.description); } else { if (message.toString().indexOf("0x80040111") == -1) { alert(message); } } }; DWREngine.beginBatch = function() { if (DWREngine._batch) { DWREngine._handleError("Batch already started."); return; } DWREngine._batch = { map:{ callCount:0 }, paramCount:0, ids:[], preHooks:[], postHooks:[] }; }; DWREngine.endBatch = function(options) { var batch = DWREngine._batch; if (batch == null) { DWREngine._handleError("No batch in progress."); return; } if (options && options.preHook) batch.preHooks.unshift(options.preHook); if (options && options.postHook) batch.postHooks.push(options.postHook); if (DWREngine._preHook) batch.preHooks.unshift(DWREngine._preHook); if (DWREngine._postHook) batch.postHooks.push(DWREngine._postHook); if (batch.method == null) batch.method = DWREngine._method; if (batch.verb == null) batch.verb = DWREngine._verb; if (batch.async == null) batch.async = DWREngine._async; if (batch.timeout == null) batch.timeout = DWREngine._timeout; batch.completed = false; DWREngine._batch = null; if (!DWREngine._ordered) { DWREngine._sendData(batch); DWREngine._batches[DWREngine._batches.length] = batch; } else { if (DWREngine._batches.length == 0) { DWREngine._sendData(batch); DWREngine._batches[DWREngine._batches.length] = batch; } else { DWREngine._batchQueue[DWREngine._batchQueue.length] = batch; } } }; DWREngine._errorHandler = DWREngine.defaultMessageHandler; DWREngine._warningHandler = null; DWREngine._preHook = null; DWREngine._postHook = null; DWREngine._batches = []; DWREngine._batchQueue = []; DWREngine._handlersMap = {}; DWREngine._method = DWREngine.XMLHttpRequest; DWREngine._verb = "POST"; DWREngine._ordered = false; DWREngine._async = true; DWREngine._batch = null; DWREngine._timeout = 0; DWREngine._DOMDocument = ["Msxml2.DOMDocument.6.0", "Msxml2.DOMDocument.5.0", "Msxml2.DOMDocument.4.0", "Msxml2.DOMDocument.3.0", "MSXML2.DOMDocument", "MSXML.DOMDocument", "Microsoft.XMLDOM"]; DWREngine._XMLHTTP = ["Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"]; DWREngine._execute = function(path, scriptName, methodName, vararg_params) { var singleShot = false; if (DWREngine._batch == null) { DWREngine.beginBatch(); singleShot = true; } var args = []; for (var i = 0; i < arguments.length - 3; i++) { args[i] = arguments[i + 3]; } if (DWREngine._batch.path == null) { DWREngine._batch.path = path; } else { if (DWREngine._batch.path != path) { DWREngine._handleError("Can't batch requests to multiple DWR Servlets."); return; } } var params; var callData; var firstArg = args[0]; var lastArg = args[args.length - 1]; if (typeof firstArg == "function") { callData = { callback:args.shift() }; params = args; } else if (typeof lastArg == "function") { callData = { callback:args.pop() }; params = args; } else if (lastArg != null && typeof lastArg == "object" && lastArg.callback != null && typeof lastArg.callback == "function") { callData = args.pop(); params = args; } else if (firstArg == null) { if (lastArg == null && args.length > 2) { DWREngine._handleError("Ambiguous nulls at start and end of parameter list. Which is the callback function?"); } callData = { callback:args.shift() }; params = args; } else if (lastArg == null) { callData = { callback:args.pop() }; params = args; } else { DWREngine._handleError("Missing callback function or metadata object."); return; } var random = Math.floor(Math.random() * 10001); var id = (random + "_" + new Date().getTime()).toString(); var prefix = "c" + DWREngine._batch.map.callCount + "-"; DWREngine._batch.ids.push(id); if (callData.method != null) { DWREngine._batch.method = callData.method; delete callData.method; } if (callData.verb != null) { DWREngine._batch.verb = callData.verb; delete callData.verb; } if (callData.async != null) { DWREngine._batch.async = callData.async; delete callData.async; } if (callData.timeout != null) { DWREngine._batch.timeout = callData.timeout; delete callData.timeout; } if (callData.preHook != null) { DWREngine._batch.preHooks.unshift(callData.preHook); delete callData.preHook; } if (callData.postHook != null) { DWREngine._batch.postHooks.push(callData.postHook); delete callData.postHook; } if (callData.errorHandler == null) callData.errorHandler = DWREngine._errorHandler; if (callData.warningHandler == null) callData.warningHandler = DWREngine._warningHandler; DWREngine._handlersMap[id] = callData; DWREngine._batch.map[prefix + "scriptName"] = scriptName; DWREngine._batch.map[prefix + "methodName"] = methodName; DWREngine._batch.map[prefix + "id"] = id; for (i = 0; i < params.length; i++) { DWREngine._serializeAll(DWREngine._batch, [], params[i], prefix + "param" + i); } DWREngine._batch.map.callCount++; if (singleShot) { DWREngine.endBatch(); } }; DWREngine._sendData = function(batch) { if (batch.map.callCount == 0) return; for (var i = 0; i < batch.preHooks.length; i++) { batch.preHooks[i](); } batch.preHooks = null; if (batch.timeout && batch.timeout != 0) { batch.interval = setInterval(function() { DWREngine._abortRequest(batch); }, batch.timeout); } var urlPostfix; if (batch.map.callCount == 1) { urlPostfix = batch.map["c0-scriptName"] + "." + batch.map["c0-methodName"] + ".dwr"; } else { urlPostfix = "Multiple." + batch.map.callCount + ".dwr"; } if (batch.method == DWREngine.XMLHttpRequest) { if (window.XMLHttpRequest) { batch.req = new XMLHttpRequest(); } else if (window.ActiveXObject && !(navigator.userAgent.indexOf("Mac") >= 0 && navigator.userAgent.indexOf("MSIE") >= 0)) { batch.req = DWREngine._newActiveXObject(DWREngine._XMLHTTP); } } var query = ""; var prop; if (batch.req) { batch.map.xml = "true"; if (batch.async) { batch.req.onreadystatechange = function() { DWREngine._stateChange(batch); }; } var indexSafari = navigator.userAgent.indexOf("Safari/"); if (indexSafari >= 0) { var version = navigator.userAgent.substring(indexSafari + 7); if (parseInt(version, 10) < 400) batch.verb == "GET"; } if (batch.verb == "GET") { batch.map.callCount = "" + batch.map.callCount; for (prop in batch.map) { var qkey = encodeURIComponent(prop); var qval = encodeURIComponent(batch.map[prop]); if (qval == "") DWREngine._handleError("Found empty qval for qkey=" + qkey); query += qkey + "=" + qval + "&"; } try { batch.req.open("GET", batch.path + "/exec/" + urlPostfix + "?" + query, batch.async); batch.req.send(null); if (!batch.async) DWREngine._stateChange(batch); } catch (ex) { DWREngine._handleMetaDataError(null, ex); } } else { for (prop in batch.map) { if (typeof batch.map[prop] != "function") { query += prop + "=" + batch.map[prop] + "\n"; } } try { batch.req.open("POST", batch.path + "/exec/" + urlPostfix, batch.async); batch.req.setRequestHeader('Content-Type', 'text/plain'); batch.req.send(query); if (!batch.async) DWREngine._stateChange(batch); } catch (ex) { DWREngine._handleMetaDataError(null, ex); } } } else { batch.map.xml = "false"; var idname = "dwr-if-" + batch.map["c0-id"]; batch.div = document.createElement("div"); batch.div.innerHTML = ""; document.body.appendChild(batch.div); batch.iframe = document.getElementById(idname); batch.iframe.setAttribute("style", "width:0px; height:0px; border:0px;"); if (batch.verb == "GET") { for (prop in batch.map) { if (typeof batch.map[prop] != "function") { query += encodeURIComponent(prop) + "=" + encodeURIComponent(batch.map[prop]) + "&"; } } query = query.substring(0, query.length - 1); batch.iframe.setAttribute("src", batch.path + "/exec/" + urlPostfix + "?" + query); document.body.appendChild(batch.iframe); } else { batch.form = document.createElement("form"); batch.form.setAttribute("id", "dwr-form"); batch.form.setAttribute("action", batch.path + "/exec" + urlPostfix); batch.form.setAttribute("target", idname); batch.form.target = idname; batch.form.setAttribute("method", "POST"); for (prop in batch.map) { var formInput = document.createElement("input"); formInput.setAttribute("type", "hidden"); formInput.setAttribute("name", prop); formInput.setAttribute("value", batch.map[prop]); batch.form.appendChild(formInput); } document.body.appendChild(batch.form); batch.form.submit(); } } }; DWREngine._stateChange = function(batch) { if (!batch.completed && batch.req.readyState == 4) { try { var reply = batch.req.responseText; if (reply == null || reply == "") { DWREngine._handleMetaDataWarning(null, "No data received from server"); } else { var contentType = batch.req.getResponseHeader("Content-Type"); if (!contentType.match(/^text\/plain/) && !contentType.match(/^text\/javascript/)) { if (DWREngine._textHtmlHandler && contentType.match(/^text\/html/)) { DWREngine._textHtmlHandler(); } else { DWREngine._handleMetaDataWarning(null, "Invalid content type from server: '" + contentType + "'"); } } else { if (reply.search("DWREngine._handle") == -1) { DWREngine._handleMetaDataWarning(null, "Invalid reply from server"); } else { eval(reply); } } } DWREngine._clearUp(batch); } catch (ex) { if (ex == null) ex = "Unknown error occured"; DWREngine._handleMetaDataWarning(null, ex); } finally { if (DWREngine._batchQueue.length != 0) { var sendbatch = DWREngine._batchQueue.shift(); DWREngine._sendData(sendbatch); DWREngine._batches[DWREngine._batches.length] = sendbatch; } } } }; DWREngine._handleResponse = function(id, reply) { var handlers = DWREngine._handlersMap[id]; DWREngine._handlersMap[id] = null; if (handlers) { try { if (handlers.callback) handlers.callback(reply); } catch (ex) { DWREngine._handleMetaDataError(handlers, ex); } } if (DWREngine._method == DWREngine.IFrame) { var responseBatch = DWREngine._batches[DWREngine._batches.length-1]; if (responseBatch.map["c"+(responseBatch.map.callCount-1)+"-id"] == id) { DWREngine._clearUp(responseBatch); } } }; DWREngine._handleServerError = function(id, error) { var handlers = DWREngine._handlersMap[id]; DWREngine._handlersMap[id] = null; if (error.message) DWREngine._handleMetaDataError(handlers, error.message, error); else DWREngine._handleMetaDataError(handlers, error); }; DWREngine._eval = function(script) { return eval(script); } DWREngine._abortRequest = function(batch) { if (batch && !batch.completed) { clearInterval(batch.interval); DWREngine._clearUp(batch); if (batch.req) batch.req.abort(); var handlers; for (var i = 0; i < batch.ids.length; i++) { handlers = DWREngine._handlersMap[batch.ids[i]]; DWREngine._handleMetaDataError(handlers, "Timeout"); } } }; DWREngine._clearUp = function(batch) { if (batch.completed) { DWREngine._handleError("Double complete"); return; } if (batch.div) batch.div.parentNode.removeChild(batch.div); if (batch.iframe) batch.iframe.parentNode.removeChild(batch.iframe); if (batch.form) batch.form.parentNode.removeChild(batch.form); if (batch.req) delete batch.req; for (var i = 0; i < batch.postHooks.length; i++) { batch.postHooks[i](); } batch.postHooks = null; for (var i = 0; i < DWREngine._batches.length; i++) { if (DWREngine._batches[i] == batch) { DWREngine._batches.splice(i, 1); break; } } batch.completed = true; }; DWREngine._handleError = function(reason, ex) { if (DWREngine._errorHandler) DWREngine._errorHandler(reason, ex); }; DWREngine._handleWarning = function(reason, ex) { if (DWREngine._warningHandler) DWREngine._warningHandler(reason, ex); }; DWREngine._handleMetaDataError = function(handlers, reason, ex) { if (handlers && typeof handlers.errorHandler == "function") handlers.errorHandler(reason, ex); else DWREngine._handleError(reason, ex); }; DWREngine._handleMetaDataWarning = function(handlers, reason, ex) { if (handlers && typeof handlers.warningHandler == "function") handlers.warningHandler(reason, ex); else DWREngine._handleWarning(reason, ex); }; DWREngine._serializeAll = function(batch, referto, data, name) { if (data == null) { batch.map[name] = "null:null"; return; } switch (typeof data) { case "boolean": batch.map[name] = "boolean:" + data; break; case "number": batch.map[name] = "number:" + data; break; case "string": batch.map[name] = "string:" + encodeURIComponent(data); break; case "object": if (data instanceof String) batch.map[name] = "String:" + encodeURIComponent(data); else if (data instanceof Boolean) batch.map[name] = "Boolean:" + data; else if (data instanceof Number) batch.map[name] = "Number:" + data; else if (data instanceof Date) batch.map[name] = "Date:" + data.getTime(); else if (data instanceof Array) batch.map[name] = DWREngine._serializeArray(batch, referto, data, name); else batch.map[name] = DWREngine._serializeObject(batch, referto, data, name); break; case "function": break; default: DWREngine._handleWarning("Unexpected type: " + typeof data + ", attempting default converter."); batch.map[name] = "default:" + data; break; } }; DWREngine._lookup = function(referto, data, name) { var lookup; for (var i = 0; i < referto.length; i++) { if (referto[i].data == data) { lookup = referto[i]; break; } } if (lookup) return "reference:" + lookup.name; referto.push({ data:data, name:name }); return null; }; DWREngine._serializeObject = function(batch, referto, data, name) { var ref = DWREngine._lookup(referto, data, name); if (ref) return ref; if (data.nodeName && data.nodeType) { return DWREngine._serializeXml(batch, referto, data, name); } var reply = "Object:{"; var element; for (element in data) { batch.paramCount++; var childName = "c" + DWREngine._batch.map.callCount + "-e" + batch.paramCount; DWREngine._serializeAll(batch, referto, data[element], childName); reply += encodeURIComponent(element) + ":reference:" + childName + ", "; } if (reply.substring(reply.length - 2) == ", ") { reply = reply.substring(0, reply.length - 2); } reply += "}"; return reply; }; DWREngine._serializeXml = function(batch, referto, data, name) { var ref = DWREngine._lookup(referto, data, name); if (ref) return ref; var output; if (window.XMLSerializer) output = new XMLSerializer().serializeToString(data); else output = data.toXml; return "XML:" + encodeURIComponent(output); }; DWREngine._serializeArray = function(batch, referto, data, name) { var ref = DWREngine._lookup(referto, data, name); if (ref) return ref; var reply = "Array:["; for (var i = 0; i < data.length; i++) { if (i != 0) reply += ","; batch.paramCount++; var childName = "c" + DWREngine._batch.map.callCount + "-e" + batch.paramCount; DWREngine._serializeAll(batch, referto, data[i], childName); reply += "reference:"; reply += childName; } reply += "]"; return reply; }; DWREngine._unserializeDocument = function(xml) { var dom; if (window.DOMParser) { var parser = new DOMParser(); dom = parser.parseFromString(xml, "text/xml"); if (!dom.documentElement || dom.documentElement.tagName == "parsererror") { var message = dom.documentElement.firstChild.data; message += "\n" + dom.documentElement.firstChild.nextSibling.firstChild.data; throw message; } return dom; } else if (window.ActiveXObject) { dom = DWREngine._newActiveXObject(DWREngine._DOMDocument); dom.loadXML(xml); return dom; } else { var div = document.createElement("div"); div.innerHTML = xml; return div; } }; DWREngine._newActiveXObject = function(axarray) { var returnValue; for (var i = 0; i < axarray.length; i++) { try { returnValue = new ActiveXObject(axarray[i]); break; } catch (ex) { } } return returnValue; }; if (typeof window.encodeURIComponent === 'undefined') { DWREngine._utf8 = function(wide) { wide = "" + wide; var c; var s; var enc = ""; var i = 0; while (i < wide.length) { c = wide.charCodeAt(i++); if (c >= 0xDC00 && c < 0xE000) continue; if (c >= 0xD800 && c < 0xDC00) { if (i >= wide.length) continue; s = wide.charCodeAt(i++); if (s < 0xDC00 || c >= 0xDE00) continue; c = ((c - 0xD800) << 10) + (s - 0xDC00) + 0x10000; } if (c < 0x80) { enc += String.fromCharCode(c); } else if (c < 0x800) { enc += String.fromCharCode(0xC0 + (c >> 6), 0x80 + (c & 0x3F)); } else if (c < 0x10000) { enc += String.fromCharCode(0xE0 + (c >> 12), 0x80 + (c >> 6 & 0x3F), 0x80 + (c & 0x3F)); } else { enc += String.fromCharCode(0xF0 + (c >> 18), 0x80 + (c >> 12 & 0x3F), 0x80 + (c >> 6 & 0x3F), 0x80 + (c & 0x3F)); } } return enc; } DWREngine._hexchars = "0123456789ABCDEF"; DWREngine._toHex = function(n) { return DWREngine._hexchars.charAt(n >> 4) + DWREngine._hexchars.charAt(n & 0xF); } DWREngine._okURIchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-"; window.encodeURIComponent = function(s) { s = DWREngine._utf8(s); var c; var enc = ""; for (var i= 0; i this.length) { if (arguments.length > 2) ind = this.length; else return []; } if (arguments.length < 2) cnt = this.length-ind; cnt = (typeof cnt == "number") ? Math.max(0, cnt) : 0; removeArray = this.slice(ind, ind + cnt); endArray = this.slice(ind + cnt); this.length = ind; for (var i = 2; i < arguments.length; i++) this[this.length] = arguments[i]; for (i = 0; i < endArray.length; i++) this[this.length] = endArray[i]; return removeArray; } } if (typeof Array.prototype.shift === 'undefined') { Array.prototype.shift = function(str) { var val = this[0]; for (var i = 1; i < this.length; ++i) this[i - 1] = this[i]; this.length--; return val; } } if (typeof Array.prototype.unshift === 'undefined') { Array.prototype.unshift = function() { var i = unshift.arguments.length; for (var j = this.length - 1; j >= 0; --j) this[j + i] = this[j]; for (j = 0; j < i; ++j) this[j] = unshift.arguments[j]; } } if (typeof Array.prototype.push === 'undefined') { Array.prototype.push = function() { var sub = this.length; for (var i = 0; i < push.arguments.length; ++i) { this[sub] = push.arguments[i]; sub++; } } } if (typeof Array.prototype.pop === 'undefined') { Array.prototype.pop = function() { var lastElement = this[this.length - 1]; this.length--; return lastElement; } } function DWRUtil() { } DWRUtil.onReturn = function(event, action) { if (!event) { event = window.event; } if (event && event.keyCode && event.keyCode == 13) { action(); } }; DWRUtil.selectRange = function(ele, start, end) { var orig = ele; ele = $(ele); if (ele == null) { DWRUtil.debug("selectRange() can't find an element with id: " + orig + "."); return; } if (ele.setSelectionRange) { ele.setSelectionRange(start, end); } else if (ele.createTextRange) { var range = ele.createTextRange(); range.moveStart("character", start); range.moveEnd("character", end - ele.value.length); range.select(); } ele.focus(); }; DWRUtil._getSelection = function(ele) { var orig = ele; ele = $(ele); if (ele == null) { DWRUtil.debug("selectRange() can't find an element with id: " + orig + "."); return; } return ele.value.substring(ele.selectionStart, ele.selectionEnd); } var $; if (!$ && document.getElementById) { $ = function() { var elements = new Array(); for (var i = 0; i < arguments.length; i++) { var element = arguments[i]; if (typeof element == 'string') { element = document.getElementById(element); } if (arguments.length == 1) { return element; } elements.push(element); } return elements; } } else if (!$ && document.all) { $ = function() { var elements = new Array(); for (var i = 0; i < arguments.length; i++) { var element = arguments[i]; if (typeof element == 'string') { element = document.all[element]; } if (arguments.length == 1) { return element; } elements.push(element); } return elements; } } DWRUtil.toDescriptiveString = function(data, level, depth) { var reply = ""; var i = 0; var value; var obj; if (level == null) level = 0; if (depth == null) depth = 0; if (data == null) return "null"; if (DWRUtil._isArray(data)) { if (data.length == 0) reply += "[]"; else { if (level != 0) reply += "[\n"; else reply = "["; for (i = 0; i < data.length; i++) { try { obj = data[i]; if (obj == null || typeof obj == "function") { continue; } else if (typeof obj == "object") { if (level > 0) value = DWRUtil.toDescriptiveString(obj, level - 1, depth + 1); else value = DWRUtil._detailedTypeOf(obj); } else { value = "" + obj; value = value.replace(/\/n/g, "\\n"); value = value.replace(/\/t/g, "\\t"); } } catch (ex) { value = "" + ex; } if (level != 0) { reply += DWRUtil._indent(level, depth + 2) + value + ", \n"; } else { if (value.length > 13) value = value.substring(0, 10) + "..."; reply += value + ", "; if (i > 5) { reply += "..."; break; } } } if (level != 0) reply += DWRUtil._indent(level, depth) + "]"; else reply += "]"; } return reply; } if (typeof data == "string" || typeof data == "number" || DWRUtil._isDate(data)) { return data.toString(); } if (typeof data == "object") { var typename = DWRUtil._detailedTypeOf(data); if (typename != "Object") reply = typename + " "; if (level != 0) reply += "{\n"; else reply = "{"; var isHtml = DWRUtil._isHTMLElement(data); for (var prop in data) { if (isHtml) { if (prop.toUpperCase() == prop || prop == "title" || prop == "lang" || prop == "dir" || prop == "className" || prop == "form" || prop == "name" || prop == "prefix" || prop == "namespaceURI" || prop == "nodeType" || prop == "firstChild" || prop == "lastChild" || prop.match(/^offset/)) { continue; } } value = ""; try { obj = data[prop]; if (obj == null || typeof obj == "function") { continue; } else if (typeof obj == "object") { if (level > 0) { value = "\n"; value += DWRUtil._indent(level, depth + 2); value = DWRUtil.toDescriptiveString(obj, level - 1, depth + 1); } else { value = DWRUtil._detailedTypeOf(obj); } } else { value = "" + obj; value = value.replace(/\/n/g, "\\n"); value = value.replace(/\/t/g, "\\t"); } } catch (ex) { value = "" + ex; } if (level == 0 && value.length > 13) value = value.substring(0, 10) + "..."; var propStr = prop; if (propStr.length > 30) propStr = propStr.substring(0, 27) + "..."; if (level != 0) reply += DWRUtil._indent(level, depth + 1); reply += prop + ":" + value + ", "; if (level != 0) reply += "\n"; i++; if (level == 0 && i > 5) { reply += "..."; break; } } reply += DWRUtil._indent(level, depth); reply += "}"; return reply; } return data.toString(); }; DWRUtil._indent = function(level, depth) { var reply = ""; if (level != 0) { for (var j = 0; j < depth; j++) { reply += "\u00A0\u00A0"; } reply += " "; } return reply; }; DWRUtil.useLoadingMessage = function(message) { var loadingMessage; if (message) loadingMessage = message; else loadingMessage = "Loading"; DWREngine.setPreHook(function() { var disabledZone = $('disabledZone'); if (!disabledZone) { disabledZone = document.createElement('div'); disabledZone.setAttribute('id', 'disabledZone'); disabledZone.style.position = "absolute"; disabledZone.style.zIndex = "1000"; disabledZone.style.left = "0px"; disabledZone.style.top = "0px"; disabledZone.style.width = "100%"; disabledZone.style.height = "100%"; document.body.appendChild(disabledZone); var messageZone = document.createElement('div'); messageZone.setAttribute('id', 'messageZone'); messageZone.style.position = "absolute"; messageZone.style.top = "0px"; messageZone.style.right = "0px"; messageZone.style.background = "red"; messageZone.style.color = "white"; messageZone.style.fontFamily = "Arial,Helvetica,sans-serif"; messageZone.style.padding = "4px"; disabledZone.appendChild(messageZone); var text = document.createTextNode(loadingMessage); messageZone.appendChild(text); } else { $('messageZone').innerHTML = loadingMessage; disabledZone.style.visibility = 'visible'; } }); DWREngine.setPostHook(function() { $('disabledZone').style.visibility = 'hidden'; }); } DWRUtil.setValue = function(ele, val, options) { if (val == null) val = ""; if (options != null) { if (options.escapeHtml) { val = val.replace(/&/, "&"); val = val.replace(/'/, "'"); val = val.replace(//, ">"); } } var orig = ele; var nodes, node, i; ele = $(ele); if (ele == null) { nodes = document.getElementsByName(orig); if (nodes.length >= 1) { ele = nodes.item(0); } } if (ele == null) { DWRUtil.debug("setValue() can't find an element with id/name: " + orig + "."); return; } if (DWRUtil._isHTMLElement(ele, "select")) { if (ele.type == "select-multiple" && DWRUtil._isArray(val)) { DWRUtil._selectListItems(ele, val); } else { DWRUtil._selectListItem(ele, val); } return; } if (DWRUtil._isHTMLElement(ele, "input")) { if (ele.type == "radio") { if (nodes == null) nodes = document.getElementsByName(orig); if (nodes != null && nodes.length > 1) { for (i = 0; i < nodes.length; i++) { node = nodes.item(i); if (node.type == "radio") { node.checked = (node.value == val); } } } else { ele.checked = (val == true); } } else if (ele.type == "checkbox") { ele.checked = val; } else { ele.value = val; } return; } if (DWRUtil._isHTMLElement(ele, "textarea")) { ele.value = val; return; } if (val.nodeType) { if (val.nodeType == 9 ) { val = val.documentElement; } val = DWRUtil._importNode(ele.ownerDocument, val, true); ele.appendChild(val); return; } ele.innerHTML = val; }; DWRUtil._selectListItems = function(ele, val) { var found = false; var i; var j; for (i = 0; i < ele.options.length; i++) { ele.options[i].selected = false; for (j = 0; j < val.length; j++) { if (ele.options[i].value == val[j]) { ele.options[i].selected = true; } } } if (found) return; for (i = 0; i < ele.options.length; i++) { for (j = 0; j < val.length; j++) { if (ele.options[i].text == val[j]) { ele.options[i].selected = true; } } } }; DWRUtil._selectListItem = function(ele, val) { var found = false; var i; for (i = 0; i < ele.options.length; i++) { if (ele.options[i].value == val) { ele.options[i].selected = true; found = true; } else { ele.options[i].selected = false; } } if (found) return; for (i = 0; i < ele.options.length; i++) { if (ele.options[i].text == val) { ele.options[i].selected = true; } else { ele.options[i].selected = false; } } } DWRUtil.getValue = function(ele, options) { if (options == null) { options = {}; } var orig = ele; ele = $(ele); var nodes = document.getElementsByName(orig); if (ele == null && nodes.length >= 1) { ele = nodes.item(0); } if (ele == null) { DWRUtil.debug("getValue() can't find an element with id/name: " + orig + "."); return ""; } if (DWRUtil._isHTMLElement(ele, "select")) { var sel = ele.selectedIndex; if (sel != -1) { var reply = ele.options[sel].value; if (reply == null || reply == "") { reply = ele.options[sel].text; } return reply; } else { return ""; } } if (DWRUtil._isHTMLElement(ele, "input")) { if (ele.type == "radio") { var node; for (i = 0; i < nodes.length; i++) { node = nodes.item(i); if (node.type == "radio") { if (node.checked) { if (nodes.length > 1) return node.value; else return true; } } } } switch (ele.type) { case "checkbox": case "check-box": case "radio": return ele.checked; default: return ele.value; } } if (DWRUtil._isHTMLElement(ele, "textarea")) { return ele.value; } if (options.textContent) { if (ele.textContent) return ele.textContent; else if (ele.innerText) return ele.innerText; } return ele.innerHTML; }; DWRUtil.getText = function(ele) { var orig = ele; ele = $(ele); if (ele == null) { DWRUtil.debug("getText() can't find an element with id: " + orig + "."); return ""; } if (!DWRUtil._isHTMLElement(ele, "select")) { DWRUtil.debug("getText() can only be used with select elements. Attempt to use: " + DWRUtil._detailedTypeOf(ele) + " from id: " + orig + "."); return ""; } var sel = ele.selectedIndex; if (sel != -1) { return ele.options[sel].text; } else { return ""; } }; DWRUtil.setValues = function(map) { for (var property in map) { if ($(property) != null || document.getElementsByName(property).length >= 1) { DWRUtil.setValue(property, map[property]); } } }; DWRUtil.getValues = function(data) { var ele; if (typeof data == "string") ele = $(data); if (DWRUtil._isHTMLElement(data)) ele = data; if (ele != null) { if (ele.elements == null) { alert("getValues() requires an object or reference to a form element."); return null; } var reply = {}; var value; for (var i = 0; i < ele.elements.length; i++) { if (ele[i].id != null) value = ele[i].id; else if (ele[i].value != null) value = ele[i].value; else value = "element" + i; reply[value] = DWRUtil.getValue(ele[i]); } return reply; } else { for (var property in data) { if ($(property) != null || document.getElementsByName(property).length >= 1) { data[property] = DWRUtil.getValue(property); } } return data; } }; DWRUtil.addOptions = function(ele, data) { var orig = ele; ele = $(ele); if (ele == null) { DWRUtil.debug("addOptions() can't find an element with id: " + orig + "."); return; } var useOptions = DWRUtil._isHTMLElement(ele, "select"); var useLi = DWRUtil._isHTMLElement(ele, ["ul", "ol"]); if (!useOptions && !useLi) { DWRUtil.debug("addOptions() can only be used with select/ul/ol elements. Attempt to use: " + DWRUtil._detailedTypeOf(ele)); return; } if (data == null) return; var text; var value; var opt; var li; if (DWRUtil._isArray(data)) { for (var i = 0; i < data.length; i++) { if (useOptions) { if (arguments[2] != null) { if (arguments[3] != null) { text = DWRUtil._getValueFrom(data[i], arguments[3]); value = DWRUtil._getValueFrom(data[i], arguments[2]); } else { value = DWRUtil._getValueFrom(data[i], arguments[2]); text = value; } } else { text = DWRUtil._getValueFrom(data[i], arguments[3]); value = text; } if (text || value) { opt = new Option(text, value); ele.options[ele.options.length] = opt; } } else { li = document.createElement("li"); value = DWRUtil._getValueFrom(data[i], arguments[2]); if (value != null) { li.innerHTML = value; ele.appendChild(li); } } } } else if (arguments[3] != null) { for (var prop in data) { if (!useOptions) { alert("DWRUtil.addOptions can only create select lists from objects."); return; } value = DWRUtil._getValueFrom(data[prop], arguments[2]); text = DWRUtil._getValueFrom(data[prop], arguments[3]); if (text || value) { opt = new Option(text, value); ele.options[ele.options.length] = opt; } } } else { for (var prop in data) { if (!useOptions) { DWRUtil.debug("DWRUtil.addOptions can only create select lists from objects."); return; } if (typeof data[prop] == "function") { text = null; value = null; } else if (arguments[2]) { text = prop; value = data[prop]; } else { text = data[prop]; value = prop; } if (text || value) { opt = new Option(text, value); ele.options[ele.options.length] = opt; } } } }; DWRUtil._getValueFrom = function(data, method) { if (method == null) return data; else if (typeof method == 'function') return method(data); else return data[method]; } DWRUtil.removeAllOptions = function(ele) { var orig = ele; ele = $(ele); if (ele == null) { DWRUtil.debug("removeAllOptions() can't find an element with id: " + orig + "."); return; } var useOptions = DWRUtil._isHTMLElement(ele, "select"); var useLi = DWRUtil._isHTMLElement(ele, ["ul", "ol"]); if (!useOptions && !useLi) { DWRUtil.debug("removeAllOptions() can only be used with select, ol and ul elements. Attempt to use: " + DWRUtil._detailedTypeOf(ele)); return; } if (useOptions) { ele.options.length = 0; } else { while (ele.childNodes.length > 0) { ele.removeChild(ele.firstChild); } } }; DWRUtil.addRows = function(ele, data, cellFuncs, options) { var orig = ele; ele = $(ele); if (ele == null) { DWRUtil.debug("addRows() can't find an element with id: " + orig + "."); return; } if (!DWRUtil._isHTMLElement(ele, ["table", "tbody", "thead", "tfoot"])) { DWRUtil.debug("addRows() can only be used with table, tbody, thead and tfoot elements. Attempt to use: " + DWRUtil._detailedTypeOf(ele)); return; } if (!options) options = {}; if (!options.rowCreator) options.rowCreator = DWRUtil._defaultRowCreator; if (!options.cellCreator) options.cellCreator = DWRUtil._defaultCellCreator; var tr, rowNum; if (DWRUtil._isArray(data)) { for (rowNum = 0; rowNum < data.length; rowNum++) { options.rowData = data[rowNum]; options.rowIndex = rowNum; options.rowNum = rowNum; options.data = null; options.cellNum = -1; tr = DWRUtil._addRowInner(cellFuncs, options); if (tr != null) ele.appendChild(tr); } } else if (typeof data == "object") { rowNum = 0; for (var rowIndex in data) { options.rowData = data[rowIndex]; options.rowIndex = rowIndex; options.rowNum = rowNum; options.data = null; options.cellNum = -1; tr = DWRUtil._addRowInner(cellFuncs, options); if (tr != null) ele.appendChild(tr); rowNum++; } } }; DWRUtil._addRowInner = function(cellFuncs, options) { var tr = options.rowCreator(options); if (tr == null) return null; for (var cellNum = 0; cellNum < cellFuncs.length; cellNum++) { var func = cellFuncs[cellNum]; var reply = func(options.rowData, options); options.data = reply; options.cellNum = cellNum; var td = options.cellCreator(options); if (td != null) { if (reply != null) { if (DWRUtil._isHTMLElement(reply)) td.appendChild(reply); else td.innerHTML = reply; } tr.appendChild(td); } } return tr; }; DWRUtil._defaultRowCreator = function(options) { return document.createElement("tr"); }; DWRUtil._defaultCellCreator = function(options) { return document.createElement("td"); }; DWRUtil.removeAllRows = function(ele) { var orig = ele; ele = $(ele); if (ele == null) { DWRUtil.debug("removeAllRows() can't find an element with id: " + orig + "."); return; } if (!DWRUtil._isHTMLElement(ele, ["table", "tbody", "thead", "tfoot"])) { DWRUtil.debug("removeAllRows() can only be used with table, tbody, thead and tfoot elements. Attempt to use: " + DWRUtil._detailedTypeOf(ele)); return; } while (ele.childNodes.length > 0) { ele.removeChild(ele.firstChild); } }; DWRUtil._isHTMLElement = function(ele, nodeName) { if (ele == null || typeof ele != "object" || ele.nodeName == null) { return false; } if (nodeName != null) { var test = ele.nodeName.toLowerCase(); if (typeof nodeName == "string") { return test == nodeName.toLowerCase(); } if (DWRUtil._isArray(nodeName)) { var match = false; for (var i = 0; i < nodeName.length && !match; i++) { if (test == nodeName[i].toLowerCase()) { match = true; } } return match; } DWRUtil.debug("DWRUtil._isHTMLElement was passed test node name that is neither a string or array of strings"); return false; } return true; }; DWRUtil._detailedTypeOf = function(x) { var reply = typeof x; if (reply == "object") { reply = Object.prototype.toString.apply(x); reply = reply.substring(8, reply.length-1); } return reply; }; DWRUtil._isArray = function(data) { return (data && data.join) ? true : false; }; DWRUtil._isDate = function(data) { return (data && data.toUTCString) ? true : false; }; DWRUtil._importNode = function(doc, importedNode, deep) { var newNode; if (importedNode.nodeType == 1 ) { newNode = doc.createElement(importedNode.nodeName); for (var i = 0; i < importedNode.attributes.length; i++) { var attr = importedNode.attributes[i]; if (attr.nodeValue != null && attr.nodeValue != '') { newNode.setAttribute(attr.name, attr.nodeValue); } } if (typeof importedNode.style != "undefined") { newNode.style.cssText = importedNode.style.cssText; } } else if (importedNode.nodeType == 3 ) { newNode = doc.createTextNode(importedNode.nodeValue); } if (deep && importedNode.hasChildNodes()) { for (i = 0; i < importedNode.childNodes.length; i++) { newNode.appendChild(DWRUtil._importNode(doc, importedNode.childNodes[i], true)); } } return newNode; } DWRUtil.debug = function(message) { alert(message); }