From 93518f18ff1a12a660b25596be3832f5d94c3fd5 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 18 Mar 2017 15:48:21 +0100 Subject: Add initial timetasker.js Rough approach at filling in the first row in the form. Trouble is that the "module" select box doesn't get populated until the "project" select box receives click/selection event. Will need to figure out a way around that. --- timetasker.js | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 timetasker.js (limited to 'timetasker.js') diff --git a/timetasker.js b/timetasker.js new file mode 100644 index 0000000..b700deb --- /dev/null +++ b/timetasker.js @@ -0,0 +1,48 @@ +(function() { + var CLIENT = 'af83'; + var PROJECT = 'Enroute'; + var MODULE = 'Sprint 3'; + var TASK = 'General Time - No Task'; + var WORK_TYPE = 'Développeur'; + var TIME = 7; + var BILLABLE = true; + + + var client_0 = document.getElementById('f_clientID0'); + var project_0 = document.getElementById('f_projectID0'); + var module_0 = document.getElementById('f_moduleID0'); + var task_0 = document.getElementById('f_taskID0'); + var work_type_0 = document.getElementById('f_worktypeID0'); + var date_0 = document.getElementById('f_date0'); + var time_0 = document.getElementById('f_time0'); + var billable_0 = document.getElementById('f_billable0'); + + + popupate_select(client_0, CLIENT); + popupate_select(project_0, PROJECT); + // need to add a damn event trigger in order to get options to load + window.setTimeout(function() { + popupate_select(module_0, MODULE); + }, 1500); + window.setTimeout(function() { + popupate_select(task_0, TASK); + }, 500); + window.setTimeout(function() { + popupate_select(work_type_0, WORK_TYPE); + }, 500); + // popupate_select(date_0, ''); + popupate_select(time_0, TIME); + popupate_select(billable_0, BILLABLE ? 't' : 'f'); + + + function popupate_select(element, name) { + var options = element.getElementsByTagName('option'); + + for (var i = 0; i < options.length; i++) { + if (options[i].textContent === name) { + element.value = options[i].value; + return; + } + } + } +})(); -- cgit v1.2.3