Skip to content

Commit

Permalink
refactor index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladik-gif committed Nov 5, 2024
1 parent 2adbd00 commit 8a4ac51
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/main/resources/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ <h2>Subscribe to topic</h2>
<br/>

<h2>Log Text</h2>
<textarea rows="30" cols="100" id="logtext">

</textarea>

<label for="logtext"></label>
<textarea rows="30" cols="100" id="logtext"></textarea>

</div>

Expand Down Expand Up @@ -140,7 +139,7 @@ <h2>Log Text</h2>


function refreshTokenAndReconnect() {
updateAccessToken().then(newAccessToken => {
updateAccessToken().then(() => {
if (stompClient) {
stompClient.disconnect(() => {
console.log('Disconnected from WebSocket');
Expand Down Expand Up @@ -201,26 +200,24 @@ <h2>Log Text</h2>
if (topicId.trim() === '') {
console.log('topicId is empty');
stompClient.subscribe(subToTopicDest, function (messages) {
let parseMessage = JSON.parse(messages.body);
JSON.parse(messages.body);
});
} else {
stompClient.subscribe(subToTopicDest + topicId, function (messages) {
let parseMessage = JSON.parse(messages.body);
JSON.parse(messages.body);
});
}
}

function addToLog(destination, object) {
let logtextElement = document.getElementById('logtext');

let now = new Date();
let formattedDateTime = now.toLocaleString();
let logTextElement = document.getElementById('logText');
let formattedDateTimeNow = new Date().toLocaleString();

logtextElement.append(formattedDateTime + ' ' + destination + '\n');
logtextElement.append('\n' + JSON.stringify(object, null, 2) + '\n');
logtextElement.append('=================================================================== \n');
logTextElement.append(formattedDateTimeNow + ' ' + destination + '\n');
logTextElement.append('\n' + JSON.stringify(object, null, 2) + '\n');
logTextElement.append('=================================================================== \n');

logtextElement.scrollTop = logtextElement.scrollHeight;
logTextElement.scrollTop = logTextElement.scrollHeight;
}


Expand Down

0 comments on commit 8a4ac51

Please sign in to comment.