xajax_uncompressed.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795
  1. /* xajax Javascript library :: version 0.2.4 */
  2. Array.prototype.containsValue = function(valueToCheck)
  3. {
  4. for (var i=0;i<this.length;i++) {
  5. if (this[i] == valueToCheck) return true;
  6. }
  7. return false;
  8. }
  9. function Xajax()
  10. {
  11. this.DebugMessage = function(text)
  12. {
  13. if (text.length > 1000) text = text.substr(0,1000)+"...\n[long response]\n...";
  14. try {
  15. if (this.debugWindow == undefined || this.debugWindow.closed == true) {
  16. this.debugWindow = window.open('about:blank', 'xajax-debug', 'width=800,height=600,scrollbars=1,resizable,status');
  17. this.debugWindow.document.write('<html><head><title>Xajax debug output</title></head><body><h2>Xajax debug output</h2><div id="debugTag"></div></body></html>');
  18. }
  19. text = text.replace(/&/g, "&amp;")
  20. text = text.replace(/</g, "&lt;")
  21. text = text.replace(/>/g, "&gt;")
  22. debugTag = this.debugWindow.document.getElementById('debugTag');
  23. debugTag.innerHTML = ('<b>'+(new Date()).toString()+'</b>: ' + text + '<hr/>') + debugTag.innerHTML;
  24. } catch (e) {
  25. alert("Xajax Debug:\n " + text);
  26. }
  27. };
  28. this.workId = 'xajaxWork'+ new Date().getTime();
  29. this.depth = 0;
  30. this.responseErrorsForAlert = ["400","401","402","403","404","500","501","502","503"];
  31. //Get the XMLHttpRequest Object
  32. this.getRequestObject = function()
  33. {
  34. if (xajaxDebug) this.DebugMessage("Initializing Request Object..");
  35. var req = null;
  36. if (typeof XMLHttpRequest != "undefined")
  37. req = new XMLHttpRequest();
  38. if (!req && typeof ActiveXObject != "undefined")
  39. {
  40. try
  41. {
  42. req=new ActiveXObject("Msxml2.XMLHTTP");
  43. }
  44. catch (e)
  45. {
  46. try
  47. {
  48. req=new ActiveXObject("Microsoft.XMLHTTP");
  49. }
  50. catch (e2)
  51. {
  52. try {
  53. req=new ActiveXObject("Msxml2.XMLHTTP.4.0");
  54. }
  55. catch (e3)
  56. {
  57. req=null;
  58. }
  59. }
  60. }
  61. }
  62. if(!req && window.createRequest)
  63. req = window.createRequest();
  64. if (!req) this.DebugMessage("Request Object Instantiation failed.");
  65. return req;
  66. }
  67. // xajax.$() is shorthand for document.getElementById()
  68. this.$ = function(sId)
  69. {
  70. if (!sId) {
  71. return null;
  72. }
  73. var returnObj = document.getElementById(sId);
  74. if (!returnObj && document.all) {
  75. returnObj = document.all[sId];
  76. }
  77. if (xajaxDebug && !returnObj && sId != this.workId) {
  78. this.DebugMessage("Element with the id \"" + sId + "\" not found.");
  79. }
  80. return returnObj;
  81. }
  82. // xajax.include(sFileName) dynamically includes an external javascript file
  83. this.include = function(sFileName)
  84. {
  85. var objHead = document.getElementsByTagName('head');
  86. var objScript = document.createElement('script');
  87. objScript.type = 'text/javascript';
  88. objScript.src = sFileName;
  89. objHead[0].appendChild(objScript);
  90. }
  91. this.stripOnPrefix = function(sEventName)
  92. {
  93. sEventName = sEventName.toLowerCase();
  94. if (sEventName.indexOf('on') == 0)
  95. {
  96. sEventName = sEventName.replace(/on/,'');
  97. }
  98. return sEventName;
  99. }
  100. this.addOnPrefix = function(sEventName)
  101. {
  102. sEventName = sEventName.toLowerCase();
  103. if (sEventName.indexOf('on') != 0)
  104. {
  105. sEventName = 'on' + sEventName;
  106. }
  107. return sEventName;
  108. }
  109. // xajax.addHandler adds an event handler to an element
  110. this.addHandler = function(sElementId, sEvent, sFunctionName)
  111. {
  112. if (window.addEventListener)
  113. {
  114. sEvent = this.stripOnPrefix(sEvent);
  115. eval("this.$('"+sElementId+"').addEventListener('"+sEvent+"',"+sFunctionName+",false);");
  116. }
  117. else
  118. {
  119. sAltEvent = this.addOnPrefix(sEvent);
  120. eval("this.$('"+sElementId+"').attachEvent('"+sAltEvent+"',"+sFunctionName+",false);");
  121. }
  122. }
  123. // xajax.removeHandler removes an event handler from an element
  124. this.removeHandler = function(sElementId, sEvent, sFunctionName)
  125. {
  126. if (window.addEventListener)
  127. {
  128. sEvent = this.stripOnPrefix(sEvent);
  129. eval("this.$('"+sElementId+"').removeEventListener('"+sEvent+"',"+sFunctionName+",false);");
  130. }
  131. else
  132. {
  133. sAltEvent = this.addOnPrefix(sEvent);
  134. eval("this.$('"+sElementId+"').detachEvent('"+sAltEvent+"',"+sFunctionName+",false);");
  135. }
  136. }
  137. // xajax.create creates a new child node under a parent
  138. this.create = function(sParentId, sTag, sId)
  139. {
  140. var objParent = this.$(sParentId);
  141. objElement = document.createElement(sTag);
  142. objElement.setAttribute('id',sId);
  143. if (objParent)
  144. objParent.appendChild(objElement);
  145. }
  146. // xajax.insert inserts a new node before another node
  147. this.insert = function(sBeforeId, sTag, sId)
  148. {
  149. var objSibling = this.$(sBeforeId);
  150. objElement = document.createElement(sTag);
  151. objElement.setAttribute('id',sId);
  152. objSibling.parentNode.insertBefore(objElement, objSibling);
  153. }
  154. // xajax.insertAfter inserts a new node after another node
  155. this.insertAfter = function(sAfterId, sTag, sId)
  156. {
  157. var objSibling = this.$(sAfterId);
  158. objElement = document.createElement(sTag);
  159. objElement.setAttribute('id',sId);
  160. objSibling.parentNode.insertBefore(objElement, objSibling.nextSibling);
  161. }
  162. this.getInput = function(sType, sName, sId)
  163. {
  164. var Obj;
  165. if (!window.addEventListener)
  166. {
  167. Obj = document.createElement('<input type="'+sType+'" id="'+sId+'" name="'+sName+'">');
  168. }
  169. else
  170. {
  171. Obj = document.createElement('input');
  172. Obj.setAttribute('type',sType);
  173. Obj.setAttribute('name',sName);
  174. Obj.setAttribute('id',sId);
  175. }
  176. return Obj;
  177. }
  178. // xajax.createInput creates a new input node under a parent
  179. this.createInput = function(sParentId, sType, sName, sId)
  180. {
  181. var objParent = this.$(sParentId);
  182. var objElement = this.getInput(sType, sName, sId);
  183. if (objParent && objElement)
  184. objParent.appendChild(objElement);
  185. }
  186. // xajax.insertInput creates a new input node before another node
  187. this.insertInput = function(sBeforeId, sType, sName, sId)
  188. {
  189. var objSibling = this.$(sBeforeId);
  190. var objElement = this.getInput(sType, sName, sId);
  191. if (objElement && objSibling && objSibling.parentNode)
  192. objSibling.parentNode.insertBefore(objElement, objSibling);
  193. }
  194. // xajax.insertInputAfter creates a new input node after another node
  195. this.insertInputAfter = function(sAfterId, sType, sName, sId)
  196. {
  197. var objSibling = this.$(sAfterId);
  198. var objElement = this.getInput(sType, sName, sId);
  199. if (objElement && objSibling && objSibling.parentNode) {
  200. objSibling.parentNode.insertBefore(objElement, objSibling.nextSibling);
  201. }
  202. }
  203. // xajax.remove deletes an element
  204. this.remove = function(sId)
  205. {
  206. objElement = this.$(sId);
  207. if (objElement && objElement.parentNode && objElement.parentNode.removeChild)
  208. {
  209. objElement.parentNode.removeChild(objElement);
  210. }
  211. }
  212. //xajax.replace searches for text in an attribute of an element and replaces it
  213. //with a different text
  214. this.replace = function(sId,sAttribute,sSearch,sReplace)
  215. {
  216. var bFunction = false;
  217. if (sAttribute == "innerHTML")
  218. sSearch = this.getBrowserHTML(sSearch);
  219. eval("var txt=this.$('"+sId+"')."+sAttribute);
  220. if (typeof txt == "function")
  221. {
  222. txt = txt.toString();
  223. bFunction = true;
  224. }
  225. if (txt.indexOf(sSearch)>-1)
  226. {
  227. var newTxt = '';
  228. while (txt.indexOf(sSearch) > -1)
  229. {
  230. x = txt.indexOf(sSearch)+sSearch.length+1;
  231. newTxt += txt.substr(0,x).replace(sSearch,sReplace);
  232. txt = txt.substr(x,txt.length-x);
  233. }
  234. newTxt += txt;
  235. if (bFunction)
  236. {
  237. eval('this.$("'+sId+'").'+sAttribute+'=newTxt;');
  238. }
  239. else if (this.willChange(sId,sAttribute,newTxt))
  240. {
  241. eval('this.$("'+sId+'").'+sAttribute+'=newTxt;');
  242. }
  243. }
  244. }
  245. // xajax.getFormValues() builds a query string XML message from the elements of a form object
  246. // * The first argument is the id of the form
  247. // * The second argument (optional) can be set to true if you want to submit disabled elements
  248. // * The third argument (optional) allows you to specify a string prefix that a form element
  249. // name must contain if you want that element to be submitted
  250. this.getFormValues = function(frm)
  251. {
  252. var objForm;
  253. var submitDisabledElements = false;
  254. if (arguments.length > 1 && arguments[1] == true)
  255. submitDisabledElements = true;
  256. var prefix="";
  257. if(arguments.length > 2)
  258. prefix = arguments[2];
  259. if (typeof(frm) == "string")
  260. objForm = this.$(frm);
  261. else
  262. objForm = frm;
  263. var sXml = "<xjxquery><q>";
  264. if (objForm && objForm.tagName == 'FORM')
  265. {
  266. var formElements = objForm.elements;
  267. for( var i=0; i < formElements.length; i++)
  268. {
  269. if (!formElements[i].name)
  270. continue;
  271. if (formElements[i].name.substring(0, prefix.length) != prefix)
  272. continue;
  273. if (formElements[i].type && (formElements[i].type == 'radio' || formElements[i].type == 'checkbox') && formElements[i].checked == false)
  274. continue;
  275. if (formElements[i].disabled && formElements[i].disabled == true && submitDisabledElements == false)
  276. continue;
  277. var name = formElements[i].name;
  278. if (name)
  279. {
  280. if (sXml != '<xjxquery><q>')
  281. sXml += '&';
  282. if(formElements[i].type=='select-multiple')
  283. {
  284. for (var j = 0; j < formElements[i].length; j++)
  285. {
  286. if (formElements[i].options[j].selected == true)
  287. sXml += name+"="+encodeURIComponent(formElements[i].options[j].value)+"&";
  288. }
  289. }
  290. else
  291. {
  292. sXml += name+"="+encodeURIComponent(formElements[i].value);
  293. }
  294. }
  295. }
  296. }
  297. sXml +="</q></xjxquery>";
  298. return sXml;
  299. }
  300. // Generates an XML message that xajax can understand from a javascript object
  301. this.objectToXML = function(obj)
  302. {
  303. var sXml = "<xjxobj>";
  304. for (i in obj)
  305. {
  306. try
  307. {
  308. if (i == 'constructor')
  309. continue;
  310. if (obj[i] && typeof(obj[i]) == 'function')
  311. continue;
  312. var key = i;
  313. var value = obj[i];
  314. if (value && typeof(value)=="object" && this.depth <= 50)
  315. {
  316. this.depth++;
  317. value = this.objectToXML(value);
  318. this.depth--;
  319. }
  320. sXml += "<e><k>"+key+"</k><v>"+value+"</v></e>";
  321. }
  322. catch(e)
  323. {
  324. if (xajaxDebug) this.DebugMessage(e.name+": "+e.message);
  325. }
  326. }
  327. sXml += "</xjxobj>";
  328. return sXml;
  329. }
  330. // unserializes data structure from xajaxResponse::_buildObjXml()
  331. this._nodeToObject = function(node) {
  332. // parentNode here is weird, have to tune
  333. if (node.nodeName == '#cdata-section') {
  334. var data = "";
  335. for (var j=0; j<node.parentNode.childNodes.length; j++) {
  336. data += node.parentNode.childNodes[j].data;
  337. }
  338. return data;
  339. }
  340. else if (node.nodeName == 'xjxobj') {
  341. var data = new Array();
  342. for (var j=0; j<node.childNodes.length; j++) {
  343. var child = node.childNodes[j];
  344. var key;
  345. var value;
  346. if (child.nodeName == 'e') {
  347. for (var k=0; k<child.childNodes.length; k++) {
  348. if (child.childNodes[k].nodeName == 'k') {
  349. key = child.childNodes[k].firstChild.data;
  350. }
  351. else if (child.childNodes[k].nodeName == 'v') {
  352. value = this._nodeToObject(child.childNodes[k].firstChild);
  353. }
  354. }
  355. if (key != null && value != null) {
  356. data[key] = value;
  357. key = value = null;
  358. }
  359. }
  360. }
  361. return data;
  362. }
  363. }
  364. this.loadingFunction = function(){};
  365. this.doneLoadingFunction = function(){};
  366. var loadingTimeout;
  367. // Sends a XMLHttpRequest to call the specified PHP function on the server
  368. // * sRequestType is optional -- defaults to POST
  369. this.call = function(sFunction, aArgs, sRequestType)
  370. {
  371. var i,r,postData;
  372. if (document.body && xajaxWaitCursor)
  373. document.body.style.cursor = 'wait';
  374. if (xajaxStatusMessages == true) window.status = 'Sending Request...';
  375. clearTimeout(loadingTimeout);
  376. loadingTimeout = setTimeout("xajax.loadingFunction();",400);
  377. if (xajaxDebug) this.DebugMessage("Starting xajax...");
  378. if (sRequestType == null) {
  379. var xajaxRequestType = xajaxDefinedPost;
  380. }
  381. else {
  382. var xajaxRequestType = sRequestType;
  383. }
  384. var uri = xajaxRequestUri;
  385. var value;
  386. switch(xajaxRequestType)
  387. {
  388. case xajaxDefinedGet:{
  389. var uriGet = uri.indexOf("?")==-1?"?xajax="+encodeURIComponent(sFunction):"&xajax="+encodeURIComponent(sFunction);
  390. if (aArgs) {
  391. for (i = 0; i<aArgs.length; i++)
  392. {
  393. value = aArgs[i];
  394. if (typeof(value)=="object")
  395. value = this.objectToXML(value);
  396. uriGet += "&xajaxargs[]="+encodeURIComponent(value);
  397. }
  398. }
  399. uriGet += "&xajaxr=" + new Date().getTime();
  400. uri += uriGet;
  401. postData = null;
  402. } break;
  403. case xajaxDefinedPost:{
  404. postData = "xajax="+encodeURIComponent(sFunction);
  405. postData += "&xajaxr="+new Date().getTime();
  406. if (aArgs) {
  407. for (i = 0; i <aArgs.length; i++)
  408. {
  409. value = aArgs[i];
  410. if (typeof(value)=="object")
  411. value = this.objectToXML(value);
  412. postData = postData+"&xajaxargs[]="+encodeURIComponent(value);
  413. }
  414. }
  415. } break;
  416. default:
  417. alert("Illegal request type: " + xajaxRequestType); return false; break;
  418. }
  419. r = this.getRequestObject();
  420. if (!r) return false;
  421. r.open(xajaxRequestType==xajaxDefinedGet?"GET":"POST", uri, true);
  422. if (xajaxRequestType == xajaxDefinedPost)
  423. {
  424. try
  425. {
  426. r.setRequestHeader("Method", "POST " + uri + " HTTP/1.1");
  427. r.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  428. }
  429. catch(e)
  430. {
  431. alert("Your browser does not appear to support asynchronous requests using POST.");
  432. return false;
  433. }
  434. }
  435. r.onreadystatechange = function()
  436. {
  437. if (r.readyState != 4)
  438. return;
  439. if (r.status==200)
  440. {
  441. if (xajaxDebug) xajax.DebugMessage("Received:\n" + r.responseText);
  442. if (r.responseXML && r.responseXML.documentElement)
  443. xajax.processResponse(r.responseXML);
  444. else {
  445. var errorString = "Error: the XML response that was returned from the server is invalid.";
  446. errorString += "\nReceived:\n" + r.responseText;
  447. trimmedResponseText = r.responseText.replace( /^\s+/g, "" );// strip leading space
  448. trimmedResponseText = trimmedResponseText.replace( /\s+$/g, "" );// strip trailing
  449. if (trimmedResponseText != r.responseText)
  450. errorString += "\nYou have whitespace in your response.";
  451. alert(errorString);
  452. document.body.style.cursor = 'default';
  453. if (xajaxStatusMessages == true) window.status = 'Invalid XML response error';
  454. }
  455. }
  456. else {
  457. if (xajax.responseErrorsForAlert.containsValue(r.status)) {
  458. var errorString = "Error: the server returned the following HTTP status: " + r.status;
  459. errorString += "\nReceived:\n" + r.responseText;
  460. alert(errorString);
  461. }
  462. document.body.style.cursor = 'default';
  463. if (xajaxStatusMessages == true) window.status = 'Invalid XML response error';
  464. }
  465. delete r;
  466. r = null;
  467. }
  468. if (xajaxDebug) this.DebugMessage("Calling "+sFunction +" uri="+uri+" (post:"+ postData +")");
  469. r.send(postData);
  470. if (xajaxStatusMessages == true) window.status = 'Waiting for data...';
  471. delete r;
  472. return true;
  473. }
  474. //Gets the text as it would be if it were being retrieved from
  475. //the innerHTML property in the current browser
  476. this.getBrowserHTML = function(html)
  477. {
  478. tmpXajax = this.$(this.workId);
  479. if (!tmpXajax)
  480. {
  481. tmpXajax = document.createElement("div");
  482. tmpXajax.setAttribute('id',this.workId);
  483. tmpXajax.style.display = "none";
  484. tmpXajax.style.visibility = "hidden";
  485. document.body.appendChild(tmpXajax);
  486. }
  487. tmpXajax.innerHTML = html;
  488. var browserHTML = tmpXajax.innerHTML;
  489. tmpXajax.innerHTML = '';
  490. return browserHTML;
  491. }
  492. // Tests if the new Data is the same as the extant data
  493. this.willChange = function(element, attribute, newData)
  494. {
  495. if (!document.body)
  496. {
  497. return true;
  498. }
  499. if (attribute == "innerHTML")
  500. {
  501. newData = this.getBrowserHTML(newData);
  502. }
  503. elementObject = this.$(element);
  504. if (elementObject) {
  505. var oldData;
  506. eval("oldData=this.$('"+element+"')."+attribute);
  507. if (newData !== oldData)
  508. return true;
  509. }
  510. return false;
  511. }
  512. //Returns the source code of the page after it's been modified by xajax
  513. this.viewSource = function()
  514. {
  515. return "<html>"+document.getElementsByTagName("HTML")[0].innerHTML+"</html>";
  516. }
  517. //Process XML xajaxResponses returned from the request
  518. this.processResponse = function(xml)
  519. {
  520. clearTimeout(loadingTimeout);
  521. this.doneLoadingFunction();
  522. if (xajaxStatusMessages == true) window.status = 'Processing...';
  523. var tmpXajax = null;
  524. xml = xml.documentElement;
  525. if (xml == null)
  526. return;
  527. var skipCommands = 0;
  528. for (var i=0; i<xml.childNodes.length; i++)
  529. {
  530. if (skipCommands > 0) {
  531. skipCommands--;
  532. continue;
  533. }
  534. if (xml.childNodes[i].nodeName == "cmd")
  535. {
  536. var cmd;
  537. var id;
  538. var property;
  539. var data;
  540. var search;
  541. var type;
  542. var before;
  543. var objElement = null;
  544. for (var j=0; j<xml.childNodes[i].attributes.length; j++)
  545. {
  546. if (xml.childNodes[i].attributes[j].name == "n")
  547. {
  548. cmd = xml.childNodes[i].attributes[j].value;
  549. }
  550. else if (xml.childNodes[i].attributes[j].name == "t")
  551. {
  552. id = xml.childNodes[i].attributes[j].value;
  553. }
  554. else if (xml.childNodes[i].attributes[j].name == "p")
  555. {
  556. property = xml.childNodes[i].attributes[j].value;
  557. }
  558. else if (xml.childNodes[i].attributes[j].name == "c")
  559. {
  560. type = xml.childNodes[i].attributes[j].value;
  561. }
  562. }
  563. if (xml.childNodes[i].childNodes.length > 1 && xml.childNodes[i].firstChild.nodeName == "#cdata-section")
  564. {
  565. data = "";
  566. for (var j=0; j<xml.childNodes[i].childNodes.length; j++)
  567. {
  568. data += xml.childNodes[i].childNodes[j].data;
  569. }
  570. }
  571. else if (xml.childNodes[i].firstChild && xml.childNodes[i].firstChild.nodeName == 'xjxobj') {
  572. data = this._nodeToObject(xml.childNodes[i].firstChild);
  573. objElement = "XJX_SKIP";
  574. }
  575. else if (xml.childNodes[i].childNodes.length > 1)
  576. {
  577. for (var j=0; j<xml.childNodes[i].childNodes.length; j++)
  578. {
  579. if (xml.childNodes[i].childNodes[j].childNodes.length > 1 && xml.childNodes[i].childNodes[j].firstChild.nodeName == "#cdata-section")
  580. {
  581. var internalData = "";
  582. for (var k=0; k<xml.childNodes[i].childNodes[j].childNodes.length;k++)
  583. {
  584. internalData+=xml.childNodes[i].childNodes[j].childNodes[k].nodeValue;
  585. }
  586. } else {
  587. var internalData = xml.childNodes[i].childNodes[j].firstChild.nodeValue;
  588. }
  589. if (xml.childNodes[i].childNodes[j].nodeName == "s")
  590. {
  591. search = internalData;
  592. }
  593. if (xml.childNodes[i].childNodes[j].nodeName == "r")
  594. {
  595. data = internalData;
  596. }
  597. }
  598. }
  599. else if (xml.childNodes[i].firstChild)
  600. data = xml.childNodes[i].firstChild.nodeValue;
  601. else
  602. data = "";
  603. if (objElement != "XJX_SKIP") objElement = this.$(id);
  604. var cmdFullname;
  605. try
  606. {
  607. if (cmd=="cc") {
  608. cmdFullname = "addConfirmCommands";
  609. var confirmResult = confirm(data);
  610. if (!confirmResult) {
  611. skipCommands = id;
  612. }
  613. }
  614. if (cmd=="al")
  615. {
  616. cmdFullname = "addAlert";
  617. alert(data);
  618. }
  619. else if (cmd=="js")
  620. {
  621. cmdFullname = "addScript/addRedirect";
  622. eval(data);
  623. }
  624. else if (cmd=="jc")
  625. {
  626. cmdFullname = "addScriptCall";
  627. var scr = id + '(';
  628. if (data[0] != null) {
  629. scr += 'data[0]';
  630. for (var l=1; l<data.length; l++) {
  631. scr += ',data['+l+']';
  632. }
  633. }
  634. scr += ');';
  635. eval(scr);
  636. }
  637. else if (cmd=="in")
  638. {
  639. cmdFullname = "addIncludeScript";
  640. this.include(data);
  641. }
  642. else if (cmd=="as")
  643. {
  644. cmdFullname = "addAssign/addClear";
  645. if (this.willChange(id,property,data))
  646. {
  647. eval("objElement."+property+"=data;");
  648. }
  649. }
  650. else if (cmd=="ap")
  651. {
  652. cmdFullname = "addAppend";
  653. eval("objElement."+property+"+=data;");
  654. }
  655. else if (cmd=="pp")
  656. {
  657. cmdFullname = "addPrepend";
  658. eval("objElement."+property+"=data+objElement."+property);
  659. }
  660. else if (cmd=="rp")
  661. {
  662. cmdFullname = "addReplace";
  663. this.replace(id,property,search,data)
  664. }
  665. else if (cmd=="rm")
  666. {
  667. cmdFullname = "addRemove";
  668. this.remove(id);
  669. }
  670. else if (cmd=="ce")
  671. {
  672. cmdFullname = "addCreate";
  673. this.create(id,data,property);
  674. }
  675. else if (cmd=="ie")
  676. {
  677. cmdFullname = "addInsert";
  678. this.insert(id,data,property);
  679. }
  680. else if (cmd=="ia")
  681. {
  682. cmdFullname = "addInsertAfter";
  683. this.insertAfter(id,data,property);
  684. }
  685. else if (cmd=="ci")
  686. {
  687. cmdFullname = "addCreateInput";
  688. this.createInput(id,type,data,property);
  689. }
  690. else if (cmd=="ii")
  691. {
  692. cmdFullname = "addInsertInput";
  693. this.insertInput(id,type,data,property);
  694. }
  695. else if (cmd=="iia")
  696. {
  697. cmdFullname = "addInsertInputAfter";
  698. this.insertInputAfter(id,type,data,property);
  699. }
  700. else if (cmd=="ev")
  701. {
  702. cmdFullname = "addEvent";
  703. property = this.addOnPrefix(property);
  704. eval("this.$('"+id+"')."+property+"= function(){"+data+";}");
  705. }
  706. else if (cmd=="ah")
  707. {
  708. cmdFullname = "addHandler";
  709. this.addHandler(id, property, data);
  710. }
  711. else if (cmd=="rh")
  712. {
  713. cmdFullname = "addRemoveHandler";
  714. this.removeHandler(id, property, data);
  715. }
  716. }
  717. catch(e)
  718. {
  719. if (xajaxDebug)
  720. alert("While trying to '"+cmdFullname+"' (command number "+i+"), the following error occured:\n"
  721. + e.name+": "+e.message+"\n"
  722. + (id&&!objElement?"Object with id='"+id+"' wasn't found.\n":""));
  723. }
  724. delete objElement;
  725. delete cmd;
  726. delete cmdFullname;
  727. delete id;
  728. delete property;
  729. delete search;
  730. delete data;
  731. delete type;
  732. delete before;
  733. delete internalData;
  734. delete j;
  735. delete k;
  736. }
  737. }
  738. delete xml;
  739. delete i;
  740. document.body.style.cursor = 'default';
  741. if (xajaxStatusMessages == true) window.status = 'Done';
  742. }
  743. }
  744. var xajax = new Xajax();
  745. xajaxLoaded = true;