aboutsummaryrefslogtreecommitdiff
path: root/src/webex/pages/show-db.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/webex/pages/show-db.ts')
-rw-r--r--src/webex/pages/show-db.ts41
1 files changed, 25 insertions, 16 deletions
diff --git a/src/webex/pages/show-db.ts b/src/webex/pages/show-db.ts
index d95951385..16ea80d2d 100644
--- a/src/webex/pages/show-db.ts
+++ b/src/webex/pages/show-db.ts
@@ -14,15 +14,19 @@
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-
/**
* Wallet database dump for debugging.
*
* @author Florian Dold
*/
-function replacer(match: string, pIndent: string, pKey: string, pVal: string,
- pEnd: string) {
+function replacer(
+ match: string,
+ pIndent: string,
+ pKey: string,
+ pVal: string,
+ pEnd: string,
+) {
const key = "<span class=json-key>";
const val = "<span class=json-value>";
const str = "<span class=json-string>";
@@ -36,18 +40,18 @@ function replacer(match: string, pIndent: string, pKey: string, pVal: string,
return r + (pEnd || "");
}
-
function prettyPrint(obj: any) {
- const jsonLine = /^( *)("[\w]+": )?("[^"]*"|[\w.+-]*)?([,[{])?$/mg;
+ const jsonLine = /^( *)("[\w]+": )?("[^"]*"|[\w.+-]*)?([,[{])?$/gm;
return JSON.stringify(obj, null as any, 3)
- .replace(/&/g, "&amp;").replace(/\\"/g, "&quot;")
- .replace(/</g, "&lt;").replace(/>/g, "&gt;")
- .replace(jsonLine, replacer);
+ .replace(/&/g, "&amp;")
+ .replace(/\\"/g, "&quot;")
+ .replace(/</g, "&lt;")
+ .replace(/>/g, "&gt;")
+ .replace(jsonLine, replacer);
}
-
document.addEventListener("DOMContentLoaded", () => {
- chrome.runtime.sendMessage({type: "dump-db"}, (resp) => {
+ chrome.runtime.sendMessage({ type: "dump-db" }, (resp) => {
const el = document.getElementById("dump");
if (!el) {
throw Error();
@@ -57,16 +61,18 @@ document.addEventListener("DOMContentLoaded", () => {
document.getElementById("download")!.addEventListener("click", (evt) => {
console.log("creating download");
const element = document.createElement("a");
- element.setAttribute("href", "data:text/plain;charset=utf-8," + encodeURIComponent(JSON.stringify(resp)));
+ element.setAttribute(
+ "href",
+ "data:text/plain;charset=utf-8," +
+ encodeURIComponent(JSON.stringify(resp)),
+ );
element.setAttribute("download", "wallet-dump.txt");
element.style.display = "none";
document.body.appendChild(element);
element.click();
});
-
});
-
const fileInput = document.getElementById("fileInput")! as HTMLInputElement;
fileInput.onchange = (evt) => {
if (!fileInput.files || fileInput.files.length !== 1) {
@@ -79,9 +85,12 @@ document.addEventListener("DOMContentLoaded", () => {
console.log("got file");
const dump = JSON.parse(e.target.result);
console.log("parsed contents", dump);
- chrome.runtime.sendMessage({ type: "import-db", detail: { dump } }, (resp) => {
- alert("loaded");
- });
+ chrome.runtime.sendMessage(
+ { type: "import-db", detail: { dump } },
+ (resp) => {
+ alert("loaded");
+ },
+ );
};
console.log("reading file", file);
fr.readAsText(file);