Show/update number of pending discussions in page title
pvds on MM:Submitted by Elmer van Chastelet on 8 September 2020 at 15:08
As a TA I use the discussions tab on WebLab a lot, which works great. There are also some labs that have ‘lab sessions’ where we are online to answer questions. Some of those labs are more quiet than others, so I’m not checking the discussions page all the time.
Would it be possible to prepend the number of pending discussions to document.title, sort of like Slack and Mattermost do? Adapting the current implementation might be a bit hacky though. If it’s not possible, then by all means ignore this request :slightly_smiling_face:
Tried some stuff, it might be possible to add this to the end of the table refresh function. Warning: it’s hacky as heck :innocent:
var numberOfPending = $("table:visible tbody").find('tr:not(.comment-answered)').length; document.title = "(" + numberOfPending + ") " + document.title.match(/(\(\d+\)\s+)?(.+)/);
The regex matching cuts of the part between parentheses so it’s always reset properly.