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>
|
<li>
|
||||||
<i class="far fa-calendar-alt"></i>
|
<i class="far fa-calendar-alt"></i>
|
||||||
<input type="date" name="date-1">
|
<input type="date" name="date-1">
|
||||||
<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>
|
|
||||||
|
|
||||||
<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>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<button>Ajouter une plage de date</button>
|
<button id="addDateButton">Ajouter une date</button>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<nav>
|
<nav>
|
||||||
|
@ -62,12 +62,6 @@ const buildTextField = () => {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$$('input').forEach((inputElement) => {
|
|
||||||
inputElement.addEventListener("change", () => {
|
|
||||||
localStorage[inputElement.name] = inputElement.value
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
if($("#add-response-choice")) {
|
if($("#add-response-choice")) {
|
||||||
$("#add-response-choice").addEventListener('click', (e) => {
|
$("#add-response-choice").addEventListener('click', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@ -101,10 +95,42 @@ if(document.getElementById("type_sondage")) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(document.getElementById("startButton")) {
|
if(document.getElementById("startButton")) {
|
||||||
startButton.addEventListener('click', function () {
|
startButton.addEventListener('click', () => {
|
||||||
localStorage.clear()
|
localStorage.clear()
|
||||||
localStorage.setItem('type_sondage', 'classique');
|
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();
|
debugStorage();
|
||||||
|
Loading…
Reference in New Issue
Block a user