Skip to content
This repository has been archived by the owner on Dec 12, 2023. It is now read-only.

Commit

Permalink
Jlinoff 20210104 show (#10)
Browse files Browse the repository at this point in the history
* bump version

* fix error messages

* convenience: show/hide button for each record
  • Loading branch information
jlinoff authored Jan 4, 2021
1 parent 873cb6b commit 61df79c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 18 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.2
0.1.3
8 changes: 4 additions & 4 deletions www/js/dropbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function dropboxDownload() {
return;
}
if (!fname) {
alert("WARNING! upload file was not specified");
alert("WARNING! download file was not specified");
return;
}

Expand All @@ -120,7 +120,7 @@ function dropboxDownload() {
}, 0.30);
}
).catch((error) => {
alert("WARNING! upload failed with code " + error);
alert("WARNING! download failed with code " + error + "\nYou may need to re-authenticate.");
});
}

Expand Down Expand Up @@ -179,7 +179,7 @@ function dropboxListFiles() {
var mtime = entries[i]["client_modified"];
var size = entries[i]["size"];
fname = fname.substring(PATH.length); // strip off the prefix
console.log("file: " + fname);
//console.log("dropbox:list:file: " + fname);

tr = document.createElement("TR");

Expand Down Expand Up @@ -219,7 +219,7 @@ function dropboxListFiles() {
obj2.appendChild(tbl);
}
).catch((error) => {
alert("WARNING! list failed with code " + error);
alert("WARNING! list failed with code " + error + "\nYou may need to re-authenticate.");
obj2.innerHTML = "0 files";
});
}
Expand Down
45 changes: 32 additions & 13 deletions www/js/records.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

/*eslint no-unused-vars: ["warn", { "argsIgnorePattern": "^_" }]*/
window.addEventListener("load", function(_evt) {
window.doRecords = doRecords;
Expand Down Expand Up @@ -89,9 +90,7 @@ function doRecords() {
// Schedule search event if the search
// string has a value.
// This allows the system to "remember" the last search.
if (window.recordsSearch) {
setTimeout(searchRecords(), 200);
}
setTimeout(searchRecords(), 200);
}

// Display the records.
Expand Down Expand Up @@ -133,13 +132,23 @@ function displayRecord(rec, div, rid, rkey) {
deleteButton.innerHTML = "Delete";

// Stack them.
var br = document.createElement("BR");
var br1 = document.createElement("BR");
var br2 = document.createElement("BR");

var editButton = document.createElement("BUTTON");
editButton.setAttribute("type", "button");
editButton.setAttribute("onclick", "editRecord('" + frkey + "', true)");
editButton.innerHTML = "Edit";

// The local show/hide is only for convenience.
// It works by "clicking" the top level Show/Hide button.
var showButton = document.createElement("BUTTON");
showButton.setAttribute("title", "show or hide password fields with the prefix 'pass'");
showButton.setAttribute("type", "button");
showButton.setAttribute("onclick", "toggleRecordsPasswords()");
showButton.classList.add("main-records-show-hide-button");
showButton.innerHTML = "Show";

// Create the field table.
var tbl = document.createElement("TABLE");
var tbody = document.createElement("TBODY");
Expand All @@ -166,8 +175,10 @@ function displayRecord(rec, div, rid, rkey) {

// Add the Delete and Edit buttons in the third column.
td2.appendChild(deleteButton);
td2.appendChild(br);
td2.appendChild(br1);
td2.appendChild(editButton);
td2.appendChild(br2);
td2.appendChild(showButton);

trow.appendChild(td0);
trow.appendChild(td1);
Expand Down Expand Up @@ -248,16 +259,24 @@ function toggleRecordsPasswords() {
var i;
var obj1 = document.getElementById("main-records-show-hide");
var obj2s = document.getElementsByClassName("main-records-password-field");
var obj3s = document.getElementsByClassName("main-records-show-hide-button");
var atype = "?";
var title = "?";
if (obj1.innerHTML == "Show") {
obj1.innerHTML = "Hide";
for (i=0; i<obj2s.length; i++) {
obj2s[i].setAttribute("type", "text");
}
title = "Hide";
atype = "text";
} else {
obj1.innerHTML = "Show";
for (i=0; i<obj2s.length; i++) {
obj2s[i].setAttribute("type", "password");
}
title = "Show";
atype = "password";
}

// Update the objects.
obj1.innerHTML = title; // the top level button
for (i=0; i<obj2s.length; i++) {
obj2s[i].setAttribute("type", atype); // each field
}
for (i=0; i<obj3s.length; i++) {
obj3s[i].innerHTML = title; // each record show button
}
}

Expand Down

0 comments on commit 61df79c

Please sign in to comment.