/// THEME-COMMON
function switchTheme (theme,variation) {
var form = document.forms["theme-switcher"];
form.elements["new-theme"].value = theme;
form.elements["new-variation"].value = variation;
form.submit(); }
// Haverbeke's 'registerEventHandler' function (renamed)
function addEventHandler(node, event, handler) {
if (typeof node.addEventListener == "function")
node.addEventListener(event, handler, false);
else
node.attachEvent ("on"+event, handler); } // IE
function escapeForPosting(string) {
string = string.replace(/"/g,"\\\"");
return string; }
function commandLineInput() {
return document.getElementById("command-line"); }
function commandLinePost() {
var xhr = new XMLHttpRequest(); // .------------.
xhr.open("POST", "/xhr/parse-command", false); // synchronous
xhr.send(escapeForPosting(commandLineInput().value));
var response = xhr.responseText;
if (xhr.status == 200)
document.location = xhr.responseText;
else {
console.log(response);
alert("XMLHttpRequest error: " + xhr.status); } }
var commandLineRetListener = function (event) {
event = event || window.event;
var charCode = event.charCode || event.keyCode;
if (charCode == 13) { // RET
event.preventDefault(); // suppress newline
commandLinePost(); } };
]]>