Comparing version 0.3.0 to 0.3.1
@@ -327,12 +327,26 @@ (function (JSUS) { | ||
var attributes = attributes || {'rel' : 'stylesheet', | ||
'type': 'text/css'}; | ||
attributes = attributes || {}; | ||
attributes.href = css; | ||
attributes = JSUS.merge(attributes, {rel : 'stylesheet', | ||
type: 'text/css', | ||
href: css, | ||
}); | ||
var id = id || 'maincss'; | ||
return this.addElement('link', root, id, attributes); | ||
}; | ||
DOM.addJS = function (root, js, id, attributes) { | ||
var root = root || document.head || document.body || document; | ||
if (!root) return false; | ||
attributes = attributes || {}; | ||
attributes = JSUS.merge(attributes, {charset : 'utf-8', | ||
type: 'text/javascript', | ||
src: js, | ||
}); | ||
return this.addElement('script', root, id, attributes); | ||
}; | ||
DOM.getDiv = function (id, attributes) { | ||
@@ -339,0 +353,0 @@ return this.getElement('div', id, attributes); |
@@ -170,23 +170,2 @@ (function (JSUS) { | ||
}; | ||
// /** | ||
// * Creates a perfect copy of the object passed as parameter. | ||
// * | ||
// * @deprecated | ||
// * | ||
// */ | ||
// OBJ.clone_old = function (obj) { | ||
// if (!obj) return; | ||
// var clone = {}; | ||
// for (var i in obj) { | ||
// //if (obj.hasOwnProperty(i)) { | ||
// if ( 'object' === typeof obj[i] ) { | ||
// clone[i] = OBJ.clone(obj[i]); | ||
// } else { | ||
// clone[i] = obj[i]; | ||
// } | ||
// //} | ||
// } | ||
// return clone; | ||
// }; | ||
@@ -203,4 +182,5 @@ /** | ||
var value = ('object' === typeof obj[i]) ? OBJ.clone(obj[i]) | ||
: obj[i]; | ||
// It is not NULL and it is an object | ||
var value = (obj[i] && 'object' === typeof obj[i]) ? OBJ.clone(obj[i]) | ||
: obj[i]; | ||
@@ -262,2 +242,7 @@ if (obj.hasOwnProperty(i)) { | ||
OBJ.merge = function (obj1, obj2) { | ||
// Checking before starting the algorithm | ||
if (!obj1 && !obj2) return false; | ||
if (!obj1) return OBJ.clone(obj2); | ||
if (!obj2) return OBJ.clone(obj1); | ||
var clone = OBJ.clone(obj1); | ||
@@ -267,3 +252,4 @@ if (!obj2) return clone; | ||
if (obj2.hasOwnProperty(i)) { | ||
if ( 'object' === typeof obj2[i] ) { | ||
// it is an object and it is not NULL | ||
if ( obj2[i] && 'object' === typeof obj2[i] ) { | ||
clone[i] = OBJ.merge(obj1[i],obj2[i]); | ||
@@ -270,0 +256,0 @@ } else { |
{ | ||
"name": "JSUS", | ||
"description": "JavaScript UtilS. Collection of general purpose functions. JSUS helps!", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"keywords": [ "util", "general", "array", "eval", "time", "date", "object"], | ||
@@ -6,0 +6,0 @@ "author": "Stefano Balietti <futur.dorko@gmail.com>", |
56585
14
1621