Removing E-RES PREVIEW items from e-reserve lists

For organizational purposes and to keep control over copyright clearances, we only allow course items on electronic reserve (usually articles) to be visible for the dates the course is active (typically one semester). But understandably, instructors like to be able to see their reserves pages ahead of time and confirm that everything looks and works as expected. In the past, this meant “unhiding” the course page on a specific date so the instructor could check it, and then hiding it again until the official start of the term.

My colleague just came up with a better solution: create a temporary term called “E-RES PREVIEW” which would be open only to the instructor (via password) before the official term begins. Then once the course pages are approved, he would simply move them into the Fall 2018 (etc.) term, which would become visible to students on the first day of that term.

It was a great idea, but it led to E-RES PREVIEW courses cluttering up the course lists generated by the e-reserve software. Could I remove or hide the ones with E-RES PREVIEW from the list, my colleague asked?

It turned out to be a really interesting challenge!

The page looks like this: [screenshot]

My first thought was that it should be easy enough to manipulate the DOM using jQuery (if available, and it is) or vanilla JavaScript to search for the string “E-RES PREVIEW” and remove its parent elements. I tried a few tests and nothing was happening, even with the code enclosed in the $(document).ready function. What’s going on? I tried adding a timer to delay the change by a few seconds, and now I could see the change to the DOM element. Ah. The page is loading its content by JavaScript (ajax) as well, so I need to let it load before I can make changes. The timers will suffice for now, but eventually I’ll probably refactor with setInterval instead.

Next on the list was to figure out what needs to trigger the changes. Obviously going to the URL needs to be a trigger, but so does clicking any of the buttons (Bootstrap “pills”) to navigate to the other tabs. And we also need to make sure that going to the URL associated with each tab triggers the action, just in case someone has the link to a particular tab used or bookmarked somewhere.

Categories:

Updated: