Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Alternate History Wiki Page Generator</title>
- <style>
- body { font-family: 'Helvetica Neue', Arial, sans-serif; max-width: 1024px; margin: 0 auto; padding: 20px; line-height: 1.6; background: #f8f9fa; color: #202122; }
- form { display: grid; gap: 15px; }
- label { font-weight: bold; }
- input, textarea { width: 100%; padding: 10px; box-sizing: border-box; border: 1px solid #a2a9b1; border-radius: 2px; }
- button { padding: 12px; background: #36c; color: white; border: none; cursor: pointer; font-size: 16px; border-radius: 2px; }
- button:hover { background: #447ff5; }
- #output { margin-top: 30px; border: 1px solid #a2a9b1; padding: 20px; background: #f8f9fa; white-space: pre-wrap; font-family: monospace; }
- #preview { margin-top: 30px; border: 1px solid #a2a9b1; padding: 20px; background: white; box-shadow: 0 1px 1px rgba(0,0,0,0.05); }
- #preview-container { display: flex; }
- #sidebar { width: 220px; flex-shrink: 0; margin-right: 20px; font-size: 0.875em; }
- #sidebar .toc { border: 1px solid #a2a9b1; background: #f8f9fa; padding: 10px; margin: 0; position: sticky; top: 20px; }
- #sidebar .toc h2 { font-size: 1.125em; margin: 0 0 0.5em; border: none; padding: 0; }
- #sidebar .toc ul { list-style-type: none; padding: 0; margin: 0; }
- #sidebar .toc li { margin: 0.3em 0; }
- #main-content { flex: 1; }
- #preview h1 { font-size: 1.875em; border-bottom: 1px solid #a2a9b1; padding-bottom: 0.25em; margin: 0 0 0.5em; }
- #preview h2 { font-size: 1.5em; border-bottom: 1px solid #a2a9b1; padding-bottom: 0.25em; margin: 1.5em 0 0.5em; }
- #preview .infobox { float: right; width: 22em; border: 1px solid #a2a9b1; background: #f8f9fa; margin: 0 0 1em 1em; font-size: 0.875em; line-height: 1.4; }
- #preview .infobox th { text-align: center; font-weight: bold; background: #eaecf0; padding: 0.5em; }
- #preview .infobox td { padding: 0.5em; border-top: 1px solid #a2a9b1; }
- #preview img { max-width: 100%; height: auto; display: block; margin: 0 auto; }
- #preview p { margin: 0.5em 0; }
- #preview a { color: #0645ad; text-decoration: none; }
- #preview a:hover { text-decoration: underline; }
- .clear { clear: both; }
- </style>
- </head>
- <body>
- <h1>Alternate History Wiki Page Generator</h1>
- <p>Create a full wiki-style page for your alternate history scenario. Fill in the details, generate the MediaWiki markup, and copy it to a site like althistory.fandom.com. The preview now emulates Wikipedia's modern layout with the Table of Contents in a left sidebar!</p>
- <form id="wikiForm">
- <label for="title">Page Title:</label>
- <input type="text" id="title" placeholder="e.g., United Federation of Atlantis">
- <label for="infoboxName">Nation/Entity Name (for Infobox):</label>
- <input type="text" id="infoboxName" placeholder="e.g., United Federation of Atlantis">
- <label for="flagUrl">Flag Image URL (or filename after upload):</label>
- <input type="text" id="flagUrl" placeholder="e.g., File:Atlantis_flag.png">
- <label for="capital">Capital:</label>
- <input type="text" id="capital" placeholder="e.g., New Atlantis">
- <label for="government">Government:</label>
- <input type="text" id="government" placeholder="e.g., Federal Republic">
- <label for="leader">Leader:</label>
- <input type="text" id="leader" placeholder="e.g., President Aquaman">
- <label for="population">Population:</label>
- <input type="text" id="population" placeholder="e.g., 50 million">
- <label for="currency">Currency:</label>
- <input type="text" id="currency" placeholder="e.g., Atlantean Dollar">
- <label for="introduction">Introduction (Lead Paragraph):</label>
- <textarea id="introduction" rows="4" placeholder="e.g., The United Federation of Atlantis is a sovereign state in an alternate timeline where Atlantis never sank..."></textarea>
- <label for="history">History Section:</label>
- <textarea id="history" rows="6" placeholder="e.g., ==History==\nIn 1492, Columbus discovered Atlantis instead of America...\nUse wiki markup like '''bold''', ''italics'', [[links]]."></textarea>
- <label for="geography">Geography Section:</label>
- <textarea id="geography" rows="6" placeholder="e.g., ==Geography==\nAtlantis spans the Atlantic Ocean...\nAdd images or tables if needed."></textarea>
- <label for="economy">Economy Section:</label>
- <textarea id="economy" rows="6" placeholder="e.g., ==Economy==\nBased on advanced underwater tech..."></textarea>
- <label for="additionalSections">Additional Sections:</label>
- <textarea id="additionalSections" rows="6" placeholder="e.g., ==Culture==\n...\nOr any other sections you want."></textarea>
- <button type="button" onclick="generateWikiPage()">Generate Wiki Markup</button>
- </form>
- <div id="output"></div>
- <div id="preview">
- <div id="preview-container">
- <div id="sidebar"></div>
- <div id="main-content"></div>
- </div>
- </div>
- <script>
- function generateWikiPage() {
- const title = document.getElementById('title').value;
- const infoboxName = document.getElementById('infoboxName').value;
- const flagUrl = document.getElementById('flagUrl').value;
- const capital = document.getElementById('capital').value;
- const government = document.getElementById('government').value;
- const leader = document.getElementById('leader').value;
- const population = document.getElementById('population').value;
- const currency = document.getElementById('currency').value;
- const introduction = document.getElementById('introduction').value;
- const history = document.getElementById('history').value;
- const geography = document.getElementById('geography').value;
- const economy = document.getElementById('economy').value;
- const additionalSections = document.getElementById('additionalSections').value;
- const infoboxMarkup = `{{Infobox country
- | name = ${infoboxName}
- | image_flag = ${flagUrl}
- | capital = ${capital}
- | government = ${government}
- | leader_title1 = Leader
- | leader_name1 = ${leader}
- | population = ${population}
- | currency = ${currency}
- }}`;
- const fullMarkup = `${infoboxMarkup}\n\n${introduction}\n\n__TOC__\n\n${history}\n\n${geography}\n\n${economy}\n\n${additionalSections}\n\n[[Category:Alternate History]]`;
- document.getElementById('output').textContent = fullMarkup;
- // Simple preview rendering: Convert basic wiki markup to HTML
- function wikiToHtml(text) {
- text = text.replace(/'''(.*?)'''/g, '<strong>$1</strong>'); // Bold
- text = text.replace(/''(.*?)''/g, '<em>$1</em>'); // Italics
- text = text.replace(/\[\[(.*?)\]\]/g, '<a href="#">$1</a>'); // Links (dummy href)
- text = text.replace(/==([^=]+)==/g, function(match, p1) {
- const id = p1.trim().toLowerCase().replace(/\s+/g, '-');
- return `<h2 id="${id}">${p1}</h2>`;
- }); // Headings with anchors
- text = text.replace(/\n/g, '<br>'); // Line breaks
- return text;
- }
- const introHtml = wikiToHtml(introduction);
- const historyHtml = wikiToHtml(history);
- const geographyHtml = wikiToHtml(geography);
- const economyHtml = wikiToHtml(economy);
- const additionalHtml = wikiToHtml(additionalSections);
- // Collect headings for TOC
- const sections = [historyHtml, geographyHtml, economyHtml, additionalHtml].join('');
- const headings = sections.match(/<h2 id="([^"]+)">([^<]+)<\/h2>/g) || [];
- let tocItems = '';
- headings.forEach((heading, index) => {
- const match = heading.match(/<h2 id="([^"]+)">([^<]+)<\/h2>/);
- if (match) {
- tocItems += `<li><a href="#${match[1]}">${index + 1}. ${match[2]}</a></li>`;
- }
- });
- const tocHtml = tocItems ? `
- <div class="toc">
- <h2>Contents</h2>
- <ul>${tocItems}</ul>
- </div>
- ` : '';
- const mainContentHtml = `
- <h1>${title}</h1>
- <div class="infobox">
- <table>
- <tr><th colspan="2">${infoboxName}</th></tr>
- <tr><td colspan="2"><img src="${flagUrl.startsWith('http') ? flagUrl : 'https://via.placeholder.com/220x147?text=Flag'}" alt="Flag"></td></tr>
- <tr><td>Capital</td><td>${capital}</td></tr>
- <tr><td>Government</td><td>${government}</td></tr>
- <tr><td>Leader</td><td>${leader}</td></tr>
- <tr><td>Population</td><td>${population}</td></tr>
- <tr><td>Currency</td><td>${currency}</td></tr>
- </table>
- </div>
- <p>${introHtml}</p>
- ${historyHtml}
- ${geographyHtml}
- ${economyHtml}
- ${additionalHtml}
- <div class="clear"></div>
- `;
- document.getElementById('sidebar').innerHTML = tocHtml;
- document.getElementById('main-content').innerHTML = mainContentHtml;
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment