Skip to content

Instantly share code, notes, and snippets.

@kladov
Created June 24, 2014 18:48
Show Gist options
  • Save kladov/92f163ab2f1250143b07 to your computer and use it in GitHub Desktop.
Save kladov/92f163ab2f1250143b07 to your computer and use it in GitHub Desktop.
newExcitingAlerts = (function () {
var oldTitle = document.title;
var msg = "New!";
var timeoutId;
var blink = function() { document.title = document.title == msg ? ' ' : msg; };
var clear = function() {
clearInterval(timeoutId);
document.title = oldTitle;
window.onmousemove = null;
timeoutId = null;
};
return function () {
if (!timeoutId) {
timeoutId = setInterval(blink, 1000);
window.onmousemove = clear;
}
};
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment