Suggested Improvement: Flashing favicon when message received? (Code inside)

Being the type of person to obsess over any given campaign, I tend to keep Triton running in a separate tab at almost all times. With that in mind, I made a little PoC script for having the icon in tab bar flash when a message has been received: GitHub - perrycate/Flashing-Favicon-Example: POC to remind myself later how to make a tab's icon flash

I just spent a couple minutes in MS Paint (or rather the linux equivalent) darkening the existing icon, and this script switches between the two at a set interval until it is told to stop. I used javascript’s setInterval, but since triton already has timekeeping mechanisms, you could probably just tie the icon-switching part into an existing method. My knowledge of the Triton codebase is very limited, but I would guess that you could tie this in to inboxTabs.onOneSecondTick around line 3875 in interface_screens.js, something like:

if(inbox.unreadDiplomacy > 0 || inbox.unreadEvents > 0) {
    if(inboxTabs.tickCount % 2) {
        icon.href = "images/original.ico";
    } else {
        icon.href = "images/flash.ico";
    }
} else {
    icon.href = "images/original.ico";
}

It’s quite likely there’s a better place for it than the inboxTabs.onOneSecondTick function, but you get the idea regardless. I tried to find the area specifically responsible for the flashing inbox icon itself, but saw this first and was lazy ;).

Any feedback is appreciated, I’m pretty tired today so I hope there’s not something simple I’m overlooking.

3 Likes

@JayKyburz