diff --git a/src/main/resources/org/jenkinsci/plugins/scriptler/ScriptlerManagement/confirm-remove.js b/src/main/resources/org/jenkinsci/plugins/scriptler/ScriptlerManagement/confirm-remove.js
index 9f88eaf8..beda28be 100644
--- a/src/main/resources/org/jenkinsci/plugins/scriptler/ScriptlerManagement/confirm-remove.js
+++ b/src/main/resources/org/jenkinsci/plugins/scriptler/ScriptlerManagement/confirm-remove.js
@@ -2,7 +2,7 @@ document.addEventListener("DOMContentLoaded", () => {
const removeScriptButtons = document.querySelectorAll(".scriptler-remove-script-form");
removeScriptButtons.forEach((button) =>
button.addEventListener("click", (e) => {
- const name = e.currentTarget.getAttribute("data-name");
+ const name = e.currentTarget.dataset.name;
if (!confirm("Sure you want to delete [" + name + "]?")) {
e.preventDefault();
}
diff --git a/src/main/resources/org/jenkinsci/plugins/scriptler/builder/ScriptlerBuilder/config.jelly b/src/main/resources/org/jenkinsci/plugins/scriptler/builder/ScriptlerBuilder/config.jelly
index b4d9161a..af7fd8a9 100644
--- a/src/main/resources/org/jenkinsci/plugins/scriptler/builder/ScriptlerBuilder/config.jelly
+++ b/src/main/resources/org/jenkinsci/plugins/scriptler/builder/ScriptlerBuilder/config.jelly
@@ -3,7 +3,11 @@
-
+
@@ -20,7 +24,7 @@
-
-
-
-
diff --git a/src/main/webapp/lib/scriptler.js b/src/main/webapp/lib/scriptler.js
index 4302a721..d4f8b0ac 100644
--- a/src/main/webapp/lib/scriptler.js
+++ b/src/main/webapp/lib/scriptler.js
@@ -1,5 +1,5 @@
-function scriptler_initDetailLink(rootURL, referenceTag) {
- var itemURL = referenceTag.getAttribute("data-item-url");
+function scriptler_initDetailLink(rootUrl, referenceTag) {
+ var itemUrl = referenceTag.dataset.itemUrl;
var selId = referenceTag.value;
var all = new Array();
all = document.getElementsByName("scriptlerScriptId");
@@ -7,7 +7,7 @@ function scriptler_initDetailLink(rootURL, referenceTag) {
if (referenceTag == all.item(i)) {
var detailsLinkTag = document.getElementsByName("showScriptlerDetailLink").item(i);
if (selId.length != 0) {
- detailsLinkTag.href = rootURL + "/" + itemURL + "scriptler/showScript?id=".concat(selId);
+ detailsLinkTag.href = rootUrl + "/" + itemUrl + "scriptler/showScript?id=".concat(selId);
detailsLinkTag.style.display = "block";
} else {
detailsLinkTag.style.display = "none";
@@ -39,3 +39,42 @@ function scriptler_showParams(referenceTag, scriptId) {
}
});
}
+
+Behaviour.specify("select[name='scriptlerScriptId']", "ScriptlerBuilderSelect", 0, function (element) {
+ const script = document.querySelector("#scriptler-builder-behaviour");
+ const rootUrl = script.dataset.rootUrl;
+ element.addEventListener("change", function (event) {
+ const target = event.target;
+ scriptler_initDetailLink(rootUrl, target);
+ scriptler_showParams(target, target.value);
+ });
+});
+
+Behaviour.specify("a[name='showScriptlerDetailLink']", "ScriptlerBuilderDetailLink", 0, function (element) {
+ element.addEventListener("click", function (event) {
+ event.preventDefault();
+ const target = event.target;
+ window.open(target.href, "window", "width=900,height=640,resizable,scrollbars,toolbar,menubar");
+ });
+});
+
+document.addEventListener("DOMContentLoaded", function () {
+ const script = document.querySelector("#scriptler-builder-behaviour");
+ const rootUrl = script.dataset.rootUrl;
+ const hasPermission = script.dataset.hasPermission;
+
+ var all = new Array();
+ all = document.getElementsByName("scriptlerScriptId");
+ for (var i = 0; i < all.length; i++) {
+ all.item(i).disabled = !hasPermission;
+ scriptler_initDetailLink(rootUrl, all.item(i));
+ scriptler_showParams(all.item(i), all.item(i).value);
+ }
+
+ // remember the job name to send it along with the form
+ var jobName = document.getElementsByName("name").item(0).value;
+ var allBackupJobNames = document.getElementsByName("backupJobName");
+ for (var i = 0; i < allBackupJobNames.length; i++) {
+ allBackupJobNames.item(i).value = jobName;
+ }
+});