fred 2023-08-30 21:25:57 +02:00
parent dd98a35277
commit f50c85b025
2 changed files with 30 additions and 19 deletions

View File

@ -2,7 +2,7 @@
Calcule les montants a verser pour chaque projet proposé au financement quadratique Calcule les montants a verser pour chaque projet proposé au financement quadratique
[![](./G1_FQ.png)](https://ipfs.asycn.io/ipfs/QmdLeswsEH7F3hZBUjimrRRJQNEyfWjut7u4EuQEcoXwvg/) [![](./G1_FQ.png)](https://ipfs.asycn.io/ipfs/QmYRuZcG58eo549FFr4Y8qQUcF559iiUnRL87Y7UZBsSWz/)
Les montants de contrepartie sont calculés à l'aide de la formule suivante : Les montants de contrepartie sont calculés à l'aide de la formule suivante :

View File

@ -1,9 +1,8 @@
<!DOCTYPE html> <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Quadratic Funding Calculator</title> <title>Quadratic Funding Calculator</title>
<style> <style>
.matchingAmount, .matchingAmount,
.projectTable, .projectTable,
.addProjectCopyURL { .addProjectCopyURL {
@ -127,13 +126,14 @@
border: none; /* Remove vertical borders */ border: none; /* Remove vertical borders */
} }
</style> </style>
<script src="lib/jquery.min.js"></script>
</head> </head>
<body> <body>
<div class="section fit interactive">
<div class="container">
<script src="lib/jquery.min.js"></script>
<div id="calculation"> <div id="calculation">
</div>
<script> <script>
$(document).ready(function () { $(document).ready(function () {
@ -142,7 +142,20 @@ let quadraticFunding = {
projects: [], projects: [],
}; };
// Update URL parameters on changes
function updateUrl() {
let params = new URLSearchParams();
params.set("match", quadraticFunding.matchAmount);
quadraticFunding.projects.forEach((project, i) => {
params.append("grant", project.contributions.join("-"));
});
// Update the URL only if it differs from the current state
if (window.location.search !== "?" + params.toString()) {
window.history.replaceState({}, "", "?" + params.toString());
}
}
let matchAmountInput = $("<input>") let matchAmountInput = $("<input>")
.attr("id", "matchAmount") .attr("id", "matchAmount")
@ -153,11 +166,11 @@ let quadraticFunding = {
let addProjectButton = $("<button>") let addProjectButton = $("<button>")
.attr("id", "addProject") .attr("id", "addProject")
.attr("class", "button") .attr("class", "button")
.text("Ajouter Projet"); .text("Add Project");
let copyURLButton = $("<button>") let copyURLButton = $("<button>")
.attr("id", "copyURL") .attr("id", "copyURL")
.attr("class", "button") .attr("class", "button")
.text("Copier URL"); .text("Copy URL");
let projectTable = $("<table>").attr("id", "projectTable"); let projectTable = $("<table>").attr("id", "projectTable");
$("#calculation").append( $("#calculation").append(
@ -174,11 +187,11 @@ let quadraticFunding = {
$("#projectTable").append( $("#projectTable").append(
$("<tr>").append( $("<tr>").append(
$('<th colspan="2">').text("Projet"), $('<th colspan="2">').text("Project"),
$("<th>").text("Contributions"), $("<th>").text("Contributions"),
$("<th>").text("Montant financé"), $("<th>").text("Funded Amount"),
$("<th>").text("Montant versé"), $("<th>").text("Match Amount"),
$("<th>").text("Supprimer") $("<th>").text("Remove")
) )
); );
@ -193,7 +206,7 @@ let quadraticFunding = {
}); });
$("#addProject").on("click", function () { $("#addProject").on("click", function () {
let projectName = "Projet #" + (quadraticFunding.projects.length + 1); let projectName = "Project #" + (quadraticFunding.projects.length + 1);
if (projectName) { if (projectName) {
quadraticFunding.projects.push({ quadraticFunding.projects.push({
@ -210,7 +223,7 @@ let quadraticFunding = {
$("<td>").append( $("<td>").append(
$("<input>") $("<input>")
.addClass("contributionInput") .addClass("contributionInput")
.attr("placeholder", "Ajouter une contribution et pressez Enter") .attr("placeholder", "Add a contribution and press Enter")
), ),
$("<td>").attr("class", "contributions"), $("<td>").attr("class", "contributions"),
$("<td>").attr("class", "fundedAmount").text(0), $("<td>").attr("class", "fundedAmount").text(0),
@ -404,7 +417,5 @@ let quadraticFunding = {
// Call this function on page load to load the values from the URL // Call this function on page load to load the values from the URL
loadDefaults(); loadDefaults();
}); });
</script> </script></div></div></div>
</body></html>
</body>
</html>