22
22
border-radius : 4px ;
23
23
background : # f06433 ;
24
24
}
25
+ hr .split {
26
+ border-style : dashed;
27
+ border-width : 1px ;
28
+ }
29
+
25
30
</ style >
26
31
27
32
</ head >
28
- < body >
29
- < div id ="progress " class ="progress "> < div id ="progress-bar " class ="progress-bar "> </ div > </ div >
33
+ < body custom-attr =" ca " >
34
+ < div id ="progress " class ="progress "> < div id ="progress-bar " class ="progress-bar " ondblclick =" alert('dbClick') " > </ div > </ div >
30
35
< h1 > AX5 API Check</ h1 >
31
36
< div id ="test-result " class ="test-result "> </ div >
32
- < p > [email protected] - 2014-12-11
</ p >
37
+ < p id =" author " ondblclick =" alert('author_dbClick') " > [email protected] - 2014-12-11
</ p >
33
38
34
39
< div id ="id-test "> </ div >
35
40
< a class ="class-text "> </ a >
36
41
37
- < span data-attr ="A "> </ span >
42
+ < span data-attr ="A " id =" test " > </ span >
38
43
< div data-attr ="B "> </ div >
39
44
40
45
< script type ="text/javascript ">
41
46
/*
42
47
http://ax5.io/jsdoc/document/index.html 에 좌측메뉴 순서대로 테스트 코드를 작성을 기준으로 하지만 짝이 있는 함수일 경우 같이 작성 합니다.
43
48
*/
49
+ var eventChecker = '' ;
50
+ var eventCheckerFn = function ( ) {
51
+ eventChecker = "click_event_on" ;
52
+ } ;
53
+
44
54
var check_list = [
55
+ //ax5.util----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
45
56
{
46
57
label :"ax5.util.alert" ,
47
58
fn : function ( ) {
48
59
return ( function A ( ) { return typeof ax5 . util . alert ; } ) ( ) ;
49
60
}
50
61
} ,
62
+ {
63
+ label :"ax5.util.attr" ,
64
+ fn : function ( ) {
65
+ ax5 . util . attr ( ax5 . util . get_elements ( "[data-attr=A]" ) , "set" , { "data-ax-spt" :"ABCD" } ) ;
66
+ ax5 . util . attr ( ax5 . util . get_elements ( "[data-attr=A]" ) , "set" , { "customn-attr-1" :"ca1" , "customn-attr-2" :"ca2" } ) ;
67
+ var getAttr = ax5 . util . attr ( ax5 . util . get_elements ( "[data-attr=A]" ) , "data-ax-spt" ) ;
68
+ var getAttr2 = ax5 . util . attr ( ax5 . util . get_elements ( "[data-attr=A]" ) , "customn-attr-2" ) ;
69
+ ax5 . util . attr ( ax5 . util . get_elements ( "[data-attr=A]" ) , "remove" , "customn-attr-1" ) ;
70
+ var getAttr3 = ax5 . util . attr ( ax5 . util . get_elements ( "[data-attr=A]" ) , "customn-attr-1" ) ;
71
+
72
+ return ( getAttr + " " + getAttr2 + " " + getAttr3 ) ;
73
+ } ,
74
+ r :"ABCD ca2 null"
75
+ } ,
76
+ {
77
+ label :"ax5.util.clazz" ,
78
+ fn : function ( ) {
79
+ var hasResult1 = ax5 . util . clazz ( ax5 . util . get_elements ( "#test-result" ) , "test-result" ) ;
80
+ var hasResult_false = ax5 . util . clazz ( ax5 . util . get_elements ( "#test-result" ) , "no-exist" ) ;
81
+ var addResult = ax5 . util . clazz ( ax5 . util . get_elements ( "#test-result" ) , "add" , "add-class-name" ) ;
82
+ var hasResult2 = ax5 . util . clazz ( ax5 . util . get_elements ( "#test-result" ) , "add-class-name" ) ;
83
+ var removeResult = ax5 . util . clazz ( ax5 . util . get_elements ( "#test-result" ) , "remove" , "add-class-name" ) ;
84
+ var hasResult3 = ax5 . util . clazz ( ax5 . util . get_elements ( "#test-result" ) , "add-class-name" ) ;
85
+ var toggleResult = ax5 . util . clazz ( ax5 . util . get_elements ( "#test-result" ) , "toggle" , "add-class-name" ) ;
86
+ var hasResult4 = ax5 . util . clazz ( ax5 . util . get_elements ( "#test-result" ) , "add-class-name" ) ;
87
+ var toggleResult = ax5 . util . clazz ( ax5 . util . get_elements ( "#test-result" ) , "toggle" , "add-class-name" ) ;
88
+ var hasResult5 = ax5 . util . clazz ( ax5 . util . get_elements ( "#test-result" ) , "add-class-name" ) ;
89
+
90
+ var po = [ ] ;
91
+ po . push ( hasResult1 ) ;
92
+ po . push ( hasResult_false ) ;
93
+ po . push ( hasResult2 ) ;
94
+ po . push ( hasResult3 ) ;
95
+ po . push ( hasResult4 ) ;
96
+ po . push ( hasResult5 ) ;
97
+
98
+ return po . join ( ' ' ) ;
99
+ } ,
100
+ r : "true false true false true false"
101
+ } ,
51
102
{
52
103
label :"ax5.util.clone(object)" ,
53
104
fn : function ( ) {
@@ -68,6 +119,18 @@ <h1>AX5 API Check</h1>
68
119
} ,
69
120
r : "string A"
70
121
} ,
122
+ {
123
+ label :"ax5.util.create_elements" ,
124
+ fn : function ( ) {
125
+ var ele = ax5 . util . create_elements ( "div" , { id :"createEleId" , class :"createEleClass" } ) ;
126
+ var target = document . getElementById ( "test-result" ) ;
127
+ target . appendChild ( ele ) ;
128
+
129
+ //return ax5.util.is_element(document.getElementById("test-result"));
130
+ return ax5 . util . is_element ( document . getElementById ( "createEleId" ) ) ;
131
+ } ,
132
+ r : true
133
+ } ,
71
134
{
72
135
label :"ax5.util.each" ,
73
136
fn : function ( ) {
@@ -96,6 +159,29 @@ <h1>AX5 API Check</h1>
96
159
return ( function A ( ) { return typeof ax5 . util . error ; } ) ( ) ;
97
160
}
98
161
} ,
162
+ {
163
+ label :"ax5.util.event_on" ,
164
+ fn : function ( ) {
165
+ var mydom = ax5 . util . get_elements ( "#author" ) ;
166
+ ax5 . util . event_on ( mydom , "click" , eventCheckerFn ) ;
167
+
168
+ mydom [ 0 ] . click ( ) ;
169
+ return eventChecker ;
170
+ } ,
171
+ r : "click_event_on"
172
+ } ,
173
+ {
174
+ label :"ax5.util.event_off" ,
175
+ fn : function ( ) {
176
+ var mydom = ax5 . util . get_elements ( "#author" ) ;
177
+ ax5 . util . event_off ( mydom , "click" , eventCheckerFn ) ;
178
+
179
+ eventChecker = "off" ;
180
+ mydom [ 0 ] . click ( ) ;
181
+ return eventChecker ;
182
+ } ,
183
+ r : "off"
184
+ } ,
99
185
100
186
{
101
187
label :"ax5.util.extend : add key" ,
@@ -176,8 +262,8 @@ <h1>AX5 API Check</h1>
176
262
{
177
263
label :"ax5.util.first(object)" ,
178
264
fn : function ( ) {
179
- var aarray = { a :11 , b :22 , c :33 , d :44 } ;
180
- var result = ax5 . util . first ( aarray ) ;
265
+ var obj = { a :11 , b :22 , c :33 , d :44 } ;
266
+ var result = ax5 . util . first ( obj ) ;
181
267
182
268
return result [ Object . keys ( result ) [ 0 ] ] ;
183
269
} ,
@@ -194,8 +280,8 @@ <h1>AX5 API Check</h1>
194
280
{
195
281
label :"ax5.util.last(object)" ,
196
282
fn : function ( ) {
197
- var aarray = { a :11 , b :22 , c :33 , d :44 }
198
- var result = ax5 . util . last ( aarray ) ;
283
+ var obj = { a :11 , b :22 , c :33 , d :44 }
284
+ var result = ax5 . util . last ( obj ) ;
199
285
200
286
return result [ Object . keys ( result ) [ 0 ] ] ;
201
287
} ,
@@ -257,14 +343,38 @@ <h1>AX5 API Check</h1>
257
343
return ax5 . util . get_elements ( "div.progress #progress-bar" ) ;
258
344
}
259
345
} ,
260
-
261
346
{
262
- label :"ax5.util.get_elements(selecter, parent_element )" ,
347
+ label :"ax5.util.get_elements(selecter, parent_element_selecter )" ,
263
348
fn : function ( ) {
264
- return ax5 . util . get_elements ( "div:first-child" , document . querySelector ( ' #test-result' ) ) ;
349
+ return ax5 . util . get_elements ( 'div #test-result div' ) ;
265
350
}
266
351
} ,
352
+ {
353
+ label :"ax5.util.get_elements(selecter, parent_element_selecter)" ,
354
+ fn : function ( ) {
355
+ return ax5 . util . get_element ( 'div#test-result div' ) ;
356
+ }
357
+ } ,
358
+ {
359
+ label :"ax5.util.get_element_right" ,
360
+ fn : function ( ) {
361
+ var tg = ax5 . util . get_element ( "#progress-bar" ) ;
362
+ var cond = {
363
+ tagname : "div" ,
364
+ clazz :"progress"
267
365
366
+ //,"custom-attr":"ca"
367
+ } ;
368
+ /*
369
+ var cond = {
370
+ tagname: "body"
371
+ //,"custom-attr":"ca"
372
+ };
373
+ */
374
+
375
+ return ax5 . util . get_element_right ( tg , cond ) ;
376
+ }
377
+ } ,
268
378
{
269
379
label :"ax5.util.get_type" ,
270
380
fn : function ( ) {
@@ -298,6 +408,12 @@ <h1>AX5 API Check</h1>
298
408
return ax5 . util . is_function ( a ) ;
299
409
}
300
410
} ,
411
+ {
412
+ label :"ax5.util.is_nodelist" ,
413
+ fn : function ( ) {
414
+ return ax5 . util . is_nodelist ( document . querySelectorAll ( 'div' ) ) ;
415
+ }
416
+ } ,
301
417
{
302
418
label :"ax5.util.is_nothing" ,
303
419
fn : function ( ) {
@@ -398,6 +514,28 @@ <h1>AX5 API Check</h1>
398
514
} ,
399
515
r : "ready-response"
400
516
} ,
517
+ {
518
+ label : "ax5.util.require(not found), fail is OK" ,
519
+ fn : function ( callBack ) {
520
+ ax5 . util . require ( [ "src/ax5_class_sample_not_found.js" ] , function ( ) {
521
+ callBack ( true ) ;
522
+ } , function ( ) {
523
+ callBack ( false ) ;
524
+ } ) ;
525
+ } ,
526
+ r : "ready-response"
527
+ } ,
528
+ {
529
+ label : "ax5.util.require(large file)" ,
530
+ fn : function ( callBack ) {
531
+ ax5 . util . require ( [ "src/ax5_large_class_sample.js?v=" + parseInt ( Math . random ( ) * 100 ) ] , function ( ) {
532
+ callBack ( true ) ;
533
+ } , function ( ) {
534
+ callBack ( false ) ;
535
+ } ) ;
536
+ } ,
537
+ r : "ready-response"
538
+ } ,
401
539
{
402
540
label : "ax5.util.search" ,
403
541
fn : function ( ) {
@@ -453,16 +591,20 @@ <h1>AX5 API Check</h1>
453
591
} ,
454
592
r : "/api-test.html"
455
593
} ,
594
+ //ax5.dom----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
595
+ {
596
+ label : "split"
597
+ } ,
456
598
{
457
599
label : "ax5.dom('#id')" ,
458
600
fn : function ( ) {
459
- return ax5 . util . is_element ( ax5 . dom ( "#id-test" ) . elements [ 0 ] )
601
+ return ax5 . util . is_element ( ax5 . dom ( "#id-test" ) . elements [ 0 ] ) ;
460
602
}
461
603
} ,
462
604
{
463
605
label : "ax5.dom('.class')" ,
464
606
fn : function ( ) {
465
- return ax5 . util . is_element ( ax5 . dom ( ".class-text" ) . elements [ 0 ] )
607
+ return ax5 . util . is_element ( ax5 . dom ( ".class-text" ) . elements [ 0 ] ) ;
466
608
}
467
609
} ,
468
610
{
@@ -474,7 +616,7 @@ <h1>AX5 API Check</h1>
474
616
{
475
617
label : "ax5.dom('[attr=value]')" ,
476
618
fn : function ( ) {
477
- return ax5 . util . is_element ( ax5 . dom ( "[data-attr=A]" ) . elements [ 0 ] )
619
+ return ax5 . util . is_element ( ax5 . dom ( "[data-attr=A]" ) . elements [ 0 ] ) ;
478
620
}
479
621
} ,
480
622
{
@@ -550,35 +692,64 @@ <h1>AX5 API Check</h1>
550
692
var result , err_string ;
551
693
552
694
if ( O . r === "ready-response" ) {
695
+ var skipFlag = false ;
696
+
697
+ /*
698
+ var skipFn = setTimeout(function () {
699
+ //var req = new XMLHttpRequest();
700
+ //req.abort();
701
+ console.log("settimeout");
702
+ skipFlag = true;
703
+
704
+ newDiv.innerHTML = "<h3 class='red'>" + O.label + " : <u>skip</u></h3>";
705
+ target.appendChild(newDiv);
706
+ checker(check_list.shift());
707
+ }, 1000);
708
+ */
709
+
553
710
O . fn ( function ( res ) {
554
- if ( res ) {
555
- newDiv . innerHTML = "<h3 class='blue'>" + O . label + " : <u>OK</u></h3>" ;
556
- target . appendChild ( newDiv ) ;
557
- setTimeout ( function ( ) {
558
- checker ( check_list . shift ( ) ) ;
559
- } , 100 ) ;
711
+ if ( ! skipFlag ) {
712
+ //if(skipFn) clearTimeout(skipFn);
713
+ if ( res ) {
714
+ newDiv . innerHTML = "<h3 class='blue'>" + O . label + " : <u>OK</u></h3>" ;
715
+ target . appendChild ( newDiv ) ;
716
+ setTimeout ( function ( ) {
717
+ checker ( check_list . shift ( ) ) ;
718
+ } , 100 ) ;
719
+ } else {
720
+ newDiv . innerHTML = "<h3 class='red'>" + O . label + " : <u>fail</u></h3>" ;
721
+ target . appendChild ( newDiv ) ;
722
+ setTimeout ( function ( ) {
723
+ checker ( check_list . shift ( ) ) ;
724
+ } , 100 ) ;
725
+ }
560
726
}
561
727
} ) ;
562
728
} else {
563
- try {
564
- result = O . fn ( ) ;
565
- } catch ( e ) {
566
- err_string = e . toString ( ) ;
567
- console . error ( e ) ;
568
- }
729
+ if ( O . label === "split" ) {
730
+ newDiv . innerHTML = "<hr class='split' />" ;
731
+ } else {
732
+ try {
733
+ result = O . fn ( ) ;
734
+ } catch ( e ) {
735
+ err_string = e . toString ( ) ;
736
+ console . error ( e ) ;
737
+ }
569
738
570
- if ( typeof O . r != "undefined" && ( result == O . r ) ) {
571
- newDiv . innerHTML = "<h3 class='blue'>" + O . label + " : <u>OK</u></h3>" ;
572
- } else if ( typeof O . r == "undefined" && result ) {
573
- newDiv . innerHTML = "<h3 class='blue'>" + O . label + " : <u>OK : " + result + "</u></h3>" ;
574
- } else {
575
- newDiv . innerHTML = "<h3 class='red'>" + O . label + " : <u>?? " + result + "[" + err_string + "]" + "</u></h3>" ;
739
+ if ( typeof O . r != "undefined" && ( result == O . r ) ) {
740
+ newDiv . innerHTML = "<h3 class='blue'>" + O . label + " : <u>OK</u></h3>" ;
741
+ } else if ( typeof O . r == "undefined" && result ) {
742
+ newDiv . innerHTML = "<h3 class='blue'>" + O . label + " : <u>OK : " + result + "</u></h3>" ;
743
+ } else {
744
+ newDiv . innerHTML = "<h3 class='red'>" + O . label + " : <u>?? " + result + "[" + err_string + "]" + "</u></h3>" ;
745
+ }
576
746
}
577
747
578
748
target . appendChild ( newDiv ) ;
579
749
setTimeout ( function ( ) {
580
750
checker ( check_list . shift ( ) ) ;
581
751
} , 10 ) ;
752
+
582
753
}
583
754
}
584
755
checker ( check_list . shift ( ) ) ;
0 commit comments