diff --git a/src/core/js/ext_trigger_crawler_form.js b/src/core/js/ext_trigger_crawler_form.js index 900cda98e5c0c3fd8efcd075b06ed25a91f906a1..a6e1e3a18a3582cc9b3e511880b72d15f730b346 100644 --- a/src/core/js/ext_trigger_crawler_form.js +++ b/src/core/js/ext_trigger_crawler_form.js @@ -78,15 +78,7 @@ var ext_trigger_crawler_form = function ($, form_elements) { }); $(warning_checkbox).find("input").attr("value", "TRUE"); - const scripting_caller = $(` - <form method="POST" action="/scripting"> - <input type="hidden" name="call" value="${script}"/> - <input type="hidden" name="-p0" value=""/> - <div class="form-control"> - <input type="submit" - class="form-control btn btn-primary" value="${button_name}"/> - </div> - </form>`); + const scripting_caller = form_elements.make_scripting_submission_button(script, button_name); scripting_caller.prepend(warning_checkbox).prepend(path_field); diff --git a/src/core/js/form_elements.js b/src/core/js/form_elements.js index 5d2143b52018f6b1f24ee64cca153227042f9bd2..f59f64416993d4fc908c5f2df4fabf5dfee2699e 100644 --- a/src/core/js/form_elements.js +++ b/src/core/js/form_elements.js @@ -1568,17 +1568,16 @@ var form_elements = new function () { * * @param {HTMLElement} form - the form to be shown in the modal * @param {string} title - the title of the form modal - * @param {string} explanation_text - An optional paragraph shown between + * @param {string} explanationText - An optional paragraph shown between * modal title and form. */ - this.make_form_modal = function (form, title, explanation_text) { + this.make_form_modal = function (form, title, explanationText) { const modal = $(` <div class="modal fade" tabindex="-1" role="dialog"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h4 class="modal-title">${title}</h4> - <p>{explanation_text}</p> <button type="button" class="btn-close" data-bs-dismiss="modal" @@ -1586,6 +1585,7 @@ var form_elements = new function () { </button> </div> <div class="modal-body"> + <p>${explanationText}</p> </div> </div> </div>`); @@ -1594,6 +1594,27 @@ var form_elements = new function () { return modal[0]; } + /** + * Return a submission button that triggers a given server-side-script. + * + * @param {string} script - Name of the server-side script to be triggered + * @param {string} buttonName - Display name of the submission button + */ + this.make_scripting_submission_button = function (script, buttonName) { + let button_name = buttonName || "Submit"; + const scripting_caller = $(` + <form method="POST" action="/scripting"> + <input type="hidden" name="call" value="${script}"/> + <input type="hidden" name="-p0" value=""/> + <div class="form-group"> + <input type="submit" + class="form-control btn btn-primary" value="${button_name}"/> + </div> + </form>`); + + return scripting_caller + } + /** * Return an input and a label, wrapped in a div with class