-
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.
- Loading branch information
1 parent
76cd232
commit 47c26d4
Showing
1 changed file
with
68 additions
and
51 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 |
---|---|---|
@@ -1,75 +1,92 @@ | ||
function normalizeString(str) { | ||
return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toUpperCase(); | ||
return str | ||
.normalize("NFD") | ||
.replace(/[\u0300-\u036f]/g, "") | ||
.toUpperCase(); | ||
} | ||
|
||
function filterEvents() { | ||
var input, filter, ul, li, decodedSearchString; | ||
input = document.getElementById('myInput'); | ||
filter = normalizeString(input.value); // Normalize the input string | ||
ul = document.getElementById("myUL"); | ||
li = ul.getElementsByTagName('li'); | ||
var input, filter, ul, dateLi, eventLi, decodedSearchString; | ||
input = document.getElementById("myInput"); | ||
filter = normalizeString(input.value); | ||
ul = document.getElementById("myUL"); | ||
dateLi = ul.getElementsByClassName("date_li"); | ||
|
||
for (var i = 0; i < li.length; i++) { | ||
var searchStringElement = li[i].getElementsByClassName("searchstring")[0]; | ||
for (var i = 0; i < dateLi.length; i++) { | ||
eventLi = dateLi[i].getElementsByClassName("event_li"); | ||
|
||
// Decode HTML entities and normalize | ||
decodedSearchString = normalizeString(htmlDecode(searchStringElement.textContent)); | ||
for (var j = 0; j < eventLi.length; j++) { | ||
var searchStringElement = | ||
eventLi[j].getElementsByClassName("searchstring")[0]; | ||
|
||
if (decodedSearchString.includes(filter)) { | ||
li[i].style.display = ""; | ||
} else { | ||
li[i].style.display = "none"; | ||
} | ||
decodedSearchString = normalizeString( | ||
htmlDecode(searchStringElement.textContent) | ||
); | ||
|
||
if (decodedSearchString.includes(filter)) { | ||
eventLi[j].style.display = ""; | ||
} else { | ||
eventLi[j].style.display = "none"; | ||
} | ||
} | ||
} | ||
} | ||
|
||
document.getElementById('myInput').onkeyup = filterEvents; | ||
document.getElementById("myInput").onkeyup = filterEvents; | ||
|
||
function startTime() { | ||
var today, r, t, li, a, b, ul, currentEventFound = false, nextEventElement = null; | ||
today = new Date(); | ||
t = today.getTime(); | ||
ul = document.getElementById("myUL"); | ||
li = ul.getElementsByClassName('event_li'); | ||
var today, | ||
r, | ||
t, | ||
li, | ||
a, | ||
b, | ||
ul, | ||
currentEventFound = false, | ||
nextEventElement = null; | ||
today = new Date(); | ||
t = today.getTime(); | ||
ul = document.getElementById("myUL"); | ||
li = ul.getElementsByClassName("event_li"); | ||
|
||
for (var i = 0; i < li.length; i++) { | ||
a = parseInt(li[i].getElementsByClassName("begin_epoch")[0].innerText); | ||
b = parseInt(li[i].getElementsByClassName("end_epoch")[0].innerText); | ||
for (var i = 0; i < li.length; i++) { | ||
a = parseInt(li[i].getElementsByClassName("begin_epoch")[0].innerText); | ||
b = parseInt(li[i].getElementsByClassName("end_epoch")[0].innerText); | ||
|
||
if (b > t && t > a) { | ||
li[i].style.backgroundColor = "lightblue"; | ||
if (!currentEventFound) { | ||
li[i].scrollIntoView({ behavior: 'smooth', block: 'center' }); | ||
currentEventFound = true; | ||
} | ||
} else { | ||
li[i].style.backgroundColor = (t > b) ? "lightgray" : ""; | ||
if (a > t && !nextEventElement) { | ||
nextEventElement = li[i]; | ||
} | ||
} | ||
if (b > t && t > a) { | ||
li[i].style.backgroundColor = "lightblue"; | ||
if (!currentEventFound) { | ||
li[i].scrollIntoView({ behavior: "smooth", block: "center" }); | ||
currentEventFound = true; | ||
} | ||
} else { | ||
li[i].style.backgroundColor = t > b ? "lightgray" : ""; | ||
if (a > t && !nextEventElement) { | ||
nextEventElement = li[i]; | ||
} | ||
} | ||
} | ||
|
||
if (!currentEventFound && nextEventElement) { | ||
nextEventElement.scrollIntoView({ behavior: 'smooth', block: 'center' }); | ||
} | ||
if (!currentEventFound && nextEventElement) { | ||
nextEventElement.scrollIntoView({ behavior: "smooth", block: "center" }); | ||
} | ||
|
||
setTimeout(startTime, 10000); | ||
setTimeout(startTime, 10000); | ||
} | ||
|
||
var coll = document.getElementsByClassName("events-vert"); | ||
for (var i = 0; i < coll.length; i++) { | ||
coll[i].addEventListener("click", function () { | ||
this.classList.toggle("active"); | ||
var content = this.nextElementSibling; | ||
if (content.style.display === "block") { | ||
content.style.display = "none"; | ||
} else { | ||
content.style.display = "block"; | ||
} | ||
}); | ||
coll[i].addEventListener("click", function () { | ||
this.classList.toggle("active"); | ||
var content = this.nextElementSibling; | ||
if (content.style.display === "block") { | ||
content.style.display = "none"; | ||
} else { | ||
content.style.display = "block"; | ||
} | ||
}); | ||
} | ||
|
||
document.addEventListener('DOMContentLoaded', function() { | ||
startTime(); | ||
document.addEventListener("DOMContentLoaded", function () { | ||
startTime(); | ||
}); |