-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
146 lines (118 loc) · 3.95 KB
/
main.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
//filterSelection("all") // Execute the function and show all columns
function filterSelection(c) {
var x, i;
x = document.getElementsByClassName("entry");
if (c == "all") c = "";
// Add the "show" class (display:block) to the filtered elements, and remove the "show" class from the elements that are not selected
for (i = 0; i < x.length; i++) {
w3RemoveClass(x[i], "show");
if (x[i].className.indexOf(c) > -1) w3AddClass(x[i], "show");
}
}
// Show filtered elements
function w3AddClass(element, name) {
var i, arr1, arr2;
arr1 = element.className.split(" ");
arr2 = name.split(" ");
for (i = 0; i < arr2.length; i++) {
if (arr1.indexOf(arr2[i]) == -1) {
element.className += " " + arr2[i];
}
}
}
// Hide elements that are not selected
function w3RemoveClass(element, name) {
var i, arr1, arr2;
arr1 = element.className.split(" ");
arr2 = name.split(" ");
for (i = 0; i < arr2.length; i++) {
while (arr1.indexOf(arr2[i]) > -1) {
arr1.splice(arr1.indexOf(arr2[i]), 1);
}
}
element.className = arr1.join(" ");
}
function filterNumName_() {
// Declare variables
var input, filter, table, tr, td, i, txtValue;
input = document.getElementById("filtreNom");
filter = input.value.toUpperCase();
gal = document.getElementById("gal");
items = gal.getElementsByClassName("entry");
// Loop through all table rows, and hide those who don't match the search query
for (i = 0; i < items.length; i++) {
titre = items[i].getElementsByTagName("h4")[0];
if (titre) {
txtValue = titre.textContent || titre.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
w3AddClass(items[i], "fltrN")
} else {
w3RemoveClass(items[i], "fltrN");
}
}
}
}
function filterPeople_() {
// Declare variables
var input, filter, table, tr, td, i, txtValue;
input = document.getElementById("filtrePeople");
filter = input.value.toUpperCase();
gal = document.getElementById("gal");
items = gal.getElementsByClassName("entry");
// Loop through all table rows, and hide those who don't match the search query
for (i = 0; i < items.length; i++) {
titre = items[i].getElementsByTagName("p")[0];
if (titre) {
txtValue = titre.textContent || titre.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
w3AddClass(items[i], "fltrP")
} else {
w3RemoveClass(items[i], "fltrP");
}
}
}
}
// Get the image and insert it inside the modal - use its "alt" text as a caption
function showModal(idimg) {
// Get the modal
var modal = document.getElementById("myModal");
var img = document.getElementById(idimg);
var modalImg = document.getElementById("img01");
var captionText = document.getElementById("caption");
modal.style.display = "block";
modalImg.src = img.src;
captionText.innerHTML = img.alt;
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
}
function forceRepaint() {
requestAnimationFrame(()=>{
const e=document.createElement('DIV');
e.style='position:fixed;top:0;left:0;bottom:0;right:0;background:#80808001;\
pointer-events:none;z-index:9999999';
document.body.appendChild(e);
requestAnimationFrame(()=>e.remove());
});
}
function filterNumName() {
input = document.getElementById("filtreNom");
var searchStyle_N = document.getElementById('search_style_N');
if (!input.value) {
searchStyle_N.innerHTML = "";
return;
}
searchStyle_N.innerHTML = ".searchable:not([data-name*=\"" + input.value.toLowerCase() + "\" i]) { display: none; }";
};
function filterPeople() {
input = document.getElementById("filtrePeople");
var searchStyle_P = document.getElementById('search_style_P');
if (!input.value) {
searchStyle_P.innerHTML = "";
return;
}
searchStyle_P.innerHTML = ".searchable:not([data-people*=\"" + input.value.toLowerCase() + "\" i]) { display: none; }";
};