Oscola referencing generator
<!-- OSCOLA Referencing Generator -->
<div style="max-width:500px;margin:40px auto;padding:24px;border:1px solid #eee;border-radius:10px;box-shadow:0 2px 8px #f2f2f2;"> <h2>OSCOLA Reference Generator</h2> <label style="display:block;margin-top:18px;">Select Reference Type:</label> <select id="refType" style="width:100%;margin-bottom:12px;"> <option value="book">Book</option> <option value="journal">Journal</option> <option value="case">Case</option> <option value="legislation">Legislation</option> </select> <div id="bookFields"> <input type="text" id="author" placeholder="Author name" style="width:100%;margin-bottom:8px;"> <input type="text" id="title" placeholder="Book Title" style="width:100%;margin-bottom:8px;"> <input type="text" id="edition" placeholder="Edition (e.g., 3rd Edition)" style="width:100%;margin-bottom:8px;"> <input type="text" id="publisher" placeholder="Publisher" style="width:100%;margin-bottom:8px;"> <input type="text" id="year" placeholder="Year" style="width:100%;margin-bottom:8px;"> <input type="text" id="page" placeholder="Page Number" style="width:100%;margin-bottom:8px;"> </div> <div id="journalFields" style="display:none;"> <input type="text" id="jAuthor" placeholder="Author name" style="width:100%;margin-bottom:8px;"> <input type="text" id="jTitle" placeholder="Journal Title" style="width:100%;margin-bottom:8px;"> <input type="text" id="jYear" placeholder="Year" style="width:100%;margin-bottom:8px;"> <input type="text" id="jPages" placeholder="Pages" style="width:100%;margin-bottom:8px;"> </div> <div id="caseFields" style="display:none;"> <input type="text" id="caseName" placeholder="Case Name" style="width:100%;margin-bottom:8px;"> <input type="text" id="caseYear" placeholder="Year" style="width:100%;margin-bottom:8px;"> <input type="text" id="courtNumber" placeholder="Court & Number" style="width:100%;margin-bottom:8px;"> <input type="text" id="volume" placeholder="Volume (optional)" style="width:100%;margin-bottom:8px;"> <input type="text" id="reportAbbr" placeholder="Report Abbreviation" style="width:100%;margin-bottom:8px;"> </div> <div id="legislationFields" style="display:none;"> <input type="text" id="statuteTitle" placeholder="Title of Statute" style="width:100%;margin-bottom:8px;"> <input type="text" id="statuteYear" placeholder="Year" style="width:100%;margin-bottom:8px;"> <input type="text" id="section" placeholder="Section (Subsection)" style="width:100%;margin-bottom:8px;"> </div> <button onclick="generateOSCRef()" style="margin-top:12px;width:100%;background:#4169e1;color:#fff;padding:10px;font-size:16px;border:none;border-radius:6px;">Generate OSCOLA Reference</button> <div id="oscolaRef" style="margin-top:20px;font-weight:bold;background:#fafaff;padding:12px;border-radius:8px;"></div> </div> <script> document.getElementById("refType").addEventListener("change", function() { let type = this.value; document.getElementById("bookFields").style.display = type === "book" ? "block" : "none"; document.getElementById("journalFields").style.display = type === "journal" ? "block" : "none"; document.getElementById("caseFields").style.display = type === "case" ? "block" : "none"; document.getElementById("legislationFields").style.display = type === "legislation" ? "block" : "none"; }); function generateOSCRef() { let type = document.getElementById("refType").value; let output = ""; if (type === "book") { let author = document.getElementById("author").value.trim(); let title = document.getElementById("title").value.trim(); let edition = document.getElementById("edition").value.trim(); let publisher = document.getElementById("publisher").value.trim(); let year = document.getElementById("year").value.trim(); let page = document.getElementById("page").value.trim(); output = `${author}, <i>${title}</i>, (${edition}${edition ? ', ' : ''}${publisher} ${year})${page ? ' ' + page + '.' : ''}`; } if (type === "journal") { let author = document.getElementById("jAuthor").value.trim(); let title = document.getElementById("jTitle").value.trim(); let year = document.getElementById("jYear").value.trim(); let pages = document.getElementById("jPages").value.trim(); output = `${author}, ‘${title}’ [${year}]${pages ? ' p.' + pages : ''}`; } if (type === "case") { let caseName = document.getElementById("caseName").value.trim(); let year = document.getElementById("caseYear").value.trim(); let courtNum = document.getElementById("courtNumber").value.trim(); let volume = document.getElementById("volume").value.trim(); let report = document.getElementById("reportAbbr").value.trim(); output = `${caseName} [${year}] ${courtNum}${volume ? ', [' + year + '] ' + volume : ''}${report ? ' ' + report : ''}`; } if (type === "legislation") { let title = document.getElementById("statuteTitle").value.trim(); let year = document.getElementById("statuteYear").value.trim(); let section = document.getElementById("section").value.trim(); output = `${title} ${year}${section ? ', s ' + section : ''}.`; } document.getElementById("oscolaRef").innerHTML = output ? output : "<span style='color:red;'>Please fill all required fields.</span>"; } </script>
Comments
Post a Comment