From e1f3d31dead19ee5858f1ba921ea7eab6ab6b4ac Mon Sep 17 00:00:00 2001 From: skj3gg Date: Mon, 28 Jul 2014 13:42:11 -0400 Subject: [PATCH] Add variable for blink interval and remove unnecessary type checking Cleans up global variable that was introduced in favor of a variable in Events. Removes type checking from conditionals and instead sets BLINK_INTERVAL variable to false when stopped. --- script/events.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/script/events.js b/script/events.js index c10ab43..dff0ef7 100644 --- a/script/events.js +++ b/script/events.js @@ -9,6 +9,7 @@ var Events = { _EAT_COOLDOWN: 5, _MEDS_COOLDOWN: 7, STUN_DURATION: 4000, + BLINK_INTERVAL: false, init: function(options) { this.options = $.extend( @@ -727,17 +728,20 @@ var Events = { } }, - //blinks the browser window title + // blinks the browser window title blinkTitle: function() { var title = document.title; - blinkInterval = setInterval(function() { - document.title = '*** EVENT ***'; - setTimeout(function() {document.title = title;}, 1500); + + // every 3 seconds change title to '*** EVENT ***', then 1.5 seconds later, change it back to the original title. + Events.BLINK_INTERVAL = setInterval(function() { + document.title = _('*** EVENT ***'); + setTimeout(function() {document.title = title;}, 1500); }, 3000); }, stopTitleBlink: function() { - clearInterval(blinkInterval); + clearInterval(Events.BLINK_INTERVAL); + Events.BLINK_INTERVAL = false; }, // Makes an event happen! @@ -803,7 +807,7 @@ var Events = { $('div#wrapper').append(Events.eventPanel()); Events.eventPanel().animate({opacity: 1}, Events._PANEL_FADE, 'linear'); var currentSceneInformation = Events.activeEvent().scenes[Events.activeScene]; - if (typeof currentSceneInformation.blink == 'boolean' && currentSceneInformation.blink == true) { + if (currentSceneInformation.blink) { Events.blinkTitle(); } } @@ -823,7 +827,7 @@ var Events = { Events.eventStack.shift(); Engine.log(Events.eventStack.length + ' events remaining'); Engine.keyLock = false; - if (typeof blinkInterval != 'undefined') { + if (Events.BLINK_INTERVAL) { Events.stopTitleBlink(); } // Force refocus on the body. I hate you, IE.