From 051555ef1420954c5cce1d3d441c72f3c5a66c17 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 23 Jul 2020 20:54:25 -0400 Subject: [PATCH] Prevent overloading of window.onload --- WebHostLib/static/tracker.js | 10 +++------- WebHostLib/static/uploads.js | 4 ++-- WebHostLib/static/view_seed.js | 4 ++-- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/WebHostLib/static/tracker.js b/WebHostLib/static/tracker.js index 8cf5ae5f..eebd1552 100644 --- a/WebHostLib/static/tracker.js +++ b/WebHostLib/static/tracker.js @@ -1,7 +1,5 @@ -let tables = null; - -window.onload = () => { - tables = $(".table").DataTable({ +window.addEventListener('load', () => { + const tables = $(".table").DataTable({ paging: false, info: false, scrollCollapse: true, @@ -37,6 +35,4 @@ window.onload = () => { y_sync: true, x_sync: true }); - - window.onresize = () => tables.draw(); -} +}); diff --git a/WebHostLib/static/uploads.js b/WebHostLib/static/uploads.js index 81f6efc9..14a63d44 100644 --- a/WebHostLib/static/uploads.js +++ b/WebHostLib/static/uploads.js @@ -1,4 +1,4 @@ -window.onload = () => { +window.addEventListener('load', () => { document.getElementById('upload-button').addEventListener('click', () => { document.getElementById('file-input').click(); }); @@ -14,4 +14,4 @@ window.onload = () => { "info": false, "dom": "t", }); -}; +}); diff --git a/WebHostLib/static/view_seed.js b/WebHostLib/static/view_seed.js index f1ed8b71..57711dcc 100644 --- a/WebHostLib/static/view_seed.js +++ b/WebHostLib/static/view_seed.js @@ -1,6 +1,6 @@ -window.onload = () => { +window.addEventListener('load', () => { const timeElement = document.getElementById('creation-time'); const creationTime = timeElement.getAttribute('data-creation-time'); const creationDate = new Date(creationTime); timeElement.innerText = creationDate.toLocaleString(); -}; +});