User:EnDumEn/doublepage.js

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("(.|\n)*");

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);