1+ <!doctype html>
12< html >
2- < head >
3- < link href ="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/themes/prism-tomorrow.css " rel ="stylesheet " />
4- < script src ="./lib/cginput.js "> </ script >
5- < script >
6- function getPrismJsLanguage ( language ) {
7- switch ( language ) {
8- case 'C#' :
9- return 'csharp'
10- case 'C++' :
11- return 'cpp'
12- case 'F#' :
13- return 'fsharp'
14- case 'VB.NET' :
15- return 'vbnet'
16- case 'Python' :
17- case 'Python3' :
18- return 'python'
19- default :
20- return language . toLowerCase ( )
21- }
22- }
233
24- function getStubInput ( ) {
25- return document . getElementById ( "stubInput" ) . value
26- }
4+ < head >
5+ < link href =" https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/themes/prism-tomorrow.css " rel =" stylesheet " />
6+ < link rel =" stylesheet " type =" text/css " href =" stub.css " >
277
28- function refreshStub ( ) {
29- const resultNode = document . getElementById ( "result" )
30- const errorNode = document . getElementById ( "error" )
31- const languageId = document . getElementById ( "language" ) . value
32- const prismLanguage = getPrismJsLanguage ( languageId )
8+ < script src ="./lib/cginput.js "> </ script >
9+ < script src ="stub.js "> </ script >
10+ </ head >
3311
34- try {
35- resultNode . innerText = cginput . generateStub ( { stubInput : getStubInput ( ) , languageId : languageId } )
36-
37- resultNode . innerHTML = resultNode . innerHTML . replace ( / [ < ] b r [ / ] ? [ > ] / gi, "\n" ) ;
38-
39- resultNode . className = 'language-' + prismLanguage
40- Prism . highlightElement ( resultNode )
41-
42- errorNode . innerText = ''
43- resultNode . style . opacity = 1
44- } catch ( e ) {
45- errorNode . innerText = e . message
46- resultNode . style . opacity = 0.2
47- }
48- }
49-
50- async function load ( ) {
51- const response = await fetch ( '/services/stub' )
52- stub = await response . text ( )
53- document . getElementById ( "stubInput" ) . value = stub
54-
55- refreshStub ( 'java' )
56- }
57-
58- async function save ( ) {
59- document . getElementById ( "save" ) . disabled = true
60- await fetch ( '/services/stub' , {
61- body : getStubInput ( ) ,
62- method : 'PUT'
63- } )
64- document . getElementById ( "save" ) . innerText = 'Saved'
65- }
66-
67- function handleChangeStubInput ( ) {
68- document . getElementById ( "save" ) . disabled = false
69- document . getElementById ( "save" ) . innerText = 'Save'
70- refreshStub ( )
71- }
72- </ script >
73- < style >
74- html , body {
75- height : 100%
76- }
77-
78- body {
79- color : white;
80- font-family : 'Open Sans' , Lato, sans-serif;
81- font-weight : 400 ;
82- background-color : # 363e48 ;
83- }
84-
85- textarea {
86- color : white;
87- background-color : # 29323c ;
88- border : solid 1px # 363e48 ;
89- outline : none;
90- }
91-
92- button {
93- border : none;
94- font : inherit;
95- cursor : pointer;
96- margin : 0 ;
97- padding : 0 ;
98- }
99-
100- * , : after , : before {
101- box-sizing : border-box;
102- -moz-box-sizing : border-box;
103- -webkit-box-sizing : border-box;
104- margin : 0 ;
105- padding : 0 ;
106- }
107-
108- # stubInput {
109- width : 600px ;
110- height : 200px ;
111- }
112-
113- # save {
114- display : block;
115- width : 300px ;
116- background-color : # f2bb13 ;
117- color : # 252e38 ;
118- margin-top : 10px ;
119- text-transform : uppercase;
120- font-size : 14px ;
121- font-weight : 600 ;
122- min-height : 42px ;
123- }
124-
125- # save : hover {
126- opacity : 0.8 ;
127- transition : 0.2s ;
128- }
129-
130- # save : disabled {
131- opacity : 0.8 ;
132- cursor : default;
133- }
134-
135- .edit , .preview {
136- margin : 10px ;
137- background : # 252e38 ;
138- padding : 20px ;
139- }
140-
141- .edit-title , .preview-title {
142- font-size : 13px ;
143- font-weight : 600 ;
144- color : # f2bb13 ;
145- text-transform : uppercase;
146- margin-bottom : 9px ;
147- }
148-
149- # error , # result {
150- font-size : 13px ;
151- }
152-
153- # error {
154- color : red;
155- margin : 10px 0 ;
156- }
157- </ style >
158- </ head >
15912< body onload ="load() ">
16013 < div class ="edit ">
161- < div class ="edit-title "> Edit</ div >
162- < textarea id ="stubInput " onkeyup ="handleChangeStubInput() "> </ textarea >
14+ < div class ="edit-title "> Edit stub </ div >
15+ < textarea id ="stubInput " onkeyup ="handleChangeStubInput() " spellcheck =" false " > </ textarea >
16316 < button id ="save " onclick ="save() " disabled > Saved</ button >
16417 </ div >
18+
16519 < div class ="preview ">
16620 < div class ="preview-title "> Preview</ div >
16721 < select id ="language " onchange ="refreshStub() ">
19852 </ div >
19953
20054 < script src ="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/components/prism-core.js "> </ script >
201- < script src ="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/plugins/autoloader/prism-autoloader.js " data-autoloader-path ="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/components/ "> </ script >
55+ < script src ="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/plugins/autoloader/prism-autoloader.js "
56+ data-autoloader-path ="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/components/ "> </ script >
20257</ body >
58+
20359</ html >
0 commit comments