Switch Repo to notatio/notatio
This commit is contained in:
commit
9da51a1e6b
26 changed files with 4117 additions and 0 deletions
212
templates/list.html
Normal file
212
templates/list.html
Normal file
|
@ -0,0 +1,212 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>List Files</title>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
|
||||
<link rel="icon" href="/static/favicon.ico" type="image/x-icon">
|
||||
<script>
|
||||
// Function to convert Unix timestamps to local time
|
||||
function convertUnixTimeToLocalTime(unixTime, element) {
|
||||
const date = new Date(unixTime * 1000);
|
||||
element.textContent = date.toLocaleString();
|
||||
}
|
||||
|
||||
// Call the function for each timestamp on page load
|
||||
window.onload = function () {
|
||||
const creationTimeElements = document.querySelectorAll('.creation-time');
|
||||
const lastEditedTimeElements = document.querySelectorAll('.last-edited-time');
|
||||
|
||||
creationTimeElements.forEach(element => {
|
||||
const unixTime = parseInt(element.getAttribute('data-unix'));
|
||||
convertUnixTimeToLocalTime(unixTime, element);
|
||||
});
|
||||
|
||||
lastEditedTimeElements.forEach(element => {
|
||||
const unixTime = parseInt(element.getAttribute('data-unix'));
|
||||
convertUnixTimeToLocalTime(unixTime, element);
|
||||
});
|
||||
};
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="page-container" class="container">
|
||||
<h1>Welcome, {{.Username}}!</h1>
|
||||
|
||||
|
||||
|
||||
<!-- Upload Form Modal -->
|
||||
<div id="uploadModal" class="modal">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Upload File</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form method="post" action="/upload" enctype="multipart/form-data">
|
||||
<input type="file" name="file" id="file" accept=".md,.html" multiple required /><br /><br />
|
||||
<button type="submit" class="btn btn-primary">Upload</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- New File Modal -->
|
||||
<div id="newFileModal" class="modal">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Create New File</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="newFileForm" method="post" action="/create">
|
||||
<label for="newFileName">File Name:</label>
|
||||
<input type="text" name="newFileName" id="newFileName" required><br /><br />
|
||||
<button type="submit" id="createNewFile" class="btn btn-primary">Create</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="buttons-container" class="d-flex justify-content-between">
|
||||
<div>
|
||||
<button id="openUploadModal" class="btn btn-primary" data-bs-toggle="modal"
|
||||
data-bs-target="#uploadModal">Upload File</button>
|
||||
</div>
|
||||
<div>
|
||||
<button id="openNewFileModal" class="btn btn-primary" data-bs-toggle="modal"
|
||||
data-bs-target="#newFileModal">Create New File</button>
|
||||
</div>
|
||||
<div>
|
||||
<button id="openDeleteFileModal" class="btn btn-primary" data-bs-toggle="modal"
|
||||
data-bs-target="#deleteFileModal">Delete Files</button>
|
||||
</div>
|
||||
<div>
|
||||
<button id="exportFolder" class="btn btn-primary">Export Folder</button>
|
||||
</div>
|
||||
<div>
|
||||
<button onclick="location.href='/logout'" class="btn btn-primary">Logout</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Delete File Modal -->
|
||||
<div id="deleteFileModal" class="modal">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Delete Files</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="deleteForm" action="/delete" method="post">
|
||||
<div class="checklist">
|
||||
{{range .Files}}
|
||||
<label>
|
||||
<input type="checkbox" name="filesToDelete[]" value="{{.Filename}}">
|
||||
{{.Filename}}
|
||||
</label>
|
||||
<br>
|
||||
{{end}}
|
||||
</div>
|
||||
<button type="button" data-bs-dismiss="modal" class="btn btn-secondary">Cancel</button>
|
||||
<button type="button" id="checkAll" class="btn btn-primary">Check All</button>
|
||||
<button type="submit" id="deleteSelected" class="btn btn-danger">Delete Selected</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>File Name</th>
|
||||
<th>Creation Time</th>
|
||||
<th>Last Edited</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{range .Files}}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/edit?filename={{.Filename}}">{{.Filename}}</a>
|
||||
</td>
|
||||
<td>
|
||||
<span class="creation-time" data-unix="{{.CreationTime}}"></span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="last-edited-time" data-unix="{{.LastEdited}}"></span>
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
<script>
|
||||
const deleteForm = document.getElementById("deleteForm");
|
||||
const checkAllButton = document.getElementById("checkAll");
|
||||
const checkboxes = document.querySelectorAll('input[type="checkbox"]');
|
||||
checkAllButton.addEventListener("click", function () {
|
||||
checkboxes.forEach(checkbox => {
|
||||
checkbox.checked = true;
|
||||
});
|
||||
});
|
||||
|
||||
deleteForm.addEventListener("submit", function (event) {
|
||||
event.preventDefault(); // Stop form submission
|
||||
|
||||
// Get all checkboxes in the delete form
|
||||
const checkboxes = deleteForm.querySelectorAll('input[type="checkbox"]');
|
||||
const filesToDelete = [];
|
||||
|
||||
// Get the filenames of the selected files
|
||||
checkboxes.forEach(checkbox => {
|
||||
if (checkbox.checked) {
|
||||
filesToDelete.push(checkbox.value);
|
||||
}
|
||||
});
|
||||
|
||||
// Call the deleteFiles function to send the request to the server
|
||||
deleteFiles(filesToDelete);
|
||||
});
|
||||
|
||||
|
||||
function deleteFiles(filesToDelete) {
|
||||
// Send a POST request to the server to delete the selected files
|
||||
fetch("/delete", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ files: filesToDelete }),
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
// Files deleted successfully
|
||||
location.reload(); // Refresh the page to reflect the changes
|
||||
} else {
|
||||
// Handle the error, e.g., display an error message
|
||||
console.error("Error deleting files");
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error("Error deleting files:", error);
|
||||
});
|
||||
}
|
||||
// Handle exportFolder button click
|
||||
const exportFolderButton = document.getElementById("exportFolder");
|
||||
exportFolderButton.addEventListener("click", function () {
|
||||
window.location.href = "/export";
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue