Skip to content

Commit

Permalink
tommoor#19 - bugfix for handling dynamic document titles
Browse files Browse the repository at this point in the history
  • Loading branch information
simong committed Jan 21, 2014
1 parent 46d9ae2 commit 9cc67d6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tinycon.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
var Tinycon = {}; var Tinycon = {};
var currentFavicon = null; var currentFavicon = null;
var originalFavicon = null; var originalFavicon = null;
var originalTitle = document.title;
var faviconImage = null; var faviconImage = null;
var canvas = null; var canvas = null;
var options = {}; var options = {};
Expand Down Expand Up @@ -145,6 +144,14 @@
var updateTitle = function(label) { var updateTitle = function(label) {


if (options.fallback) { if (options.fallback) {
// Grab the current title that we can prefix with the label
var originalTitle = document.title;

// Strip out the old label if there is one
if (originalTitle[0] === '(') {
originalTitle = originalTitle.slice(originalTitle.indexOf(' '));
}

if ((label + '').length > 0) { if ((label + '').length > 0) {
document.title = '(' + label + ') ' + originalTitle; document.title = '(' + label + ') ' + originalTitle;
} else { } else {
Expand Down

0 comments on commit 9cc67d6

Please sign in to comment.