rename vars
This commit is contained in:
parent
5ad848c563
commit
b2cae84ca9
2 changed files with 31 additions and 31 deletions
|
@ -38,8 +38,8 @@ Ox.encodeBase32 <b> Encode a number as base32
|
|||
'110V'
|
||||
@*/
|
||||
Ox.encodeBase32 = function(number) {
|
||||
return Ox.map(number.toString(32), function(character) {
|
||||
return Ox.BASE_32_DIGITS[parseInt(character, 32)];
|
||||
return Ox.map(number.toString(32), function(char) {
|
||||
return Ox.BASE_32_DIGITS[parseInt(char, 32)];
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -54,9 +54,9 @@ Ox.decodeBase32 <f> Decodes a base32-encoded number
|
|||
'NaN'
|
||||
@*/
|
||||
Ox.decodeBase32 = function(string) {
|
||||
return parseInt(Ox.map(string.toUpperCase(), function(character) {
|
||||
return parseInt(Ox.map(string.toUpperCase(), function(char) {
|
||||
var index = Ox.BASE_32_DIGITS.indexOf(
|
||||
Ox.BASE_32_ALIASES[character] || character
|
||||
Ox.BASE_32_ALIASES[char] || char
|
||||
);
|
||||
return (index == -1 ? ' ' : index).toString(32);
|
||||
}), 32);
|
||||
|
@ -242,11 +242,11 @@ Ox.encodeHTML <f> HTML-encodes a string
|
|||
> Ox.encodeHTML('äbçdê')
|
||||
'äbçdê'
|
||||
@*/
|
||||
Ox.encodeHTML = function(str) {
|
||||
return Ox.map(str.toString(), function(v) {
|
||||
var code = v.charCodeAt(0);
|
||||
Ox.encodeHTML = function(string) {
|
||||
return Ox.map(string.toString(), function(char) {
|
||||
var code = char.charCodeAt(0);
|
||||
return code < 128
|
||||
? (v in Ox.HTML_ENTITIES ? Ox.HTML_ENTITIES[v] : v)
|
||||
? (char in Ox.HTML_ENTITIES ? Ox.HTML_ENTITIES[char] : char)
|
||||
: '&#x' + Ox.pad(code.toString(16).toUpperCase(), 4) + ';';
|
||||
});
|
||||
};
|
||||
|
@ -264,14 +264,14 @@ Ox.decodeHTML <f> Decodes an HTML-encoded string
|
|||
> Ox.decodeHTML('<b>bold</b>')
|
||||
'<b>bold</b>'
|
||||
@*/
|
||||
Ox.decodeHTML = function(str) {
|
||||
Ox.decodeHTML = function(string) {
|
||||
// relies on dom, but shorter than using this:
|
||||
// http://www.w3.org/TR/html5/named-character-references.html
|
||||
return Ox.decodeHTMLEntities(Ox.element('<div>').html(str).html());
|
||||
return Ox.decodeHTMLEntities(Ox.element('<div>').html(string).html());
|
||||
};
|
||||
|
||||
Ox.encodeHTMLEntities = function(str) {
|
||||
return str.replace(
|
||||
Ox.encodeHTMLEntities = function(string) {
|
||||
return string.replace(
|
||||
new RegExp('(' + Object.keys(Ox.HTML_ENTITIES).join('|') + ')', 'g'),
|
||||
function(match) {
|
||||
return Ox.HTML_ENTITIES[match];
|
||||
|
@ -279,8 +279,8 @@ Ox.encodeHTMLEntities = function(str) {
|
|||
);
|
||||
};
|
||||
|
||||
Ox.decodeHTMLEntities = function(str) {
|
||||
return str.replace(
|
||||
Ox.decodeHTMLEntities = function(string) {
|
||||
return string.replace(
|
||||
new RegExp('(' + Ox.values(Ox.HTML_ENTITIES).join('|') + ')', 'g'),
|
||||
function(match) {
|
||||
return Ox.keyOf(Ox.HTML_ENTITIES, match);
|
||||
|
@ -298,21 +298,21 @@ Ox.encodeUTF8 <f> Encodes a string as UTF-8
|
|||
> Ox.encodeUTF8("¥€$")
|
||||
"\u00C2\u00A5\u00E2\u0082\u00AC\u0024"
|
||||
@*/
|
||||
Ox.encodeUTF8 = function(str) {
|
||||
return Ox.map(str, function(chr) {
|
||||
var code = chr.charCodeAt(0),
|
||||
str = '';
|
||||
Ox.encodeUTF8 = function(string) {
|
||||
return Ox.map(string, function(char) {
|
||||
var code = char.charCodeAt(0),
|
||||
string = '';
|
||||
if (code < 128) {
|
||||
str = chr;
|
||||
string = char;
|
||||
} else if (code < 2048) {
|
||||
str = String.fromCharCode(code >> 6 | 192)
|
||||
string = String.fromCharCode(code >> 6 | 192)
|
||||
+ String.fromCharCode(code & 63 | 128);
|
||||
} else {
|
||||
str = String.fromCharCode(code >> 12 | 224)
|
||||
string = String.fromCharCode(code >> 12 | 224)
|
||||
+ String.fromCharCode(code >> 6 & 63 | 128)
|
||||
+ String.fromCharCode(code & 63 | 128);
|
||||
}
|
||||
return str;
|
||||
return string;
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -348,24 +348,24 @@ if (
|
|||
|| Ox.typeOf() != 'undefined'
|
||||
) {
|
||||
Ox.typeOf = function(value) {
|
||||
var ret = Object.prototype.toString.call(
|
||||
var type = Object.prototype.toString.call(
|
||||
value
|
||||
).slice(8, -1).toLowerCase();
|
||||
if (ret == 'object' && typeof value.callee == 'function') {
|
||||
ret = 'arguments';
|
||||
if (type == 'object' && typeof value.callee == 'function') {
|
||||
type = 'arguments';
|
||||
} else if (
|
||||
ret == 'htmlcollection' || (
|
||||
ret == 'object'
|
||||
type == 'htmlcollection' || (
|
||||
type == 'object'
|
||||
&& typeof value.item != 'undefined'
|
||||
&& typeof value.length == 'number'
|
||||
)
|
||||
) {
|
||||
ret = 'nodelist';
|
||||
type = 'nodelist';
|
||||
} else if (value === null) {
|
||||
ret = 'null';
|
||||
type = 'null';
|
||||
} else if (value === void 0) {
|
||||
ret = 'undefined'
|
||||
type = 'undefined'
|
||||
}
|
||||
return ret;
|
||||
return type;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue