mirror of
https://framagit.org/framasoft/framadate/funky-framadate-front.git
synced 2023-08-25 13:53:14 +02:00
Ajoute des dates, et les enregistres dans le localStorage
This commit is contained in:
parent
531fd91aef
commit
8f309740c1
@ -35,17 +35,11 @@
|
||||
<li>
|
||||
<i class="far fa-calendar-alt"></i>
|
||||
<input type="date" name="date-1">
|
||||
<button class="btn-no-style"><i class="fas fa-trash-alt"></i></button>
|
||||
</li>
|
||||
|
||||
<li class="item-disabled">
|
||||
<i class="far fa-calendar-alt"></i>
|
||||
<input type="date" name="date-2">
|
||||
<button class="btn-no-style"><i class="fas fa-trash-alt"></i></button>
|
||||
<button class="remove btn-no-style"><i class="fas fa-trash-alt"></i></button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<button>Ajouter une plage de date</button>
|
||||
<button id="addDateButton">Ajouter une date</button>
|
||||
</section>
|
||||
|
||||
<nav>
|
||||
|
@ -62,12 +62,6 @@ const buildTextField = () => {
|
||||
|
||||
}
|
||||
|
||||
$$('input').forEach((inputElement) => {
|
||||
inputElement.addEventListener("change", () => {
|
||||
localStorage[inputElement.name] = inputElement.value
|
||||
});
|
||||
});
|
||||
|
||||
if($("#add-response-choice")) {
|
||||
$("#add-response-choice").addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
@ -101,10 +95,42 @@ if(document.getElementById("type_sondage")) {
|
||||
}
|
||||
|
||||
if(document.getElementById("startButton")) {
|
||||
startButton.addEventListener('click', function () {
|
||||
startButton.addEventListener('click', () => {
|
||||
localStorage.clear()
|
||||
localStorage.setItem('type_sondage', 'classique');
|
||||
});
|
||||
}
|
||||
|
||||
if(document.getElementById("addDateButton")) {
|
||||
addDateButton.addEventListener('click', () => {
|
||||
let newLi = document.createElement("li")
|
||||
let content = $("ul>li").innerHTML.replace("date-1", `date-${$$("li").length + 1}`)
|
||||
newLi.innerHTML = content
|
||||
$("ul").appendChild(newLi);
|
||||
initEventOnScreen();
|
||||
});
|
||||
}
|
||||
|
||||
const addDeleteParentEvent = () => {
|
||||
$$(".remove").forEach((element) => {
|
||||
element.addEventListener('click', () => {
|
||||
element.parentElement.remove();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const addInputToStorageEvent = () => {
|
||||
$$('input').forEach((inputElement) => {
|
||||
inputElement.addEventListener("change", () => {
|
||||
localStorage[inputElement.name] = inputElement.value
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const initEventOnScreen = () => {
|
||||
addDeleteParentEvent();
|
||||
addInputToStorageEvent();
|
||||
}
|
||||
|
||||
initEventOnScreen();
|
||||
debugStorage();
|
||||
|
Loading…
Reference in New Issue
Block a user