Skip to content

Commit a587480

Browse files
committed
fix core page features for java study files
1 parent cc11cae commit a587480

File tree

15 files changed

+390
-106
lines changed

15 files changed

+390
-106
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,20 @@
55
66
## Project Studies:
77
You can test all my [JAVA files at this Github-Pages](https://biralavor.github.io/FIAP-DomainDrivenDesign-JAVA/)
8+
9+
## GitHub Pages Features
10+
11+
- Terminal-like UI with a red theme
12+
- Interactive menu of Java study files (Cliente.java, Calculator.java, BreadMaker.java)
13+
- Keyboard navigation (arrow keys) and touch/mouse support
14+
- Switch indicator (▶) at the left side of selected menu items
15+
- View source code and run Java files in the browser using simulated Java execution
16+
- Consistent experience for both desktop and mobile users
17+
18+
### Navigation
19+
20+
- **↑/↓ Arrow Keys**: Navigate through menu items
21+
- **→ Right Arrow**: View source code of selected item
22+
- **← Left Arrow**: Go back to previous screen
23+
- **Enter**: Run the selected Java file
24+
- **b**: Return to main menu from any screen

assets/css/style.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,14 @@ body {
2222
margin-top: 40px;
2323
font-size: 0.9em;
2424
}
25+
26+
.kbd {
27+
background-color: #444;
28+
color: #fff;
29+
padding: 2px 5px;
30+
border-radius: 3px;
31+
font-size: 0.9em;
32+
display: inline-block;
33+
margin: 0 2px;
34+
box-shadow: 0 2px 0 #222;
35+
}

assets/css/terminal.css

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,57 @@
3232
color: #ff5555;
3333
font-weight: bold;
3434
}
35+
.terminal-menu-item {
36+
display: flex;
37+
align-items: center;
38+
gap: 8px;
39+
cursor: pointer;
40+
padding: 4px 0;
41+
}
42+
.terminal-menu-item.active {
43+
color: #ff5555;
44+
font-weight: bold;
45+
}
46+
#terminal-menu-list {
47+
margin-top: 18px;
48+
}
49+
.mobile-menu-btns {
50+
margin-top: 18px;
51+
display: flex;
52+
flex-direction: column;
53+
gap: 8px;
54+
}
55+
.mobile-menu-btn {
56+
background-color: #333;
57+
color: #fff;
58+
border: none;
59+
padding: 8px 16px;
60+
border-radius: 4px;
61+
cursor: pointer;
62+
width: 100%;
63+
}
64+
.mobile-menu-btn.active {
65+
background-color: #ff5555;
66+
}
67+
.mobile-output-btns, .mobile-source-btns {
68+
margin-top: 16px;
69+
display: flex;
70+
gap: 8px;
71+
flex-wrap: wrap;
72+
}
73+
.mobile-output-btns button, .mobile-source-btns button {
74+
background-color: #333;
75+
color: #fff;
76+
border: none;
77+
padding: 8px 16px;
78+
border-radius: 4px;
79+
cursor: pointer;
80+
}
81+
.switch-indicator {
82+
display: inline-block;
83+
width: 18px;
84+
text-align: center;
85+
}
3586
.menu {
3687
margin-top: 8px;
3788
display: flex;
@@ -77,6 +128,120 @@
77128
.run-btn:hover {
78129
background-color: #218838;
79130
}
131+
.terminal-instruction {
132+
color: #888;
133+
}
134+
.file-description {
135+
color: #ffb86c;
136+
}
137+
.terminal-output {
138+
color: #ff5555;
139+
}
80140
.hidden {
81141
display: none;
82142
}
143+
144+
.java-input-dialog {
145+
position: fixed;
146+
top: 40%;
147+
left: 50%;
148+
transform: translate(-50%, -50%);
149+
background: #222;
150+
padding: 24px 32px;
151+
border-radius: 8px;
152+
z-index: 9999;
153+
color: #fff;
154+
box-shadow: 0 0 16px #ff5555cc;
155+
}
156+
157+
.java-input-prompt {
158+
margin-bottom: 12px;
159+
}
160+
161+
.java-input-field {
162+
width: 220px;
163+
padding: 8px;
164+
font-size: 1em;
165+
}
166+
167+
.java-input-btn {
168+
margin-left: 12px;
169+
padding: 8px 16px;
170+
background-color: #ff5555;
171+
border: none;
172+
color: white;
173+
border-radius: 4px;
174+
cursor: pointer;
175+
}
176+
177+
/* Terminal Menu Enhancements */
178+
.terminal-menu-item:hover {
179+
color: #ff8888;
180+
}
181+
182+
.switch-indicator {
183+
color: #ff5555;
184+
}
185+
186+
/* Mobile-specific styles */
187+
@media (max-width: 768px) {
188+
#terminal {
189+
padding: 16px;
190+
min-height: 350px;
191+
margin-top: 20px;
192+
width: 90%;
193+
}
194+
195+
.mobile-menu-btns {
196+
display: flex;
197+
flex-direction: column;
198+
gap: 10px;
199+
}
200+
201+
.mobile-menu-btn {
202+
padding: 12px 16px;
203+
font-size: 16px;
204+
}
205+
206+
.mobile-output-btns button,
207+
.mobile-source-btns button {
208+
padding: 12px 16px;
209+
flex-grow: 1;
210+
text-align: center;
211+
font-size: 16px;
212+
}
213+
214+
.ansi-title {
215+
font-size: 2em;
216+
}
217+
}
218+
219+
/* Run button animations */
220+
.run-btn:active {
221+
transform: scale(0.95);
222+
}
223+
224+
/* Loading animation */
225+
.loading-dots {
226+
display: inline-block;
227+
}
228+
229+
.loading-dots:after {
230+
content: '.';
231+
animation: dots 1.5s steps(5, end) infinite;
232+
}
233+
234+
@keyframes dots {
235+
0%, 20% {
236+
content: '.';
237+
}
238+
40% {
239+
content: '..';
240+
}
241+
60% {
242+
content: '...';
243+
}
244+
80%, 100% {
245+
content: '';
246+
}
247+
}

