File tree Expand file tree Collapse file tree 1 file changed +14
-10
lines changed
Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -13,25 +13,29 @@ const editor = CodeMirror.fromTextArea(document.querySelector('#input'), {
1313} ) ;
1414
1515let onChangeTimer ;
16- function run ( ) {
17- if ( onChangeTimer !== null ) {
18- clearTimeout ( onChangeTimer ) ;
19- }
20- onChangeTimer = setTimeout ( ( ) => {
21- onChangeTimer = null ;
16+ function run ( timer ) {
17+ if ( timer ) {
18+ if ( onChangeTimer !== null ) {
19+ clearTimeout ( onChangeTimer ) ;
20+ }
21+ onChangeTimer = setTimeout ( ( ) => {
22+ onChangeTimer = null ;
23+ evaluate ( editor . getValue ( ) ) ;
24+ } , 500 ) ;
25+ } else {
2226 evaluate ( editor . getValue ( ) ) ;
23- } , 500 ) ;
27+ }
2428}
2529
2630editor . on ( 'change' , ( ) => {
2731 if ( ! autoEvaluate . checked ) {
2832 return ;
2933 }
30- run ( ) ;
34+ run ( true ) ;
3135} ) ;
3236
3337runButton . addEventListener ( 'click' , ( ) => {
34- run ( ) ;
38+ run ( false ) ;
3539} ) ;
3640
3741getState ( 'code' )
@@ -41,7 +45,7 @@ getState('code')
4145
4246mode . addEventListener ( 'change' , ( ) => {
4347 setState ( 'mode' , mode . value ) ;
44- run ( ) ;
48+ run ( false ) ;
4549} ) ;
4650
4751getState ( 'mode' )
You can’t perform that action at this time.
0 commit comments