Revision of Twine: ever-growing Jonah (repeats previous visited passages) from Wed, 12/11/2013 - 03:29

Update: this has become the default behaviour in Twine 1.4, so this is no longer necessary.

This code will alter the Jonah format such that:
* All passages are now added to the bottom, regardless of where you click the link.
* Clicking a link to 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. Unlike in those games, this code also preserves the "Rewind to Here" link's functionality.

(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=document.getElementById("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(document.getElementById("passages"),{fade:"out",onComplete:A});
function A(){var p=document.getElementById("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(document.getElementById("passages"),{fade:"in"});}};var ps=document.getElementById("passageStart");if(ps){var res=ps.querySelector(".toolbar a:last-child");
res.onclick=Passage.toolbarItems[1].activate;res.div=ps;}}());

Remember, this goes in a disconnected passage with the tag "script".

Feel free to report any bugs to @webbedspace.