@@ -46,29 +46,33 @@ <h1 class="text-3xl font-semibold mb-2">Bash Script Tools</h1>
4646 <!-- Action Buttons -->
4747 < div class ="flex gap-3 ">
4848 < button
49+ id ="format-btn "
4950 onclick ="formatCode() "
50- class ="inline-flex items-center px-4 py-2 bg-zinc-900 text-zinc-100 rounded-md hover:bg-zinc-800 focus:outline-none focus:ring-2 focus:ring-zinc-700 transition-colors font-medium text-sm border border-zinc-800 "
51+ class ="inline-flex items-center px-4 py-2 bg-zinc-900 text-zinc-100 rounded-md hover:bg-zinc-800 focus:outline-none focus:ring-2 focus:ring-zinc-700 transition-colors font-medium text-sm border border-zinc-800 disabled:opacity-50 disabled:cursor-not-allowed "
5152 >
5253 < span > Format</ span >
5354 </ button >
5455
5556 < button
57+ id ="lint-btn "
5658 onclick ="checkCode() "
57- class ="inline-flex items-center px-4 py-2 bg-zinc-900 text-zinc-100 rounded-md hover:bg-zinc-800 focus:outline-none focus:ring-2 focus:ring-zinc-700 transition-colors font-medium text-sm border border-zinc-800 "
59+ class ="inline-flex items-center px-4 py-2 bg-zinc-900 text-zinc-100 rounded-md hover:bg-zinc-800 focus:outline-none focus:ring-2 focus:ring-zinc-700 transition-colors font-medium text-sm border border-zinc-800 disabled:opacity-50 disabled:cursor-not-allowed "
5860 >
5961 < span > Lint</ span >
6062 </ button >
6163
6264 < button
65+ id ="autofix-btn "
6366 onclick ="autofixCode() "
64- class ="inline-flex items-center px-4 py-2 bg-zinc-900 text-zinc-100 rounded-md hover:bg-zinc-800 focus:outline-none focus:ring-2 focus:ring-zinc-700 transition-colors font-medium text-sm border border-zinc-800 "
67+ class ="inline-flex items-center px-4 py-2 bg-zinc-900 text-zinc-100 rounded-md hover:bg-zinc-800 focus:outline-none focus:ring-2 focus:ring-zinc-700 transition-colors font-medium text-sm border border-zinc-800 disabled:opacity-50 disabled:cursor-not-allowed "
6568 >
6669 < span > Autofix</ span >
6770 </ button >
6871
6972 < button
73+ id ="autofix-ai-btn "
7074 onclick ="autofixAICode() "
71- class ="inline-flex items-center px-4 py-2 bg-zinc-900 text-zinc-100 rounded-md hover:bg-zinc-800 focus:outline-none focus:ring-2 focus:ring-zinc-700 transition-colors font-medium text-sm border border-zinc-800 "
75+ class ="inline-flex items-center px-4 py-2 bg-zinc-900 text-zinc-100 rounded-md hover:bg-zinc-800 focus:outline-none focus:ring-2 focus:ring-zinc-700 transition-colors font-medium text-sm border border-zinc-800 disabled:opacity-50 disabled:cursor-not-allowed "
7276 >
7377 < span > Autofix (AI)</ span >
7478 </ button >
@@ -101,8 +105,16 @@ <h1 class="text-3xl font-semibold mb-2">Bash Script Tools</h1>
101105 highlightGutterLine : true ,
102106 } ) ;
103107
108+ function setButtonsDisabled ( disabled ) {
109+ document . getElementById ( "format-btn" ) . disabled = disabled ;
110+ document . getElementById ( "lint-btn" ) . disabled = disabled ;
111+ document . getElementById ( "autofix-btn" ) . disabled = disabled ;
112+ document . getElementById ( "autofix-ai-btn" ) . disabled = disabled ;
113+ }
114+
104115 async function formatCode ( ) {
105116 const code = editor . getValue ( ) ;
117+ setButtonsDisabled ( true ) ;
106118
107119 try {
108120 const response = await fetch ( "/format" , {
@@ -117,6 +129,8 @@ <h1 class="text-3xl font-semibold mb-2">Bash Script Tools</h1>
117129 editor . moveCursorToPosition ( cursor ) ;
118130 } catch ( error ) {
119131 console . error ( "Format error:" , error ) ;
132+ } finally {
133+ setButtonsDisabled ( false ) ;
120134 }
121135 }
122136
@@ -128,6 +142,7 @@ <h1 class="text-3xl font-semibold mb-2">Bash Script Tools</h1>
128142 async function checkCode ( ) {
129143 const code = editor . getValue ( ) ;
130144 editor . session . clearAnnotations ( ) ;
145+ setButtonsDisabled ( true ) ;
131146
132147 try {
133148 const response = await fetch ( "/shellcheck" , {
@@ -158,11 +173,14 @@ <h1 class="text-3xl font-semibold mb-2">Bash Script Tools</h1>
158173 console . error ( "Shellcheck error:" , error ) ;
159174 document . getElementById ( "output-box" ) . innerHTML =
160175 '<div class="text-xs text-red-600 font-mono">Error running ShellCheck</div>' ;
176+ } finally {
177+ setButtonsDisabled ( false ) ;
161178 }
162179 }
163180
164181 async function autofixCode ( ) {
165182 const code = editor . getValue ( ) ;
183+ setButtonsDisabled ( true ) ;
166184
167185 try {
168186 const response = await fetch ( "/autofix" , {
@@ -180,11 +198,13 @@ <h1 class="text-3xl font-semibold mb-2">Bash Script Tools</h1>
180198 await checkCode ( ) ;
181199 } catch ( error ) {
182200 console . error ( "Autofix error:" , error ) ;
201+ setButtonsDisabled ( false ) ;
183202 }
184203 }
185204
186205 async function autofixAICode ( ) {
187206 const code = editor . getValue ( ) ;
207+ setButtonsDisabled ( true ) ;
188208
189209 try {
190210 const response = await fetch ( "/autofix-ai" , {
@@ -195,6 +215,7 @@ <h1 class="text-3xl font-semibold mb-2">Bash Script Tools</h1>
195215
196216 if ( ! response . ok ) {
197217 console . error ( "AI Autofix error:" , response . status ) ;
218+ setButtonsDisabled ( false ) ;
198219 return ;
199220 }
200221
@@ -207,6 +228,7 @@ <h1 class="text-3xl font-semibold mb-2">Bash Script Tools</h1>
207228 await checkCode ( ) ;
208229 } catch ( error ) {
209230 console . error ( "AI Autofix error:" , error ) ;
231+ setButtonsDisabled ( false ) ;
210232 }
211233 }
212234 </ script >
0 commit comments