From b2cae84ca956b31304872e9f70d2aeac96168ff3 Mon Sep 17 00:00:00 2001 From: rolux Date: Fri, 25 May 2012 21:25:48 +0200 Subject: [PATCH] rename vars --- source/Ox/js/Encoding.js | 44 ++++++++++++++++++++-------------------- source/Ox/js/Type.js | 18 ++++++++-------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/source/Ox/js/Encoding.js b/source/Ox/js/Encoding.js index a0ae93fc..27e702a3 100644 --- a/source/Ox/js/Encoding.js +++ b/source/Ox/js/Encoding.js @@ -38,8 +38,8 @@ Ox.encodeBase32 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 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 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 Decodes an HTML-encoded string > Ox.decodeHTML('bold') 'bold' @*/ -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('
').html(str).html()); + return Ox.decodeHTMLEntities(Ox.element('
').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 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; }); }; diff --git a/source/Ox/js/Type.js b/source/Ox/js/Type.js index 5e8f707f..db53f4d4 100644 --- a/source/Ox/js/Type.js +++ b/source/Ox/js/Type.js @@ -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; }; }