Logo
doctype [?]
[strict] [loose] [none]

Util, DOM, CSS, Event Functions


Successful tests will be green, unsuccessful tests will be red.

Global Functions

isArray

Test #1 : isArray([]) Test #2 : isArray([1]) Test #3 : isArray([1,2,3]) Test #4 : !isArray({'a':'b'}) Test #5 : !isArray({'length':99}) Test #6 : !isArray('test') Test #7 : !isArray(null)

isObject

Test #8 : isObject({}) Test #9 : isObject({'a':'b'}) Test #10 : !isObject([]) Test #11 : !isObject('test') Test #12 : !isObject(null) Test #13 : !isObject(document.getElementsByTagName('DIV')[0])

defined

var defined1;
var defined2=null;
Test #14 : defined(null) Test #15 : !defined(defined1) Test #16 : defined(defined2)

map

var str = "";
Test #17 : map('str+=$_','a','b',['c','d'],{'value1':'e','value2':'f'}) && (str=='abcdef') Test #18 : map('return $_.toLowerCase()',['A','B','C']).join('-')=='a-b-c' Test #19 : map('return $_.toUpperCase()','test')=='TEST'

setDefaultValues

var o = {'a':true,'b':99};
Test #20 : setDefaultValues(o,{'a':false}).a==true Test #21 : setDefaultValues(o,{'b':0}).b==99 Test #22 : setDefaultValues(o,{'c':'test'}).c=='test' Test #23 : setDefaultValues(o,null)==o

DOM

div1
div2
div3
div4

DOM.getParentByTagName

Test #24 : DOM.getParentByTagName(DOM.resolve('div2'),'DIV').id=='div1' Test #25 : DOM.getParentByTagName(DOM.resolve('div1'),'BODY')==Screen.getBody() Test #26 : DOM.getParentByTagName(DOM.resolve('div1'),'JUNK')==null

DOM.removeNode

Test #27 : DOM.removeNode(DOM.resolve('div4'))==true Test #28 : DOM.resolve('div4')==null

DOM.getOuterWidth

DOM.getOuterHeight

DOM.resolve

Test #29 : DOM.resolve('div1')==document.getElementById('div1') Test #30 : DOM.resolve(document.getElementById('div1'))==document.getElementById('div1') Test #31 : DOM.resolve([document.getElementById('div1'),document.getElementById('div2')])[1]==document.getElementById('div2')

CSS

div5
div6
div7
div8

CSS.rgb2hex

Test #32 : CSS.rgb2hex('rgb (255, 0, 0)')=='#ff0000' Test #33 : CSS.rgb2hex('rgb(255,255,16)')=='#ffff10' Test #34 : CSS.rgb2hex('rgb (junk, 255, 16)')=='rgb (junk, 255, 16)' Test #35 : CSS.rgb2hex(null)==null Test #36 : CSS.rgb2hex({})==null

CSS.hyphen2camel

Test #37 : CSS.hyphen2camel()==null Test #38 : CSS.hyphen2camel(null)==null Test #39 : CSS.hyphen2camel('color')=='color' Test #40 : CSS.hyphen2camel('border-width')=='borderWidth' Test #41 : CSS.hyphen2camel('background-color')=='backgroundColor' Test #42 : CSS.hyphen2camel('list-style-type')=='listStyleType'

CSS.hasClass

Test #43 : CSS.hasClass(null,'test')==false Test #44 : CSS.hasClass('','test')==false Test #45 : CSS.hasClass('test','test')==true Test #46 : CSS.hasClass('test1 test2 test3','test')==false Test #47 : CSS.hasClass('test1 test2 test test3','test')==true Test #48 : CSS.hasClass(DOM.resolve('div5'),'div')==true Test #49 : CSS.hasClass(DOM.resolve('div5'),'div2')==true Test #50 : CSS.hasClass(DOM.resolve('div5'),'div3')==false

CSS.addClass

Test #51 : CSS.addClass(null,'test')==false Test #52 : CSS.addClass(DOM.resolve('div6'),'div')==true Test #53 : CSS.addClass(DOM.resolve('div6'),'div')==true Test #54 : CSS.addClass(DOM.resolve('div5'),'div2')==true Test #55 : DOM.resolve('div6').className=='div'

CSS.removeClass

Test #56 : CSS.removeClass(null,'')==false Test #57 : CSS.removeClass(DOM.resolve('div6'),'div')==true Test #58 : CSS.hasClass(DOM.resolve('div6'),'div')==false

CSS.replaceClass

