diff --git a/lib/split/dashboard/public/dashboard.js b/lib/split/dashboard/public/dashboard.js index ebfa28c4..922c2ae6 100644 --- a/lib/split/dashboard/public/dashboard.js +++ b/lib/split/dashboard/public/dashboard.js @@ -13,11 +13,6 @@ function confirmWinner() { return agree ? true : false; } -function confirmStep(step) { - var agree = confirm(step); - return agree ? true : false; -} - function confirmReopen() { var agree = confirm("This will reopen the experiment. Are you sure?"); return agree ? true : false; @@ -32,3 +27,26 @@ function confirmDisableCohorting(){ var agree = confirm("This will disable the cohorting of the experiment. Note: Existing participants will continue to receive their alternative and may continue to convert. Are you sure?"); return agree ? true : false; } + + +document.addEventListener("DOMContentLoaded", function () { + const eventHandlers = { + "split reopen": confirmReopen, + "split enable-cohorting": confirmEnableCohorting, + "split disable-cohorting": confirmDisableCohorting, + "split reset": confirmReset, + "split delete": confirmDelete, + "split winner": confirmWinner, + }; + + Object.keys(eventHandlers).forEach(className => { + const selector = `.${className.replace(" ", ".")}`; + const elements = document.querySelectorAll(selector); + + if (elements.length > 0) { + elements.forEach(element => { + element.addEventListener("click", eventHandlers[className]); + }); + } + }); +}); diff --git a/lib/split/dashboard/views/_controls.erb b/lib/split/dashboard/views/_controls.erb index 2472b9ee..c5d1a24c 100644 --- a/lib/split/dashboard/views/_controls.erb +++ b/lib/split/dashboard/views/_controls.erb @@ -1,15 +1,15 @@ <% if experiment.has_winner? %> -
<% else %> <% if experiment.cohorting_disabled? %> - <% else %> - @@ -17,7 +17,7 @@ <% end %> | <% if experiment.start_time %> - <% else%> @@ -25,7 +25,7 @@ <% end %> - diff --git a/lib/split/dashboard/views/_experiment.erb b/lib/split/dashboard/views/_experiment.erb index d23ac2b5..05db126f 100644 --- a/lib/split/dashboard/views/_experiment.erb +++ b/lib/split/dashboard/views/_experiment.erb @@ -125,7 +125,7 @@ Loser <% end %> <% else %> -