Luigi commited on
Commit
2f0cf23
·
1 Parent(s): a639fb7

Complete JavaScript initialization fix

Browse files

- Add missing backend selector initialization
- Add podcast list initialization calls
- Ensure complete app startup sequence matches original init() function
- All event listeners and UI components now properly initialize

Files changed (1) hide show
  1. frontend/app.js +69 -2
frontend/app.js CHANGED
@@ -847,7 +847,74 @@ async function downloadEpisode(audioUrl, title, triggerButton = null) {
847
  console.error(err);
848
  setStatus(err.message, 'error');
849
  } finally {
850
- triggerButton.classList.remove('loading');
851
- triggerButton.textContent = 'Download';
 
 
852
  }
853
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
847
  console.error(err);
848
  setStatus(err.message, 'error');
849
  } finally {
850
+ if (triggerButton) {
851
+ triggerButton.classList.remove('loading');
852
+ triggerButton.textContent = originalLabel || 'Download';
853
+ }
854
  }
855
  }
856
+
857
+ // Initialize the application
858
+ document.addEventListener('DOMContentLoaded', async () => {
859
+ // Initialize tabs
860
+ initTabs();
861
+
862
+ // Initialize sidebar interactions
863
+ initSidebarInteractions();
864
+
865
+ // Initialize audio interactions
866
+ initAudioInteractions();
867
+
868
+ // Load configuration
869
+ await fetchConfig();
870
+
871
+ // Initialize backend selector
872
+ elements.backendSelect.innerHTML = `
873
+ <option value="moonshine">Moonshine</option>
874
+ <option value="sensevoice" selected>SenseVoice</option>
875
+ `;
876
+ state.backend = elements.backendSelect.value;
877
+
878
+ // Initialize podcast lists
879
+ setListEmpty(elements.podcastResults, 'Search to discover podcasts.');
880
+ setListEmpty(elements.episodeResults, 'Select a podcast to view episodes.');
881
+
882
+ // Set up podcast interactions
883
+ elements.podcastResults.addEventListener('click', (event) => {
884
+ const button = event.target.closest('button[data-feed]');
885
+ if (button) {
886
+ const feedUrl = button.dataset.feed;
887
+ const sourceItem = button.closest('.list-item');
888
+ loadEpisodes(feedUrl, sourceItem);
889
+ }
890
+ });
891
+
892
+ elements.episodeResults.addEventListener('click', (event) => {
893
+ const button = event.target.closest('button[data-url]');
894
+ if (button) {
895
+ const audioUrl = button.dataset.url;
896
+ const title = button.dataset.title;
897
+ downloadEpisode(audioUrl, title, button);
898
+ }
899
+ });
900
+
901
+ elements.podcastQuery.addEventListener('keydown', (event) => {
902
+ if (event.key === 'Enter') {
903
+ event.preventDefault();
904
+ handlePodcastSearch();
905
+ }
906
+ });
907
+
908
+ // Set up other event listeners
909
+ elements.transcribeBtn.addEventListener('click', handleTranscription);
910
+ elements.summaryBtn.addEventListener('click', handleSummaryGeneration);
911
+ elements.detectSpeakerNamesBtn.addEventListener('click', handleSpeakerNameDetection);
912
+ elements.exportTranscriptBtn.addEventListener('click', handleExportTranscript);
913
+ elements.exportSummaryBtn.addEventListener('click', handleExportSummary);
914
+ elements.fileInput.addEventListener('change', handleFileUpload);
915
+ elements.youtubeFetch.addEventListener('click', handleYoutubeFetch);
916
+ elements.podcastSearch.addEventListener('click', handlePodcastSearch);
917
+
918
+ // Set initial status
919
+ setStatus('Ready', 'info');
920
+ });