Test #59 : CSS.replaceClass(DOM.resolve('div5'),'div2','div3')==true Test #60 : CSS.hasClass(DOM.resolve('div5'),'div3')==true Test #61 : CSS.hasClass(DOM.resolve('div5'),'div2')==false Test #62 : CSS.replaceClass(DOM.resolve('div5'),'div3','div2')==true Test #63 : CSS.hasClass(DOM.resolve('div5'),'div3')==false Test #64 : CSS.hasClass(DOM.resolve('div5'),'div2')==true

CSS.getStyle

Test #65 : CSS.getStyle(DOM.resolve('div8'),'color')=='#aaaaaa' Test #66 : CSS.getStyle(DOM.resolve('div5'),'height')=='200px' Test #67 : CSS.getStyle(DOM.resolve('div5'),'background-color')=='#ff0000'

CSS.setStyle

Test #68 : CSS.setStyle(null)==false Test #69 : CSS.setStyle(document)==false Test #70 : CSS.setStyle(document,null)==false Test #71 : CSS.setStyle(DOM.resolve('div5'),'background-color','#ffffff')==true Test #72 : CSS.getStyle(DOM.resolve('div5'),'background-color')=='#ffffff'

CSS.createId

id="createIdContainer"
no id
Test #73 : CSS.createId()=='ID_1000' Test #74 : CSS.createId(null)=='ID_1001' Test #75 : CSS.createId(DOM.resolve('createIdContainer'))=='createIdContainer' Test #76 : CSS.createId(DOM.resolve('createIdContainer').getElementsByTagName('DIV')[0])=='ID_1002' Test #77 : DOM.resolve('createIdContainer').getElementsByTagName('DIV')[0].id=='ID_1002'

Event

Event.resolve

No tests

Event.add

These tests require user interaction

Events will be dynamically added to this object.
onmouseover = turn the background yellow
onmouseout = turn the background white
onclick = show an alert message
This is an inner DIV. Clicking here will alert, but the outer alert will not fire because the event will be cancelled

Event.getMouseX

No tests

Event.getMouseY

No tests

Event.cancelBubble

No tests

Event.stopPropagation

No tests

Screen

Screen.getBody

Test #78 : Screen.getBody() == document.getElementsByTagName('BODY')[0]

Screen.getScrollTop

No tests

Screen.getScrollLeft

No tests

Screen.getDocumentWidth

No tests

Screen.getDocumentHeight

No tests

Screen.getViewportWidth

No tests

Screen.getViewportHeight

No tests

Sort

Sort.AlphaNumeric

Test #79 : Sort.AlphaNumeric(null,null)==0 Test #80 : Sort.AlphaNumeric('a',null)==1 Test #81 : Sort.AlphaNumeric('a','b')==-1 Test #82 : Sort.AlphaNumeric('a','A')==1 Test #83 : Sort.AlphaNumeric(1,9)==-1 Test #84 : Sort.AlphaNumeric(null,null)==0 Test #85 : Sort.AlphaNumeric(null,null)==0

Sort.Numeric

Test #86 : Sort.Numeric(1,9)<0 Test #87 : Sort.Numeric(0,0)==0 Test #88 : Sort.Numeric(-1,-2)>0 Test #89 : Sort.Numeric('1,234','1,235')<0 Test #90 : Sort.Numeric('10 camels','5 camels')>0 Test #91 : Sort.Numeric('junk',0)==0 Test #92 : Sort.Numeric('junk',1)<0

Sort.IgnoreCase

Test #93 : Sort.IgnoreCase(null,null)==0 Test #94 : Sort.IgnoreCase('a',null)==1 Test #95 : Sort.IgnoreCase('a','b')==-1 Test #96 : Sort.IgnoreCase('a','A')==0 Test #97 : Sort.IgnoreCase(1,9)==-1 Test #98 : Sort.IgnoreCase(null,null)==0 Test #99 : Sort.IgnoreCase(null,null)==0 Test #100 : Sort.IgnoreCase('JavaScript','JAVAscript')==0

Sort.Currency

Test #101 : Sort.Currency('$1.45','$1.50')<0 Test #102 : Sort.Currency('$1.99',null)>0 Test #103 : Sort.Currency('$ .99','1')<0

Sort.Date

Test #104 : Sort.Date('2000-01-01','1/1/2000')==0 Test #105 : Sort.Date('2001-01-01','1/1/2000')>0 Test #106 : Sort.Date('junk','1/1/2000')>0 Test #107 : Sort.Date('99-01-01','1/1/1999')==0 Test #108 : Sort.Date('01-02-1998','1/1/99')>0