diff --git a/app/assets/javascripts/admin/teams/scorecards.js b/app/assets/javascripts/admin/teams/scorecards.js
index 3b60ba509..ae009126f 100644
--- a/app/assets/javascripts/admin/teams/scorecards.js
+++ b/app/assets/javascripts/admin/teams/scorecards.js
@@ -3,21 +3,18 @@
$( document ).on('ready turbolinks:load', function() {
- var windowObjectReference;
- var strWindowFeatures = "menubar=no,location=no,resizable=yes,scrollbars=yes,status=no,width=700,height=800";
+ const strWindowFeatures = "menubar=no,location=no,resizable=yes,scrollbars=yes,status=no,width=700,height=800";
- function openRequestedPopup(team_scorecards_path) {
- windowObjectReference = window.open(team_scorecards_path, 'Team Scorecards', strWindowFeatures);
- }
+ const openRequestedPopup = (team_scorecards_path) => windowObjectReference = window.open(team_scorecards_path, 'Team Scorecards', strWindowFeatures);
- function refreshParent() {
- window.opener.location.reload();
- }
+
+ const refreshParent = () => window.opener.location.reload();
+
$('.open-team-scorecards').click(function (event) {
event.preventDefault();
- var team_id = $(this).data("id");
- var include_judges =$(this).data("include-judges");
+ const team_id = $(this).data("id");
+ const include_judges =$(this).data("include-judges");
openRequestedPopup(_admin_teams_path + '/' + team_id + '/scorecards?include_judges='+ include_judges +'&popup=true');
});
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index c0c5e9aee..8243b77d7 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -30,7 +30,7 @@ $(document).ready(function() {
$( document ).on('turbolinks:load', function() {
// Initilize the table and save any state changes.
- var table = $('[id$="table"]').DataTable({
+ const table = $('[id$="table"]').DataTable({
stateSave: true,
responsive: true
});
@@ -42,18 +42,22 @@ $( document ).on('turbolinks:load', function() {
});
// Check if filter needs to be applied
- if ((window._search != undefined) && (window._search.length > 0 )) {
+ if ((window._search !== undefined) && (window._search.length > 0 )) {
// Apply the filter param to the filter box.
table.search(window._search);
table.draw();
// Clear the filter in the URL when the search param is updated.
table.on( 'search.dt', function () {
- if ((table.search() != window._search) && (window._search.length > 0 )) {
- var url = window.location.href;
- var tail = url.substring(url.lastIndexOf('/') + 1);
- var clean_tail = tail.substring(0, tail.lastIndexOf('?'));
- var clean_title = document.title.replace(/#(.*?)\s/, '');
+ if ((table.search() !== window._search) && (window._search.length > 0 )) {
+ const url = window.location.href;
+ const tail = url.substring(url.lastIndexOf('/') + 1);
+
+ // Remove any query parameters from the segment
+ const clean_tail = tail.substring(0, tail.lastIndexOf('?'));
+
+ // Clean up the document title by removing text after '#' symbol and whitespace
+ const clean_title = document.title.replace(/#(.*?)\s/, '');
history.replaceState({}, clean_title, clean_tail);
document.title = clean_title;
diff --git a/app/assets/javascripts/projects.js b/app/assets/javascripts/projects.js
index 1f8097802..acc7962c0 100644
--- a/app/assets/javascripts/projects.js
+++ b/app/assets/javascripts/projects.js
@@ -2,16 +2,12 @@
// All this logic will automatically be available in application.js.
$( document ).on('ready turbolinks:load', function() {
- var windowObjectReference;
- var strWindowFeatures = "menubar=no,location=no,resizable=yes,scrollbars=yes,status=no,width=500,height=800";
+ const strWindowFeatures = "menubar=no,location=no,resizable=yes,scrollbars=yes,status=no,width=500,height=800";
- function openRequestedPopup() {
- windowObjectReference = window.open(_scorecard_path, 'Scorecard', strWindowFeatures);
- }
+ const openRequestedPopup = () => windowObjectReference = window.open(_scorecard_path, 'Scorecard', strWindowFeatures);
+
- function refreshParent() {
- window.opener.location.reload();
- }
+ const refreshParent = () => window.opener.location.reload();
$('#open-scorecard').click(function (event) {
event.preventDefault();
diff --git a/app/assets/javascripts/team_management/entries.js b/app/assets/javascripts/team_management/entries.js
index b2c275d6e..2b5bde032 100644
--- a/app/assets/javascripts/team_management/entries.js
+++ b/app/assets/javascripts/team_management/entries.js
@@ -3,22 +3,22 @@
$( document ).on('ready turbolinks:load', function() {
$("#team_data_set_url").blur(function() {
- var url = $("#team_data_set_url").val();
- var separated = url.split("/dataset/");
- console.log(url);
+ const teamUrlData = $("#team_data_set_url").val().split("/dataset/");
+
var data = {
- id: separated[1]
+ id: teamUrlData[1]
}
$.ajax({
type: "GET",
data: data,
- url: separated[0] + "/api/3/action/package_show",
+ url: teamUrlData[0] + "/api/3/action/package_show",
success: function (data) {
$("#team_data_set_name").val(data.result.title);
$("#team_data_set_description").val(data.result.notes);
-
$("#hiddendescription").width($("#data_set_description").width());
- var content = data.result.notes.replace(/\n/g, "
");
+
+ const content = data.result.notes.replace(/\n/g, "
");
+
$("#hiddendescription").html(content);
$("#team_data_set_description").css("height", $("#hiddendescription").outerHeight());
},
@@ -27,10 +27,12 @@ $( document ).on('ready turbolinks:load', function() {
});
try {
$("#hiddendescription").width($("#data_set_description").width());
- var content = $("#team_data_set_description").val().replace(/\n/g, "
");
+
+ const content = $("#team_data_set_description").val().replace(/\n/g, "
");
+
$("#hiddendescription").html(content);
$("#team_data_set_description").css("height", $("#hiddendescription").outerHeight());
} catch (e) {
-
+ console.error('An error occured.', e)
}
});
\ No newline at end of file
diff --git a/app/assets/javascripts/team_management/team_data_sets.js b/app/assets/javascripts/team_management/team_data_sets.js
index 1b39def4b..f69fb8390 100644
--- a/app/assets/javascripts/team_management/team_data_sets.js
+++ b/app/assets/javascripts/team_management/team_data_sets.js
@@ -3,8 +3,8 @@
$(document).ready(function() {
$("#team_data_set_url").blur(function() {
- var url = $("#team_data_set_url").val();
- var separated = url.split("/dataset/");
+ const url = $("#team_data_set_url").val();
+ const separated = url.split("/dataset/");
var data = {
id: separated[1]
@@ -18,19 +18,28 @@ $(document).ready(function() {
$("#team_data_set_description").val(data.result.notes);
$("#hiddendescription").width($("#team_data_set_description").width());
- var content = data.result.notes.replace(/\n/g, "
");
+
+ const content = data.result.notes.replace(/\n/g, "
");
+
$("#hiddendescription").html(content);
$("#team_data_set_description").css("height", $("#hiddendescription").outerHeight());
},
dataType: "jsonp"
})
});
+
try {
+
$("#hiddendescription").width($("#team_data_set_description").width());
- var content = $("#team_data_set_description").val().replace(/\n/g, "
");
+
+ const content = $("#team_data_set_description").val().replace(/\n/g, "
");
+
$("#hiddendescription").html(content);
$("#team_data_set_description").css("height", $("#hiddendescription").outerHeight());
+
} catch (e) {
-
+
+ console.error("An error occurred:", e);
+
}
});
\ No newline at end of file