Skip to content

Commit

Permalink
..
Browse files Browse the repository at this point in the history
  • Loading branch information
zilvinas committed Oct 15, 2024
1 parent f1a6aa0 commit f0362cf
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 17 deletions.

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,19 @@
font-family: monospace;
padding: 10px;
border-radius: 5px;
max-height: 400px;
max-height: 800px;
overflow-y: auto;
white-space: pre-wrap;
/* Preserve formatting */
}
</style>
<script type="module" crossorigin src="/assets/index-RO_tAo3e.js"></script>
<script type="module" crossorigin src="/assets/index-tgGTH1kp.js"></script>
</head>

<body>
<main id="app">
<div id="console"></div>
</main>
<!-- <script src="main.js"></script> -->
</body>

</html>
5 changes: 2 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,19 @@
font-family: monospace;
padding: 10px;
border-radius: 5px;
max-height: 400px;
max-height: 800px;
overflow-y: auto;
white-space: pre-wrap;
/* Preserve formatting */
}
</style>
<script type="module" crossorigin src="assets/index-tgGTH1kp.js"></script>
</head>

<body>
<main id="app">
<div id="console"></div>
</main>
<!-- <script src="main.js"></script> -->
<script type="module" src="/src/main.ts"></script>
</body>

</html>
30 changes: 30 additions & 0 deletions index.html.orign
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>console-like Output</title>
<style>
#console {
/* background-color: #1e1e1e; */
color: #dcdcdc;
font-family: monospace;
padding: 10px;
border-radius: 5px;
max-height: 1000px;
overflow-y: auto;
white-space: pre-wrap;
/* Preserve formatting */
}
</style>
</head>

<body>
<main id="app">
<div id="console"></div>
</main>
<script type="module" src="/src/main.ts"></script>
</body>

</html>
2 changes: 2 additions & 0 deletions src/game-15-reconstruction/EpisodeRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { QTableUpdater } from './QTableUpdater';
import { Action } from './Action';
import { EnvironmentActionResult } from './EnvironmentActionResult';
import { Utils } from './utils/Utils';
import { ConsoleUtils } from './utils/ConsoleUtils';

export class EpisodeRunner {
private static experience: Set<ExperienceRecord> = new Set();
Expand Down Expand Up @@ -81,6 +82,7 @@ export class EpisodeRunner {
Utils.prnt(message);
Utils.prnt("");
await Utils.sleep(1000);
ConsoleUtils.clearScreen();
}

public static replayExperience(
Expand Down
9 changes: 2 additions & 7 deletions src/game-15-reconstruction/utils/ConsoleUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,20 @@ export class ConsoleUtils {
}

public static clearScreen() {
this.prnt("clearScrn ... ", "color: orange;");
const consoleDiv = document.getElementById('console');
if (consoleDiv) { consoleDiv.innerHTML = ''; }
}

public static prnt(message: string, style: string = ""): void {
const consoleDiv = document.getElementById('console');
if (consoleDiv) {
// Create a new div element for each message
const messageElement = document.createElement('div');
messageElement.textContent = message;

// Apply custom styles if provided
if (style) {
messageElement.style.cssText = style;
}

// Append the message to the custom Utils.prnt
consoleDiv.appendChild(messageElement);

// Scroll to the bottom of the Utils.prnt to show the latest message
consoleDiv.scrollTop = consoleDiv.scrollHeight;
}
}
Expand Down

0 comments on commit f0362cf

Please sign in to comment.