Use page visibility API instead of buggy window.focus tracking
This commit is contained in:
parent
60a39890f0
commit
cd94c8b83d
|
@ -2,7 +2,7 @@
|
|||
"author": "Calvin Montgomery",
|
||||
"name": "CyTube",
|
||||
"description": "Online media synchronizer and chat",
|
||||
"version": "3.60.1",
|
||||
"version": "3.60.2",
|
||||
"repository": {
|
||||
"url": "http://github.com/calzoneman/sync"
|
||||
},
|
||||
|
|
14
www/js/ui.js
14
www/js/ui.js
|
@ -1,12 +1,18 @@
|
|||
/* window focus/blur */
|
||||
$(window).focus(function() {
|
||||
if (typeof document.hidden === "undefined") {
|
||||
console.error("Browser is too old; giving up on visibility tracking for notifications");
|
||||
} else {
|
||||
document.addEventListener("visibilitychange", function () {
|
||||
if (document.hidden) {
|
||||
FOCUSED = false;
|
||||
} else {
|
||||
FOCUSED = true;
|
||||
clearInterval(TITLE_BLINK);
|
||||
TITLE_BLINK = false;
|
||||
document.title = PAGETITLE;
|
||||
}).blur(function() {
|
||||
FOCUSED = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$("#togglemotd").click(function () {
|
||||
var hidden = $("#motd").css("display") === "none";
|
||||
|
|
Loading…
Reference in a new issue