Revision of Twine: Jonah: Disable all links after leaving a passage from Wed, 12/11/2013 - 02:59

Update: The Javascript on this page is now built into Twine 1.4! It is no longer necessary to install it. You can enable this in Twine 1.4 by setting "Undo: off" in the StorySettings passage.

If you're using Jonah, and you're not using single-passage, then you may find this useful. It causes all internal links to behave like the <<choice>> macro. Rather than having to use it constantly, you may include this script:

(function () {
  var d2 = History.prototype.display;
  function closeLinks() {
    var ret = [];
    var l = document.querySelectorAll("#passages .internalLink");
    for(var i = l.length-1; i >= 0; i--) {
      var D = insertElement(null, "span", null, "disabled");
      D.innerHTML = l[i].innerHTML;
      l[i].parentNode.insertBefore(D, l[i].nextSibling);
      ret.push(l[i]);
    }
    return ret;
  }
  History.prototype.display = function (E, C, A) {
    var l = closeLinks();
    var r = d2.call(this, E, C, A);
    l.forEach(function (e) {
      e.parentNode.removeChild(e);
    });
    return r;
  }
}());

This is designed to also work with approximately all of my link macros (<<cyclinglink>>, <<revise>>, <<replace>> etc.)

Version history:

  1. 9-5-13: Initial.

Feel free to report any bugs to @webbedspace.

pensive-mosquitoes