-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DEV] changement de localisation des fichiers et découplage
- Loading branch information
1 parent
7fc1cf5
commit 24ef135
Showing
4 changed files
with
96 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const couleur_rouge = '#ff0000'; | ||
|
||
const couleur_vert = '#10b020'; | ||
|
||
const couleur_bleu = '#0004ff'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
function logMessage(message) | ||
{ | ||
console.log(message); | ||
} | ||
|
||
function logArray(array_object) | ||
{ | ||
array_object.forEach(element => console.log(element)); | ||
} | ||
|
||
function logDateEtMessage(message) | ||
{ | ||
var d = new Date(); // on récupérère la date courante | ||
console.log(d.getHours(),":",d.getMinutes(),message); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
for (let i = 0; i < 5; i++) | ||
{ | ||
if (i==0) { logMessage(couleur_vert); } | ||
if (i%2 == 0) | ||
logMessage(couleur_rouge); | ||
else | ||
logMessage(couleur_bleu); | ||
} | ||
|
||
let h1 = document.querySelector('h1'); | ||
logMessage(h1); | ||
|
||
let titleNews = document.querySelector('#titleNews'); | ||
logMessage(titleNews); | ||
|
||
let lis_h3_id_title = document.querySelectorAll('.title'); | ||
logArray(lis_h3_id_title); | ||
|
||
|
||
let input_text = document.querySelector('#input_text'); | ||
let input_add_news = document.getElementsByName('addNewsBtn'); | ||
|
||
input_add_news.forEach(input => onsubmit = create_news); | ||
|
||
function create_news() | ||
{ | ||
if (isUniqueArticle(input_text.value)) | ||
{ | ||
let newArticle = document.createElement('article'); | ||
let h3 = document.createElement('h3'); | ||
h3.className = "title"; | ||
h3.innerHTML = input_text.value; | ||
newArticle.append(h3); | ||
|
||
logMessage(input_text.value); | ||
|
||
ajouterAuNews(newArticle); | ||
} | ||
else | ||
{ | ||
realiserUneErreur(); | ||
} | ||
return false; | ||
} | ||
|
||
function isUniqueArticle(titre_article) | ||
{ | ||
let list_h3 = document.querySelectorAll('.title'); | ||
let retour = true; | ||
list_h3.forEach(function(h3) { | ||
if (h3.innerHTML == titre_article) { | ||
retour = false; | ||
} | ||
}); | ||
return retour; | ||
} | ||
|
||
|
||
function realiserUneErreur() | ||
{ | ||
let newErreurText = document.createElement('p'); | ||
newErreurText.innerHTML = "[ERREUR] pas de duplication d'article" | ||
newErreurText.style.color = couleur_rouge; | ||
ajouterAuNews(newErreurText); | ||
} | ||
|
||
function ajouterAuNews(element) | ||
{ | ||
let news = document.querySelector('#news'); | ||
news.append(element); | ||
} | ||
|
||
logDateEtMessage("Un message avec la date actuelle"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters