From 9b36247f8f4f5d6416f080ee7128008b18c4a21b Mon Sep 17 00:00:00 2001 From: peregrineshahin <41402573+peregrineshahin@users.noreply.github.com> Date: Thu, 11 Jul 2024 11:31:06 +0300 Subject: [PATCH] Use an IIFE to Reduce Global Scope Pollution --- server/fishtest/static/js/application.js | 10 +- server/fishtest/static/js/spsa.js | 2 +- server/fishtest/templates/contributors.mak | 3 +- server/fishtest/templates/tests.mak | 134 +-- server/fishtest/templates/tests_live_elo.mak | 8 +- server/fishtest/templates/tests_run.mak | 684 ++++++------ server/fishtest/templates/tests_view.mak | 973 +++++++++--------- server/fishtest/templates/user.mak | 40 +- server/fishtest/templates/user_management.mak | 41 +- server/fishtest/templates/workers.mak | 98 +- 10 files changed, 993 insertions(+), 1000 deletions(-) diff --git a/server/fishtest/static/js/application.js b/server/fishtest/static/js/application.js index d1fa8e0f3..ccfa51c5d 100644 --- a/server/fishtest/static/js/application.js +++ b/server/fishtest/static/js/application.js @@ -375,8 +375,7 @@ function padDotVersionStr(dn) { } // Filters tables client-side -function filterTable(inputValue, tableId, originalRows, predicate) { - const table = document.getElementById(tableId); +function filterTable(inputValue, table, originalRows, predicate) { const tbody = table.querySelector("tbody"); let noDataRow = table.querySelector(".no-data"); inputValue = inputValue.toLowerCase(); @@ -442,13 +441,12 @@ function filterTable(inputValue, tableId, originalRows, predicate) { }); }; - const originalTable = document - .getElementById("my_table") - .cloneNode(true); + const originalTable = document.getElementById("my_table").cloneNode(true); const originalRows = Array.from(originalTable.querySelectorAll("tbody tr")); - const searchInput = document.getElementById("my_input"); + searchInput.addEventListener("input", (e) => { + const myTable = document.getElementById("my_table"); filterTable(e.target.value, "my_table", originalRows, myPredicate); }); })(); diff --git a/server/fishtest/static/js/spsa.js b/server/fishtest/static/js/spsa.js index 575f6a602..e9d20c7f8 100644 --- a/server/fishtest/static/js/spsa.js +++ b/server/fishtest/static/js/spsa.js @@ -1,4 +1,4 @@ -async function handleSPSA() { +async function handleSPSA(spsaData) { let raw = [], chart_object, chart_data, diff --git a/server/fishtest/templates/contributors.mak b/server/fishtest/templates/contributors.mak index b619c2413..b030ff82e 100644 --- a/server/fishtest/templates/contributors.mak +++ b/server/fishtest/templates/contributors.mak @@ -29,7 +29,8 @@ const searchInput = document.getElementById("search_contributors"); searchInput.addEventListener("input", (e) => { - filterTable(e.target.value, "contributors_table", originalRows, includes); + const contributorsTable = document.getElementById("contributors_table"); + filterTable(e.target.value, contributorsTable, originalRows, includes); }); })(); diff --git a/server/fishtest/templates/tests.mak b/server/fishtest/templates/tests.mak index 3e486fed7..9dade538e 100644 --- a/server/fishtest/templates/tests.mak +++ b/server/fishtest/templates/tests.mak @@ -47,72 +47,6 @@ - -

${str(run['_id'])}

diff --git a/server/fishtest/templates/tests_run.mak b/server/fishtest/templates/tests_run.mak index 744ecb782..aa43ab08a 100644 --- a/server/fishtest/templates/tests_run.mak +++ b/server/fishtest/templates/tests_run.mak @@ -673,389 +673,389 @@ + + - + document.getElementById('checkbox-book-visibility').addEventListener("change", (e) => { + toggleBook(e.target); + }); - diff --git a/server/fishtest/templates/tests_view.mak b/server/fishtest/templates/tests_view.mak index 8ecd01730..21c78b2f0 100644 --- a/server/fishtest/templates/tests_view.mak +++ b/server/fishtest/templates/tests_view.mak @@ -6,64 +6,6 @@ <%namespace name="base" file="base.mak"/> - - -% if show_task >= 0: - -% endif - -% if follow == 1: - -% else: - -% endif - -% if 'spsa' in run['args']: - - - - - - -% else: - -% endif - + +% if 'spsa' in run['args']: + + +% endif + diff --git a/server/fishtest/templates/user.mak b/server/fishtest/templates/user.mak index 1172e4a0e..7ff4e3eb2 100644 --- a/server/fishtest/templates/user.mak +++ b/server/fishtest/templates/user.mak @@ -4,26 +4,26 @@ from fishtest.util import format_group %> -% if profile: - -% else: - -% endif +
diff --git a/server/fishtest/templates/user_management.mak b/server/fishtest/templates/user_management.mak index 095c939f9..c7d557031 100644 --- a/server/fishtest/templates/user_management.mak +++ b/server/fishtest/templates/user_management.mak @@ -5,29 +5,30 @@ %>

User Management

diff --git a/server/fishtest/templates/workers.mak b/server/fishtest/templates/workers.mak index 2e56cc0ae..c013a7189 100644 --- a/server/fishtest/templates/workers.mak +++ b/server/fishtest/templates/workers.mak @@ -7,56 +7,58 @@ %>

Workers Management