Home / index.html
Examups's picture
Update index.html
28d0ad3 verified
Raw History Blame Contribute Delete
141 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Advanced Component Builder</title> <script src="https://cdn.tailwindcss.com"></script> <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=Open+Sans:wght@400;700&family=Lato:wght@400;700&family=Montserrat:wght@400;700&family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.0/FileSaver.min.js"></script> <style> :root { --primary-color: #3b82f6; --primary-hover-color: #2563eb; --secondary-color: #10b981; --secondary-hover-color: #059669; --text-color: #374151; --heading-color: #111827; --font-family: 'Inter', sans-serif; } body { font-family: var(--font-family); color: var(--text-color); background-color: var(--background-color); } h1, h2, h3, h4, h5, h6 { color: var(--heading-color); } /* Custom scrollbar for webkit browsers */ ::-webkit-scrollbar { width: 8px; height: 8px; } ::-webkit-scrollbar-track { background: #f1f1f1; } ::-webkit-scrollbar-thumb { background: #888; border-radius: 10px; } ::-webkit-scrollbar-thumb:hover { background: #555; } .preview-iframe { width: 100%; height: 100%; border: 0; transition: all 0.3s ease-in-out; } #preview-container.preview-desktop .preview-iframe { width: 100%; } #preview-container.preview-tablet .preview-iframe { width: 768px; margin: 0 auto; } #preview-container.preview-mobile .preview-iframe { width: 375px; margin: 0 auto; } .toast { visibility: hidden; min-width: 250px; background-color: #333; color: #fff; text-align: center; border-radius: 8px; padding: 16px; position: fixed; z-index: 100; left: 50%; bottom: 30px; transform: translateX(-50%); opacity: 0; transition: opacity 0.3s, visibility 0.3s; } .toast.show { visibility: visible; opacity: 1; } /* New Professional Controls UI Styles */ #controls-layout { display: flex; height: 100%; } #controls-nav { width: 180px; flex-shrink: 0; background-color: #f8fafc; border-right: 1px solid #e5e7eb; padding: 0.5rem; overflow-y: auto; } .control-nav-button { display: flex; align-items: center; width: 100%; padding: 0.75rem; border-radius: 0.375rem; font-weight: 500; color: var(--text-color); transition: background-color 0.2s, color 0.2s; text-align: left; } .control-nav-button:hover { background-color: #e5e7eb; } .control-nav-button.active { background-color: var(--primary-color); color: white; box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06); } .control-nav-button i { margin-right: 0.75rem; width: 20px; text-align: center; } #controls-panels { flex-grow: 1; padding: 1.5rem; overflow-y: auto; } .control-panel { display: none; } .control-panel.active { display: block; } .control-panel h3 { font-size: 1.25rem; font-weight: 600; margin-bottom: 1.5rem; border-bottom: 1px solid #e5e7eb; padding-bottom: 0.75rem; } .nested-builder { margin-left: 1rem; padding-left: 1rem; border-left: 2px solid #e5e7eb; margin-top: 1rem; padding-top: 1rem; } .item-toolbar { display: flex; justify-content: flex-end; gap: 0.25rem; margin-bottom: 0.5rem; } .layout-item { cursor: move; } .code-modal-pre { background-color: #2d3748; color: #e2e8f0; padding: 1rem; border-radius: 0.375rem; max-height: 200px; overflow-y: auto; position: relative; } /* Feature: Hide/Show Sidebar */ #controls-sidebar { flex-shrink: 0; } #main-container.sidebar-collapsed #controls-sidebar { width: 0; padding: 0; overflow: hidden; } #main-container.sidebar-collapsed #preview-main { width: 100%; } </style> </head> <body class="text-gray-800"> <div id="app" class="flex flex-col h-screen"> <header class="bg-white shadow-md p-4 flex justify-between items-center z-20"> <div class="flex items-center space-x-3"> <h1 class="text-xl font-bold text-gray-700">Component Builder</h1> <button id="toggle-sidebar-btn" class="p-2 rounded-md hover:bg-gray-200 text-gray-600" title="Hide Controls"> <i class="fas fa-chevron-left"></i> </button> </div> <div class="flex items-center space-x-4"> <button id="import-btn" class="flex items-center space-x-2 bg-blue-600 text-white font-bold py-2 px-4 rounded-md hover:bg-blue-700 transition"> <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor"> <path d="M10 2a1 1 0 00-1 1v5.586l-1.293-1.293a1 1 0 00-1.414 1.414l3 3a1 1 0 001.414 0l3-3a1 1 0 00-1.414-1.414L11 8.586V3a1 1 0 00-1-1z"></path> <path d="M4 14a1 1 0 011 1v1a1 1 0 001 1h8a1 1 0 001-1v-1a1 1 0 112 0v1a3 3 0 01-3 3H6a3 3 0 01-3-3v-1a1 1 0 011-1z"></path> </svg> <span>Import</span> </button> <input type="file" id="import-file-input" class="hidden" accept=".html"> <div id="export-menu-container" class="relative"> <button id="export-menu-btn" class="flex items-center space-x-2 bg-green-600 text-white font-bold py-2 px-4 rounded-md hover:bg-green-700 transition"> <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM6.293 6.707a1 1 0 010-1.414l3-3a1 1 0 011.414 0l3 3a1 1 0 01-1.414 1.414L11 5.414V13a1 1 0 11-2 0V5.414L7.707 6.707a1 1 0 01-1.414 0z" clip-rule="evenodd"></path></svg> <span>Export Page</span> </button> <div id="export-dropdown" class="hidden absolute right-0 mt-2 w-64 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 z-30"> <div class="py-1" role="menu" aria-orientation="vertical" aria-labelledby="export-menu-btn"> <a href="#" id="copy-combined-code" class="flex items-center px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" role="menuitem"> <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-3 text-gray-500" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"></path></svg> <span>Copy Combined Code</span> </a> <a href="#" id="copy-html" class="flex items-center px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" role="menuitem"> <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-3 text-gray-500" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path d="M5 5a2 2 0 012-2h10a2 2 0 012 2v1h-14V5zM3 8h18v10a2 2 0 01-2 2H5a2 2 0 01-2-2V8z"></path></svg> <span>Copy Page HTML</span> </a> <a href="#" id="copy-css" class="flex items-center px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" role="menuitem"> <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-3 text-gray-500" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21a4 4 0 01-4-4V5a2 2 0 012-2h4a2 2 0 012 2v12a4 4 0 01-4 4zm0 0h12a2 2 0 002-2v-4a2 2 0 00-2-2h-2.343M11 7.343l1.657-1.657a2 2 0 012.828 0l2.829 2.829a2 2 0 010 2.828l-8.486 8.485M7 17h.01"></path></svg> <span>Copy Page CSS</span> </a> <a href="#" id="copy-js" class="flex items-center px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" role="menuitem"> <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-3 text-gray-500" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M10 2a1 1 0 011 1v1h1a1 1 0 010 2h-1v1a1 1 0 01-2 0V6H8a1 1 0 010-2h1V3a1 1 0 011-1zM5 5a3 3 0 013-3h4a3 3 0 013 3v1h-1V5a2 2 0 00-2-2H8a2 2 0 00-2 2v1H5V5zm2 5a1 1 0 011-1h4a1 1 0 110 2H8a1 1 0 01-1-1zm-1 4a1 1 0 100 2h8a1 1 0 100-2H6z" clip-rule="evenodd" /></svg> <span>Copy Page JS</span> </a> <div class="border-t border-gray-100"></div> <a href="#" id="download-zip-btn" class="flex items-center px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" role="menuitem"> <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-3 text-gray-500" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M4 2a2 2 0 00-2 2v12a2 2 0 002 2h12a2 2 0 002-2V4a2 2 0 00-2-2H4zm1 3a1 1 0 000 2h10a1 1 0 100-2H5zM5 13a1 1 0 100 2h10a1 1 0 100-2H5z" clip-rule="evenodd"></path></svg> <span>Download Page .zip</span> </a> </div> </div> </div> <div class="flex items-center space-x-2"> <span class="text-sm font-medium text-gray-500">Preview:</span> <button id="desktop-btn" class="p-2 rounded-md bg-blue-500 text-white shadow" title="Desktop View"> <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M10 2a2 2 0 00-2 2v1H6a2 2 0 00-2 2v7a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2V4a2 2 0 00-2-2zm-1 3V4a1 1 0 112 0v1h-2zM6 7v7h8V7H6z" clip-rule="evenodd"></path></svg> </button> <button id="tablet-btn" class="p-2 rounded-md bg-gray-200 text-gray-700" title="Tablet View"> <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M4 2a2 2 0 00-2 2v12a2 2 0 002 2h12a2 2 0 002-2V4a2 2 0 00-2-2H4zm1 2a1 1 0 00-1 1v10a1 1 0 001 1h10a1 1 0 001-1V5a1 1 0 00-1-1H5z" clip-rule="evenodd"></path></svg> </button> <button id="mobile-btn" class="p-2 rounded-md bg-gray-200 text-gray-700" title="Mobile View"> <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor"><path d="M5 2a2 2 0 00-2 2v12a2 2 0 002 2h6a2 2 0 002-2V4a2 2 0 00-2-2H5z"></path></svg> </button> </div> </div> </header> <div class="flex flex-1 overflow-hidden" id="main-container"> <aside id="controls-sidebar" class="w-1/3 bg-white shadow-lg overflow-hidden transition-all duration-300 ease-in-out"> <div id="controls-layout"> <nav id="controls-nav" class="space-y-2"> <button class="control-nav-button" data-target="#panel-global-settings"><i class="fas fa-cog"></i>Global</button> <button class="control-nav-button" data-target="#panel-layout"><i class="fas fa-layer-group"></i>Layout</button> <button class="control-nav-button" data-target="#panel-top-courses"><i class="fas fa-graduation-cap"></i>Top Courses</button> <button class="control-nav-button" data-target="#panel-popular-exams"><i class="fas fa-list-alt"></i>Popular Exams</button> <button class="control-nav-button" data-target="#panel-popular-test-series"><i class="fas fa-file-alt"></i>Test Series</button> <button class="control-nav-button" data-target="#panel-mcq-topics"><i class="fas fa-list-ul"></i>MCQ Topics</button> <button class="control-nav-button" data-target="#panel-bulk-mcq"><i class="fas fa-question-circle"></i>Bulk MCQ</button> <button class="control-nav-button" data-target="#panel-stats-bar"><i class="fas fa-chart-bar"></i>Stats Bar</button> <button class="control-nav-button" data-target="#panel-features-grid"><i class="fas fa-th-large"></i>Features Grid</button> <button class="control-nav-button" data-target="#panel-custom-html"><i class="fas fa-code"></i>Custom HTML</button> </nav> <div id="controls-panels"> <div id="panel-global-settings" class="control-panel"> <h3>⚙️ Global Settings</h3> <div class="space-y-4"> <div class="space-y-2 border-b pb-4"> <label class="font-medium text-sm">Color Palette</label> <div class="grid grid-cols-2 gap-2 text-xs"> <div> <label for="global-color-primary">Primary</label> <input type="color" id="global-color-primary" class="w-full p-0 h-8 border-none rounded-md"> </div> <div> <label for="global-color-secondary">Secondary</label> <input type="color" id="global-color-secondary" class="w-full p-0 h-8 border-none rounded-md"> </div> <div> <label for="global-color-text">Text</label> <input type="color" id="global-color-text" class="w-full p-0 h-8 border-none rounded-md"> </div> <div> <label for="global-color-heading">Heading</label> <input type="color" id="global-color-heading" class="w-full p-0 h-8 border-none rounded-md"> </div> </div> </div> <div class="space-y-2 border-b pb-4"> <label class="font-medium text-sm">Typography</label> <div> <label for="global-font-family" class="text-xs">Font Family</label> <select id="global-font-family" class="w-full p-1 border rounded-md text-sm"> <option value="'Inter', sans-serif">Inter</option> <option value="'Roboto', sans-serif">Roboto</option> <option value="'Open Sans', sans-serif">Open Sans</option> <option value="'Lato', sans-serif">Lato</option> <option value="'Montserrat', sans-serif">Montserrat</option> <option value="'Poppins', sans-serif">Poppins</option> </select> </div> </div> <button id="apply-global-settings" class="w-full bg-blue-600 text-white font-bold py-2 px-4 rounded-md hover:bg-blue-700 transition">Apply Global Styles</button> </div> </div> <div id="panel-layout" class="control-panel"> <h3>↕️ Component Layout</h3> <p class="text-xs text-gray-500 mb-4">Drag and drop to change the vertical order of the components on your page.</p> <div id="layout-builder-container" class="space-y-2"></div> </div> <div id="panel-top-courses" class="control-panel"> <div class="flex justify-between items-center mb-6"> <h3 class="mb-0 pb-0 border-b-0">🎓 Top Courses</h3> <button class="get-component-code-btn text-sm bg-indigo-500 text-white py-1 px-3 rounded-md hover:bg-indigo-600" data-component-key="topCourses"> <i class="fas fa-code mr-1"></i> Get Code </button> </div> <div class="space-y-4"> <div class="flex items-center space-x-2 border-b pb-4"> <input type="checkbox" id="top-courses-toggle" class="h-4 w-4 rounded"> <label for="top-courses-toggle" class="font-medium">Enable Section</label> </div> <div id="top-courses-builder" class="space-y-4"> <div> <label class="text-sm font-medium">Title</label> <input type="text" id="top-courses-title" class="w-full p-1 border rounded-md mt-1 text-sm"> </div> <div class="border-t pt-4"> <h4 class="text-sm font-semibold mb-2">Category Tabs</h4> <div id="top-courses-tabs-builder" class="space-y-2"></div> <button id="add-course-tab-btn" class="mt-2 text-xs w-full bg-blue-100 text-blue-800 font-semibold py-1 px-2 rounded-md hover:bg-blue-200 transition">Add Tab</button> </div> <div class="border-t pt-4"> <h4 class="text-sm font-semibold mb-2">Course Items</h4> <div id="top-courses-items-builder" class="space-y-3"></div> <button id="add-course-item-btn" class="mt-4 text-sm w-full bg-green-100 text-green-800 font-semibold py-2 px-4 rounded-md hover:bg-green-200 transition"> <i class="fas fa-plus mr-2"></i>Add New Course </button> </div> <div class="border-t pt-4"> <h4 class="text-sm font-semibold mb-2">Explore Button</h4> <div> <label class="text-xs font-medium">Button Text Template</label> <input type="text" id="top-courses-explore-text" class="w-full p-1 border rounded-md mt-1 text-xs" placeholder="Explore {category} Supercoaching"> <p class="text-xs text-gray-500 mt-1">Use `{category}` as a placeholder for the active tab name.</p> </div> <div> <label class="text-xs font-medium">Button Link</label> <input type="text" id="top-courses-explore-link" class="w-full p-1 border rounded-md mt-1 text-xs"> </div> </div> </div> </div> </div> <div id="panel-popular-exams" class="control-panel"> <div class="flex justify-between items-center mb-6"> <h3 class="mb-0 pb-0 border-b-0">🎓 Popular Exams</h3> <button class="get-component-code-btn text-sm bg-indigo-500 text-white py-1 px-3 rounded-md hover:bg-indigo-600" data-component-key="popularExams"> <i class="fas fa-code mr-1"></i> Get Code </button> </div> <div class="space-y-4"> <div class="flex items-center space-x-2 border-b pb-4"> <input type="checkbox" id="popular-exams-toggle" class="h-4 w-4 rounded"> <label for="popular-exams-toggle" class="font-medium">Enable Section</label> </div> <div id="popular-exams-builder" class="space-y-4"> <div> <label class="text-sm font-medium">Title</label> <input type="text" id="popular-exams-title" class="w-full p-1 border rounded-md mt-1 text-sm"> </div> <div> <label class="text-sm font-medium">Subtitle</label> <input type="text" id="popular-exams-subtitle" class="w-full p-1 border rounded-md mt-1 text-sm"> </div> <div class="border-t pt-4"> <h4 class="text-sm font-semibold mb-2">Category Tabs</h4> <div id="popular-exams-tabs-builder" class="space-y-2"></div> <button id="add-exam-tab-btn" class="mt-2 text-xs w-full bg-blue-100 text-blue-800 font-semibold py-1 px-2 rounded-md hover:bg-blue-200 transition">Add Tab</button> </div> <div class="border-t pt-4"> <h4 class="text-sm font-semibold mb-2">Exam Items</h4> <div id="popular-exams-items-builder" class="space-y-3"></div> <button id="add-exam-item-btn" class="mt-4 text-sm w-full bg-green-100 text-green-800 font-semibold py-2 px-4 rounded-md hover:bg-green-200 transition"> <i class="fas fa-plus mr-2"></i>Add New Exam </button> </div> </div> </div> </div> <div id="panel-popular-test-series" class="control-panel"> <div class="flex justify-between items-center mb-6"> <h3 class="mb-0 pb-0 border-b-0">📝 Popular Test Series</h3> <button class="get-component-code-btn text-sm bg-indigo-500 text-white py-1 px-3 rounded-md hover:bg-indigo-600" data-component-key="popularTestSeries"> <i class="fas fa-code mr-1"></i> Get Code </button> </div> <div class="space-y-4"> <div class="flex items-center space-x-2 border-b pb-4"> <input type="checkbox" id="test-series-toggle" class="h-4 w-4 rounded"> <label for="test-series-toggle" class="font-medium">Enable Section</label> </div> <div id="test-series-builder" class="space-y-4"> <div> <label class="text-sm font-medium">Title</label> <input type="text" id="test-series-title" class="w-full p-1 border rounded-md mt-1 text-sm"> </div> <div class="border-t pt-4"> <h4 class="text-sm font-semibold mb-2">Test Series Items</h4> <div id="test-series-items-builder" class="space-y-3"></div> <button id="add-test-series-item-btn" class="mt-4 text-sm w-full bg-green-100 text-green-800 font-semibold py-2 px-4 rounded-md hover:bg-green-200 transition"> <i class="fas fa-plus mr-2"></i>Add New Test Series </button> </div> </div> </div> </div> <div id="panel-mcq-topics" class="control-panel"> <div class="flex justify-between items-center mb-6"> <h3 class="mb-0 pb-0 border-b-0">📚 MCQ Topics</h3> <button class="get-component-code-btn text-sm bg-indigo-500 text-white py-1 px-3 rounded-md hover:bg-indigo-600" data-component-key="mcqTopics"> <i class="fas fa-code mr-1"></i> Get Code </button> </div> <div class="space-y-4"> <div class="flex items-center space-x-2 border-b pb-4"> <input type="checkbox" id="mcq-topics-toggle" class="h-4 w-4 rounded"> <label for="mcq-topics-toggle" class="font-medium">Enable Section</label> </div> <div id="mcq-topics-builder-container" class="space-y-4"> <div> <label class="text-sm font-medium">Title</label> <input type="text" id="mcq-topics-title" class="w-full p-1 border rounded-md mt-1 text-sm"> </div> <div class="border-t pt-4"> <h4 class="text-sm font-semibold mb-2">Topic Items</h4> <div id="mcq-topics-items-builder" class="space-y-3"></div> <button id="add-mcq-topic-item-btn" class="mt-4 text-sm w-full bg-green-100 text-green-800 font-semibold py-2 px-4 rounded-md hover:bg-green-200 transition"> <i class="fas fa-plus mr-2"></i>Add New Topic </button> </div> </div> </div> </div> <div id="panel-bulk-mcq" class="control-panel"> <div class="flex justify-between items-center mb-6"> <h3 class="mb-0 pb-0 border-b-0">🧩 Bulk MCQ Creator</h3> <button class="get-component-code-btn text-sm bg-indigo-500 text-white py-1 px-3 rounded-md hover:bg-indigo-600" data-component-key="bulkMcq"> <i class="fas fa-code mr-1"></i> Get Code </button> </div> <div class="space-y-4"> <div class="flex items-center space-x-2 border-b pb-4"> <input type="checkbox" id="bulk-mcq-toggle" class="h-4 w-4 rounded"> <label for="bulk-mcq-toggle" class="font-medium">Enable Section</label> </div> <div id="bulk-mcq-builder" class="space-y-4"> <div> <label class="text-sm font-medium">Section Title</label> <input type="text" id="bulk-mcq-title" class="w-full p-1 border rounded-md mt-1 text-sm"> </div> <div> <label for="bulk-mcq-content" class="text-sm font-medium">Paste Bulk MCQs Here</label> <p class="text-xs text-gray-500 mb-2">Use `---` to separate questions. Follow the specified format.</p> <textarea id="bulk-mcq-content" rows="15" class="w-full p-2 border rounded-md font-mono text-sm"></textarea> </div> <button id="bulk-mcq-generate-btn" class="w-full bg-green-600 text-white font-bold py-2 px-4 rounded-md hover:bg-green-700 transition">Parse & Generate MCQs</button> </div> </div> </div> <div id="panel-stats-bar" class="control-panel"> <div class="flex justify-between items-center mb-6"> <h3 class="mb-0 pb-0 border-b-0">📊 Stats Bar</h3> <button class="get-component-code-btn text-sm bg-indigo-500 text-white py-1 px-3 rounded-md hover:bg-indigo-600" data-component-key="statsBar"> <i class="fas fa-code mr-1"></i> Get Code </button> </div> <div class="space-y-4"> <div class="flex items-center space-x-2 border-b pb-4"> <input type="checkbox" id="stats-bar-toggle" class="h-4 w-4 rounded"> <label for="stats-bar-toggle" class="font-medium">Enable Stats Bar</label> </div> <div id="stats-bar-builder" class="space-y-4"> <div> <h4 class="text-sm font-semibold mb-2">Styling</h4> <div class="grid grid-cols-2 gap-x-4 gap-y-2 text-xs"> <div> <label for="stats-bar-bg-color">Background</label> <input type="color" id="stats-bar-bg-color" class="w-full p-0 h-8 border-none rounded-md"> </div> <div> <label for="stats-bar-text-color">Label Text</label> <input type="color" id="stats-bar-text-color" class="w-full p-0 h-8 border-none rounded-md"> </div> <div> <label for="stats-bar-value-color">Value Text</label> <input type="color" id="stats-bar-value-color" class="w-full p-0 h-8 border-none rounded-md"> </div> <div> <label for="stats-bar-icon-color">Icon Color</label> <input type="color" id="stats-bar-icon-color" class="w-full p-0 h-8 border-none rounded-md"> </div> </div> </div> <div class="border-t pt-4 mt-4"> <h4 class="text-sm font-semibold mb-2">Stat Items</h4> <div id="stats-bar-items-builder" class="space-y-3"></div> <button id="add-stat-item-btn" class="mt-4 text-sm w-full bg-blue-100 text-blue-800 font-semibold py-2 px-4 rounded-md hover:bg-blue-200 transition"> <i class="fas fa-plus mr-2"></i>Add New Stat Item </button> </div> </div> </div> </div> <div id="panel-features-grid" class="control-panel"> <div class="flex justify-between items-center mb-6"> <h3 class="mb-0 pb-0 border-b-0">✨ Features Grid</h3> <button class="get-component-code-btn text-sm bg-indigo-500 text-white py-1 px-3 rounded-md hover:bg-indigo-600" data-component-key="featuresGrid"> <i class="fas fa-code mr-1"></i> Get Code </button> </div> <div class="space-y-4"> <div class="flex items-center space-x-2 border-b pb-4"> <input type="checkbox" id="features-grid-toggle" class="h-4 w-4 rounded"> <label for="features-grid-toggle" class="font-medium">Enable Section</label> </div> <div id="features-grid-builder" class="space-y-4"> <div> <label class="text-sm font-medium">Title (Optional)</label> <input type="text" id="features-grid-title" class="w-full p-1 border rounded-md mt-1 text-sm"> </div> <div class="border-t pt-4"> <h4 class="text-sm font-semibold mb-2">Feature Items</h4> <div id="features-grid-items-builder" class="space-y-3"></div> <button id="add-feature-item-btn" class="mt-4 text-sm w-full bg-green-100 text-green-800 font-semibold py-2 px-4 rounded-md hover:bg-green-200 transition"> <i class="fas fa-plus mr-2"></i>Add New Feature Item </button> </div> </div> </div> </div> <div id="panel-custom-html" class="control-panel"> <div class="flex justify-between items-center mb-6"> <h3 class="mb-0 pb-0 border-b-0"> </> Custom HTML</h3> <button class="get-component-code-btn text-sm bg-indigo-500 text-white py-1 px-3 rounded-md hover:bg-indigo-600" data-component-key="customHtml"> <i class="fas fa-code mr-1"></i> Get Code </button> </div> <div class="space-y-4"> <div class="flex items-center space-x-2 border-b pb-4"> <input type="checkbox" id="custom-html-toggle" class="h-4 w-4 rounded"> <label for="custom-html-toggle" class="font-medium">Enable Custom HTML Section</label> </div> <div id="custom-html-builder"> <label for="custom-html-content" class="text-sm font-medium">HTML Content</label> <p class="text-xs text-gray-500 mb-2">Paste any valid HTML. Be cautious, as invalid code can break the page layout.</p> <textarea id="custom-html-content" rows="10" class="w-full p-2 border rounded-md font-mono text-sm"></textarea> </div> </div> </div> </div> </div> </aside> <main id="preview-main" class="w-2/3 bg-gray-200 p-4 flex flex-col items-center justify-center overflow-hidden transition-all duration-300 ease-in-out"> <div id="preview-container" class="bg-white shadow-lg rounded-lg w-full h-full overflow-hidden"> <iframe id="preview-iframe" class="preview-iframe"></iframe> </div> </main> </div> </div> <div id="toast-notification" class="toast"></div> <div id="code-modal" class="hidden fixed inset-0 bg-gray-600 bg-opacity-75 overflow-y-auto h-full w-full z-50"> <div class="relative top-10 mx-auto p-5 border w-11/12 md:w-2/3 shadow-lg rounded-md bg-white"> <div class="flex justify-between items-center border-b pb-3"> <h3 id="code-modal-title" class="text-lg leading-6 font-medium text-gray-900">Component Code</h3> <button id="close-code-modal-btn" class="text-gray-400 hover:text-gray-600">&times;</button> </div> <div class="mt-4 space-y-4"> <div> <label class="font-semibold text-gray-700">HTML</label> <pre id="code-modal-html" class="code-modal-pre"><code></code></pre> </div> <div> <label class="font-semibold text-gray-700">CSS</label> <pre id="code-modal-css" class="code-modal-pre"><code></code></pre> </div> <div> <label class="font-semibold text-gray-700">JavaScript</label> <pre id="code-modal-js" class="code-modal-pre"><code></code></pre> </div> </div> <div class="items-center px-4 py-3 mt-4 text-right bg-gray-50 -mx-5 -mb-5 rounded-b-md"> <button id="download-component-zip-btn" class="px-4 py-2 bg-green-600 text-white text-base font-medium rounded-md shadow-sm hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-green-300"> Download .zip </button> <button id="close-code-modal-btn-2" class="px-4 py-2 bg-gray-200 text-gray-800 text-base font-medium rounded-md shadow-sm hover:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-gray-300 ml-2"> Close </button> </div> </div> </div> <script> document.addEventListener('DOMContentLoaded', () => { // State object to hold all configurations const config = { globalSettings: { colors: { primary: '#3b82f6', secondary: '#10b981', text: '#374151', heading: '#111827', }, typography: { fontFamily: "'Inter', sans-serif", } }, componentOrder: [ 'featuresGrid', 'topCourses', 'popularTestSeries', 'mcqTopics', 'bulkMcq', 'popularExams', 'statsBar', 'customHtml' ], topCourses: { enabled: true, title: 'Top Courses and Complete Study Material Included', tabs: [ { id: 'ugc_net_hinglish', name: 'UGC NET/SET (Hinglish)'}, { id: 'ugc_net_guaranteed', name: 'UGC NET/SET (Guaranteed Selection Program)'}, { id: 'up_lt_grade', name: 'UP LT Grade 2025'}, { id: 'ib_acio', name: 'IB ACIO 2025'}, ], items: [ { category: 'ugc_net_hinglish', title: 'UGC NET/JRF Paper 1 Foundation Batch 2.0...', language: 'Hinglish', image: 'https://i.imgur.com/uN0B9pY.png', link: '#' }, { category: 'ugc_net_hinglish', title: 'UGC NET/JRF Environmental Science...', language: 'Hinglish', image: 'https://i.imgur.com/i9G5s4e.png', link: '#' }, { category: 'ugc_net_hinglish', title: 'UGC NET/JRF Psychology Foundation...', language: 'Hinglish', image: 'https://i.imgur.com/8Qp4Y2G.png', link: '#' }, { category: 'ugc_net_hinglish', title: 'UGC NET/JRF Commerce Foundation...', language: 'Hinglish', image: 'https://i.imgur.com/gK9q05j.png', link: '#' }, { category: 'up_lt_grade', title: 'UP LT Grade Foundation...', language: 'Hinglish', image: 'https://placehold.co/300x160/a78bfa/ffffff/png?text=UP+LT', link: '#' }, ], exploreButton: { textTemplate: 'Explore {category} Supercoaching', link: '#' } }, popularExams: { enabled: true, title: 'Popular Exams', subtitle: 'Get exam-ready with concepts, questions and study notes as per the latest pattern', tabs: [ { id: 'ssc', name: 'SSC Exams' }, { id: 'banking', name: 'Banking Exams' }, { id: 'teaching', name: 'Teaching Exams' }, { id: 'civil', name: 'Civil Services Exam' }, { id: 'railways', name: 'Railways Exams' }, { id: 'eng', name: 'Engineering Recruitment Exams' }, ], items: [ { category: 'ssc', name: 'SSC CGL', icon: 'https://placehold.co/40x40/f87171/ffffff/png?text=SC', link: '#' }, { category: 'ssc', name: 'SSC Stenographer', icon: 'https://placehold.co/40x40/f87171/ffffff/png?text=SS', link: '#' }, { category: 'ssc', name: 'SSC CHSL', icon: 'https://placehold.co/40x40/f87171/ffffff/png?text=SC', link: '#' }, { category: 'ssc', name: 'IB ACIO', icon: 'https://placehold.co/40x40/374151/ffffff/png?text=IB', link: '#' }, ] }, popularTestSeries: { enabled: true, title: 'Popular Test Series', items: [ { icon: 'https://i.imgur.com/e4Wb4S8.png', users: '65.1k Users', title: 'SBI Clerk Mock Test Series 2025 - 26 (Pre + Mains)', totalTests: '274', freeTests: '3', languages: 'English,Hindi', features: [ '22 Full Test (Prelims)', '15 Sectional Test (Prelims)', '81 Chapter Test (Prelims)', '+156 more tests' ], link: '#' }, { icon: 'https://i.imgur.com/gK9q05j.png', users: '1730.2k Users', title: 'SSC CGL Mock Test Series 2025 (Tier I & Tier II)', totalTests: '1888', freeTests: '5', languages: 'English,Hindi', features: [ '3 Marathon Ultimate Mega Live Test', '68 Eduquity Pattern Revision Series', '10 AI-Generated Test', '+1807 more tests' ], link: '#' }, { icon: 'https://i.imgur.com/gK9q05j.png', users: '198.6k Users', title: 'SSC Stenographer Grade C & D Mock Test 2025', totalTests: '841', freeTests: '10', languages: 'English,Hindi', features: [ '2 Live Test', '3 Daily Practice Test', '18 Mission Steno Revision Series', '+818 more tests' ], link: '#' }, { icon: 'https://i.imgur.com/E0P5Xo7.png', users: '2589.8k Users', title: 'RRB NTPC Mock Test Series 2024-25 (CBT 1 + CBT 2)', totalTests: '2360', freeTests: '8', languages: 'English,Hindi + 6 More', features: [ '4 Daily Practice Test', '15 New Interface Full Test (Under Graduate)', '2 Ultimate Live Test', '+2339 more tests' ], link: '#' } ] }, mcqTopics: { enabled: true, title: 'Computer Related MCQ Question For Practice', items: [ { label: 'COMPUTER FUNDAMENTAL', link: '#', iconUrl: 'https://i.imgur.com/7p4wL8A.png', color: '#92c44c' }, { label: 'OPERATING SYSTEM', link: '#', iconUrl: 'https://i.imgur.com/7p4wL8A.png', color: '#ea7e23' }, { label: 'MS Word', link: '#', iconUrl: 'https://i.imgur.com/7p4wL8A.png', color: '#2d572c' }, { label: 'MS Excel', link: '#', iconUrl: 'https://i.imgur.com/7p4wL8A.png', color: '#1e7145' }, { label: 'MS PowerPoint', link: '#', iconUrl: 'https://i.imgur.com/7p4wL8A.png', color: '#c04825' }, { label: 'DATA SCIENCE', link: '#', iconUrl: 'https://i.imgur.com/7p4wL8A.png', color: '#d83a3a' }, { label: 'MACHINE LEARNING', link: '#', iconUrl: 'https://i.imgur.com/7p4wL8A.png', color: '#298fca' }, { label: 'CLOUD COMPUTING', link: '#', iconUrl: 'https://i.imgur.com/7p4wL8A.png', color: '#e7963d' }, ] }, bulkMcq: { enabled: true, title: 'Practice MCQs', bulkText: `### **1. What is the output voltage of a full-wave rectifier circuit with a peak input voltage of 20 V, assuming ideal diodes and no load resistance?** a) 20 V b) 40 V c) 10 V d) 18.9 V **Correct Answer:** a) 20 V **Explanation:** In a full-wave rectifier with ideal diodes, the output voltage follows the input voltage’s magnitude, rectifying both positive and negative cycles. For a peak input voltage of 20 V, the peak output voltage is also 20 V (ignoring diode voltage drops, which are zero for ideal diodes). The output is a pulsating DC with the same peak value. --- ### **2. Which type of diode is used to maintain a constant voltage across a load in a power supply circuit?** a) Schottky diode b) Zener diode c) Light-emitting diode d) Tunnel diode **Correct Answer:** b) Zener diode **Explanation:** A Zener diode operates in reverse bias near its breakdown voltage, maintaining a nearly constant voltage across its terminals. This property makes it ideal for voltage regulation in power supply circuits.`, questions: [] // Will be populated by the parser }, statsBar: { enabled: true, items: [ { icon: 'fas fa-user-check', value: '7.4+ Crore', label: 'Registered Students' }, { icon: 'fas fa-trophy', value: '4+ Lacs', label: 'Student Selections' }, { icon: 'fas fa-tasks', value: '242+ Crore', label: 'Tests Attempted' }, { icon: 'fas fa-chalkboard-teacher', value: '5.5+ Crore', label: 'Classes Attended' } ], style: { backgroundColor: '#ffffff', textColor: '#6b7280', valueColor: '#111827', iconColor: '#3b82f6' } }, featuresGrid: { enabled: true, title: '', items: [ { label: 'Live Test', iconUrl: 'https://img.icons8.com/fluency/48/test-results.png', link: '#', isNew: false }, { label: 'Quizzes', iconUrl: 'https://img.icons8.com/fluency/48/quiz.png', link: '#', isNew: false }, { label: 'Practice', iconUrl: 'https://img.icons8.com/fluency/48/development-skill.png', link: '#', isNew: false }, { label: 'GK and CA', iconUrl: 'https://img.icons8.com/fluency/48/news.png', link: '#', isNew: false }, { label: 'Blog', iconUrl: 'https://img.icons8.com/fluency/48/blog.png', link: '#', isNew: false }, { label: 'Videos', iconUrl: 'https://img.icons8.com/fluency/48/video-playlist.png', link: '#', isNew: false }, { label: 'Downloads', iconUrl: 'https://img.icons8.com/fluency/48/download.png', link: '#', isNew: false }, { label: 'Saved', iconUrl: 'https://img.icons8.com/fluency/48/bookmark-ribbon.png', link: '#', isNew: false }, { label: 'Doubts', iconUrl: 'https://img.icons8.com/fluency/48/collaboration.png', link: '#', isNew: false }, { label: 'PYP', iconUrl: 'https://img.icons8.com/fluency/48/document.png', link: '#', isNew: true }, ] }, customHtml: { enabled: false, content: '' } }; const componentNames = { topCourses: 'Top Courses', popularExams: 'Popular Exams', popularTestSeries: 'Popular Test Series', mcqTopics: 'MCQ Topics', bulkMcq: 'Bulk MCQ', statsBar: 'Stats Bar', featuresGrid: 'Features Grid', customHtml: 'Custom HTML' }; // UI Element References const ui = { previewIframe: document.getElementById('preview-iframe'), mainContainer: document.getElementById('main-container'), toggleSidebarBtn: document.getElementById('toggle-sidebar-btn'), controls: { nav: document.getElementById('controls-nav'), panels: document.getElementById('controls-panels'), }, globalSettings: { primaryColor: document.getElementById('global-color-primary'), secondaryColor: document.getElementById('global-color-secondary'), textColor: document.getElementById('global-color-text'), headingColor: document.getElementById('global-color-heading'), fontFamily: document.getElementById('global-font-family'), applyBtn: document.getElementById('apply-global-settings'), }, layout: { container: document.getElementById('layout-builder-container'), panel: document.getElementById('panel-layout') }, topCourses: { toggle: document.getElementById('top-courses-toggle'), title: document.getElementById('top-courses-title'), tabsBuilder: document.getElementById('top-courses-tabs-builder'), itemsBuilder: document.getElementById('top-courses-items-builder'), addTabBtn: document.getElementById('add-course-tab-btn'), addItemBtn: document.getElementById('add-course-item-btn'), exploreText: document.getElementById('top-courses-explore-text'), exploreLink: document.getElementById('top-courses-explore-link'), }, popularExams: { toggle: document.getElementById('popular-exams-toggle'), title: document.getElementById('popular-exams-title'), subtitle: document.getElementById('popular-exams-subtitle'), tabsBuilder: document.getElementById('popular-exams-tabs-builder'), itemsBuilder: document.getElementById('popular-exams-items-builder'), addTabBtn: document.getElementById('add-exam-tab-btn'), addItemBtn: document.getElementById('add-exam-item-btn'), }, popularTestSeries: { toggle: document.getElementById('test-series-toggle'), title: document.getElementById('test-series-title'), itemsBuilder: document.getElementById('test-series-items-builder'), addItemBtn: document.getElementById('add-test-series-item-btn'), }, mcqTopics: { toggle: document.getElementById('mcq-topics-toggle'), title: document.getElementById('mcq-topics-title'), itemsBuilder: document.getElementById('mcq-topics-items-builder'), addItemBtn: document.getElementById('add-mcq-topic-item-btn'), }, bulkMcq: { toggle: document.getElementById('bulk-mcq-toggle'), title: document.getElementById('bulk-mcq-title'), content: document.getElementById('bulk-mcq-content'), generateBtn: document.getElementById('bulk-mcq-generate-btn'), }, statsBar: { panel: document.getElementById('panel-stats-bar'), toggle: document.getElementById('stats-bar-toggle'), itemsBuilder: document.getElementById('stats-bar-items-builder'), addItemBtn: document.getElementById('add-stat-item-btn'), bgColor: document.getElementById('stats-bar-bg-color'), textColor: document.getElementById('stats-bar-text-color'), valueColor: document.getElementById('stats-bar-value-color'), iconColor: document.getElementById('stats-bar-icon-color'), }, featuresGrid: { toggle: document.getElementById('features-grid-toggle'), title: document.getElementById('features-grid-title'), itemsBuilder: document.getElementById('features-grid-items-builder'), addItemBtn: document.getElementById('add-feature-item-btn'), }, customHtml: { toggle: document.getElementById('custom-html-toggle'), content: document.getElementById('custom-html-content'), }, buttons: { desktop: document.getElementById('desktop-btn'), tablet: document.getElementById('tablet-btn'), mobile: document.getElementById('mobile-btn'), import: document.getElementById('import-btn'), importFile: document.getElementById('import-file-input'), }, exportMenu: { container: document.getElementById('export-menu-container'), button: document.getElementById('export-menu-btn'), dropdown: document.getElementById('export-dropdown'), copyCombined: document.getElementById('copy-combined-code'), copyHtml: document.getElementById('copy-html'), copyCss: document.getElementById('copy-css'), copyJs: document.getElementById('copy-js'), downloadZip: document.getElementById('download-zip-btn'), }, codeModal: { modal: document.getElementById('code-modal'), title: document.getElementById('code-modal-title'), htmlContainer: document.getElementById('code-modal-html'), cssContainer: document.getElementById('code-modal-css'), jsContainer: document.getElementById('code-modal-js'), htmlCode: document.querySelector('#code-modal-html code'), cssCode: document.querySelector('#code-modal-css code'), jsCode: document.querySelector('#code-modal-js code'), downloadBtn: document.getElementById('download-component-zip-btn'), closeBtns: [document.getElementById('close-code-modal-btn'), document.getElementById('close-code-modal-btn-2')], }, previewContainer: document.getElementById('preview-container'), }; // --- Event Listeners --- function setupEventListeners() { ui.controls.nav.addEventListener('click', (e) => { const button = e.target.closest('.control-nav-button'); if (!button) return; const targetPanelId = button.dataset.target; ui.controls.nav.querySelectorAll('.control-nav-button').forEach(btn => btn.classList.remove('active')); button.classList.add('active'); ui.controls.panels.querySelectorAll('.control-panel').forEach(panel => { panel.classList.toggle('active', `#${panel.id}` === targetPanelId); }); }); // Global Settings Listeners ui.globalSettings.primaryColor.addEventListener('input', e => config.globalSettings.colors.primary = e.target.value); ui.globalSettings.secondaryColor.addEventListener('input', e => config.globalSettings.colors.secondary = e.target.value); ui.globalSettings.textColor.addEventListener('input', e => config.globalSettings.colors.text = e.target.value); ui.globalSettings.headingColor.addEventListener('input', e => config.globalSettings.colors.heading = e.target.value); ui.globalSettings.fontFamily.addEventListener('change', e => config.globalSettings.typography.fontFamily = e.target.value); ui.globalSettings.applyBtn.addEventListener('click', () => { renderAll(); showToast('Global styles applied!'); }); // Layout Controls ui.layout.panel.addEventListener('click', handleLayoutControlsClick); setupDragAndDrop(); // Component Listeners setupTopCoursesListeners(); setupPopularExamsListeners(); setupPopularTestSeriesListeners(); setupStatsBarListeners(); setupFeaturesGridListeners(); setupMcqTopicsListeners(); setupBulkMcqListeners(); ui.customHtml.toggle.addEventListener('change', e => { config.customHtml.enabled = e.target.checked; renderAll(); }); ui.customHtml.content.addEventListener('input', e => { config.customHtml.content = e.target.value; renderAll(); }); // Preview & Export ui.buttons.desktop.addEventListener('click', () => setPreviewMode('desktop')); ui.buttons.tablet.addEventListener('click', () => setPreviewMode('tablet')); ui.buttons.mobile.addEventListener('click', () => setPreviewMode('mobile')); ui.exportMenu.button.addEventListener('click', (e) => { e.stopPropagation(); ui.exportMenu.dropdown.classList.toggle('hidden'); }); window.addEventListener('click', (e) => { if (!ui.exportMenu.container.contains(e.target)) { ui.exportMenu.dropdown.classList.add('hidden'); } }); const copyAction = (e, dataGetter, message) => { e.preventDefault(); navigator.clipboard.writeText(dataGetter()).then(() => showToast(message)); ui.exportMenu.dropdown.classList.add('hidden'); }; ui.exportMenu.copyCombined.addEventListener('click', (e) => copyAction(e, getCombinedCode, 'Combined code copied!')); ui.exportMenu.copyHtml.addEventListener('click', (e) => copyAction(e, getAllHtml, 'All HTML copied!')); ui.exportMenu.copyCss.addEventListener('click', (e) => copyAction(e, getFullCSS, 'All CSS copied!')); ui.exportMenu.copyJs.addEventListener('click', (e) => copyAction(e, getFullJS, 'All JS copied!')); ui.exportMenu.downloadZip.addEventListener('click', (e) => { e.preventDefault(); generatePageZip(); ui.exportMenu.dropdown.classList.add('hidden'); }); // Import ui.buttons.import.addEventListener('click', () => ui.buttons.importFile.click()); ui.buttons.importFile.addEventListener('change', handleFileImport); // Code Modal Listeners ui.controls.panels.addEventListener('click', handleGetCodeClick); ui.codeModal.closeBtns.forEach(btn => btn.addEventListener('click', () => ui.codeModal.modal.classList.add('hidden'))); ui.codeModal.modal.addEventListener('click', (e) => { if (e.target.id === 'code-modal-html' || e.target.id === 'code-modal-css' || e.target.id === 'code-modal-js') { const code = e.target.querySelector('code').innerText; navigator.clipboard.writeText(code).then(() => showToast('Copied to clipboard!')); } }); // Sidebar Toggle Listener ui.toggleSidebarBtn.addEventListener('click', () => { ui.mainContainer.classList.toggle('sidebar-collapsed'); const isCollapsed = ui.mainContainer.classList.contains('sidebar-collapsed'); const icon = ui.toggleSidebarBtn.querySelector('i'); icon.classList.toggle('fa-chevron-left', !isCollapsed); icon.classList.toggle('fa-chevron-right', isCollapsed); ui.toggleSidebarBtn.title = isCollapsed ? 'Show Controls' : 'Hide Controls'; }); } // --- TOP COURSES --- function setupTopCoursesListeners() { const tc = ui.topCourses; tc.toggle.addEventListener('change', e => { config.topCourses.enabled = e.target.checked; renderAll(); }); tc.title.addEventListener('input', e => { config.topCourses.title = e.target.value; renderAll(); }); tc.exploreText.addEventListener('input', e => { config.topCourses.exploreButton.textTemplate = e.target.value; renderAll(); }); tc.exploreLink.addEventListener('input', e => { config.topCourses.exploreButton.link = e.target.value; renderAll(); }); tc.addTabBtn.addEventListener('click', () => { const newId = `new_course_tab_${Date.now()}`; config.topCourses.tabs.push({ id: newId, name: 'New Course Tab' }); renderTopCoursesBuilder(); renderAll(); }); tc.addItemBtn.addEventListener('click', () => { config.topCourses.items.push({ category: config.topCourses.tabs[0]?.id || '', title: 'New Course', language: 'English', image: 'https://placehold.co/300x160/cccccc/ffffff/png?text=New', link: '#' }); renderTopCoursesItemsBuilder(); renderAll(); }); tc.tabsBuilder.addEventListener('input', e => { if(e.target.classList.contains('course-tab-name-input')) { const index = e.target.closest('[data-index]').dataset.index; config.topCourses.tabs[index].name = e.target.value; renderTopCoursesItemsBuilder(); // Re-render items to update dropdown renderAll(); } }); tc.tabsBuilder.addEventListener('click', e => { if(e.target.closest('.remove-course-tab-btn')) { const index = e.target.closest('[data-index]').dataset.index; config.topCourses.tabs.splice(index, 1); renderTopCoursesBuilder(); renderAll(); } }); tc.itemsBuilder.addEventListener('input', e => { if (e.target.dataset.prop) { const index = e.target.closest('[data-index]').dataset.index; const prop = e.target.dataset.prop; config.topCourses.items[index][prop] = e.target.value; renderAll(); } }); tc.itemsBuilder.addEventListener('change', e => { if (e.target.dataset.prop === 'category') { const index = e.target.closest('[data-index]').dataset.index; config.topCourses.items[index].category = e.target.value; renderAll(); } }); tc.itemsBuilder.addEventListener('click', e => { if(e.target.closest('.remove-course-item-btn')) { const index = e.target.closest('[data-index]').dataset.index; config.topCourses.items.splice(index, 1); renderTopCoursesItemsBuilder(); renderAll(); } }); } function renderTopCoursesBuilder() { renderTopCoursesTabsBuilder(); renderTopCoursesItemsBuilder(); } function renderTopCoursesTabsBuilder() { ui.topCourses.tabsBuilder.innerHTML = config.topCourses.tabs.map((tab, index) => ` <div class="flex items-center space-x-2 bg-gray-50 p-1 rounded" data-index="${index}"> <input type="text" value="${tab.name}" class="course-tab-name-input w-full p-1 border rounded-md text-xs"> <button class="remove-course-tab-btn text-red-500 hover:text-red-700 text-xs p-1" title="Remove Tab"><i class="fas fa-trash-alt fa-fw"></i></button> </div> `).join(''); } function renderTopCoursesItemsBuilder() { const tabsOptions = config.topCourses.tabs.map(tab => `<option value="${tab.id}">${tab.name}</option>`).join(''); ui.topCourses.itemsBuilder.innerHTML = config.topCourses.items.map((item, index) => ` <div class="p-3 border rounded-md bg-gray-50 space-y-2" data-index="${index}"> <div class="flex justify-end"> <button class="remove-course-item-btn text-red-500 hover:text-red-700 text-xs" title="Remove Item"><i class="fas fa-trash-alt"></i></button> </div> <div> <label class="text-xs font-medium">Course Title</label> <input type="text" value="${item.title}" data-prop="title" class="w-full p-1 border rounded-md mt-1 text-xs"> </div> <div> <label class="text-xs font-medium">Image URL</label> <input type="text" value="${item.image}" data-prop="image" class="w-full p-1 border rounded-md mt-1 text-xs"> </div> <div> <label class="text-xs font-medium">Language</label> <input type="text" value="${item.language}" data-prop="language" class="w-full p-1 border rounded-md mt-1 text-xs"> </div> <div> <label class="text-xs font-medium">Link URL</label> <input type="text" value="${item.link}" data-prop="link" class="w-full p-1 border rounded-md mt-1 text-xs"> </div> <div> <label class="text-xs font-medium">Category</label> <select data-prop="category" class="w-full p-1 border rounded-md mt-1 text-xs"> ${tabsOptions.replace(`value="${item.category}"`, `value="${item.category}" selected`)} </select> </div> </div> `).join(''); } // --- POPULAR EXAMS --- function setupPopularExamsListeners() { const pe = ui.popularExams; pe.toggle.addEventListener('change', e => { config.popularExams.enabled = e.target.checked; renderAll(); }); pe.title.addEventListener('input', e => { config.popularExams.title = e.target.value; renderAll(); }); pe.subtitle.addEventListener('input', e => { config.popularExams.subtitle = e.target.value; renderAll(); }); pe.addTabBtn.addEventListener('click', () => { const newId = `new_tab_${Date.now()}`; config.popularExams.tabs.push({ id: newId, name: 'New Tab' }); renderPopularExamsBuilder(); renderAll(); }); pe.addItemBtn.addEventListener('click', () => { config.popularExams.items.push({ category: config.popularExams.tabs[0]?.id || '', name: 'New Exam', icon: 'https://placehold.co/40x40/cccccc/ffffff/png?text=N', link: '#' }); renderPopularExamsItemsBuilder(); renderAll(); }); pe.tabsBuilder.addEventListener('input', e => { if(e.target.classList.contains('exam-tab-name-input')) { const index = e.target.closest('[data-index]').dataset.index; config.popularExams.tabs[index].name = e.target.value; renderPopularExamsItemsBuilder(); // Re-render items to update dropdown renderAll(); } }); pe.tabsBuilder.addEventListener('click', e => { if(e.target.closest('.remove-exam-tab-btn')) { const index = e.target.closest('[data-index]').dataset.index; config.popularExams.tabs.splice(index, 1); renderPopularExamsBuilder(); renderAll(); } }); pe.itemsBuilder.addEventListener('input', e => { if (e.target.dataset.prop) { const index = e.target.closest('[data-index]').dataset.index; const prop = e.target.dataset.prop; config.popularExams.items[index][prop] = e.target.value; renderAll(); } }); pe.itemsBuilder.addEventListener('change', e => { // for select dropdown if (e.target.dataset.prop === 'category') { const index = e.target.closest('[data-index]').dataset.index; config.popularExams.items[index].category = e.target.value; renderAll(); } }); pe.itemsBuilder.addEventListener('click', e => { if(e.target.closest('.remove-exam-item-btn')) { const index = e.target.closest('[data-index]').dataset.index; config.popularExams.items.splice(index, 1); renderPopularExamsItemsBuilder(); renderAll(); } }); } function renderPopularExamsBuilder() { renderPopularExamsTabsBuilder(); renderPopularExamsItemsBuilder(); } function renderPopularExamsTabsBuilder() { ui.popularExams.tabsBuilder.innerHTML = config.popularExams.tabs.map((tab, index) => ` <div class="flex items-center space-x-2 bg-gray-50 p-1 rounded" data-index="${index}"> <input type="text" value="${tab.name}" class="exam-tab-name-input w-full p-1 border rounded-md text-xs"> <button class="remove-exam-tab-btn text-red-500 hover:text-red-700 text-xs p-1" title="Remove Tab"><i class="fas fa-trash-alt fa-fw"></i></button> </div> `).join(''); } function renderPopularExamsItemsBuilder() { const tabsOptions = config.popularExams.tabs.map(tab => `<option value="${tab.id}">${tab.name}</option>`).join(''); ui.popularExams.itemsBuilder.innerHTML = config.popularExams.items.map((item, index) => ` <div class="p-3 border rounded-md bg-gray-50 space-y-2" data-index="${index}"> <div class="flex justify-end"> <button class="remove-exam-item-btn text-red-500 hover:text-red-700 text-xs" title="Remove Item"><i class="fas fa-trash-alt"></i></button> </div> <div> <label class="text-xs font-medium">Exam Name</label> <input type="text" value="${item.name}" data-prop="name" class="w-full p-1 border rounded-md mt-1 text-xs"> </div> <div> <label class="text-xs font-medium">Icon URL</label> <input type="text" value="${item.icon}" data-prop="icon" class="w-full p-1 border rounded-md mt-1 text-xs"> </div> <div> <label class="text-xs font-medium">Link URL</label> <input type="text" value="${item.link}" data-prop="link" class="w-full p-1 border rounded-md mt-1 text-xs"> </div> <div> <label class="text-xs font-medium">Category</label> <select data-prop="category" class="w-full p-1 border rounded-md mt-1 text-xs"> ${tabsOptions.replace(`value="${item.category}"`, `value="${item.category}" selected`)} </select> </div> </div> `).join(''); } // --- POPULAR TEST SERIES --- function setupPopularTestSeriesListeners() { const pts = ui.popularTestSeries; pts.toggle.addEventListener('change', e => { config.popularTestSeries.enabled = e.target.checked; renderAll(); }); pts.title.addEventListener('input', e => { config.popularTestSeries.title = e.target.value; renderAll(); }); pts.addItemBtn.addEventListener('click', () => { config.popularTestSeries.items.push({ icon: 'https://placehold.co/40x40/9ca3af/ffffff/png?text=Icon', users: '1k Users', title: 'New Mock Test Series', totalTests: '100', freeTests: '5', languages: 'English', features: ['10 Full Tests', '10 Sectional Tests'], link: '#' }); renderPopularTestSeriesBuilder(); renderAll(); }); pts.itemsBuilder.addEventListener('input', e => { const itemDiv = e.target.closest('[data-index]'); if (!itemDiv) return; const index = itemDiv.dataset.index; const prop = e.target.dataset.prop; let value = e.target.value; if (prop === 'features') { value = value.split('\n').map(s => s.trim()).filter(Boolean); } config.popularTestSeries.items[index][prop] = value; renderAll(); }); pts.itemsBuilder.addEventListener('click', e => { const button = e.target.closest('.remove-test-series-item-btn'); if (button) { const index = button.closest('[data-index]').dataset.index; config.popularTestSeries.items.splice(index, 1); renderPopularTestSeriesBuilder(); renderAll(); } }); } function renderPopularTestSeriesBuilder() { ui.popularTestSeries.itemsBuilder.innerHTML = config.popularTestSeries.items.map((item, index) => { const featuresText = Array.isArray(item.features) ? item.features.join('\n') : (item.features || ''); return ` <div class="p-3 border rounded-md bg-gray-50 space-y-2" data-index="${index}"> <div class="flex justify-end"> <button class="remove-test-series-item-btn text-red-500 hover:text-red-700 text-xs" title="Remove Item"><i class="fas fa-trash-alt"></i></button> </div> <div class="grid grid-cols-2 gap-2 text-xs"> <div> <label class="font-medium">Icon URL</label> <input type="text" value="${item.icon}" data-prop="icon" class="w-full p-1 border rounded-md mt-1"> </div> <div> <label class="font-medium">Users Text</label> <input type="text" value="${item.users}" data-prop="users" class="w-full p-1 border rounded-md mt-1"> </div> <div> <label class="font-medium">Total Tests</label> <input type="text" value="${item.totalTests}" data-prop="totalTests" class="w-full p-1 border rounded-md mt-1"> </div> <div> <label class="font-medium">Free Tests</label> <input type="text" value="${item.freeTests}" data-prop="freeTests" class="w-full p-1 border rounded-md mt-1"> </div> </div> <div> <label class="text-xs font-medium">Title</label> <input type="text" value="${item.title}" data-prop="title" class="w-full p-1 border rounded-md mt-1 text-xs"> </div> <div> <label class="text-xs font-medium">Languages</label> <input type="text" value="${item.languages}" data-prop="languages" class="w-full p-1 border rounded-md mt-1 text-xs"> </div> <div> <label class="text-xs font-medium">Link URL</label> <input type="text" value="${item.link}" data-prop="link" class="w-full p-1 border rounded-md mt-1 text-xs"> </div> <div> <label class="text-xs font-medium">Features (one per line)</label> <textarea data-prop="features" rows="4" class="w-full p-1 border rounded-md mt-1 text-xs font-mono">${featuresText}</textarea> </div> </div>`; }).join(''); } // --- MCQ TOPICS --- function setupMcqTopicsListeners() { const mt = ui.mcqTopics; mt.toggle.addEventListener('change', e => { config.mcqTopics.enabled = e.target.checked; renderAll(); }); mt.title.addEventListener('input', e => { config.mcqTopics.title = e.target.value; renderAll(); }); mt.addItemBtn.addEventListener('click', () => { config.mcqTopics.items.push({ label: 'New Topic', link: '#', iconUrl: 'https://i.imgur.com/7p4wL8A.png', color: '#cccccc' }); renderMcqTopicsBuilder(); renderAll(); }); mt.itemsBuilder.addEventListener('input', e => { const itemDiv = e.target.closest('[data-index]'); if (!itemDiv) return; const index = itemDiv.dataset.index; const prop = e.target.dataset.prop; config.mcqTopics.items[index][prop] = e.target.value; renderAll(); }); mt.itemsBuilder.addEventListener('click', e => { const button = e.target.closest('.remove-mcq-topic-item-btn'); if (button) { const index = button.closest('[data-index]').dataset.index; config.mcqTopics.items.splice(index, 1); renderMcqTopicsBuilder(); renderAll(); } }); } function renderMcqTopicsBuilder() { ui.mcqTopics.itemsBuilder.innerHTML = config.mcqTopics.items.map((item, index) => { return ` <div class="p-3 border rounded-md bg-gray-50 space-y-2" data-index="${index}"> <div class="flex justify-end"> <button class="remove-mcq-topic-item-btn text-red-500 hover:text-red-700 text-xs" title="Remove Item"><i class="fas fa-trash-alt"></i></button> </div> <div class="grid grid-cols-2 gap-2 text-xs"> <div> <label class="font-medium">Label</label> <input type="text" value="${item.label}" data-prop="label" class="w-full p-1 border rounded-md mt-1"> </div> <div> <label class="font-medium">Link URL</label> <input type="text" value="${item.link}" data-prop="link" class="w-full p-1 border rounded-md mt-1"> </div> </div> <div class="grid grid-cols-2 gap-2 text-xs"> <div> <label class="font-medium">Icon URL</label> <input type="text" value="${item.iconUrl}" data-prop="iconUrl" class="w-full p-1 border rounded-md mt-1"> </div> <div> <label class="font-medium">Color</label> <input type="color" value="${item.color}" data-prop="color" class="w-full p-0 h-8 border-none rounded-md mt-1"> </div> </div> </div>`; }).join(''); } // --- BULK MCQ --- function setupBulkMcqListeners() { const bmcq = ui.bulkMcq; bmcq.toggle.addEventListener('change', e => { config.bulkMcq.enabled = e.target.checked; renderAll(); }); bmcq.title.addEventListener('input', e => { config.bulkMcq.title = e.target.value; renderAll(); }); bmcq.content.addEventListener('input', e => { config.bulkMcq.bulkText = e.target.value; }); bmcq.generateBtn.addEventListener('click', () => { config.bulkMcq.questions = parseBulkMcqText(config.bulkMcq.bulkText); renderAll(); showToast(`${config.bulkMcq.questions.length} MCQs generated!`); }); } function parseBulkMcqText(text) { if (!text || !text.trim()) return []; const questionBlocks = text.trim().split(/\n---\n/); const parsedQuestions = []; questionBlocks.forEach(block => { const lines = block.trim().split('\n').filter(line => line.trim() !== ''); if (lines.length < 4) return; // Not a valid question block let question = ''; const options = []; let correctAnswer = ''; let explanation = ''; let state = 'question'; // 'question', 'options', 'answer', 'explanation' for (const line of lines) { if (line.startsWith('### **')) { question = line.replace(/### \*\*/, '').replace(/\*\*/, '').trim(); state = 'options'; } else if (state === 'options' && /^[a-z]\)\s/.test(line)) { options.push(line.trim()); } else if (line.startsWith('**Correct Answer:**')) { correctAnswer = line.replace('**Correct Answer:**', '').trim(); state = 'explanation'; } else if (line.startsWith('**Explanation:**')) { explanation = line.replace('**Explanation:**', '').trim(); } else if (state === 'explanation') { explanation += '\n' + line.trim(); } } if (question && options.length > 0 && correctAnswer && explanation) { parsedQuestions.push({ question, options, correctAnswer, explanation }); } }); return parsedQuestions; } // --- STATS BAR --- function setupStatsBarListeners() { ui.statsBar.toggle.addEventListener('change', e => { config.statsBar.enabled = e.target.checked; renderAll(); }); ui.statsBar.addItemBtn.addEventListener('click', () => { config.statsBar.items.push({ icon: 'fas fa-star', value: '100+', label: 'New Stat' }); renderStatsBarBuilder(); renderAll(); }); ui.statsBar.itemsBuilder.addEventListener('input', handleStatItemChange); ui.statsBar.itemsBuilder.addEventListener('click', handleStatItemClick); const styleChangeHandler = (key, event) => { config.statsBar.style[key] = event.target.value; renderAll(); }; ui.statsBar.bgColor.addEventListener('input', (e) => styleChangeHandler('backgroundColor', e)); ui.statsBar.textColor.addEventListener('input', (e) => styleChangeHandler('textColor', e)); ui.statsBar.valueColor.addEventListener('input', (e) => styleChangeHandler('valueColor', e)); ui.statsBar.iconColor.addEventListener('input', (e) => styleChangeHandler('iconColor', e)); } function renderStatsBarBuilder() { ui.statsBar.itemsBuilder.innerHTML = config.statsBar.items.map((item, index) => ` <div class="p-3 border rounded-md bg-gray-50 space-y-2" data-index="${index}"> <div class="flex justify-end"> <button class="remove-stat-item-btn text-red-500 hover:text-red-700 text-xs" title="Remove Item"><i class="fas fa-trash-alt"></i></button> </div> <div class="grid grid-cols-2 gap-2 text-xs"> <div> <label class="font-medium">Icon (FA)</label> <input type="text" value="${item.icon}" data-prop="icon" class="w-full p-1 border rounded-md mt-1"> </div> <div> <label class="font-medium">Value</label> <input type="text" value="${item.value}" data-prop="value" class="w-full p-1 border rounded-md mt-1"> </div> </div> <div> <label class="text-xs font-medium">Label</label> <input type="text" value="${item.label}" data-prop="label" class="w-full p-1 border rounded-md mt-1 text-xs"> </div> </div> `).join(''); } function handleStatItemChange(e) { if (e.target.tagName !== 'INPUT') return; const itemDiv = e.target.closest('[data-index]'); const index = parseInt(itemDiv.dataset.index, 10); const prop = e.target.dataset.prop; config.statsBar.items[index][prop] = e.target.value; renderAll(); } function handleStatItemClick(e) { const button = e.target.closest('.remove-stat-item-btn'); if (!button) return; const itemDiv = button.closest('[data-index]'); const index = parseInt(itemDiv.dataset.index, 10); config.statsBar.items.splice(index, 1); renderStatsBarBuilder(); renderAll(); } // --- FEATURES GRID --- function setupFeaturesGridListeners() { const fg = ui.featuresGrid; fg.toggle.addEventListener('change', e => { config.featuresGrid.enabled = e.target.checked; renderAll(); }); fg.title.addEventListener('input', e => { config.featuresGrid.title = e.target.value; renderAll(); }); fg.addItemBtn.addEventListener('click', () => { config.featuresGrid.items.push({ label: 'New Feature', iconUrl: 'https://placehold.co/48x48/d1d5db/ffffff/png?text=Icon', link: '#', isNew: false }); renderFeaturesGridBuilder(); renderAll(); }); fg.itemsBuilder.addEventListener('input', e => { const itemDiv = e.target.closest('[data-index]'); if (!itemDiv) return; const index = itemDiv.dataset.index; const prop = e.target.dataset.prop; if (e.target.type === 'checkbox') { config.featuresGrid.items[index][prop] = e.target.checked; } else { config.featuresGrid.items[index][prop] = e.target.value; } renderAll(); }); fg.itemsBuilder.addEventListener('click', e => { const button = e.target.closest('.remove-feature-item-btn'); if (button) { const index = button.closest('[data-index]').dataset.index; config.featuresGrid.items.splice(index, 1); renderFeaturesGridBuilder(); renderAll(); } }); } function renderFeaturesGridBuilder() { ui.featuresGrid.itemsBuilder.innerHTML = config.featuresGrid.items.map((item, index) => { return ` <div class="p-3 border rounded-md bg-gray-50 space-y-2" data-index="${index}"> <div class="flex justify-between items-start"> <div class="flex-grow space-y-2"> <div class="grid grid-cols-2 gap-2 text-xs"> <div> <label class="font-medium">Label</label> <input type="text" value="${item.label}" data-prop="label" class="w-full p-1 border rounded-md mt-1"> </div> <div> <label class="font-medium">Link URL</label> <input type="text" value="${item.link}" data-prop="link" class="w-full p-1 border rounded-md mt-1"> </div> </div> <div> <label class="text-xs font-medium">Icon URL</label> <input type="text" value="${item.iconUrl}" data-prop="iconUrl" class="w-full p-1 border rounded-md mt-1 text-xs"> </div> <div class="flex items-center space-x-2 mt-2"> <input type="checkbox" id="feature-item-new-${index}" data-prop="isNew" class="h-4 w-4 rounded" ${item.isNew ? 'checked' : ''}> <label for="feature-item-new-${index}" class="text-xs font-medium">Show 'NEW' Badge</label> </div> </div> <button class="remove-feature-item-btn text-red-500 hover:text-red-700 text-xs ml-2 flex-shrink-0" title="Remove Item"><i class="fas fa-trash-alt fa-lg"></i></button> </div> </div>`; }).join(''); } // --- LAYOUT CONTROLS --- function renderLayoutControls() { ui.layout.container.innerHTML = config.componentOrder.map((key, index) => { const total = config.componentOrder.length; return ` <div class="layout-item p-3 border rounded-md bg-white flex items-center justify-between" draggable="true" data-key="${key}"> <span class="font-medium text-sm"><i class="fas fa-grip-vertical mr-3 text-gray-400"></i> ${componentNames[key]}</span> <div class="item-toolbar mb-0"> <button class="reorder-layout-up-btn text-xs bg-gray-200 text-gray-700 p-1 rounded-md hover:bg-gray-300" data-index="${index}" ${index === 0 ? 'disabled' : ''}><i class="fas fa-arrow-up fa-fw"></i></button> <button class="reorder-layout-down-btn text-xs bg-gray-200 text-gray-700 p-1 rounded-md hover:bg-gray-300" data-index="${index}" ${index === total - 1 ? 'disabled' : ''}><i class="fas fa-arrow-down fa-fw"></i></button> </div> </div>`; }).join(''); } function handleLayoutControlsClick(e) { const button = e.target.closest('button'); if (!button) return; const index = parseInt(button.dataset.index, 10); const order = config.componentOrder; let changed = false; if (button.classList.contains('reorder-layout-up-btn') && index > 0) { [order[index], order[index - 1]] = [order[index - 1], order[index]]; changed = true; } else if (button.classList.contains('reorder-layout-down-btn') && index < order.length - 1) { [order[index], order[index + 1]] = [order[index + 1], order[index]]; changed = true; } if(changed) { renderLayoutControls(); renderAll(); } } function setupDragAndDrop() { let draggedItem = null; ui.layout.container.addEventListener('dragstart', e => { draggedItem = e.target; setTimeout(() => { e.target.style.display = 'none'; }, 0); }); ui.layout.container.addEventListener('dragend', e => { setTimeout(() => { draggedItem.style.display = 'flex'; draggedItem = null; }, 0); }); ui.layout.container.addEventListener('dragover', e => { e.preventDefault(); const afterElement = getDragAfterElement(ui.layout.container, e.clientY); if (afterElement == null) { ui.layout.container.appendChild(draggedItem); } else { ui.layout.container.insertBefore(draggedItem, afterElement); } }); ui.layout.container.addEventListener('drop', e => { e.preventDefault(); const newOrderKeys = [...ui.layout.container.querySelectorAll('.layout-item')].map(item => item.dataset.key); config.componentOrder = newOrderKeys; renderLayoutControls(); renderAll(); }); } function getDragAfterElement(container, y) { const draggableElements = [...container.querySelectorAll('.layout-item:not(.dragging)')]; return draggableElements.reduce((closest, child) => { const box = child.getBoundingClientRect(); const offset = y - box.top - box.height / 2; if (offset < 0 && offset > closest.offset) { return { offset: offset, element: child }; } else { return closest; } }, { offset: Number.NEGATIVE_INFINITY }).element; } // --- HTML Generation Logic --- const componentGenerators = { topCourses: generateTopCoursesHTML, popularExams: generatePopularExamsHTML, popularTestSeries: generatePopularTestSeriesHTML, mcqTopics: generateMcqTopicsHTML, bulkMcq: generateBulkMcqHTML, statsBar: generateStatsBarHTML, featuresGrid: generateFeaturesGridHTML, customHtml: generateCustomHtmlHTML }; function getAllHtml() { return config.componentOrder .map(key => componentGenerators[key] ? componentGenerators[key]() : '') .filter(Boolean) .join('\n\n'); } function generateTopCoursesHTML() { if (!config.topCourses.enabled) return ''; const { title, tabs, items, exploreButton } = config.topCourses; const tabsHtml = tabs.map(tab => ` <button class="course-tab whitespace-nowrap px-4 py-2 rounded-full text-sm font-medium" data-filter="${tab.id}" data-text-name="${tab.name}">${tab.name}</button> `).join(''); const itemsHtml = items.map(item => ` <a href="${item.link}" class="course-card-link" data-category="${item.category}"> <div class="course-card rounded-lg overflow-hidden shadow-md hover:shadow-xl transition-shadow duration-300 bg-white"> <div class="relative"> <img src="${item.image}" alt="${item.title}" class="course-card-image w-full h-40 object-cover"> <div class="course-card-badge absolute top-2 left-2 bg-red-500 text-white text-xs font-bold px-2 py-1 rounded"> <i class="fas fa-broadcast-tower mr-1"></i>LIVE CLASS </div> </div> <div class="p-4"> <h3 class="course-card-title font-semibold text-gray-800 h-12">${item.title}</h3> <p class="course-card-lang text-sm text-gray-500 mt-2">${item.language}</p> </div> </div> </a> `).join(''); return ` <div class="top-courses-section bg-gray-100 py-12"> <div class="container mx-auto px-4"> <h2 class="text-3xl font-bold text-center mb-8">${title}</h2> <div class="course-tabs-wrapper relative max-w-4xl mx-auto mb-8"> <button class="course-tab-arrow prev-course-tab-btn" aria-label="Previous Tabs"><i class="fas fa-chevron-left"></i></button> <div class="course-tabs-container flex items-center space-x-2 p-1 bg-white rounded-full shadow-sm"> ${tabsHtml} </div> <button class="course-tab-arrow next-course-tab-btn" aria-label="Next Tabs"><i class="fas fa-chevron-right"></i></button> </div> <div class="course-items-grid grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-6"> ${itemsHtml} </div> <div class="mt-12 text-center"> <a href="${exploreButton.link}" id="explore-courses-btn" class="inline-block bg-blue-600 text-white font-bold py-3 px-8 rounded-lg hover:bg-blue-700 transition-colors"> ${exploreButton.textTemplate.replace('{category}', tabs[0]?.name || '')} </a> </div> </div> </div>`; } function generatePopularExamsHTML() { if (!config.popularExams.enabled) return ''; const { title, subtitle, tabs, items } = config.popularExams; const tabsHtml = tabs.map((tab, index) => ` <button class="exam-tab whitespace-nowrap px-4 py-2 rounded-md text-sm font-medium" data-filter="${tab.id}">${tab.name}</button> `).join(''); const itemsHtml = items.map(item => ` <a href="${item.link}" class="exam-item-card flex items-center p-4 border rounded-lg bg-white shadow-sm hover:shadow-md transition-shadow" data-category="${item.category}"> <img src="${item.icon}" alt="${item.name}" class="w-8 h-8 mr-4 rounded-full"> <span class="font-semibold text-gray-800">${item.name}</span> <i class="fas fa-chevron-right text-gray-400 ml-auto"></i> </a> `).join(''); return ` <div class="popular-exams-section bg-gray-50 py-12"> <div class="container mx-auto px-4"> <h2 class="text-2xl font-bold text-center mb-2">${title}</h2> <p class="text-gray-600 text-center mb-8">${subtitle}</p> <div class="exam-tabs-wrapper relative"> <button class="exam-tab-arrow prev-tab-btn" aria-label="Previous Tabs"><i class="fas fa-chevron-left"></i></button> <div class="exam-tabs-container"> ${tabsHtml} </div> <button class="exam-tab-arrow next-tab-btn" aria-label="Next Tabs"><i class="fas fa-chevron-right"></i></button> </div> <div class="exam-items-grid grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4 mt-8"> ${itemsHtml} <a href="#" class="explore-all-card flex items-center justify-center p-4 border-2 border-dashed rounded-lg bg-white hover:bg-gray-100 transition-colors" data-category="*"> <span class="font-semibold text-blue-600">Explore all exams</span> </a> </div> </div> </div>`; } function generatePopularTestSeriesHTML() { if (!config.popularTestSeries.enabled) return ''; const { title, items } = config.popularTestSeries; const itemsHtml = items.map(item => { const featuresHtml = (item.features || []).map(feature => { let iconClass = 'fa-check-circle text-green-500'; // Default if (feature.toLowerCase().includes('live test')) iconClass = 'fa-broadcast-tower text-red-500'; else if (feature.toLowerCase().includes('daily practice')) iconClass = 'fa-calendar-alt text-blue-500'; else if (feature.toLowerCase().includes('ultimate live')) iconClass = 'fa-star text-yellow-500'; return `<li class="flex items-center text-sm text-gray-600"><i class="fas ${iconClass} mr-2"></i>${feature}</li>`; }).join(''); return ` <div class="test-series-card flex flex-col bg-white border border-gray-200 rounded-lg shadow-sm hover:shadow-lg transition-shadow duration-300 p-4"> <div class="flex items-start justify-between mb-3"> <img src="${item.icon}" alt="" class="h-10 w-10 rounded-full object-contain"> <span class="bg-purple-100 text-purple-700 text-xs font-semibold px-2.5 py-1 rounded-full"><i class="fas fa-users mr-1"></i>${item.users}</span> </div> <h3 class="font-bold text-gray-800 text-base flex-grow">${item.title}</h3> <p class="text-sm text-gray-500 my-2">${item.totalTests} Total Tests | <span class="font-semibold text-green-600">${item.freeTests} Free Tests</span></p> <p class="text-sm text-gray-600 mb-3"><i class="fas fa-language mr-1 text-gray-400"></i> ${item.languages}</p> <ul class="space-y-2 mb-4 border-t border-gray-200 pt-3"> ${featuresHtml} </ul> <div class="mt-auto"> <a href="${item.link}" class="block w-full text-center bg-cyan-400 text-white font-bold py-2.5 px-4 rounded-md hover:bg-cyan-500 transition">View Test Series</a> </div> </div> `; }).join(''); return ` <section class="popular-test-series-section py-12" style="background-color: #f0f8ff;"> <div class="container mx-auto px-4"> <h2 class="text-3xl font-bold text-center text-gray-800 mb-8">${title}</h2> <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6"> ${itemsHtml} </div> <div class="mt-10 text-center"> <a href="#" class="inline-block text-blue-600 font-semibold border-2 border-blue-500 rounded-lg px-6 py-2 hover:bg-blue-500 hover:text-white transition-colors"> Explore All Test Series </a> </div> </div> </section>`; } function generateMcqTopicsHTML() { if (!config.mcqTopics.enabled) return ''; const { title, items } = config.mcqTopics; const itemsHtml = items.map(item => ` <a href="${item.link}" class="mcq-topic-item" style="background-color: ${item.color};"> <span class="mcq-topic-label">${item.label}</span> <div class="mcq-topic-icon-wrapper"> <img src="${item.iconUrl}" alt="MCQ" class="mcq-topic-icon"/> </div> </a> `).join(''); return ` <section class="mcq-topics-section bg-white py-8"> <div class="container mx-auto px-4"> <h2 class="text-xl font-semibold text-gray-700 mb-6">${title}</h2> <div class="grid grid-cols-1 md:grid-cols-2 gap-4"> ${itemsHtml} </div> </div> </section>`; } function generateBulkMcqHTML() { if (!config.bulkMcq.enabled || !config.bulkMcq.questions.length) return ''; const { title, questions } = config.bulkMcq; const questionsHtml = questions.map((q, index) => ` <div class="bulk-mcq-item border-b py-4"> <p class="font-semibold mb-3">${q.question}</p> <div class="mcq-options space-y-2 mb-3"> ${q.options.map(opt => `<div class="option p-2 border rounded-md">${opt}</div>`).join('')} </div> <button class="toggle-answer-btn text-sm font-medium text-blue-600 hover:text-blue-800" data-target="answer-${index}">Show Answer & Explanation</button> <div id="answer-${index}" class="answer-content hidden mt-3 p-3 bg-gray-100 rounded-md border"> <p class="font-bold text-green-700">Correct Answer: ${q.correctAnswer}</p> <p class="mt-2 text-sm">${q.explanation.replace(/\n/g, '<br>')}</p> </div> </div> `).join(''); return ` <section class="bulk-mcq-section bg-white py-8"> <div class="container mx-auto px-6"> <h2 class="text-2xl font-bold text-gray-800 mb-6">${title}</h2> <div class="mcq-list"> ${questionsHtml} </div> </div> </section> `; } function generateStatsBarHTML() { if (!config.statsBar.enabled) return ''; const itemsHtml = config.statsBar.items.map(item => ` <div class="stat-item text-center"> <div class="stat-item-icon"><i class="${item.icon}"></i></div> <div class="stat-item-value" data-value="${item.value}">0</div> <div class="stat-item-label">${item.label}</div> </div> `).join(''); return `<div class="stats-bar-section py-4"> <div class="container mx-auto px-4 flex items-center justify-around gap-4 flex-wrap"> ${itemsHtml} </div> </div>`; } function generateFeaturesGridHTML() { if (!config.featuresGrid.enabled) return ''; const { title, items } = config.featuresGrid; const itemsHtml = items.map(item => ` <a href="${item.link}" class="feature-item group"> <div class="feature-item-icon-wrapper"> <img src="${item.iconUrl}" alt="${item.label}" class="feature-item-icon"> ${item.isNew ? '<span class="feature-item-new-badge">NEW</span>' : ''} </div> <span class="feature-item-label">${item.label}</span> </a> `).join(''); return ` <section class="features-grid-section bg-white py-6"> <div class="container mx-auto px-4"> ${title ? `<h2 class="text-2xl font-bold text-center text-gray-800 mb-6">${title}</h2>` : ''} <div class="grid grid-cols-5 gap-y-4 justify-items-center"> ${itemsHtml} </div> </div> </section>`; } function generateCustomHtmlHTML() { if (!config.customHtml.enabled) return ''; return `<div class="custom-html-section">${config.customHtml.content}</div>`; } function generateComponentCSS(targetKey = null) { const { colors, typography } = config.globalSettings; const css = {}; css.global = ` /* --- Global --- */ :root { --primary-color: ${colors.primary}; --secondary-color: ${colors.secondary}; --text-color: ${colors.text}; --heading-color: ${colors.heading}; --font-family: ${typography.fontFamily}; } body { font-family: var(--font-family); color: var(--text-color); margin: 0; background-color: #f0f2f5; } h1,h2,h3,h4,h5,h6 { color: var(--heading-color); } .container { max-width: 1280px; } a { text-decoration: none; transition: color 0.2s; color: var(--primary-color); } `; if (config.topCourses.enabled) { css.topCourses = ` /* --- Top Courses --- */ .course-tabs-wrapper { max-width: 90%; } .course-tabs-container { overflow-x: auto; -ms-overflow-style: none; /* IE and Edge */ scrollbar-width: none; /* Firefox */ } .course-tabs-container::-webkit-scrollbar { display: none; /* Chrome, Safari, Opera */ } .course-tab { color: #374151; background-color: transparent; transition: all 0.2s; border: 1px solid transparent; } .course-tab.active, .course-tab:hover { color: white; background-color: var(--primary-color); } .course-card-link { display: block; } .course-tab-arrow { display: none; position: absolute; top: 50%; transform: translateY(-50%); background-color: white; border: 1px solid #d1d5db; border-radius: 50%; width: 32px; height: 32px; align-items: center; justify-content: center; box-shadow: 0 1px 3px rgba(0,0,0,0.1); cursor: pointer; z-index: 10; } .course-tab-arrow:hover { background-color: #f3f4f6; } .course-tab-arrow.prev-course-tab-btn { left: -16px; } .course-tab-arrow.next-course-tab-btn { right: -16px; } .course-tab-arrow:disabled { opacity: 0.4; cursor: not-allowed; } @media (min-width: 1024px) { .course-tabs-container { -ms-overflow-style: none; /* IE and Edge */ scrollbar-width: none; /* Firefox */ } .course-tabs-container::-webkit-scrollbar { display: none; /* Chrome, Safari, Opera */ } .course-tab-arrow { display: flex; } } `; } if (config.popularExams.enabled) { css.popularExams = ` /* --- Popular Exams --- */ .exam-tabs-wrapper { max-width: 90%; margin-left: auto; margin-right: auto; } .exam-tabs-container { display: flex; overflow-x: auto; padding-bottom: 8px; border-bottom: 1px solid #e5e7eb; -ms-overflow-style: auto; scrollbar-width: auto; } .exam-tab { color: #4b5563; background-color: transparent; transition: all 0.3s; border: 1px solid transparent; } .exam-tab.active, .exam-tab:hover { color: var(--primary-color); background-color: #e0f2fe; border-color: var(--primary-color); } .exam-item-card { transition: box-shadow 0.2s ease-in-out; } .exam-tab-arrow { display: none; position: absolute; top: 50%; transform: translateY(-50%); background-color: white; border: 1px solid #d1d5db; border-radius: 50%; width: 32px; height: 32px; align-items: center; justify-content: center; box-shadow: 0 1px 3px rgba(0,0,0,0.1); cursor: pointer; z-index: 10; } .exam-tab-arrow:hover { background-color: #f3f4f6; } .exam-tab-arrow.prev-tab-btn { left: -16px; } .exam-tab-arrow.next-tab-btn { right: -16px; } .exam-tab-arrow:disabled { opacity: 0.4; cursor: not-allowed; } @media (min-width: 768px) { .exam-tabs-container { -ms-overflow-style: none; /* IE and Edge */ scrollbar-width: none; /* Firefox */ } .exam-tabs-container::-webkit-scrollbar { display: none; /* Chrome, Safari, Opera */ } .exam-tab-arrow { display: flex; } } `; } if (config.popularTestSeries.enabled) { css.popularTestSeries = ` /* --- Popular Test Series --- */ .test-series-card { min-height: 430px; } `; } if (config.mcqTopics.enabled) { css.mcqTopics = ` /* --- MCQ Topics --- */ .mcq-topic-item { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 1rem; padding-left: 1.5rem; color: white; font-weight: 500; text-decoration: none; border-radius: 0.375rem; /* rounded-md */ transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out; } .mcq-topic-item:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); } .mcq-topic-label { flex-grow: 1; } .mcq-topic-icon-wrapper { background-color: white; border-radius: 9999px; /* rounded-full */ padding: 0.25rem; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); display: flex; align-items: center; justify-content: center; width: 48px; height: 48px; } .mcq-topic-icon { width: 40px; height: 40px; object-fit: contain; } `; } if (config.bulkMcq.enabled) { css.bulkMcq = ` /* --- Bulk MCQ --- */ .bulk-mcq-item:last-child { border-bottom: none; } .answer-content.hidden { display: none; } `; } if(config.statsBar.enabled) { const s = config.statsBar.style; css.statsBar = ` /* --- Stats Bar --- */ .stats-bar-section { background-color: ${s.backgroundColor}; } .stat-item-icon { font-size: 1.75rem; color: ${s.iconColor}; margin-bottom: 0.25rem; } .stat-item-value { font-size: 1.25rem; font-weight: 700; color: ${s.valueColor}; line-height: 1.2; } .stat-item-label { font-size: 0.75rem; color: ${s.textColor}; } `; } if (config.featuresGrid.enabled) { css.featuresGrid = ` /* --- Features Grid --- */ .features-grid-section { border-radius: 0.75rem; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1); margin: 1rem; } .feature-item { display: flex; flex-direction: column; align-items: center; text-align: center; color: var(--text-color); } .feature-item:hover .feature-item-label { color: var(--primary-color); } .feature-item-icon-wrapper { position: relative; margin-bottom: 0.5rem; background-color: #f3f4f6; border-radius: 50%; width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; transition: transform 0.2s ease-in-out; } .feature-item:hover .feature-item-icon-wrapper { transform: scale(1.1); } .feature-item-icon { width: 32px; height: 32px; object-fit: contain; } .feature-item-label { font-size: 0.875rem; /* 14px */ font-weight: 500; transition: color 0.2s; } .feature-item-new-badge { position: absolute; top: -2px; right: -8px; background-color: #ef4444; /* red-500 */ color: white; font-size: 0.625rem; /* 10px */ font-weight: bold; padding: 2px 5px; border-radius: 0.375rem; /* rounded-md */ border: 1px solid white; } `; } if(config.customHtml.enabled) css.customHtml = ` /* --- Custom HTML Section --- */ .custom-html-section { padding: 1rem 0; }`; if (targetKey) { return { global: css.global, component: css[targetKey] || '' } } return css; } function getFullCSS() { const cssObject = generateComponentCSS(); const orderedCSS = config.componentOrder.map(key => cssObject[key]).filter(Boolean); return [cssObject.global, ...orderedCSS].join('\n\n'); } function generateComponentJavaScript(targetKey = null) { const js = {}; if (config.topCourses.enabled) { js.topCourses = ` // --- Top Courses Filtering & Arrows --- const coursesSection = document.querySelector('.top-courses-section'); if (coursesSection) { const tabsContainer = coursesSection.querySelector('.course-tabs-container'); const courseItems = coursesSection.querySelectorAll('.course-card-link'); const allTabs = tabsContainer.querySelectorAll('.course-tab'); const exploreBtn = coursesSection.querySelector('#explore-courses-btn'); const exploreTextTemplate = \`${config.topCourses.exploreButton.textTemplate}\`; const prevBtn = coursesSection.querySelector('.prev-course-tab-btn'); const nextBtn = coursesSection.querySelector('.next-course-tab-btn'); tabsContainer.addEventListener('click', e => { const tab = e.target.closest('.course-tab'); if (!tab) return; allTabs.forEach(t => t.classList.remove('active')); tab.classList.add('active'); const filter = tab.dataset.filter; courseItems.forEach(item => { item.style.display = (item.dataset.category === filter) ? 'block' : 'none'; }); if (exploreBtn) { const categoryName = tab.dataset.textName || ''; exploreBtn.textContent = exploreTextTemplate.replace('{category}', categoryName); } }); if (allTabs.length > 0) { allTabs[0].click(); } // Arrow Logic for Top Courses const updateCourseArrowState = () => { if (!prevBtn || !nextBtn) return; const isDesktop = window.getComputedStyle(prevBtn).display !== 'none'; if (isDesktop) { const scrollLeft = tabsContainer.scrollLeft; const scrollWidth = tabsContainer.scrollWidth; const clientWidth = tabsContainer.clientWidth; prevBtn.disabled = scrollLeft <= 0; nextBtn.disabled = scrollLeft >= (scrollWidth - clientWidth - 1); } else { prevBtn.disabled = true; nextBtn.disabled = true; } }; if (prevBtn && nextBtn) { const scrollAmount = 200; prevBtn.addEventListener('click', () => { tabsContainer.scrollBy({ left: -scrollAmount, behavior: 'smooth' }); }); nextBtn.addEventListener('click', () => { tabsContainer.scrollBy({ left: scrollAmount, behavior: 'smooth' }); }); tabsContainer.addEventListener('scroll', updateCourseArrowState); new ResizeObserver(updateCourseArrowState).observe(tabsContainer); updateCourseArrowState(); } } `; } if (config.popularExams.enabled) { js.popularExams = ` // --- Popular Exams Filtering & Tab Arrows --- const examsContainer = document.querySelector('.popular-exams-section'); if (examsContainer) { const tabsContainer = examsContainer.querySelector('.exam-tabs-container'); const examItems = examsContainer.querySelectorAll('.exam-item-card, .explore-all-card'); const tabs = tabsContainer.querySelectorAll('.exam-tab'); const prevBtn = examsContainer.querySelector('.prev-tab-btn'); const nextBtn = examsContainer.querySelector('.next-tab-btn'); // Filter Logic tabsContainer.addEventListener('click', e => { const tab = e.target.closest('.exam-tab'); if (!tab) return; tabs.forEach(t => t.classList.remove('active')); tab.classList.add('active'); const filter = tab.dataset.filter; examItems.forEach(item => { const category = item.dataset.category; if (filter === 'all' || category === '*' || category === filter) { item.style.display = 'flex'; } else { item.style.display = 'none'; } }); }); if (tabs.length > 0) { tabs[0].click(); } // Arrow Logic const updateArrowState = () => { if (!prevBtn || !nextBtn) return; const isDesktop = window.getComputedStyle(prevBtn).display !== 'none'; if(isDesktop) { const scrollLeft = tabsContainer.scrollLeft; const scrollWidth = tabsContainer.scrollWidth; const clientWidth = tabsContainer.clientWidth; prevBtn.disabled = scrollLeft <= 0; nextBtn.disabled = scrollLeft >= (scrollWidth - clientWidth - 1); } }; if (prevBtn && nextBtn) { const scrollAmount = 200; prevBtn.addEventListener('click', () => { tabsContainer.scrollBy({ left: -scrollAmount, behavior: 'smooth' }); }); nextBtn.addEventListener('click', () => { tabsContainer.scrollBy({ left: scrollAmount, behavior: 'smooth' }); }); tabsContainer.addEventListener('scroll', updateArrowState); new ResizeObserver(updateArrowState).observe(tabsContainer); updateArrowState(); } } `; } if (config.bulkMcq.enabled) { js.bulkMcq = ` // --- Bulk MCQ Show/Hide Answer --- const mcqSection = document.querySelector('.bulk-mcq-section'); if (mcqSection) { mcqSection.addEventListener('click', function(e) { const button = e.target.closest('.toggle-answer-btn'); if (!button) return; e.preventDefault(); const targetId = button.dataset.target; const answerContent = document.getElementById(targetId); if (answerContent) { const isHidden = answerContent.classList.contains('hidden'); if (isHidden) { answerContent.classList.remove('hidden'); button.textContent = 'Hide Answer & Explanation'; } else { answerContent.classList.add('hidden'); button.textContent = 'Show Answer & Explanation'; } } }); } `; } if (config.statsBar.enabled) { js.statsBar = ` // --- Stats Bar Counter Animation --- const statsSection = document.querySelector('.stats-bar-section'); if (statsSection) { const animateValue = (el, start, end, duration, prefix, suffix) => { let startTimestamp = null; const step = (timestamp) => { if (!startTimestamp) startTimestamp = timestamp; const progress = Math.min((timestamp - startTimestamp) / duration, 1); const currentNumber = Math.floor(progress * (end - start) + start); el.innerHTML = prefix + currentNumber.toLocaleString() + suffix; if (progress < 1) { window.requestAnimationFrame(step); } }; window.requestAnimationFrame(step); }; const observer = new IntersectionObserver(entries => { entries.forEach(entry => { if (entry.isIntersecting) { const counters = entry.target.querySelectorAll('.stat-item-value'); counters.forEach(counter => { const fullValue = counter.dataset.value; if (counter.dataset.animated) return; counter.dataset.animated = true; const match = fullValue.match(/^([\\d,.]+)(.*)/); if (match) { const numericPart = parseFloat(match[1].replace(/,/g, '')); const suffix = match[2] || ''; animateValue(counter, 0, numericPart, 2000, '', suffix); } else { counter.textContent = fullValue; // fallback for non-numeric values } }); observer.unobserve(entry.target); } }); }, { threshold: 0.5 }); observer.observe(statsSection); } `; } if (targetKey) { return js[targetKey] || ''; } return js; } function getFullJS() { const jsObject = generateComponentJavaScript(); return config.componentOrder.map(key => { let script = jsObject[key] || ''; return script; }).filter(Boolean).join('\n\n'); } function getCombinedCode() { const htmlBody = getAllHtml(); const css = getFullCSS(); let js = getFullJS(); if (js.trim()) { js = `document.addEventListener('DOMContentLoaded', () => { \n${js.trim()} \n});`; } return `<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Exported Page</title> <script src="https://cdn.tailwindcss.com"><\/script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"> <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=Open+Sans:wght@400;700&family=Lato:wght@400;700&family=Montserrat:wght@400;700&family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet"> <style> ${css} </style> </head> <body class="bg-gray-100"> ${htmlBody} ${js ? `<script>${js}<\/script>` : ''} </body> </html>`; } // --- Rendering --- function renderAll() { const fullJs = getFullJS(); const previewContent = `<!DOCTYPE html><html><head><title>Preview</title> <script src="https://cdn.tailwindcss.com"><\/script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"> <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=Open+Sans:wght@400;700&family=Lato:wght@400;700&family=Montserrat:wght@400;700&family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet"> <style>${getFullCSS()}</style></head><body> <div class="site-wrapper"> ${getAllHtml()} <div style="min-height: 400px; padding: 40px; text-align: center; color: #6b7280; font-family: 'Inter', sans-serif;"></div> </div> <script> ${fullJs ? `document.addEventListener('DOMContentLoaded', () => { \n${fullJs} \n});` : ''} <\/script></body></html>`; ui.previewIframe.srcdoc = previewContent; } // --- Utility Functions --- function setPreviewMode(mode) { ui.previewContainer.className = `bg-white shadow-lg rounded-lg w-full h-full overflow-hidden transition-all duration-300 preview-${mode}`; ['desktop', 'tablet', 'mobile'].forEach(m => { const btn = ui.buttons[m]; btn.classList.toggle('bg-blue-500', m === mode); btn.classList.toggle('text-white', m === mode); btn.classList.toggle('shadow', m === mode); btn.classList.toggle('bg-gray-200', m !== mode); btn.classList.toggle('text-gray-700', m !== mode); }); } function showToast(message) { const toast = document.getElementById('toast-notification'); toast.textContent = message; toast.classList.add('show'); setTimeout(() => { toast.classList.remove('show'); }, 3000); } function generatePageZip() { const zip = new JSZip(); const html = `<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Exported Page</title> <script src="https://cdn.tailwindcss.com"><\/script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"> <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=Open+Sans:wght@400;700&family=Lato:wght@400;700&family=Montserrat:wght@400;700&family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet"> <link rel="stylesheet" href="style.css"> </head> <body> ${getAllHtml()} <script src="script.js"><\/script> </body> </html>`; const css = getFullCSS(); const js = getFullJS(); zip.file("index.html", html); zip.file("style.css", css); if (js.trim()) { zip.file("script.js", `document.addEventListener('DOMContentLoaded', () => { \n${js} \n});`); } zip.generateAsync({type:"blob"}).then(function(content) { saveAs(content, "exported-page.zip"); showToast("ZIP file generated!"); }); } function handleFileImport(event) { const file = event.target.files[0]; if (!file) return; const reader = new FileReader(); reader.onload = function(e) { const content = e.target.result; try { const parser = new DOMParser(); const doc = parser.parseFromString(content, 'text/html'); parseImportedDocument(doc); showToast('Import successful!'); } catch (error) { console.error('Error parsing imported file:', error); showToast('Error: Could not parse file.'); } event.target.value = null; // Reset file input }; reader.readAsText(file); } function parseImportedDocument(doc) { console.log("Parsing imported document..."); } function handleGetCodeClick(e) { const button = e.target.closest('.get-component-code-btn'); if (!button) return; const key = button.dataset.componentKey; if (!key) return; const html = componentGenerators[key] ? componentGenerators[key]() : 'Not available'; const { global, component: css } = generateComponentCSS(key); const js = generateComponentJavaScript(key); ui.codeModal.title.textContent = `${componentNames[key]} Component Code`; ui.codeModal.htmlCode.textContent = html; ui.codeModal.cssCode.textContent = (global + '\n\n' + css).trim(); let jsWithWrapper = js.trim(); if (jsWithWrapper) { jsWithWrapper = `document.addEventListener('DOMContentLoaded', () => { \n${jsWithWrapper}\n });`; } ui.codeModal.jsCode.textContent = jsWithWrapper || '// No JavaScript for this component'; [ui.codeModal.htmlContainer, ui.codeModal.cssContainer, ui.codeModal.jsContainer].forEach(el => { if (el.querySelector('code').textContent.trim() === '' || el.querySelector('code').textContent.startsWith('//')) { el.style.display = 'none'; } else { el.style.display = 'block'; } }); ui.codeModal.downloadBtn.onclick = () => generateComponentZip(key); ui.codeModal.modal.classList.remove('hidden'); } function generateComponentZip(key) { const zip = new JSZip(); const { global, component: css } = generateComponentCSS(key); const js = generateComponentJavaScript(key); const htmlBody = componentGenerators[key] ? componentGenerators[key]() : ''; const html = `<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>${componentNames[key]} Component</title> <script src="https://cdn.tailwindcss.com"><\/script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"> <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=Open+Sans:wght@400;700&family=Lato:wght@400;700&family=Montserrat:wght@400;700&family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet"> <link rel="stylesheet" href="style.css"> </head> <body> ${htmlBody} ${js.trim() ? '<script src="script.js"><\/script>' : ''} </body> </html>`; zip.file("index.html", html); zip.file("style.css", (global + '\n\n' + css).trim()); if (js.trim()) { let jsWithWrapper = `document.addEventListener('DOMContentLoaded', () => { \n${js} \n});`; zip.file("script.js", jsWithWrapper); } zip.generateAsync({type:"blob"}).then(function(content) { saveAs(content, `${key}-component.zip`); showToast("Component ZIP generated!"); }); } // Initial Load function init() { const { customHtml, globalSettings, statsBar, popularExams, topCourses, popularTestSeries, featuresGrid, mcqTopics, bulkMcq } = config; // Init Global Settings ui.globalSettings.primaryColor.value = globalSettings.colors.primary; ui.globalSettings.secondaryColor.value = globalSettings.colors.secondary; ui.globalSettings.textColor.value = globalSettings.colors.text; ui.globalSettings.headingColor.value = globalSettings.colors.heading; ui.globalSettings.fontFamily.value = globalSettings.typography.fontFamily; // Init Top Courses ui.topCourses.toggle.checked = topCourses.enabled; ui.topCourses.title.value = topCourses.title; ui.topCourses.exploreText.value = topCourses.exploreButton.textTemplate; ui.topCourses.exploreLink.value = topCourses.exploreButton.link; renderTopCoursesBuilder(); // Init Popular Exams ui.popularExams.toggle.checked = popularExams.enabled; ui.popularExams.title.value = popularExams.title; ui.popularExams.subtitle.value = popularExams.subtitle; renderPopularExamsBuilder(); // Init Popular Test Series ui.popularTestSeries.toggle.checked = popularTestSeries.enabled; ui.popularTestSeries.title.value = popularTestSeries.title; renderPopularTestSeriesBuilder(); // Init MCQ Topics ui.mcqTopics.toggle.checked = mcqTopics.enabled; ui.mcqTopics.title.value = mcqTopics.title; renderMcqTopicsBuilder(); // Init Bulk MCQ ui.bulkMcq.toggle.checked = bulkMcq.enabled; ui.bulkMcq.title.value = bulkMcq.title; ui.bulkMcq.content.value = bulkMcq.bulkText; config.bulkMcq.questions = parseBulkMcqText(config.bulkMcq.bulkText); // Init Stats Bar ui.statsBar.toggle.checked = statsBar.enabled; ui.statsBar.bgColor.value = statsBar.style.backgroundColor; ui.statsBar.textColor.value = statsBar.style.textColor; ui.statsBar.valueColor.value = statsBar.style.valueColor; ui.statsBar.iconColor.value = statsBar.style.iconColor; renderStatsBarBuilder(); // Init Features Grid ui.featuresGrid.toggle.checked = featuresGrid.enabled; ui.featuresGrid.title.value = featuresGrid.title; renderFeaturesGridBuilder(); // Init Custom HTML ui.customHtml.toggle.checked = customHtml.enabled; ui.customHtml.content.value = customHtml.content; setupEventListeners(); renderLayoutControls(); renderAll(); if(!document.querySelector('.control-nav-button.active')){ ui.controls.nav.querySelector('.control-nav-button').click(); } } init(); }); </script> </body> </html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Advanced Component Builder</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=Open+Sans:wght@400;700&family=Lato:wght@400;700&family=Montserrat:wght@400;700&family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.0/FileSaver.min.js"></script>
<style>
:root {
--primary-color: #3b82f6;
--primary-hover-color: #2563eb;
--secondary-color: #10b981;
--secondary-hover-color: #059669;
--text-color: #374151;
--heading-color: #111827;
--font-family: 'Inter', sans-serif;
}
body {
font-family: var(--font-family);
color: var(--text-color);
background-color: var(--background-color);
}
h1, h2, h3, h4, h5, h6 {
color: var(--heading-color);
}
/* Custom scrollbar for webkit browsers */
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
background: #f1f1f1;
}
::-webkit-scrollbar-thumb {
background: #888;
border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
background: #555;
}
.preview-iframe {
width: 100%;
height: 100%;
border: 0;
transition: all 0.3s ease-in-out;
}
#preview-container.preview-desktop .preview-iframe { width: 100%; }
#preview-container.preview-tablet .preview-iframe { width: 768px; margin: 0 auto; }
#preview-container.preview-mobile .preview-iframe { width: 375px; margin: 0 auto; }
.toast {
visibility: hidden;
min-width: 250px;
background-color: #333;
color: #fff;
text-align: center;
border-radius: 8px;
padding: 16px;
position: fixed;
z-index: 100;
left: 50%;
bottom: 30px;
transform: translateX(-50%);
opacity: 0;
transition: opacity 0.3s, visibility 0.3s;
}
.toast.show {
visibility: visible;
opacity: 1;
}
/* New Professional Controls UI Styles */
#controls-layout {
display: flex;
height: 100%;
}
#controls-nav {
width: 180px;
flex-shrink: 0;
background-color: #f8fafc;
border-right: 1px solid #e5e7eb;
padding: 0.5rem;
overflow-y: auto;
}
.control-nav-button {
display: flex;
align-items: center;
width: 100%;
padding: 0.75rem;
border-radius: 0.375rem;
font-weight: 500;
color: var(--text-color);
transition: background-color 0.2s, color 0.2s;