Random List Generator

Random List Generator

Randomized List

Click the button to randomize your list from the "Data Configuration" tab.

Your randomized list will appear here.

Add items in the "Data Configuration" tab first.

Manage List Items

  • No items added yet.

Bulk Add

Your list is empty. Add items in the "Data Configuration" tab first.

`; pdfDownloadBtn.style.display = 'none'; return; } // Fisher-Yates Shuffle Algorithm const shuffledList = [...itemList]; for (let i = shuffledList.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [shuffledList[i], shuffledList[j]] = [shuffledList[j], shuffledList[i]]; } let ol = '
    '; shuffledList.forEach(item => { ol += `
  1. ${escapeHTML(item)}
  2. `; }); ol += '
'; dashboardContent.innerHTML = ol; pdfDownloadBtn.style.display = 'block'; } function addItem() { const item = newItemInput.value.trim(); if (item) { itemList.push(item); newItemInput.value = ''; renderConfigList(); } } function addBulkItems() { const items = bulkItemsInput.value.trim().split('\n'); items.forEach(item => { const trimmedItem = item.trim(); if (trimmedItem) { itemList.push(trimmedItem); } }); bulkItemsInput.value = ''; renderConfigList(); } function clearAll() { if (confirm('Are you sure you want to clear all items?')) { itemList = []; renderConfigList(); renderGenerator(); } } async function downloadPdf() { const { jsPDF } = jspdf; const content = container.querySelector('#rlg-pdf-target'); container.classList.add('rlg-pdf-view'); try { const canvas = await html2canvas(content, { scale: 2, useCORS: true, logging: false }); const pdf = new jsPDF({ orientation: 'portrait', unit: 'mm', format: 'a4' }); const imgData = canvas.toDataURL('image/png'); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = (canvas.height * pdfWidth) / canvas.width; pdf.setFont("helvetica", "bold"); pdf.setFontSize(18); pdf.setTextColor(getComputedStyle(document.documentElement).getPropertyValue('--rlg-primary-color').trim()); pdf.text("Randomized List", 15, 20); pdf.addImage(imgData, 'PNG', 15, 30, pdfWidth - 30, pdfHeight - 30); pdf.save('random_list.pdf'); } catch (error) { console.error("PDF Error:", error); alert("Error generating PDF."); } finally { container.classList.remove('rlg-pdf-view'); } } function escapeHTML(str) { return str.replace(/[&<>"']/g, m => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[m])); } // --- 4. EVENT BINDING --- tabButtons.forEach((btn, i) => btn.addEventListener('click', () => showRlgTab(i))); navNext.addEventListener('click', () => showRlgTab(currentRlgTab + 1)); navPrev.addEventListener('click', () => showRlgTab(currentRlgTab - 1)); generateBtn.addEventListener('click', renderGenerator); pdfDownloadBtn.addEventListener('click', downloadPdf); addItemBtn.addEventListener('click', addItem); addBulkBtn.addEventListener('click', addBulkItems); clearAllBtn.addEventListener('click', clearAll); loadSampleBtn.addEventListener('click', () => { bulkItemsInput.value = sampleData.join('\n'); addBulkItems(); }); configList.addEventListener('click', (e) => { if (e.target.classList.contains('rlg-delete-item')) { const index = parseInt(e.target.dataset.index, 10); itemList.splice(index, 1); renderConfigList(); } }); // --- 5. INITIALIZATION --- showRlgTab(0); renderConfigList(); });
Scroll to Top