-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimulator.html
164 lines (147 loc) · 6.48 KB
/
simulator.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>UbuntuBoost Simulator</title>
<!-- Tailwind CSS CDN for modern styling -->
<script src="https://cdn.tailwindcss.com"></script>
<style>
body {
background-color: #f0f4f8;
}
.terminal {
background-color: #1e293b;
color: #00ff00;
font-family: 'Courier New', Courier, monospace;
padding: 20px;
height: 300px;
overflow-y: auto;
border-radius: 8px;
white-space: pre-wrap;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.btn-primary {
background-color: #2563eb;
color: white;
transition: background-color 0.3s ease;
}
.btn-primary:hover {
background-color: #1d4ed8;
}
.fade-in {
opacity: 0;
animation: fadeIn 1s forwards;
}
@keyframes fadeIn {
to {
opacity: 1;
}
}
.progress-bar {
width: 0;
height: 8px;
background-color: #2563eb;
transition: width 1s ease;
border-radius: 4px;
}
.error {
color: #ff4d4d;
}
</style>
</head>
<body class="flex flex-col items-center justify-center min-h-screen p-6">
<div class="bg-white p-8 rounded-lg shadow-lg max-w-lg">
<h1 class="text-3xl font-bold text-center mb-6">UbuntuBoost Simulator</h1>
<!-- Buttons to control simulation and repository access -->
<div class="flex justify-between mb-4">
<button id="runBtn" class="btn-primary py-2 px-4 rounded focus:outline-none">Run Simulation</button>
<button id="downloadBtn" class="btn-primary py-2 px-4 rounded focus:outline-none">Download & Contribute</button>
</div>
<!-- Terminal-like display for visualizing program steps -->
<div id="terminal" class="terminal mb-4">
<p class="fade-in">Press "Run Simulation" to start the simulation...</p>
</div>
<!-- Progress bar -->
<div id="progressBarContainer" class="bg-gray-200 w-full rounded-lg h-8 hidden">
<div id="progressBar" class="progress-bar"></div>
</div>
<!-- Explanation below the terminal -->
<p class="text-sm text-gray-600 mt-4">
Simulate how <strong>run.py</strong>, <strong>install.py</strong>, and <strong>src/init.py</strong> work together to run UbuntuBoost or MacBoost.
Visualize the process before downloading the project from GitHub.
</p>
</div>
<!-- JavaScript for controlling the simulation -->
<script>
// Select elements for interaction
const runBtn = document.getElementById('runBtn');
const downloadBtn = document.getElementById('downloadBtn');
const terminal = document.getElementById('terminal');
const progressBar = document.getElementById('progressBar');
const progressBarContainer = document.getElementById('progressBarContainer');
// Define the steps for simulating the program flow
const steps = [
{ text: "Checking system environment... 💻", delay: 1000 },
{ text: "Creating virtual environment... 🔧", delay: 2000 },
{ text: "Installing dependencies... 📦", delay: 2500, progress: 40 },
{ text: "Running install.py... ⚙️", delay: 1500 },
{ text: "Executing src/__init__.py... 🤖", delay: 2000 },
{ text: "Determining correct optimizer (UbuntuBoost/MacBoost)... 🔍", delay: 2500, progress: 60 },
{ text: "Optimization in progress... ⚡", delay: 2500 },
{ text: "Optimization complete! 🎉", delay: 1000, progress: 100 }
];
// Simulate an error step to show how the system handles issues
const errorStep = { text: "Error: Failed to install pygame 😱", delay: 2000, error: true };
let currentStep = 0;
// Function to simulate terminal output
function simulateStep() {
if (currentStep < steps.length) {
const step = steps[currentStep];
const p = document.createElement('p');
p.classList.add('fade-in');
p.textContent = step.text;
if (step.error) {
p.classList.add('error');
}
terminal.appendChild(p);
// Update progress bar if progress is part of the step
if (step.progress !== undefined) {
progressBarContainer.classList.remove('hidden');
progressBar.style.width = step.progress + '%';
}
// Scroll terminal to the bottom to show the latest log
terminal.scrollTop = terminal.scrollHeight;
currentStep++;
setTimeout(simulateStep, step.delay); // Schedule next step after delay
} else {
const completeMessage = document.createElement('p');
completeMessage.classList.add('text-blue-500', 'fade-in');
completeMessage.textContent = "Simulation complete. You can now download and contribute!";
terminal.appendChild(completeMessage);
terminal.scrollTop = terminal.scrollHeight;
}
}
// Function to start simulation
runBtn.addEventListener('click', () => {
terminal.innerHTML = "<p class='fade-in'>Starting UbuntuBoost/MacBoost simulation...</p>";
currentStep = 0;
simulateStep();
// Randomly simulate an error after step 3 (dependencies installation)
if (Math.random() > 0.7) {
setTimeout(() => {
const errorMessage = document.createElement('p');
errorMessage.classList.add('error', 'fade-in');
errorMessage.textContent = errorStep.text;
terminal.appendChild(errorMessage);
terminal.scrollTop = terminal.scrollHeight;
}, steps[2].delay + 1500); // Error occurs after step 3
}
});
// Function to redirect to GitHub repository
downloadBtn.addEventListener('click', () => {
window.open('https://github.com/Kvnbbg/UbuntuBoost', '_blank');
});
</script>
</body>
</html>