Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
18 changes: 16 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ <h1 class="mb-3 h3" data-i18n="app.title">eXeViewer</h1>
<div class="drop-zone-content">
<i class="bi bi-cloud-arrow-up drop-icon" aria-hidden="true"></i>
<p class="drop-text mb-2" data-i18n="welcome.dragDrop">
Drag and drop your <strong>.zip</strong> or <strong>.elpx</strong> file here
Drag and drop your <strong>.zip</strong>, <strong>.elpx</strong> or <strong>.elp</strong> file here
</p>
<p class="text-muted small mb-3" data-i18n="welcome.or">or</p>
<label class="btn btn-primary">
<i class="bi bi-folder2-open me-2" aria-hidden="true"></i>
<span data-i18n="welcome.browseFiles">Browse Files</span>
<input type="file" id="fileInput" accept=".zip,.elpx" hidden>
<input type="file" id="fileInput" accept=".zip,.elpx,.elp" hidden>
</label>
</div>
</div>
Expand Down Expand Up @@ -234,9 +234,23 @@ <h5 class="modal-title" id="shareModalLabel" data-i18n="share.modalTitle">Share
<!-- Bootstrap JS -->
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

<!-- Legacy .elp support -->
<script>
// Polyfill for Node.js process (required by importers.bundle.js)
if (typeof process === 'undefined') {
window.process = { env: {} };
}
</script>
<script src="vendor/yjs/yjs.min.js"></script>
<script src="vendor/exelearning/importers.bundle.js"></script>
<script src="vendor/exelearning/exporters.bundle.js"></script>

<!-- Internationalization Module -->
<script src="js/i18n.js"></script>

<!-- ELP Converter Module -->
<script src="js/elp-converter.js"></script>

<!-- Main Application Script -->
<script src="js/app.js"></script>

Expand Down
66 changes: 64 additions & 2 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@
const urlObj = new URL(url);
const pathname = urlObj.pathname;
const filename = pathname.split('/').pop();
if (filename && (filename.endsWith('.zip') || filename.endsWith('.elpx'))) {
if (filename && (filename.endsWith('.zip') || filename.endsWith('.elpx') || filename.endsWith('.elp'))) {
return decodeURIComponent(filename);
}
} catch (e) {
Expand Down Expand Up @@ -712,7 +712,7 @@

// Validate file extension or content type
const lowerFilename = filename.toLowerCase();
if (!lowerFilename.endsWith('.zip') && !lowerFilename.endsWith('.elpx') && !isValidType) {
if (!lowerFilename.endsWith('.zip') && !lowerFilename.endsWith('.elpx') && !lowerFilename.endsWith('.elp') && !isValidType) {
throw new Error(i18n.t('errors.invalidFileType'));
}

Expand Down Expand Up @@ -784,13 +784,75 @@
}
}

/**
* Process legacy .elp file using ElpConverter
* @param {File} file - The .elp file to process
*/
async function processLegacyElp(file) {
if (!window.ElpConverter || !window.ElpConverter.isSupported()) {
showError('errors.legacyNotSupported');
return;
}

try {
hideError();
showLoading(i18n.t('loading.convertingLegacy'));

// Ensure Service Worker is ready
if (!state.serviceWorkerReady) {
updateLoadingText(i18n.t('loading.registeringSW'));
await registerServiceWorker();
}

// Clear any previous content
await clearServiceWorkerContent();

const result = await window.ElpConverter.convert(file, (phase, percent) => {
if (phase === 'generating') {
updateLoadingText(i18n.t('loading.generatingHtml'));
}
});

if (!result.success) {
console.error('[App] ELP conversion failed:', result.error);
showError('errors.legacyConversionFailed');
hideLoading();
return;
}

updateLoadingText(i18n.t('loading.loadingContent'));

// Send to Service Worker (existing flow)
await sendContentToServiceWorker(result.files);

state.currentPackageName = file.name;

// Small delay to ensure SW is ready to serve
await new Promise(resolve => setTimeout(resolve, 200));

showViewer();

} catch (error) {
console.error('[App] Error processing legacy ELP:', error);
showError('errors.legacyConversionFailed');
hideLoading();
}
}

/**
* Process the selected file
* @param {File} file - The file to process
*/
async function processFile(file) {
// Validate file type
const fileName = file.name.toLowerCase();

// Check for legacy .elp files
if (fileName.endsWith('.elp')) {
await processLegacyElp(file);
return;
}

if (!fileName.endsWith('.zip') && !fileName.endsWith('.elpx')) {
showError('errors.invalidFile');
return;
Expand Down
Loading