assets/img/favicon.svg

Lines changed: 6 additions & 0 deletions
Loading

assets/java/TestRunner.class

1.04 KB
Binary file not shown.

assets/java/TestRunner.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// This is a test file to demonstrate loading and execution
2+
// of Java class files in the browser
3+
4+
public class TestRunner {
5+
public static void main(String[] args) {
6+
System.out.println("Running Java code in the browser...");
7+
8+
// Print class info
9+
System.out.println("\nClass loading test successful!");
10+
System.out.println("Java version: " + System.getProperty("java.version"));
11+
System.out.println("JVM vendor: WebAssembly JVM");
12+
}
13+
}
1.99 KB
Binary file not shown.
3.92 KB
Binary file not shown.
1.86 KB
Binary file not shown.

assets/js/main.js

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,33 @@ function renderTerminal() {
1818
const terminal = document.getElementById('terminal');
1919
let html = '';
2020
if (terminalState === 'menu') {
21-
html += '<span style="color:#888">Use ↑/↓ to select, Enter/double-tap to run, to view code.</span><br>';
21+
html += '<span class="terminal-instruction">Use <span class="kbd">↑</span><span class="kbd">↓</span> to select, <span class="kbd">Enter</span>/double-tap to run, <span class="kbd">→</span> to view code.</span><br>';
2222
// Terminal printed menu with switch indicator
23-
html += '<div id="terminal-menu-list" style="margin-top:18px;">';
23+
html += '<div id="terminal-menu-list">';
2424
javaFilesList.forEach((file, idx) => {
25-
html += `<div class="terminal-menu-item${idx===selectedFileIdx?' active':''}" data-idx="${idx}" style="display:flex;align-items:center;gap:8px;cursor:pointer;">`;
26-
html += `<span style="display:inline-block;width:18px;text-align:center;">${idx===selectedFileIdx?'▶':'&nbsp;'}</span>`;
25+
html += `<div class="terminal-menu-item${idx===selectedFileIdx?' active':''}" data-idx="${idx}">`;
26+
html += `<span class="switch-indicator">${idx===selectedFileIdx?'▶':'&nbsp;'}</span>`;
2727
html += `<span>${file.label}</span>`;
2828
html += '</div>';
2929
});
3030
html += '</div>';
31-
html += '<br><span style="color:#ffb86c">' + javaFilesList[selectedFileIdx].brief + '</span>';
31+
html += '<br><span class="file-description">' + javaFilesList[selectedFileIdx].brief + '</span>';
3232
// Mobile menu buttons (below for accessibility)
33-
html += '<div class="mobile-menu-btns" style="margin-top:18px;">';
33+
html += '<div class="mobile-menu-btns">';
3434
javaFilesList.forEach((file, idx) => {
3535
html += `<button class="mobile-menu-btn${idx===selectedFileIdx?' active':''}" data-idx="${idx}">${file.label}</button>\n`;
3636
});
3737
html += '</div>';
3838
} else if (terminalState === 'output') {
39-
html += '<pre style="color:#ff5555;">' + lastOutputText + '</pre>';
40-
html += '<br><span style="color:#888">[→] Check source code | [b] Back to menu</span>';
39+
html += '<pre class="terminal-output">' + lastOutputText + '</pre>';
40+
html += '<br><span class="terminal-instruction"><span class="kbd">→</span> Check source code | <span class="kbd">b</span> Back to menu</span>';
4141
html += '<div class="mobile-output-btns"><button id="mobile-source-btn">Check Source Code</button> <button id="mobile-back-btn">Back to Menu</button></div>';
4242
} else if (terminalState === 'source') {
43-
html += '<pre style="color:#ff5555;">' + javaFiles[javaFilesList[selectedFileIdx].key] + '</pre>';
44-
html += '<br><span style="color:#888">[←] Back to output | [b] Back to menu</span>';
43+
html += '<pre class="terminal-output">' + javaFiles[javaFilesList[selectedFileIdx].key] + '</pre>';
44+
html += '<br><span class="terminal-instruction"><span class="kbd">←</span> Back to output | <span class="kbd">b</span> Back to menu</span>';
4545
html += '<div class="mobile-source-btns"><button id="mobile-back-output-btn">Back to Output</button> <button id="mobile-back-menu-btn">Back to Menu</button></div>';
4646
} else if (terminalState === 'running') {
47-
html += '<span style="color:#888">Running Java...</span>';
47+
html += '<span class="terminal-instruction">Running Java<span class="loading-dots"></span></span>';
4848
}
4949
terminal.innerHTML = html;
5050

@@ -83,9 +83,29 @@ function renderTerminal() {
8383
if (backOutputBtn) backOutputBtn.onclick = () => showOutput(lastOutputText);
8484
const backMenuBtn = document.getElementById('mobile-back-menu-btn');
8585
if (backMenuBtn) backMenuBtn.onclick = showMenu;
86-
// Show/hide desktop source button
87-
const btn = document.getElementById('show-source-btn');
88-
if (btn) btn.style.display = (terminalState === 'output') ? 'inline-block' : 'none';
86+
}
87+
88+
// Handle Java input requests for simulations
89+
function requestJavaInput(promptText) {
90+
return new Promise(resolve => {
91+
const dialog = document.createElement('div');
92+
dialog.className = 'java-input-dialog';
93+
dialog.innerHTML = `<div class="java-input-prompt">${promptText || 'Java program requests input:'}</div>
94+
<input id="java-input" class="java-input-field" autofocus />
95+
<button id="java-input-ok" class="java-input-btn">OK</button>`;
96+
document.body.appendChild(dialog);
97+
document.getElementById('java-input').focus();
98+
document.getElementById('java-input-ok').onclick = () => {
99+
const val = document.getElementById('java-input').value + '\n';
100+
document.body.removeChild(dialog);
101+
resolve(val);
102+
};
103+
document.getElementById('java-input').onkeydown = (e) => {
104+
if (e.key === 'Enter') {
105+
document.getElementById('java-input-ok').click();
106+
}
107+
};
108+
});
89109
}
90110

91111
function showMenu() {
@@ -159,4 +179,5 @@ window.addEventListener('DOMContentLoaded', function() {
159179
window.showOutput = showOutput;
160180
window.showMenu = showMenu;
161181
window.showSource = showSource;
182+
window.requestJavaInput = requestJavaInput;
162183
window.runJavaFile = (key, cb) => runJavaFile(key).then(cb);

0 commit comments

Comments
 (0)