update styling of subject page

This commit is contained in:
Eric Blommel
2024-11-18 22:13:45 +01:00
parent 32fb286728
commit 4d15af1803
7 changed files with 436 additions and 799 deletions

View File

@@ -318,7 +318,7 @@ if(!isset($topicData)) {
<h2><?php echo($subjectData->displayName); ?></h2>
</div>
<a href="homepage.php" class="nav-link">
<i class="fas fa-home"></i> Homepage
<i class="fas fa-home"></i> Startseite
</a>
<a href="subject.php?subject=<?php echo($subjectData->id); ?>" class="nav-link">
<i class="fas fa-book"></i> <?php echo($subjectData->displayName); ?> Übersicht
@@ -388,35 +388,5 @@ if(!isset($topicData)) {
</div>
</aside>
<!-- Add this script at the end of the body, before the closing body tag -->
<script>
function handleContentSearch() {
const searchTerm = document.getElementById('searchInput').value.toLowerCase();
const contentElements = document.querySelectorAll('.content-text, .content-text li');
if (searchTerm.length < 2) {
// Remove all highlights if search term is too short
document.querySelectorAll('mark').forEach(mark => {
mark.outerHTML = mark.innerHTML;
});
return;
}
contentElements.forEach(element => {
let content = element.innerHTML;
// Remove existing highlights
content = content.replace(/<\/?mark>/g, '');
if (searchTerm) {
// Create a regular expression for case-insensitive search
const regex = new RegExp(`(${searchTerm})`, 'gi');
// Replace matches with highlighted text
content = content.replace(regex, '<mark>$1</mark>');
}
element.innerHTML = content;
});
}
</script>
</body>
</html>