function resetActivity() {
title = document.title;
if (title.indexOf('(') == 0) {
- document.title = title.substr(title.indexOf(' ') + 1);
+ setTitle(title.substr(title.indexOf(' ') + 1));
}
}
if (!focus) {
title = document.title;
if (title.indexOf('(') != 0) {
- document.title = "(!) " + title;
+ setTitle("(!) " + title);
}
if (!iconBlinking) {
setTimeout(toggleIcon, 1500);
}
}
+/**
+ * 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;