Academic Citation Generator

Academic Citation Generator

Create citations in APA, MLA, and Chicago formats.

Select Source Type

Enter Details

Generated Citations

Your generated citations will appear here.

Your generated citations will appear here.

'; return; } let html = `
`; html += `

APA Style

    ${this.citations.map(c => `
  • ${c.apa}
  • `).join('')}
`; html += `

MLA Style

    ${this.citations.map(c => `
  • ${c.mla}
  • `).join('')}
`; html += `

Chicago Style

    ${this.citations.map(c => `
  • ${c.chicago}
  • `).join('')}
`; this.dom.citationOutputArea.innerHTML = html; }, resetForm() { this.dom.detailsForm.reset(); this.setSourceType('website'); }, changeTab(tabIndex) { if (tabIndex > this.currentTab && this.currentTab === 1) { if (!this.addCitation()) return; } this.dom.tabButtons[this.currentTab].classList.remove('active'); this.dom.tabContents[this.currentTab].classList.remove('active'); this.currentTab = tabIndex; this.dom.tabButtons[this.currentTab].classList.add('active'); this.dom.tabContents[this.currentTab].classList.add('active'); this.updateNavButtons(); }, navigateTabs(direction) { const newTab = direction === 'next' ? this.currentTab + 1 : this.currentTab - 1; if (newTab >= 0 && newTab < this.dom.tabButtons.length) { this.changeTab(newTab); } }, updateNavButtons() { this.dom.prevBtn.style.visibility = this.currentTab === 0 ? 'hidden' : 'visible'; this.dom.nextBtn.textContent = this.currentTab === this.dom.tabButtons.length - 2 ? 'Generate Citation' : 'Next'; this.dom.nextBtn.style.visibility = this.currentTab === this.dom.tabButtons.length - 1 ? 'hidden' : 'visible'; }, generatePdf() { const { jsPDF } = window.jspdf; const content = document.getElementById('pdf-content'); if (!content || this.citations.length === 0) { alert("No citations to download."); return; } html2canvas(content, { scale: 2 }).then(canvas => { const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'portrait', unit: 'px', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const imgProps = pdf.getImageProperties(imgData); const pdfHeight = (imgProps.height * pdfWidth) / imgProps.width; pdf.setFont('Times-Roman'); pdf.text("Academic Citations", pdfWidth/2, 40, {align: 'center'}); pdf.addImage(imgData, 'PNG', 40, 60, pdfWidth - 80, pdfHeight > 0 ? pdfHeight - 80 : 0); pdf.save('Academic-Citations.pdf'); }); }, }; window.app = { changeTab: app.changeTab.bind(app), navigateTabs: app.navigateTabs.bind(app), }; app.init(); });
Scroll to Top