From fdf45783f5c8c01613915ea10ac8458ed50c027f Mon Sep 17 00:00:00 2001 From: Ian C Date: Mon, 30 Jul 2018 20:49:38 +0000 Subject: Finished rejig of interface to a single record. --- www/edit.php | 2 ++ www/get.php | 3 ++- www/index.html | 9 +++++++ www/scripts/main.js | 67 +++++++++++++++++++++++++++++++++++++++-------------- 4 files changed, 63 insertions(+), 18 deletions(-) (limited to 'www') diff --git a/www/edit.php b/www/edit.php index 890d042..226e142 100644 --- a/www/edit.php +++ b/www/edit.php @@ -46,6 +46,8 @@ try $cmd->execute(); $result["status"] = true; + $result["group"] = $group; + $result["id"] = $id; $db = null; } diff --git a/www/get.php b/www/get.php index a4e1f2a..ee4dae5 100644 --- a/www/get.php +++ b/www/get.php @@ -29,7 +29,8 @@ try $index = 0; - foreach ($db->query("SELECT * FROM pm_store ORDER BY display") as $row) + foreach ($db->query("SELECT * FROM pm_store ORDER BY groupname, display") + as $row) { $data = array(); $data["id"] = $row["id"]; diff --git a/www/index.html b/www/index.html index db66991..088767d 100644 --- a/www/index.html +++ b/www/index.html @@ -60,6 +60,11 @@ + + + + +
DescriptionUsernamePasswordCommands
+ +
diff --git a/www/scripts/main.js b/www/scripts/main.js index 93c3c83..36ac5f3 100644 --- a/www/scripts/main.js +++ b/www/scripts/main.js @@ -135,6 +135,31 @@ function GetData(id) return null; } +function FindNextPrevious() +{ + var rows = GetGroupRows(); + var f; + var ret = {prev: -1, next: -1}; + var prev = -1; + + for(f = 0; f < rows.length; f++) + { + if (rows[f].id == globalCurrentSelection) + { + ret.prev = prev; + + if (f < rows.length - 1) + { + ret.next = rows[f + 1].id; + } + } + + prev = rows[f].id; + } + + return ret; +} + function SetButtonState() { SetEnable("Add", true); @@ -142,6 +167,8 @@ function SetButtonState() SetEnable("Delete", globalCurrentSelection != -1); SetEnable("CopyUsername", globalCurrentSelection != -1); SetEnable("CopyPassword", globalCurrentSelection != -1); + SetEnable("Up", globalCurrentSelection != -1); + SetEnable("Down", globalCurrentSelection != -1); } function LoadGroups(keep_selection) @@ -356,6 +383,7 @@ function DoChangePassphrase() ); } + document.getElementById("PassPhrase").value = newphrase; document.getElementById("NewPassPhrase").value = ""; } } @@ -449,6 +477,8 @@ function DoEditAsync() } else { + globalCurrentGroup = response.group; + globalCurrentSelection = response.id; RefreshData(); } } @@ -564,28 +594,32 @@ function DoReorderAsync() function DoUp() { - var id = this.dataset.pmId; - var prev = this.dataset.pmPrevId; + var rec = FindNextPrevious(); - WebRequest("reorder.php", DoReorderAsync, - [ - "from_id", id, - "to_id", prev - ] - ); + if (rec.prev != -1) + { + WebRequest("reorder.php", DoReorderAsync, + [ + "from_id", globalCurrentSelection, + "to_id", rec.prev + ] + ); + } } function DoDown() { - var id = this.dataset.pmId; - var next = this.dataset.pmNextId; + var rec = FindNextPrevious(); - WebRequest("reorder.php", DoReorderAsync, - [ - "from_id", id, - "to_id", next - ] - ); + if (rec.next != -1) + { + WebRequest("reorder.php", DoReorderAsync, + [ + "from_id", globalCurrentSelection, + "to_id", rec.next + ] + ); + } } function DoShowPasswords() @@ -604,7 +638,6 @@ function DoShowPasswords() SetInputType("PassPhrase", type); SetInputType("NewPassPhrase", type); SetInputType("Password", type); - SetInputType("NewPassword", type); } // vim: sw=4 ts=4 -- cgit v1.2.3