Revision of Twine: ever-growing Jonah from Sun, 03/10/2013 - 06:35

This code will alter the Jonah format such that:
* All passages are now added to the bottom, regardless of where you click the link.
* Revisiting a previously displayed passage will display a new version of the passage at the bottom, instead of scrolling up to the old version.

This is based on a bit of code used by E. Turner in some of his Twine games.

(function(){var ppr=Passage.prototype.render;Passage.prototype.render=function(){var e=ppr.call(this);
var rew=e.querySelector(".toolbar a:last-child");rew.div=e;return e;};var hpd=History.prototype.display;
History.prototype.display=function(E,C,A){var el;if(el=$("passage"+E)){el.id+=(new Date).getTime();
}return hpd.call(this,E,null,A);};Passage.toolbarItems[1].activate=function(){state.rewindTo(this);
};History.prototype.rewindTo=function(C){var B=this;fade($("passages"),{fade:"out",onComplete:A});
function A(){var p=$("passages");while(p.lastChild!=C.div){p.removeChild(p.lastChild);
B.history.shift();}B.history[0].variables=clone(B.history[1].variables);C.passage.reset();
var E=C.div.querySelector(".body");if(E){removeChildren(E);new Wikifier(E,C.passage.text);
}fade($("passages"),{fade:"in"});}};var ps=$("passageStart");var res=ps.querySelector(".toolbar a:last-child");
res.onclick=Passage.toolbarItems[1].activate;res.div=ps;}());