From bd8af153a93485aeab61fbe90db6bdb66904e6b4 Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Sun, 16 Aug 2020 14:05:16 +0100 Subject: [PATCH] disable generate button if duration is zero --- data/static/admin.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/data/static/admin.js b/data/static/admin.js index 139edef..50de99f 100644 --- a/data/static/admin.js +++ b/data/static/admin.js @@ -549,6 +549,7 @@ document.getElementById('loginForm').onsubmit = function() { let minutes = document.getElementById('minutes'); addOptions(59, minutes); minutes.selected = "30"; + checkDuration(); loginModal.hide(); } } @@ -958,3 +959,17 @@ document.getElementById('settingsSave').onclick = function() { } } +// Diable 'Generate' button if days, hours, minutes are all zero +function checkDuration() { + let boxVals = [document.getElementById("days").value, document.getElementById("hours").value, document.getElementById("minutes").value]; + let submit = document.getElementById("generateSubmit"); + if (boxVals[0] != 0 || boxVals[1] != 0 || boxVals[2] != 0) { + submit.disabled = false; + } else if (boxVals[0] == 0 && boxVals[1] == 0 && boxVals[2] == 0) { + submit.disabled = true; + } +} + +for (i of ["days", "hours", "minutes"]) { + document.getElementById(i).addEventListener("change", checkDuration); +}