From ede1eab3f219537349c91cf7fcdaf8bdb242d41a Mon Sep 17 00:00:00 2001 From: anuko Date: Sun, 29 Jan 2017 17:28:58 +0000 Subject: [PATCH] A bit of cleanup in JavaScript, removed repeated var declarations. --- WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/mobile/time.tpl | 19 ++++++++++--------- WEB-INF/templates/mobile/time_edit.tpl | 15 ++++++++------- WEB-INF/templates/time.tpl | 19 ++++++++++--------- WEB-INF/templates/time_edit.tpl | 15 ++++++++------- 5 files changed, 37 insertions(+), 33 deletions(-) diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index ca9f38ef..2a9bf670 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.9.35.3555 | Copyright © Anuko | +  Anuko Time Tracker 1.9.35.3556 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/mobile/time.tpl b/WEB-INF/templates/mobile/time.tpl index bb800ffd..29e27180 100644 --- a/WEB-INF/templates/mobile/time.tpl +++ b/WEB-INF/templates/mobile/time.tpl @@ -143,39 +143,40 @@ function fillTaskDropdown(id) { // The formDisable function disables some fields depending on what we have in other fields. function formDisable(formField) { - formFieldValue = eval("document.timeRecordForm." + formField + ".value"); - formFieldName = eval("document.timeRecordForm." + formField + ".name"); + var formFieldValue = eval("document.timeRecordForm." + formField + ".value"); + var formFieldName = eval("document.timeRecordForm." + formField + ".name"); + var x; if (((formFieldValue != "") && (formFieldName == "start")) || ((formFieldValue != "") && (formFieldName == "finish"))) { - var x = eval("document.timeRecordForm.duration"); + x = eval("document.timeRecordForm.duration"); x.value = ""; x.disabled = true; x.style.background = "#e9e9e9"; } if (((formFieldValue == "") && (formFieldName == "start") && (document.timeRecordForm.finish.value == "")) || ((formFieldValue == "") && (formFieldName == "finish") && (document.timeRecordForm.start.value == ""))) { - var x = eval("document.timeRecordForm.duration"); + x = eval("document.timeRecordForm.duration"); x.value = ""; x.disabled = false; x.style.background = "white"; } if ((formFieldValue != "") && (formFieldName == "duration")) { - var x = eval("document.timeRecordForm.start"); + x = eval("document.timeRecordForm.start"); x.value = ""; x.disabled = true; x.style.background = "#e9e9e9"; - var x = eval("document.timeRecordForm.finish"); + x = eval("document.timeRecordForm.finish"); x.value = ""; x.disabled = true; x.style.background = "#e9e9e9"; } if ((formFieldValue == "") && (formFieldName == "duration")) { - var x = eval("document.timeRecordForm.start"); + x = eval("document.timeRecordForm.start"); x.disabled = false; x.style.background = "white"; - var x = eval("document.timeRecordForm.finish"); + x = eval("document.timeRecordForm.finish"); x.disabled = false; x.style.background = "white"; } @@ -186,7 +187,7 @@ function setNow(formField) { var x = eval("document.timeRecordForm.start"); x.disabled = false; x.style.background = "white"; - var x = eval("document.timeRecordForm.finish"); + x = eval("document.timeRecordForm.finish"); x.disabled = false; x.style.background = "white"; var today = new Date(); diff --git a/WEB-INF/templates/mobile/time_edit.tpl b/WEB-INF/templates/mobile/time_edit.tpl index 117e2082..f5b90838 100644 --- a/WEB-INF/templates/mobile/time_edit.tpl +++ b/WEB-INF/templates/mobile/time_edit.tpl @@ -145,37 +145,38 @@ function fillTaskDropdown(id) { function formDisable(formField) { var formFieldValue = eval("document.timeRecordForm." + formField + ".value"); var formFieldName = eval("document.timeRecordForm." + formField + ".name"); + var x; if (((formFieldValue != "") && (formFieldName == "start")) || ((formFieldValue != "") && (formFieldName == "finish"))) { - var x = eval("document.timeRecordForm.duration"); + x = eval("document.timeRecordForm.duration"); x.value = ""; x.disabled = true; x.style.background = "#e9e9e9"; } if (((formFieldValue == "") && (formFieldName == "start") && (document.timeRecordForm.finish.value == "")) || ((formFieldValue == "") && (formFieldName == "finish") && (document.timeRecordForm.start.value == ""))) { - var x = eval("document.timeRecordForm.duration"); + x = eval("document.timeRecordForm.duration"); x.value = ""; x.disabled = false; x.style.background = "white"; } if ((formFieldValue != "") && (formFieldName == "duration")) { - var x = eval("document.timeRecordForm.start"); + x = eval("document.timeRecordForm.start"); x.value = ""; x.disabled = true; x.style.background = "#e9e9e9"; - var x = eval("document.timeRecordForm.finish"); + x = eval("document.timeRecordForm.finish"); x.value = ""; x.disabled = true; x.style.background = "#e9e9e9"; } if ((formFieldValue == "") && (formFieldName == "duration")) { - var x = eval("document.timeRecordForm.start"); + x = eval("document.timeRecordForm.start"); x.disabled = false; x.style.background = "white"; - var x = eval("document.timeRecordForm.finish"); + x = eval("document.timeRecordForm.finish"); x.disabled = false; x.style.background = "white"; } @@ -186,7 +187,7 @@ function setNow(formField) { var x = eval("document.timeRecordForm.start"); x.disabled = false; x.style.background = "white"; - var x = eval("document.timeRecordForm.finish"); + x = eval("document.timeRecordForm.finish"); x.disabled = false; x.style.background = "white"; var today = new Date(); diff --git a/WEB-INF/templates/time.tpl b/WEB-INF/templates/time.tpl index 6d294fb1..454abf9f 100644 --- a/WEB-INF/templates/time.tpl +++ b/WEB-INF/templates/time.tpl @@ -142,39 +142,40 @@ function fillTaskDropdown(id) { // The formDisable function disables some fields depending on what we have in other fields. function formDisable(formField) { - formFieldValue = eval("document.timeRecordForm." + formField + ".value"); - formFieldName = eval("document.timeRecordForm." + formField + ".name"); + var formFieldValue = eval("document.timeRecordForm." + formField + ".value"); + var formFieldName = eval("document.timeRecordForm." + formField + ".name"); + var x; if (((formFieldValue != "") && (formFieldName == "start")) || ((formFieldValue != "") && (formFieldName == "finish"))) { - var x = eval("document.timeRecordForm.duration"); + x = eval("document.timeRecordForm.duration"); x.value = ""; x.disabled = true; x.style.background = "#e9e9e9"; } if (((formFieldValue == "") && (formFieldName == "start") && (document.timeRecordForm.finish.value == "")) || ((formFieldValue == "") && (formFieldName == "finish") && (document.timeRecordForm.start.value == ""))) { - var x = eval("document.timeRecordForm.duration"); + x = eval("document.timeRecordForm.duration"); x.value = ""; x.disabled = false; x.style.background = "white"; } if ((formFieldValue != "") && (formFieldName == "duration")) { - var x = eval("document.timeRecordForm.start"); + x = eval("document.timeRecordForm.start"); x.value = ""; x.disabled = true; x.style.background = "#e9e9e9"; - var x = eval("document.timeRecordForm.finish"); + x = eval("document.timeRecordForm.finish"); x.value = ""; x.disabled = true; x.style.background = "#e9e9e9"; } if ((formFieldValue == "") && (formFieldName == "duration")) { - var x = eval("document.timeRecordForm.start"); + x = eval("document.timeRecordForm.start"); x.disabled = false; x.style.background = "white"; - var x = eval("document.timeRecordForm.finish"); + x = eval("document.timeRecordForm.finish"); x.disabled = false; x.style.background = "white"; } @@ -185,7 +186,7 @@ function setNow(formField) { var x = eval("document.timeRecordForm.start"); x.disabled = false; x.style.background = "white"; - var x = eval("document.timeRecordForm.finish"); + x = eval("document.timeRecordForm.finish"); x.disabled = false; x.style.background = "white"; var today = new Date(); diff --git a/WEB-INF/templates/time_edit.tpl b/WEB-INF/templates/time_edit.tpl index a4e26a6f..863cdb16 100644 --- a/WEB-INF/templates/time_edit.tpl +++ b/WEB-INF/templates/time_edit.tpl @@ -145,37 +145,38 @@ function fillTaskDropdown(id) { function formDisable(formField) { var formFieldValue = eval("document.timeRecordForm." + formField + ".value"); var formFieldName = eval("document.timeRecordForm." + formField + ".name"); + var x; if (((formFieldValue != "") && (formFieldName == "start")) || ((formFieldValue != "") && (formFieldName == "finish"))) { - var x = eval("document.timeRecordForm.duration"); + x = eval("document.timeRecordForm.duration"); x.value = ""; x.disabled = true; x.style.background = "#e9e9e9"; } if (((formFieldValue == "") && (formFieldName == "start") && (document.timeRecordForm.finish.value == "")) || ((formFieldValue == "") && (formFieldName == "finish") && (document.timeRecordForm.start.value == ""))) { - var x = eval("document.timeRecordForm.duration"); + x = eval("document.timeRecordForm.duration"); x.value = ""; x.disabled = false; x.style.background = "white"; } if ((formFieldValue != "") && (formFieldName == "duration")) { - var x = eval("document.timeRecordForm.start"); + x = eval("document.timeRecordForm.start"); x.value = ""; x.disabled = true; x.style.background = "#e9e9e9"; - var x = eval("document.timeRecordForm.finish"); + x = eval("document.timeRecordForm.finish"); x.value = ""; x.disabled = true; x.style.background = "#e9e9e9"; } if ((formFieldValue == "") && (formFieldName == "duration")) { - var x = eval("document.timeRecordForm.start"); + x = eval("document.timeRecordForm.start"); x.disabled = false; x.style.background = "white"; - var x = eval("document.timeRecordForm.finish"); + x = eval("document.timeRecordForm.finish"); x.disabled = false; x.style.background = "white"; } @@ -186,7 +187,7 @@ function setNow(formField) { var x = eval("document.timeRecordForm.start"); x.disabled = false; x.style.background = "white"; - var x = eval("document.timeRecordForm.finish"); + x = eval("document.timeRecordForm.finish"); x.disabled = false; x.style.background = "white"; var today = new Date(); -- 2.20.1