RepliQ/repliq.html
2025-03-21 09:26:40 +01:00

161 lines
6.0 KiB
HTML
Executable File

<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>RépliQ - Générateur de bannière e-mail</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
text-align: center;
}
.banner {
padding: 10px;
font-weight: bold;
margin-top: 20px;
border-radius: 5px;
display: inline-block;
width: auto;
min-width: 250px;
text-align: center;
}
.output-container {
margin-top: 20px;
}
.copy-btn {
margin-top: 10px;
padding: 8px 15px;
font-size: 14px;
cursor: pointer;
border: none;
background-color: #0078D7;
color: white;
border-radius: 5px;
}
.copy-btn:hover {
background-color: #005A9E;
}
#hiddenContainer {
position: absolute;
left: -9999px;
top: -9999px;
}
</style>
</head>
<body>
<h2>RépliQ - Générateur de bannière e-mail</h2>
<label for="action">Demander une :</label>
<select id="action" onchange="toggleConvenienceOption()">
<option value="Action">Action</option>
<option value="Lecture">Lecture</option>
<option value="Réponse">Réponse</option>
</select>
<br><br>
<label for="date">Date limite :</label>
<input type="date" id="date">
<br><br>
<div id="convenienceOption" style="display: none;">
<input type="checkbox" id="convenience"> À votre convenance
</div>
<br><br>
<button onclick="generateBanner()">Générer</button>
<button onclick="setASAP()">ASAP</button>
<div class="output-container">
<div id="result" class="banner" style="display: none;"></div>
<button class="copy-btn" onclick="copyFormattedBanner()" style="display: none;" id="copyButton">Copier le bandeau</button>
</div>
<div id="hiddenContainer"></div>
<script>
function toggleConvenienceOption() {
const action = document.getElementById("action").value;
const convenienceOption = document.getElementById("convenienceOption");
const dateInput = document.getElementById("date");
const convenienceCheckbox = document.getElementById("convenience");
if (action === "Lecture") {
convenienceOption.style.display = "block";
} else {
convenienceOption.style.display = "none";
convenienceCheckbox.checked = false;
}
}
function generateBanner() {
const action = document.getElementById("action").value;
const dateInput = document.getElementById("date").value;
const resultDiv = document.getElementById("result");
const copyButton = document.getElementById("copyButton");
const hiddenContainer = document.getElementById("hiddenContainer");
const convenienceCheckbox = document.getElementById("convenience").checked;
if (!dateInput && !convenienceCheckbox) {
alert("Veuillez sélectionner une date ou cocher 'À votre convenance'.");
return;
}
let message = "";
let bgColor = "#A8E6A3";
let textColor = "#206A1E";
if (convenienceCheckbox) {
message = "Lecture à votre convenance.";
} else {
const selectedDate = new Date(dateInput);
const formattedDate = selectedDate.toLocaleDateString("fr-FR");
const today = new Date();
const diffTime = selectedDate - today;
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
message = `${action} souhaitée avant le ${formattedDate}.`;
if (diffDays <= 3) {
bgColor = "#FFD580";
textColor = "#A65E00";
}
}
if (action === "Lecture") {
message += " Inutile de répondre.";
}
resultDiv.style.backgroundColor = bgColor;
resultDiv.style.color = textColor;
resultDiv.textContent = message;
resultDiv.style.display = "block";
copyButton.style.display = "inline-block";
hiddenContainer.innerHTML = `<div style='background-color: ${bgColor}; color: ${textColor}; padding: 10px; font-weight: bold; border-radius: 5px; display: inline-block; text-align: left;'>${message.replace("\n", "<br>")}</div>`;
}
function setASAP() {
const action = document.getElementById("action").value;
const resultDiv = document.getElementById("result");
const copyButton = document.getElementById("copyButton");
const hiddenContainer = document.getElementById("hiddenContainer");
resultDiv.style.backgroundColor = "#FFA8A8";
resultDiv.style.color = "#8B0000";
resultDiv.textContent = `${action} souhaitée dès que possible`;
resultDiv.style.display = "block";
copyButton.style.display = "inline-block";
hiddenContainer.innerHTML = `<div style='background-color: #FFA8A8; color: #8B0000; padding: 10px; font-weight: bold; border-radius: 5px; display: inline-block; text-align: left;'>${action} souhaitée dès que possible</div>`;
}
function copyFormattedBanner() {
const hiddenContainer = document.getElementById("hiddenContainer");
const range = document.createRange();
range.selectNode(hiddenContainer);
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
document.execCommand("copy");
window.getSelection().removeAllRanges();
alert("Bandeau copié ! Collez-le directement dans Outlook.");
}
</script>
</body>
</html>