Struggling with this. This is what I have so far:
function swap() {
// Grab the HTML element we are interested in
rightPane = document.getElementById("gamePanesRunning");
// ... and its direct child nodes
nodes = rightPane.childNodes;
// Save the nodes in a new array
var ary = new Array();
s = "Found: " + nodes.length + ". "
for (i = 0; i < nodes.length; i++) {
s += " Got: " + nodes[i].id + " (" + nodes[i].tagName + ")" + ". ";
ary[i] = nodes[i]
}
// Clear the existing content
rightPane.innerHTML = '';
// Add the panes back in, in the new order
// Seem to count spaces as nodes, which gives you 17 nodes, where all the even numbered ones
// can be ignored.
order = [3, 1, 0, 2]
// Internet Explorer gets to here okay
for (i = 0; i < order.length; i++) {
append(rightPane, ary[order[i] * 4 + 1])
append(rightPane, ary[order[i] * 4 + 3])
}
}
function append(root, node) {
root.appendChild(node)
}
This works in the offline game, and in Google when online, but not in Internet Explorer. The problem seems to be in the append function (putting in print statements reveals the code gets to here, then silently gives up). I have tried putting the empty nodes (the even numbered ones) back in, but that does not work either (and you get "undefined" between each pane).
Also tried this (offline panels are reordered but do not work):
root.innerHTML += node.outerHTML
And this (crashes Quest; I think my JavaScript is wrong, but cannot see where):
root.createElement(node.tagName)
for (i = 0; i < node.attributes.length; i++) {
root.setAttribute(node.attributes[i].name, node.attributes[i].value)
}
Any suggests or comments anyone?
The uploaded game is here:
http://play.textadventures.co.uk/v5/Play.aspx?id=986And the test game is here: