fork(1) download
  1.  
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  3. "http://w...content-available-to-author-only...3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <html xmlns="http://w...content-available-to-author-only...3.org/1999/xhtml">
  5. <head>
  6. <!-- This is header file for main pages. -->
  7. <title>USATestprep, Inc. - Online State-Specific Review and Benchmark Testing</title>
  8.  
  9. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  10.  
  11. <link href="/css/main.css" rel="stylesheet" type="text/css" />
  12. <!--[if lte ie 7]>
  13. <link href="/css/main_ie6.css" rel="stylesheet" type="text/css" />
  14. <![endif]-->
  15. <!--[if IE 7]>
  16. <link href="/css/main_ie7.css" rel="stylesheet" type="text/css" />
  17. <![endif]-->
  18. <link rel="stylesheet" type="text/css" href="/css/smoothness/jquery-ui-1.7.1.custom.css" />
  19. <link rel="Shortcut Icon" href="/favicon.ico" />
  20.  
  21. <script language="JavaScript" type="text/javascript" src="/js/flash8.js"></script>
  22.  
  23. <script language="JavaScript" type="text/javascript" src="/js/jquery-1.3.2.min.js"></script>
  24. <script language="JavaScript" type="text/javascript" src="/js/jquery-ui-1.7.1.custom.min.js"></script>
  25. <script language="JavaScript" type="text/javascript" src="/js/_jquery_plugins/json/jquery.json.min.js"></script>
  26.  
  27. <script type="text/javascript">
  28. var iframe_form_submitted = false;
  29. jQuery(document).ready(function(){
  30. //jQuery.noConflict();
  31.  
  32. createModal('modal_page');
  33. createModal('modal_test_info');
  34.  
  35. if(jQuery('#test_info_link'))
  36. {
  37. jQuery('#test_info_link').click(function(){
  38. jQuery('#modal_test_info').dialog("open");
  39. });
  40. }
  41.  
  42.  
  43. if(!jQuery.support.leadingWhitespace){
  44. jQuery('#top_nav ul li').hover(
  45. function(){
  46. jQuery(this).children('ul').css('left','auto');
  47.  
  48. },
  49. function(){
  50. jQuery(this).children('ul').css('left','-999');
  51. }
  52. //alert($(this).children('ul').html());
  53. )
  54.  
  55.  
  56. jQuery('#top_nav ul li ul li').hover(
  57. function(){
  58. jQuery(this).css('background-color','#d05197');
  59. },
  60. function(){
  61. jQuery(this).css('background-color','#ececec');
  62. }
  63. );
  64. }
  65.  
  66. function QSMouseOver()
  67. {
  68. if(!jQuery(this).hasClass("question_selection_eliminated"))
  69. {
  70. jQuery(this).addClass("question_selection_hover");
  71. jQuery(this).children("td:first").addClass("question_selection_pink_bar");
  72. if(!jQuery(this).children("td").children("input[type=radio]").attr("checked"))
  73. {
  74. jQuery(this).children("td:first").css("background-color","#ececec");
  75. jQuery(this).children("td").children(".question_er").show();
  76. }
  77. }
  78. }
  79.  
  80. function QSMouseOut()
  81. {
  82. jQuery(this).removeClass("question_selection_hover");
  83. jQuery(this).children("td:first").removeClass("question_selection_pink_bar");
  84. if(!jQuery(this).children("td").children("input[type=radio]").attr("checked"))
  85. jQuery(this).children("td:first").css("background-color","");
  86. if(!jQuery(this).hasClass("question_selection_eliminated"))
  87. jQuery(this).children("td").children(".question_er").hide();
  88. }
  89.  
  90. function QSClick()
  91. {
  92. if(!jQuery(this).hasClass("question_selection_eliminated") && !jQuery(this).hasClass("question_selection_noclick"))
  93. {
  94. jQuery(this).siblings().removeClass("question_selection_click");
  95. jQuery(this).addClass("question_selection_click");
  96.  
  97. jQuery(this).siblings().children("td").removeClass("question_selection_pink_bar");
  98. jQuery(this).siblings().children("td").css("background-color","");
  99. jQuery(this).children("td:first").css("background-color","#cfe4f9");
  100. // i cant tell you how much i hate internet explorer 6
  101. jQuery(this).children("td").children("input[type=radio]").attr("checked", "checked");
  102.  
  103. jQuery(this).children("td").children(".question_er").hide();
  104.  
  105. if(!iframe_form_submitted && getObject("iframe_form"))
  106. {
  107. iframe_form_submitted = true;
  108. if(getObject("iframe"))
  109. getObject("iframe").onload = function () { setTimeout("iframe_form_submitted = false", 1000) };
  110. setTimeout("iframe_form_submitted = false", 2000);
  111. if(!getObject("iframe_form").onsubmit || getObject("iframe_form").onsubmit())
  112. {
  113. getObject("iframe_form").onsubmit = function () { return false };
  114. getObject("iframe_form").submit();
  115. }
  116. }
  117. }
  118.  
  119. jQuery(this).removeClass("question_selection_noclick");
  120. }
  121.  
  122. jQuery(".question_selection").live("mouseover", QSMouseOver);
  123. jQuery(".question_selection").live("mouseout", QSMouseOut);
  124. jQuery(".question_selection").live("click", QSClick);
  125.  
  126. jQuery(".question_eliminate").live("click", function(e){
  127. jQuery(this).parents(".question_selection").addClass("question_selection_eliminated");
  128. jQuery(this).parents(".question_selection").children("td").children("input[type=radio]").attr("checked", false);
  129. jQuery(this).siblings(".eliminated_answers").val('1');
  130. jQuery(this).hide();
  131. jQuery(this).siblings(".question_reactivate").show();
  132. jQuery(this).parents(".question_selection").trigger("mouseout");
  133.  
  134. return false;
  135. });
  136.  
  137. jQuery(".question_reactivate").live("click", function(e){
  138. jQuery(this).parents(".question_selection").removeClass("question_selection_eliminated");
  139. jQuery(this).parents(".question_selection").addClass("question_selection_noclick");
  140. jQuery(this).siblings(".eliminated_answers").val('0');
  141. jQuery(this).hide();
  142. jQuery(this).siblings(".question_eliminate").show();
  143.  
  144. return false;
  145. });
  146.  
  147. jQuery(".answer_sa").live("click", function(){
  148. doOnEnter(function(){
  149. if(getObject("iframe_form") && (!getObject("iframe_form").onsubmit || getObject("iframe_form").onsubmit()))
  150. {
  151. getObject("iframe_form").onsubmit = function () { return false };
  152. getObject("iframe_form").submit();
  153. }
  154. }, event);
  155. });
  156.  
  157. if(is_ie && !is_ie8up)
  158. {
  159. jQuery(".ent_ang").html("&#208;");
  160. jQuery(".ent_ang").css("font-family", "Symbol");
  161. }
  162. });
  163. </script>
  164.  
  165.  
  166. <script language="JavaScript" type="text/javascript" src="/js/scriptaculous/scriptaculous.js?load=effects"></script>
  167. <script language="JavaScript" type="text/JavaScript">
  168.  
  169. /*********************************************
  170. Start of /js/ajax.js
  171. *********************************************/
  172. // Compat.js
  173. /**
  174. * Compat functions
  175. * @category HTML
  176. * @package AJAX
  177. * @author Joshua Eichorn <josh@bluga.net>
  178. * @copyright 2005 Joshua Eichorn
  179. * @license http://w...content-available-to-author-only...e.org/licenses/lgpl-license.php LGPL
  180. */
  181. /**
  182. * Functions for compatibility with older browsers
  183. */
  184. if(!String.fromCharCode&&!String.prototype.fromCharCode){String.prototype.fromCharCode=function(code){var h=code.toString(16);if(h.length==1){h='0'+h}return unescape('%'+h)}}if(!String.charCodeAt&&!String.prototype.charCodeAt){String.prototype.charCodeAt=function(index){var c=this.charAt(index);for(i=1;i<256;i++){if(String.fromCharCode(i)==c){return i}}}}if(!Array.splice&&!Array.prototype.splice){Array.prototype.splice=function(s,d){var max=Math.max,min=Math.min,a=[],e,i=max(arguments.length-2,0),k=0,l=this.length,n,v,x;s=s||0;if(s<0){s+=l}s=max(min(s,l),0);d=max(min(typeof d=='number'?d:l,l-s),0);v=i-d;n=l+v;while(k<d){e=this[s+k];if(!e){a[k]=e}k+=1}x=l-s-d;if(v<0){k=s+i;while(x){this[k]=this[k-v];k+=1;x-=1}this.length=n}else if(v>0){k=1;while(x){this[n-k]=this[l-k];k+=1;x-=1}}for(k=0;k<i;++k){this[s+k]=arguments[k+2]}return a}}if(!Array.push&&!Array.prototype.push){Array.prototype.push=function(){for(var i=0,startLength=this.length;i<arguments.length;i++){this[startLength+i]=arguments[i]}return this.length}}if(!Array.pop&&!Array.prototype.pop){Array.prototype.pop=function(){return this.splice(this.length-1,1)[0]}}if(window.ActiveXObject&&window['DOMParser']=='undefined'){window.DOMParser=new function(){};DOMParser.prototype={parseFromString:function(str,contentType){var xmlDocument=new ActiveXObject('Microsoft.XMLDOM');xmlDocument.loadXML(str);return xmlDocument}};window.XMLSerializer=new function(){};XMLSerializer.prototype={serializeToString:function(root){return root.xml||root.outerHTML}}}
  185. // Main.js
  186. /**
  187. * JavaScript library for use with HTML_AJAX
  188. *
  189. * This library is free software; you can redistribute it and/or
  190. * modify it under the terms of the GNU Lesser General Public
  191. * License as published by the Free Software Foundation; either
  192. * version 2.1 of the License, or (at your option) any later version.
  193. *
  194. * This library is distributed in the hope that it will be useful,
  195. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  196. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  197. * Lesser General Public License for more details.
  198. *
  199. * You should have received a copy of the GNU Lesser General Public
  200. * License along with this library; if not, write to:
  201. * Free Software Foundation, Inc.,
  202. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  203. *
  204. * @category HTML
  205. * @package Ajax
  206. * @author Joshua Eichorn <josh@bluga.net>
  207. * @author Arpad Ray <arpad@php.net>
  208. * @author David Coallier <davidc@php.net>
  209. * @author Elizabeth Smith <auroraeosrose@gmail.com>
  210. * @copyright 2005 Joshua Eichorn, Arpad Ray, David Coallier, Elizabeth Smith
  211. * @license http://w...content-available-to-author-only...e.org/licenses/lgpl-license.php LGPL
  212. */
  213.  
  214. /**
  215. * HTML_AJAX static methods, this is the main proxyless api, it also handles global error and event handling
  216. */
  217. var HTML_AJAX = {
  218. version: '0.5.6',
  219. defaultServerUrl: false,
  220. defaultEncoding: 'JSON',
  221. queues: false,
  222. clientPools: {},
  223. // get an HttpClient, supply a name to use the pool of that name or the default if it isn't found
  224. httpClient: function(name) {
  225. if (name) {
  226. if (this.clientPools[name]) {
  227. return this.clientPools[name].getClient();
  228. }
  229. }
  230. return this.clientPools['default'].getClient();
  231. },
  232. // Pushing the given request to queue specified by it, in default operation this will immediately make a request
  233. // request might be delayed or never happen depending on the queue setup
  234. // making a sync request to a non immediate queue will cause you problems so just don't do it
  235. makeRequest: function(request) {
  236. if (!HTML_AJAX.queues[request.queue]) {
  237. var e = new Error('Unknown Queue: '+request.queue);
  238. if (HTML_AJAX.onError) {
  239. HTML_AJAX.onError(e);
  240. return false;
  241. }
  242. else {
  243. throw(e);
  244. }
  245. }
  246. else {
  247. var qn = request.queue;
  248. var q = HTML_AJAX.queues[qn];
  249.  
  250. HTML_AJAX.queues[request.queue].addRequest(request);
  251. return HTML_AJAX.queues[request.queue].processRequest();
  252. }
  253. },
  254. // get a serializer object for a specific encoding
  255. serializerForEncoding: function(encoding) {
  256. for(var i in HTML_AJAX.contentTypeMap) {
  257. if (encoding == HTML_AJAX.contentTypeMap[i] || encoding == i) {
  258. return eval("new HTML_AJAX_Serialize_"+i+";");
  259. }
  260. }
  261. return new HTML_AJAX_Serialize_Null();
  262. },
  263. fullcall: function(url,encoding,className,method,callback,args, options) {
  264. var serializer = HTML_AJAX.serializerForEncoding(encoding);
  265.  
  266. var request = new HTML_AJAX_Request(serializer);
  267. if (callback) {
  268. request.isAsync = true;
  269. }
  270. request.requestUrl = url;
  271. request.className = className;
  272. request.methodName = method;
  273. request.callback = callback;
  274. request.args = args;
  275. if (options) {
  276. for(var i in options) {
  277. request[i] = options[i];
  278. }
  279. if (options.grab) {
  280. if (!request.args || !request.args.length) {
  281. request.requestType = 'GET';
  282. }
  283. }
  284. }
  285.  
  286. return HTML_AJAX.makeRequest(request);
  287. },
  288. callPhpCallback: function(phpCallback, jsCallback, url) {
  289. var args = new Array();
  290. for (var i = 3; i < arguments.length; i++) {
  291. args.push(arguments[i]);
  292. }
  293. if (HTML_AJAX_Util.getType(phpCallback[0]) == 'object') {
  294. jsCallback(phpCallback[0][phpCallback[1]](args));
  295. return;
  296. }
  297. if (!url) {
  298. url = HTML_AJAX.defaultServerUrl;
  299. }
  300. HTML_AJAX.fullcall(url, HTML_AJAX.defaultEncoding,
  301. false, false, jsCallback, args, {phpCallback: phpCallback});
  302. },
  303. call: function(className,method,callback) {
  304. var args = new Array();
  305. for(var i = 3; i < arguments.length; i++) {
  306. args.push(arguments[i]);
  307. }
  308. return HTML_AJAX.fullcall(HTML_AJAX.defaultServerUrl,HTML_AJAX.defaultEncoding,className,method,callback,args);
  309. },
  310. grab: function(url,callback,options) {
  311. if (!options) {
  312. options = {grab:true};
  313. }
  314. else {
  315. options['grab'] = true;
  316. }
  317. return HTML_AJAX.fullcall(url,'Null',false,null,callback, '', options);
  318. },
  319. post: function(url,payload,callback,options) {
  320. var serializer = 'Null';
  321. if (HTML_AJAX_Util.getType(payload) == 'object') {
  322. serializer = 'Urlencoded';
  323. }
  324. return HTML_AJAX.fullcall(url,serializer,false,null,callback, payload, options);
  325. },
  326. replace: function(id) {
  327. var callback = function(result) {
  328. HTML_AJAX_Util.setInnerHTML(HTML_AJAX_Util.getElement(id),result);
  329. }
  330. if (arguments.length == 2) {
  331. // grab replacement
  332. HTML_AJAX.grab(arguments[1],callback);
  333. }
  334. else {
  335. // call replacement
  336. var args = new Array();
  337. for(var i = 3; i < arguments.length; i++) {
  338. args.push(arguments[i]);
  339. }
  340. HTML_AJAX.fullcall(HTML_AJAX.defaultServerUrl,HTML_AJAX.defaultEncoding,arguments[1],arguments[2],callback,args, {grab:true});
  341. }
  342. },
  343. append: function(id) {
  344. var callback = function(result) {
  345. HTML_AJAX_Util.setInnerHTML(HTML_AJAX_Util.getElement(id),result,'append');
  346. }
  347. if (arguments.length == 2) {
  348. // grab replacement
  349. HTML_AJAX.grab(arguments[1],callback);
  350. }
  351. else {
  352. // call replacement
  353. var args = new Array();
  354. for(var i = 3; i < arguments.length; i++) {
  355. args.push(arguments[i]);
  356. }
  357. HTML_AJAX.fullcall(HTML_AJAX.defaultServerUrl,HTML_AJAX.defaultEncoding,arguments[1],arguments[2],callback,args, {grab:true});
  358. }
  359. },
  360. // override to add top level loading notification (start)
  361. Open: function(request) {
  362. },
  363. // override to add top level loading notification (finish)
  364. Load: function(request) {
  365. },
  366. /*
  367. // A really basic error handler
  368. onError: function(e) {
  369. msg = "";
  370. for(var i in e) {
  371. msg += i+':'+e[i]+"\n";
  372. }
  373. alert(msg);
  374. },
  375. */
  376. // Class postfix to content-type map
  377. contentTypeMap: {
  378. 'JSON': 'application/json',
  379. 'Null': 'text/plain',
  380. 'Error': 'application/error',
  381. 'PHP': 'application/php-serialized',
  382. 'HA' : 'application/html_ajax_action',
  383. 'Urlencoded': 'application/x-www-form-urlencoded'
  384. },
  385. // used internally to make queues work, override Load or onError to perform custom events when a request is complete
  386. // fires on success and error
  387. requestComplete: function(request,error) {
  388. for(var i in HTML_AJAX.queues) {
  389. if (HTML_AJAX.queues[i].requestComplete) {
  390. HTML_AJAX.queues[i].requestComplete(request,error);
  391. }
  392. }
  393. },
  394.  
  395. // turns a form into a urlencoded string
  396. formEncode: function(form, array_format) {
  397. form = HTML_AJAX_Util.getElement(form);
  398. var el, inpType, value, name;
  399. var out = (array_format) ? {} : '';
  400. var inputTags = form.getElementsByTagName('INPUT');
  401. var selectTags = form.getElementsByTagName('SELECT');
  402. var buttonTags = form.getElementsByTagName('BUTTON');
  403. var textareaTags = form.getElementsByTagName('TEXTAREA');
  404. var arrayRegex = /(.+)%5B%5D/;
  405.  
  406. var validElement = function (element) {
  407. if (!element || !element.getAttribute) {
  408. return false;
  409. }
  410. el = element;
  411. name = HTML_AJAX_Util.encodeUrl(el.getAttribute('name'));
  412. if (!name) {
  413. // no element name so skip
  414. return false;
  415. }
  416. if (element.disabled) {
  417. return false;
  418. }
  419.  
  420. if (!array_format) {
  421. value = HTML_AJAX_Util.encodeUrl(el.value);
  422. } else {
  423. value = el.value;
  424. }
  425.  
  426. inpType = el.getAttribute('type');
  427. return true;
  428. }
  429.  
  430. inputLoop:
  431. for (var i=0; i < inputTags.length; i++) {
  432. if (!validElement(inputTags[i])) {
  433. continue;
  434. }
  435. if (inpType == 'checkbox' || inpType == 'radio') {
  436. if (!el.checked) {
  437. // unchecked radios/checkboxes don't get submitted
  438. continue inputLoop;
  439. }
  440. var arr_var = arrayRegex.exec(name);
  441. if (array_format && arr_var) {
  442. if (!out[arr_var[1]]) {
  443. out[arr_var[1]] = new Array();
  444. }
  445. out[arr_var[1]].push(value);
  446. continue inputLoop;
  447. }
  448. }
  449. // add element to output array
  450. if (array_format) {
  451. out[name] = value;
  452. } else {
  453. out += name + '=' + value + '&';
  454. }
  455. } // end inputLoop
  456.  
  457. selectLoop:
  458. for (var i=0; i<selectTags.length; i++) {
  459. if (!validElement(selectTags[i])) {
  460. continue selectLoop;
  461. }
  462. var options = el.options;
  463. for (var z=0; z<options.length; z++){
  464. var option=options[z];
  465. if(option.selected){
  466. if (array_format) {
  467. if (el.type == 'select-one') {
  468. out[name] = option.value;
  469. //only one item can be selected
  470. continue selectLoop;
  471. } else {
  472. if (!out[name]) {
  473. out[name] = new Array();
  474. }
  475. out[name].push(option.value);
  476. }
  477. } else {
  478. out += name + '=' + option.value + '&';
  479. if (el.type == 'select-one') {
  480. continue selectLoop;
  481. }
  482. }
  483. }
  484. }
  485. } // end selectLoop
  486.  
  487. buttonLoop:
  488. for (var i=0; i<buttonTags.length; i++) {
  489. if (!validElement(buttonTags[i])) {
  490. continue;
  491. }
  492. // add element to output array
  493. if (array_format) {
  494. out[name] = value;
  495. } else {
  496. out += name + '=' + value + '&';
  497. }
  498. } // end buttonLoop
  499.  
  500. textareaLoop:
  501. for (var i=0; i<textareaTags.length; i++) {
  502. if (!validElement(textareaTags[i])) {
  503. continue;
  504. }
  505. // add element to output array
  506. if (array_format) {
  507. out[name] = value;
  508. } else {
  509. out += name + '=' + value + '&';
  510. }
  511. } // end textareaLoop
  512.  
  513. return out;
  514. },
  515. // submits a form through ajax. both arguments can be either DOM nodes or IDs, if the target is omitted then the form is set to be the target
  516. formSubmit: function (form, target, options)
  517. {
  518. form = HTML_AJAX_Util.getElement(form);
  519. if (!form) {
  520. // let the submit be processed normally
  521. return false;
  522. }
  523.  
  524. var out = HTML_AJAX.formEncode(form);
  525. target = HTML_AJAX_Util.getElement(target);
  526. if (!target) {
  527. target = form;
  528. }
  529. try
  530. {
  531. var action = form.attributes['action'].value;
  532. }
  533. catch(e){}
  534. if(action == undefined)
  535. {
  536. action = form.getAttribute('action');
  537. }
  538.  
  539. var callback = false;
  540. if (HTML_AJAX_Util.getType(target) == 'function') {
  541. callback = target;
  542. }
  543. else {
  544. callback = function(result) {
  545. // result will be undefined if HA_Action is returned, so skip the replace
  546. if (typeof result != 'undefined') {
  547. HTML_AJAX_Util.setInnerHTML(target,result);
  548. }
  549. }
  550. }
  551.  
  552. var serializer = HTML_AJAX.serializerForEncoding('Null');
  553. var request = new HTML_AJAX_Request(serializer);
  554. request.isAsync = true;
  555. request.callback = callback;
  556.  
  557. switch (form.getAttribute('method').toLowerCase()) {
  558. case 'post':
  559. var headers = {};
  560. headers['Content-Type'] = 'application/x-www-form-urlencoded';
  561. request.customHeaders = headers;
  562. request.requestType = 'POST';
  563. request.requestUrl = action;
  564. request.args = out;
  565. break;
  566. default:
  567. if (action.indexOf('?') == -1) {
  568. out = '?' + out.substr(0, out.length - 1);
  569. }
  570. request.requestUrl = action+out;
  571. request.requestType = 'GET';
  572. }
  573.  
  574. if(options) {
  575. for(var i in options) {
  576. request[i] = options[i];
  577. }
  578. }
  579.  
  580. if (request.isAsync == false) {
  581. return HTML_AJAX.makeRequest(request);
  582. }
  583. else {
  584. HTML_AJAX.makeRequest(request);
  585. return true;
  586. }
  587. }, // end formSubmit()
  588. makeFormAJAX: function(form,target,options) {
  589. form = HTML_AJAX_Util.getElement(form);
  590. var preSubmit = false;
  591. if(typeof form.onsubmit != 'undefined') {
  592. preSubmit = form.onsubmit;
  593. form.onsubmit = function() {};
  594. }
  595. form.HAOptions = options;
  596. var handler = function(e) {
  597. var form = HTML_AJAX_Util.eventTarget(e);
  598.  
  599. var valid = true;
  600. if (preSubmit) {
  601. valid = preSubmit();
  602. }
  603. if (valid) {
  604. HTML_AJAX.formSubmit(form,target,form.HAOptions);
  605. }
  606. // cancel submission in IE
  607. e.returnValue = false;
  608. // cancel submission in FF
  609. if (e.preventDefault) {
  610. e.preventDefault();
  611. }
  612. }
  613. HTML_AJAX_Util.registerEvent(form,'submit',handler);
  614. }
  615. }
  616.  
  617. // small classes that I don't want to put in there own file
  618.  
  619. function HTML_AJAX_Serialize_Null() {}
  620. HTML_AJAX_Serialize_Null.prototype = {
  621. contentType: 'text/plain; charset=utf-8',
  622. serialize: function(input) {
  623. return new String(input).valueOf();
  624. },
  625.  
  626. unserialize: function(input) {
  627. return new String(input).valueOf();
  628. }
  629. }
  630.  
  631. function HTML_AJAX_Serialize_XML() {}
  632. HTML_AJAX_Serialize_XML.prototype = {
  633. contentType: 'application/xml; charset=utf-8',
  634. serialize: function(input) {
  635. var xml = '';
  636. if(typeof(input) == 'object' && input)
  637. {
  638. for (var i = 0;i<input.length;i++)
  639. {
  640. xml += new XMLSerializer().serializeToString(input[i]);
  641. }
  642. }
  643. return xml;
  644. },
  645.  
  646. unserialize: function(input) {
  647. return input;
  648. }
  649. }
  650.  
  651. // serialization class for JSON, wrapper for JSON.stringify in json.js
  652. function HTML_AJAX_Serialize_JSON() {}
  653. HTML_AJAX_Serialize_JSON.prototype = {
  654. contentType: 'application/json; charset=utf-8',
  655. serialize: function(input) {
  656. return HTML_AJAX_JSON.stringify(input);
  657. },
  658. unserialize: function(input) {
  659. try {
  660. return eval('('+input+')');
  661. } catch(e) {
  662. // sometimes JSON encoded input isn't created properly, if eval of it fails we use the more forgiving but slower parser so will at least get something
  663. return HTML_AJAX_JSON.parse(input);
  664. }
  665. }
  666. }
  667.  
  668. function HTML_AJAX_Serialize_Error() {}
  669. HTML_AJAX_Serialize_Error.prototype = {
  670. contentType: 'application/error; charset=utf-8',
  671. serialize: function(input) {
  672. var ser = new HTML_AJAX_Serialize_JSON();
  673. return ser.serialize(input);
  674. },
  675. unserialize: function(input) {
  676. var ser = new HTML_AJAX_Serialize_JSON();
  677. var data = new ser.unserialize(input);
  678.  
  679. var e = new Error('PHP Error: '+data.errStr);
  680. for(var i in data) {
  681. e[i] = data[i];
  682. }
  683. throw e;
  684. }
  685. }
  686.  
  687. // Processing Queues
  688.  
  689. // simple queue, just processes the request immediately
  690. function HTML_AJAX_Queue_Immediate() {}
  691. HTML_AJAX_Queue_Immediate.prototype = {
  692. request: false,
  693. addRequest: function(request) {
  694. this.request = request;
  695. },
  696. processRequest: function() {
  697. var client = HTML_AJAX.httpClient();
  698. client.request = this.request;
  699. return client.makeRequest();
  700. }
  701. }
  702.  
  703.  
  704.  
  705. // create a default queue, has to happen after the Queue class has been defined
  706. HTML_AJAX.queues = new Object();
  707. HTML_AJAX.queues['default'] = new HTML_AJAX_Queue_Immediate();
  708.  
  709. // Queue.js
  710. /**
  711. * Various processing queues, use when you want to control how multiple requests are made
  712. * @category HTML
  713. * @package AJAX
  714. * @author Joshua Eichorn <josh@bluga.net>
  715. * @copyright 2005 Joshua Eichorn
  716. * @license http://w...content-available-to-author-only...e.org/licenses/lgpl-license.php LGPL
  717. */
  718.  
  719. // Single Buffer queue with interval
  720. // works by attempting to send a request every x miliseconds
  721. // if an item is currently in the queue when a new item is added it will be replaced
  722. // simple queue, just processes the request immediately
  723. // the first request starts the interval timer
  724. function HTML_AJAX_Queue_Interval_SingleBuffer(interval,singleOutstandingRequest) {
  725. this.interval = interval;
  726. if (singleOutstandingRequest) {
  727. this.singleOutstandingRequest = true;
  728. }
  729. }
  730. HTML_AJAX_Queue_Interval_SingleBuffer.prototype = {
  731. request: false,
  732. _intervalId: false,
  733. singleOutstandingRequest: false,
  734. client: false,
  735. addRequest: function(request) {
  736. this.request = request;
  737. },
  738. processRequest: function() {
  739. if (!this._intervalId) {
  740. this.runInterval();
  741. this.start();
  742. }
  743. },
  744. start: function() {
  745. var self = this;
  746. this._intervalId = setInterval(function() { self.runInterval() },this.interval);
  747. },
  748. stop: function() {
  749. clearInterval(this._intervalId);
  750. },
  751. runInterval: function() {
  752. if (this.request) {
  753. if (this.singleOutstandingRequest && this.client) {
  754. this.client.abort();
  755. }
  756. this.client = HTML_AJAX.httpClient();
  757. this.client.request = this.request;
  758. this.request = false;
  759. this.client.makeRequest();
  760. }
  761. }
  762. }
  763.  
  764. // Requests return in the same order they were called
  765. // this helps handle high latency situations
  766. function HTML_AJAX_Queue_Ordered() { }
  767. HTML_AJAX_Queue_Ordered.prototype = {
  768. request: false,
  769. order: 0,
  770. current: 0,
  771. callbacks: {},
  772. interned: {},
  773. addRequest: function(request) {
  774. request.order = this.order;
  775. this.request = request;
  776. this.callbacks[this.order] = this.request.callback;
  777. var self = this;
  778. this.request.callback = function(result) {
  779. self.processCallback(result,request.order);
  780. }
  781. },
  782. processRequest: function() {
  783. var client = HTML_AJAX.httpClient();
  784. client.request = this.request;
  785. client.makeRequest();
  786. this.order++;
  787. },
  788. requestComplete: function(request,e) {
  789. // something when wrong with the request lets stop waiting for it
  790. if (e) {
  791. this.current++;
  792. }
  793. },
  794. processCallback: function(result,order) {
  795. if (order == this.current) {
  796. this.callbacks[order](result);
  797. this.current++;
  798. }
  799. else {
  800. this.interned[order] = result;
  801. }
  802. while (this.interned[this.current]) {
  803. this.callbacks[this.current](this.interned[this.current]);
  804. this.current++;
  805. }
  806. }
  807. }
  808.  
  809. // Make a single request at once, canceling and currently outstanding requests when a new one is made
  810. function HTML_AJAX_Queue_Single() {
  811. }
  812. HTML_AJAX_Queue_Single.prototype = {
  813. request: false,
  814. client: false,
  815. addRequest: function(request) {
  816. this.request = request;
  817. },
  818. processRequest: function() {
  819. if (this.request) {
  820. if (this.client) {
  821. this.client.abort();
  822. }
  823. this.client = HTML_AJAX.httpClient();
  824. this.client.request = this.request;
  825. this.request = false;
  826. this.client.makeRequest();
  827. }
  828. }
  829. }
  830.  
  831. /**
  832. * Priority queue
  833. *
  834. * @author Arpad Ray <arpad@php.net>
  835. */
  836. function HTML_AJAX_Queue_Priority_Item(item, time) {
  837. this.item = item;
  838. this.time = time;
  839. }
  840. HTML_AJAX_Queue_Priority_Item.prototype = {
  841. compareTo: function (other) {
  842. var ret = this.item.compareTo(other.item);
  843. if (ret == 0) {
  844. ret = this.time - other.time;
  845. }
  846. return ret;
  847. }
  848. }
  849.  
  850. function HTML_AJAX_Queue_Priority_Simple(interval) {
  851. this.interval = interval;
  852. this.idleMax = 10; // keep the interval going with an empty queue for 10 intervals
  853. this.requestTimeout = 5; // retry uncompleted requests after 5 seconds
  854. this.checkRetryChance = 0.1; // check for uncompleted requests to retry on 10% of intervals
  855. this._intervalId = 0;
  856. this._requests = [];
  857. this._removed = [];
  858. this._len = 0;
  859. this._removedLen = 0;
  860. this._idle = 0;
  861. }
  862. HTML_AJAX_Queue_Priority_Simple.prototype = {
  863. isEmpty: function () {
  864. return this._len == 0;
  865. },
  866. addRequest: function (request) {
  867. request = new HTML_AJAX_Queue_Priority_Item(request, new Date().getTime());
  868. ++this._len;
  869. if (this.isEmpty()) {
  870. this._requests[0] = request;
  871. return;
  872. }
  873. for (i = 0; i < this._len - 1; i++) {
  874. if (request.compareTo(this._requests[i]) < 0) {
  875. this._requests.splice(i, 1, request, this._requests[i]);
  876. return;
  877. }
  878. }
  879. this._requests.push(request);
  880. },
  881. peek: function () {
  882. return (this.isEmpty() ? false : this._requests[0]);
  883. },
  884. requestComplete: function (request) {
  885. for (i = 0; i < this._removedLen; i++) {
  886. if (this._removed[i].item == request) {
  887. this._removed.splice(i, 1);
  888. --this._removedLen;
  889. out('removed from _removed');
  890. return true;
  891. }
  892. }
  893. return false;
  894. },
  895. processRequest: function() {
  896. if (!this._intervalId) {
  897. this._runInterval();
  898. this._start();
  899. }
  900. this._idle = 0;
  901. },
  902. _runInterval: function() {
  903. if (Math.random() < this.checkRetryChance) {
  904. this._doRetries();
  905. }
  906. if (this.isEmpty()) {
  907. if (++this._idle > this.idleMax) {
  908. this._stop();
  909. }
  910. return;
  911. }
  912. var client = HTML_AJAX.httpClient();
  913. if (!client) {
  914. return;
  915. }
  916. var request = this.peek();
  917. if (!request) {
  918. this._requests.splice(0, 1);
  919. return;
  920. }
  921. client.request = request.item;
  922. client.makeRequest();
  923. this._requests.splice(0, 1);
  924. --this._len;
  925. this._removed[this._removedLen++] = new HTML_AJAX_Queue_Priority_Item(request, new Date().getTime());
  926. },
  927. _doRetries: function () {
  928. for (i = 0; i < this._removedLen; i++) {
  929. if (this._removed[i].time + this._requestTimeout < new Date().getTime()) {
  930. this.addRequest(request.item);
  931. this._removed.splice(i, 1);
  932. --this._removedLen;
  933. return true;
  934. }
  935. }
  936. },
  937. _start: function() {
  938. var self = this;
  939. this._intervalId = setInterval(function() { self._runInterval() }, this.interval);
  940. },
  941. _stop: function() {
  942. clearInterval(this._intervalId);
  943. this._intervalId = 0;
  944. }
  945. };
  946. // clientPool.js
  947. HTML_AJAX_Client_Pool = function(maxClients, startingClients)
  948. {
  949. this.maxClients = maxClients;
  950. this._clients = [];
  951. this._len = 0;
  952. while (--startingClients > 0) {
  953. this.addClient();
  954. }
  955. }
  956.  
  957. HTML_AJAX_Client_Pool.prototype = {
  958. isEmpty: function()
  959. {
  960. return this._len == 0;
  961. },
  962. addClient: function()
  963. {
  964. if (this.maxClients != 0 && this._len > this.maxClients) {
  965. return false;
  966. }
  967. var key = this._len++;
  968. this._clients[key] = new HTML_AJAX_HttpClient();
  969. return this._clients[key];
  970. },
  971. getClient: function ()
  972. {
  973. for (var i = 0; i < this._len; i++) {
  974. if (!this._clients[i].callInProgress() && this._clients[i].callbackComplete) {
  975. return this._clients[i];
  976. }
  977. }
  978. var client = this.addClient();
  979. if (client) {
  980. return client;
  981. }
  982. return false;
  983. },
  984. removeClient: function (client)
  985. {
  986. for (var i = 0; i < this._len; i++) {
  987. if (!this._clients[i] == client) {
  988. this._clients.splice(i, 1);
  989. return true;
  990. }
  991. }
  992. return false;
  993. },
  994. clear: function ()
  995. {
  996. this._clients = [];
  997. this._len = 0;
  998. }
  999. };
  1000.  
  1001. // create a default client pool with unlimited clients
  1002. HTML_AJAX.clientPools['default'] = new HTML_AJAX_Client_Pool(0);
  1003. // IframeXHR.js
  1004. /**
  1005. * XMLHttpRequest Iframe fallback
  1006. *
  1007. * http://l...content-available-to-author-only...a.org/seamonkey/source/extensions/xmlextras/tests/ - should work with these
  1008. *
  1009. * @category HTML
  1010. * @package AJAX
  1011. * @author Elizabeth Smith <auroraeosrose@gmail.com>
  1012. * @copyright 2005 Elizabeth Smith
  1013. * @license http://w...content-available-to-author-only...e.org/licenses/lgpl-license.php LGPL
  1014. */
  1015. HTML_AJAX_IframeXHR_instances = new Object();
  1016. function HTML_AJAX_IframeXHR()
  1017. {
  1018. this._id = 'HAXHR_iframe_' + new Date().getTime();
  1019. HTML_AJAX_IframeXHR_instances[this._id] = this;
  1020. }
  1021. HTML_AJAX_IframeXHR.prototype = {
  1022. // Data not sent with text/xml Content-Type will only be available via the responseText property
  1023.  
  1024. // properties available in safari/mozilla/IE xmlhttprequest object
  1025. onreadystatechange: null, // Event handler for an event that fires at every state change
  1026. readyState: 0, // Object status integer: 0 = uninitialized 1 = loading 2 = loaded 3 = interactive 4 = complete
  1027. responseText: '', // String version of data returned from server process
  1028. responseXML: null, // DOM-compatible document object of data returned from server process
  1029. status: 0, // Numeric code returned by server, such as 404 for "Not Found" or 200 for "OK"
  1030. statusText: '', // String message accompanying the status code
  1031. iframe: true, // flag for iframe
  1032.  
  1033. //these are private properties used internally to keep track of stuff
  1034. _id: null, // iframe id, unique to object(hopefully)
  1035. _url: null, // url sent by open
  1036. _method: null, // get or post
  1037. _async: null, // sync or async sent by open
  1038. _headers: new Object(), //request headers to send, actually sent as form vars
  1039. _response: new Object(), //response headers received
  1040. _phpclass: null, //class to send
  1041. _phpmethod: null, //method to send
  1042. _history: null, // opera has to have history munging
  1043.  
  1044. // Stops the current request
  1045. abort: function()
  1046. {
  1047. var iframe = document.getElementById(this._id);
  1048. if (iframe) {
  1049. document.body.removeChild(iframe);
  1050. }
  1051. if (this._timeout) {
  1052. window.clearTimeout(this._timeout);
  1053. }
  1054. this.readyState = 1;
  1055. if (typeof(this.onreadystatechange) == "function") {
  1056. this.onreadystatechange();
  1057. }
  1058. },
  1059.  
  1060. // This will send all headers in this._response and will include lastModified and contentType if not already set
  1061. getAllResponseHeaders: function()
  1062. {
  1063. var string = '';
  1064. for (i in this._response) {
  1065. string += i + ' : ' + this._response[i] + "\n";
  1066. }
  1067. return string;
  1068. },
  1069.  
  1070. // This will use lastModified and contentType if they're not set
  1071. getResponseHeader: function(header)
  1072. {
  1073. return (this._response[header] ? this._response[header] : null);
  1074. },
  1075.  
  1076. // Assigns a label/value pair to the header to be sent with a request
  1077. setRequestHeader: function(label, value) {
  1078. this._headers[label] = value;
  1079. return; },
  1080.  
  1081. // Assigns destination URL, method, and other optional attributes of a pending request
  1082. open: function(method, url, async, username, password)
  1083. {
  1084. if (!document.body) {
  1085. throw('CANNOT_OPEN_SEND_IN_DOCUMENT_HEAD');
  1086. }
  1087. //exceptions for not enough arguments
  1088. if (!method || !url) {
  1089. throw('NOT_ENOUGH_ARGUMENTS:METHOD_URL_REQUIRED');
  1090. }
  1091. //get and post are only methods accepted
  1092. this._method = (method.toUpperCase() == 'POST' ? 'POST' : 'GET');
  1093. this._decodeUrl(url);
  1094. this._async = async;
  1095. if(!this._async && document.readyState && !window.opera) {
  1096. throw('IE_DOES_NOT_SUPPORT_SYNC_WITH_IFRAMEXHR');
  1097. }
  1098. //set status to loading and call onreadystatechange
  1099. this.readyState = 1;
  1100. if(typeof(this.onreadystatechange) == "function") {
  1101. this.onreadystatechange();
  1102. }
  1103. },
  1104.  
  1105. // Transmits the request, optionally with postable string or DOM object data
  1106. send: function(content)
  1107. {
  1108. //attempt opera history munging
  1109. if (window.opera) {
  1110. this._history = window.history.length;
  1111. }
  1112. //create a "form" for the contents of the iframe
  1113. var form = '<html><body><form method="'
  1114. + (this._url.indexOf('px=') < 0 ? this._method : 'post')
  1115. + '" action="' + this._url + '">';
  1116. //tell iframe unwrapper this IS an iframe
  1117. form += '<input name="Iframe_XHR" value="1" />';
  1118. //class and method
  1119. if (this._phpclass != null) {
  1120. form += '<input name="Iframe_XHR_class" value="' + this._phpclass + '" />';
  1121. }
  1122. if (this._phpmethod != null) {
  1123. form += '<input name="Iframe_XHR_method" value="' + this._phpmethod + '" />';
  1124. }
  1125. // fake headers
  1126. for (label in this._headers) {
  1127. form += '<textarea name="Iframe_XHR_headers[]">' + label +':'+ this._headers[label] + '</textarea>';
  1128. }
  1129. // add id
  1130. form += '<textarea name="Iframe_XHR_id">' + this._id + '</textarea>';
  1131. if (content != null && content.length > 0) {
  1132. form += '<textarea name="Iframe_XHR_data">' + content + '</textarea>';
  1133. }
  1134. form += '<input name="Iframe_XHR_HTTP_method" value="' + this._method + '" />';
  1135. form += '<s'+'cript>document.forms[0].submit();</s'+'cript></form></body></html>';
  1136. form = "javascript:document.write('" + form.replace(/\'/g,"\\'") + "');void(0);";
  1137. this.readyState = 2;
  1138. if (typeof(this.onreadystatechange) == "function") {
  1139. this.onreadystatechange();
  1140. }
  1141. // try to create an iframe with createElement and append node
  1142. try {
  1143. var iframe = document.createElement('iframe');
  1144. iframe.id = this._id;
  1145. // display: none will fail on some browsers
  1146. iframe.style.visibility = 'hidden';
  1147. // for old browsers with crappy css
  1148. iframe.style.border = '0';
  1149. iframe.style.width = '0';
  1150. iframe.style.height = '0';
  1151.  
  1152. if (document.all) {
  1153. // MSIE, opera
  1154. iframe.src = form;
  1155. document.body.appendChild(iframe);
  1156. } else {
  1157. document.body.appendChild(iframe);
  1158. iframe.src = form;
  1159. }
  1160. } catch(exception) {
  1161. // dom failed, write the sucker manually
  1162. var html = '<iframe src="' + form +'" id="' + this._id + '" style="visibility:hidden;border:0;height:0;width:0;"></iframe>';
  1163. document.body.innerHTML += html;
  1164. }
  1165. if (this._async == true) {
  1166. //avoid race state if onload is called first
  1167. if (this.readyState < 3) {
  1168. this.readyState = 3;
  1169. if(typeof(this.onreadystatechange) == "function") {
  1170. this.onreadystatechange();
  1171. }
  1172. }
  1173. } else {
  1174. //we force a while loop for sync, it's ugly but hopefully it works
  1175. while (this.readyState != 4) {
  1176. //just check to see if we can up readyState
  1177. if (this.readyState < 3) {
  1178. this.readyState = 3;
  1179. if(typeof(this.onreadystatechange) == "function") {
  1180. this.onreadystatechange();
  1181. }
  1182. }
  1183. }
  1184. }
  1185. },
  1186.  
  1187. // attached as an onload function to the iframe to trigger when we're done
  1188. isLoaded: function(headers, data)
  1189. {
  1190. this.readyState = 4;
  1191. //set responseText, Status, StatusText
  1192. this.status = 200;
  1193. this.statusText = 'OK';
  1194. this.responseText = data;
  1195. this._response = headers;
  1196. if (!this._response['Last-Modified']) {
  1197. string += 'Last-Modified : ' + document.getElementById(this._id).lastModified + "\n";
  1198. }
  1199. if (!this._response['Content-Type']) {
  1200. string += 'Content-Type : ' + document.getElementById(this._id).contentType + "\n";
  1201. }
  1202. // if this is xml populate responseXML accordingly
  1203. if (this._response['Content-Type'] == 'application/xml')
  1204. {
  1205. return new DOMParser().parseFromString(this.responseText, 'application/xml');
  1206. }
  1207. //attempt opera history munging in opera 8+ - this is a REGRESSION IN OPERA
  1208. if (window.opera && window.opera.version) {
  1209. //go back current history - old history
  1210. window.history.go(this._history - window.history.length);
  1211. }
  1212. if (typeof(this.onreadystatechange) == "function") {
  1213. this.onreadystatechange();
  1214. }
  1215. document.body.removeChild(document.getElementById(this._id));
  1216. },
  1217.  
  1218. // strip off the c and m from the url send...yuck
  1219. _decodeUrl: function(querystring)
  1220. {
  1221. //opera 7 is too stupid to do a relative url...go figure
  1222. var url = unescape(location.href);
  1223. url = url.substring(0, url.lastIndexOf("/") + 1);
  1224. var item = querystring.split('?');
  1225. //rip off any path info and append to path above <- relative paths (../) WILL screw this
  1226. this._url = url + item[0].substring(item[0].lastIndexOf("/") + 1,item[0].length);
  1227. if(item[1]) {
  1228. item = item[1].split('&');
  1229. for (i in item) {
  1230. var v = item[i].split('=');
  1231. if (v[0] == 'c') {
  1232. this._phpclass = v[1];
  1233. } else if (v[0] == 'm') {
  1234. this._phpmethod = v[1];
  1235. }
  1236. }
  1237. }
  1238. if (!this._phpclass || !this._phpmethod) {
  1239. var cloc = window.location.href;
  1240. this._url = cloc + (cloc.indexOf('?') >= 0 ? '&' : '?') + 'px=' + escape(HTML_AJAX_Util.absoluteURL(querystring));
  1241. }
  1242. }
  1243. }
  1244. // serializer/UrlSerializer.js
  1245. // {{{ HTML_AJAX_Serialize_Urlencoded
  1246. /**
  1247. * URL-encoding serializer
  1248. *
  1249. * This class can be used to serialize and unserialize data in a
  1250. * format compatible with PHP's handling of HTTP query strings.
  1251. * Due to limitations of the format, all input is serialized as an
  1252. * array or a string. See examples/serialize.url.examples.php
  1253. *
  1254. * @version 0.0.1
  1255. * @copyright 2005 Arpad Ray <arpad@php.net>
  1256. * @license http://w...content-available-to-author-only...e.org/licenses/lgpl-license.php LGPL
  1257. *
  1258. * See Main.js for Author/license details
  1259. */
  1260. function HTML_AJAX_Serialize_Urlencoded() {}
  1261. HTML_AJAX_Serialize_Urlencoded.prototype = {
  1262. contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1263. base: '_HTML_AJAX',
  1264. _keys: [],
  1265. error: false,
  1266. message: "",
  1267. cont: "",
  1268. // {{{ serialize
  1269. /**
  1270. * Serializes a variable
  1271. *
  1272. * @param mixed inp the variable to serialize
  1273. * @return string a string representation of the input,
  1274. * which can be reconstructed by unserialize()
  1275. */
  1276. serialize: function(input, _internal) {
  1277. if (typeof input == 'undefined') {
  1278. return '';
  1279. }
  1280. if (!_internal) {
  1281. this._keys = [];
  1282. }
  1283. var ret = '', first = true;
  1284. for (i = 0; i < this._keys.length; i++) {
  1285. ret += (first ? HTML_AJAX_Util.encodeUrl(this._keys[i]) : '[' + HTML_AJAX_Util.encodeUrl(this._keys[i]) + ']');
  1286. first = false;
  1287. }
  1288. ret += '=';
  1289. switch (HTML_AJAX_Util.getType(input)) {
  1290. case 'string':
  1291. case 'number':
  1292. ret += HTML_AJAX_Util.encodeUrl(input.toString());
  1293. break;
  1294. case 'boolean':
  1295. ret += (input ? '1' : '0');
  1296. break;
  1297. case 'array':
  1298. case 'object':
  1299. ret = '';
  1300. for (i in input) {
  1301. this._keys.push(i);
  1302. ret += this.serialize(input[i], true) + '&';
  1303. this._keys.pop();
  1304. }
  1305. ret = ret.substr(0, ret.length - 1);
  1306. }
  1307. return ret;
  1308. },
  1309. // }}}
  1310. // {{{ unserialize
  1311. /**
  1312. * Reconstructs a serialized variable
  1313. *
  1314. * @param string inp the string to reconstruct
  1315. * @return array an array containing the variable represented by the input string, or void on failure
  1316. */
  1317. unserialize: function(input) {
  1318. if (!input.length || input.length == 0) {
  1319. // null
  1320. return;
  1321. }
  1322. if (!/^(\w+(\[[^\[\]]*\])*=[^&]*(&|$))+$/.test(input)) {
  1323. this.raiseError("invalidly formed input", input);
  1324. return;
  1325. }
  1326. input = input.split("&");
  1327. var pos, key, keys, val, _HTML_AJAX = [];
  1328. if (input.length == 1) {
  1329. return HTML_AJAX_Util.decodeUrl(input[0].substr(this.base.length + 1));
  1330. }
  1331. for (var i in input) {
  1332. pos = input[i].indexOf("=");
  1333. if (pos < 1 || input[i].length - pos - 1 < 1) {
  1334. this.raiseError("input is too short", input[i]);
  1335. return;
  1336. }
  1337. key = HTML_AJAX_Util.decodeUrl(input[i].substr(0, pos));
  1338. val = HTML_AJAX_Util.decodeUrl(input[i].substr(pos + 1));
  1339. key = key.replace(/\[((\d*\D+)+)\]/g, '["$1"]');
  1340. keys = key.split(']');
  1341. for (j in keys) {
  1342. if (!keys[j].length || keys[j].length == 0) {
  1343. continue;
  1344. }
  1345. try {
  1346. if (eval('typeof ' + keys[j] + ']') == 'undefined') {
  1347. var ev = keys[j] + ']=[];';
  1348. eval(ev);
  1349. }
  1350. } catch (e) {
  1351. this.raiseError("error evaluating key", ev);
  1352. return;
  1353. }
  1354. }
  1355. try {
  1356. eval(key + '="' + val + '";');
  1357. } catch (e) {
  1358. this.raiseError("error evaluating value", input);
  1359. return;
  1360. }
  1361. }
  1362. return _HTML_AJAX;
  1363. },
  1364. // }}}
  1365. // {{{ getError
  1366. /**
  1367. * Gets the last error message
  1368. *
  1369. * @return string the last error message from unserialize()
  1370. */
  1371. getError: function() {
  1372. return this.message + "\n" + this.cont;
  1373. },
  1374. // }}}
  1375. // {{{ raiseError
  1376. /**
  1377. * Raises an eror (called by unserialize().)
  1378. *
  1379. * @param string message the error message
  1380. * @param string cont the remaining unserialized content
  1381. */
  1382. raiseError: function(message, cont) {
  1383. this.error = 1;
  1384. this.message = message;
  1385. this.cont = cont;
  1386. }
  1387. // }}}
  1388. }
  1389. // }}}
  1390. // serializer/phpSerializer.js
  1391. // {{{ HTML_AJAX_Serialize_PHP
  1392. /**
  1393. * PHP serializer
  1394. *
  1395. * This class can be used to serialize and unserialize data in a
  1396. * format compatible with PHP's native serialization functions.
  1397. *
  1398. * @version 0.0.3
  1399. * @copyright 2005 Arpad Ray <arpad@php.net>
  1400. * @license http://w...content-available-to-author-only...e.org/licenses/lgpl-license.php LGPL
  1401. *
  1402. * See Main.js for Author/license details
  1403. */
  1404.  
  1405. function HTML_AJAX_Serialize_PHP() {}
  1406. HTML_AJAX_Serialize_PHP.prototype = {
  1407. error: false,
  1408. message: "",
  1409. cont: "",
  1410. defaultEncoding: 'UTF-8',
  1411. contentType: 'application/php-serialized; charset: UTF-8',
  1412. // {{{ serialize
  1413. /**
  1414. * Serializes a variable
  1415. *
  1416. * @param mixed inp the variable to serialize
  1417. * @return string a string representation of the input,
  1418. * which can be reconstructed by unserialize()
  1419. * @author Arpad Ray <arpad@rajeczy.com>
  1420. * @author David Coallier <davidc@php.net>
  1421. */
  1422. serialize: function(inp) {
  1423. var type = HTML_AJAX_Util.getType(inp);
  1424. var val;
  1425. switch (type) {
  1426. case "undefined":
  1427. val = "N";
  1428. break;
  1429. case "boolean":
  1430. val = "b:" + (inp ? "1" : "0");
  1431. break;
  1432. case "number":
  1433. val = (Math.round(inp) == inp ? "i" : "d") + ":" + inp;
  1434. break;
  1435. case "string":
  1436. val = "s:" + inp.length + ":\"" + inp + "\"";
  1437. break;
  1438. case "array":
  1439. val = "a";
  1440. case "object":
  1441. if (type == "object") {
  1442. var objname = inp.constructor.toString().match(/(\w+)\(\)/);
  1443. if (objname == undefined) {
  1444. return;
  1445. }
  1446. objname[1] = this.serialize(objname[1]);
  1447. val = "O" + objname[1].substring(1, objname[1].length - 1);
  1448. }
  1449. var count = 0;
  1450. var vals = "";
  1451. var okey;
  1452. for (key in inp) {
  1453. okey = (key.match(/^[0-9]+$/) ? parseInt(key) : key);
  1454. vals += this.serialize(okey) +
  1455. this.serialize(inp[key]);
  1456. count++;
  1457. }
  1458. val += ":" + count + ":{" + vals + "}";
  1459. break;
  1460. }
  1461. if (type != "object" && type != "array") val += ";";
  1462. return val;
  1463. },
  1464. // }}}
  1465. // {{{ unserialize
  1466. /**
  1467. * Reconstructs a serialized variable
  1468. *
  1469. * @param string inp the string to reconstruct
  1470. * @return mixed the variable represented by the input string, or void on failure
  1471. */
  1472. unserialize: function(inp) {
  1473. this.error = 0;
  1474. if (inp == "" || inp.length < 2) {
  1475. this.raiseError("input is too short");
  1476. return;
  1477. }
  1478. var val, kret, vret, cval;
  1479. var type = inp.charAt(0);
  1480. var cont = inp.substring(2);
  1481. var size = 0, divpos = 0, endcont = 0, rest = "", next = "";
  1482.  
  1483. switch (type) {
  1484. case "N": // null
  1485. if (inp.charAt(1) != ";") {
  1486. this.raiseError("missing ; for null", cont);
  1487. }
  1488. // leave val undefined
  1489. rest = cont;
  1490. break;
  1491. case "b": // boolean
  1492. if (!/[01];/.test(cont.substring(0,2))) {
  1493. this.raiseError("value not 0 or 1, or missing ; for boolean", cont);
  1494. }
  1495. val = (cont.charAt(0) == "1");
  1496. rest = cont.substring(1);
  1497. break;
  1498. case "s": // string
  1499. val = "";
  1500. divpos = cont.indexOf(":");
  1501. if (divpos == -1) {
  1502. this.raiseError("missing : for string", cont);
  1503. break;
  1504. }
  1505. size = parseInt(cont.substring(0, divpos));
  1506. if (size == 0) {
  1507. if (cont.length - divpos < 4) {
  1508. this.raiseError("string is too short", cont);
  1509. break;
  1510. }
  1511. rest = cont.substring(divpos + 4);
  1512. break;
  1513. }
  1514. if ((cont.length - divpos - size) < 4) {
  1515. this.raiseError("string is too short", cont);
  1516. break;
  1517. }
  1518. if (cont.substring(divpos + 2 + size, divpos + 4 + size) != "\";") {
  1519. this.raiseError("string is too long, or missing \";", cont);
  1520. }
  1521. val = cont.substring(divpos + 2, divpos + 2 + size);
  1522. rest = cont.substring(divpos + 4 + size);
  1523. break;
  1524. case "i": // integer
  1525. case "d": // float
  1526. var dotfound = 0;
  1527. for (var i = 0; i < cont.length; i++) {
  1528. cval = cont.charAt(i);
  1529. if (isNaN(parseInt(cval)) && !(type == "d" && cval == "." && !dotfound++)) {
  1530. endcont = i;
  1531. break;
  1532. }
  1533. }
  1534. if (!endcont || cont.charAt(endcont) != ";") {
  1535. this.raiseError("missing or invalid value, or missing ; for int/float", cont);
  1536. }
  1537. val = cont.substring(0, endcont);
  1538. val = (type == "i" ? parseInt(val) : parseFloat(val));
  1539. rest = cont.substring(endcont + 1);
  1540. break;
  1541. case "a": // array
  1542. if (cont.length < 4) {
  1543. this.raiseError("array is too short", cont);
  1544. return;
  1545. }
  1546. divpos = cont.indexOf(":", 1);
  1547. if (divpos == -1) {
  1548. this.raiseError("missing : for array", cont);
  1549. return;
  1550. }
  1551. size = parseInt(cont.substring(0, divpos));
  1552. cont = cont.substring(divpos + 2);
  1553. val = new Array();
  1554. if (cont.length < 1) {
  1555. this.raiseError("array is too short", cont);
  1556. return;
  1557. }
  1558. for (var i = 0; i < size; i++) {
  1559. kret = this.unserialize(cont, 1);
  1560. if (this.error || kret[0] == undefined || kret[1] == "") {
  1561. this.raiseError("missing or invalid key, or missing value for array", cont);
  1562. return;
  1563. }
  1564. vret = this.unserialize(kret[1], 1);
  1565. if (this.error) {
  1566. this.raiseError("invalid value for array", cont);
  1567. return;
  1568. }
  1569. val[kret[0]] = vret[0];
  1570. cont = vret[1];
  1571. }
  1572. if (cont.charAt(0) != "}") {
  1573. this.raiseError("missing ending }, or too many values for array", cont);
  1574. return;
  1575. }
  1576. rest = cont.substring(1);
  1577. break;
  1578. case "O": // object
  1579. divpos = cont.indexOf(":");
  1580. if (divpos == -1) {
  1581. this.raiseError("missing : for object", cont);
  1582. return;
  1583. }
  1584. size = parseInt(cont.substring(0, divpos));
  1585. var objname = cont.substring(divpos + 2, divpos + 2 + size);
  1586. if (cont.substring(divpos + 2 + size, divpos + 4 + size) != "\":") {
  1587. this.raiseError("object name is too long, or missing \":", cont);
  1588. return;
  1589. }
  1590. var objprops = this.unserialize("a:" + cont.substring(divpos + 4 + size), 1);
  1591. if (this.error) {
  1592. this.raiseError("invalid object properties", cont);
  1593. return;
  1594. }
  1595. rest = objprops[1];
  1596. var objout = "function " + objname + "(){";
  1597. for (key in objprops[0]) {
  1598. objout += "this." + key + "=objprops[0]['" + key + "'];";
  1599. }
  1600. objout += "}val=new " + objname + "();";
  1601. eval(objout);
  1602. break;
  1603. default:
  1604. this.raiseError("invalid input type", cont);
  1605. }
  1606. return (arguments.length == 1 ? val : [val, rest]);
  1607. },
  1608. // }}}
  1609. // {{{ getError
  1610. /**
  1611. * Gets the last error message
  1612. *
  1613. * @return string the last error message from unserialize()
  1614. */
  1615. getError: function() {
  1616. return this.message + "\n" + this.cont;
  1617. },
  1618. // }}}
  1619. // {{{ raiseError
  1620. /**
  1621. * Raises an eror (called by unserialize().)
  1622. *
  1623. * @param string message the error message
  1624. * @param string cont the remaining unserialized content
  1625. */
  1626. raiseError: function(message, cont) {
  1627. this.error = 1;
  1628. this.message = message;
  1629. this.cont = cont;
  1630. }
  1631. // }}}
  1632. }
  1633. // }}}
  1634.  
  1635. // Dispatcher.js
  1636. /**
  1637. * Class that is used by generated stubs to make actual AJAX calls
  1638. *
  1639. * @category HTML
  1640. * @package AJAX
  1641. * @author Joshua Eichorn <josh@bluga.net>
  1642. * @copyright 2005 Joshua Eichorn
  1643. * @license http://w...content-available-to-author-only...e.org/licenses/lgpl-license.php LGPL
  1644. */
  1645. function HTML_AJAX_Dispatcher(className,mode,callback,serverUrl,serializerType)
  1646. {
  1647. this.className = className;
  1648. this.mode = mode;
  1649. this.callback = callback;
  1650. this.serializerType = serializerType;
  1651.  
  1652. if (serverUrl) {
  1653. this.serverUrl = serverUrl
  1654. }
  1655. else {
  1656. this.serverUrl = window.location;
  1657. }
  1658. }
  1659.  
  1660. HTML_AJAX_Dispatcher.prototype = {
  1661. /**
  1662. * Queue to use when making a request
  1663. */
  1664. queue: 'default',
  1665.  
  1666. /**
  1667. * Timeout for async calls
  1668. */
  1669. timeout: 20000,
  1670.  
  1671. /**
  1672. * Default request priority
  1673. */
  1674. priority: 0,
  1675.  
  1676. /**
  1677. * Request options
  1678. */
  1679. options: {},
  1680.  
  1681. /**
  1682. * Make an ajax call
  1683. *
  1684. * @param string callName
  1685. * @param Array args arguments to the report method
  1686. */
  1687. doCall: function(callName,args)
  1688. {
  1689. var request = new HTML_AJAX_Request();
  1690. request.requestUrl = this.serverUrl;
  1691. request.className = this.className;
  1692. request.methodName = callName;
  1693. request.timeout = this.timeout;
  1694. request.contentType = this.contentType;
  1695. request.serializer = eval('new HTML_AJAX_Serialize_'+this.serializerType);
  1696. request.queue = this.queue;
  1697. request.priority = this.priority;
  1698.  
  1699. for(var i in this.options) {
  1700. request[i] = this.options[i];
  1701. }
  1702.  
  1703. for(var i=0; i < args.length; i++) {
  1704. request.addArg(i,args[i]);
  1705. };
  1706.  
  1707. if ( this.mode == "async" ) {
  1708. request.isAsync = true;
  1709. if (this.callback[callName]) {
  1710. var self = this;
  1711. request.callback = function(result) { self.callback[callName](result); }
  1712. }
  1713.  
  1714. } else {
  1715. request.isAsync = false;
  1716. }
  1717.  
  1718. return HTML_AJAX.makeRequest(request);
  1719. },
  1720.  
  1721. Sync: function()
  1722. {
  1723. this.mode = 'sync';
  1724. },
  1725.  
  1726. Async: function(callback)
  1727. {
  1728. this.mode = 'async';
  1729. if (callback) {
  1730. this.callback = callback;
  1731. }
  1732. }
  1733. };
  1734. // HttpClient.js
  1735. /**
  1736. * XMLHttpRequest Wrapper
  1737. * @category HTML
  1738. * @package AJAX
  1739. * @author Joshua Eichorn <josh@bluga.net>
  1740. * @copyright 2005 Joshua Eichorn
  1741. * @license http://w...content-available-to-author-only...e.org/licenses/lgpl-license.php LGPL
  1742. */
  1743. function HTML_AJAX_HttpClient() { }
  1744. HTML_AJAX_HttpClient.prototype = {
  1745. // request object
  1746. request: null,
  1747.  
  1748. // timeout id
  1749. _timeoutId: null,
  1750.  
  1751. callbackComplete: true,
  1752.  
  1753. // has this request been aborted
  1754. aborted: false,
  1755.  
  1756. // method to initialize an xmlhttpclient
  1757. init:function()
  1758. {
  1759. try {
  1760. // Mozilla / Safari
  1761. //this.xmlhttp = new HTML_AJAX_IframeXHR(); //uncomment these two lines to test iframe
  1762. //return;
  1763. this.xmlhttp = new XMLHttpRequest();
  1764. } catch (e) {
  1765. // IE
  1766. var XMLHTTP_IDS = new Array(
  1767. 'MSXML2.XMLHTTP.5.0',
  1768. 'MSXML2.XMLHTTP.4.0',
  1769. 'MSXML2.XMLHTTP.3.0',
  1770. 'MSXML2.XMLHTTP',
  1771. 'Microsoft.XMLHTTP' );
  1772. var success = false;
  1773. for (var i=0;i < XMLHTTP_IDS.length && !success; i++) {
  1774. try {
  1775. this.xmlhttp = new ActiveXObject(XMLHTTP_IDS[i]);
  1776. success = true;
  1777. } catch (e) {}
  1778. }
  1779. if (!success) {
  1780. try{
  1781. this.xmlhttp = new HTML_AJAX_IframeXHR();
  1782. this.request.iframe = true;
  1783. } catch(e) {
  1784. throw new Error('Unable to create XMLHttpRequest.');
  1785. }
  1786. }
  1787. }
  1788. },
  1789.  
  1790. // check if there is a call in progress
  1791. callInProgress: function()
  1792. {
  1793. switch ( this.xmlhttp.readyState ) {
  1794. case 1:
  1795. case 2:
  1796. case 3:
  1797. return true;
  1798. break;
  1799. default:
  1800. return false;
  1801. break;
  1802. }
  1803. },
  1804.  
  1805. // make the request defined in the request object
  1806. makeRequest: function()
  1807. {
  1808. if (!this.xmlhttp) {
  1809. this.init();
  1810. }
  1811.  
  1812. try {
  1813. if (this.request.Open) {
  1814. this.request.Open();
  1815. }
  1816. else if (HTML_AJAX.Open) {
  1817. HTML_AJAX.Open(this.request);
  1818. }
  1819.  
  1820. if (this.request.multipart) {
  1821. if (document.all) {
  1822. this.iframe = true;
  1823. } else {
  1824. this.xmlhttp.multipart = true;
  1825. }
  1826. }
  1827.  
  1828. // set onreadystatechange here since it will be reset after a completed call in Mozilla
  1829. var self = this;
  1830. this.xmlhttp.open(this.request.requestType,this.request.completeUrl(),this.request.isAsync);
  1831. if (this.request.customHeaders) {
  1832. for (var i in this.request.customHeaders) {
  1833. this.xmlhttp.setRequestHeader(i, this.request.customHeaders[i]);
  1834. }
  1835. }
  1836. if (this.request.customHeaders && !this.request.customHeaders['Content-Type']) {
  1837. var content = this.request.getContentType();
  1838. var charsetIndex = content.indexOf('; charset=UTF-8');
  1839. if (charsetIndex == -1) {
  1840. content += '; charset=UTF-8';
  1841. }
  1842. this.xmlhttp.setRequestHeader('Content-Type', content);
  1843. }
  1844.  
  1845. if (this.request.isAsync) {
  1846. if (this.request.callback) {
  1847. this.callbackComplete = false;
  1848. }
  1849. this.xmlhttp.onreadystatechange = function() { self._readyStateChangeCallback(); }
  1850. } else {
  1851. this.xmlhttp.onreadystatechange = function() {}
  1852. }
  1853. var payload = this.request.getSerializedPayload();
  1854. if (payload) {
  1855. this.xmlhttp.setRequestHeader('Content-Length', payload.length);
  1856. }
  1857. this.xmlhttp.send(payload);
  1858.  
  1859. if (!this.request.isAsync) {
  1860. if ( this.xmlhttp.status == 200 ) {
  1861. HTML_AJAX.requestComplete(this.request);
  1862. if (this.request.Load) {
  1863. this.request.Load();
  1864. } else if (HTML_AJAX.Load) {
  1865. HTML_AJAX.Load(this.request);
  1866. }
  1867.  
  1868. return this._decodeResponse();
  1869. } else {
  1870. var e = new Error('['+this.xmlhttp.status +'] '+this.xmlhttp.statusText);
  1871. e.headers = this.xmlhttp.getAllResponseHeaders();
  1872. this._handleError(e);
  1873. }
  1874. }
  1875. else {
  1876. // setup timeout
  1877. var self = this;
  1878. this._timeoutId = window.setTimeout(function() { self.abort(true); },this.request.timeout);
  1879. }
  1880. } catch (e) {
  1881. this._handleError(e);
  1882. }
  1883. },
  1884.  
  1885. // abort an inprogress request
  1886. abort: function (automatic)
  1887. {
  1888. if (this.callInProgress()) {
  1889. this.aborted = true;
  1890. this.xmlhttp.abort();
  1891.  
  1892. if (automatic) {
  1893. HTML_AJAX.requestComplete(this.request);
  1894. this._handleError(new Error('Request Timed Out: time out was '+this.request.timeout+'ms'));
  1895. }
  1896. }
  1897. },
  1898.  
  1899. // internal method used to handle ready state changes
  1900. _readyStateChangeCallback:function()
  1901. {
  1902. try {
  1903. switch(this.xmlhttp.readyState) {
  1904. // XMLHTTPRequest.open() has just been called
  1905. case 1:
  1906. break;
  1907. // XMLHTTPRequest.send() has just been called
  1908. case 2:
  1909. if (this.request.Send) {
  1910. this.request.Send();
  1911. } else if (HTML_AJAX.Send) {
  1912. HTML_AJAX.Send(this.request);
  1913. }
  1914. break;
  1915. // Fetching response from server in progress
  1916. case 3:
  1917. if (this.request.Progress) {
  1918. this.request.Progress();
  1919. } else if (HTML_AJAX.Progress ) {
  1920. HTML_AJAX.Progress(this.request);
  1921. }
  1922. break;
  1923. // Download complete
  1924. case 4:
  1925. window.clearTimeout(this._timeoutId);
  1926. if (this.aborted) {
  1927. if (this.request.Load) {
  1928. this.request.Load();
  1929. } else if (HTML_AJAX.Load) {
  1930. HTML_AJAX.Load(this.request);
  1931. }
  1932. }
  1933. else if (this.xmlhttp.status == 200) {
  1934. if (this.request.Load) {
  1935. this.request.Load();
  1936. } else if (HTML_AJAX.Load ) {
  1937. HTML_AJAX.Load(this.request);
  1938. }
  1939.  
  1940. var response = this._decodeResponse();
  1941.  
  1942. if (this.request.callback) {
  1943. this.request.callback(response);
  1944. this.callbackComplete = true;
  1945. }
  1946. }
  1947. else {
  1948. var e = new Error('HTTP Error Making Request: ['+this.xmlhttp.status+'] '+this.xmlhttp.statusText);
  1949. this._handleError(e);
  1950. }
  1951. HTML_AJAX.requestComplete(this.request);
  1952. break;
  1953. }
  1954. } catch (e) {
  1955. this._handleError(e);
  1956. }
  1957. },
  1958.  
  1959. // decode response as needed
  1960. _decodeResponse: function() {
  1961. //try for x-Content-Type first
  1962. var content = null;
  1963. try {
  1964. content = this.xmlhttp.getResponseHeader('X-Content-Type');
  1965. } catch(e) {}
  1966. if(!content || content == null)
  1967. {
  1968. content = this.xmlhttp.getResponseHeader('Content-Type');
  1969. }
  1970. //strip anything after ;
  1971. if(content.indexOf(';') != -1)
  1972. {
  1973. content = content.substring(0, content.indexOf(';'));
  1974. }
  1975. // hook for xml, it doesn't need to be unserialized
  1976. if(content == 'application/xml' || content == 'text/xml')
  1977. {
  1978. return this.xmlhttp.responseXML;
  1979. }
  1980. var unserializer = HTML_AJAX.serializerForEncoding(content);
  1981. //alert(this.xmlhttp.getAllResponseHeaders()); // some sort of debug hook is needed here
  1982. return unserializer.unserialize(this.xmlhttp.responseText);
  1983. },
  1984.  
  1985. // handle sending an error where it needs to go
  1986. _handleError: function(e)
  1987. {
  1988. HTML_AJAX.requestComplete(this.request,e);
  1989. if (this.request.onError) {
  1990. this.request.onError(e);
  1991. } else if (HTML_AJAX.onError) {
  1992. HTML_AJAX.onError(e,this.request);
  1993. }
  1994. else {
  1995. throw e;
  1996. }
  1997. }
  1998. }
  1999. // Request.js
  2000. /**
  2001. * Class that contains everything needed to make a request
  2002. * This includes:
  2003. * The url were calling
  2004. * If were calling a remote method, the class and method name
  2005. * The payload, unserialized
  2006. * The timeout for async calls
  2007. * The callback method
  2008. * Optional event handlers: onError, Load, Send
  2009. * A serializer instance
  2010. *
  2011. * @category HTML
  2012. * @package AJAX
  2013. * @author Joshua Eichorn <josh@bluga.net>
  2014. * @copyright 2005 Joshua Eichorn
  2015. * @license http://w...content-available-to-author-only...e.org/licenses/lgpl-license.php LGPL
  2016. *
  2017. * See Main.js for author/license details
  2018. */
  2019. function HTML_AJAX_Request(serializer) {
  2020. this.serializer = serializer;
  2021. }
  2022. HTML_AJAX_Request.prototype = {
  2023.  
  2024. // Instance of a serializer
  2025. serializer: null,
  2026.  
  2027. // Is this an async request
  2028. isAsync: false,
  2029.  
  2030. // HTTP verb
  2031. requestType: 'POST',
  2032.  
  2033. // The actual URL the request is sent to
  2034. requestUrl: '',
  2035.  
  2036. // Remote Class
  2037. className: null,
  2038.  
  2039. // Remote Method
  2040. methodName: null,
  2041.  
  2042. // Timeout in milliseconds for requests
  2043. timeout: 20000,
  2044.  
  2045. // unserialized data, for rpc calls use add args, to send raw data just set this directly
  2046. args: null,
  2047.  
  2048. // async callback method
  2049. callback: null,
  2050.  
  2051. // Queue to push this request too
  2052. queue: 'default',
  2053.  
  2054. // default priority
  2055. priority: 0,
  2056.  
  2057. // a hash of headers to add to add to this request
  2058. customHeaders: {'X-Requested-With': 'XMLHttpRequest', 'X-Ajax-Engine': 'HTML_AJAX/0.5.6'},
  2059.  
  2060. // true if this request will be sent using iframes
  2061. iframe: false,
  2062.  
  2063. // is this a grab request? if so we need to proxy for iframes
  2064. grab: false,
  2065.  
  2066. // true if this request should expect a multipart response
  2067. multipart: false,
  2068.  
  2069. // remote callback
  2070. phpCallback: false,
  2071.  
  2072. /**
  2073. * Add an argument for the remote method
  2074. * @param string argument name
  2075. * @param mixed value
  2076. * @return void
  2077. * @throws Error code 1004
  2078. */
  2079. addArg: function(name, value)
  2080. {
  2081. if ( !this.args ) {
  2082. this.args = [];
  2083. }
  2084. if (!/[^a-zA-Z_0-9]/.test(name) ) {
  2085. this.args[name] = value;
  2086. } else {
  2087. throw new Error('Invalid parameter name ('+name+')');
  2088. }
  2089. },
  2090.  
  2091. /**
  2092. * Get the payload in a serialized manner
  2093. */
  2094. getSerializedPayload: function() {
  2095. return this.serializer.serialize(this.args);
  2096. },
  2097.  
  2098. /**
  2099. * Get the content type
  2100. */
  2101. getContentType: function() {
  2102. return this.serializer.contentType;
  2103. },
  2104.  
  2105. /**
  2106. * Get the complete url, adding in any needed get params for rpc
  2107. */
  2108. completeUrl: function() {
  2109. if (this.className || this.methodName) {
  2110. this.addGet('c', this.className);
  2111. this.addGet('m', this.methodName);
  2112. }
  2113. if (this.phpCallback) {
  2114. if (HTML_AJAX_Util.getType(this.phpCallback) == 'array') {
  2115. this.phpCallback = this.phpCallback.join('.');
  2116. }
  2117. this.addGet('cb', this.phpCallback);
  2118. }
  2119. if (this.multipart) {
  2120. this.addGet('multipart', '1');
  2121. }
  2122. return this.requestUrl;
  2123. },
  2124.  
  2125. /**
  2126. * Compare to another request by priority
  2127. */
  2128. compareTo: function(other) {
  2129. if (this.priority == other.priority) {
  2130. return 0;
  2131. }
  2132. return (this.priority > other.priority ? 1 : -1);
  2133. },
  2134.  
  2135. /**
  2136. * Add a GET argument
  2137. */
  2138. addGet: function(name, value) {
  2139. var url = new String(this.requestUrl);
  2140. url += (url.indexOf('?') < 0 ? '?' : '&') + escape(name) + '=' + escape(value);
  2141. this.requestUrl = url;
  2142. }
  2143. }
  2144. // serializer/JSON.js
  2145. /*
  2146. Copyright (c) 2005 JSON.org
  2147.  
  2148. Permission is hereby granted, free of charge, to any person obtaining a copy
  2149. of this software and associated documentation files (the "Software"), to deal
  2150. in the Software without restriction, including without limitation the rights
  2151. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  2152. copies of the Software, and to permit persons to whom the Software is
  2153. furnished to do so, subject to the following conditions:
  2154.  
  2155. The Software shall be used for Good, not Evil.
  2156.  
  2157. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  2158. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  2159. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  2160. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  2161. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  2162. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  2163. SOFTWARE.
  2164. */
  2165.  
  2166. /*
  2167. The global object JSON contains two methods.
  2168.  
  2169. JSON.stringify(value) takes a JavaScript value and produces a JSON text.
  2170. The value must not be cyclical.
  2171.  
  2172. JSON.parse(text) takes a JSON text and produces a JavaScript value. It will
  2173. throw a 'JSONError' exception if there is an error.
  2174. */
  2175. var HTML_AJAX_JSON = {
  2176. copyright: '(c)2005 JSON.org',
  2177. license: 'http://w...content-available-to-author-only...d.com/JSON/license.html',
  2178. /*
  2179. Stringify a JavaScript value, producing a JSON text.
  2180. */
  2181. stringify: function (v) {
  2182. var a = [];
  2183.  
  2184. /*
  2185. Emit a string.
  2186. */
  2187. function e(s) {
  2188. a[a.length] = s;
  2189. }
  2190.  
  2191. /*
  2192. Convert a value.
  2193. */
  2194. function g(x) {
  2195. var c, i, l, v;
  2196.  
  2197. switch (typeof x) {
  2198. case 'object':
  2199. if (x) {
  2200. if (x instanceof Array) {
  2201. e('[');
  2202. l = a.length;
  2203. for (i = 0; i < x.length; i += 1) {
  2204. v = x[i];
  2205. if (typeof v != 'undefined' &&
  2206. typeof v != 'function') {
  2207. if (l < a.length) {
  2208. e(',');
  2209. }
  2210. g(v);
  2211. }
  2212. }
  2213. e(']');
  2214. return;
  2215. } else if (typeof x.valueOf == 'function') {
  2216. e('{');
  2217. l = a.length;
  2218. for (i in x) {
  2219. v = x[i];
  2220. if (typeof v != 'undefined' &&
  2221. typeof v != 'function' &&
  2222. (!v || typeof v != 'object' ||
  2223. typeof v.valueOf == 'function')) {
  2224. if (l < a.length) {
  2225. e(',');
  2226. }
  2227. g(i);
  2228. e(':');
  2229. g(v);
  2230. }
  2231. }
  2232. return e('}');
  2233. }
  2234. }
  2235. e('null');
  2236. return;
  2237. case 'number':
  2238. e(isFinite(x) ? +x : 'null');
  2239. return;
  2240. case 'string':
  2241. l = x.length;
  2242. e('"');
  2243. for (i = 0; i < l; i += 1) {
  2244. c = x.charAt(i);
  2245. if (c >= ' ') {
  2246. if (c == '\\' || c == '"') {
  2247. e('\\');
  2248. }
  2249. e(c);
  2250. } else {
  2251. switch (c) {
  2252. case '\b':
  2253. e('\\b');
  2254. break;
  2255. case '\f':
  2256. e('\\f');
  2257. break;
  2258. case '\n':
  2259. e('\\n');
  2260. break;
  2261. case '\r':
  2262. e('\\r');
  2263. break;
  2264. case '\t':
  2265. e('\\t');
  2266. break;
  2267. default:
  2268. c = c.charCodeAt();
  2269. e('\\u00' + Math.floor(c / 16).toString(16) +
  2270. (c % 16).toString(16));
  2271. }
  2272. }
  2273. }
  2274. e('"');
  2275. return;
  2276. case 'boolean':
  2277. e(String(x));
  2278. return;
  2279. default:
  2280. e('null');
  2281. return;
  2282. }
  2283. }
  2284. g(v);
  2285. return a.join('');
  2286. },
  2287. /*
  2288. Parse a JSON text, producing a JavaScript value.
  2289. */
  2290. parse: function (text) {
  2291. return
  2292. (/^(\s+|[,:{}\[\]]|"(\\["\\\/bfnrtu]|[^\x00-\x1f"\\]+)*"|-?\d+(\.\d*)?([eE][+-]?\d+)?|true|false|null)+$/.test(text))
  2293. &&
  2294. eval('(' + text + ')');
  2295. }
  2296. };// serializer/haSerializer.js
  2297. /**
  2298. * HTML_AJAX_Serialize_HA - custom serialization
  2299. *
  2300. * This class is used with the JSON serializer and the HTML_AJAX_Action php class
  2301. * to allow users to easily write data handling and dom manipulation related to
  2302. * ajax actions directly from their php code
  2303. *
  2304. * See Main.js for Author/license details
  2305. */
  2306. function HTML_AJAX_Serialize_HA() { }
  2307. HTML_AJAX_Serialize_HA.prototype =
  2308. {
  2309. /**
  2310. *
Runtime error #stdin #stdout 0.01s 4980KB
stdin
Standard input is empty
stdout
Standard output is empty