Skip to content

Commit dd77bad

Browse files
authored
Update main.js
Removed welcome menu
1 parent a862731 commit dd77bad

1 file changed

Lines changed: 4 additions & 124 deletions

File tree

src/main.js

Lines changed: 4 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
/* ====================================================================
77
TABLE OF CONTENTS
88
9-
FETCH HELPER
10-
LOAD PASSAGE
119
DATE / TIME
1210
ERROR HANDLING
1311
EVENT LISTENERS
@@ -17,7 +15,6 @@
1715
INITIALIZATION
1816
START THE APP
1917
THEMING
20-
WELCOME SCREEN HANDLERS
2118
==================================================================== */
2219

2320

@@ -164,16 +161,6 @@ export function handleError(error, context) {
164161

165162
/* Setup all event listeners for the application */
166163
function setupEventListeners() {
167-
// Welcome Screen
168-
document.getElementById('getStartedBtn')
169-
.addEventListener('click', completeWelcome);
170-
document.getElementById('welcomePdfUploadArea')
171-
.addEventListener('click', () => {
172-
document.getElementById('welcomePdfUpload').click();
173-
});
174-
document.getElementById('welcomePdfUpload')
175-
.addEventListener('change', handleWelcomePDFUpload);
176-
177164
// Theme Toggle
178165
document.querySelector('.theme-toggle')
179166
.addEventListener('click', toggleTheme);
@@ -692,104 +679,6 @@ export function applyColorTheme() {
692679
}
693680

694681

695-
/* ====================================================================
696-
WELCOME SCREEN HANDLERS
697-
First-time user onboarding with optional PDF upload
698-
==================================================================== */
699-
700-
/* Handle PDF file selection on welcome screen */
701-
async function handleWelcomePDFUpload(ev) {
702-
try {
703-
const file = ev.target.files[0];
704-
if (!file) return;
705-
706-
if (file.size > 50 * 1024 * 1024) {
707-
alert('PDF file is too large (max 50 MiB).');
708-
ev.target.value = '';
709-
return;
710-
}
711-
712-
state.welcomePdfFile = file;
713-
document.getElementById('welcomePdfUploadArea').classList.add('has-file');
714-
document.getElementById('welcomeUploadText').innerHTML = `
715-
<strong>${file.name}</strong><br>
716-
<small>Ready to use for offline mode</small>`;
717-
} catch (err) {
718-
handleError(err, 'handleWelcomePDFUpload');
719-
}
720-
}
721-
722-
/* Complete welcome flow and initialize main app */
723-
async function completeWelcome() {
724-
showLoading(true);
725-
726-
try {
727-
if (state.welcomePdfFile) {
728-
const reader = new FileReader();
729-
const arrayBuffer = await new Promise((resolve, reject) => {
730-
reader.onload = (e) => resolve(e.target.result);
731-
reader.onerror = (e) => reject(new Error('Failed to read file'));
732-
reader.readAsArrayBuffer(state.welcomePdfFile);
733-
});
734-
735-
const bufferCopy = arrayBuffer.slice(0);
736-
const loadingTask = pdfjsLib.getDocument({ data: bufferCopy });
737-
const pdf = await loadingTask.promise;
738-
const base64 = arrayBufferToBase64(arrayBuffer);
739-
const pdfData = {
740-
name: state.welcomePdfFile.name,
741-
data: base64,
742-
uploadDate: new Date().toISOString(),
743-
numPages: pdf.numPages
744-
};
745-
746-
await savePDFToIndexedDB(pdfData);
747-
748-
state.settings.customPdf = {
749-
name: pdfData.name,
750-
uploadDate: pdfData.uploadDate,
751-
numPages: pdfData.numPages,
752-
storedInDB: true
753-
};
754-
}
755-
756-
state.settings.hasSeenWelcome = true;
757-
saveToStorage();
758-
saveToCookies();
759-
760-
document.getElementById('welcomeScreen').classList.add('hidden');
761-
await init();
762-
763-
} catch (err) {
764-
handleError(err, 'completeWelcome');
765-
alert('Error processing PDF: ' + err.message +
766-
'. You can continue without offline mode.');
767-
state.settings.hasSeenWelcome = true;
768-
saveToStorage();
769-
saveToCookies();
770-
document.getElementById('welcomeScreen').classList.add('hidden');
771-
await init();
772-
} finally {
773-
showLoading(false);
774-
}
775-
}
776-
777-
/**
778-
* HELPER: ATTACH WELCOME LISTENERS
779-
* Set up event listeners for welcome screen (used for early exit)
780-
*/
781-
function attachWelcomeListeners() {
782-
document.getElementById('getStartedBtn')
783-
.addEventListener('click', completeWelcome);
784-
document.getElementById('welcomePdfUploadArea')
785-
.addEventListener('click', () => {
786-
document.getElementById('welcomePdfUpload').click();
787-
});
788-
document.getElementById('welcomePdfUpload')
789-
.addEventListener('change', handleWelcomePDFUpload);
790-
}
791-
792-
793682
/* ====================================================================
794683
INITIALIZATION
795684
Application startup sequence
@@ -816,24 +705,15 @@ async function init() {
816705
window.addEventListener('online', () => updateOfflineStatus(false));
817706
window.addEventListener('offline', () => updateOfflineStatus(true));
818707

819-
// Guard defaults for other settings (if they were never saved)
708+
// Guard defaults for other settings
820709
if (!state.settings.readingMode) state.settings.readingMode = 'readingPlan';
821710
if (!state.settings.readingPlanId) state.settings.readingPlanId = 'default';
822711

823-
// Initialize manual navigation (book/chapter dropdowns)
712+
// Initialize manual navigation
824713
initBookChapterControls();
825714

826-
// Restore the book/chapter UI to the saved values
827-
restoreBookChapterUI(); // also loads the passage
828-
829-
// Check welcome screen
830-
if (!state.settings.hasSeenWelcome) {
831-
attachWelcomeListeners();
832-
return;
833-
}
834-
835-
// Hide welcome screen
836-
document.getElementById('welcomeScreen').classList.add('hidden');
715+
// Restore the book/chapter UI
716+
restoreBookChapterUI();
837717

838718
// Apply theme
839719
applyTheme();

0 commit comments

Comments
 (0)