Sell soul to the css gods

This commit is contained in:
Joren 2024-09-06 18:31:42 +02:00
parent 3872c1c4ca
commit 93d262d293
Signed by: Joren
GPG Key ID: 280E33DFBC0F1B55
2 changed files with 178 additions and 8 deletions

View File

@ -1,5 +1,91 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Downloader</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
background-color: #1e1e1e;
color: #d4d4d4;
line-height: 1.6;
padding: 20px;
max-width: 800px;
margin: 0 auto;
box-sizing: border-box;
}
h1, h2 {
border-bottom: 1px solid #333;
padding-bottom: 10px;
word-wrap: break-word;
}
form {
margin-bottom: 20px;
display: flex;
flex-direction: column;
}
input[type="file"], input[type="submit"] {
background-color: #2d2d2d;
color: #d4d4d4;
border: 1px solid #444;
padding: 8px 12px;
border-radius: 4px;
margin-bottom: 10px;
max-width: 100%;
}
input[type="submit"] {
cursor: pointer;
background-color: #4CAF50;
color: white;
}
input[type="submit"]:hover {
background-color: #45a049;
}
ul {
list-style-type: none;
padding: 0;
}
li {
background-color: #2d2d2d;
margin-bottom: 10px;
padding: 10px;
border-radius: 4px;
word-wrap: break-word;
}
.job-title {
font-size: 1.1em;
font-weight: bold;
margin-bottom: 5px;
}
.job-title a {
color: #58a6ff;
text-decoration: none;
}
.job-title a:hover {
text-decoration: underline;
}
.job-info {
font-size: 0.9em;
color: #a0a0a0;
}
.progress-text {
display: inline-block;
width: 5em;
}
@media (max-width: 600px) {
body {
padding: 10px;
}
h1, h2 {
font-size: 1.5em;
}
input[type="file"], input[type="submit"] {
font-size: 16px;
}
}
</style>
</head>
<body>
<h1>Simple Downloader</h1>
<form action="/upload" method="post" enctype="multipart/form-data">
@ -10,9 +96,12 @@
<ul>
{{range $filename, $info := .Jobs}}
<li>
<a href="/progress?filename={{$filename}}">{{$filename}}</a>:
{{printf "%.2f%%" $info.Percentage}}
(Current file: {{$info.CurrentFile}})
<div class="job-title">
<a href="/progress?filename={{$filename}}">{{$filename}}</a>
</div>
<div class="job-info">
Progress: <span class="progress-text">{{printf "%5.1f%%" $info.Percentage}}</span> Current file: {{$info.CurrentFile}}
</div>
</li>
{{else}}
<li>No active jobs</li>

View File

@ -1,9 +1,89 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Processing {{.Filename}}</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
background-color: #1e1e1e;
color: #d4d4d4;
line-height: 1.6;
padding: 20px;
max-width: 800px;
margin: 0 auto;
box-sizing: border-box;
}
h1 {
border-bottom: 1px solid #333;
padding-bottom: 10px;
word-wrap: break-word;
}
#progress-container {
background-color: #2d2d2d;
border-radius: 4px;
margin-bottom: 20px;
padding: 20px;
}
#progress-bar-container {
background-color: #444;
height: 20px;
border-radius: 10px;
overflow: hidden;
margin-bottom: 10px;
position: relative;
}
#progress-bar {
background-color: #4CAF50;
height: 100%;
width: 0;
transition: width 0.5s ease-in-out;
}
#progress-text {
position: absolute;
top: 50%;
left: 0;
right: 0;
transform: translateY(-50%);
text-align: center;
color: #fff;
font-weight: bold;
text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
line-height: 20px;
}
#currentFile {
margin-top: 10px;
word-wrap: break-word;
}
@media (max-width: 600px) {
body {
padding: 10px;
}
h1 {
font-size: 1.5em;
}
#progress-container {
padding: 10px;
}
#progress-bar-container {
height: 15px;
}
#progress-text {
font-size: 0.9em;
}
}
</style>
</head>
<body>
<h1>Processing {{.Filename}}</h1>
<div id="progress">0%</div>
<div id="currentFile"></div>
<div id="progress-container">
<div id="progress-bar-container">
<div id="progress-bar"></div>
<div id="progress-text">0%</div>
</div>
<div id="currentFile"></div>
</div>
<script>
function updateProgress() {
fetch('/progress?filename={{.Filename}}', {
@ -14,7 +94,8 @@
.then(response => response.json())
.then(data => {
const progress = Math.round(data.Percentage);
document.getElementById('progress').innerText = progress + '%';
document.getElementById('progress-bar').style.width = progress + '%';
document.getElementById('progress-text').innerText = progress + '%';
document.getElementById('currentFile').innerText = 'Current file: ' + (data.CurrentFile || 'None');
if (progress < 100) {
setTimeout(updateProgress, 1000);