< div>
< b>
some text
< strong> </ strong>
< span> </ span>
< em> </ em>
< i> </ i>
</ b>
< strong>
< span>
< time> </ time>
</ span>
</ strong>
</ div>
< script>
function retElementChild ( node) {
var temp = {
length : 0 ,
push : Array. prototype. push,
splice : Array. prototype. splice
} ;
if ( ! node) { return temp; }
var child = node. childNodes,
len = child. length;
for ( var i = 0 ; i < len; i ++ ) {
if ( child[ i] . nodeType === 1 ) {
temp. push ( child[ i] ) ;
}
}
return temp;
}
Element. prototype. myChildren = function ( ) {
var child = this . childNodes,
len = child. length;
arr = [ ] ;
for ( var i = 0 ; i < len; i ++ ) {
if ( child[ i] . nodeType == 1 ) {
arr. push ( child[ i] ) ;
}
}
return arr;
}
function retParent ( e, n) {
while ( e && n) {
e = e. parentElement;
n -- ;
}
return e;
}
function retSibling ( e, n) {
while ( e && n) {
if ( n > 0 ) {
if ( e. nextElemntSibling) {
e = e. nextElementSibling;
} else {
for ( e = e. nextSibling; e && e. nodeType != 1 ; e = e. nextSibling) ;
}
n -- ;
} else {
if ( e. previousElementSibling) {
e = e. previousElementSibling;
} else {
for ( e = e. previousSibling; e && e. nodeType != 1 ; e = e. previousSibling) ;
}
n ++ ;
}
}
return e;
}
function getScrollOffset ( ) {
if ( window. pageXOffset) {
return {
x : window. pageXOffset,
y : window. pageYOffset
}
} else {
return {
x : document. body. scrollLeft + document. documentElement. scrollLeft,
y : document. body. scrollTop + document. documentElement. scrollTop
}
}
}
function getViewportOffset ( ) {
if ( window. innerWidth) {
return {
w : window. innerWidth,
h : window. innerHeight
}
} else {
if ( document. compatMode === "BackCompat" ) {
return {
w : document. body. clientWidth,
h : document. body. clientHeight
}
} else {
return {
w : document. documentElement. clientWidth,
h : document. documentElement. clientHeight
}
}
}
}
</ script>
function deepClone ( o, t) {
t = t || { } ;
for ( var k in o) {
if ( o. hasOwnProperty ( k) ) {
if ( o[ k] !== null && typeof ( o[ k] ) == 'object' ) {
t[ k] = Object. prototype. toString. call ( o[ k] ) == '[object Array]' ? [ ] : { } ;
deepClone ( o[ k] , t[ k] ) ;
} else {
t[ k] = o[ k] ;
}
}
}
return t;
}
function type ( t) {
var temp = {
'[object Array]' : 'array' ,
'[object Object]' : 'object' ,
'[object Number]' : 'number object' ,
'[object Boolean]' : 'boolean object' ,
'[object String]' : 'string object'
}
if ( t === null ) { return 'null' ; }
if ( typeof ( t) == 'object' ) {
var str = Object. prototype. toString. call ( t) ;
return temp[ str] ;
}
return typeof ( t) ;
}
Array. prototype. unique = function ( diff) {
var arr = [ ] ,
len = this . length;
if ( diff) {
var temp = {
"string" : { } ,
"else" : { }
} ;
for ( var i = 0 ; i < len; i ++ ) {
if ( type ( this [ i] ) == "string" ) {
if ( ! temp[ "string" ] [ this [ i] ] ) {
temp[ "string" ] [ this [ i] ] = "zhanwei" ;
arr. push ( this [ i] ) ;
}
} else {
if ( ! temp[ "else" ] [ this [ i] ] ) {
temp[ "else" ] [ this [ i] ] = "zhanwei" ;
arr. push ( this [ i] ) ;
}
}
}
} else {
var temp = { } ;
for ( var i = 0 ; i < len; i ++ ) {
if ( ! temp[ this [ i] ] ) {
temp[ this [ i] ] = "zhanwei" ;
arr. push ( this [ i] ) ;
}
}
}
return arr;
}