| 赞 | 8 |
| VIP | |
| 好人卡 | |
| 积分 | 1 |
| 经验 | |
| 最后登录 | 2016-8-9 |
| 在线时间 | 119 小时 |
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 119 小时
- 注册时间
- 2015-1-5
- 回帖
- 118
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 MonsterJohnCN 于 2015-10-25 02:37 编辑
这些函数没有被列在F1文档中(或者我没找到),在JS教程中通常会存在。
不过我所找到的是直接使用F8调试查询到的可确保用于RMMV的函数。
因此提供这些方便的函数,也许你会需要。
暂时没有翻译,因为我暂时还没用到这些功能。
- function StringConstructor(a) {
- if ( % _ArgumentsLength() == 0) a = '';
- if ( % _IsConstructCall()) { % _SetValueOf(this, ((typeof( % IS_VAR(a)) === 'string') ? a : NonStringToString(a)));
- } else {
- return (typeof(a) === 'symbol') ?
- % _CallFunction(a, SymbolToString) : ((typeof( % IS_VAR(a)) === 'string') ? a : NonStringToString(a));
- }
- }
- function StringToString() {
- if (!(typeof(this) === 'string') && !( % _ClassOf(this) === 'String')) {
- throw new $TypeError('String.prototype.toString is not generic');
- }
- return %_ValueOf(this);
- }
- function StringValueOf() {
- if (!(typeof(this) === 'string') && !( % _ClassOf(this) === 'String')) {
- throw new $TypeError('String.prototype.valueOf is not generic');
- }
- return %_ValueOf(this);
- }
- function StringCharAt(a) {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.charAt"]);
- var b = % _StringCharAt(this, a);
- if ( % _IsSmi(b)) {
- b = % _StringCharAt(((typeof( % IS_VAR(this)) === 'string') ? this : NonStringToString(this)), ( % _IsSmi( % IS_VAR(a)) ? a : % NumberToInteger(ToNumber(a))));
- }
- return b;
- }
- function StringCharCodeAt(a) {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.charCodeAt"]);
- var b = % _StringCharCodeAt(this, a);
- if (! % _IsSmi(b)) {
- b = % _StringCharCodeAt(((typeof( % IS_VAR(this)) === 'string') ? this : NonStringToString(this)), ( % _IsSmi( % IS_VAR(a)) ? a : % NumberToInteger(ToNumber(a))));
- }
- return b;
- }
- function StringConcat(a) {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.concat"]);
- var b = % _ArgumentsLength();
- var c = ((typeof( % IS_VAR(this)) === 'string') ? this : NonStringToString(this));
- if (b === 1) {
- return c + a;
- }
- var d = new InternalArray(b + 1);
- d[0] = c;
- for (var g = 0; g < b; g++) {
- var h = % _Arguments(g);
- d[g + 1] = ((typeof( % IS_VAR(h)) === 'string') ? h : NonStringToString(h));
- }
- return %StringBuilderConcat(d, b + 1, "");
- }
- function StringIndexOfJS(a) {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.indexOf"]);
- var b = ((typeof( % IS_VAR(this)) === 'string') ? this : NonStringToString(this));
- a = ((typeof( % IS_VAR(a)) === 'string') ? a : NonStringToString(a));
- var c = 0;
- if ( % _ArgumentsLength() > 1) {
- c = % _Arguments(1);
- c = ( % _IsSmi( % IS_VAR(c)) ? c : % NumberToInteger(ToNumber(c)));
- if (c < 0) c = 0;
- if (c > b.length) c = b.length;
- }
- return %StringIndexOf(b, a, c);
- }
- function StringLastIndexOfJS(a) {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.lastIndexOf"]);
- var b = ((typeof( % IS_VAR(this)) === 'string') ? this : NonStringToString(this));
- var c = b.length;
- var a = ((typeof( % IS_VAR(a)) === 'string') ? a : NonStringToString(a));
- var d = a.length;
- var g = c - d;
- if ( % _ArgumentsLength() > 1) {
- var h = ToNumber( % _Arguments(1));
- if (!(! % _IsSmi( % IS_VAR(h)) && !(h == h))) {
- h = ( % _IsSmi( % IS_VAR(h)) ? h : % NumberToInteger(ToNumber(h)));
- if (h < 0) {
- h = 0;
- }
- if (h + d < c) {
- g = h;
- }
- }
- }
- if (g < 0) {
- return -1;
- }
- return %StringLastIndexOf(b, a, g);
- }
- function StringLocaleCompareJS(a) {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.localeCompare"]);
- return %StringLocaleCompare(((typeof( % IS_VAR(this)) === 'string') ? this : NonStringToString(this)), ((typeof( % IS_VAR(a)) === 'string') ? a : NonStringToString(a)));
- }
- function StringMatchJS(a) {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.match"]);
- var b = ((typeof( % IS_VAR(this)) === 'string') ? this : NonStringToString(this));
- if (( % _IsRegExp(a))) {
- var c = a.lastIndex;
- ( % _IsSmi( % IS_VAR(c)) ? c : ToNumber(c));
- if (!a.global) return RegExpExecNoTests(a, b, 0);
- var d = % StringMatch(b, a, lastMatchInfo);
- if (d !== null) lastMatchInfoOverride = null;
- a.lastIndex = 0;
- return d;
- }
- a = new $RegExp(a);
- return RegExpExecNoTests(a, b, 0);
- }
- var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD'];
- function StringNormalizeJS(a) {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.normalize"]);
- var a = a ? ((typeof( % IS_VAR(a)) === 'string') ? a : NonStringToString(a)) : 'NFC';
- var b = NORMALIZATION_FORMS.indexOf(a);
- if (b === -1) {
- throw new $RangeError('The normalization form should be one of ' + NORMALIZATION_FORMS.join(', ') + '.');
- }
- return %_ValueOf(this);
- }
- var reusableMatchInfo = [2, "", "", -1, -1];
- function StringReplace(a, b) {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.replace"]);
- var c = ((typeof( % IS_VAR(this)) === 'string') ? this : NonStringToString(this));
- if (( % _IsRegExp(a))) {
- var d = a.lastIndex;
- ( % _IsSmi( % IS_VAR(d)) ? d : ToNumber(d));
- if (!( % _ClassOf(b) === 'Function')) {
- b = ((typeof( % IS_VAR(b)) === 'string') ? b : NonStringToString(b));
- if (!a.global) {
- var g = DoRegExpExec(a, c, 0);
- if (g == null) {
- a.lastIndex = 0
- return c;
- }
- if (b.length == 0) {
- return %_SubString(c, 0, g[3]) +
- % _SubString(c, g[4], c.length)
- }
- return ExpandReplacement(b, c, lastMatchInfo, % _SubString(c, 0, g[3])) +
- % _SubString(c, g[4], c.length);
- }
- a.lastIndex = 0;
- if (lastMatchInfoOverride == null) {
- return %StringReplaceGlobalRegExpWithString(
- c, a, b, lastMatchInfo);
- } else {
- var h = lastMatchInfo[1];
- lastMatchInfo[1] = 0;
- var i = % StringReplaceGlobalRegExpWithString(
- c, a, b, lastMatchInfo);
- if ( % _IsSmi(lastMatchInfo[1])) {
- lastMatchInfo[1] = h;
- } else {
- lastMatchInfoOverride = null;
- }
- return i;
- }
- }
- if (a.global) {
- return StringReplaceGlobalRegExpWithFunction(c, a, b);
- }
- return StringReplaceNonGlobalRegExpWithFunction(c, a, b);
- }
- a = ((typeof( % IS_VAR(a)) === 'string') ? a : NonStringToString(a));
- if (a.length == 1 &&
- c.length > 0xFF &&
- (typeof(b) === 'string') &&
- % StringIndexOf(b, '$', 0) < 0) {
- return %StringReplaceOneCharWithString(c, a, b);
- }
- var j = % StringIndexOf(c, a, 0);
- if (j < 0) return c;
- var k = j + a.length;
- var l = % _SubString(c, 0, j);
- if (( % _ClassOf(b) === 'Function')) {
- var m = % GetDefaultReceiver(b);
- l += % _CallFunction(m, a, j, c, b);
- } else {
- reusableMatchInfo[3] = j;
- reusableMatchInfo[4] = k;
- l = ExpandReplacement(((typeof( % IS_VAR(b)) === 'string') ? b : NonStringToString(b)),
- c,
- reusableMatchInfo,
- l);
- }
- return l + % _SubString(c, k, c.length);
- }
- function ExpandReplacement(a, b, c, d) {
- var g = a.length;
- var h = % StringIndexOf(a, '$', 0);
- if (h < 0) {
- if (g > 0) d += a;
- return d;
- }
- if (h > 0) d += % _SubString(a, 0, h);
- while (true) {
- var i = '$';
- var j = h + 1;
- if (j < g) {
- var k = % _StringCharCodeAt(a, j);
- if (k == 36) {
- ++j;
- d += '$';
- } else if (k == 38) {
- ++j;
- d +=
- % _SubString(b, c[3], c[4]);
- } else if (k == 96) {
- ++j;
- d += % _SubString(b, 0, c[3]);
- } else if (k == 39) {
- ++j;
- d += % _SubString(b, c[4], b.length);
- } else if (k >= 48 && k <= 57) {
- var l = (k - 48) << 1;
- var m = 1;
- var o = ((c)[0]);
- if (j + 1 < a.length) {
- var h = % _StringCharCodeAt(a, j + 1);
- if (h >= 48 && h <= 57) {
- var q = l * 10 + ((h - 48) << 1);
- if (q < o) {
- l = q;
- m = 2;
- }
- }
- }
- if (l != 0 && l < o) {
- var r = c[(3 + (l))];
- if (r >= 0) {
- d +=
- % _SubString(b, r, c[(3 + (l + 1))]);
- }
- j += m;
- } else {
- d += '$';
- }
- } else {
- d += '$';
- }
- } else {
- d += '$';
- }
- h = % StringIndexOf(a, '$', j);
- if (h < 0) {
- if (j < g) {
- d += % _SubString(a, j, g);
- }
- return d;
- }
- if (h > j) {
- d += % _SubString(a, j, h);
- }
- }
- return d;
- }
- function CaptureString(a, b, c) {
- var d = c << 1;
- var g = b[(3 + (d))];
- if (g < 0) return;
- var h = b[(3 + (d + 1))];
- return %_SubString(a, g, h);
- }
- var reusableReplaceArray = new InternalArray(16);
- function StringReplaceGlobalRegExpWithFunction(a, b, c) {
- var d = reusableReplaceArray;
- if (d) {
- reusableReplaceArray = null;
- } else {
- d = new InternalArray(16);
- }
- var g = % RegExpExecMultiple(b,
- a,
- lastMatchInfo,
- d);
- b.lastIndex = 0;
- if ((g === null)) {
- reusableReplaceArray = d;
- return a;
- }
- var h = g.length;
- if (((lastMatchInfo)[0]) == 2) {
- var i = 0;
- var j = new InternalPackedArray(null, 0, a);
- var k = % GetDefaultReceiver(c);
- for (var l = 0; l < h; l++) {
- var m = g[l];
- if ( % _IsSmi(m)) {
- if (m > 0) {
- i = (m >> 11) + (m & 0x7ff);
- } else {
- i = g[++l] - m;
- }
- } else {
- j[0] = m;
- j[1] = i;
- lastMatchInfoOverride = j;
- var o = % _CallFunction(k, m, i, a, c);
- g[l] = ((typeof( % IS_VAR(o)) === 'string') ? o : NonStringToString(o));
- i += m.length;
- }
- }
- } else {
- var k = % GetDefaultReceiver(c);
- for (var l = 0; l < h; l++) {
- var m = g[l];
- if (! % _IsSmi(m)) {
- lastMatchInfoOverride = m;
- var o = % Apply(c, k, m, 0, m.length);
- g[l] = ((typeof( % IS_VAR(o)) === 'string') ? o : NonStringToString(o));
- }
- }
- }
- var q = % StringBuilderConcat(g, g.length, a);
- d.length = 0;
- reusableReplaceArray = d;
- return q;
- }
- function StringReplaceNonGlobalRegExpWithFunction(a, b, c) {
- var d = DoRegExpExec(b, a, 0);
- if ((d === null)) {
- b.lastIndex = 0;
- return a;
- }
- var g = d[3];
- var h = % _SubString(a, 0, g);
- var i = d[4];
- var j = ((d)[0]) >> 1;
- var k;
- var l = % GetDefaultReceiver(c);
- if (j == 1) {
- var m = % _SubString(a, g, i);
- k = % _CallFunction(l, m, g, a, c);
- } else {
- var o = new InternalArray(j + 2);
- for (var q = 0; q < j; q++) {
- o[q] = CaptureString(a, d, q);
- }
- o[q] = g;
- o[q + 1] = a;
- k = % Apply(c, l, o, 0, q + 2);
- }
- h += k;
- return h + % _SubString(a, i, a.length);
- }
- function StringSearch(a) {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.search"]);
- var b;
- if ((typeof(a) === 'string')) {
- b = % _GetFromCache(0, a);
- } else if (( % _IsRegExp(a))) {
- b = a;
- } else {
- b = new $RegExp(a);
- }
- var c = DoRegExpExec(b, ((typeof( % IS_VAR(this)) === 'string') ? this : NonStringToString(this)), 0);
- if (c) {
- return c[3];
- }
- return -1;
- }
- function StringSlice(a, b) {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.slice"]);
- var c = ((typeof( % IS_VAR(this)) === 'string') ? this : NonStringToString(this));
- var d = c.length;
- var g = ( % _IsSmi( % IS_VAR(a)) ? a : % NumberToInteger(ToNumber(a)));
- var h = d;
- if (!(b === (void 0))) {
- h = ( % _IsSmi( % IS_VAR(b)) ? b : % NumberToInteger(ToNumber(b)));
- }
- if (g < 0) {
- g += d;
- if (g < 0) {
- g = 0;
- }
- } else {
- if (g > d) {
- return '';
- }
- }
- if (h < 0) {
- h += d;
- if (h < 0) {
- return '';
- }
- } else {
- if (h > d) {
- h = d;
- }
- }
- if (h <= g) {
- return '';
- }
- return %_SubString(c, g, h);
- }
- function StringSplitJS(a, b) {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.split"]);
- var c = ((typeof( % IS_VAR(this)) === 'string') ? this : NonStringToString(this));
- b = ((b === (void 0))) ? 0xffffffff : (b >>> 0);
- var d = c.length;
- if (!( % _IsRegExp(a))) {
- var g = ((typeof( % IS_VAR(a)) === 'string') ? a : NonStringToString(a));
- if (b === 0) return [];
- if ((a === (void 0))) return [c];
- var h = g.length;
- if (h === 0) return %StringToArray(c, b);
- var i = % StringSplit(c, g, b);
- return i;
- }
- if (b === 0) return [];
- return StringSplitOnRegExp(c, a, b, d);
- }
- function StringSplitOnRegExp(a, b, c, d) {
- if (d === 0) {
- if (DoRegExpExec(b, a, 0, 0) != null) {
- return [];
- }
- return [a];
- }
- var g = 0;
- var h = 0;
- var i = 0;
- var j = new InternalArray();
- outer_loop:
- while (true) {
- if (h === d) {
- j[j.length] = % _SubString(a, g, d);
- break;
- }
- var k = DoRegExpExec(b, a, h);
- if (k == null || d === (i = k[3])) {
- j[j.length] = % _SubString(a, g, d);
- break;
- }
- var l = k[4];
- if (h === l && l === g) {
- h++;
- continue;
- }
- j[j.length] = % _SubString(a, g, i);
- if (j.length === c) break;
- var m = ((k)[0]) + 3;
- for (var o = 3 + 2; o < m;) {
- var q = k[o++];
- var r = k[o++];
- if (r != -1) {
- j[j.length] = % _SubString(a, q, r);
- } else {
- j[j.length] = (void 0);
- }
- if (j.length === c) break outer_loop;
- }
- h = g = l;
- }
- var t = []; % MoveArrayContents(j, t);
- return t;
- }
- function StringSubstring(a, b) {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.subString"]);
- var c = ((typeof( % IS_VAR(this)) === 'string') ? this : NonStringToString(this));
- var d = c.length;
- var g = ( % _IsSmi( % IS_VAR(a)) ? a : % NumberToInteger(ToNumber(a)));
- if (g < 0) {
- g = 0;
- } else if (g > d) {
- g = d;
- }
- var h = d;
- if (!(b === (void 0))) {
- h = ( % _IsSmi( % IS_VAR(b)) ? b : % NumberToInteger(ToNumber(b)));
- if (h > d) {
- h = d;
- } else {
- if (h < 0) h = 0;
- if (g > h) {
- var i = h;
- h = g;
- g = i;
- }
- }
- }
- return %_SubString(c, g, h);
- }
- function StringSubstr(a, b) {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.substr"]);
- var c = ((typeof( % IS_VAR(this)) === 'string') ? this : NonStringToString(this));
- var d;
- if ((b === (void 0))) {
- d = c.length;
- } else {
- d = ( % _IsSmi( % IS_VAR(b)) ? b : % NumberToInteger(ToNumber(b)));
- if (d <= 0) return '';
- }
- if ((a === (void 0))) {
- a = 0;
- } else {
- a = ( % _IsSmi( % IS_VAR(a)) ? a : % NumberToInteger(ToNumber(a)));
- if (a >= c.length) return '';
- if (a < 0) {
- a += c.length;
- if (a < 0) a = 0;
- }
- }
- var g = a + d;
- if (g > c.length) g = c.length;
- return %_SubString(c, a, g);
- }
- function StringToLowerCaseJS() {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.toLowerCase"]);
- return %StringToLowerCase(((typeof( % IS_VAR(this)) === 'string') ? this : NonStringToString(this)));
- }
- function StringToLocaleLowerCase() {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.toLocaleLowerCase"]);
- return %StringToLowerCase(((typeof( % IS_VAR(this)) === 'string') ? this : NonStringToString(this)));
- }
- function StringToUpperCaseJS() {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.toUpperCase"]);
- return %StringToUpperCase(((typeof( % IS_VAR(this)) === 'string') ? this : NonStringToString(this)));
- }
- function StringToLocaleUpperCase() {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.toLocaleUpperCase"]);
- return %StringToUpperCase(((typeof( % IS_VAR(this)) === 'string') ? this : NonStringToString(this)));
- }
- function StringTrimJS() {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.trim"]);
- return %StringTrim(((typeof( % IS_VAR(this)) === 'string') ? this : NonStringToString(this)), true, true);
- }
- function StringTrimLeft() {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.trimLeft"]);
- return %StringTrim(((typeof( % IS_VAR(this)) === 'string') ? this : NonStringToString(this)), true, false);
- }
- function StringTrimRight() {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.trimRight"]);
- return %StringTrim(((typeof( % IS_VAR(this)) === 'string') ? this : NonStringToString(this)), false, true);
- }
- function StringFromCharCode(a) {
- var b = % _ArgumentsLength();
- if (b == 1) {
- if (! % _IsSmi(a)) a = ToNumber(a);
- return %_StringCharFromCode(a & 0xffff);
- }
- var c = % NewString(b, true);
- var d;
- for (d = 0; d < b; d++) {
- var a = % _Arguments(d);
- if (! % _IsSmi(a)) a = ToNumber(a) & 0xffff;
- if (a < 0) a = a & 0xffff;
- if (a > 0xff) break; % _OneByteSeqStringSetChar(d, a, c);
- }
- if (d == b) return c;
- c = % TruncateString(c, d);
- var g = % NewString(b - d, false);
- for (var h = 0; d < b; d++, h++) {
- var a = % _Arguments(d);
- if (! % _IsSmi(a)) a = ToNumber(a) & 0xffff; % _TwoByteSeqStringSetChar(h, a, g);
- }
- return c + g;
- }
- function HtmlEscape(a) {
- return ((typeof( % IS_VAR(a)) === 'string') ? a : NonStringToString(a)).replace(/"/g, """);
- }
- function StringAnchor(a) {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.anchor"]);
- return "<a name="" + HtmlEscape(a) + "">" + this + "</a>";
- }
- function StringBig() {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.big"]);
- return "<big>" + this + "</big>";
- }
- function StringBlink() {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.blink"]);
- return "<blink>" + this + "</blink>";
- }
- function StringBold() {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.bold"]);
- return "<b>" + this + "</b>";
- }
- function StringFixed() {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.fixed"]);
- return "<tt>" + this + "</tt>";
- }
- function StringFontcolor(a) {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.fontcolor"]);
- return "<font color="" + HtmlEscape(a) + "">" + this + "</font>";
- }
- function StringFontsize(a) {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.fontsize"]);
- return "<font size="" + HtmlEscape(a) + "">" + this + "</font>";
- }
- function StringItalics() {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.italics"]);
- return "<i>" + this + "</i>";
- }
- function StringLink(a) {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.link"]);
- return "<a href="" + HtmlEscape(a) + "">" + this + "</a>";
- }
- function StringSmall() {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.small"]);
- return "<small>" + this + "</small>";
- }
- function StringStrike() {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.strike"]);
- return "<strike>" + this + "</strike>";
- }
- function StringSub() {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.sub"]);
- return "<sub>" + this + "</sub>";
- }
- function StringSup() {
- if ((this == null) && !( % _IsUndetectableObject(this))) throw MakeTypeError('called_on_null_or_undefined', ["String.prototype.sup"]);
- return "<sup>" + this + "</sup>";
- }
- function SetUpString() { % CheckIsBootstrapping(); % SetCode($String, StringConstructor); % FunctionSetPrototype($String, new $String()); % AddNamedProperty($String.prototype, "constructor", $String, 2);
- InstallFunctions($String, 2, $Array(
- "fromCharCode", StringFromCharCode
- ));
- InstallFunctions($String.prototype, 2, $Array(
- "valueOf", StringValueOf,
- "toString", StringToString,
- "charAt", StringCharAt,
- "charCodeAt", StringCharCodeAt,
- "concat", StringConcat,
- "indexOf", StringIndexOfJS,
- "lastIndexOf", StringLastIndexOfJS,
- "localeCompare", StringLocaleCompareJS,
- "match", StringMatchJS,
- "normalize", StringNormalizeJS,
- "replace", StringReplace,
- "search", StringSearch,
- "slice", StringSlice,
- "split", StringSplitJS,
- "substring", StringSubstring,
- "substr", StringSubstr,
- "toLowerCase", StringToLowerCaseJS,
- "toLocaleLowerCase", StringToLocaleLowerCase,
- "toUpperCase", StringToUpperCaseJS,
- "toLocaleUpperCase", StringToLocaleUpperCase,
- "trim", StringTrimJS,
- "trimLeft", StringTrimLeft,
- "trimRight", StringTrimRight,
- "link", StringLink,
- "anchor", StringAnchor,
- "fontcolor", StringFontcolor,
- "fontsize", StringFontsize,
- "big", StringBig,
- "blink", StringBlink,
- "bold", StringBold,
- "fixed", StringFixed,
- "italics", StringItalics,
- "small", StringSmall,
- "strike", StringStrike,
- "sub", StringSub,
- "sup", StringSup
- ));
- }
- SetUpString();
复制代码 |
评分
-
查看全部评分
|