1
1
<!DOCTYPE html>
2
2
< html >
3
- < head >
4
- < meta charset ="UTF-8 ">
5
- < meta name ="viewport " content ="user-scalable=no, width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0 " />
6
- < link rel ="stylesheet " href ="/testbed/styles.css " />
7
- < title > Testbed for Planck.js</ title >
8
- </ head >
9
- < body >
10
- < div class ="center ">
11
- < div class ="header ">
12
- < table class ="control ">
13
- < tr > < td >
14
- < a id ="testbed-play " class ="pause "> < span class ="pause "> Pause</ span > < span class ="play "> Play</ span > </ a >
15
- </ td > < td >
16
- < a id ="testbed-reload "> Reload</ a >
17
- </ td > < td >
18
- < a id ="testbed-prev "> Prev</ a >
19
- </ td > < td >
20
- < a id ="testbed-next "> Next</ a >
21
- </ td > < td >
22
- < select id ="testbed-select ">
23
- < option selected disabled hidden value =''> Select...</ option >
24
- </ select >
25
- </ td > </ tr >
26
- </ table >
27
- < h3 class ="title "> Planck.js</ h3 >
28
- </ div >
29
- < canvas id ="stage "> </ canvas >
30
- < div class ="output ">
31
- < div id ="testbed-status "> </ div >
32
- < div id ="testbed-info "> </ div >
33
- </ div >
34
- </ div >
35
- < script type ="module ">
36
- if ( window . location . pathname . startsWith ( '/example/' ) ) {
37
- import ( window . location . pathname ) ;
38
- }
39
- </ script >
40
- < script type ="module ">
41
- import list from '/example/list.json' ;
42
- {
43
- const reloadButton = document . getElementById ( 'testbed-reload' ) ;
44
- const listSelect = document . getElementById ( 'testbed-select' ) ;
45
- const nextButton = document . getElementById ( 'testbed-next' ) ;
46
- const prevButton = document . getElementById ( 'testbed-prev' ) ;
47
3
48
- reloadButton . addEventListener ( 'click' , function ( ) {
49
- window . location . reload ( ) ;
50
- } ) ;
4
+ < head >
5
+ < meta charset ="UTF-8 ">
6
+ < meta name ="viewport "
7
+ content ="user-scalable=no, width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0 " />
8
+ < link rel ="stylesheet " href ="/testbed/styles.css " />
9
+ < title > Testbed for Planck.js</ title >
10
+ </ head >
11
+
12
+ < body >
13
+ < div class ="center ">
14
+ < div class ="header ">
15
+ < table class ="control ">
16
+ < tr >
17
+ < td >
18
+ < a id ="testbed-play " class ="pause "> < span class ="pause "> Pause</ span > < span class ="play "> Play</ span > </ a >
19
+ </ td >
20
+ < td >
21
+ < a id ="testbed-reload "> Reload</ a >
22
+ </ td >
23
+ < td >
24
+ < a id ="testbed-prev "> Prev</ a >
25
+ </ td >
26
+ < td >
27
+ < a id ="testbed-next "> Next</ a >
28
+ </ td >
29
+ < td >
30
+ < select id ="testbed-select ">
31
+ < option selected disabled hidden value =''> Select...</ option >
32
+ </ select >
33
+ </ td >
34
+ </ tr >
35
+ </ table >
36
+ < h3 class ="title "> Planck.js</ h3 >
37
+ </ div >
38
+ < canvas id ="stage "> </ canvas >
39
+ < div class ="output ">
40
+ < div id ="testbed-status "> </ div >
41
+ < div id ="testbed-info "> </ div >
42
+ </ div >
43
+ </ div >
44
+ < script type ="module ">
45
+ const url = new URL ( document . location . toString ( ) ) ;
46
+ const file = url . searchParams . get ( "example" ) ;
47
+ import ( '/example/' + file + '.ts' ) ;
48
+ </ script >
49
+ < script type ="module ">
50
+ import list from '/example/list.json' ;
51
+ {
52
+ const reloadButton = document . getElementById ( 'testbed-reload' ) ;
53
+ const listSelect = document . getElementById ( 'testbed-select' ) ;
54
+ const nextButton = document . getElementById ( 'testbed-next' ) ;
55
+ const prevButton = document . getElementById ( 'testbed-prev' ) ;
51
56
52
- listSelect . addEventListener ( 'change ' , function ( ) {
53
- window . location . href = this . options [ listSelect . selectedIndex ] . value ;
54
- } ) ;
57
+ reloadButton . addEventListener ( 'click ' , function ( ) {
58
+ window . location . reload ( ) ;
59
+ } ) ;
55
60
56
- for ( const example of list ) {
57
- var opt = document . createElement ( 'option' ) ;
58
- opt . value = '/example/' + example ;
59
- opt . innerHTML = example ;
60
- opt . selected = opt . value === window . location . pathname ;
61
- listSelect . appendChild ( opt ) ;
62
- }
61
+ listSelect . addEventListener ( 'change' , function ( ) {
62
+ window . location . href = this . options [ listSelect . selectedIndex ] . value ;
63
+ } ) ;
63
64
64
- nextButton . addEventListener ( 'click' , function ( ) {
65
- playNext ( + 1 ) ;
66
- } ) ;
65
+ for ( const example of list ) {
66
+ const option = document . createElement ( 'option' ) ;
67
+ option . value = '?example=' + example ;
68
+ option . innerHTML = example ;
69
+ option . selected = window . location . search . indexOf ( example ) > - 1 ;
70
+ listSelect . appendChild ( option ) ;
71
+ }
67
72
68
- prevButton . addEventListener ( 'click' , function ( ) {
69
- playNext ( - 1 ) ;
70
- } ) ;
73
+ nextButton . addEventListener ( 'click' , function ( ) {
74
+ playNext ( + 1 ) ;
75
+ } ) ;
71
76
72
- function playNext ( step ) {
73
- for ( var i = 0 ; i < listSelect . options . length ; i ++ ) {
74
- var index = ( listSelect . selectedIndex + ( 1 + i ) * step + listSelect . options . length ) % listSelect . options . length ;
77
+ prevButton . addEventListener ( 'click' , function ( ) {
78
+ playNext ( - 1 ) ;
79
+ } ) ;
75
80
76
- var option = listSelect . options [ index ] ;
77
- if ( option && option . value ) {
78
- window . location . href = option . value ;
79
- break ;
80
- }
81
- }
81
+ function playNext ( step ) {
82
+ const nextIndex = ( listSelect . selectedIndex + step + listSelect . options . length ) % listSelect . options . length ;
83
+ const nextOption = listSelect . options [ nextIndex ] ;
84
+ if ( nextOption && nextOption . value ) {
85
+ window . location . href = nextOption . value ;
82
86
}
83
87
}
84
- </ script >
85
- </ body >
86
- </ html >
88
+ }
89
+ </ script >
90
+ </ body >
91
+
92
+ </ html >
0 commit comments