Skip to content

Commit

Permalink
Use const insted of var and function
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomiej.zylinski committed Jun 10, 2024
1 parent e916f8c commit 49472b4
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/main/resources/templates/msgs-page.ftlh
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,13 @@
}
</style>
<script>
function htmlDecode(input) {
var doc = new DOMParser().parseFromString(input, "text/html");
const htmlDecode = (input) => {
const doc = new DOMParser().parseFromString(input, "text/html");
return doc.documentElement.textContent;
}

function toggleCollapse(contentId, button) {
var element = document.getElementById(contentId);
const toggleCollapse = (contentId, button) => {
const element = document.getElementById(contentId);
element.classList.toggle("collapsed");

// Update button text based on the state
Expand All @@ -164,9 +164,9 @@
}
}

function formatTimestamp(timestamp) {
var date = new Date(timestamp);
var options = {year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit'};
const formatTimestamp = (timestamp) => {
const date = new Date(timestamp);
const options = {year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit'};
return date.toLocaleDateString(undefined, options);
}
</script>
Expand Down Expand Up @@ -223,19 +223,19 @@

<script>
try {
var decodedMessage = htmlDecode('${message.body()?json_string}');
var messageData = JSON.parse(decodedMessage);
var formattedJson = JSON.stringify(messageData, null, 4);
document.getElementById('collapsible-${message_index}').textContent = formattedJson;
const decodedMessage = htmlDecode('${message.body()?json_string}');
const messageData = JSON.parse(decodedMessage);
document.getElementById('collapsible-${message_index}').textContent = JSON.stringify(messageData, null, 4);
} catch (error) {
document.getElementById('collapsible-${message_index}').textContent = '${message.body()}';
}

document.addEventListener('DOMContentLoaded', (event) => {
var timestamps = document.querySelectorAll('.message__timestamp');
timestamps.forEach(function (elem) {
var timestamp = elem.getAttribute('data-timestamp');
elem.textContent = formatTimestamp(timestamp);
document
.querySelectorAll('.message__timestamp')
.forEach((elem) => {
const timestamp = elem.getAttribute('data-timestamp');
elem.textContent = formatTimestamp(timestamp);
});
});
</script>
Expand Down

0 comments on commit 49472b4

Please sign in to comment.