From c4c55c23c564160a7150062ffb73041f21de70e9 Mon Sep 17 00:00:00 2001 From: Ian C Date: Tue, 26 Jun 2018 21:12:37 +0000 Subject: Added links for edit actions, and place holders for the event handlers. --- www/scripts/main.js | 46 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) (limited to 'www/scripts/main.js') diff --git a/www/scripts/main.js b/www/scripts/main.js index 900357b..9c77f56 100644 --- a/www/scripts/main.js +++ b/www/scripts/main.js @@ -118,11 +118,10 @@ function LoadGroups(keep_selection) elem.add(option); } - alert(globalCurrentGroup); elem.value = globalCurrentGroup; } -function AddTableInputCell(id, text, name, tr) +function AddTableInputCell(id, text, name, node) { var td = document.createElement("td"); var input = document.createElement("input"); @@ -132,7 +131,26 @@ function AddTableInputCell(id, text, name, tr) input.type = "text"; td.appendChild(input); - tr.appendChild(td); + node.appendChild(td); +} + +function AddSmallLink(node, text, func, id) +{ + var anchor = document.createElement("a"); + + anchor.href = "#"; + anchor.onclick = func; + anchor.text = text; + anchor.className = "smalltext"; + anchor.dataset.pmId = id; + + node.appendChild(anchor); +} + +function AddNBSP(node) +{ + var nbsp = document.createTextNode("\u00a0"); + node.appendChild(nbsp); } function AddRow(table, id, desc, username, password, rowcount) @@ -141,11 +159,11 @@ function AddRow(table, id, desc, username, password, rowcount) if ((rowcount % 2) == 1) { - tr.style = "style1"; + tr.className = "style1"; } else { - tr.style = "style2"; + tr.className = "style2"; } AddTableInputCell(id, desc, "Description", tr); @@ -156,11 +174,13 @@ function AddRow(table, id, desc, username, password, rowcount) if (id == -1) { - td.innerText = "Stuff for new entry"; + AddSmallLink(td, "Add", DoAdd, id); } else { - td.innerText = "Stuff for existing entry"; + AddSmallLink(td, "Edit", DoEdit, id); + AddNBSP(td); + AddSmallLink(td, "Delete", DoDelete, id); } tr.appendChild(td); @@ -218,4 +238,16 @@ function DoSelectGroup() LoadTable(); } +function DoAdd() +{ +} + +function DoEdit() +{ +} + +function DoDelete() +{ +} + // vim: sw=4 ts=4 -- cgit v1.2.3