welsonjs/app/index.js

33 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-11-05 05:09:20 +00:00
////////////////////////////////////////////////////////////////////////
2020-11-10 09:13:41 +00:00
// index.js
2020-11-05 05:09:20 +00:00
////////////////////////////////////////////////////////////////////////
2020-11-25 06:10:02 +00:00
2021-09-21 11:59:57 +00:00
var FILE = require("lib/file");
var OldBrowser = require("lib/oldbrowser");
2021-09-21 03:28:25 +00:00
var token;
2020-11-05 05:09:20 +00:00
if (FILE.fileExists("token.txt")) {
token = FILE.readFile("token.txt", FILE.CdoCharset.CdoUTF_8);
2020-11-05 05:09:20 +00:00
}
OldBrowser.setContent(FILE.readFile("app\\signin.html", FILE.CdoCharset.CdoUTF_8));
2020-11-25 08:08:17 +00:00
2021-09-21 03:28:25 +00:00
document.getElementById("loginform").onsubmit = function(ev) {
ev.preventDefault();
};
2020-11-05 05:09:20 +00:00
2021-09-21 03:28:25 +00:00
if (FILE.fileExists("credential.json")) {
var credential = JSON.parse(FILE.readFile("credential.json", FILE.CdoCharset.CdoUTF_8));
2021-09-21 03:28:25 +00:00
document.getElementById("txt_email").value = credential.email;
document.getElementById("txt_password").value = credential.password;
2020-11-05 05:09:20 +00:00
}
2021-09-21 03:28:25 +00:00
document.getElementById("btn_submit").onclick = function() {
var credential = {
"email": document.getElementById("txt_email").value,
"password": document.getElementById("txt_password").value
};
FILE.writeFile("credential.json", JSON.stringify(credential), FILE.CdoCharset.CdoUTF_8);
2021-09-21 03:28:25 +00:00
};