Skip to content

Commit d718280

Browse files
committed
yaml: paramètres random + bouncingEffect
1 parent e285be0 commit d718280

File tree

5 files changed

+24
-8
lines changed

5 files changed

+24
-8
lines changed

js/processMarkdown/parseMarkdown.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { markdownToHTML } from "./markdownToHTML";
2-
import { processYAML } from "./yaml";
2+
import { processYAML, yaml } from "./yaml";
3+
import { shuffleArray } from "../utils/arrays";
34

45
export function parseMarkdown(markdownContent) {
56
processYAML(markdownContent);
@@ -72,7 +73,9 @@ export function parseMarkdown(markdownContent) {
7273
calendarMarkdown.push(fullDayHtml);
7374
day++;
7475
}
75-
76+
if (yaml && yaml.random == true) {
77+
shuffleArray(calendarMarkdown);
78+
}
7679
// Ajout de la dernière fermeture, si nécessaire
7780
if (calendarMarkdown.length > 0) {
7881
calendarMarkdown[calendarMarkdown.length - 1] +=

js/ui/handleCalendar.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { yaml } from "../processMarkdown/yaml";
2+
13
export function handleCalendar(startDay) {
24
const contentNotAvalaible =
35
"Ce n'est pas encore le bon jour, merci de patienter !";
@@ -9,7 +11,9 @@ export function handleCalendar(startDay) {
911
const currentMonth = currentDate.getMonth();
1012

1113
function dayContentHide() {
12-
document.querySelector(".currentDate").classList.add("bounce");
14+
if (!yaml || yaml.bouncingEffect != false) {
15+
document.querySelector(".currentDate").classList.add("bounce");
16+
}
1317
daySections.forEach((daySection) => {
1418
const dayContent = daySection.querySelector(".dayContent");
1519
dayContent.style.display = "none";
@@ -75,5 +79,7 @@ export function handleCalendar(startDay) {
7579
event.stopPropagation();
7680
});
7781
});
78-
document.querySelector(".currentDate").classList.add("bounce");
82+
if (!yaml || yaml.bouncingEffect != false) {
83+
document.querySelector(".currentDate").classList.add("bounce");
84+
}
7985
}

js/utils/arrays.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Pour réordonner de manière aléatoire un tableau
2+
export function shuffleArray(array) {
3+
return array.sort(function () {
4+
return Math.random() - 0.5;
5+
});
6+
}

script.min.js

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

script.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)