Hours widget

When we built the current library webpage in 2021, I wrote a homemade widget in JavaScript to display the library’s hours. It has worked consistently since then without any problems, perhaps surprisingly, since the code is very ugly. This original version of the widget drew upon a custom JSON file with the hours data, which I would have to laboriously reconstruct by hand every semester.

So it was not ideal. None of the other librarians knew the workflow to update the JSON file, because it required steps to validate and format (such as with babeljs.io) before uploading, all of which were a bit arcane. So this summer, I built new version of the widget where mercifully the hours data can be easily updated using the LibCal admin interface. This is an obvious improvement.

I’m still working on the details of the new widget now – especially the CSS – but in some ways the new widget is very similar to the old widget. The most obvious difference is the source of the JSON, which is now accessed with ajax, following the example in this repository. I’ve also taken the opportunity to make the JavaScript a lot nicer, which was of course much easier the second time around.

Anyhow, we hope to have a new hours widget to share with you soon!

This entry was posted in javascript, libguides, widgets. Bookmark the permalink. Both comments and trackbacks are currently closed.
  • Subscribe to this blog

Skip to toolbar