[ Index ] |
|
Code source de Seagull 0.6.1 |
1 // Compat.js 2 if (!String.fromCharCode && !String.prototype.fromCharCode) { 3 String.prototype.fromCharCode = function(code) 4 { 5 var h = code.toString(16); 6 if (h.length == 1) { 7 h = '0' + h; 8 } 9 return unescape('%' + h); 10 } 11 } 12 if (!String.charCodeAt && !String.prototype.charCodeAt) { 13 String.prototype.charCodeAt = function(index) 14 { 15 var c = this.charAt(index); 16 for (i = 1; i < 256; i++) { 17 if (String.fromCharCode(i) == c) { 18 return i; 19 } 20 } 21 } 22 } 23 if (!Array.splice && !Array.prototype.splice) { 24 Array.prototype.splice = function(s, d) 25 { 26 var max = Math.max, 27 min = Math.min, 28 a = [], // The return value array 29 e, // element 30 i = max(arguments.length - 2, 0), // insert count 31 k = 0, 32 l = this.length, 33 n, // new length 34 v, // delta 35 x; // shift count 36 s = s || 0; 37 if (s < 0) { 38 s += l; 39 } 40 s = max(min(s, l), 0); // start point 41 d = max(min(typeof d == 'number' ? d : l, l - s), 0); // delete count 42 v = i - d; 43 n = l + v; 44 while (k < d) { 45 e = this[s + k]; 46 if (!e) { 47 a[k] = e; 48 } 49 k += 1; 50 } 51 x = l - s - d; 52 if (v < 0) { 53 k = s + i; 54 while (x) { 55 this[k] = this[k - v]; 56 k += 1; 57 x -= 1; 58 } 59 this.length = n; 60 } else if (v > 0) { 61 k = 1; 62 while (x) { 63 this[n - k] = this[l - k]; 64 k += 1; 65 x -= 1; 66 } 67 } 68 for (k = 0; k < i; ++k) { 69 this[s + k] = arguments[k + 2]; 70 } 71 return a; 72 } 73 } 74 if (!Array.push && !Array.prototype.push) { 75 Array.prototype.push = function() 76 { 77 for (var i = 0, startLength = this.length; i < arguments.length; i++) { 78 this[startLength + i] = arguments[i]; 79 } 80 return this.length; 81 } 82 } 83 if (!Array.pop && !Array.prototype.pop) { 84 Array.prototype.pop = function() 85 { 86 return this.splice(this.length - 1, 1)[0]; 87 } 88 } 89 if (!DOMParser.parseFromString && window.ActiveXObject) 90 { 91 function DOMParser() {/* empty constructor */}; 92 DOMParser.prototype = { 93 parseFromString: function(str, contentType) { 94 var xmlDocument = new ActiveXObject('Microsoft.XMLDOM'); 95 xmlDocument.loadXML(str); 96 return xmlDocument; 97 } 98 }; 99 function XMLSerializer() {/* empty constructor */}; 100 XMLSerializer.prototype = { 101 serializeToString: function(root) { 102 return root.xml || root.outerHTML; 103 } 104 }; 105 } 106 // Main.js 107 var HTML_AJAX = { 108 defaultServerUrl: false, 109 defaultEncoding: 'JSON', 110 queues: false, 111 clientPools: {}, 112 httpClient: function(name) { 113 if (name) { 114 if (this.clientPools[name]) { 115 return this.clientPools[name].getClient(); 116 } 117 } 118 return this.clientPools['default'].getClient(); 119 }, 120 makeRequest: function(request) { 121 if (!HTML_AJAX.queues[request.queue]) { 122 var e = new Error('Unknown Queue: '+request.queue); 123 if (HTML_AJAX.onError) { 124 HTML_AJAX.onError(e); 125 return false; 126 } 127 else { 128 throw(e); 129 } 130 } 131 else { 132 var qn = request.queue; 133 var q = HTML_AJAX.queues[qn]; 134 HTML_AJAX.queues[request.queue].addRequest(request); 135 return HTML_AJAX.queues[request.queue].processRequest(); 136 } 137 }, 138 serializerForEncoding: function(encoding) { 139 for(var i in HTML_AJAX.contentTypeMap) { 140 if (encoding == HTML_AJAX.contentTypeMap[i] || encoding == i) { 141 return eval("new HTML_AJAX_Serialize_"+i+";"); 142 } 143 } 144 return new HTML_AJAX_Serialize_Null(); 145 }, 146 fullcall: function(url,encoding,className,method,callback,args, options) { 147 var serializer = HTML_AJAX.serializerForEncoding(encoding); 148 var request = new HTML_AJAX_Request(serializer); 149 if (callback) { 150 request.isAsync = true; 151 } 152 request.requestUrl = url; 153 request.className = className; 154 request.methodName = method; 155 request.callback = callback; 156 request.args = args; 157 if (options) { 158 for(var i in options) { 159 request[i] = options[i]; 160 } 161 if (options.grab) { 162 if (!request.args || !request.args.length) { 163 request.requestType = 'GET'; 164 } 165 } 166 } 167 return HTML_AJAX.makeRequest(request); 168 }, 169 callPhpCallback: function(phpCallback, jsCallback, url) { 170 var args = new Array(); 171 for (var i = 3; i < arguments.length; i++) { 172 args.push(arguments[i]); 173 } 174 if (HTML_AJAX_Util.getType(phpCallback[0]) == 'object') { 175 jsCallback(phpCallback[0][phpCallback[1]](args)); 176 return; 177 } 178 if (!url) { 179 url = HTML_AJAX.defaultServerUrl; 180 } 181 HTML_AJAX.fullcall(url, HTML_AJAX.defaultEncoding, 182 false, false, jsCallback, args, {phpCallback: phpCallback}); 183 }, 184 call: function(className,method,callback) { 185 var args = new Array(); 186 for(var i = 3; i < arguments.length; i++) { 187 args.push(arguments[i]); 188 } 189 return HTML_AJAX.fullcall(HTML_AJAX.defaultServerUrl,HTML_AJAX.defaultEncoding,className,method,callback,args); 190 }, 191 grab: function(url,callback,options) { 192 if (!options) { 193 options = {grab:true}; 194 } 195 else { 196 options['grab'] = true; 197 } 198 return HTML_AJAX.fullcall(url,'Null',false,null,callback, '', options); 199 }, 200 post: function(url,payload,callback,options) { 201 var serializer = 'Null'; 202 if (HTML_AJAX_Util.getType(payload) == 'object') { 203 serializer = 'Urlencoded'; 204 } 205 return HTML_AJAX.fullcall(url,serializer,false,null,callback, payload, options); 206 }, 207 replace: function(id) { 208 var callback = function(result) { 209 HTML_AJAX_Util.setInnerHTML(document.getElementById(id),result); 210 } 211 if (arguments.length == 2) { 212 HTML_AJAX.grab(arguments[1],callback); 213 } 214 else { 215 var args = new Array(); 216 for(var i = 3; i < arguments.length; i++) { 217 args.push(arguments[i]); 218 } 219 HTML_AJAX.fullcall(HTML_AJAX.defaultServerUrl,HTML_AJAX.defaultEncoding,arguments[1],arguments[2],callback,args, {grab:true}); 220 } 221 }, 222 append: function(id) { 223 var callback = function(result) { 224 HTML_AJAX_Util.setInnerHTML(document.getElementById(id),result,'append'); 225 } 226 if (arguments.length == 2) { 227 HTML_AJAX.grab(arguments[1],callback); 228 } 229 else { 230 var args = new Array(); 231 for(var i = 3; i < arguments.length; i++) { 232 args.push(arguments[i]); 233 } 234 HTML_AJAX.fullcall(HTML_AJAX.defaultServerUrl,HTML_AJAX.defaultEncoding,arguments[1],arguments[2],callback,args, {grab:true}); 235 } 236 }, 237 Open: function(request) { 238 }, 239 Load: function(request) { 240 }, 241 contentTypeMap: { 242 'JSON': 'application/json', 243 'Null': 'text/plain', 244 'Error': 'application/error', 245 'PHP': 'application/php-serialized', 246 'HA' : 'application/html_ajax_action', 247 'Urlencoded': 'application/x-www-form-urlencoded' 248 }, 249 requestComplete: function(request,error) { 250 for(var i in HTML_AJAX.queues) { 251 if (HTML_AJAX.queues[i].requestComplete) { 252 HTML_AJAX.queues[i].requestComplete(request,error); 253 } 254 } 255 }, 256 formEncode: function(form, array_format) { 257 form = HTML_AJAX_Util.getElement(form); 258 var el, inpType, value, name; 259 var out = (array_format) ? {} : ''; 260 var inputTags = form.getElementsByTagName('INPUT'); 261 var selectTags = form.getElementsByTagName('SELECT'); 262 var buttonTags = form.getElementsByTagName('BUTTON'); 263 var textareaTags = form.getElementsByTagName('TEXTAREA'); 264 var arrayRegex = /(.+)%5B%5D/; 265 var validElement = function (element) { 266 if (!element || !element.getAttribute) { 267 return false; 268 } 269 el = element; 270 name = HTML_AJAX_Util.encodeUrl(el.getAttribute('name')); 271 if (!name) { 272 return false; 273 } 274 if (element.disabled) { 275 return false; 276 } 277 if (!array_format) { 278 value = HTML_AJAX_Util.encodeUrl(el.value); 279 } else { 280 value = el.value; 281 } 282 inpType = el.getAttribute('type'); 283 return true; 284 } 285 inputLoop: 286 for (var i=0; i < inputTags.length; i++) { 287 if (!validElement(inputTags[i])) { 288 continue; 289 } 290 if (inpType == 'checkbox' || inpType == 'radio') { 291 if (!el.checked) { 292 continue inputLoop; 293 } 294 var arr_var = arrayRegex.exec(name); 295 if (array_format && arr_var) { 296 if (!out[arr_var[1]]) { 297 out[arr_var[1]] = new Array(); 298 } 299 out[arr_var[1]].push(value); 300 continue inputLoop; 301 } 302 } 303 if (array_format) { 304 out[name] = value; 305 } else { 306 out += name + '=' + value + '&'; 307 } 308 } // end inputLoop 309 selectLoop: 310 for (var i=0; i<selectTags.length; i++) { 311 if (!validElement(selectTags[i])) { 312 continue selectLoop; 313 } 314 var options = el.options; 315 for (var z=0; z<options.length; z++){ 316 var option=options[z]; 317 if(option.selected){ 318 if (array_format) { 319 if (el.type == 'select-one') { 320 out[name] = option.value; 321 continue selectLoop; 322 } else { 323 if (!out[name]) { 324 out[name] = new Array(); 325 } 326 out[name].push(option.value); 327 } 328 } else { 329 out += name + '=' + option.value + '&'; 330 if (el.type == 'select-one') { 331 continue selectLoop; 332 } 333 } 334 } 335 } 336 } // end selectLoop 337 buttonLoop: 338 for (var i=0; i<buttonTags.length; i++) { 339 if (!validElement(buttonTags[i])) { 340 continue; 341 } 342 if (array_format) { 343 out[name] = value; 344 } else { 345 out += name + '=' + value + '&'; 346 } 347 } // end buttonLoop 348 textareaLoop: 349 for (var i=0; i<textareaTags.length; i++) { 350 if (!validElement(textareaTags[i])) { 351 continue; 352 } 353 if (array_format) { 354 out[name] = value; 355 } else { 356 out += name + '=' + value + '&'; 357 } 358 } // end textareaLoop 359 return out; 360 }, 361 formSubmit: function (form, target, options) 362 { 363 form = HTML_AJAX_Util.getElement(form); 364 if (!form) { 365 return false; 366 } 367 var out = HTML_AJAX.formEncode(form); 368 target = HTML_AJAX_Util.getElement(target); 369 if (!target) { 370 target = form; 371 } 372 var action = form.attributes['action'].value; 373 var callback = function(result) { 374 HTML_AJAX_Util.setInnerHTML(target,result); 375 } 376 var serializer = HTML_AJAX.serializerForEncoding('Null'); 377 var request = new HTML_AJAX_Request(serializer); 378 request.isAsync = true; 379 request.callback = callback; 380 switch (form.getAttribute('method').toLowerCase()) { 381 case 'post': 382 var headers = {}; 383 headers['Content-Type'] = 'application/x-www-form-urlencoded'; 384 request.customHeaders = headers; 385 request.requestType = 'POST'; 386 request.requestUrl = action; 387 request.args = out; 388 break; 389 default: 390 if (action.indexOf('?') == -1) { 391 out = '?' + out.substr(0, out.length - 1); 392 } 393 request.requestUrl = action+out; 394 request.requestType = 'GET'; 395 } 396 if(options) { 397 for(var i in options) { 398 request[i] = options[i]; 399 } 400 } 401 HTML_AJAX.makeRequest(request); 402 return true; 403 }, // end formSubmit() 404 makeFormAJAX: function(form,target,options) { 405 form = HTML_AJAX_Util.getElement(form); 406 var preSubmit = false; 407 if(typeof form.onsubmit != 'undefined') { 408 preSubmit = form.onsubmit; 409 form.onsubmit = function() {}; 410 } 411 form.HAOptions = options; 412 var handler = function(e) { 413 var form = HTML_AJAX_Util.eventTarget(e); 414 var valid = true; 415 if (preSubmit) { 416 valid = preSubmit(); 417 } 418 if (valid) { 419 HTML_AJAX.formSubmit(form,target,form.HAOptions); 420 } 421 e.returnValue = false; 422 if (e.preventDefault) { 423 e.preventDefault(); 424 } 425 } 426 HTML_AJAX_Util.registerEvent(form,'submit',handler); 427 } 428 } 429 function HTML_AJAX_Serialize_Null() {} 430 HTML_AJAX_Serialize_Null.prototype = { 431 contentType: 'text/plain; charset=utf-8', 432 serialize: function(input) { 433 return new String(input).valueOf(); 434 }, 435 unserialize: function(input) { 436 return new String(input).valueOf(); 437 } 438 } 439 function HTML_AJAX_Serialize_XML() {} 440 HTML_AJAX_Serialize_XML.prototype = { 441 contentType: 'application/xml; charset=utf-8', 442 serialize: function(input) { 443 var xml = ''; 444 if(typeof(input) == 'object' && input) 445 { 446 for (var i = 0;i<input.length;i++) 447 { 448 xml += new XMLSerializer().serializeToString(input[i]); 449 } 450 } 451 return xml; 452 }, 453 unserialize: function(input) { 454 return input; 455 } 456 } 457 function HTML_AJAX_Serialize_JSON() {} 458 HTML_AJAX_Serialize_JSON.prototype = { 459 contentType: 'application/json; charset=utf-8', 460 serialize: function(input) { 461 return HTML_AJAX_JSON.stringify(input); 462 }, 463 unserialize: function(input) { 464 try { 465 return eval('('+input+')'); 466 } catch(e) { 467 return HTML_AJAX_JSON.parse(input); 468 } 469 } 470 } 471 function HTML_AJAX_Serialize_Error() {} 472 HTML_AJAX_Serialize_Error.prototype = { 473 contentType: 'application/error; charset=utf-8', 474 serialize: function(input) { 475 var ser = new HTML_AJAX_Serialize_JSON(); 476 return ser.serialize(input); 477 }, 478 unserialize: function(input) { 479 var ser = new HTML_AJAX_Serialize_JSON(); 480 var data = new ser.unserialize(input); 481 var e = new Error('PHP Error: '+data.errStr); 482 for(var i in data) { 483 e[i] = data[i]; 484 } 485 throw e; 486 } 487 } 488 function HTML_AJAX_Queue_Immediate() {} 489 HTML_AJAX_Queue_Immediate.prototype = { 490 request: false, 491 addRequest: function(request) { 492 this.request = request; 493 }, 494 processRequest: function() { 495 var client = HTML_AJAX.httpClient(); 496 client.request = this.request; 497 return client.makeRequest(); 498 } 499 } 500 HTML_AJAX.queues = new Object(); 501 HTML_AJAX.queues['default'] = new HTML_AJAX_Queue_Immediate(); 502 // Queue.js 503 function HTML_AJAX_Queue_Interval_SingleBuffer(interval,singleOutstandingRequest) { 504 this.interval = interval; 505 if (singleOutstandingRequest) { 506 this.singleOutstandingRequest = true; 507 } 508 } 509 HTML_AJAX_Queue_Interval_SingleBuffer.prototype = { 510 request: false, 511 _intervalId: false, 512 singleOutstandingRequest: false, 513 client: false, 514 addRequest: function(request) { 515 this.request = request; 516 }, 517 processRequest: function() { 518 if (!this._intervalId) { 519 this.runInterval(); 520 this.start(); 521 } 522 }, 523 start: function() { 524 var self = this; 525 this._intervalId = setInterval(function() { self.runInterval() },this.interval); 526 }, 527 stop: function() { 528 clearInterval(this._intervalId); 529 }, 530 runInterval: function() { 531 if (this.request) { 532 if (this.singleOutstandingRequest && this.client) { 533 this.client.abort(); 534 } 535 this.client = HTML_AJAX.httpClient(); 536 this.client.request = this.request; 537 this.request = false; 538 this.client.makeRequest(); 539 } 540 } 541 } 542 function HTML_AJAX_Queue_Ordered() { } 543 HTML_AJAX_Queue_Ordered.prototype = { 544 request: false, 545 order: 0, 546 current: 0, 547 callbacks: {}, 548 interned: {}, 549 addRequest: function(request) { 550 request.order = this.order; 551 this.request = request; 552 this.callbacks[this.order] = this.request.callback; 553 var self = this; 554 this.request.callback = function(result) { 555 self.processCallback(result,request.order); 556 } 557 }, 558 processRequest: function() { 559 var client = HTML_AJAX.httpClient(); 560 client.request = this.request; 561 client.makeRequest(); 562 this.order++; 563 }, 564 requestComplete: function(request,e) { 565 if (e) { 566 this.current++; 567 } 568 }, 569 processCallback: function(result,order) { 570 if (order == this.current) { 571 this.callbacks[order](result); 572 this.current++; 573 } 574 else { 575 this.interned[order] = result; 576 if (this.interned[this.current]) { 577 this.callbacks[this.current](this.interned[this.current]); 578 this.current++; 579 } 580 } 581 } 582 } 583 function HTML_AJAX_Queue_Single() { 584 } 585 HTML_AJAX_Queue_Single.prototype = { 586 request: false, 587 client: false, 588 addRequest: function(request) { 589 this.request = request; 590 }, 591 processRequest: function() { 592 if (this.request) { 593 if (this.client) { 594 this.client.abort(); 595 } 596 this.client = HTML_AJAX.httpClient(); 597 this.client.request = this.request; 598 this.request = false; 599 this.client.makeRequest(); 600 } 601 } 602 } 603 function HTML_AJAX_Queue_Priority_Item(item, time) { 604 this.item = item; 605 this.time = time; 606 } 607 HTML_AJAX_Queue_Priority_Item.prototype = { 608 compareTo: function (other) { 609 var ret = this.item.compareTo(other.item); 610 if (ret == 0) { 611 ret = this.time - other.time; 612 } 613 return ret; 614 } 615 } 616 function HTML_AJAX_Queue_Priority_Simple(interval) { 617 this.interval = interval; 618 this.idleMax = 10; // keep the interval going with an empty queue for 10 intervals 619 this.requestTimeout = 5; // retry uncompleted requests after 5 seconds 620 this.checkRetryChance = 0.1; // check for uncompleted requests to retry on 10% of intervals 621 this._intervalId = 0; 622 this._requests = []; 623 this._removed = []; 624 this._len = 0; 625 this._removedLen = 0; 626 this._idle = 0; 627 } 628 HTML_AJAX_Queue_Priority_Simple.prototype = { 629 isEmpty: function () { 630 return this._len == 0; 631 }, 632 addRequest: function (request) { 633 request = new HTML_AJAX_Queue_Priority_Item(request, new Date().getTime()); 634 ++this._len; 635 if (this.isEmpty()) { 636 this._requests[0] = request; 637 return; 638 } 639 for (i = 0; i < this._len - 1; i++) { 640 if (request.compareTo(this._requests[i]) < 0) { 641 this._requests.splice(i, 1, request, this._requests[i]); 642 return; 643 } 644 } 645 this._requests.push(request); 646 }, 647 peek: function () { 648 return (this.isEmpty() ? false : this._requests[0]); 649 }, 650 requestComplete: function (request) { 651 for (i = 0; i < this._removedLen; i++) { 652 if (this._removed[i].item == request) { 653 this._removed.splice(i, 1); 654 --this._removedLen; 655 out('removed from _removed'); 656 return true; 657 } 658 } 659 return false; 660 }, 661 processRequest: function() { 662 if (!this._intervalId) { 663 this._runInterval(); 664 this._start(); 665 } 666 this._idle = 0; 667 }, 668 _runInterval: function() { 669 if (Math.random() < this.checkRetryChance) { 670 this._doRetries(); 671 } 672 if (this.isEmpty()) { 673 if (++this._idle > this.idleMax) { 674 this._stop(); 675 } 676 return; 677 } 678 var client = HTML_AJAX.httpClient(); 679 if (!client) { 680 return; 681 } 682 var request = this.peek(); 683 if (!request) { 684 this._requests.splice(0, 1); 685 return; 686 } 687 client.request = request.item; 688 client.makeRequest(); 689 this._requests.splice(0, 1); 690 --this._len; 691 this._removed[this._removedLen++] = new HTML_AJAX_Queue_Priority_Item(request, new Date().getTime()); 692 }, 693 _doRetries: function () { 694 for (i = 0; i < this._removedLen; i++) { 695 if (this._removed[i].time + this._requestTimeout < new Date().getTime()) { 696 this.addRequest(request.item); 697 this._removed.splice(i, 1); 698 --this._removedLen; 699 return true; 700 } 701 } 702 }, 703 _start: function() { 704 var self = this; 705 this._intervalId = setInterval(function() { self._runInterval() }, this.interval); 706 }, 707 _stop: function() { 708 clearInterval(this._intervalId); 709 this._intervalId = 0; 710 } 711 }; 712 // clientPool.js 713 HTML_AJAX_Client_Pool = function(maxClients, startingClients) 714 { 715 this.maxClients = maxClients; 716 this._clients = []; 717 this._len = 0; 718 while (--startingClients > 0) { 719 this.addClient(); 720 } 721 } 722 HTML_AJAX_Client_Pool.prototype = { 723 isEmpty: function() 724 { 725 return this._len == 0; 726 }, 727 addClient: function() 728 { 729 if (this.maxClients != 0 && this._len > this.maxClients) { 730 return false; 731 } 732 var key = this._len++; 733 this._clients[key] = new HTML_AJAX_HttpClient(); 734 return this._clients[key]; 735 }, 736 getClient: function () 737 { 738 for (var i = 0; i < this._len; i++) { 739 if (!this._clients[i].callInProgress() && this._clients[i].callbackComplete) { 740 return this._clients[i]; 741 } 742 } 743 var client = this.addClient(); 744 if (client) { 745 return client; 746 } 747 return false; 748 }, 749 removeClient: function (client) 750 { 751 for (var i = 0; i < this._len; i++) { 752 if (!this._clients[i] == client) { 753 this._clients.splice(i, 1); 754 return true; 755 } 756 } 757 return false; 758 }, 759 clear: function () 760 { 761 this._clients = []; 762 this._len = 0; 763 } 764 }; 765 HTML_AJAX.clientPools['default'] = new HTML_AJAX_Client_Pool(0); 766 // IframeXHR.js 767 HTML_AJAX_IframeXHR_instances = new Object(); 768 function HTML_AJAX_IframeXHR() 769 { 770 this._id = 'HAXHR_iframe_' + new Date().getTime(); 771 HTML_AJAX_IframeXHR_instances[this._id] = this; 772 } 773 HTML_AJAX_IframeXHR.prototype = { 774 onreadystatechange: null, // Event handler for an event that fires at every state change 775 readyState: 0, // Object status integer: 0 = uninitialized 1 = loading 2 = loaded 3 = interactive 4 = complete 776 responseText: '', // String version of data returned from server process 777 responseXML: null, // DOM-compatible document object of data returned from server process 778 status: 0, // Numeric code returned by server, such as 404 for "Not Found" or 200 for "OK" 779 statusText: '', // String message accompanying the status code 780 iframe: true, // flag for iframe 781 _id: null, // iframe id, unique to object(hopefully) 782 _url: null, // url sent by open 783 _method: null, // get or post 784 _async: null, // sync or async sent by open 785 _headers: new Object(), //request headers to send, actually sent as form vars 786 _response: new Object(), //response headers received 787 _phpclass: null, //class to send 788 _phpmethod: null, //method to send 789 _history: null, // opera has to have history munging 790 abort: function() 791 { 792 var iframe = document.getElementById(this._id); 793 if (iframe) { 794 document.body.removeChild(iframe); 795 } 796 if (this._timeout) { 797 window.clearTimeout(this._timeout); 798 } 799 this.readyState = 1; 800 if (typeof(this.onreadystatechange) == "function") { 801 this.onreadystatechange(); 802 } 803 }, 804 getAllResponseHeaders: function() 805 { 806 var string = ''; 807 for (i in this._response) { 808 string += i + ' : ' + this._response[i] + "\n"; 809 } 810 return string; 811 }, 812 getResponseHeader: function(header) 813 { 814 return (this._response[header] ? this._response[header] : null); 815 }, 816 setRequestHeader: function(label, value) { 817 this._headers[label] = value; 818 return; }, 819 open: function(method, url, async, username, password) 820 { 821 if (!document.body) { 822 throw('CANNOT_OPEN_SEND_IN_DOCUMENT_HEAD'); 823 } 824 if (!method || !url) { 825 throw('NOT_ENOUGH_ARGUMENTS:METHOD_URL_REQUIRED'); 826 } 827 this._method = (method.toUpperCase() == 'POST' ? 'POST' : 'GET'); 828 this._decodeUrl(url); 829 this._async = async; 830 if(!this._async && document.readyState && !window.opera) { 831 throw('IE_DOES_NOT_SUPPORT_SYNC_WITH_IFRAMEXHR'); 832 } 833 this.readyState = 1; 834 if(typeof(this.onreadystatechange) == "function") { 835 this.onreadystatechange(); 836 } 837 }, 838 send: function(content) 839 { 840 if (window.opera) { 841 this._history = window.history.length; 842 } 843 var form = '<html><body><form method="' 844 + (this._url.indexOf('px=') < 0 ? this._method : 'post') 845 + '" action="' + this._url + '">'; 846 form += '<input name="Iframe_XHR" value="1" />'; 847 if (this._phpclass != null) { 848 form += '<input name="Iframe_XHR_class" value="' + this._phpclass + '" />'; 849 } 850 if (this._phpmethod != null) { 851 form += '<input name="Iframe_XHR_method" value="' + this._phpmethod + '" />'; 852 } 853 for (label in this._headers) { 854 form += '<textarea name="Iframe_XHR_headers[]">' + label +':'+ this._headers[label] + '</textarea>'; 855 } 856 form += '<textarea name="Iframe_XHR_id">' + this._id + '</textarea>'; 857 if (content != null && content.length > 0) { 858 form += '<textarea name="Iframe_XHR_data">' + content + '</textarea>'; 859 } 860 form += '<input name="Iframe_XHR_HTTP_method" value="' + this._method + '" />'; 861 form += '<s'+'cript>document.forms[0].submit();</s'+'cript></form></body></html>'; 862 form = "javascript:document.write('" + form.replace(/\'/g,"\\'") + "');void(0);"; 863 this.readyState = 2; 864 if (typeof(this.onreadystatechange) == "function") { 865 this.onreadystatechange(); 866 } 867 try { 868 var iframe = document.createElement('iframe'); 869 iframe.id = this._id; 870 iframe.style.visibility = 'hidden'; 871 iframe.style.border = '0'; 872 iframe.style.width = '0'; 873 iframe.style.height = '0'; 874 if (document.all) { 875 iframe.src = form; 876 document.body.appendChild(iframe); 877 } else { 878 document.body.appendChild(iframe); 879 iframe.src = form; 880 } 881 } catch(exception) { 882 var html = '<iframe src="' + form +'" id="' + this._id + '" style="visibility:hidden;border:0;height:0;width:0;"></iframe>'; 883 document.body.innerHTML += html; 884 } 885 if (this._async == true) { 886 if (this.readyState < 3) { 887 this.readyState = 3; 888 if(typeof(this.onreadystatechange) == "function") { 889 this.onreadystatechange(); 890 } 891 } 892 } else { 893 while (this.readyState != 4) { 894 if (this.readyState < 3) { 895 this.readyState = 3; 896 if(typeof(this.onreadystatechange) == "function") { 897 this.onreadystatechange(); 898 } 899 } 900 } 901 } 902 }, 903 isLoaded: function(headers, data) 904 { 905 this.readyState = 4; 906 this.status = 200; 907 this.statusText = 'OK'; 908 this.responseText = data; 909 this._response = headers; 910 if (!this._response['Last-Modified']) { 911 string += 'Last-Modified : ' + document.getElementById(this._id).lastModified + "\n"; 912 } 913 if (!this._response['Content-Type']) { 914 string += 'Content-Type : ' + document.getElementById(this._id).contentType + "\n"; 915 } 916 if (this._response['Content-Type'] == 'application/xml') 917 { 918 return new DOMParser().parseFromString(this.responseText, 'application/xml'); 919 } 920 if (window.opera && window.opera.version) { 921 window.history.go(this._history - window.history.length); 922 } 923 if (typeof(this.onreadystatechange) == "function") { 924 this.onreadystatechange(); 925 } 926 document.body.removeChild(document.getElementById(this._id)); 927 }, 928 _decodeUrl: function(querystring) 929 { 930 var url = unescape(location.href); 931 url = url.substring(0, url.lastIndexOf("/") + 1); 932 var item = querystring.split('?'); 933 this._url = url + item[0].substring(item[0].lastIndexOf("/") + 1,item[0].length); 934 if(item[1]) { 935 item = item[1].split('&'); 936 for (i in item) { 937 var v = item[i].split('='); 938 if (v[0] == 'c') { 939 this._phpclass = v[1]; 940 } else if (v[0] == 'm') { 941 this._phpmethod = v[1]; 942 } 943 } 944 } 945 if (!this._phpclass || !this._phpmethod) { 946 var cloc = window.location.href; 947 this._url = cloc + (cloc.indexOf('?') >= 0 ? '&' : '?') + 'px=' + escape(HTML_AJAX_Util.absoluteURL(querystring)); 948 } 949 } 950 } 951 // serializer/UrlSerializer.js 952 function HTML_AJAX_Serialize_Urlencoded() {} 953 HTML_AJAX_Serialize_Urlencoded.prototype = { 954 contentType: 'application/x-www-form-urlencoded; charset=UTF-8', 955 base: '_HTML_AJAX', 956 _keys: [], 957 error: false, 958 message: "", 959 cont: "", 960 serialize: function(input, _internal) { 961 if (typeof input == 'undefined') { 962 return ''; 963 } 964 if (!_internal) { 965 this._keys = []; 966 } 967 var ret = '', first = true; 968 for (i = 0; i < this._keys.length; i++) { 969 ret += (first ? HTML_AJAX_Util.encodeUrl(this._keys[i]) : '[' + HTML_AJAX_Util.encodeUrl(this._keys[i]) + ']'); 970 first = false; 971 } 972 ret += '='; 973 switch (HTML_AJAX_Util.getType(input)) { 974 case 'string': 975 case 'number': 976 ret += HTML_AJAX_Util.encodeUrl(input.toString()); 977 break; 978 case 'boolean': 979 ret += (input ? '1' : '0'); 980 break; 981 case 'array': 982 case 'object': 983 ret = ''; 984 for (i in input) { 985 this._keys.push(i); 986 ret += this.serialize(input[i], true) + '&'; 987 this._keys.pop(); 988 } 989 ret = ret.substr(0, ret.length - 1); 990 } 991 return ret; 992 }, 993 unserialize: function(input) { 994 if (!input.length || input.length == 0) { 995 return; 996 } 997 if (!/^(\w+(\[[^\[\]]*\])*=[^&]*(&|$))+$/.test(input)) { 998 this.raiseError("invalidly formed input", input); 999 return; 1000 } 1001 input = input.split("&"); 1002 var pos, key, keys, val, _HTML_AJAX = []; 1003 if (input.length == 1) { 1004 return HTML_AJAX_Util.decodeUrl(input[0].substr(this.base.length + 1)); 1005 } 1006 for (var i in input) { 1007 pos = input[i].indexOf("="); 1008 if (pos < 1 || input[i].length - pos - 1 < 1) { 1009 this.raiseError("input is too short", input[i]); 1010 return; 1011 } 1012 key = HTML_AJAX_Util.decodeUrl(input[i].substr(0, pos)); 1013 val = HTML_AJAX_Util.decodeUrl(input[i].substr(pos + 1)); 1014 key = key.replace(/\[((\d*\D+)+)\]/g, '["$1"]'); 1015 keys = key.split(']'); 1016 for (j in keys) { 1017 if (!keys[j].length || keys[j].length == 0) { 1018 continue; 1019 } 1020 try { 1021 if (eval('typeof ' + keys[j] + ']') == 'undefined') { 1022 var ev = keys[j] + ']=[];'; 1023 eval(ev); 1024 } 1025 } catch (e) { 1026 this.raiseError("error evaluating key", ev); 1027 return; 1028 } 1029 } 1030 try { 1031 eval(key + '="' + val + '";'); 1032 } catch (e) { 1033 this.raiseError("error evaluating value", input); 1034 return; 1035 } 1036 } 1037 return _HTML_AJAX; 1038 }, 1039 getError: function() { 1040 return this.message + "\n" + this.cont; 1041 }, 1042 raiseError: function(message, cont) { 1043 this.error = 1; 1044 this.message = message; 1045 this.cont = cont; 1046 } 1047 } 1048 // serializer/phpSerializer.js 1049 function HTML_AJAX_Serialize_PHP() {} 1050 HTML_AJAX_Serialize_PHP.prototype = { 1051 error: false, 1052 message: "", 1053 cont: "", 1054 defaultEncoding: 'UTF-8', 1055 contentType: 'application/php-serialized; charset: UTF-8', 1056 serialize: function(inp) { 1057 var type = HTML_AJAX_Util.getType(inp); 1058 var val; 1059 switch (type) { 1060 case "undefined": 1061 val = "N"; 1062 break; 1063 case "boolean": 1064 val = "b:" + (inp ? "1" : "0"); 1065 break; 1066 case "number": 1067 val = (Math.round(inp) == inp ? "i" : "d") + ":" + inp; 1068 break; 1069 case "string": 1070 val = "s:" + inp.length + ":\"" + inp + "\""; 1071 break; 1072 case "array": 1073 val = "a"; 1074 case "object": 1075 if (type == "object") { 1076 var objname = inp.constructor.toString().match(/(\w+)\(\)/); 1077 if (objname == undefined) { 1078 return; 1079 } 1080 objname[1] = this.serialize(objname[1]); 1081 val = "O" + objname[1].substring(1, objname[1].length - 1); 1082 } 1083 var count = 0; 1084 var vals = ""; 1085 var okey; 1086 for (key in inp) { 1087 okey = (key.match(/^[0-9]+$/) ? parseInt(key) : key); 1088 vals += this.serialize(okey) + 1089 this.serialize(inp[key]); 1090 count++; 1091 } 1092 val += ":" + count + ":{" + vals + "}"; 1093 break; 1094 } 1095 if (type != "object" && type != "array") val += ";"; 1096 return val; 1097 }, 1098 unserialize: function(inp) { 1099 this.error = 0; 1100 if (inp == "" || inp.length < 2) { 1101 this.raiseError("input is too short"); 1102 return; 1103 } 1104 var val, kret, vret, cval; 1105 var type = inp.charAt(0); 1106 var cont = inp.substring(2); 1107 var size = 0, divpos = 0, endcont = 0, rest = "", next = ""; 1108 switch (type) { 1109 case "N": // null 1110 if (inp.charAt(1) != ";") { 1111 this.raiseError("missing ; for null", cont); 1112 } 1113 rest = cont; 1114 break; 1115 case "b": // boolean 1116 if (!/[01];/.test(cont.substring(0,2))) { 1117 this.raiseError("value not 0 or 1, or missing ; for boolean", cont); 1118 } 1119 val = (cont.charAt(0) == "1"); 1120 rest = cont.substring(1); 1121 break; 1122 case "s": // string 1123 val = ""; 1124 divpos = cont.indexOf(":"); 1125 if (divpos == -1) { 1126 this.raiseError("missing : for string", cont); 1127 break; 1128 } 1129 size = parseInt(cont.substring(0, divpos)); 1130 if (size == 0) { 1131 if (cont.length - divpos < 4) { 1132 this.raiseError("string is too short", cont); 1133 break; 1134 } 1135 rest = cont.substring(divpos + 4); 1136 break; 1137 } 1138 if ((cont.length - divpos - size) < 4) { 1139 this.raiseError("string is too short", cont); 1140 break; 1141 } 1142 if (cont.substring(divpos + 2 + size, divpos + 4 + size) != "\";") { 1143 this.raiseError("string is too long, or missing \";", cont); 1144 } 1145 val = cont.substring(divpos + 2, divpos + 2 + size); 1146 rest = cont.substring(divpos + 4 + size); 1147 break; 1148 case "i": // integer 1149 case "d": // float 1150 var dotfound = 0; 1151 for (var i = 0; i < cont.length; i++) { 1152 cval = cont.charAt(i); 1153 if (isNaN(parseInt(cval)) && !(type == "d" && cval == "." && !dotfound++)) { 1154 endcont = i; 1155 break; 1156 } 1157 } 1158 if (!endcont || cont.charAt(endcont) != ";") { 1159 this.raiseError("missing or invalid value, or missing ; for int/float", cont); 1160 } 1161 val = cont.substring(0, endcont); 1162 val = (type == "i" ? parseInt(val) : parseFloat(val)); 1163 rest = cont.substring(endcont + 1); 1164 break; 1165 case "a": // array 1166 if (cont.length < 4) { 1167 this.raiseError("array is too short", cont); 1168 return; 1169 } 1170 divpos = cont.indexOf(":", 1); 1171 if (divpos == -1) { 1172 this.raiseError("missing : for array", cont); 1173 return; 1174 } 1175 size = parseInt(cont.substring(0, divpos)); 1176 cont = cont.substring(divpos + 2); 1177 val = new Array(); 1178 if (cont.length < 1) { 1179 this.raiseError("array is too short", cont); 1180 return; 1181 } 1182 for (var i = 0; i < size; i++) { 1183 kret = this.unserialize(cont, 1); 1184 if (this.error || kret[0] == undefined || kret[1] == "") { 1185 this.raiseError("missing or invalid key, or missing value for array", cont); 1186 return; 1187 } 1188 vret = this.unserialize(kret[1], 1); 1189 if (this.error) { 1190 this.raiseError("invalid value for array", cont); 1191 return; 1192 } 1193 val[kret[0]] = vret[0]; 1194 cont = vret[1]; 1195 } 1196 if (cont.charAt(0) != "}") { 1197 this.raiseError("missing ending }, or too many values for array", cont); 1198 return; 1199 } 1200 rest = cont.substring(1); 1201 break; 1202 case "O": // object 1203 divpos = cont.indexOf(":"); 1204 if (divpos == -1) { 1205 this.raiseError("missing : for object", cont); 1206 return; 1207 } 1208 size = parseInt(cont.substring(0, divpos)); 1209 var objname = cont.substring(divpos + 2, divpos + 2 + size); 1210 if (cont.substring(divpos + 2 + size, divpos + 4 + size) != "\":") { 1211 this.raiseError("object name is too long, or missing \":", cont); 1212 return; 1213 } 1214 var objprops = this.unserialize("a:" + cont.substring(divpos + 4 + size), 1); 1215 if (this.error) { 1216 this.raiseError("invalid object properties", cont); 1217 return; 1218 } 1219 rest = objprops[1]; 1220 var objout = "function " + objname + "(){"; 1221 for (key in objprops[0]) { 1222 objout += "this." + key + "=objprops[0]['" + key + "'];"; 1223 } 1224 objout += "}val=new " + objname + "();"; 1225 eval(objout); 1226 break; 1227 default: 1228 this.raiseError("invalid input type", cont); 1229 } 1230 return (arguments.length == 1 ? val : [val, rest]); 1231 }, 1232 getError: function() { 1233 return this.message + "\n" + this.cont; 1234 }, 1235 raiseError: function(message, cont) { 1236 this.error = 1; 1237 this.message = message; 1238 this.cont = cont; 1239 } 1240 } 1241 // Dispatcher.js 1242 function HTML_AJAX_Dispatcher(className,mode,callback,serverUrl,serializerType) 1243 { 1244 this.className = className; 1245 this.mode = mode; 1246 this.callback = callback; 1247 this.serializerType = serializerType; 1248 if (serverUrl) { 1249 this.serverUrl = serverUrl 1250 } 1251 else { 1252 this.serverUrl = window.location; 1253 } 1254 } 1255 HTML_AJAX_Dispatcher.prototype = { 1256 queue: 'default', 1257 timeout: 20000, 1258 priority: 0, 1259 options: {}, 1260 doCall: function(callName,args) 1261 { 1262 var request = new HTML_AJAX_Request(); 1263 request.requestUrl = this.serverUrl; 1264 request.className = this.className; 1265 request.methodName = callName; 1266 request.timeout = this.timeout; 1267 request.contentType = this.contentType; 1268 request.serializer = eval('new HTML_AJAX_Serialize_'+this.serializerType); 1269 request.queue = this.queue; 1270 request.priority = this.priority; 1271 for(var i in this.options) { 1272 request[i] = this.options[i]; 1273 } 1274 for(var i=0; i < args.length; i++) { 1275 request.addArg(i,args[i]); 1276 }; 1277 if ( this.mode == "async" ) { 1278 request.isAsync = true; 1279 if (this.callback[callName]) { 1280 var self = this; 1281 request.callback = function(result) { self.callback[callName](result); } 1282 } 1283 } else { 1284 request.isAsync = false; 1285 } 1286 return HTML_AJAX.makeRequest(request); 1287 }, 1288 Sync: function() 1289 { 1290 this.mode = 'sync'; 1291 }, 1292 Async: function(callback) 1293 { 1294 this.mode = 'async'; 1295 if (callback) { 1296 this.callback = callback; 1297 } 1298 } 1299 }; 1300 // HttpClient.js 1301 function HTML_AJAX_HttpClient() { } 1302 HTML_AJAX_HttpClient.prototype = { 1303 request: null, 1304 _timeoutId: null, 1305 callbackComplete: true, 1306 aborted: false, 1307 init:function() 1308 { 1309 try { 1310 this.xmlhttp = new XMLHttpRequest(); 1311 } catch (e) { 1312 var XMLHTTP_IDS = new Array( 1313 'MSXML2.XMLHTTP.5.0', 1314 'MSXML2.XMLHTTP.4.0', 1315 'MSXML2.XMLHTTP.3.0', 1316 'MSXML2.XMLHTTP', 1317 'Microsoft.XMLHTTP' ); 1318 var success = false; 1319 for (var i=0;i < XMLHTTP_IDS.length && !success; i++) { 1320 try { 1321 this.xmlhttp = new ActiveXObject(XMLHTTP_IDS[i]); 1322 success = true; 1323 } catch (e) {} 1324 } 1325 if (!success) { 1326 try{ 1327 this.xmlhttp = new HTML_AJAX_IframeXHR(); 1328 this.request.iframe = true; 1329 } catch(e) { 1330 throw new Error('Unable to create XMLHttpRequest.'); 1331 } 1332 } 1333 } 1334 }, 1335 callInProgress: function() 1336 { 1337 switch ( this.xmlhttp.readyState ) { 1338 case 1: 1339 case 2: 1340 case 3: 1341 return true; 1342 break; 1343 default: 1344 return false; 1345 break; 1346 } 1347 }, 1348 makeRequest: function() 1349 { 1350 if (!this.xmlhttp) { 1351 this.init(); 1352 } 1353 try { 1354 if (this.request.Open) { 1355 this.request.Open(); 1356 } 1357 else if (HTML_AJAX.Open) { 1358 HTML_AJAX.Open(this.request); 1359 } 1360 if (this.request.multipart) { 1361 if (document.all) { 1362 this.iframe = true; 1363 } else { 1364 this.xmlhttp.multipart = true; 1365 } 1366 } 1367 var self = this; 1368 this.xmlhttp.open(this.request.requestType,this.request.completeUrl(),this.request.isAsync); 1369 if (this.request.customHeaders) { 1370 for (i in this.request.customHeaders) { 1371 this.xmlhttp.setRequestHeader(i, this.request.customHeaders[i]); 1372 } 1373 } 1374 if (this.request.customHeaders && !this.request.customHeaders['Content-Type']) { 1375 var content = this.request.getContentType(); 1376 if(window.opera && content != 'application/xml') 1377 { 1378 this.xmlhttp.setRequestHeader('Content-Type','text/plain; charset=utf-8'); 1379 this.xmlhttp.setRequestHeader('x-Content-Type', content + '; charset=utf-8'); 1380 } 1381 else 1382 { 1383 this.xmlhttp.setRequestHeader('Content-Type', content + '; charset=utf-8'); 1384 } 1385 } 1386 if (this.request.isAsync) { 1387 if (this.request.callback) { 1388 this.callbackComplete = false; 1389 } 1390 this.xmlhttp.onreadystatechange = function() { self._readyStateChangeCallback(); } 1391 } else { 1392 this.xmlhttp.onreadystatechange = function() {} 1393 } 1394 var payload = this.request.getSerializedPayload(); 1395 if (payload) { 1396 this.xmlhttp.setRequestHeader('Content-Length', payload.length); 1397 } 1398 this.xmlhttp.send(payload); 1399 if (!this.request.isAsync) { 1400 if ( this.xmlhttp.status == 200 ) { 1401 HTML_AJAX.requestComplete(this.request); 1402 if (this.request.Load) { 1403 this.request.Load(); 1404 } else if (HTML_AJAX.Load) { 1405 HTML_AJAX.Load(this.request); 1406 } 1407 return this._decodeResponse(); 1408 } else { 1409 var e = new Error('['+this.xmlhttp.status +'] '+this.xmlhttp.statusText); 1410 e.headers = this.xmlhttp.getAllResponseHeaders(); 1411 this._handleError(e); 1412 } 1413 } 1414 else { 1415 var self = this; 1416 this._timeoutId = window.setTimeout(function() { self.abort(true); },this.request.timeout); 1417 } 1418 } catch (e) { 1419 this._handleError(e); 1420 } 1421 }, 1422 abort: function (automatic) 1423 { 1424 if (this.callInProgress()) { 1425 this.aborted = true; 1426 this.xmlhttp.abort(); 1427 if (automatic) { 1428 HTML_AJAX.requestComplete(this.request); 1429 this._handleError(new Error('Request Timed Out: time out was '+this.request.timeout+'ms')); 1430 } 1431 } 1432 }, 1433 _readyStateChangeCallback:function() 1434 { 1435 try { 1436 switch(this.xmlhttp.readyState) { 1437 case 1: 1438 break; 1439 case 2: 1440 if (this.request.Send) { 1441 this.request.Send(); 1442 } else if (HTML_AJAX.Send) { 1443 HTML_AJAX.Send(this.request); 1444 } 1445 break; 1446 case 3: 1447 if (this.request.Progress) { 1448 this.request.Progress(); 1449 } else if (HTML_AJAX.Progress ) { 1450 HTML_AJAX.Progress(this.request); 1451 } 1452 break; 1453 case 4: 1454 window.clearTimeout(this._timeoutId); 1455 if (this.aborted) { 1456 if (this.request.Load) { 1457 this.request.Load(); 1458 } else if (HTML_AJAX.Load) { 1459 HTML_AJAX.Load(this.request); 1460 } 1461 } 1462 else if (this.xmlhttp.status == 200) { 1463 if (this.request.Load) { 1464 this.request.Load(); 1465 } else if (HTML_AJAX.Load ) { 1466 HTML_AJAX.Load(this.request); 1467 } 1468 var response = this._decodeResponse(); 1469 if (this.request.callback) { 1470 this.request.callback(response); 1471 this.callbackComplete = true; 1472 } 1473 } 1474 else { 1475 var e = new Error('HTTP Error Making Request: ['+this.xmlhttp.status+'] '+this.xmlhttp.statusText); 1476 this._handleError(e); 1477 } 1478 HTML_AJAX.requestComplete(this.request); 1479 break; 1480 } 1481 } catch (e) { 1482 this._handleError(e); 1483 } 1484 }, 1485 _decodeResponse: function() { 1486 var content = null; 1487 try { 1488 content = this.xmlhttp.getResponseHeader('X-Content-Type'); 1489 } catch(e) {} 1490 if(!content || content == null) 1491 { 1492 content = this.xmlhttp.getResponseHeader('Content-Type'); 1493 } 1494 if(content.indexOf(';') != -1) 1495 { 1496 content = content.substring(0, content.indexOf(';')); 1497 } 1498 if(content == 'application/xml') 1499 { 1500 return this.xmlhttp.responseXML; 1501 } 1502 var unserializer = HTML_AJAX.serializerForEncoding(content); 1503 return unserializer.unserialize(this.xmlhttp.responseText); 1504 }, 1505 _handleError: function(e) 1506 { 1507 HTML_AJAX.requestComplete(this.request,e); 1508 if (this.request.onError) { 1509 this.request.onError(e); 1510 } else if (HTML_AJAX.onError) { 1511 HTML_AJAX.onError(e,this.request); 1512 } 1513 else { 1514 throw e; 1515 } 1516 } 1517 } 1518 // Request.js 1519 function HTML_AJAX_Request(serializer) { 1520 this.serializer = serializer; 1521 } 1522 HTML_AJAX_Request.prototype = { 1523 serializer: null, 1524 isAsync: false, 1525 requestType: 'POST', 1526 requestUrl: '', 1527 className: null, 1528 methodName: null, 1529 timeout: 20000, 1530 args: null, 1531 callback: null, 1532 queue: 'default', 1533 priority: 0, 1534 customHeaders: {}, 1535 iframe: false, 1536 grab: false, 1537 multipart: false, 1538 phpCallback: false, 1539 addArg: function(name, value) 1540 { 1541 if ( !this.args ) { 1542 this.args = []; 1543 } 1544 if (!/[^a-zA-Z_0-9]/.test(name) ) { 1545 this.args[name] = value; 1546 } else { 1547 throw new Error('Invalid parameter name ('+name+')'); 1548 } 1549 }, 1550 getSerializedPayload: function() { 1551 return this.serializer.serialize(this.args); 1552 }, 1553 getContentType: function() { 1554 return this.serializer.contentType; 1555 }, 1556 completeUrl: function() { 1557 if (this.className || this.methodName) { 1558 this.addGet('c', this.className); 1559 this.addGet('m', this.methodName); 1560 } 1561 if (this.phpCallback) { 1562 if (HTML_AJAX_Util.getType(this.phpCallback) == 'array') { 1563 this.phpCallback = this.phpCallback.join('.'); 1564 } 1565 this.addGet('cb', this.phpCallback); 1566 } 1567 if (this.multipart) { 1568 this.addGet('multipart', '1'); 1569 } 1570 return this.requestUrl; 1571 }, 1572 compareTo: function(other) { 1573 if (this.priority == other.priority) { 1574 return 0; 1575 } 1576 return (this.priority > other.priority ? 1 : -1); 1577 }, 1578 addGet: function(name, value) { 1579 var url = new String(this.requestUrl); 1580 url += (url.indexOf('?') < 0 ? '?' : '&') + escape(name) + '=' + escape(value); 1581 this.requestUrl = url; 1582 } 1583 } 1584 // serializer/JSON.js 1585 Array.prototype.______array = '______array'; 1586 var HTML_AJAX_JSON = { 1587 org: 'http://www.JSON.org', 1588 copyright: '(c)2005 JSON.org', 1589 license: 'http://www.crockford.com/JSON/license.html', 1590 stringify: function (arg) { 1591 var c, i, l, s = '', v; 1592 switch (typeof arg) { 1593 case 'object': 1594 if (arg) { 1595 if (arg.______array == '______array') { 1596 for (i = 0; i < arg.length; ++i) { 1597 v = this.stringify(arg[i]); 1598 if (s) { 1599 s += ','; 1600 } 1601 s += v; 1602 } 1603 return '[' + s + ']'; 1604 } else if (typeof arg.toString != 'undefined') { 1605 for (i in arg) { 1606 v = arg[i]; 1607 if (typeof v != 'undefined' && typeof v != 'function') { 1608 v = this.stringify(v); 1609 if (s) { 1610 s += ','; 1611 } 1612 s += this.stringify(i) + ':' + v; 1613 } 1614 } 1615 return '{' + s + '}'; 1616 } 1617 } 1618 return 'null'; 1619 case 'number': 1620 return isFinite(arg) ? String(arg) : 'null'; 1621 case 'string': 1622 l = arg.length; 1623 s = '"'; 1624 for (i = 0; i < l; i += 1) { 1625 c = arg.charAt(i); 1626 if (c >= ' ') { 1627 if (c == '\\' || c == '"') { 1628 s += '\\'; 1629 } 1630 s += c; 1631 } else { 1632 switch (c) { 1633 case '\b': 1634 s += '\\b'; 1635 break; 1636 case '\f': 1637 s += '\\f'; 1638 break; 1639 case '\n': 1640 s += '\\n'; 1641 break; 1642 case '\r': 1643 s += '\\r'; 1644 break; 1645 case '\t': 1646 s += '\\t'; 1647 break; 1648 default: 1649 c = c.charCodeAt(); 1650 s += '\\u00' + Math.floor(c / 16).toString(16) + 1651 (c % 16).toString(16); 1652 } 1653 } 1654 } 1655 return s + '"'; 1656 case 'boolean': 1657 return String(arg); 1658 default: 1659 return 'null'; 1660 } 1661 }, 1662 parse: function (text) { 1663 var at = 0; 1664 var ch = ' '; 1665 function error(m) { 1666 throw { 1667 name: 'JSONError', 1668 message: m, 1669 at: at - 1, 1670 text: text 1671 }; 1672 } 1673 function next() { 1674 ch = text.charAt(at); 1675 at += 1; 1676 return ch; 1677 } 1678 function white() { 1679 while (ch) { 1680 if (ch <= ' ') { 1681 next(); 1682 } else if (ch == '/') { 1683 switch (next()) { 1684 case '/': 1685 while (next() && ch != '\n' && ch != '\r') {} 1686 break; 1687 case '*': 1688 next(); 1689 for (;;) { 1690 if (ch) { 1691 if (ch == '*') { 1692 if (next() == '/') { 1693 next(); 1694 break; 1695 } 1696 } else { 1697 next(); 1698 } 1699 } else { 1700 error("Unterminated comment"); 1701 } 1702 } 1703 break; 1704 default: 1705 error("Syntax error"); 1706 } 1707 } else { 1708 break; 1709 } 1710 } 1711 } 1712 function string() { 1713 var i, s = '', t, u; 1714 if (ch == '"') { 1715 outer: while (next()) { 1716 if (ch == '"') { 1717 next(); 1718 return s; 1719 } else if (ch == '\\') { 1720 switch (next()) { 1721 case 'b': 1722 s += '\b'; 1723 break; 1724 case 'f': 1725 s += '\f'; 1726 break; 1727 case 'n': 1728 s += '\n'; 1729 break; 1730 case 'r': 1731 s += '\r'; 1732 break; 1733 case 't': 1734 s += '\t'; 1735 break; 1736 case 'u': 1737 u = 0; 1738 for (i = 0; i < 4; i += 1) { 1739 t = parseInt(next(), 16); 1740 if (!isFinite(t)) { 1741 break outer; 1742 } 1743 u = u * 16 + t; 1744 } 1745 s += String.fromCharCode(u); 1746 break; 1747 default: 1748 s += ch; 1749 } 1750 } else { 1751 s += ch; 1752 } 1753 } 1754 } 1755 error("Bad string"); 1756 } 1757 function array() { 1758 var a = []; 1759 if (ch == '[') { 1760 next(); 1761 white(); 1762 if (ch == ']') { 1763 next(); 1764 return a; 1765 } 1766 while (ch) { 1767 a.push(value()); 1768 white(); 1769 if (ch == ']') { 1770 next(); 1771 return a; 1772 } else if (ch != ',') { 1773 break; 1774 } 1775 next(); 1776 white(); 1777 } 1778 } 1779 error("Bad array"); 1780 } 1781 function object() { 1782 var k, o = {}; 1783 if (ch == '{') { 1784 next(); 1785 white(); 1786 if (ch == '}') { 1787 next(); 1788 return o; 1789 } 1790 while (ch) { 1791 k = string(); 1792 white(); 1793 if (ch != ':') { 1794 break; 1795 } 1796 next(); 1797 o[k] = value(); 1798 white(); 1799 if (ch == '}') { 1800 next(); 1801 return o; 1802 } else if (ch != ',') { 1803 break; 1804 } 1805 next(); 1806 white(); 1807 } 1808 } 1809 error("Bad object"); 1810 } 1811 function number() { 1812 var n = '', v; 1813 if (ch == '-') { 1814 n = '-'; 1815 next(); 1816 } 1817 while (ch >= '0' && ch <= '9') { 1818 n += ch; 1819 next(); 1820 } 1821 if (ch == '.') { 1822 n += '.'; 1823 while (next() && ch >= '0' && ch <= '9') { 1824 n += ch; 1825 } 1826 } 1827 if (ch == 'e' || ch == 'E') { 1828 n += 'e'; 1829 next(); 1830 if (ch == '-' || ch == '+') { 1831 n += ch; 1832 next(); 1833 } 1834 while (ch >= '0' && ch <= '9') { 1835 n += ch; 1836 next(); 1837 } 1838 } 1839 v = +n; 1840 if (!isFinite(v)) { 1841 } else { 1842 return v; 1843 } 1844 } 1845 function word() { 1846 switch (ch) { 1847 case 't': 1848 if (next() == 'r' && next() == 'u' && next() == 'e') { 1849 next(); 1850 return true; 1851 } 1852 break; 1853 case 'f': 1854 if (next() == 'a' && next() == 'l' && next() == 's' && 1855 next() == 'e') { 1856 next(); 1857 return false; 1858 } 1859 break; 1860 case 'n': 1861 if (next() == 'u' && next() == 'l' && next() == 'l') { 1862 next(); 1863 return null; 1864 } 1865 break; 1866 } 1867 error("Syntax error"); 1868 } 1869 function value() { 1870 white(); 1871 switch (ch) { 1872 case '{': 1873 return object(); 1874 case '[': 1875 return array(); 1876 case '"': 1877 return string(); 1878 case '-': 1879 return number(); 1880 default: 1881 return ch >= '0' && ch <= '9' ? number() : word(); 1882 } 1883 } 1884 return value(); 1885 } 1886 }; 1887 // serializer/haSerializer.js 1888 function HTML_AJAX_Serialize_HA() { } 1889 HTML_AJAX_Serialize_HA.prototype = 1890 { 1891 unserialize: function(payload) 1892 { 1893 var actions = eval(payload); 1894 for(var i = 0; i < actions.length; i++) 1895 { 1896 var action = actions[i]; 1897 switch(action.action) 1898 { 1899 case 'prepend': 1900 this._prependAttr(action.id, action.attributes); 1901 break; 1902 case 'append': 1903 this._appendAttr(action.id, action.attributes); 1904 break; 1905 case 'assign': 1906 this._assignAttr(action.id, action.attributes); 1907 break; 1908 case 'clear': 1909 this._clearAttr(action.id, action.attributes); 1910 break; 1911 case 'create': 1912 this._createNode(action.id, action.tag, action.attributes, action.type); 1913 break; 1914 case 'replace': 1915 this._replaceNode(action.id, action.tag, action.attributes); 1916 break; 1917 case 'remove': 1918 this._removeNode(action.id); 1919 break; 1920 case 'script': 1921 this._insertScript(action.data); 1922 break; 1923 case 'alert': 1924 this._insertAlert(action.data); 1925 break; 1926 } 1927 } 1928 }, 1929 _prependAttr: function(id, attributes) 1930 { 1931 var node = document.getElementById(id); 1932 for (var i in attributes) 1933 { 1934 if(i == 'innerHTML') 1935 { 1936 HTML_AJAX_Util.setInnerHTML(node, attributes[i], 'prepend'); 1937 } 1938 else if(i == 'value') 1939 { 1940 node.value = attributes[i]; 1941 } 1942 else 1943 { 1944 var value = node.getAttribute(i); 1945 if(value) 1946 { 1947 node.setAttribute(i, attributes[i] + value); 1948 } 1949 else 1950 { 1951 node.setAttribute(i, attributes[i]); 1952 } 1953 } 1954 } 1955 }, 1956 _appendAttr: function(id, attributes) 1957 { 1958 var node = document.getElementById(id); 1959 for (var i in attributes) 1960 { 1961 if(i == 'innerHTML') 1962 { 1963 HTML_AJAX_Util.setInnerHTML(node, attributes[i], 'append'); 1964 } 1965 else if(i == 'value') 1966 { 1967 node.value = attributes[i]; 1968 } 1969 else 1970 { 1971 var value = node.getAttribute(i); 1972 if(value) 1973 { 1974 node.setAttribute(i, value + attributes[i]); 1975 } 1976 else 1977 { 1978 node.setAttribute(i, attributes[i]); 1979 } 1980 } 1981 } 1982 }, 1983 _assignAttr: function(id, attributes) 1984 { 1985 var node = document.getElementById(id); 1986 for (var i in attributes) 1987 { 1988 if(i == 'innerHTML') 1989 { 1990 HTML_AJAX_Util.setInnerHTML(node,attributes[i]); 1991 } 1992 else if(i == 'value') 1993 { 1994 node.value = attributes[i]; 1995 } 1996 else if(i == 'style') 1997 { 1998 var styles = []; 1999 if (attributes[i].indexOf(';')) { 2000 styles = attributes[i].split(';'); 2001 } 2002 else { 2003 styles.push(attributes[i]); 2004 } 2005 for(var i = 0; i < styles.length; i++) { 2006 var r = styles[i].match(/^\s*(.+)\s*:\s*(.+)\s*$/); 2007 if(r) { 2008 node.style[this._camelize(r[1])] = r[2]; 2009 } 2010 } 2011 } 2012 else 2013 { 2014 try { 2015 node[i] = attributes[i]; 2016 } catch(e) { 2017 } 2018 node.setAttribute(i, attributes[i]); 2019 } 2020 } 2021 }, 2022 _camelize: function(instr) 2023 { 2024 var p = instr.split('-'); 2025 var out = p[0]; 2026 for(var i = 1; i < p.length; i++) { 2027 out += p[i].charAt(0).toUpperCase()+p[i].substring(1); 2028 } 2029 return out; 2030 }, 2031 _clearAttr: function(id, attributes) 2032 { 2033 var node = document.getElementById(id); 2034 for(var i = 0; i < attributes.length; i++) 2035 { 2036 if(attributes[i] == 'innerHTML') 2037 { 2038 node.innerHTML = ''; 2039 } 2040 else if(attributes[i] == 'value') 2041 { 2042 node.value = ''; 2043 } 2044 else 2045 { 2046 node.removeAttribute(attributes[i]); 2047 } 2048 } 2049 }, 2050 _createNode: function(id, tag, attributes, type) 2051 { 2052 var newnode = document.createElement(tag); 2053 for (var i in attributes) 2054 { 2055 if(i == 'innerHTML') 2056 { 2057 newnode.innerHTML = attributes[i]; 2058 } 2059 else if(i == 'value') 2060 { 2061 newnode.value = attributes[i]; 2062 } 2063 else 2064 { 2065 newnode.setAttribute(i, attributes[i]); 2066 } 2067 } 2068 switch(type) 2069 { 2070 case 'append': 2071 document.getElementById(id).appendChild(newnode); 2072 break 2073 case 'prepend': 2074 var parent = document.getElementById(id); 2075 var sibling = parent.firstChild; 2076 parent.insertBefore(newnode, sibling); 2077 break; 2078 case 'insertBefore': 2079 var sibling = document.getElementById(id); 2080 var parent = sibling.parentNode; 2081 parent.insertBefore(newnode, sibling); 2082 break; 2083 case 'insertAfter': 2084 var sibling = document.getElementById(id); 2085 var parent = sibling.parentNode; 2086 var next = sibling.nextSibling; 2087 if(next == null) 2088 { 2089 parent.appendChild(newnode); 2090 } 2091 else 2092 { 2093 parent.insertBefore(newnode, next); 2094 } 2095 break; 2096 } 2097 }, 2098 _replaceNode: function(id, tag, attributes) 2099 { 2100 var node = document.getElementById(id); 2101 var parent = node.parentNode; 2102 var newnode = document.createElement(tag); 2103 for (var i in attributes) 2104 { 2105 if(i == 'innerHTML') 2106 { 2107 newnode.innerHTML = attributes[i]; 2108 } 2109 else if(i == 'value') 2110 { 2111 newnode.value = attributes[i]; 2112 } 2113 } 2114 parent.replaceChild(newnode, node); 2115 }, 2116 _removeNode: function(id) 2117 { 2118 var node = document.getElementById(id); 2119 if(node) 2120 { 2121 var parent = node.parentNode; 2122 parent.removeChild(node); 2123 } 2124 }, 2125 _insertScript: function(data) 2126 { 2127 eval(data); 2128 }, 2129 _insertAlert: function(data) 2130 { 2131 alert(data); 2132 } 2133 } 2134 // Loading.js 2135 HTML_AJAX.Open = function(request) { 2136 var loading = document.getElementById('HTML_AJAX_LOADING'); 2137 if (!loading) { 2138 loading = document.createElement('div'); 2139 loading.id = 'HTML_AJAX_LOADING'; 2140 loading.innerHTML = 'Loading...'; 2141 loading.style.color = '#fff'; 2142 loading.style.position = 'absolute'; 2143 loading.style.top = 0; 2144 loading.style.right = 0; 2145 loading.style.backgroundColor = '#f00'; 2146 loading.style.border = '1px solid #f99'; 2147 loading.style.width = '80px'; 2148 loading.style.padding = '4px'; 2149 loading.style.fontFamily = 'Arial, Helvetica, sans'; 2150 loading.count = 0; 2151 document.body.insertBefore(loading,document.body.firstChild); 2152 } 2153 else { 2154 if (loading.count == undefined) { 2155 loading.count = 0; 2156 } 2157 } 2158 loading.count++; 2159 if (request.isAsync) { 2160 request.loadingId = window.setTimeout(function() { loading.style.display = 'block'; },500); 2161 } 2162 else { 2163 loading.style.display = 'block'; 2164 } 2165 } 2166 HTML_AJAX.Load = function(request) { 2167 if (request.loadingId) { 2168 window.clearTimeout(request.loadingId); 2169 } 2170 var loading = document.getElementById('HTML_AJAX_LOADING'); 2171 loading.count--; 2172 if (loading.count == 0) { 2173 loading.style.display = 'none'; 2174 } 2175 } 2176 // util.js 2177 var HTML_AJAX_Util = { 2178 registerEvent: function(element, event, handler) 2179 { 2180 element = this.getElement(element); 2181 if (typeof element.addEventListener != "undefined") { //Dom2 2182 element.addEventListener(event, handler, false); 2183 } else if (typeof element.attachEvent != "undefined") { //IE 5+ 2184 element.attachEvent("on" + event, handler); 2185 } else { 2186 if (element["on" + event] != null) { 2187 var oldHandler = element["on" + event]; 2188 element["on" + event] = function(e) { 2189 oldHander(e); 2190 handler(e); 2191 }; 2192 } else { 2193 element["on" + event] = handler; 2194 } 2195 } 2196 }, 2197 eventTarget: function(event) 2198 { 2199 if (!event) var event = window.event; 2200 if (event.target) return event.target; // w3c 2201 if (event.srcElement) return event.srcElement; // ie 5 2202 }, 2203 getType: function(inp) 2204 { 2205 var type = typeof inp, match; 2206 if(type == 'object' && !inp) 2207 { 2208 return 'null'; 2209 } 2210 if (type == "object") { 2211 if(!inp.constructor) 2212 { 2213 return 'object'; 2214 } 2215 var cons = inp.constructor.toString(); 2216 if (match = cons.match(/(\w+)\(/)) { 2217 cons = match[1].toLowerCase(); 2218 } 2219 var types = ["boolean", "number", "string", "array"]; 2220 for (key in types) { 2221 if (cons == types[key]) { 2222 type = types[key]; 2223 break; 2224 } 2225 } 2226 } 2227 return type; 2228 }, 2229 strRepeat: function(inp, multiplier) { 2230 var ret = ""; 2231 while (--multiplier > 0) ret += inp; 2232 return ret; 2233 }, 2234 encodeUrl: function(input) { 2235 return encodeURIComponent(input); 2236 }, 2237 decodeUrl: function(input) { 2238 return decodeURIComponent(input); 2239 }, 2240 varDump: function(inp, printFuncs, _indent, _recursionLevel) 2241 { 2242 if (!_recursionLevel) _recursionLevel = 0; 2243 if (!_indent) _indent = 1; 2244 var tab = this.strRepeat(" ", ++_indent); 2245 var type = this.getType(inp), out = type; 2246 var consrx = /(\w+)\(/; 2247 consrx.compile(); 2248 if (++_recursionLevel > 6) { 2249 return tab + inp + "Loop Detected\n"; 2250 } 2251 switch (type) { 2252 case "boolean": 2253 case "number": 2254 out += "(" + inp.toString() + ")"; 2255 break; 2256 case "string": 2257 out += "(" + inp.length + ") \"" + inp + "\""; 2258 break; 2259 case "function": 2260 if (printFuncs) { 2261 out += inp.toString().replace(/\n/g, "\n" + tab); 2262 } 2263 break; 2264 case "array": 2265 case "object": 2266 var atts = "", attc = 0; 2267 try { 2268 for (k in inp) { 2269 atts += tab + "[" + (/\D/.test(k) ? "\"" + k + "\"" : k) 2270 + "]=>\n" + tab + this.varDump(inp[k], printFuncs, _indent, _recursionLevel); 2271 ++attc; 2272 } 2273 } catch (e) {} 2274 if (type == "object") { 2275 var objname, objstr = inp.toString(); 2276 if (objname = objstr.match(/^\[object (\w+)\]$/)) { 2277 objname = objname[1]; 2278 } else { 2279 try { 2280 objname = inp.constructor.toString().match(consrx)[1]; 2281 } catch (e) { 2282 objname = 'unknown'; 2283 } 2284 } 2285 out += "(" + objname + ") "; 2286 } 2287 out += "(" + attc + ") {\n" + atts + this.strRepeat(" ", _indent - 1) +"}"; 2288 break; 2289 } 2290 return out + "\n"; 2291 }, 2292 quickPrint: function(input,sep) { 2293 if (!sep) { 2294 var sep = "\n"; 2295 } 2296 var type = HTML_AJAX_Util.getType(input); 2297 switch (type) { 2298 case 'string': 2299 return input; 2300 case 'array': 2301 var ret = ""; 2302 for(var i = 0; i < input.length; i++) { 2303 ret += i+':'+input[i]+sep; 2304 } 2305 return ret; 2306 default: 2307 var ret = ""; 2308 for(var i in input) { 2309 ret += i+':'+input[i]+sep; 2310 } 2311 return ret; 2312 } 2313 }, 2314 getAllElements: function(parentElement) 2315 { 2316 if( document.all) 2317 { 2318 if(!parentElement) { 2319 var allElements = document.all; 2320 } 2321 else 2322 { 2323 var allElements = [], rightName = new RegExp( parentElement, 'i' ), i; 2324 for( i=0; i<document.all.length; i++ ) { 2325 if( rightName.test( document.all[i].parentElement ) ) 2326 allElements.push( document.all[i] ); 2327 } 2328 } 2329 return allElements; 2330 } 2331 else 2332 { 2333 if (!parentElement) { parentElement = document.body; } 2334 return parentElement.getElementsByTagName('*'); 2335 } 2336 }, 2337 getElementsByProperty: function(property, regex, parentElement) { 2338 var allElements = HTML_AJAX_Util.getAllElements(parentElement); 2339 var items = []; 2340 for(var i=0,j=allElements.length; i<j; i++) 2341 { 2342 if(regex.test(allElements[i][property])) 2343 { 2344 items.push(allElements[i]); 2345 } 2346 } 2347 return items; 2348 }, 2349 getElementsByClassName: function(className, parentElement) { 2350 return HTML_AJAX_Util.getElementsByProperty('className',new RegExp('(^| )' + className + '( |$)'),parentElement); 2351 }, 2352 getElementsById: function(id, parentElement) { 2353 return HTML_AJAX_Util.getElementsByProperty('id',new RegExp(id),parentElement); 2354 }, 2355 getElementsByCssSelector: function(selector,parentElement) { 2356 return cssQuery(selector,parentElement); 2357 }, 2358 htmlEscape: function(inp) { 2359 var div = document.createElement('div'); 2360 var text = document.createTextNode(inp); 2361 div.appendChild(text); 2362 return div.innerHTML; 2363 }, 2364 baseURL: function(absolute, filename) { 2365 var qPos = absolute.indexOf('?'); 2366 if (qPos >= 0) { 2367 absolute = absolute.substr(0, qPos); 2368 } 2369 var slashPos = Math.max(absolute.lastIndexOf('/'), absolute.lastIndexOf('\\')); 2370 if (slashPos < 0) { 2371 return absolute; 2372 } 2373 return (filename ? absolute.substr(slashPos + 1) : absolute.substr(0, slashPos + 1)); 2374 }, 2375 queryString: function(url) { 2376 var qPos = url.indexOf('?'); 2377 if (qPos >= 0) { 2378 return url.substr(qPos+1); 2379 } 2380 }, 2381 absoluteURL: function(rel, absolute) { 2382 if (/^https?:\/\//i.test(rel)) { 2383 return rel; 2384 } 2385 if (!absolute) { 2386 var bases = document.getElementsByTagName('base'); 2387 for (i in bases) { 2388 if (bases[i].href) { 2389 absolute = bases[i].href; 2390 break; 2391 } 2392 } 2393 if (!absolute) { 2394 absolute = window.location.href; 2395 } 2396 } 2397 if (rel == '') { 2398 return absolute; 2399 } 2400 if (rel.substr(0, 2) == '//') { 2401 var slashesPos = absolute.indexOf('//'); 2402 if (slashesPos < 0) { 2403 return 'http:' + rel; 2404 } 2405 return absolute.substr(0, slashesPos) + rel; 2406 } 2407 var base = this.baseURL(absolute); 2408 var absParts = base.substr(0, base.length - 1).split('/'); 2409 var absHost = absParts.slice(0, 3).join('/') + '/'; 2410 if (rel.substr(0, 1) == '/') { 2411 return absHost + rel; 2412 } 2413 if (rel.substr(0, 1) == '.' && rel.substr(1, 1) != '.') { 2414 return base + rel.substr(1); 2415 } 2416 absParts.splice(0, 3); 2417 var relParts = rel.split('/'); 2418 var loopStart = relParts.length - 1; 2419 relParts = absParts.concat(relParts); 2420 for (i = loopStart; i < relParts.length;) { 2421 if (relParts[i] == '..') { 2422 if (i == 0) { 2423 return absolute; 2424 } 2425 relParts.splice(i - 1, 2); 2426 --i; 2427 continue; 2428 } 2429 i++; 2430 } 2431 return absHost + relParts.join('/'); 2432 }, 2433 setInnerHTML: function(node, innerHTML, type) 2434 { 2435 node = this.getElement(node); 2436 if (type != 'append') { 2437 if (type == 'prepend') { 2438 var oldHtml = node.innerHTML; 2439 } 2440 node.innerHTML = ''; 2441 } 2442 var good_browser = (window.opera || navigator.product == 'Gecko'); 2443 var regex = /^([\s\S]*?)<script([\s\S]*?)>([\s\S]*?)<\/script>([\s\S]*)$/i; 2444 var regex_src = /src=["'](.*?)["']/i; 2445 var matches, id, script, output = '', subject = innerHTML; 2446 var scripts = []; 2447 while (true) { 2448 matches = regex.exec(subject); 2449 if (matches && matches[0]) { 2450 subject = matches[4]; 2451 id = 'ih_' + Math.round(Math.random()*9999) + '_' + Math.round(Math.random()*9999); 2452 var startLen = matches[3].length; 2453 script = matches[3].replace(/document\.write\(([\s\S]*?)\)/ig, 2454 'document.getElementById("' + id + '").innerHTML+=$1'); 2455 output += matches[1]; 2456 if (startLen != script.length) { 2457 output += '<span id="' + id + '"></span>'; 2458 } 2459 output += '<script' + matches[2] + '>' + script + '</script>'; 2460 if (good_browser) { 2461 continue; 2462 } 2463 if (script) { 2464 scripts.push(script); 2465 } 2466 if (regex_src.test(matches[2])) { 2467 var script_el = document.createElement("SCRIPT"); 2468 var atts_regex = /(\w+)=["'](.*?)["']([\s\S]*)$/; 2469 var atts = matches[2]; 2470 for (var i = 0; i < 5; i++) { 2471 var atts_matches = atts_regex.exec(atts); 2472 if (atts_matches && atts_matches[0]) { 2473 script_el.setAttribute(atts_matches[1], atts_matches[2]); 2474 atts = atts_matches[3]; 2475 } else { 2476 break; 2477 } 2478 } 2479 scripts.push(script_el); 2480 } 2481 } else { 2482 output += subject; 2483 break; 2484 } 2485 } 2486 innerHTML = output; 2487 if (good_browser) { 2488 var el = document.createElement('span'); 2489 el.innerHTML = innerHTML; 2490 for(var i = 0; i < el.childNodes.length; i++) { 2491 node.appendChild(el.childNodes[i].cloneNode(true)); 2492 } 2493 } 2494 else { 2495 node.innerHTML += innerHTML; 2496 } 2497 if (oldHtml) { 2498 node.innerHTML += oldHtml; 2499 } 2500 if (!good_browser) { 2501 for(var i = 0; i < scripts.length; i++) { 2502 if (HTML_AJAX_Util.getType(scripts[i]) == 'string') { 2503 scripts[i] = scripts[i].replace(/^\s*<!(\[CDATA\[|--)|((\/\/)?--|\]\])>\s*$/g, ''); 2504 window.eval(scripts[i]); 2505 } 2506 else { 2507 node.appendChild(scripts[i]); 2508 } 2509 } 2510 } 2511 return; 2512 }, 2513 classSep: '(^|$| )', 2514 hasClass: function(o, className) { 2515 var o = this.getElement(o); 2516 var regex = new RegExp(this.classSep + className + this.classSep); 2517 return regex.test(o.className); 2518 }, 2519 addClass: function(o, className) { 2520 var o = this.getElement(o); 2521 if(!this.hasClass(o, className)) { 2522 o.className += " " + className; 2523 } 2524 }, 2525 removeClass: function(o, className) { 2526 var o = this.getElement(o); 2527 var regex = new RegExp(this.classSep + className + this.classSep); 2528 o.className = o.className.replace(regex, " "); 2529 }, 2530 replaceClass: function(o, oldClass, newClass) { 2531 var o = this.getElement(o); 2532 var regex = new RegExp(this.classSep + oldClass + this.classSep); 2533 o.className = o.className.replace(regex, newClass); 2534 }, 2535 getElement: function(el) { 2536 if (typeof el == 'string') { 2537 return document.getElementById(el); 2538 } 2539 return el; 2540 } 2541 } 2542 // behavior/behavior.js 2543 var Behavior = { 2544 debug : false, 2545 list : new Array(), 2546 addLoadEvent : function(func) { 2547 var oldonload = window.onload; 2548 if (typeof window.onload != 'function') { 2549 window.onload = func; 2550 } else { 2551 window.onload = function() { 2552 oldonload(); 2553 func(); 2554 } 2555 } 2556 }, 2557 apply : function() { 2558 if (this.debug) { 2559 document.getElementById(this.debug).innerHTML += 'Apply: '+new Date()+'<br>'; 2560 var total = 0; 2561 } 2562 if (Behavior.list.length > 2) { 2563 cssQuery.caching = true; 2564 } 2565 for (i = 0; i < Behavior.list.length; i++) { 2566 var rule = Behavior.list[i]; 2567 if (this.debug) { var ds = new Date() }; 2568 var tags = cssQuery(rule.selector, rule.from); 2569 if (this.debug) { 2570 var de = new Date(); 2571 var ts = de.valueOf()-ds.valueOf(); 2572 document.getElementById(this.debug).innerHTML += 'Rule: '+rule.selector+' - Took: '+ts+' - Returned: '+tags.length+' tags<br>'; 2573 total += ts; 2574 } 2575 if (tags) { 2576 for (j = 0; j < tags.length; j++) { 2577 rule.action(tags[j]); 2578 } 2579 } 2580 } 2581 if (Behavior.list.length > 2) { 2582 cssQuery.caching = false; 2583 } 2584 if (this.debug) { 2585 document.getElementById(this.debug).innerHTML += 'Total rule apply time: '+total; 2586 } 2587 }, 2588 register : function(selector, action, from) { 2589 Behavior.list.push(new BehaviorRule(selector, from, action)); 2590 }, 2591 start : function() { 2592 Behavior.addLoadEvent(function() { 2593 Behavior.apply(); 2594 }); 2595 } 2596 } 2597 function BehaviorRule(selector, from, action) { 2598 this.selector = selector; 2599 this.from = from; 2600 this.action = action; 2601 } 2602 Behavior.start(); 2603 // behavior/cssQuery-p.js 2604 eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('7 x=6(){7 1D="2.0.2";7 C=/\\s*,\\s*/;7 x=6(s,A){33{7 m=[];7 u=1z.32.2c&&!A;7 b=(A)?(A.31==22)?A:[A]:[1g];7 1E=18(s).1l(C),i;9(i=0;i<1E.y;i++){s=1y(1E[i]);8(U&&s.Z(0,3).2b("")==" *#"){s=s.Z(2);A=24([],b,s[1])}1A A=b;7 j=0,t,f,a,c="";H(j<s.y){t=s[j++];f=s[j++];c+=t+f;a="";8(s[j]=="("){H(s[j++]!=")")a+=s[j];a=a.Z(0,-1);c+="("+a+")"}A=(u&&V[c])?V[c]:21(A,t,f,a);8(u)V[c]=A}m=m.30(A)}2a x.2d;5 m}2Z(e){x.2d=e;5[]}};x.1Z=6(){5"6 x() {\\n [1D "+1D+"]\\n}"};7 V={};x.2c=L;x.2Y=6(s){8(s){s=1y(s).2b("");2a V[s]}1A V={}};7 29={};7 19=L;x.15=6(n,s){8(19)1i("s="+1U(s));29[n]=12 s()};x.2X=6(c){5 c?1i(c):o};7 D={};7 h={};7 q={P:/\\[([\\w-]+(\\|[\\w-]+)?)\\s*(\\W?=)?\\s*([^\\]]*)\\]/};7 T=[];D[" "]=6(r,f,t,n){7 e,i,j;9(i=0;i<f.y;i++){7 s=X(f[i],t,n);9(j=0;(e=s[j]);j++){8(M(e)&&14(e,n))r.z(e)}}};D["#"]=6(r,f,i){7 e,j;9(j=0;(e=f[j]);j++)8(e.B==i)r.z(e)};D["."]=6(r,f,c){c=12 1t("(^|\\\\s)"+c+"(\\\\s|$)");7 e,i;9(i=0;(e=f[i]);i++)8(c.l(e.1V))r.z(e)};D[":"]=6(r,f,p,a){7 t=h[p],e,i;8(t)9(i=0;(e=f[i]);i++)8(t(e,a))r.z(e)};h["2W"]=6(e){7 d=Q(e);8(d.1C)9(7 i=0;i<d.1C.y;i++){8(d.1C[i]==e)5 K}};h["2V"]=6(e){};7 M=6(e){5(e&&e.1c==1&&e.1f!="!")?e:23};7 16=6(e){H(e&&(e=e.2U)&&!M(e))28;5 e};7 G=6(e){H(e&&(e=e.2T)&&!M(e))28;5 e};7 1r=6(e){5 M(e.27)||G(e.27)};7 1P=6(e){5 M(e.26)||16(e.26)};7 1o=6(e){7 c=[];e=1r(e);H(e){c.z(e);e=G(e)}5 c};7 U=K;7 1h=6(e){7 d=Q(e);5(2S d.25=="2R")?/\\.1J$/i.l(d.2Q):2P(d.25=="2O 2N")};7 Q=6(e){5 e.2M||e.1g};7 X=6(e,t){5(t=="*"&&e.1B)?e.1B:e.X(t)};7 17=6(e,t,n){8(t=="*")5 M(e);8(!14(e,n))5 L;8(!1h(e))t=t.2L();5 e.1f==t};7 14=6(e,n){5!n||(n=="*")||(e.2K==n)};7 1e=6(e){5 e.1G};6 24(r,f,B){7 m,i,j;9(i=0;i<f.y;i++){8(m=f[i].1B.2J(B)){8(m.B==B)r.z(m);1A 8(m.y!=23){9(j=0;j<m.y;j++){8(m[j].B==B)r.z(m[j])}}}}5 r};8(![].z)22.2I.z=6(){9(7 i=0;i<1z.y;i++){o[o.y]=1z[i]}5 o.y};7 N=/\\|/;6 21(A,t,f,a){8(N.l(f)){f=f.1l(N);a=f[0];f=f[1]}7 r=[];8(D[t]){D[t](r,A,f,a)}5 r};7 S=/^[^\\s>+~]/;7 20=/[\\s#.:>+~()@]|[^\\s#.:>+~()@]+/g;6 1y(s){8(S.l(s))s=" "+s;5 s.P(20)||[]};7 W=/\\s*([\\s>+~(),]|^|$)\\s*/g;7 I=/([\\s>+~,]|[^(]\\+|^)([#.:@])/g;7 18=6(s){5 s.O(W,"$1").O(I,"$1*$2")};7 1u={1Z:6(){5"\'"},P:/^(\'[^\']*\')|("[^"]*")$/,l:6(s){5 o.P.l(s)},1S:6(s){5 o.l(s)?s:o+s+o},1Y:6(s){5 o.l(s)?s.Z(1,-1):s}};7 1s=6(t){5 1u.1Y(t)};7 E=/([\\/()[\\]?{}|*+-])/g;6 R(s){5 s.O(E,"\\\\$1")};x.15("1j-2H",6(){D[">"]=6(r,f,t,n){7 e,i,j;9(i=0;i<f.y;i++){7 s=1o(f[i]);9(j=0;(e=s[j]);j++)8(17(e,t,n))r.z(e)}};D["+"]=6(r,f,t,n){9(7 i=0;i<f.y;i++){7 e=G(f[i]);8(e&&17(e,t,n))r.z(e)}};D["@"]=6(r,f,a){7 t=T[a].l;7 e,i;9(i=0;(e=f[i]);i++)8(t(e))r.z(e)};h["2G-10"]=6(e){5!16(e)};h["1x"]=6(e,c){c=12 1t("^"+c,"i");H(e&&!e.13("1x"))e=e.1n;5 e&&c.l(e.13("1x"))};q.1X=/\\\\:/g;q.1w="@";q.J={};q.O=6(m,a,n,c,v){7 k=o.1w+m;8(!T[k]){a=o.1W(a,c||"",v||"");T[k]=a;T.z(a)}5 T[k].B};q.1Q=6(s){s=s.O(o.1X,"|");7 m;H(m=s.P(o.P)){7 r=o.O(m[0],m[1],m[2],m[3],m[4]);s=s.O(o.P,r)}5 s};q.1W=6(p,t,v){7 a={};a.B=o.1w+T.y;a.2F=p;t=o.J[t];t=t?t(o.13(p),1s(v)):L;a.l=12 2E("e","5 "+t);5 a};q.13=6(n){1d(n.2D()){F"B":5"e.B";F"2C":5"e.1V";F"9":5"e.2B";F"1T":8(U){5"1U((e.2A.P(/1T=\\\\1v?([^\\\\s\\\\1v]*)\\\\1v?/)||[])[1]||\'\')"}}5"e.13(\'"+n.O(N,":")+"\')"};q.J[""]=6(a){5 a};q.J["="]=6(a,v){5 a+"=="+1u.1S(v)};q.J["~="]=6(a,v){5"/(^| )"+R(v)+"( |$)/.l("+a+")"};q.J["|="]=6(a,v){5"/^"+R(v)+"(-|$)/.l("+a+")"};7 1R=18;18=6(s){5 1R(q.1Q(s))}});x.15("1j-2z",6(){D["~"]=6(r,f,t,n){7 e,i;9(i=0;(e=f[i]);i++){H(e=G(e)){8(17(e,t,n))r.z(e)}}};h["2y"]=6(e,t){t=12 1t(R(1s(t)));5 t.l(1e(e))};h["2x"]=6(e){5 e==Q(e).1H};h["2w"]=6(e){7 n,i;9(i=0;(n=e.1F[i]);i++){8(M(n)||n.1c==3)5 L}5 K};h["1N-10"]=6(e){5!G(e)};h["2v-10"]=6(e){e=e.1n;5 1r(e)==1P(e)};h["2u"]=6(e,s){7 n=x(s,Q(e));9(7 i=0;i<n.y;i++){8(n[i]==e)5 L}5 K};h["1O-10"]=6(e,a){5 1p(e,a,16)};h["1O-1N-10"]=6(e,a){5 1p(e,a,G)};h["2t"]=6(e){5 e.B==2s.2r.Z(1)};h["1M"]=6(e){5 e.1M};h["2q"]=6(e){5 e.1q===L};h["1q"]=6(e){5 e.1q};h["1L"]=6(e){5 e.1L};q.J["^="]=6(a,v){5"/^"+R(v)+"/.l("+a+")"};q.J["$="]=6(a,v){5"/"+R(v)+"$/.l("+a+")"};q.J["*="]=6(a,v){5"/"+R(v)+"/.l("+a+")"};6 1p(e,a,t){1d(a){F"n":5 K;F"2p":a="2n";1a;F"2o":a="2n+1"}7 1m=1o(e.1n);6 1k(i){7 i=(t==G)?1m.y-i:i-1;5 1m[i]==e};8(!Y(a))5 1k(a);a=a.1l("n");7 m=1K(a[0]);7 s=1K(a[1]);8((Y(m)||m==1)&&s==0)5 K;8(m==0&&!Y(s))5 1k(s);8(Y(s))s=0;7 c=1;H(e=t(e))c++;8(Y(m)||m==1)5(t==G)?(c<=s):(s>=c);5(c%m)==s}});x.15("1j-2m",6(){U=1i("L;/*@2l@8(@\\2k)U=K@2j@*/");8(!U){X=6(e,t,n){5 n?e.2i("*",t):e.X(t)};14=6(e,n){5!n||(n=="*")||(e.2h==n)};1h=1g.1I?6(e){5/1J/i.l(Q(e).1I)}:6(e){5 Q(e).1H.1f!="2g"};1e=6(e){5 e.2f||e.1G||1b(e)};6 1b(e){7 t="",n,i;9(i=0;(n=e.1F[i]);i++){1d(n.1c){F 11:F 1:t+=1b(n);1a;F 3:t+=n.2e;1a}}5 t}}});19=K;5 x}();',62,190,'|||||return|function|var|if|for||||||||pseudoClasses||||test|||this||AttributeSelector|||||||cssQuery|length|push|fr|id||selectors||case|nextElementSibling|while||tests|true|false|thisElement||replace|match|getDocument|regEscape||attributeSelectors|isMSIE|cache||getElementsByTagName|isNaN|slice|child||new|getAttribute|compareNamespace|addModule|previousElementSibling|compareTagName|parseSelector|loaded|break|_0|nodeType|switch|getTextContent|tagName|document|isXML|eval|css|_1|split|ch|parentNode|childElements|nthChild|disabled|firstElementChild|getText|RegExp|Quote|x22|PREFIX|lang|_2|arguments|else|all|links|version|se|childNodes|innerText|documentElement|contentType|xml|parseInt|indeterminate|checked|last|nth|lastElementChild|parse|_3|add|href|String|className|create|NS_IE|remove|toString|ST|select|Array|null|_4|mimeType|lastChild|firstChild|continue|modules|delete|join|caching|error|nodeValue|textContent|HTML|prefix|getElementsByTagNameNS|end|x5fwin32|cc_on|standard||odd|even|enabled|hash|location|target|not|only|empty|root|contains|level3|outerHTML|htmlFor|class|toLowerCase|Function|name|first|level2|prototype|item|scopeName|toUpperCase|ownerDocument|Document|XML|Boolean|URL|unknown|typeof|nextSibling|previousSibling|visited|link|valueOf|clearCache|catch|concat|constructor|callee|try'.split('|'),0,{}))
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Mar 30 01:27:52 2007 | par Balluche grâce à PHPXref 0.7 |