Menu

[r443]: / phprpc_3.0 / ajs / compat.js  Maximize  Restore  History

Download this file

128 lines (122 with data), 5.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/**********************************************************\
| |
| The implementation of PHPRPC Protocol 3.0 |
| |
| compat.js |
| |
| Release 3.0.0 |
| Copyright (c) 2005-2008 by Team-PHPRPC |
| |
| WebSite: http://www.phprpc.org/ |
| http://www.phprpc.net/ |
| http://www.phprpc.com/ |
| http://sourceforge.net/projects/php-rpc/ |
| |
| Authors: Ma Bingyao <andot@ujn.edu.cn> |
| |
| This file may be distributed and/or modified under the |
| terms of the GNU Lesser General Public License (LGPL) |
| version 3.0 as published by the Free Software Foundation |
| and appearing in the included file LICENSE. |
| |
\**********************************************************/
/* Provides missing functionality for older versions of JScript.
*
* Copyright (C) 2005-2008 Ma Bingyao <andot@ujn.edu.cn>
* Version: 3.0.0
* LastModified: Jul 4, 2007
* This library is free. You can redistribute it and/or modify it.
*/
if (typeof(encodeURIComponent) == "undefined") {
encodeURIComponent = function() {
var URIEncodeTable = "%00|%01|%02|%03|%04|%05|%06|%07|%08|%09|%0A|%0B|%0C|%0D|%0E|%0F|%10|%11|%12|%13|%14|%15|%16|%17|%18|%19|%1A|%1B|%1C|%1D|%1E|%1F|%20|!|%22|%23|%24|%25|%26|'|(|)|*|%2B|%2C|-|.|%2F|0|1|2|3|4|5|6|7|8|9|%3A|%3B|%3C|%3D|%3E|%3F|%40|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|%5B|%5C|%5D|%5E|_|%60|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|%7B|%7C|%7D|~|%7F".split('|');
return function(str) {
var out, i, j, len, c, c2;
out = [];
len = str.length;
for(i = 0, j = 0; i < len; i++) {
c = str.charCodeAt(i);
if (c <= 0x007F) {
out[j++] = URIEncodeTable[c];
continue;
}
else if (c <= 0x7FF) {
out[j++] = '%' + (0xC0 | ((c >> 6) & 0x1F)).toString(16).toUpperCase();
out[j++] = '%' + (0x80 | ( c & 0x3F)).toString(16).toUpperCase();
continue;
}
else if (c < 0xD800 || c > 0xDFFF) {
out[j++] = '%' + (0xE0 | ((c >> 12) & 0x0F)).toString(16).toUpperCase();
out[j++] = '%' + (0x80 | ((c >> 6) & 0x3F)).toString(16).toUpperCase();
out[j++] = '%' + (0x80 | (c & 0x3F)).toString(16).toUpperCase();
continue;
}
else {
if (++i < len) {
c2 = str.charCodeAt(i);
if (c <= 0xDBFF && 0xDC00 <= c2 && c2 <= 0xDFFF) {
c = ((c & 0x03FF) << 10 | (c2 & 0x03FF)) + 0x010000;
if (0x010000 <= c && c <= 0x10FFFF) {
out[j++] = '%' + (0xF0 | ((c >>> 18) & 0x3F)).toString(16).toUpperCase();
out[j++] = '%' + (0x80 | ((c >>> 12) & 0x3F)).toString(16).toUpperCase();
out[j++] = '%' + (0x80 | ((c >>> 6) & 0x3F)).toString(16).toUpperCase();
out[j++] = '%' + (0x80 | (c & 0x3F)).toString(16).toUpperCase();
continue;
}
}
}
}
var e = new Error(-2146823264, "The URI to be encoded contains an invalid character");
e.name = "URIError";
e.message = e.description;
throw e;
}
return out.join('');
}
}();
}
if (typeof(decodeURIComponent) == "undefined") {
decodeURIComponent = function(str) {
var out, i, j, len, c, d1, d2;
out = [];
len = str.length;
i = j = 0;
while(i < len) {
c = str.charAt(i++);
if (c == "%") {
d1 = str.charAt(i++);
d2 = str.charAt(i++);
if (isNaN(parseInt(d1, 16)) || isNaN(parseInt(d2, 16))) {
var e = new Error(-2146823263, "The URI to be decoded is not a valid encoding");
e.name = "URIError";
e.message = e.description;
throw e;
}
out[j++] = String.fromCharCode(parseInt(d1 + d2, 16));
}
else {
out[j++] = c;
}
}
return out.join('').toUTF16();
}
}
if (typeof(Array.prototype.push) == "undefined") {
Array.prototype.push = function() {
var curlen = this.length;
for (var i = 0; i < arguments.length; i++) {
this[curlen + i] = arguments[i];
}
return this.length;
}
}
if (typeof(Array.prototype.shift) == "undefined") {
Array.prototype.shift = function() {
var returnValue = this[0];
for (var i = 1; i < this.length; i++) {
this[i - 1] = this[i];
}
this.length--;
return returnValue;
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.