separated utils from room template
This commit is contained in:
15
static/js/utils.js
Normal file
15
static/js/utils.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
// Utility functions for DocuPulse
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats a Unix timestamp into a localized date and time string
|
||||||
|
* @param {number} ts - Unix timestamp in seconds
|
||||||
|
* @returns {string} Formatted date and time string
|
||||||
|
*/
|
||||||
|
function formatDate(ts) {
|
||||||
|
if (!ts) return '';
|
||||||
|
const d = new Date(ts * 1000);
|
||||||
|
return d.toLocaleDateString() + ' ' + d.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Export the functions
|
||||||
|
export { formatDate };
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<meta name="csrf-token" content="{{ csrf_token }}">
|
<meta name="csrf-token" content="{{ csrf_token }}">
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/room.css') }}">
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/room.css') }}">
|
||||||
|
<script type="module" src="{{ url_for('static', filename='js/utils.js') }}"></script>
|
||||||
<div class="container mt-4">
|
<div class="container mt-4">
|
||||||
<div class="row mb-4">
|
<div class="row mb-4">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
@@ -95,7 +96,9 @@
|
|||||||
{% include 'components/overwrite_confirm_modal.html' %}
|
{% include 'components/overwrite_confirm_modal.html' %}
|
||||||
{% include 'components/move_modal.html' %}
|
{% include 'components/move_modal.html' %}
|
||||||
|
|
||||||
<script>
|
<script type="module">
|
||||||
|
import { formatDate } from "{{ url_for('static', filename='js/utils.js') }}";
|
||||||
|
|
||||||
// Define showDetailsModal function first
|
// Define showDetailsModal function first
|
||||||
function showDetailsModal(idx) {
|
function showDetailsModal(idx) {
|
||||||
// Check if currentFiles exists and idx is valid
|
// Check if currentFiles exists and idx is valid
|
||||||
@@ -199,12 +202,6 @@ async function initializeView() {
|
|||||||
toggleView(currentView);
|
toggleView(currentView);
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatDate(ts) {
|
|
||||||
if (!ts) return '';
|
|
||||||
const d = new Date(ts * 1000);
|
|
||||||
return d.toLocaleDateString() + ' ' + d.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'});
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderBreadcrumb() {
|
function renderBreadcrumb() {
|
||||||
const bc = document.getElementById('breadcrumb');
|
const bc = document.getElementById('breadcrumb');
|
||||||
bc.innerHTML = '';
|
bc.innerHTML = '';
|
||||||
|
|||||||
Reference in New Issue
Block a user