Advertisement
Guest User

listetache2BIS

a guest
Nov 17th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /** arnaud waetermans 14/11/2019 **/
  2. const HEURE = 50;
  3. var taches = [];
  4. var message;
  5. var tachesSuppr = [];
  6. let compteurTache = 100;
  7. let chaineTache = [];
  8. function ajouterTache(f) {
  9.     compteurTache++;
  10.     taches.push( [ "T"+compteurTache, f.tacheNom.value, f.tacheDateLimite.value,f.tacheImportance.value,f.tacheDuree.value,f.tacheDescription.value, true]);
  11.     message =  f.tacheNom.value;
  12.     message = "Nouvelle tache : "+ f.tacheNom.value + " avec le code T" + compteurTache + " a bien été ajoutée";
  13.     document.getElementById("message").innerText = message;
  14.     document.getElementById("tachesAffichage").style.color= "green";
  15.     return false;
  16. }
  17. function afficherTaches() {
  18.     console.log(taches);
  19. }
  20. function annulerDerniereTache(){
  21.     if (taches.length < 1 ) {
  22.         message = "La liste de taches est vide.";
  23.         document.getElementById("message").innerText = message;
  24.     } else {
  25.         tachesSuppr = taches.pop();
  26.         message = "La tâche "+ tachesSuppr[1] +" avec le code "+tachesSuppr[0]+" a bien été supprimée.";
  27.         document.getElementById("message").innerText = message;
  28.         document.getElementById("tachesAffichage").style.color="red";
  29.     }
  30. }
  31. function tacheVersString(taches) {
  32.     chaineTache = "La tâche " + taches[0] + " \"" + taches[1] +
  33.         "\" à finir avant le " + taches[2] + " d'importance " + taches[3] +
  34.         " est " + (taches[6] ? "ouverte" : "fermée") +
  35.         " et il reste " + taches[4] + " h pour la terminer." +
  36.         " Infos sup : " + taches[5] + ".";
  37.     return chaineTache;
  38. }
  39. function tacheVersStringCourt(taches) {
  40.     chaineTacheCourt = "Tâche : " + taches[0] + "; " + taches[1] +"; " + taches[3];
  41.     return chaineTacheCourt;
  42. }
  43. function afficherTacheUrgente() {
  44.     let tacheUrgente = ["T000", "minimale", "9999-99-99", "low", 0, "", true];
  45.     if (taches.length === 0) {
  46.         message = "La liste de taches est vide.";
  47.         document.getElementById("message").innerText = message;
  48.     } else {
  49.         for (let i = 0; i < taches.length; i+= 1) {
  50.             if (taches[i][6] && (taches[i][2] < tacheUrgente[2])) {
  51.                 tacheUrgente = taches[i];
  52.             }
  53.         }
  54.         message = "Taches Urgente : " + tacheVersString(tacheUrgente);
  55.         document.getElementById("message").innerText = message;
  56.         document.getElementById("tachesAffichage").style.color = "green";
  57.     }
  58. }
  59. function afficherTachesImportance(){
  60.     let importance = document.getElementById("choixImportance").value;
  61.     for (let index = 0; index < taches.length; index++) {
  62.         if (taches[index][3] === importance) {
  63.             chaineTache.push([tacheVersStringCourt(taches[index]) + "<br>"]);
  64.             document.getElementById("message").innerHTML =  chaineTache;
  65.     }
  66.     }
  67. }
  68. function marquerTacheResolue() {
  69.     for (let index = 0; index < taches.length; index++) {
  70.         if (document.getElementById("codeTacheResolue").value === taches[index][0]) {
  71.             if (taches[index][6] === true) {
  72.                 taches[index][6] = false;
  73.                 document.getElementById("message").innerText = "La tâche " + taches[index][1] + " avec le code " + taches[index][0] + " a bien été fermée.";
  74.             } else if (taches[index][6] === false) {
  75.                 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";
  76.             }
  77.         }
  78.     }
  79. }
  80. function afficherTachesOuvertesImportance(type){
  81.     console.log("Tache d'importance "+ type +" :");
  82.     for (let index = 0; index < taches.length; index++) {
  83.         if(taches[index][6] == true && taches[index][3]==type){
  84.             console.log(tacheVersStringCourt(taches[index]));
  85.         }
  86.     }
  87. }
  88. function afficherDureeTachesOuvertes() {
  89.     var nombreHeure = 0;
  90.     for (let index = 0; index < taches.length; index++) {
  91.         if (taches[index][6] == true) {
  92.             nombreHeure += taches[index][4];
  93.         }
  94.     }
  95.     if (nombreHeure > HEURE) {
  96.         console.log("Courage !");
  97.         console.log("Vous en avez encore pour " + nombreHeure.toFixed(2) + " heures de tâches à effectuer !");
  98.     } else {
  99.         console.log("Vous en avez encore pour " + nombreHeure.toFixed(2) + " heures de tâches à effectuer !");
  100.     }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement