diff --git a/web/public/css/tfm.css b/web/public/css/tfm.css index a633e45..dfcc2d2 100644 --- a/web/public/css/tfm.css +++ b/web/public/css/tfm.css @@ -24,42 +24,6 @@ main { overflow-x: hidden; } -.sasa { - position: relative; - margin: 16px; - padding: 0; - width: 160px; - height: 160px; - border-radius: 20px; - background-image: url(/images/loader.gif); - background-size: cover; - background-position: center; - overflow: hidden; - cursor: pointer; -} - -.sasa .overlay { - position: absolute; - top: 0; - right: 0; - bottom: 0; - left: 0; - background-color: #0000; -} - -.sasa:hover .overlay { - background-color: #0002; -} - -.sasa.selected .overlay { - background-color: #0004; -} - -.thumb { - min-width: 100%; - min-height: 100%; -} - .menu-wrapper { display: none; flex-direction: column; @@ -84,11 +48,11 @@ main { overflow: hidden; } -#sasa-form { +form { padding: 2vw 2vw; } -#tanzaku-list { +.list { display: flex; flex-direction: row; justify-content: flex-start; @@ -101,6 +65,36 @@ main { overflow-x: hidden; } +.sasa { + position: relative; + margin: 16px; + padding: 0; + width: 160px; + height: 160px; + border-radius: 20px; + background-size: cover; + background-position: center; + overflow: hidden; + cursor: pointer; +} + +.sasa .overlay { + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + background-color: #0000; +} + +.sasa:hover .overlay { + background-color: #0002; +} + +.sasa.selected .overlay { + background-color: #0004; +} + .tanzaku { margin: 5px; padding: 7px; diff --git a/web/public/js/tfm-files.js b/web/public/js/tfm-files.js new file mode 100644 index 0000000..7a3d52a --- /dev/null +++ b/web/public/js/tfm-files.js @@ -0,0 +1,77 @@ +$(window).on("load", function () { + sasa_load(); + sasahyou.forEach((sasa) => { + $(".contents-wrapper").append(`
`); + }); + tanzaku_load(); + sappyou.forEach((tanzaku) => { + $(".list").append(`
${tanzaku.name}
`); + }); + kazari_load(); +}); + +$(document).on("dblclick", ".item", function (e) { + let id = parseInt($(this).attr("id").slice(1)); + sasahyou.every(sasa => { + if (sasa.id === id) { + current_sasa = sasa; + return false; + } + return true; + }); + $(".item.selected").removeClass("selected"); + $(".menu-wrapper").css("display", "flex"); + $("#name").val(decodeURI(current_sasa.path)); + $("#btn-full").attr("href", "/files/" + current_sasa.path); + let resp = tdb_query("$TFM", 24, '' + id); + if (!resp.status) { + alert("Something went wrong!"); + return; + } + resp.data.forEach(tanzaku => { + $(`#t${tanzaku.id}`).addClass("selected"); + }); +}); + +$(document).on("input", "#filter", function (e) { + let filter = $(this).val().toLowerCase(); + if (filter === "") { + $(".tanzaku").css("display", "block"); + return; + } + sappyou.forEach((tanzaku) => { + if (tanzaku.name.toLowerCase().includes(filter)) { + $(`#t${tanzaku.id}`).css("display", "block"); + } else { + $(`#t${tanzaku.id}`).css("display", "none"); + } + }); +}); + +$(document).on("click", "#btn-confirm", function (e) { + e.preventDefault(); + let resp = tdb_query("$TFM", 24, '' + current_sasa.id); + if (!resp.status) { + alert("Something went wrong!"); + return; + } + $(".menu-wrapper").css("display", "none"); + resp.data.forEach(tanzaku => { + let current = $(`#t${tanzaku.id}`) + if (current.hasClass("selected")) { + current.removeClass("selected"); + } else { + if (!tdb_query("$TFM", 9, '' + current_sasa.id + ' ' + tanzaku.id).status) { + console.log("ERROR: failed to remove kazari: " + current_sasa.id + '-' + tanzaku.id); + } + } + }); + $(".tanzaku.selected").each(function (index, element) { + if (!tdb_query("$TFM", 10, '' + current_sasa.id + ' ' + $(element).attr("id").slice(1))) { + console.log("ERROR: failed to add kazari: " + current_sasa.id + '-' + tanzaku.id); + } + }); + sappyou.forEach(tanzaku => { + $(`#t${tanzaku.id}`).removeClass("selected"); + }); +}) diff --git a/web/public/js/tfm.js b/web/public/js/tfm.js index ab3fbf7..3787a8c 100644 --- a/web/public/js/tfm.js +++ b/web/public/js/tfm.js @@ -2,8 +2,8 @@ var sasahyou = null, sappyou = null, shoppyou = null; var current_sasa = null, current_tanzaku = null; var sasa_modified = false, tanzaku_modified = false; -function sasa_load(id) { - resp = tdb_query("$TFM", 16, id < 0 ? "" : `${id}`); +function sasa_load() { + resp = tdb_query("$TFM", 16, ""); if (resp == null) { $(location).attr("href", "/auth"); throw new Error("Unauthorized"); @@ -12,16 +12,11 @@ function sasa_load(id) { alert("Something went wrong"); return; } - if (id < 0) { - sasahyou = resp.data; - sasahyou.forEach((sasa) => { - $(".contents-wrapper").append(`
`); - }); - } + sasahyou = resp.data; } -function tanzaku_load(id) { - resp = tdb_query("$TFM", 32, id < 0 ? "" : `${id}`); +function tanzaku_load() { + resp = tdb_query("$TFM", 32, ""); if (resp == null) { $(location).attr("href", "/auth"); throw new Error("Unauthorized"); @@ -30,12 +25,7 @@ function tanzaku_load(id) { alert("Something went wrong"); return; } - if (id < 0) { - sappyou = resp.data; - sappyou.forEach((tanzaku) => { - $("#tanzaku-list").append(`
${tanzaku.name}
`); - }); - } + sappyou = resp.data; } function kazari_load() { @@ -51,23 +41,16 @@ function kazari_load() { shoppyou = resp.data; } -$(window).on("load", function () { - sasa_load(-1); - tanzaku_load(-1); - kazari_load(); -}); - $(document).keyup(function (e) { if (e.key === "Escape") { $(".selected").removeClass("selected"); } }); -$(document).on("click", ".sasa", function (e) { +$(document).on("click", ".item", function (e) { let wasSelected = $(this).hasClass("selected"); if (!e.ctrlKey) { - $(".selected").removeClass("selected"); - wasSelected = false; + $(".item.selected").removeClass("selected"); } if (wasSelected) { $(this).removeClass("selected"); @@ -76,39 +59,7 @@ $(document).on("click", ".sasa", function (e) { } }); -$(document).on("dblclick", ".sasa", function (e) { - let id = parseInt($(this).attr("id").slice(1)); - sasahyou.every(sasa => { - if (sasa.id === id) { - current_sasa = sasa; - return false; - } - return true; - }); - $(".sasa.selected").removeClass("selected"); - $(".menu-wrapper").css("display", "flex"); - $("#sasa-name").val(decodeURI(current_sasa.path)); - $("#btn-full").attr("href", "/files/" + current_sasa.path); - let resp = tdb_query("$TFM", 24, '' + id); - if (!resp.status) { - alert("Something went wrong!"); - return; - } - resp.data.forEach(tanzaku => { - $(`#t${tanzaku.id}`).addClass("selected"); - }); -}); - -$(document).on("click", "#btn-close", function (e) { - e.preventDefault(); - $("#sasa-menu").css("display", "none"); - sappyou.forEach(tanzaku => { - $(`#t${tanzaku.id}`).removeClass("selected"); - }); -}); - -$(document).on("click", ".tanzaku", function (e) { - sasa_modified = true; +$(document).on("click", ".list-item", function (e) { if ($(this).hasClass("selected")) { $(this).removeClass("selected"); } else { @@ -116,45 +67,8 @@ $(document).on("click", ".tanzaku", function (e) { } }); -$(document).on("input", "#tanzaku-filter", function (e) { - let filter = $(this).val().toLowerCase(); - if (filter === "") { - $(".tanzaku").css("display", "block"); - return; - } - sappyou.forEach((tanzaku) => { - if (tanzaku.name.toLowerCase().includes(filter)) { - $(`#t${tanzaku.id}`).css("display", "block"); - } else { - $(`#t${tanzaku.id}`).css("display", "none"); - } - }); -}); - -$(document).on("click", "#btn-sasa-confirm", function (e) { +$(document).on("click", "#btn-close", function (e) { e.preventDefault(); - let resp = tdb_query("$TFM", 24, '' + current_sasa.id); - if (!resp.status) { - alert("Something went wrong!"); - return; - } - $("#sasa-menu").css("display", "none"); - resp.data.forEach(tanzaku => { - let current = $(`#t${tanzaku.id}`) - if (current.hasClass("selected")) { - current.removeClass("selected"); - } else { - if (!tdb_query("$TFM", 0b1001, '' + current_sasa.id + ' ' + tanzaku.id).status) { - console.log("ERROR: failed to remove kazari: " + current_sasa.id + '-' + tanzaku.id); - } - } - }); - $(".tanzaku.selected").each(function (index, element) { - if (!tdb_query("$TFM", 0b1010, '' + current_sasa.id + ' ' + $(element).attr("id").slice(1))) { - console.log("ERROR: failed to add kazari: " + current_sasa.id + '-' + tanzaku.id); - } - }); - sappyou.forEach(tanzaku => { - $(`#t${tanzaku.id}`).removeClass("selected"); - }); -}) + $(".menu-wrapper").css("display", "none"); + $(".list-item").removeClass("selected"); +}); diff --git a/web/public/tfm/files.html b/web/public/tfm/files.html index f7a488d..e134eb0 100644 --- a/web/public/tfm/files.html +++ b/web/public/tfm/files.html @@ -26,6 +26,7 @@ +

TFM Files

@@ -33,31 +34,31 @@
-