Bookmarklet to search Google Books from an HTML element

Install the bookmarklet by dragging the link to your bookmarks toolbar:

Or, create a bookmark manually, and change the Location property to the following:


To use it, go to a page which has an element with an id of “isbn” then click on the bookmark.

You can edit the bookmark if the id is called something else (change the bit in brackets and quotes from isbn to something else) or you want to search on another index (change q=isbn to q=somethingelse).

Automatic table of contents for RDA Toolkit workflows

Below is described a way to add tables of contents to RDA Toolkit workflows automatically, i.e. without manually adding anchors and creating a list. You can see an example of it action on this workflow (although of course I can’t guarantee that this workflow will always be around or look like this).

It uses some Javascript but requires no knowledge of it as it can be dropped in. It is 95% a script written by Stuart Langridge (@sil) with some minor amendments to get round some strange internal linking behaviour and to provide links to the top of the document throughout the workflow.

Instructions follow and some caveats are below.

  1. Open an RDA Toolkit workflow for editing
  2. Click on Source
  3. Insert the following snippet of HTML where you want the table of contents to appear:
    <div class="generate_from_h2" id="generated-toc"><a name="top"></a></div>
  4. If you have access to a local web server:
    1. Copy the Javascript file generate_toc_rda.js and put it somewhere sensible.
    2. At the very end of the workflow, put the following HTML snippet, changing the URL to where your copy of generate_toc_rda.js now lives:
      <script type="text/javascript" src=""></script>
  5. If you don’t have access to a local server:
    1. At the very end of the workflow, put the following HTML snippet:
      <script type="text/javascript">
    2. Copy the complete contents of the Javascript file generate_toc_rda.js and paste it on the next line. There will be a lot of it.
    3. On another line underneath, i.e. right at the end, put the following snippet of HTML:
  6. Save the workflow.
  7. Click on the workflow in the Toolkit to refresh it.
  8. Buy Stuart some beer next time you see him, e.g. some gueuze, or give him some custom.

Caveats: it is not official and while the script was designed to work on any web page, these things always depend on the approach taken by the encompassing page to be logical and consistent over time, and this can be particularly unpredictable in a CMS, which the Toolkit basically is. I am also unsure of the publisher’s attitude towards dropping Javascript into workflows, although cannot see why there should necessarily be objections to this. Lastly, using this approach also means  removing any existing apparatus of table of contents or links to the top. It would be advisable to back up everything, including the source of generated tocs, although in the worst case, it would probably be possible to move the contents of a workflow to an external file, run the toc script on it, then re-import the HTML source.

Please do let me know if you try this and how you get on. I might be amenable to making changes to it, time and circumstances allowing. Stuart released the original toc script “under an X11 licence. What this boils down to is: do what you like with it. You can use the script in commercial environments, you can use it on your intranet, you can use it anywhere you like.” Sounds good to me too.

MARC Viewer Codecademy Project

I have created a Codecademy project (with a lot of help in corrections and improvements from Esther Arens!) that builds a short script to read a raw MARC record and display it in a more readable format. Try it here:

This is not by no means the last word in reading a MARC file and is basically a walk through of one way to do it. There are other ways and better ways that use more advanced coding, or allow more sophisticated re-use of the bits and pieces that are pulled out of the MARC record. There are also entire programmes and programming utilities designed to do this kind of thing and to manipulate MARC records, not least library management systems and things like MARCEdit. Moreover, there are limitations in formatting on the Codecademy platform that can easily be overcome by adapting the script to be run directly in an HTML file (I have done a direct simple adaptation without any further elaboration (view the HTML source to see the code and the alterations)).

I hope, if nothing else, that it gives cataloguing coders an idea of what a MARC21 record looks like under the hood and helps clarify the cataloguer’s opinions as to whether MARC must or mustn’t die. (HINT: it must).

Please see the following notes below before proceeding:

