Skip to content

Instantly share code, notes, and snippets.

@krzysu
Created February 4, 2013 15:17
Show Gist options
  • Save krzysu/4707342 to your computer and use it in GitHub Desktop.
Save krzysu/4707342 to your computer and use it in GitHub Desktop.
manage document title to set info about number of notifications
# manage document title
Title =
regex: /\(\d*\) \| /
# set number of new items in document title
set: (number) ->
# update value
if document.title.match(@regex)?
document.title = document.title.replace(@regex, '(' + number + ') | ')
# set value
else
document.title = '(' + number + ') | ' + document.title
# remove number from title
reset: ->
if document.title.match(@regex)?
document.title = document.title.replace(@regex, '')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment