Spaces:
Sleeping
Sleeping
File size: 2,614 Bytes
9f3217a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | const fs = require('fs');
let code = fs.readFileSync('public/index.html', 'utf8');
const modalJsFind = ` window.openVideoModal = function(videoId, title, batch, subject) {
if (!videoId) return;
currentModalEmbedLink = \`https://www.youtube.com/embed/\${videoId}\`;
modalIframe.src = \`https://www.youtube.com/embed/\${videoId}?autoplay=1\`;
modalVideoTitle.textContent = title;
modalBatchTag.textContent = batch || 'Batch';
modalSubjectTag.textContent = subject || 'Subject';
modalYtLink.href = \`https://www.youtube.com/watch?v=\${videoId}\`;
videoModal.classList.remove('hidden');
};`;
const modalJsReplace = ` window.openVideoModal = function(videoId, title, batch, subject, processingMode) {
if (!videoId) return;
const isDrive = processingMode === 'drive_secure';
currentModalEmbedLink = isDrive
? \`https://drive.google.com/file/d/\${videoId}/preview\`
: \`https://www.youtube.com/embed/\${videoId}\`;
modalIframe.src = isDrive
? \`https://drive.google.com/file/d/\${videoId}/preview\`
: \`https://www.youtube.com/embed/\${videoId}?autoplay=1\`;
modalVideoTitle.textContent = title;
modalBatchTag.textContent = batch || 'Batch';
modalSubjectTag.textContent = subject || 'Subject';
if (isDrive) {
modalYtLink.href = \`https://drive.google.com/file/d/\${videoId}/view\`;
modalYtLink.textContent = 'Open in Drive ↗';
} else {
modalYtLink.href = \`https://www.youtube.com/watch?v=\${videoId}\`;
modalYtLink.textContent = 'Open Watch URL ↗';
}
videoModal.classList.remove('hidden');
};`;
code = code.replace(modalJsFind, modalJsReplace);
const buttonFind = `<button onclick="openVideoModal('\${file.videoId}', '\${escapeHtml(displayTitle)}', '\${escapeHtml(file.batch)}', '\${escapeHtml(file.subject)}')" class="relative group w-16 h-10 rounded border border-slate-200 overflow-hidden shadow-2xs flex-shrink-0 bg-slate-900 cursor-pointer" title="Click to preview lecture">`;
const buttonReplace = `<button onclick="openVideoModal('\${file.videoId}', '\${escapeHtml(displayTitle)}', '\${escapeHtml(file.batch)}', '\${escapeHtml(file.subject)}', '\${currentState.processingMode}')" class="relative group w-16 h-10 rounded border border-slate-200 overflow-hidden shadow-2xs flex-shrink-0 bg-slate-900 cursor-pointer" title="Click to preview lecture">`;
code = code.replaceAll(buttonFind, buttonReplace);
fs.writeFileSync('public/index.html', code);
console.log('patched');
|