From 3c89029015d877e02315150e6566540d38b7e0d7 Mon Sep 17 00:00:00 2001 From: Miguel Angel Mulero Martinez Date: Mon, 26 Oct 2020 09:55:40 +0100 Subject: [PATCH] Replace timeout/interval functions by Node ones --- src/js/main.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/js/main.js b/src/js/main.js index 8e041c8e..0e86d3da 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -4,11 +4,26 @@ window.googleAnalytics = analytics; window.analytics = null; $(document).ready(function () { + + useGlobalNodeFunctions(); + if (typeof cordovaApp === 'undefined') { appReady(); } }); +function useGlobalNodeFunctions() { + // The global functions of Node continue working on background. This is good to continue flashing, + // for example, when the window is minimized + if (GUI.isNWJS()) { + console.log("Replacing timeout/interval functions with Node versions"); + window.setTimeout = global.setTimeout; + window.clearTimeout = global.clearTimeout; + window.setInterval = global.setInterval; + window.clearInterval = global.clearInterval; + } +} + function appReady() { $.getJSON('version.json', function(data) { CONFIGURATOR.version = data.version;