diff --git a/src/array.js b/src/array.js index fd0a427..e3dd30e 100644 --- a/src/array.js +++ b/src/array.js @@ -100,18 +100,18 @@ Object.extend(Array.prototype, { Array.prototype.toArray = Array.prototype.clone; -function $w(string){ +function $w(string) { string = string.strip(); return string ? string.split(/\s+/) : []; } -if(Prototype.Browser.Opera){ - Array.prototype.concat = function(){ +if (Prototype.Browser.Opera){ + Array.prototype.concat = function() { var array = []; - for(var i = 0, length = this.length; i < length; i++) array.push(this[i]); - for(var i = 0, length = arguments.length; i < length; i++) { - if(arguments[i].constructor == Array) { - for(var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++) + for (var i = 0, length = this.length; i < length; i++) array.push(this[i]); + for (var i = 0, length = arguments.length; i < length; i++) { + if (arguments[i].constructor == Array) { + for (var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++) array.push(arguments[i][j]); } else { array.push(arguments[i]); diff --git a/src/base.js b/src/base.js index d0d7535..f1ffac8 100644 --- a/src/base.js +++ b/src/base.js @@ -99,7 +99,7 @@ Object.extend(Number.prototype, { return '0'.times(length - string.length) + string; }, - toJSON: function(){ + toJSON: function() { return isFinite(this) ? this.toString() : 'null'; } }); diff --git a/src/dom.js b/src/dom.js index 6d7ae4f..1df63c2 100644 --- a/src/dom.js +++ b/src/dom.js @@ -421,9 +421,9 @@ if (Prototype.Browser.Opera) { case 'top': case 'right': case 'bottom': - if(Element._getStyle(element, 'position') == 'static') return null; + if (Element._getStyle(element, 'position') == 'static') return null; default: return Element._getStyle(element, style); - } + } }; } else if (Prototype.Browser.IE) { @@ -480,17 +480,13 @@ else if (Prototype.Browser.IE) { div.innerHTML = '
' + html.stripScripts() + '
'; depth = 4; } - $A(element.childNodes).each(function(node){ - element.removeChild(node) - }); - depth.times(function(){ div = div.firstChild }); - - $A(div.childNodes).each( - function(node){ element.appendChild(node) }); + $A(element.childNodes).each(function(node) { element.removeChild(node) }); + depth.times(function() { div = div.firstChild }); + $A(div.childNodes).each(function(node) { element.appendChild(node) }); } else { element.innerHTML = html.stripScripts(); } - setTimeout(function() {html.evalScripts()}, 10); + setTimeout(function() { html.evalScripts() }, 10); return element; } } diff --git a/src/hash.js b/src/hash.js index efeb3d1..9d0e0b1 100644 --- a/src/hash.js +++ b/src/hash.js @@ -26,7 +26,7 @@ Object.extend(Hash, { toJSON: function(object) { var results = []; - this.prototype._each.call(object, function(pair){ + this.prototype._each.call(object, function(pair) { var value = Object.toJSON(pair.value); if (value !== undefined) results.push(pair.key.toJSON() + ':' + value); }); diff --git a/src/string.js b/src/string.js index c81e45a..266607b 100644 --- a/src/string.js +++ b/src/string.js @@ -1,5 +1,5 @@ Object.extend(String, { - interpret: function(value){ + interpret: function(value) { return value == null ? '' : String(value); }, specialChar: { @@ -85,7 +85,7 @@ Object.extend(String.prototype, { var div = document.createElement('div'); div.innerHTML = this.stripTags(); return div.childNodes[0] ? (div.childNodes.length > 1 ? - $A(div.childNodes).inject('',function(memo,node){ return memo+node.nodeValue }) : + $A(div.childNodes).inject('', function(memo, node) { return memo+node.nodeValue }) : div.childNodes[0].nodeValue) : ''; }, @@ -159,15 +159,15 @@ Object.extend(String.prototype, { return "'" + escapedString.replace(/'/g, '\\\'') + "'"; }, - toJSON: function(){ + toJSON: function() { return this.inspect(true); }, - evalJSON: function(sanitize){ + evalJSON: function(sanitize) { try { if (!sanitize || (/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(this))) return eval('(' + this + ')'); - } catch(e) {} + } catch (e) {} throw new SyntaxError('Badly formated JSON string: ' + this.inspect()); },