Prevent multiple blink cycles happening simultaneously.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 27 Jan 2011 13:39:48 +0000 (14:39 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 27 Jan 2011 13:39:48 +0000 (14:39 +0100)
src/main/resources/static/javascript/sone.js

index 0bed52b..254c0c3 100644 (file)
@@ -1036,13 +1036,19 @@ function setActivity() {
                if (title.indexOf('(') != 0) {
                        document.title = "(!) " + title;
                }
-               setTimeout(toggleIcon, 1500);
+               if (!iconBlinking) {
+                       setTimeout(toggleIcon, 1500);
+                       iconBlinking = true;
+               }
        }
 }
 
 /** Whether the icon is currently showing activity. */
 var iconActive = false;
 
+/** Whether the icon is currently supposed to blink. */
+var iconBlinking = false;
+
 /**
  * Toggles the icon. If the window has gained focus and the icon is still
  * showing the activity state, it is returned to normal.
@@ -1053,6 +1059,7 @@ function toggleIcon() {
                        changeIcon("images/icon.png");
                        iconActive = false;
                }
+               iconBlinking = false;
        } else {
                iconActive = !iconActive;
                console.log("showing icon: " + iconActive);