1. This project was designed for someone who has done the first few weeks of the Code Year course. By necessity it introduces some new things and an attempt has been made to explain them and encourage the cataloguer to enter the actual lines of Javascript that make up the programme. In any case, the Hints always contain the correct code needed to proceed.

2. Output will often consist of many lines, so sometimes you will have to scroll up in the console to see what has happened.

3. Some lines (including line 1!) will always produce errors, although the script will still run. This will is because MARC uses BAD and DANGEROUS characters. BAD and DANGEROUS characters are of course common in the world of cataloguing (mentioning no names…).

There are many ways this could be improved or extended if you wanted the challenge, e.g.:

  • Take the HTML version and use more HTML and CSS to make it clearer and prettier (e.g. more spacing, colour, bolding of codes). Try making it look like a specific LMS editing screen.
  • Make it capture the elements in more detail and in a more re-usable way. For instance, try making each field an object with tags, indicators, subfields, etc. as properties. This would enable more interesting things, such as…
  • A simple OPAC or even a card index display.
  • Adapt it to read MARC files with more than one record. This isn’t as hard as it sounds, in that each record ends with a specific terminator (see the guide to record structure below).

For full technical details of how a MARC21 bibliographic record is put together, see the MARC 21 Specifications for Record Structure, Character Sets, and Exchange Media Record Structure. For details of the contents and use of MARC21 fields, see LC’s MARC Standards page. For a HTML version of the completed MARC Viewer script, see my adaptation.

The Code Year programme is part of Codecademy, an online set of programming lessons. Cataloguers interested in learning to programme will find the independent CatCode Wiki useful for extra information, advice, and support. See also the #catcode hashtag on Twitter.

Do let me know if you come across any problems with it or have any comments on the project.

Thank you again to Esther for her help.!/EstherArensEstter

Flexi hours calculator (online and for Excel)

I have tidied up and moved my ancient flexi hours calculator which now lives at Several people have emailed me out of the blue recently about setting up an Excel version, which I have done and which now lives at

This is a version of one of the oldest useful programmes I ever wrote. My dad used to manage an office where everyone filled in paper flexi-time forms. My dad then had to add them all up at the end of every week, which he did manually. I wrote something in AmigaBasic to make it easier for him. The main point of it was that it had to be easy and quick to enter the times in, which is why it uses the simple four figure times and no drop downs (although I’m not sure how or if you can do drop down lists in AmigaBasic (nor do I intend to find out now)). Eventually my dad got the IT people at work to replace their version of a flexi calculator with something based instead on mine, which is silly considering how simple this was. Sometime after starting at my current employer (1997), I thought it would be a useful exercise to convert the programme to work on the web as I was learning Javascript at the time. It still exists and hasn’t changed a lot since then, barring a bit of explanation and some atrocious styling: the last time that file was touched was in 2003.

Although it is really hard to find (I can never remember where I left it and it seems impossible to Google), people do seem to come across it quite often and find it useful. I’ve been emailed a couple of times about getting bespoke versions done in Excel which led me to create a version initially to record multiple users, and another with additional days and more complicated working patterns. I’ve put a more standard version up with seven days and two sessions per day. It can easily be altered if you’re into Excel or, if you have something particular in mind, do let me know and I might be able to do something with it.

The original online version is written in Javascript. If you’re learning Javascript, please don’t look at it as it is a most outdated and inefficient way of adding Javascript to a webpage. However, it works, and the effort of making it all elegant would I think be counterproductive. It works on the idea that the first two digits of a four digit time (HHMM) are hours, the second two digits minutes. It converts these both to minutes (HH * 60 + MM) and does all the necessary maths. The slightly more tricky bit is converting a total of minutes back into hours and minutes. This is one rare (for me) real life use of the modulo (%) operation (although looking at the code source I seem to have invented my own weird convoluted version of the same thing). If you have x number of minutes, the number of hours will be x divided by 60 with any remainder taken off, i.e. Math.floor(x / 60); the number of minutes will be that remainder, i.e. x % 60. These can be put together into a pretty string.

