Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** arnaud waetermans 14/11/2019 **/
- const HEURE = 50;
- var taches = [];
- var message;
- var tachesSuppr = [];
- let compteurTache = 100;
- let chaineTache = [];
- function ajouterTache(f) {
- compteurTache++;
- taches.push( [ "T"+compteurTache, f.tacheNom.value, f.tacheDateLimite.value,f.tacheImportance.value,f.tacheDuree.value,f.tacheDescription.value, true]);
- message = f.tacheNom.value;
- message = "Nouvelle tache : "+ f.tacheNom.value + " avec le code T" + compteurTache + " a bien été ajoutée";
- document.getElementById("message").innerText = message;
- document.getElementById("tachesAffichage").style.color= "green";
- return false;
- }
- function afficherTaches() {
- console.log(taches);
- }
- function annulerDerniereTache(){
- if (taches.length < 1 ) {
- message = "La liste de taches est vide.";
- document.getElementById("message").innerText = message;
- } else {
- tachesSuppr = taches.pop();
- message = "La tâche "+ tachesSuppr[1] +" avec le code "+tachesSuppr[0]+" a bien été supprimée.";
- document.getElementById("message").innerText = message;
- document.getElementById("tachesAffichage").style.color="red";
- }
- }
- function tacheVersString(taches) {
- chaineTache = "La tâche " + taches[0] + " \"" + taches[1] +
- "\" à finir avant le " + taches[2] + " d'importance " + taches[3] +
- " est " + (taches[6] ? "ouverte" : "fermée") +
- " et il reste " + taches[4] + " h pour la terminer." +
- " Infos sup : " + taches[5] + ".";
- return chaineTache;
- }
- function tacheVersStringCourt(taches) {
- chaineTacheCourt = "Tâche : " + taches[0] + "; " + taches[1] +"; " + taches[3];
- return chaineTacheCourt;
- }
- function afficherTacheUrgente() {
- let tacheUrgente = ["T000", "minimale", "9999-99-99", "low", 0, "", true];
- if (taches.length === 0) {
- message = "La liste de taches est vide.";
- document.getElementById("message").innerText = message;
- } else {
- for (let i = 0; i < taches.length; i+= 1) {
- if (taches[i][6] && (taches[i][2] < tacheUrgente[2])) {
- tacheUrgente = taches[i];
- }
- }
- message = "Taches Urgente : " + tacheVersString(tacheUrgente);
- document.getElementById("message").innerText = message;
- document.getElementById("tachesAffichage").style.color = "green";
- }
- }
- function afficherTachesImportance(){
- let importance = document.getElementById("choixImportance").value;
- for (let index = 0; index < taches.length; index++) {
- if (taches[index][3] === importance) {
- chaineTache.push([tacheVersStringCourt(taches[index]) + "<br>"]);
- document.getElementById("message").innerHTML = chaineTache;
- }
- }
- }
- function marquerTacheResolue() {
- for (let index = 0; index < taches.length; index++) {
- if (document.getElementById("codeTacheResolue").value === taches[index][0]) {
- if (taches[index][6] === true) {
- taches[index][6] = false;
- document.getElementById("message").innerText = "La tâche " + taches[index][1] + " avec le code " + taches[index][0] + " a bien été fermée.";
- } else if (taches[index][6] === false) {
- document.getElementById("message").innerText = "La tâche " + taches[index][1] + " avec le code " + taches[index][0] + " a déjà été fermée précédemment";
- }
- }
- }
- }
- function afficherTachesOuvertesImportance(type){
- console.log("Tache d'importance "+ type +" :");
- for (let index = 0; index < taches.length; index++) {
- if(taches[index][6] == true && taches[index][3]==type){
- console.log(tacheVersStringCourt(taches[index]));
- }
- }
- }
- function afficherDureeTachesOuvertes() {
- var nombreHeure = 0;
- for (let index = 0; index < taches.length; index++) {
- if (taches[index][6] == true) {
- nombreHeure += taches[index][4];
- }
- }
- if (nombreHeure > HEURE) {
- console.log("Courage !");
- console.log("Vous en avez encore pour " + nombreHeure.toFixed(2) + " heures de tâches à effectuer !");
- } else {
- console.log("Vous en avez encore pour " + nombreHeure.toFixed(2) + " heures de tâches à effectuer !");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement