@@ -3,9 +3,19 @@ function ping() {
3
3
document . getElementById ( 'version' ) . innerText = data . go_version ;
4
4
} ) ;
5
5
}
6
+ ping ( ) ; // inject version info
7
+
8
+
6
9
7
10
let msgbox = document . getElementById ( 'outputMsg' )
8
11
let ssabox = document . getElementById ( 'ssa' )
12
+ ssabox . addEventListener ( 'load' , ( ) => {
13
+ // inject ssa style
14
+ let $head = $ ( "iframe" ) . contents ( ) . find ( "head" ) ;
15
+ $head . append ( $ ( "<link/>" , { rel : "stylesheet" , href : "/gossa/scrollbar.css" , type : "text/css" } ) ) ;
16
+ setMessageBox ( '' , true )
17
+ } ) ;
18
+
9
19
let lastFuncName , lastCode ;
10
20
function build ( ) {
11
21
let funcname = document . getElementById ( 'funcname' ) . value ;
@@ -17,18 +27,17 @@ function build() {
17
27
return
18
28
}
19
29
if ( ! code . includes ( 'func ' + funcname ) ) {
20
- ssabox . src = ''
21
- msgbox . innerText = 'GOFUNCNAME does not exist in your code.'
30
+ setMessageBox ( 'GOFUNCNAME does not exist in your code.' , false )
22
31
return
23
32
}
24
33
25
- msgbox . innerText = ''
26
34
lastFuncName = funcname
27
35
lastCode = code
36
+ setMessageBox ( 'Waiting for response...' , false )
28
37
29
38
fetch ( '/api/v1/buildssa' , {
30
39
method : 'POST' ,
31
- headers : { 'Content-Type' : 'application/json' , } ,
40
+ headers : { 'Content-Type' : 'application/json' } ,
32
41
body : JSON . stringify ( {
33
42
'funcname' : funcname ,
34
43
'code' : code ,
@@ -44,24 +53,20 @@ function build() {
44
53
} )
45
54
. then ( res => {
46
55
ssabox . src = `/gossa/buildbox/${ res . data . build_id } /ssa.html`
47
- msgbox . innerText = ''
48
56
} )
49
- . catch ( res => {
50
- ssabox . src = ''
51
- msgbox . innerText = res . data . msg
52
- } ) ;
57
+ . catch ( res => setMessageBox ( res . data . msg , true ) ) ;
53
58
}
54
59
55
- // inject ssa style
56
- let ssablock = document . getElementById ( 'ssa' )
57
- ssablock . addEventListener ( 'load' , ( ) => {
58
- // wait until ssa is loaded
59
- let $head = $ ( "iframe" ) . contents ( ) . find ( "head" ) ;
60
- $head . append ( $ ( "<link/>" , { rel : "stylesheet" , href : "/gossa/scrollbar.css" , type : "text/css" } ) ) ;
61
- } )
62
-
63
- // inject version info
64
- ping ( ) ;
60
+ function setMessageBox ( msg , hide ) {
61
+ msgbox . innerText = msg
62
+ if ( hide ) {
63
+ ssabox . style . display = '' ;
64
+ msgbox . style . display = 'none' ;
65
+ return
66
+ }
67
+ ssabox . style . display = 'none' ;
68
+ msgbox . style . display = '' ;
69
+ }
65
70
66
71
// listen build action
67
72
let buildssa = document . getElementById ( 'build' )
@@ -85,6 +90,7 @@ $('#aboutbtn').click(function() {
85
90
aboutinfo . show ( ) ;
86
91
} )
87
92
93
+ // textarea and tab key stroke
88
94
$ ( '#code' ) . linedtextarea ( ) ;
89
95
$ ( '#code' ) . keydown ( function ( event ) {
90
96
if ( event . keyCode == 9 ) {
0 commit comments