feat(web): introduce saving and discarding changes
This commit is contained in:
parent
70ac14a17a
commit
fefff3ce45
22
web/public/js/tfm-database.js
Normal file
22
web/public/js/tfm-database.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
$(document).on("click", "#btn-save", function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
let resp = tdb_query("$TFM", 4, "");
|
||||||
|
if (resp.status) {
|
||||||
|
alert("Successfully saved!");
|
||||||
|
} else {
|
||||||
|
alert("Something went wrong!");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on("click", "#btn-discard", function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
if (!confirm("All unsaved changes will be lost permanently. Are you sure?")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let resp = tdb_query("$TFM", 2, "");
|
||||||
|
if (resp.status) {
|
||||||
|
alert("Successfully reloaded database!");
|
||||||
|
} else {
|
||||||
|
alert("Something went wrong!");
|
||||||
|
}
|
||||||
|
});
|
||||||
@ -24,16 +24,22 @@
|
|||||||
<link rel="stylesheet" href="/css/bootstrap.min.css">
|
<link rel="stylesheet" href="/css/bootstrap.min.css">
|
||||||
<link rel="stylesheet" href="/css/general.css">
|
<link rel="stylesheet" href="/css/general.css">
|
||||||
<script src="/js/jquery-3.6.0.min.js"></script>
|
<script src="/js/jquery-3.6.0.min.js"></script>
|
||||||
|
<script src="/js/tdbms.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Welcome to Tanabata File Manager!</h1>
|
<h1>Welcome to Tanabata File Manager!</h1>
|
||||||
<main>
|
<main>
|
||||||
<h2>Files or tags?</h2>
|
<h2>Come on, what to do?</h2>
|
||||||
<div class="contents-wrapper">
|
<div class="contents-wrapper">
|
||||||
<a href="/tfm/files" class="btn btn-primary">Files</a>
|
<a href="/tfm/files" class="btn btn-primary">Files</a>
|
||||||
<a href="/tfm/tags" class="btn btn-primary">Tags</a>
|
<a href="/tfm/tags" class="btn btn-primary">Tags</a>
|
||||||
<a href="/" class="btn btn-outline-secondary">Home</a>
|
<a href="/" class="btn btn-outline-secondary">Home</a>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="contents-wrapper">
|
||||||
|
<button class="btn btn-success" id="btn-save">Save changes</button>
|
||||||
|
<button class="btn btn-danger" id="btn-discard">Discard changes</button>
|
||||||
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
<script src="/js/tfm-database.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user