Install Your Own Network Rail Train Delay Excuses Generator On Your Own Website!

This widget has various advantages over attempting to use the official National Rail API, such as: you can install it without any fucking around with registering and licences and all that fucking shite; it is completely self-contained, does not connect to any server other than that of the hosting website and does not support or facilitate the harvesting of personal data; and it is often more informative. It uses the official Network Rail list of excuses for train delays and permutes them using advanced stochastic techniques* to generate an output tuned precisely to the user's state of mind; if, despite this, the user still feels inadequately informed, they can simply request further excuses until they get one they can believe, so satisfaction is guaranteed.

Installing the widget is simplicity itself; it goes like this:

  1. Download the script: train-delay-excuses-2.js and upload it to your server.
  2. Add a SCRIPT tag referring to the script in the HEAD section of the page you wish to embed the generator on, ie. <script type="text/javascript" src="train-delay-excuses-2.js"></script> with the path adjusted to suit your configuration.
  3. Add an empty <div class="excuse_container"></div> to the page wherever you want the generator to appear. The source of this page, of course, provides an example. You can repeat this, and have multiple generators on the same page, if you really want to. They come out looking like the one above right. Edit the CSS near the beginning of the script to change this, at your own peril.
  4. Alternatively, or additionally, use the window.traindelayexcuse() function, which takes no parameters and returns a string containing an excuse, and devise your own means of displaying its output. The ticker below is implemented using this function. Have a look at the page source to see how it works. It also uses a couple of extra scripts: tikka.js tikka-data.js. Note that it stops ticking if it is wholly or partly off screen because it does chew a lot of CPU.

And that's it. Share and enjoy!

There is also a TCP daemon version available, using the same algorithm translated into C. It responds to an incoming connection on its port (default: 46009) by sending an excuse and then closing the connection. This version can, for example, be used to provide a public train delay excuses service by setting it to listen on a public IP, or it can be set to listen on localhost and used to feed excuses to a CGI backend for a web server. Check it out...

telnet pigeonsnest.co.uk 46009

Download the source: tdx.tar.gz

*ie. I wrote it, but I can't understand what it does any more.




Back to Pigeon's Nest


Be kind to pigeons




Valid HTML 4.01!