Skip to content

Commit

Permalink
3269 [BUGFIX] refactor reparse js file (#3280)
Browse files Browse the repository at this point in the history
* refactor reparse js file

* corrections

---------

Co-authored-by: Eric Lipe <[email protected]>
Co-authored-by: Andrew <[email protected]>
  • Loading branch information
3 people authored Nov 20, 2024
1 parent dd5ea65 commit 455ca37
Showing 1 changed file with 33 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,44 @@ $(window).on('load', function() {
console.log('loaded');
var submitBtn=document.querySelector('button[type=submit]'); // add the first listener
var theForm = submitBtn.parentNode.parentNode;
var action = "";
var number_of_files_line = "";

for (var i = 0; i < theForm.childNodes.length; i++) {
if (theForm.childNodes[i].className == "actions") {
form_header = theForm.childNodes[i];
submitBtn.addEventListener('click', function(e) {
e.preventDefault();
// number of files
action_counter = document.querySelector('span.action-counter')
is_action_counter_hidden = action_counter.className === "action-counter hidden"

for (var i = 0; i < form_header.childNodes.length; i++) {
if (form_header.childNodes[i].className == "action-counter") {
number_of_files = form_header.childNodes[i];
break;
}
}
action_counter_all = document.querySelector('span.all')

break;
if (is_action_counter_hidden) {
number_of_files_line = action_counter_all.innerText;
} else {
number_of_files_line = action_counter.innerText;
}
}
submitBtn.addEventListener('click', function(e) {
e.preventDefault();
if (confirm("You are about to re-parse " + number_of_files.innerHTML.split(/(\s+)/)[0] + " files. Are you sure you want to continue?")) {
console.log('submitting');
theForm.submit();

// what action is selected
action = document.querySelector('select[name=action]').value;

if (action === "reparse") {
console.log('reparse');
var splitted_number_of_files = number_of_files_line.split(/(\s+)/);
if (Number(splitted_number_of_files[0]) > 0 ) {
number_of_files = splitted_number_of_files[0];
} else {
number_of_files = splitted_number_of_files[2];
}
if (confirm("You are about to re-parse " + number_of_files + " files. Are you sure you want to continue?")) {
console.log('submitting');
theForm.submit();
} else {
console.log('not submitting');
};
} else {
console.log('not submitting');
};
console.log('not reparse');
alert('Please select the "Reparse" action to continue.');
}
});

});

0 comments on commit 455ca37

Please sign in to comment.