1515 < h1 > 4X4</ h1 >
1616</ section >
1717
18+ < section id ="color_picker " class ="color-picker ">
19+ < div class ="color active " style ="background-color: var(--Green) "> </ div >
20+ < div class ="color " style ="background-color: var(--Blue) "> </ div >
21+ < div class ="color " style ="background-color: var(--red) "> </ div >
22+ < div class ="color " style ="background-color: var(--pruple) "> </ div >
23+ < div class ="color " style ="background-color: var(--Pink) "> </ div >
24+ < div class ="color " style ="background-color: var(--orange) "> </ div >
25+ < div class ="color " style ="background-color: var(--yellow) "> </ div >
26+ < div class ="color " style ="background-color: var(--white) "> </ div >
27+ < div class ="color " style ="background-color: var(--black) "> </ div >
28+ < div id ="show_btn " class ="show-btn "> < span > > </ span > </ div >
29+ </ section >
30+
1831<!--Script-->
1932< script type ="text/javascript ">
2033 let LightSaber = document . getElementById ( "LightSaber" ) ;
2134 if ( window . outerHeight > window . outerWidth ) {
2235 LightSaber . classList . add ( "Second" )
2336 LightSaber . style . width = window . outerHeight + "px"
2437 }
38+
39+ /* color-picker */
40+ let color_picker = document . getElementById ( "color_picker" ) ;
41+ let colors = document . getElementsByClassName ( "color" ) ;
42+ let show_btn = document . getElementById ( "show_btn" ) ;
43+ show_btn . onclick = ( ) => {
44+ color_picker . classList . toggle ( "show" )
45+ }
46+ for ( let i = 0 ; i < colors . length ; i ++ ) {
47+ colors [ i ] . addEventListener ( "click" , ( ) => {
48+ for ( let g = 0 ; g < colors . length ; g ++ ) {
49+ colors [ g ] . className = "color" ;
50+ }
51+ colors [ i ] . className = "color active" ;
52+ document . querySelector ( ':root' ) . style . setProperty ( '--LightSaber-color' , colors [ i ] . style . backgroundColor ) ;
53+ let animationName = getComputedStyle ( LightSaber ) . animationName ;
54+ LightSaber . style . animationName = "none" ;
55+ setTimeout ( function ( ) {
56+ LightSaber . style . animationName = animationName ;
57+ } , 100 ) ;
58+ } )
59+ }
2560</ script >
2661</ body >
2762</ html >
0 commit comments