-
Notifications
You must be signed in to change notification settings - Fork 0
/
journal-show.js
130 lines (128 loc) · 5.55 KB
/
journal-show.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
const fileJson = slice (document.URL, 0,-10) + '.json';
debbyPlay.tagList =[];
debbyPlay.placeList =[];
debbyPlay.peopleList =[];
debbyPlay.years =[ 'tous', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020' ];
debbyPlay.days =[];
var allDays =[];
var yearCurrent = 'tous';
var placeCurrent = 'tous';
var tagCurrent = 'tous';
var peopleCurent = 'tous';
function initJournal(){
for (var d in debbyPlay.days){
allDays.push (debbyPlay.days[d]);
if (! containsList (debbyPlay.placeList, debbyPlay.days[d].place) && debbyPlay.days[d].place)
debbyPlay.placeList.push (debbyPlay.days[d].place);
for (var t in debbyPlay.days[d].tags){
if (! containsList (debbyPlay.tagList, debbyPlay.days[d].tags[t])){
debbyPlay.tagList.push (debbyPlay.days[d].tags[t]);
}}
for (var t in debbyPlay.days[d].peoples){
if (! containsList (debbyPlay.peopleList, debbyPlay.days[d].peoples[t])){
debbyPlay.peopleList.push (debbyPlay.days[d].peoples[t]);
}}}
debbyPlay.placeList.sort();
debbyPlay.placeList.unshift ('tous');
debbyPlay.peopleList.sort();
debbyPlay.peopleList.unshift ('tous');
debbyPlay.tagList.sort();
debbyPlay.tagList.unshift ('tous');
console.log ('lieux:', debbyPlay.placeList);
console.log ('personnes:', debbyPlay.peopleList);
console.log ('tags:', debbyPlay.tagList);
console.log ('jours:', debbyPlay.days);
}
function containsList (list, word){
if (list.indexOf (word) >-1) return true;
else return false;
}
init (document.body);
useJson (fileJson, 'days', document.body);
initJournal();
load();
function selectYears (year){ yearCurrent = year; }
function selectPlaces (place){ placeCurrent = place.toLowerCase(); }
function selectPeoples (people){ peopleCurent = people.toLowerCase(); }
function selectTags (tag){ tagCurrent = tag.toLowerCase(); }
function selectDays(){
debbyPlay.days =[];
if (yearCurrent == 'tous' && placeCurrent == 'tous' && peopleCurent == 'tous' && tagCurrent == 'tous')
for (var j in allDays) debbyPlay.days.push (allDays[j]);
// sélection sur un seul élément sur les quatre
else if (yearCurrent == 'tous' && placeCurrent == 'tous' && peopleCurent == 'tous'){
for (var j in allDays){
if (containsList (allDays[j].tags, tagCurrent)) debbyPlay.days.push (allDays[j]);
}}
else if (yearCurrent == 'tous' && tagCurrent == 'tous' && peopleCurent == 'tous'){
for (var j in allDays){
if (allDays[j].place == placeCurrent) debbyPlay.days.push (allDays[j]);
}}
else if (placeCurrent == 'tous' && tagCurrent == 'tous' && peopleCurent == 'tous'){
for (var j in allDays){
if (containsText (allDays[j].date, yearCurrent +'/')) debbyPlay.days.push (allDays[j]);
}}
else if (yearCurrent == 'tous' && placeCurrent == 'tous' && tagCurrent == 'tous'){
for (var j in allDays){
if (containsList (allDays[j].peoples, peopleCurent)) debbyPlay.days.push (allDays[j]);
}}
// sélection sur deux éléments
else if (yearCurrent == 'tous' && placeCurrent == 'tous'){
for (var j in allDays){
if (containsList (allDays[j].tags, tagCurrent) && containsList (allDays[j].peoples, peopleCurent))
debbyPlay.days.push (allDays[j]);
}}
else if (yearCurrent == 'tous' && tagCurrent == 'tous'){
for (var j in allDays){
if (allDays[j].place == placeCurrent && containsList (allDays[j].peoples, peopleCurent))
debbyPlay.days.push (allDays[j]);
}}
else if (yearCurrent == 'tous' && peopleCurent == 'tous'){
for (var j in allDays){
if (allDays[j].place == placeCurrent && containsList (allDays[j].tags, tagCurrent))
debbyPlay.days.push (allDays[j]);
}}
else if (tagCurrent == 'tous' && placeCurrent == 'tous'){
for (var j in allDays){
if (containsText (allDays[j].date, yearCurrent +'/') && containsList (allDays[j].peoples, peopleCurent))
debbyPlay.days.push (allDays[j]);
}}
else if (tagCurrent == 'tous' && peopleCurent == 'tous'){
for (var j in allDays){
if (containsText (allDays[j].date, yearCurrent +'/') && allDays[j].place == placeCurrent)
debbyPlay.days.push (allDays[j]);
}}
else if (placeCurrent == 'tous' && peopleCurent == 'tous'){
for (var j in allDays){
if (containsText (allDays[j].date, yearCurrent +'/') && containsList (allDays[j].tags, tagCurrent))
debbyPlay.days.push (allDays[j]);
}}
// sélection sur trois éléments
else if (placeCurrent == 'tous'){
for (var j in allDays){
if (containsText (allDays[j].date, yearCurrent +'/') && containsList (allDays[j].tags, tagCurrent)
&& containsList (allDays[j].peoples, peopleCurent)) debbyPlay.days.push (allDays[j]);
}}
else if (yearCurrent == 'tous'){
for (var j in allDays){
if (allDays[j].place == placeCurrent && containsList (allDays[j].tags, tagCurrent)
&& containsList (allDays[j].peoples, peopleCurent)) debbyPlay.days.push (allDays[j]);
}}
else if (peopleCurent == 'tous'){
for (var j in allDays){
if (containsText (allDays[j].date, yearCurrent +'/') && containsList (allDays[j].tags, tagCurrent)
&& allDays[j].place == placeCurrent) debbyPlay.days.push (allDays[j]);
}}
else if (tagCurrent == 'tous'){
for (var j in allDays){
if (containsText (allDays[j].date, yearCurrent +'/') && containsList (allDays[j].peoples, peopleCurent)
&& allDays[j].place == placeCurrent) debbyPlay.days.push (allDays[j]);
}}
// sélection sur tous les éléments
else{
for (var j in allDays){
if (containsText (allDays[j].date, yearCurrent +'/') && allDays[j].place == placeCurrent && containsList (allDays[j].tags, tagCurrent) && containsList (allDays[j].peoples, peopleCurent)) debbyPlay.days.push (allDays[j]);
}}
var containerDays = document.getElementsByTagName ('section')[1];
load (containerDays);
}