User:EnDumEn/doublepage.js
From Wikisource
Note: After saving, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Konqueror: Click Reload or press F5
- Opera: Clear the cache in Tools → Preferences
var xmlhttp; function compare(url) { if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); xmlhttp.onreadystatechange=xmlhttpChange; xmlhttp.open("GET", url, true); xmlhttp.send(null); } } function xmlhttpChange() { if (xmlhttp.readyState==4) { if (xmlhttp.status==200) { var content = document.getElementById('content'); var table = document.createElement('table'); var tr = document.createElement('tr'); tr.setAttribute('valign', 'top'); var td = document.createElement('td'); td.setAttribute('width', '50%'); var bodycontent = document.getElementById('bodyContent'); td.appendChild(bodycontent); tr.appendChild(td); td = document.createElement('t'); td.setAttribute('width', '50%'); var viewdiv = document.createElement('div'); viewdiv.innerHTML = xmlhttp.responseText.match("<!-- start content -->(.|\n)*<!-- end content -->"); td.appendChild(viewdiv); tr.appendChild(td); table.appendChild(tr); content.appendChild(table); } else { alert("Problem retrieving XML data" + xmlhttp.status); } } } /* add form */ function addcompareform() { var form = document.createElement('form'); form.setAttribute('id', 'compareForm'); var inp = document.createElement('input'); inp.setAttribute('id', 'compareInput'); inp.setAttribute('type', 'text'); form.appendChild(inp); inp = document.createElement('input'); inp.setAttribute('id', 'compareButton'); inp.setAttribute('type', 'button'); inp.setAttribute('value', 'show'); inp.onclick = function() { compare("http://en.wikisource.org/wiki/" + document.getElementById('compareInput').value) }; form.appendChild(inp); var tabs = document.getElementById('contentSub'); tabs.appendChild(form); } if (window.addEventListener) window.addEventListener("load",addcompareform,false); else if (window.attachEvent) window.attachEvent("onload",addcompareform);