From: David ‘Bombe’ Roden Date: Fri, 28 Jan 2011 06:29:01 +0000 (+0100) Subject: Wrap setting the document title into an own function to work around bugs in Chrome. X-Git-Tag: 0.4.4^2~17 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=7d12ad2cccddffb7f38c266cb554fc52f2d6b1fe;p=Sone.git Wrap setting the document title into an own function to work around bugs in Chrome. --- diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index 656e22c..fb16b97 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -1035,7 +1035,7 @@ function markReplyAsKnown(replyElements) { function resetActivity() { title = document.title; if (title.indexOf('(') == 0) { - document.title = title.substr(title.indexOf(' ') + 1); + setTitle(title.substr(title.indexOf(' ') + 1)); } } @@ -1043,7 +1043,7 @@ function setActivity() { if (!focus) { title = document.title; if (title.indexOf('(') != 0) { - document.title = "(!) " + title; + setTitle("(!) " + title); } if (!iconBlinking) { setTimeout(toggleIcon, 1500); @@ -1052,6 +1052,18 @@ function setActivity() { } } +/** + * Sets the window title after a small delay to prevent race-condition issues. + * + * @param title + * The title to set + */ +function setTitle(title) { + setTimeout(function() { + document.title = title; + }, 50); +} + /** Whether the icon is currently showing activity. */ var iconActive = false;