From 7d12ad2cccddffb7f38c266cb554fc52f2d6b1fe Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 28 Jan 2011 07:29:01 +0100 Subject: [PATCH 1/1] Wrap setting the document title into an own function to work around bugs in Chrome. --- src/main/resources/static/javascript/sone.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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; -- 2.7.4