X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fresources%2Fstatic%2Fjavascript%2Fsone.js;h=a465b247fae2ead5c92c9bcd42bd8a5c04467185;hb=09f7af0f31367709d8eb367b75971210c2fed58b;hp=e422237262173255e8e23ce37d7fc87df612fe7c;hpb=2f07c9c4781a36ef59d2ca7f5ed82b846df14ea3;p=Sone.git diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index e422237..a465b24 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -1037,7 +1037,28 @@ function setActivity() { if (title.indexOf('(') != 0) { document.title = "(!) " + title; } - changeIcon("images/icon-activity.png"); + setTimeout(toggleIcon, 1500); + } +} + +/** Whether the icon is currently showing activity. */ +var iconActive = false; + +/** + * Toggles the icon. If the window has gained focus and the icon is still + * showing the activity state, it is returned to normal. + */ +function toggleIcon() { + if (focus) { + if (iconActive) { + changeIcon("images/icon.png"); + iconActive = false; + } + } else { + iconActive = !iconActive; + console.log("showing icon: " + iconActive); + changeIcon(iconActive ? "images/icon-activity.png" : "images/icon.png"); + setTimeout(toggleIcon, 1500); } }