Skip to content

Commit

Permalink
Use ES6 module system
Browse files Browse the repository at this point in the history
  • Loading branch information
svera committed Jan 12, 2025
1 parent 9ae0f40 commit be20a72
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
11 changes: 11 additions & 0 deletions internal/webserver/embedded/js/datetime.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"use strict";

import { DateTime } from "./luxon.min.js";

document.addEventListener('DOMContentLoaded', function() {
const datetime = document.querySelectorAll('.datetime span');
datetime.forEach(function(element) {
const dt = DateTime.fromISO(element.textContent);
element.textContent = dt.toRelative({ locale: document.documentElement.lang });
});
});
2 changes: 1 addition & 1 deletion internal/webserver/embedded/js/luxon.min.js

Large diffs are not rendered by default.

12 changes: 1 addition & 11 deletions internal/webserver/embedded/views/user/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,4 @@ <h2>{{t $lang "Users"}}</h2>
{{template "partials/delete-modal" dict "Lang" $lang "Action" "users" "ModalHeader" "Delete user" "ModalBody" "Are you sure you want to delete this user?" "ModalErrorMessage" "There was an error deleting the user, try again later"}}

<script type="text/javascript" src="/js/delete.js"></script>
<script type="text/javascript" src="/js/luxon.min.js"></script>

<script>
document.addEventListener('DOMContentLoaded', function() {
const datetime = document.querySelectorAll('.datetime span');
datetime.forEach(function(element) {
const dt = luxon.DateTime.fromISO(element.textContent);
element.textContent = dt.toRelative({ locale: '{{$lang}}' });
});
});
</script>
<script type="module" src="/js/datetime.js"></script>

0 comments on commit be20a72

Please sign in to comment.