<commit_before>addEventListener("direct-upload:initialize", function (event) {
  var target = event.target,
      detail = event.detail,
      id = detail.id,
      file = detail.file;

  target.insertAdjacentHTML("beforebegin", "\n<div id=\"direct-upload-" +
    id +
    "\" class=\"direct-upload direct-upload--pending\">\n<div id=\"direct-upload-progress-" +
    id + "\" class=\"direct-upload__progress\" style=\"width: 0%\"></div>\n<span class=\"direct-upload__filename\">" +
    file.name +
    "</span>\n</div>\n");
});

addEventListener("direct-upload:start", function (event) {
  var id = event.detail.id,
      element = document.getElementById("direct-upload-" + id);

  element.classList.remove("direct-upload--pending");
});

addEventListener("direct-upload:progress", function (event) {
  var id = event.detail.id,
      progress = event.detail.progress,
      progressElement = document.getElementById("direct-upload-progress-" + id);

  progressElement.style.width = progress + "%";
});

addEventListener("direct-upload:error", function (event) {
  event.preventDefault();
  var id = event.detail.id,
      error = event.detail.error,
      element = document.getElementById("direct-upload-" + id);

  element.classList.add("direct-upload--error");
  element.setAttribute("title", error);
});

addEventListener("direct-upload:end", function (event) {
  var id = event.detail.id,
      element = document.getElementById("direct-upload-" + id);

  element.classList.add("direct-upload--complete");
});

addEventListener('load', function() {
    var submitButtons = document.querySelectorAll('form button[type=submit][data-action]');
    var hiddenInput = document.querySelector('form input[type=hidden][name=submit_action]');
    submitButtons = [].slice.call(submitButtons);

    submitButtons.forEach(function(button) {
      button.addEventListener('click', function() {
        hiddenInput.value = button.getAttribute('data-action');
      });
    });
});<commit_msg>form: fix action sent after navigating away and back again<commit_after>addEventListener("direct-upload:initialize", function (event) {
  var target = event.target,
      detail = event.detail,
      id = detail.id,
      file = detail.file;

  target.insertAdjacentHTML("beforebegin", "\n<div id=\"direct-upload-" +
    id +
    "\" class=\"direct-upload direct-upload--pending\">\n<div id=\"direct-upload-progress-" +
    id + "\" class=\"direct-upload__progress\" style=\"width: 0%\"></div>\n<span class=\"direct-upload__filename\">" +
    file.name +
    "</span>\n</div>\n");
});

addEventListener("direct-upload:start", function (event) {
  var id = event.detail.id,
      element = document.getElementById("direct-upload-" + id);

  element.classList.remove("direct-upload--pending");
});

addEventListener("direct-upload:progress", function (event) {
  var id = event.detail.id,
      progress = event.detail.progress,
      progressElement = document.getElementById("direct-upload-progress-" + id);

  progressElement.style.width = progress + "%";
});

addEventListener("direct-upload:error", function (event) {
  event.preventDefault();
  var id = event.detail.id,
      error = event.detail.error,
      element = document.getElementById("direct-upload-" + id);

  element.classList.add("direct-upload--error");
  element.setAttribute("title", error);
});

addEventListener("direct-upload:end", function (event) {
  var id = event.detail.id,
      element = document.getElementById("direct-upload-" + id);

  element.classList.add("direct-upload--complete");
});

addEventListener('turbolinks:load', function() {
    var submitButtons = document.querySelectorAll('form button[type=submit][data-action]');
    var hiddenInput = document.querySelector('form input[type=hidden][name=submit_action]');
    submitButtons = [].slice.call(submitButtons);

    submitButtons.forEach(function(button) {
      button.addEventListener('click', function() {
        // Active Storage will intercept the form.submit event to upload
        // the attached files, and then fire the submit action again – but forgetting
        // which button was clicked. So we manually set the type of action that trigerred
        // the form submission.
        hiddenInput.value = button.getAttribute('data-action');
      });
    });
});
{'fraction_non_alphanumeric': 0.16407519145973543, 'fraction_numerical': 0.0004641448131817127, 'mean_word_length': 3.988425925925926, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3626295', 'n_tokens_mistral': 1199, 'n_tokens_neox': 1192, 'n_words': 230}