131 lines
3.7 KiB
Smarty
131 lines
3.7 KiB
Smarty
<!DOCTYPE html>
|
||
<html lang="fr">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<title>Réduction d’images</title>
|
||
<style>
|
||
body {
|
||
font-family: 'Segoe UI', sans-serif;
|
||
background: #f8f9fa;
|
||
padding: 40px;
|
||
}
|
||
|
||
.container {
|
||
max-width: 600px;
|
||
margin: auto;
|
||
background: white;
|
||
padding: 30px;
|
||
border-radius: 10px;
|
||
box-shadow: 0 8px 16px rgba(0,0,0,0.1);
|
||
}
|
||
|
||
h1 {
|
||
text-align: center;
|
||
color: #1e3a8a;
|
||
}
|
||
|
||
label {
|
||
margin-top: 20px;
|
||
font-weight: bold;
|
||
display: block;
|
||
}
|
||
|
||
input, select {
|
||
margin-top: 5px;
|
||
width: 100%;
|
||
padding: 10px;
|
||
font-size: 15px;
|
||
border: 1px solid #ccc;
|
||
border-radius: 6px;
|
||
}
|
||
|
||
button {
|
||
margin-top: 30px;
|
||
width: 100%;
|
||
background-color: #1e40af;
|
||
color: white;
|
||
border: none;
|
||
padding: 15px;
|
||
font-size: 16px;
|
||
border-radius: 6px;
|
||
cursor: pointer;
|
||
}
|
||
|
||
.loader {
|
||
display: none;
|
||
text-align: center;
|
||
margin-top: 40px;
|
||
}
|
||
|
||
.progress-bar-container {
|
||
width: 100%;
|
||
background-color: #e0e0e0;
|
||
border-radius: 6px;
|
||
height: 20px;
|
||
}
|
||
|
||
.progress-bar {
|
||
height: 100%;
|
||
background-color: #2563eb;
|
||
width: 0%;
|
||
border-radius: 6px;
|
||
transition: width 0.3s ease;
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="container">
|
||
<h1>📷 Réduction d’images</h1>
|
||
<form id="uploadForm" action="/upload" method="post" enctype="multipart/form-data">
|
||
<label>Dossier d'images :</label>
|
||
<input type="file" name="files" webkitdirectory multiple required>
|
||
|
||
<label>Ratio de réduction :</label>
|
||
<select name="ratio" required>
|
||
<option value="1">1 (original)</option>
|
||
<option value="1.5">1.5 (léger)</option>
|
||
<option value="2" selected>2 (moitié)</option>
|
||
<option value="3">3 (fort)</option>
|
||
<option value="4">4 (très fort)</option>
|
||
</select>
|
||
|
||
<button type="submit">📥 Réduire et télécharger</button>
|
||
</form>
|
||
|
||
<div class="loader" id="loader">
|
||
<p id="progressText">Traitement des images en cours...</p>
|
||
<div class="progress-bar-container">
|
||
<div class="progress-bar" id="progressBar"></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<script>
|
||
const form = document.getElementById("uploadForm");
|
||
const loader = document.getElementById("loader");
|
||
const progressBar = document.getElementById("progressBar");
|
||
const progressText = document.getElementById("progressText");
|
||
|
||
form.addEventListener("submit", function() {
|
||
form.style.display = "none";
|
||
loader.style.display = "block";
|
||
|
||
const interval = setInterval(async () => {
|
||
const res = await fetch('/progress');
|
||
const data = await res.json();
|
||
|
||
if (data.total === 0) return;
|
||
|
||
const percent = Math.floor((data.current / data.total) * 100);
|
||
progressBar.style.width = percent + '%';
|
||
progressText.textContent = `Traitement des images... ${data.current} / ${data.total}`;
|
||
|
||
if (data.current >= data.total) {
|
||
clearInterval(interval);
|
||
}
|
||
}, 500);
|
||
});
|
||
</script>
|
||
</body>
|
||
</html>
|