I’m always interested to know if people find this useful, come across problems with it, or would find a slightly different version useful.

Tom's Excellent Website Snow (using Greasemonkey)

Behold: a version of Tom’s Excellent Javascript Snow (unobtrusive and customisable javascript snow for web pages using no images) that works on all websites you open on your browser (provided your browser is Firefox or something else that can run Greasemonkey scripts)!

To install it:

  1. Install Greasemonkey add-on for Firefox:
  2. Make sure the monkey (probably at the top-right) is happy and colourful. Click on it if not.
  3. Install the tomsnow script by going to then
  4. Click on the Install button.
  5. Go and look at a new web page or reload one.

If you want to turn Greasemonkey off altogether, click on the monkey so he’s grey. If you want to stop individual scripts, click on the monkey, click on Manage User Scripts, and click on Disable next to the script.

These instructions were tested on Firefox 3.6.24 on Linux although I imagine they would be fine on any recent version of Firefox. I would be interested to hear anything confirming or undermining that assertion.

If you’re happy to play around, the snow is very customisable: you can easily alter the amount, speed, and style of snow, and so forth:

  1. Click on the monkey
  2. Click on Manage User Scripts
  3. Select tomsnow from the list
  4. Click on Options
  5. Click on Edit this user script (you will probably have to select a text editor at this point)
  6. Look for the section under the line of asterisks where more instructions can be found on how to make customisations.
  7. Save the file and reload any pages to see changes.

The Greasemonkey version of the script uses slightly different default settings to the previous version, in particular using a lower density of flakes as a huge blizzard of snow is not likely to be welcome if used on all sites one browses.

I haven’t found any particular problems and it doesn’t seem to stop any sites working although sites that are already very script heavy are obviously less happy about running more, e.g. Twitter which is fine but can get sticky, although Gmail seems curiously OK. My cPanel was the only one which was really not happy. When you manage a Greasemonkey script, you will see a box where you can specify websites that you don’t want it to work on. For example, put* and it will stop tomsnow working on that URL with anything after it.


Tom's Excellent Javascript Snow

Behold: Tom’s Excellent Javascript Snow: unobtrusive and customisable javascript snow for web pages using no images! If you’re looking at this directly, rather than through an RSS aggregator, you should see it falling now. Unless, that is, you’re watching this on Dave, in which case it will be some time past Christmas and I might have taken the snow away again. However, it always snowing at Tom’s Excellent Javascript Snow page!

I’ve been meaning to write this since last year when my attempts were full of fail. The idea was to create simple unobstrusive javascript snow that could be added to any page and that didn’t require any images. I think Tom’s Excellent Javascript Snow fulfills these criteria and is therefore full of win. Furthermore, it is very customisable, so you can easily alter the amount, speed, and style of snow, and so forth. Incidentally, it uses the asterisk character (*) by default. There is in fact a Unicode Tight Trifoliate Snowflake character, but it is only available in a few fonts by the looks of it and I haven’t tried it. The script depends on the DOM and kind of uses CSS, but it is all defined through the Javascript: so many of the properties are different for individual snowflakes or change while the script is running, that it is not worth having a general style. It also means you only need one file to do everything.

To use it, copy tomsnow_v1.js to a directory on your web-server, and add the following code to the head of any pages on which you would like snow:

<script type=”text/javascript” src=””></script>
<script type=”text/javascript”>
function init () {

I’m sure Stuart will tell me there’s a better way of doing it…

I know this works on Firefox 2 and Internet Explorer 6 on Windows as well as Firefox 3 on Linux.

In the unlikely event you do use this, do let me know for the sake of my own vanity. Any comments generally are welcome. I do have some ideas for version 2, maybe for next year, mostly around wind effects such as better horizontal drifting, prevailing winds, and gusts. Ideally, I would like to make the snow lay in some way, as in the snow at St Pancras (you might have to wait for it to kick in), but that is quite unlikely given the trouble I had with page heights as it was.