refactor(web): move common TDBMS functions to tdbms.js
This commit is contained in:
@@ -2,87 +2,10 @@ var db_name = localStorage["tfm_db_name"];
|
||||
if (db_name == null) {
|
||||
location.href = "/tfm/settings";
|
||||
}
|
||||
var sasahyou = null, sappyou = null, shoppyou = null;
|
||||
if (localStorage["sasahyou"] != null) {
|
||||
sasahyou = JSON.parse(localStorage["sasahyou"]);
|
||||
}
|
||||
if (localStorage["sappyou"] != null) {
|
||||
sappyou = JSON.parse(localStorage["sappyou"]);
|
||||
}
|
||||
if (localStorage["shoppyou"] != null) {
|
||||
shoppyou = JSON.parse(localStorage["shoppyou"]);
|
||||
}
|
||||
var sasahyou_mts = 0, sappyou_mts = 0, shoppyou_mts = 0;
|
||||
if (localStorage["sasahyou_mts"] != null) {
|
||||
sasahyou_mts = parseInt(localStorage["sasahyou_mts"]);
|
||||
}
|
||||
if (localStorage["sappyou_mts"] != null) {
|
||||
sappyou_mts = parseInt(localStorage["sappyou_mts"]);
|
||||
}
|
||||
if (localStorage["shoppyou_mts"] != null) {
|
||||
shoppyou_mts = parseInt(localStorage["shoppyou_mts"]);
|
||||
}
|
||||
var current_sasa = null, current_tanzaku = null;
|
||||
var current_sasa_index = -1;
|
||||
var menu_count = 0;
|
||||
|
||||
function sasahyou_load() {
|
||||
let db_info = tdb_query(db_name, 0, "");
|
||||
if (db_info == null || !db_info.status) {
|
||||
alert("Failed to fetch TFM database");
|
||||
throw new Error("Failed to fetch TFM database");
|
||||
}
|
||||
if (sasahyou == null || sasahyou_mts !== db_info.data[0].sasahyou.mts) {
|
||||
let resp = tdb_query(db_name, 16, "");
|
||||
if (resp == null || !resp.status) {
|
||||
alert("Failed to get sasahyou");
|
||||
throw new Error("Failed to get sasahyou");
|
||||
}
|
||||
sasahyou = resp.data;
|
||||
sasahyou_mts = db_info.data[0].sasahyou.mts;
|
||||
localStorage["sasahyou"] = JSON.stringify(sasahyou);
|
||||
localStorage["sasahyou_mts"] = sasahyou_mts;
|
||||
}
|
||||
}
|
||||
|
||||
function sappyou_load() {
|
||||
let db_info = tdb_query(db_name, 0, "");
|
||||
if (db_info == null || !db_info.status) {
|
||||
alert("Failed to fetch TFM database");
|
||||
throw new Error("Failed to fetch TFM database");
|
||||
}
|
||||
if (sappyou == null || sappyou_mts !== db_info.data[0].sappyou.mts) {
|
||||
let resp = tdb_query(db_name, 32, "");
|
||||
if (resp == null || !resp.status) {
|
||||
alert("Failed to get sappyou");
|
||||
throw new Error("Failed to get sappyou");
|
||||
}
|
||||
sappyou = resp.data;
|
||||
sappyou_mts = db_info.data[0].sappyou.mts;
|
||||
localStorage["sappyou"] = JSON.stringify(sappyou);
|
||||
localStorage["sappyou_mts"] = sappyou_mts;
|
||||
}
|
||||
}
|
||||
|
||||
function shoppyou_load() {
|
||||
let db_info = tdb_query(db_name, 0, "");
|
||||
if (db_info == null || !db_info.status) {
|
||||
alert("Failed to fetch TFM database");
|
||||
throw new Error("Failed to fetch TFM database");
|
||||
}
|
||||
if (shoppyou == null || shoppyou_mts !== db_info.data[0].shoppyou.mts) {
|
||||
let resp = tdb_query(db_name, 8, "");
|
||||
if (resp == null || !resp.status) {
|
||||
alert("Failed to get shoppyou");
|
||||
throw new Error("Failed to get shoppyou");
|
||||
}
|
||||
shoppyou = resp.data;
|
||||
shoppyou_mts = db_info.data[0].shoppyou.mts;
|
||||
localStorage["shoppyou"] = JSON.stringify(shoppyou);
|
||||
localStorage["shoppyou_mts"] = shoppyou_mts;
|
||||
}
|
||||
}
|
||||
|
||||
function menu_view_file_open() {
|
||||
if (menu_count > 1) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user