From 61d1aa04d8d44b17bfe6dace90088669fc6c3df8 Mon Sep 17 00:00:00 2001 From: Kyle McFarland Date: Wed, 31 Jan 2018 00:51:07 -0600 Subject: Initial import * Registration system's almost done * Just part way through implementing tasks So not much done yet, but it's a start. --- js/tasks.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 js/tasks.js (limited to 'js/tasks.js') diff --git a/js/tasks.js b/js/tasks.js new file mode 100644 index 0000000..10483b3 --- /dev/null +++ b/js/tasks.js @@ -0,0 +1,46 @@ +function handle_search_results(res) { + //alert(res[0].title) + if (res) { + var tc = $("#table_container"); + tc.removeClass("hidden_results_table"); + // TODO: check if results_table is in tc's classes and add it if it isn't (jQuery stuff) + } + for (index in res) { + obj = res[index] + var tb = $("#results_tbody"); + tb.empty(); + //alert(tb); + var tr = document.createElement("tr"); + var id_td = document.createElement("td"); + var id_text = document.createTextNode(String(obj.taskid)); + id_td.appendChild(id_text); + var title_td = document.createElement("td"); + var title_text = document.createTextNode(obj.title); + title_td.appendChild(title_text); + var state_td = document.createElement("td"); + var state_text = document.createTextNode(obj.state); + state_td.appendChild(state_text); + var admin_td = document.createElement("td"); + var admin_text = document.createTextNode(obj.member_public.display_name); + admin_td.appendChild(admin_text); + var credits_total = 0; + for (tdc_index in obj.tdcs) { + tdc = obj.tdcs[tdc_index]; + credits_total += Number(tdc.remaining_credits); + } + alert(credits_total); + var credits_td = document.createElement("td"); + var credits_text = document.createTextNode(String(credits_total)); + credits_td.appendChild(credits_text); + tr.appendChild(id_td); + tr.appendChild(title_td); + tr.appendChild(state_td); + tr.appendChild(admin_td); + tr.appendChild(credits_td); + tb.append(tr); + } +} + +function get_all_tasks() { + fetch("tasks_api.php?action=get_all_tasks_simple").then(res => res.json()).then(res => handle_search_results(res)); +} -- cgit v1.1