User:Whiteknight/instructions.js
From Wikibooks, open books for an open world
Note: After saving, changes may not occur immediately. Click here to learn how to bypass your browser's cache.
- Mozilla / Firefox / Safari: hold down Shift while clicking Reload, or press Ctrl-Shift-R (Cmd-Shift-R on Apple Mac);
- Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5;
- Konqueror: simply click the Reload button, or press F5;
- Opera users may need to completely clear their cache in Tools→Preferences.
| Code that you insert on this page could contain malicious content capable of compromising your account. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate reading room. The code will be executed when previewing this page under some skins, including Monobook. |
|
|
Documentation for this script can be added at User:Whiteknight/instructions. |
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>"; } } addOnloadHook(WKCreateInstructionsForm);