@@ -20,8 +20,25 @@ document.addEventListener('DOMContentLoaded', function () {
2020 const usageExamplesContainer = document . querySelector ( '.code-examples' ) ;
2121 const initialUsageHTML = usageExamplesContainer ? usageExamplesContainer . innerHTML : '' ;
2222
23- // API key input (optional)
23+ // API key inputs (optional)
2424 const apiKeyInput = document . getElementById ( 'api-key-input' ) ;
25+ const apiKeyInputMobile = document . getElementById ( 'api-key-input-mobile' ) ;
26+
27+ // Helper to get the API key value. Prefer mobile input if visible.
28+ function getApiKey ( ) {
29+ try {
30+ if ( apiKeyInputMobile ) {
31+ // Check if mobile input is visible
32+ const style = window . getComputedStyle ( apiKeyInputMobile ) ;
33+ if ( style && style . display !== 'none' ) {
34+ return apiKeyInputMobile . value . trim ( ) ;
35+ }
36+ }
37+ } catch ( e ) {
38+ // ignore
39+ }
40+ return apiKeyInput ? apiKeyInput . value . trim ( ) : '' ;
41+ }
2542
2643 // Text upload
2744 uploadTextBtn . addEventListener ( 'click' , function ( ) {
@@ -41,10 +58,8 @@ document.addEventListener('DOMContentLoaded', function () {
4158 'Content-Type' : 'text/plain' ,
4259 'Accept' : 'application/json' ,
4360 } ;
44- const key = apiKeyInput ? apiKeyInput . value . trim ( ) : '' ;
45- if ( key ) {
46- headers [ 'Authorization' ] = 'Bearer ' + key ;
47- }
61+ const key = getApiKey ( ) ;
62+ if ( key ) headers [ 'Authorization' ] = 'Bearer ' + key ;
4863
4964 fetch ( endpoint , {
5065 method : 'POST' ,
@@ -123,7 +138,7 @@ document.addEventListener('DOMContentLoaded', function () {
123138 uploadFileBtn . textContent = 'Uploading...' ;
124139
125140 const headers = { 'Accept' : 'application/json' } ;
126- const key = apiKeyInput ? apiKeyInput . value . trim ( ) : '' ;
141+ const key = getApiKey ( ) ;
127142 if ( key ) headers [ 'Authorization' ] = 'Bearer ' + key ;
128143
129144 fetch ( endpoint , {
@@ -206,48 +221,9 @@ document.addEventListener('DOMContentLoaded', function () {
206221 // Always reload the main page to ensure a pristine, server-rendered state
207222 event . preventDefault ( ) ;
208223 window . location . assign ( '/' ) ;
209- return ;
210-
211- // Legacy fallback (kept for reference, unreachable due to return above)
212- // Hide result section
213- resultSection . style . display = 'none' ;
214-
215- // Show upload section again
216- const uploadSection = document . querySelector ( '.upload-section' ) ;
217- if ( uploadSection ) {
218- uploadSection . style . display = 'block' ;
219- }
220-
221- // Reset all form fields
222- textContent . value = '' ;
223- fileInput . value = '' ;
224- burnTextCheckbox . checked = false ;
225- burnFileCheckbox . checked = false ;
226-
227- // Remove any file selection
228- if ( fileInput ) {
229- fileInput . value = '' ;
230- }
231-
232- // Restore original usage examples exactly as initial render
233- if ( usageExamplesContainer ) {
234- usageExamplesContainer . innerHTML = initialUsageHTML ;
235- }
236-
237- // Show all usage examples (in case any were hidden)
238- const examples = document . querySelectorAll ( '.example' ) ;
239- examples . forEach ( e => e . style . display = 'block' ) ;
240-
241- // Show the usage section if it was hidden
242- if ( usageSection ) usageSection . style . display = 'block' ;
243-
244- // Scroll to top for a clean experience
245- window . scrollTo ( { top : 0 , behavior : 'smooth' } ) ;
246-
247- // Focus on the text area
248- textContent . focus ( ) ;
249224 } ) ;
250225
226+
251227 // Update usage examples to show how to read the created paste
252228 function updateUsageExamples ( url , slug ) {
253229 const baseUrl = url . replace ( '/' + slug , '' ) ;
@@ -269,9 +245,6 @@ document.addEventListener('DOMContentLoaded', function () {
269245 }
270246 }
271247
272- // Restore original usage examples for new paste
273- function restoreOriginalUsageExamples ( ) { /* no-op: handled by initialUsageHTML restore */ }
274-
275248 // Keyboard shortcuts
276249 document . addEventListener ( 'keydown' , function ( e ) {
277250 // Ctrl+Enter to upload text
0 commit comments