diff options
author | Kyle McFarland <tfkyle@gmail.com> | 2018-01-31 00:51:07 -0600 |
---|---|---|
committer | Kyle McFarland <tfkyle@gmail.com> | 2018-01-31 00:51:07 -0600 |
commit | 61d1aa04d8d44b17bfe6dace90088669fc6c3df8 (patch) | |
tree | 7ede15c880e4c41a18cded46fe6d03fb2dc4543b /js | |
download | mcoop-master.zip mcoop-master.tar.gz mcoop-master.tar.bz2 |
* Registration system's almost done
* Just part way through implementing tasks
So not much done yet, but it's a start.
Diffstat (limited to 'js')
-rw-r--r-- | js/tasks.js | 46 |
1 files changed, 46 insertions, 0 deletions
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)); +} |