diff options
author | Minteck <46352972+Minteck@users.noreply.github.com> | 2021-07-20 01:30:23 +0200 |
---|---|---|
committer | Minteck <46352972+Minteck@users.noreply.github.com> | 2021-07-20 01:30:23 +0200 |
commit | 44210691ee8444509ac466a362337af77f2bcd49 (patch) | |
tree | 4dc2f242cf5fd4daa3fc6f9e42516e7d55b73538 /views/script/core_stats.js | |
parent | efa5fc926071de7087836d399c42f53e701b4cff (diff) | |
download | kartik-client-44210691ee8444509ac466a362337af77f2bcd49.tar.gz kartik-client-44210691ee8444509ac466a362337af77f2bcd49.tar.bz2 kartik-client-44210691ee8444509ac466a362337af77f2bcd49.zip |
Commit
Diffstat (limited to 'views/script/core_stats.js')
-rw-r--r-- | views/script/core_stats.js | 64 |
1 files changed, 34 insertions, 30 deletions
diff --git a/views/script/core_stats.js b/views/script/core_stats.js index c8d26df..930c776 100644 --- a/views/script/core_stats.js +++ b/views/script/core_stats.js @@ -6,42 +6,46 @@ timer = null; current = null; webview.addEventListener('dom-ready', () => { - if (webview.getURL() !== current) { - if (session !== null) { - require('electron').ipcRenderer.send('addstats', { catalog: "times", key: session, add: Math.floor((new Date() - timer)/1000) }); + try { + if (webview.getURL() !== current) { + if (session !== null) { + require('electron').ipcRenderer.send('addstats', { catalog: "times", key: session, add: Math.floor((new Date() - timer)/1000) }); - session = null; - timer = null; - current = null; + session = null; + timer = null; + current = null; + } } - } - if (webview.getURL().endsWith("game.html")) { // Local - session = "local"; - timer = new Date(); - current = webview.getURL(); - } - if (webview.getURL().endsWith("game.html?sp")) { // Singleplayer - session = "single"; - timer = new Date(); - current = webview.getURL(); - } - if (webview.getURL().endsWith("game.html?online")) { // Online - session = "online"; - timer = new Date(); - current = webview.getURL(); - } + if (webview.getURL().endsWith("game.html")) { // Local + session = "local"; + timer = new Date(); + current = webview.getURL(); + } + if (webview.getURL().endsWith("game.html?sp")) { // Singleplayer + session = "single"; + timer = new Date(); + current = webview.getURL(); + } + if (webview.getURL().endsWith("game.html?online")) { // Online + session = "online"; + timer = new Date(); + current = webview.getURL(); + } + } catch (e) {} }) window.addEventListener("beforeunload", function(e){ - if (session !== null) { - require('electron').ipcRenderer.send('addstatsandclose', { catalog: "times", key: session, add: Math.floor((new Date() - timer)/1000) }); + try { + if (session !== null) { + require('electron').ipcRenderer.send('addstatsandclose', { catalog: "times", key: session, add: Math.floor((new Date() - timer)/1000) }); - session = null; - timer = null; - current = null; + session = null; + timer = null; + current = null; - e.preventDefault(); - return false; - } + e.preventDefault(); + return false; + } + } catch (e) {} }, false);
\ No newline at end of file |