Merge remote-tracking branch 'upstream/master'

master
hughbarney 2021-11-30 23:45:24 +00:00
commit 24e2b01e22
4 changed files with 9 additions and 4 deletions

View File

@ -4434,7 +4434,7 @@
"shortName": "AuthWatch", "shortName": "AuthWatch",
"icon": "app.png", "icon": "app.png",
"screenshots": [{"url":"screenshot.png"}], "screenshots": [{"url":"screenshot.png"}],
"version": "0.01", "version": "0.02",
"description": "Google Authenticator compatible tool.", "description": "Google Authenticator compatible tool.",
"tags": "tool", "tags": "tool",
"interface": "interface.html", "interface": "interface.html",

View File

@ -1 +1,2 @@
0.02: Fix JSON save format
0.01: First release 0.01: First release

View File

@ -8,6 +8,7 @@ const algos = {
}; };
var tokens = require("Storage").readJSON("authentiwatch.json", true) || []; var tokens = require("Storage").readJSON("authentiwatch.json", true) || [];
tokens = tokens.data;
// QR Code Text // QR Code Text
// //
@ -257,7 +258,8 @@ function onSwipe(e) {
} }
if (e == -1 && state.curtoken != -1 && tokens[state.curtoken].period <= 0) { if (e == -1 && state.curtoken != -1 && tokens[state.curtoken].period <= 0) {
tokens[state.curtoken].period--; tokens[state.curtoken].period--;
require("Storage").writeJSON("authentiwatch.json", tokens); let save={data:tokens,count:tokens.length};
require("Storage").writeJSON("authentiwatch.json", save);
state.nextTime = 0; state.nextTime = 0;
state.hide = 2; state.hide = 2;
draw(); draw();

View File

@ -322,7 +322,8 @@ function loadTokens() {
Puck.eval(`require('Storage').read(${JSON.stringify('authentiwatch.json')})`,data=>{ Puck.eval(`require('Storage').read(${JSON.stringify('authentiwatch.json')})`,data=>{
Util.hideModal(); Util.hideModal();
try { try {
tokens = JSON.parse(data); let load = JSON.parse(data);
tokens = load.data;
updateTokens(); updateTokens();
} catch { } catch {
tokens = []; tokens = [];
@ -333,7 +334,8 @@ function loadTokens() {
*/ */
function saveTokens() { function saveTokens() {
Util.showModal('Saving...'); Util.showModal('Saving...');
Puck.write(`\x10require('Storage').write(${JSON.stringify('authentiwatch.json')},${JSON.stringify(tokens)})\n`,()=>{ let save={data:tokens,count:tokens.length};
Puck.write(`\x10require('Storage').write(${JSON.stringify('authentiwatch.json')},${JSON.stringify(save)})\n`,()=>{
Util.hideModal(); Util.hideModal();
}); });
} }