Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,29 @@ body {
background: black;
color: white;
text-align: center;
font-family: Arial, sans-serif;
margin-top: 100px;
}

button {
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
border: none;
border-radius: 8px;
margin-top: 10px;
}

#loading {
margin-top: 20px;
color: yellow;
}

#error {
margin-top: 20px;
color: red;
}

.hidden {
display: none;
}
26 changes: 25 additions & 1 deletion static/js/script.js
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
console.log("RustTune loaded");
const playBtn = document.getElementById("playBtn");
const loading = document.getElementById("loading");
const errorBox = document.getElementById("error");
const retryBtn = document.getElementById("retryBtn");

function simulateRequest() {
loading.classList.remove("hidden");
errorBox.classList.add("hidden");

setTimeout(() => {
loading.classList.add("hidden");

const success = Math.random() > 0.5;

if (!success) {
errorBox.classList.remove("hidden");
} else {
alert("Music Played Successfully 🎵");
}
}, 2000);
}

playBtn.addEventListener("click", simulateRequest);

retryBtn.addEventListener("click", simulateRequest);
11 changes: 10 additions & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@
<h1>🎧 RustTune</h1>
<p>Music app using Rust</p>

<button>Play</button>
<button id="playBtn">Play</button>

<div id="loading" class="hidden">
Loading...
</div>

<div id="error" class="hidden">
<p>Something went wrong!</p>
<button id="retryBtn">Retry</button>
</div>

<script src="/static/js/script.js"></script>
</body>
Expand Down