rename vars

This commit is contained in:
rolux 2012-05-25 21:25:48 +02:00
parent 5ad848c563
commit b2cae84ca9
2 changed files with 31 additions and 31 deletions

View file

@ -38,8 +38,8 @@ Ox.encodeBase32 <b> Encode a number as base32
'110V' '110V'
@*/ @*/
Ox.encodeBase32 = function(number) { Ox.encodeBase32 = function(number) {
return Ox.map(number.toString(32), function(character) { return Ox.map(number.toString(32), function(char) {
return Ox.BASE_32_DIGITS[parseInt(character, 32)]; return Ox.BASE_32_DIGITS[parseInt(char, 32)];
}); });
}; };
@ -54,9 +54,9 @@ Ox.decodeBase32 <f> Decodes a base32-encoded number
'NaN' 'NaN'
@*/ @*/
Ox.decodeBase32 = function(string) { 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( 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); return (index == -1 ? ' ' : index).toString(32);
}), 32); }), 32);
@ -242,11 +242,11 @@ Ox.encodeHTML <f> HTML-encodes a string
> Ox.encodeHTML('äbçdê') > Ox.encodeHTML('äbçdê')
'&#x00E4;b&#x00E7;d&#x00EA;' '&#x00E4;b&#x00E7;d&#x00EA;'
@*/ @*/
Ox.encodeHTML = function(str) { Ox.encodeHTML = function(string) {
return Ox.map(str.toString(), function(v) { return Ox.map(string.toString(), function(char) {
var code = v.charCodeAt(0); var code = char.charCodeAt(0);
return code < 128 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) + ';'; : '&#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>') > Ox.decodeHTML('<b>bold</b>')
'<b>bold</b>' '<b>bold</b>'
@*/ @*/
Ox.decodeHTML = function(str) { Ox.decodeHTML = function(string) {
// relies on dom, but shorter than using this: // relies on dom, but shorter than using this:
// http://www.w3.org/TR/html5/named-character-references.html // 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) { Ox.encodeHTMLEntities = function(string) {
return str.replace( return string.replace(
new RegExp('(' + Object.keys(Ox.HTML_ENTITIES).join('|') + ')', 'g'), new RegExp('(' + Object.keys(Ox.HTML_ENTITIES).join('|') + ')', 'g'),
function(match) { function(match) {
return Ox.HTML_ENTITIES[match]; return Ox.HTML_ENTITIES[match];
@ -279,8 +279,8 @@ Ox.encodeHTMLEntities = function(str) {
); );
}; };
Ox.decodeHTMLEntities = function(str) { Ox.decodeHTMLEntities = function(string) {
return str.replace( return string.replace(
new RegExp('(' + Ox.values(Ox.HTML_ENTITIES).join('|') + ')', 'g'), new RegExp('(' + Ox.values(Ox.HTML_ENTITIES).join('|') + ')', 'g'),
function(match) { function(match) {
return Ox.keyOf(Ox.HTML_ENTITIES, match); return Ox.keyOf(Ox.HTML_ENTITIES, match);
@ -298,21 +298,21 @@ Ox.encodeUTF8 <f> Encodes a string as UTF-8
> Ox.encodeUTF8("¥€$") > Ox.encodeUTF8("¥€$")
"\u00C2\u00A5\u00E2\u0082\u00AC\u0024" "\u00C2\u00A5\u00E2\u0082\u00AC\u0024"
@*/ @*/
Ox.encodeUTF8 = function(str) { Ox.encodeUTF8 = function(string) {
return Ox.map(str, function(chr) { return Ox.map(string, function(char) {
var code = chr.charCodeAt(0), var code = char.charCodeAt(0),
str = ''; string = '';
if (code < 128) { if (code < 128) {
str = chr; string = char;
} else if (code < 2048) { } else if (code < 2048) {
str = String.fromCharCode(code >> 6 | 192) string = String.fromCharCode(code >> 6 | 192)
+ String.fromCharCode(code & 63 | 128); + String.fromCharCode(code & 63 | 128);
} else { } else {
str = String.fromCharCode(code >> 12 | 224) string = String.fromCharCode(code >> 12 | 224)
+ String.fromCharCode(code >> 6 & 63 | 128) + String.fromCharCode(code >> 6 & 63 | 128)
+ String.fromCharCode(code & 63 | 128); + String.fromCharCode(code & 63 | 128);
} }
return str; return string;
}); });
}; };

View file

@ -348,24 +348,24 @@ if (
|| Ox.typeOf() != 'undefined' || Ox.typeOf() != 'undefined'
) { ) {
Ox.typeOf = function(value) { Ox.typeOf = function(value) {
var ret = Object.prototype.toString.call( var type = Object.prototype.toString.call(
value value
).slice(8, -1).toLowerCase(); ).slice(8, -1).toLowerCase();
if (ret == 'object' && typeof value.callee == 'function') { if (type == 'object' && typeof value.callee == 'function') {
ret = 'arguments'; type = 'arguments';
} else if ( } else if (
ret == 'htmlcollection' || ( type == 'htmlcollection' || (
ret == 'object' type == 'object'
&& typeof value.item != 'undefined' && typeof value.item != 'undefined'
&& typeof value.length == 'number' && typeof value.length == 'number'
) )
) { ) {
ret = 'nodelist'; type = 'nodelist';
} else if (value === null) { } else if (value === null) {
ret = 'null'; type = 'null';
} else if (value === void 0) { } else if (value === void 0) {
ret = 'undefined' type = 'undefined'
} }
return ret; return type;
}; };
} }