summaryrefslogtreecommitdiff
path: root/www/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'www/scripts')
-rw-r--r--www/scripts/main.js67
1 files changed, 50 insertions, 17 deletions
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