File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ <h1>engine262</h1>
3939 < option value ="module "> Module</ option >
4040 </ select >
4141 < button type ="button " id ="save-to-gist "> Save to Gist</ button >
42+ < span id ="save-to-gist-output "> </ span >
4243 </ fieldset >
4344
4445 < textarea id ="input " autocomplete ="off "> </ textarea >
Original file line number Diff line number Diff line change @@ -87,10 +87,11 @@ export function setState(name, value) {
8787 . then ( ( ) => updateState ( ) ) ;
8888}
8989
90+ const saveSpan = document . querySelector ( '#save-to-gist-output' ) ;
9091document . querySelector ( '#save-to-gist' )
91- . addEventListener ( 'click' , async ( ) => {
92- const s = await state ;
93- const id = await fetch ( 'https://engine262-api.snek.now.sh/api/gist' , {
92+ . addEventListener ( 'click' , ( ) => {
93+ saveSpan . textContent = 'Saving...' ;
94+ state . then ( ( s ) => fetch ( 'https://engine262-api.snek.now.sh/api/gist' , {
9495 method : 'POST' ,
9596 headers : {
9697 'Content-Type' : 'application/json' ,
@@ -102,7 +103,14 @@ document.querySelector('#save-to-gist')
102103 features : [ ...s . get ( 'features' ) ] ,
103104 } ,
104105 } ) ,
105- } ) . then ( ( r ) => r . text ( ) ) ;
106- s . set ( 'gist' , id ) ;
107- await updateState ( ) ;
106+ } )
107+ . then ( ( r ) => r . text ( ) )
108+ . then ( ( id ) => {
109+ s . set ( 'gist' , id ) ;
110+ saveSpan . textContent = `Saved! ${ id } ` ;
111+ } )
112+ . then ( ( ) => updateState ) )
113+ . catch ( ( e ) => {
114+ saveSpan . textContent = `Error saving to gist: ${ e . message } ` ;
115+ } ) ;
108116 } ) ;
You can’t perform that action at this time.
0 commit comments