@@ -6,6 +6,8 @@ var css_box = document.getElementById("css");
66var source = document . getElementById ( "schemascii" ) ;
77var download_button = document . getElementById ( "download" ) ;
88var ver_switcher = document . getElementById ( "version" ) ;
9+ var style_elem = document . getElementById ( "custom-css" ) ;
10+ var output = document . getElementById ( "output" ) ;
911
1012var schemascii ;
1113var monkeysrc ;
@@ -34,6 +36,7 @@ async function main() {
3436 ver_switcher . value = latest_version ;
3537 info ( `["${ all_versions . join ( '", "' ) } "]\nlatest=${ latest_version } \n` ) ;
3638 await switch_version ( ) ;
39+
3740 css_box . addEventListener ( "input" , debounce ( sync_css ) ) ;
3841 source . addEventListener ( "input" , debounce ( catched ( render ) ) ) ;
3942 download_button . addEventListener ( "click" , download ) ;
@@ -95,11 +98,13 @@ async function switch_version() {
9598 info ( "Installing Schemascii version " + ver_switcher . value + "... " )
9699 await pyodide . pyimport ( "micropip" ) . install ( ver_map [ ver_switcher . value ] ) ;
97100 monkeypatch ( ) ;
98- schemascii = pyodide . runPython ( "import schemascii; schemascii " ) ;
101+ schemascii = pyodide . runPython ( "import schemascii\nschemascii " ) ;
99102 info ( "done\n" ) ;
103+ output . innerHTML = "" ;
100104}
101105
102106function download ( ) {
107+ if ( ! output . innerHTML ) return ;
103108 var a = document . createElement ( "a" ) ;
104109 a . setAttribute ( "href" , URL . createObjectURL ( new Blob ( [ output . innerHTML ] , { "type" : "application/svg+xml" } ) ) ) ;
105110 a . setAttribute ( "download" , `schemascii_playground_${ new Date ( ) . toISOString ( ) } _no_css.svg` ) ;
0 commit comments