G1Forfait/index.html

226 lines
6.2 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<link rel="icon" type="image/png" href="https://www.cine-resonance.fr/Application/G1FABLAB.png">
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>G1Forfait PIF/PAF (UNL/ML) DU² - G1FabLab -</title>
<style>
body {
display: flex;
background-color: #000000;
justify-content: center;
align-items: center;
font-family: Arial, sans-serif;
margin: 10;
}
.container {
text-align: center;
background-color: #f2f2f2;
border-radius: 10px;
padding: 0px;
}
h1 {
color: #333333;
font-size: 2em;
margin-bottom: 10px;
}
label {
display: inline-block;
font-size: 1.5em;
margin-top: 10px;
margin-right: 10px;
}
input[type="number"] {
width: 80px;
height: 30px;
font-size: 1.7em;
text-align: center;
}
p {
font-size: 1.5em;
margin-top: 20px;
font-weight: bold;
}
input[type="radio"] {
display: none;
}
input[type="radio"] + label {
position: relative;
padding-left: 30px;
cursor: pointer;
}
input[type="radio"] + label:before {
content: "";
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
width: 20px;
height: 20px;
border: 2px solid #4CAF50;
border-radius: 50%;
}
input[type="radio"]:checked + label:before {
background-color: #4CAF50;
}
button {
margin-top: 20px;
font-size: 2em;
padding: 10px 20px;
border: none;
border-radius: 5px;
background-color: #4CAF50;
color: white;
cursor: pointer;
}
.calculate-text {
display: flex;
align-items: center;
}
.calculator-container {
margin-top: -15px;
}
.emoji-text {
font-size: 1.2em;
}
.calculator-emoji {
font-size: 2.4em;
display: block;
}
button:hover {
background-color: #45a049;
}
.result {
margin-top: 20px;
font-size: 1.7em;
}
</style>
</head>
<body>
<div class="container">
<h1>Calculateur G1Forfait</h1>
Trouvez facilement le forfait à pratiquer pour conserver votre activité dans un contexte inter "opérateurs monétaires"<br>
PIF PAF ayez le forfait pour commercer en DU sans risquer de faire faillite en €.<br>
<br>
<label for="pif">PIF (DU) par Unité :</label>
<br>
<input type="number" id="pif" min="1" class="input-field" value="3">
<br>
<label for="paf">PAF (€) par Unité :</label>
<br>
<input type="number" id="paf" min="1" class="input-field" value="40">
<br>
<label for="units">Nombre d'unités :</label>
<br>
<input type="number" id="units" min="1" class="input-field" value="1">
<p style="margin-bottom: 0px;">Choix du forfait :</p>
<input type="radio" id="price1" name="price" value="1">
<label for="price1">Forfait Cool </label>
= le PAF avec le PIF offert
<br>
<input type="radio" id="price2" name="price" value="2" checked="checked">
<label for="price2">Forfait Juste </label>
= le 1/2 PAF + le PIF
<br>
<input type="radio" id="price3" name="price" value="3">
<label for="price3">Forfait Carré </label>
= le 1/4 PAF + ( PIF ) ²
<p></p>
<button class="btn-calculate" onclick="calculatePrice()">
<span class="calculate-text">Calculer</span>
</button>
<div class="result" id="result"><b>Pour nn unités :<br></b>xx €<br>yy DUs </div>
<br>
Calculateur pour marchand en herbe - <a href='https://git.p2p.legal/STI/G1Forfait' target='code'>le code</a> - <br>
/ipfs/QmbyMrzK4Yfa8mwVmLjLQXH6YKULzWECAPd743BmJDxfDq
</div>
<script>
// Function to extract URL parameters
function getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
const regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
const results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
}
// Set default values for PIF and PAF from URL parameters
const defaultPAF = getUrlParameter('paf') || '40';
const defaultPIF = getUrlParameter('pif') || '3';
document.getElementById("paf").value = defaultPAF;
document.getElementById("pif").value = defaultPIF;
function calculatePrice() {
var pafInput = document.getElementById("paf").value;
var paf = parseInt(pafInput);
var pafBy2 = paf / 2;
var pafBy4 = paf / 4;
var pafBy8 = paf / 8;
var pifInput = document.getElementById("pif").value;
var pif = parseInt(pifInput);
var units = parseInt(document.getElementById("units").value);
if (isNaN(units) || units < 1) {
document.getElementById("result").innerHTML = "Veuillez entrer un nombre entier supérieur ou égal à 1.";
return;
}
var priceType = parseInt(document.querySelector('input[name="price"]:checked').value);
var totalPrice, totalDU, duText;
if (priceType === 1) {
totalPrice = paf * units;
totalDU = pif * units;
duText = (totalDU === 1) ? "offert" : "offerts";
} else if (priceType === 2) {
totalPrice = pafBy2 * units;
totalDU = pif * units;
duText = "";
} else if (priceType === 3) {
totalPrice = pafBy4 * units;
pouf = pif * units;
totalDU = Math.pow(pouf, 2);
// totalDU = [...Array(pouf).keys()].map(i => Math.pow(i + 1, 2)).reduce((a, b) => a + b, 0);
duText = (totalDU === 1) ? "" : "";
} else if (priceType === 4) {
totalPrice = pafBy4 * units;
pouf = pif * units;
totalDU = [...Array(pouf).keys()].map(i => Math.pow(i + 1, 2)).reduce((a, b) => a + b, 0);
duText = (totalDU === 1) ? "" : "";
}
var response = "<b>Pour " + units + " " + ((units === 1) ? "unité" : "unités") + " :<br></b>";
response += totalPrice + "€<br>";
response += totalDU + " DU" + ((totalDU === 1) ? "" : "s") + " " + duText;
document.getElementById("result").innerHTML = response;
}
</script>
</body></html>