var BookName, BookNameE;
var gml_xmlhttp;
var res;
function WKPrepBook(form) {
BookName = form.WKBookName.value;
BookNameE = BookName.replace(" ", "_");
res = document.getElementById('WKInstructionsSpan');
if(res) {
gml_xmlhttp = HTTPClient();
if (!gml_xmlhttp) {
alert("xml thingy does not work");
return;
}
gml_xmlhttp.open("GET", "http://en.wikibooks.org/w/index.php?title=User:Whiteknight/Creation_Instructions_Stub&action=raw&oldid=887618", true);
gml_xmlhttp.onreadystatechange = WKPrepBook2;
gml_xmlhttp.send(null);
} else {
alert("No WKInstructionsSpan element!");
}
}
function WKPrepBook2() {
if (gml_xmlhttp.readyState != 4) {
return;
}
var xml = gml_xmlhttp.responseText;
xml = xml.replace(/%1/g, BookName);
xml = xml.replace(/%2/g, BookNameE);
res.innerHTML = xml;
}
function WKCreateInstructionsForm() {
var form_span = document.getElementById('WKInstructionsForm');
if (form_span) {
form_span.innerHTML = "<FORM NAME=\"WKBookForm\" ACTION=\"\" METHOD=\"GET\">" +
"Enter the name of your new book: <BR>" +
"<INPUT TYPE=\"text\" NAME=\"WKBookName\" VALUE=\"\"> " +
"<INPUT TYPE=\"button\" NAME=\"WKBookSubmit\" Value=\"Create\" " +
"onClick=\"WKPrepBook(this.form)\"><INPUT TYPE=\"button\" "+
"NAME=\"WKBookClear\" VALUE=\"Clear\" " +
"onClick=\"ClearSpan('WKInstructionsSpan')\"></FORM>";
}
}
$(WKCreateInstructionsForm);