52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
export class Tache {
|
|
constructor(titre, texte, date) {
|
|
this._titre = titre;
|
|
this._texte = texte;
|
|
this._date = date;
|
|
}
|
|
|
|
afficher() {
|
|
console.log(
|
|
`Titre: ${this._titre}
|
|
Texte: ${this._texte}
|
|
Date: ${this._date}`);
|
|
}
|
|
|
|
contientMot(mot) {
|
|
const regex = new RegExp(mot, 'gi');
|
|
return regex.test(this._titre) || regex.test(this._texte);
|
|
}
|
|
|
|
estEntreDates(dateDebut, dateFin) {
|
|
const dateTache = new Date(this._date);
|
|
const debut = new Date(dateDebut);
|
|
const fin = new Date(dateFin);
|
|
return dateTache >= debut && dateTache <= fin;
|
|
}
|
|
|
|
toLi() {
|
|
const li = document.createElement("li");
|
|
li.textContent = this.toString();
|
|
li.style.margin = "10px 0";
|
|
|
|
const deleteBtn = this.createDeleteButton();
|
|
li.appendChild(deleteBtn);
|
|
|
|
return li;
|
|
}
|
|
|
|
createDeleteButton() {
|
|
console.log("test");
|
|
const btn = document.createElement("button");
|
|
|
|
btn.className = "btn btn-danger";
|
|
btn.innerHTML = "<i class=\"bi bi-trash\"></i>";
|
|
btn.style.marginLeft = "10px";
|
|
|
|
return btn;
|
|
}
|
|
|
|
toString() {
|
|
return `Titre: ${this._titre}, Texte: ${this._texte}, Date: ${this._date}`;
|
|
}
|
|
} |