Dynamische Daten in Seitentemplates eingefügt

This commit is contained in:
Matthias Grief
2024-10-28 18:57:59 +01:00
parent 7d162dfadf
commit 26266096ee
18 changed files with 1653 additions and 499 deletions

1
.idea/php.xml generated
View File

@@ -10,6 +10,7 @@
<option name="highlightLevel" value="WARNING" />
<option name="transferred" value="true" />
</component>
<component name="PhpProjectSharedConfiguration" php_language_level="8.0" />
<component name="PhpStanOptionsConfiguration">
<option name="transferred" value="true" />
</component>

View File

@@ -0,0 +1,83 @@
<?php
require_once("Util.php");
require_once("TopicData.php");
class SubjectData
{
public string $id;
public string $displayName;
public string $description;
public string $color;
public string $buttonText;
public string $icon;
public array $topics;
public static function getAll() : array
{
$result = array();
$subjectDirectory = "config/subjects";
$subjectNames = scandir($subjectDirectory);
foreach ($subjectNames as $subjectName) {
if ($subjectName == "." || $subjectName == "..") {
continue;
}
$subjectData = SubjectData::fromName($subjectName);
if(!isset($subjectData)) {
continue;
}
$result[] = $subjectData;
}
return $result;
}
public static function fromName($subjectName) : SubjectData|null
{
$result = new SubjectData();
$subjectName = Util::removeIllegalCharacters($subjectName);
$subjectDirectory = "config/subjects/$subjectName";
$filename = "$subjectDirectory/properties.json";
$data = Util::parseJsonFromFile($filename);
$result->id = $subjectName;
if(isset($data->displayName)) {
$result->displayName = $data->displayName;
} else {
return null;
}
if(isset($data->description)) {
$result->description = $data->description;
} else {
return null;
}
if(isset($data->color)) {
$result->color = $data->color;
} else {
return null;
}
if(isset($data->buttonText)) {
$result->buttonText = $data->buttonText;
} else {
return null;
}
if(isset($data->icon)) {
$result->icon = $data->icon;
} else {
return null;
}
$result->topics = TopicData::getAll($subjectName);
return $result;
}
}

View File

@@ -0,0 +1,88 @@
<?php
require_once("Util.php");
class TopicData
{
public string $id;
public string $subjectId;
public string $displayName;
public string $icon;
public string $description;
public array $relatedTopics;
public array $files;
public string $article;
public static function getAll($subjectName) : array
{
$result = array();
$topicDirectory = "config/subjects/$subjectName/topics";
$topicNames = scandir($topicDirectory);
foreach ($topicNames as $topicName) {
if ($topicName == "." || $topicName == "..") {
continue;
}
$topicData = TopicData::fromName($subjectName, $topicName);
if(!isset($topicData)) {
continue;
}
$result[] = $topicData;
}
return $result;
}
public static function fromName($subjectName, $topicName): TopicData|null
{
$result = new TopicData();
$subjectName = Util::removeIllegalCharacters($subjectName);
$topicName = Util::removeIllegalCharacters($topicName);
$topicDirectory = "config/subjects/$subjectName/topics";
$filename = "$topicDirectory/$topicName/properties.json";
$data = Util::parseJsonFromFile($filename);
$result->id = $topicName;
$result->subjectId = $subjectName;
if(isset($data->displayName)) {
$result->displayName = $data->displayName;
} else {
return null;
}
if(isset($data->icon)) {
$result->icon = $data->icon;
} else {
return null;
}
if(isset($data->description)) {
$result->description = $data->description;
} else {
return null;
}
if(isset($data->relatedTopics)) {
$result->relatedTopics = $data->relatedTopics;
} else {
$result->relatedTopics = array();
}
if(isset($data->files)) {
$result->files = $data->files;
} else {
$result->files = array();
}
if(isset($data->article)) {
$result->article = $data->article;
} else {
return null;
}
return $result;
}
}

18
webseite/classes/Util.php Normal file
View File

@@ -0,0 +1,18 @@
<?php
class Util
{
static function removeIllegalCharacters($string): string
{
return preg_replace("/[^a-zA-Z0-9_-]/", "", $string);
}
static function parseJsonFromFile($filename): mixed
{
$file = fopen($filename, "r") or die("Unable to open file!");
$fileContent = fread($file, filesize($filename));
fclose($file);
return json_decode($fileContent);
}
}

View File

@@ -0,0 +1,7 @@
{
"displayName": "Deutsch",
"description": "Deutsch ist blau",
"color": "#FF0000",
"buttonText": "Erfahre von einem ungeheuren Ungeziefer",
"icon": "fa-book"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

@@ -0,0 +1,12 @@
{
"displayName": "Thema 1",
"icon": "fa-divide",
"description": "Eine kurze Beschreibung des Themas",
"relatedTopics": [
"topic2", "topic3"
],
"files": [
"exercise1.pdf"
],
"article": "Eine lange Erklärung\n![Alt Text](image.png)"
}

View File

@@ -0,0 +1,7 @@
{
"displayName": "Mathe",
"description": "Mathe ist gelb",
"color": "#60A5FA",
"buttonText": "Jetzt rechnen!",
"icon": "fa-square-root-alt"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

@@ -0,0 +1,12 @@
{
"displayName": "Thema 1",
"icon": "fa-divide",
"description": "Eine kurze Beschreibung des Themas",
"relatedTopics": [
"topic2", "topic3"
],
"files": [
"exercise1.pdf"
],
"article": "Eine lange Erklärung\n![Alt Text](image.png)"
}

View File

@@ -0,0 +1,11 @@
{
"displayName": "Thema 2",
"icon": "fa-ruler",
"description": "Kurze Beschreibung",
"relatedTopics": [
"topic3"
],
"files": [
],
"article": "Erklärung"
}

243
webseite/homepage.php Normal file
View File

@@ -0,0 +1,243 @@
<!DOCTYPE html>
<!--Homepage-->
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Modernes Lernportal</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<script src="https://cdn.tailwindcss.com"></script>
<style>
@keyframes float {
0%, 100% { transform: translateY(0px); }
50% { transform: translateY(-20px); }
}
.card-hover {
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
.card-hover:hover {
transform: translateY(-10px) scale(1.02);
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
.gradient-border {
position: relative;
background: linear-gradient(white, white) padding-box,
linear-gradient(45deg, #7C3AED, #F59E0B) border-box;
border: 4px solid transparent;
border-radius: 1rem;
}
.blob {
animation: blob 7s infinite;
filter: blur(40px);
}
@keyframes blob {
0%, 100% { border-radius: 42% 58% 70% 30% / 45% 45% 55% 55%; }
33% { border-radius: 72% 28% 30% 70% / 53% 51% 49% 47%; }
66% { border-radius: 38% 62% 63% 37% / 46% 48% 52% 54%; }
}
.pulse {
animation: pulse 2s infinite;
}
@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.05); }
100% { transform: scale(1); }
}
/* Improved icon hover effect */
.w-12 {
transition: all 0.3s ease;
}
.card-hover:hover .w-12 {
transform: scale(1.1) rotate(-5deg);
}
/* Improved button hover effect */
.hover\:bg-purple-700:hover {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}
/* Scroll to top button */
.scroll-top {
position: fixed;
bottom: 2rem;
right: 6rem; /* Move scroll-top button to the left of accessibility button */
background: linear-gradient(135deg, #7C3AED, #F59E0B);
color: white;
padding: 1rem;
border-radius: 50%;
cursor: pointer;
opacity: 0;
transition: all 0.3s ease;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.scroll-top.visible {
opacity: 1;
}
.scroll-top:hover {
transform: translateY(-3px);
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}
</style>
</head>
<body class="bg-gray-50">
<!-- Animated background blobs -->
<div class="fixed inset-0 -z-10 overflow-hidden">
<div class="blob absolute w-96 h-96 bg-purple-300/30 -top-48 -left-16"></div>
<div class="blob absolute w-96 h-96 bg-amber-300/30 bottom-0 right-0"></div>
</div>
<!-- Navigation -->
<nav class="fixed top-0 w-full bg-white/80 backdrop-blur-lg shadow-sm z-50">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between h-16">
<div class="flex items-center">
<span class="text-2xl font-bold text-purple-600">Lern<span class="text-amber-500">Portal</span></span>
</div>
<!-- Add this accessibility controls -->
</div>
</div>
</nav>
<!-- Hero Section -->
<div class="pt-24 pb-16 px-4">
<div class="max-w-7xl mx-auto">
<div class="text-center">
<h1 class="text-5xl md:text-6xl font-bold text-gray-900 mb-6 pulse">
Entdecke deine <span class="text-purple-600">Lernreise</span>
</h1>
<p class="text-xl text-gray-600 max-w-2xl mx-auto">
Interaktives Lernen für die digitale Generation. Personalisierte Lernpfade, sofortiges Feedback und spielerische Elemente.
</p>
</div>
</div>
</div>
<!-- Subject Grid -->
<div class="max-w-7xl mx-auto px-4 py-12 grid grid-cols-1 md:grid-cols-2 gap-8">
<!-- Mathematik -->
<?php
require_once ("classes/SubjectData.php");
$subjects = SubjectData::getAll();
foreach ($subjects as $subject) {
?>
<a href="subject.php?subject=<?php echo($subject->id); ?>" class="block">
<div class="gradient-border p-6 card-hover bg-white">
<div class="flex items-start space-x-4">
<div class="w-12 h-12 rounded-lg bg-purple-100 flex items-center justify-center">
<i class="fas <?php echo($subject->icon); ?> text-2xl text-purple-600"></i>
</div>
<div class="flex-1">
<h3 class="text-xl font-bold text-gray-900 mb-2"><?php echo($subject->displayName); ?></h3>
<p class="text-gray-600 mb-4"><?php echo($subject->description); ?></p>
<div class="grid grid-cols-3 gap-4 mb-4">
<div class="text-center p-2 rounded-lg bg-purple-50">
<div class="font-bold text-purple-600">150+</div>
<div class="text-sm text-gray-600">Übungen</div>
</div>
<div class="text-center p-2 rounded-lg bg-purple-50">
<div class="font-bold text-purple-600">12</div>
<div class="text-sm text-gray-600">Kapitel</div>
</div>
<div class="text-center p-2 rounded-lg bg-purple-50">
<div class="font-bold text-purple-600">4.8</div>
<div class="text-sm text-gray-600">Bewertung</div>
</div>
</div>
<div class="flex items-center space-x-2">
<span class="text-sm text-gray-500">Aktuelle Einheit:</span>
<span class="px-2 py-1 rounded-full bg-purple-100 text-purple-600 text-sm">Bruchrechnung</span>
</div>
</div>
</div>
</div>
</a>
<?php
}
?>
</div>
<button class="scroll-top" onclick="scrollToTop()" id="scrollTop">
<i class="fas fa-arrow-up"></i>
</button>
<script>
// Initialize GSAP animations
gsap.from(".gradient-border", {
duration: 0.8,
y: 60,
opacity: 0,
stagger: 0.2,
ease: "power3.out"
});
// Add intersection observer for scroll animations
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.transform = "translateY(0)";
entry.target.style.opacity = "1";
}
});
}, { threshold: 0.1 });
document.querySelectorAll('.gradient-border').forEach((el) => {
observer.observe(el);
});
// Scroll to top functionality
window.onscroll = function() {
const scrollBtn = document.getElementById('scrollTop');
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
scrollBtn.classList.add('visible');
} else {
scrollBtn.classList.remove('visible');
}
};
function scrollToTop() {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
}
// Add hover effects for subject cards
document.querySelectorAll('.gradient-border').forEach(card => {
card.addEventListener('mouseenter', () => {
gsap.to(card.querySelector('.w-12'), {
rotate: -10,
scale: 1.2,
duration: 0.3
});
});
card.addEventListener('mouseleave', () => {
gsap.to(card.querySelector('.w-12'), {
rotate: 0,
scale: 1,
duration: 0.3
});
});
});
</script>
</body>
</html>

View File

@@ -1,171 +0,0 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lernportal</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: system-ui, -apple-system, sans-serif;
}
body {
min-height: 100vh;
background: linear-gradient(135deg, #f6f8ff 0%, #f1f5ff 100%);
display: flex;
flex-direction: column;
align-items: center;
padding: 2rem;
}
h1 {
color: #2d3748;
font-size: 2.5rem;
margin-bottom: 2rem;
text-align: center;
animation: bounce 1s ease;
}
.container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 2rem;
max-width: 1200px;
width: 100%;
}
.subject-card {
background: white;
border-radius: 24px;
padding: 2rem;
text-align: center;
transition: transform 0.3s ease, box-shadow 0.3s ease;
cursor: pointer;
position: relative;
overflow: hidden;
min-height: 280px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
.subject-card:hover {
transform: translateY(-5px);
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}
.subject-card::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 8px;
background: var(--accent-color);
}
.mathematik {
--accent-color: #60A5FA;
}
.englisch {
--accent-color: #34D399;
}
.deutsch {
--accent-color: #F472B6;
}
.physik {
--accent-color: #A78BFA;
}
.icon {
font-size: 3.5rem;
margin-bottom: 1rem;
color: var(--accent-color);
}
.subject-name {
font-size: 1.5rem;
font-weight: 600;
color: #2d3748;
margin-bottom: 0.5rem;
}
.description {
font-size: 1rem;
color: #64748b;
margin-bottom: 1rem;
}
.start-button {
background: var(--accent-color);
color: white;
border: none;
padding: 0.75rem 1.5rem;
border-radius: 12px;
font-weight: 600;
transition: opacity 0.2s ease;
text-decoration: none;
}
.start-button:hover {
opacity: 0.9;
}
@keyframes bounce {
0% { transform: translateY(-20px); opacity: 0; }
100% { transform: translateY(0); opacity: 1; }
}
@media (max-width: 768px) {
.container {
grid-template-columns: 1fr;
padding: 1rem;
}
h1 {
font-size: 2rem;
}
}
</style>
</head>
<body>
<h1>Wähle dein Lieblingsfach! 🚀</h1>
<div class="container">
<div class="subject-card mathematik">
<div class="icon">🔢</div>
<h2 class="subject-name">Mathematik</h2>
<p class="description">Löse spannende Aufgaben und werde zum Mathe-Champion!</p>
<a href="./mathe/mathe.html" class="start-button">Jetzt rechnen!</a>
</div>
<div class="subject-card englisch">
<div class="icon">📚</div>
<h2 class="subject-name">Englisch</h2>
<p class="description">Entdecke neue Wörter und verbessere dein Englisch!</p>
<a href="#englisch" class="start-button">Los geht's!</a>
</div>
<div class="subject-card deutsch">
<div class="icon">✍️</div>
<h2 class="subject-name">Deutsch</h2>
<p class="description">Erkunde Geschichten und verbessere deine Sprache!</p>
<a href="#deutsch" class="start-button">Start!</a>
</div>
<div class="subject-card physik">
<div class="icon"></div>
<h2 class="subject-name">Physik</h2>
<p class="description">Entdecke die spannende Welt der Naturwissenschaften!</p>
<a href="#physik" class="start-button">Experimentieren!</a>
</div>
</div>
</body>
</html>

View File

@@ -1,328 +0,0 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mathematik 5. Klasse</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-color: #f5f5f5;
min-height: 100vh;
display: flex;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
/* Sidebar Styles */
.sidebar {
width: 250px;
height: 100vh;
background: white;
padding: 20px;
position: fixed;
left: 0;
top: 0;
box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
transition: all 0.3s ease;
z-index: 1000;
}
.search-container {
position: fixed;
top: 0;
left: 250px;
right: 0;
padding: 20px;
background: white;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
transition: all 0.3s ease;
z-index: 100;
}
.search-box {
width: 100%;
padding: 12px 20px;
border: 2px solid #ddd;
border-radius: 25px;
outline: none;
font-size: 16px;
}
.nav-link {
display: flex;
align-items: center;
padding: 15px;
color: #333;
text-decoration: none;
border-radius: 10px;
margin-bottom: 10px;
transition: all 0.3s ease;
}
.nav-link:hover {
background-color: #f0f0f0;
transform: translateX(5px);
}
.nav-link i {
margin-right: 15px;
}
/* Main Content Styles */
.main-content {
margin-left: 250px;
width: calc(100% - 250px);
padding-top: 80px;
}
.container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 20px;
padding: 20px;
max-width: 1600px;
margin: 0 auto;
}
.topic-card {
background: white;
border-radius: 15px;
padding: 20px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
transition: all 0.3s ease;
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
}
.topic-card:hover {
transform: translateY(-5px);
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}
.topic-icon {
font-size: 2.5rem;
margin-bottom: 15px;
color: #4a90e2;
}
.topic-title {
font-size: 1.25rem;
font-weight: 600;
margin-bottom: 10px;
color: #333;
}
.topic-description {
font-size: 0.9rem;
color: #666;
line-height: 1.4;
}
.progress-bar {
width: 100%;
height: 8px;
background: #eee;
border-radius: 4px;
margin-top: 15px;
overflow: hidden;
}
.progress {
height: 100%;
background: #4a90e2;
border-radius: 4px;
width: 0%;
transition: width 0.3s ease;
}
/* Responsive Design */
@media (max-width: 900px) {
.sidebar {
transform: translateX(-250px);
}
.sidebar.active {
transform: translateX(0);
}
.main-content {
margin-left: 0;
width: 100%;
}
.search-container {
left: 0;
}
.menu-toggle {
display: block;
}
}
.menu-toggle {
display: none;
position: fixed;
top: 20px;
left: 20px;
z-index: 1001;
background: white;
border: none;
padding: 12px;
border-radius: 8px;
cursor: pointer;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
</style>
</head>
<body>
<button class="menu-toggle">
<i class="fas fa-bars"></i>
</button>
<nav class="sidebar">
<h2 style="margin-bottom: 20px;">Navigation</h2>
<a href="#" class="nav-link">
<i class="fas fa-home"></i> Startseite
</a>
<a href="#" class="nav-link">
<i class="fas fa-book"></i> Aufgaben
</a>
<a href="#" class="nav-link">
<i class="fas fa-chart-line"></i> Fortschritt
</a>
<a href="#" class="nav-link">
<i class="fas fa-question-circle"></i> Hilfe
</a>
</nav>
<div class="search-container">
<input type="text" class="search-box" placeholder="Themen durchsuchen...">
</div>
<div class="main-content">
<div class="container">
<div class="topic-card">
<i class="fas fa-calculator topic-icon"></i>
<h3 class="topic-title">Grundrechenarten</h3>
<p class="topic-description">Addition, Subtraktion, Multiplikation und Division mit natürlichen Zahlen</p>
<div class="progress-bar">
<div class="progress" style="width: 75%"></div>
</div>
</div>
<div class="topic-card">
<i class="fas fa-divide topic-icon"></i>
<h3 class="topic-title">Bruchrechnung</h3>
<p class="topic-description">Einführung in Brüche, Erweitern und Kürzen von Brüchen</p>
<div class="progress-bar">
<div class="progress" style="width: 45%"></div>
</div>
</div>
<div class="topic-card">
<i class="fas fa-ruler topic-icon"></i>
<h3 class="topic-title">Geometrie</h3>
<p class="topic-description">Grundformen, Flächen und Umfang von geometrischen Figuren</p>
<div class="progress-bar">
<div class="progress" style="width: 60%"></div>
</div>
</div>
<div class="topic-card">
<i class="fas fa-percentage topic-icon"></i>
<h3 class="topic-title">Dezimalzahlen</h3>
<p class="topic-description">Rechnen mit Dezimalzahlen und Stellenwertsystem</p>
<div class="progress-bar">
<div class="progress" style="width: 30%"></div>
</div>
</div>
<div class="topic-card">
<i class="fas fa-arrows-alt-h topic-icon"></i>
<h3 class="topic-title">Längenmaße</h3>
<p class="topic-description">Umrechnen von Längeneinheiten und praktische Anwendungen</p>
<div class="progress-bar">
<div class="progress" style="width: 55%"></div>
</div>
</div>
<div class="topic-card">
<i class="fas fa-balance-scale topic-icon"></i>
<h3 class="topic-title">Gewichte</h3>
<p class="topic-description">Gewichtseinheiten und deren Umrechnung</p>
<div class="progress-bar">
<div class="progress" style="width: 40%"></div>
</div>
</div>
<div class="topic-card">
<i class="fas fa-clock topic-icon"></i>
<h3 class="topic-title">Zeitrechnung</h3>
<p class="topic-description">Umgang mit Zeiteinheiten und Zeitspannen</p>
<div class="progress-bar">
<div class="progress" style="width: 85%"></div>
</div>
</div>
<div class="topic-card">
<i class="fas fa-square-root-alt topic-icon"></i>
<h3 class="topic-title">Terme und Gleichungen</h3>
<p class="topic-description">Erste Schritte mit mathematischen Ausdrücken</p>
<div class="progress-bar">
<div class="progress" style="width: 25%"></div>
</div>
</div>
</div>
</div>
<script>
const sidebar = document.querySelector('.sidebar');
const menuToggle = document.querySelector('.menu-toggle');
const searchContainer = document.querySelector('.search-container');
let lastScroll = 0;
window.addEventListener('scroll', () => {
const currentScroll = window.pageYOffset;
if (currentScroll > lastScroll && currentScroll > 50) {
searchContainer.style.transform = 'translateY(-100%)';
} else {
searchContainer.style.transform = 'translateY(0)';
}
lastScroll = currentScroll;
});
menuToggle.addEventListener('click', () => {
sidebar.classList.toggle('active');
});
document.addEventListener('click', (e) => {
if (window.innerWidth <= 900) {
if (!sidebar.contains(e.target) && !menuToggle.contains(e.target)) {
sidebar.classList.remove('active');
}
}
});
// Animation for progress bars
document.querySelectorAll('.topic-card').forEach(card => {
card.addEventListener('mouseenter', () => {
const progress = card.querySelector('.progress');
const width = progress.style.width;
progress.style.width = '0%';
setTimeout(() => {
progress.style.width = width;
}, 50);
});
});
</script>
</body>
</html>

765
webseite/subject.php Normal file
View File

@@ -0,0 +1,765 @@
<!DOCTYPE html>
<?php
require_once ("classes/SubjectData.php");
require_once ("classes/TopicData.php");
$subjectData = SubjectData::fromName($_GET["subject"]);
$topics = $subjectData->topics;
?>
<html lang="de">
<!--topics-->
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo($subjectData->displayName); ?> 5. Klasse - Modern</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
:root {
--primary: #7C3AED;
--primary-light: #9F67FF;
--primary-dark: #6D28D9;
--bg-color: #F4F7FE;
--card-bg: #ffffff;
--text-primary: #1E293B;
--text-secondary: #64748B;
--accent: #F59E0B;
}
/* Add this right after the existing :root {...} block in the style section */
:root[data-theme="dark"] {
--primary: #9F67FF;
--primary-light: #B794F4;
--primary-dark: #7C3AED;
--bg-color: #1A1A2E;
--card-bg: #1E293B;
--text-primary: #E2E8F0;
--text-secondary: #A0AEC0;
--accent: #F59E0B;
}
body {
background-color: var(--bg-color);
min-height: 100vh;
display: flex;
overflow-x: hidden;
}
.sidebar {
width: 280px;
height: 100vh;
background: var(--primary);
padding: 2rem;
position: fixed;
left: 0;
top: 0;
transition: transform 0.3s ease;
z-index: 50;
}
.sidebar-header {
color: white;
margin-bottom: 2rem;
display: flex;
align-items: center;
gap: 1rem;
}
.sidebar-header i {
font-size: 2rem;
}
.nav-link {
display: flex;
align-items: center;
padding: 1rem;
color: rgba(255, 255, 255, 0.8);
text-decoration: none;
border-radius: 12px;
margin-bottom: 0.5rem;
transition: all 0.2s ease;
}
.nav-link:hover {
background: rgba(255, 255, 255, 0.1);
color: white;
transform: translateX(5px);
}
.nav-link i {
margin-right: 1rem;
font-size: 1.25rem;
}
.search-container {
position: fixed;
top: 0;
left: 280px;
right: 0;
padding: 1rem 2rem;
background: var(--card-bg);
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
transition: left 0.3s ease;
z-index: 40;
display: flex;
align-items: center;
gap: 1rem;
}
.search-box {
flex: 1;
padding: 0.75rem 1rem;
border: 2px solid #E2E8F0;
border-radius: 12px;
outline: none;
font-size: 1rem;
transition: all 0.2s ease;
background: var(--bg-color);
}
.search-box:focus {
border-color: var(--primary);
box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}
.main-content {
margin-left: 280px;
width: calc(100% - 280px);
padding-top: 5rem;
transition: margin-left 0.3s ease;
}
.container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
gap: 2rem;
padding: 2rem;
max-width: 1600px;
margin: 0 auto;
}
.topic-card {
background: var(--card-bg);
border-radius: 20px;
padding: 2rem;
position: relative;
overflow: hidden;
border: 1px solid rgba(255, 255, 255, 0.1);
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
transform: translateY(0);
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
display: flex;
flex-direction: column;
gap: 1.5rem;
}
.topic-card::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 5px;
background: linear-gradient(90deg, var(--primary), var(--accent));
transform: scaleX(0);
transform-origin: left;
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.topic-card:hover {
transform: translateY(-5px);
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
.topic-card:hover::before {
transform: scaleX(1);
}
.topic-header {
display: flex;
align-items: center;
margin-bottom: 1.5rem;
position: relative;
}
.topic-icon {
font-size: 2.5rem;
color: var(--primary);
margin-right: 1rem;
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.topic-card:hover .topic-icon {
transform: rotate(-10deg);
color: var(--accent);
}
.topic-title {
font-size: 1.5rem;
font-weight: 600;
color: var(--text-primary);
margin-bottom: 0.5rem;
}
.topic-description {
font-size: 1rem;
color: var(--text-secondary);
line-height: 1.7;
margin-bottom: 1.5rem;
}
.related-topics {
margin: 0;
}
.download-section {
margin-top: auto;
}
.progress-container {
margin-top: 1.5rem;
}
.download-section h4 {
margin-bottom: 1rem;
font-size: 1rem;
}
.download-links {
display: flex;
gap: 1rem;
flex-wrap: wrap;
}
.download-btn {
background: rgba(255, 255, 255, 0.1);
color: white;
padding: 0.75rem 1.25rem;
border-radius: 10px;
text-decoration: none;
font-size: 0.9rem;
transition: all 0.2s ease;
backdrop-filter: blur(5px);
flex: 1;
min-width: 120px;
display: flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
transform: translateY(0); /* Set initial transform state */
transition: all 0.2s ease;
}
.download-btn:hover {
transform: translateY(-2px);
background: rgba(255, 255, 255, 0.2);
}
.progress-label {
display: flex;
justify-content: space-between;
margin-bottom: 0.5rem;
font-size: 0.9rem;
color: var(--text-secondary);
}
.progress-bar {
height: 8px;
background: #E2E8F0;
border-radius: 4px;
overflow: hidden;
}
.progress {
height: 100%;
background: linear-gradient(90deg, var(--primary), var(--accent));
border-radius: 4px;
width: 0%;
transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}
@media (max-width: 1024px) {
.sidebar {
transform: translateX(-100%);
}
.sidebar.active {
transform: translateX(0);
}
.main-content {
margin-left: 0;
width: 100%;
}
.search-container {
left: 0;
}
}
.menu-toggle {
position: fixed;
top: 1rem;
left: 1rem;
z-index: 60;
background: white;
border: none;
padding: 0.75rem;
border-radius: 10px;
cursor: pointer;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
display: none;
}
@media (max-width: 1024px) {
.menu-toggle {
display: block;
}
}
/* Add floating animation for icons */
@keyframes float {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-10px); }
}
/* Add theme toggle button styles */
.theme-toggle {
position: fixed;
top: 1rem;
right: 1rem;
z-index: 100;
background: var(--card-bg);
border: none;
padding: 0.75rem;
border-radius: 50%;
cursor: pointer;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
color: var(--text-primary);
transition: all 0.3s ease;
}
.theme-toggle:hover {
transform: rotate(45deg);
}
/* Update animation keyframes */
@keyframes cardAppear {
0% {
opacity: 0;
transform: translateY(20px);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
/* Add these styles back for the download section */
.download-section {
background: linear-gradient(135deg, var(--primary-light), var(--primary));
padding: 1.5rem;
border-radius: 12px;
color: white;
margin-top: auto;
}
.download-section h4 {
margin-bottom: 1rem;
font-size: 1rem;
color: rgba(255, 255, 255, 0.9);
}
.download-links {
display: flex;
gap: 1rem;
flex-wrap: wrap;
}
.download-btn {
background: rgba(255, 255, 255, 0.1);
color: white;
padding: 0.75rem 1.25rem;
border-radius: 10px;
text-decoration: none;
font-size: 0.9rem;
transition: all 0.2s ease;
backdrop-filter: blur(5px);
flex: 1;
min-width: 120px;
display: flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
}
.download-btn:hover {
background: rgba(255, 255, 255, 0.2);
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
/* Add these styles for the related-topics section */
.related-topics {
background: rgba(124, 58, 237, 0.05);
padding: 1.25rem;
border-radius: 12px;
margin-bottom: 1.5rem;
}
.related-topics h4 {
color: var(--primary);
margin-bottom: 1rem;
font-size: 1rem;
}
.related-topics ul {
list-style: none;
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}
.related-topics li {
background: white;
padding: 0.5rem 1rem;
border-radius: 20px;
font-size: 0.9rem;
color: var(--text-secondary);
border: 1px solid rgba(124, 58, 237, 0.2);
transition: all 0.2s ease;
cursor: pointer;
}
.related-topics li:hover {
background: var(--primary);
color: white;
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
/* Add dark mode support for related topics */
:root[data-theme="dark"] .related-topics {
background: rgba(124, 58, 237, 0.1);
}
:root[data-theme="dark"] .related-topics li {
background: var(--card-bg);
border-color: rgba(124, 58, 237, 0.3);
}
/* Improved search box */
.search-box {
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}
.search-box:focus {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(124, 58, 237, 0.15);
}
/* Improved topic card hover */
.topic-card {
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.topic-card:hover {
transform: translateY(-5px) scale(1.01);
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}
/* Improved icon animation */
.topic-icon {
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.topic-card:hover .topic-icon {
transform: scale(1.2) rotate(-10deg);
color: var(--accent);
}
/* Active nav link style */
.nav-link.active {
background: rgba(255, 255, 255, 0.15);
color: white;
font-weight: 600;
}
</style>
</head>
<body>
<button class="menu-toggle" onclick="toggleSidebar()">
<i class="fas fa-bars"></i>
</button>
<nav class="sidebar">
<div class="sidebar-header">
<i class="fas fa-graduation-cap"></i>
<h2><?php echo($subjectData->displayName); ?></h2>
</div>
<!-- Remove this section -->
<!-- <div class="accessibility-controls mb-4">...</div> -->
<a href="homepage.php" class="nav-link">
<i class="fas fa-home"></i> Homepage
</a>
<a href="#" class="nav-link">
<i class="fas fa-book"></i> Kurse
</a>
<a href="#" class="nav-link">
<i class="fas fa-trophy"></i> Erfolge
</a>
<a href="#" class="nav-link">
<i class="fas fa-chart-line"></i> Fortschritt
</a>
<a href="#" class="nav-link">
<i class="fas fa-question-circle"></i> Hilfe
</a>
</nav>
<div class="search-container">
<input type="text" class="search-box" id="searchInput" placeholder="Suche nach Themen, Übungen oder Hilfe..." oninput="handleSearch()">
</div>
<div class="main-content">
<div class="container">
<?php
foreach ($topics as $topic) {
?>
<div class="topic-card" onclick="window.location.href='topic.php?subject=<?php echo($topic->subjectId); ?>&topic=<?php echo($topic->id); ?>'" style="cursor: pointer;">
<div class="topic-header">
<i class="fas <?php echo($topic->icon); ?> topic-icon"></i>
<h3 class="topic-title"><?php echo($topic->displayName); ?></h3>
</div>
<div class="topic-content">
<p class="topic-description">
<?php echo($topic->description); ?>
</p>
<div class="related-topics">
<h4>Verwandte Themen:</h4>
<ul>
<?php
foreach ($topic->relatedTopics as $relatedTopic) {
?>
<li><?php echo($relatedTopic); ?></li>
<?php
}
?>
</ul>
</div>
</div>
<div class="download-section">
<h4>Übungen herunterladen:</h4>
<div class="download-links">
<?php
foreach ($topic->files as $file) {
?>
<a href="#" class="download-btn">
<i class="fas fa-file-pdf"></i>
<?php echo($file); ?>
</a>
<?php
}
?>
<a href="#" class="download-btn">
<i class="fas fa-file-pdf"></i>
Übung 1
</a>
<a href="#" class="download-btn">
<i class="fas fa-file-pdf"></i>
Übung 2
</a>
</div>
</div>
<div class="progress-bar" data-progress="100">
<div class="progress"></div>
</div>
</div>
<?php
}
?>
</div>
</div>
<script>
function toggleSidebar() {
document.querySelector('.sidebar').classList.toggle('active');
}
// Animate progress bars on load
document.addEventListener('DOMContentLoaded', () => {
const progressBars = document.querySelectorAll('.progress-bar');
progressBars.forEach(bar => {
const progressContainer = bar.closest('.progress-container');
const progressLabel = progressContainer.querySelector('.progress-label');
const percentage = progressLabel.lastElementChild.textContent.replace('%', '');
setTimeout(() => {
bar.style.width = percentage + '%';
}, 300);
});
});
// Theme toggle functionality
function toggleTheme() {
const root = document.documentElement;
const themeToggle = document.querySelector('.theme-toggle i');
if (root.getAttribute('data-theme') === 'dark') {
root.removeAttribute('data-theme');
themeToggle.classList.remove('fa-sun');
themeToggle.classList.add('fa-moon');
localStorage.setItem('theme', 'light');
} else {
root.setAttribute('data-theme', 'dark');
themeToggle.classList.remove('fa-moon');
themeToggle.classList.add('fa-sun');
localStorage.setItem('theme', 'dark');
}
}
// Check for saved theme preference
document.addEventListener('DOMContentLoaded', () => {
const savedTheme = localStorage.getItem('theme');
const root = document.documentElement;
const themeToggle = document.querySelector('.theme-toggle i');
if (savedTheme === 'dark') {
root.setAttribute('data-theme', 'dark');
themeToggle.classList.remove('fa-moon');
themeToggle.classList.add('fa-sun');
}
// Add stagger effect to cards
const cards = document.querySelectorAll('.topic-card');
cards.forEach((card, index) => {
card.style.animationDelay = `${index * 0.1}s`;
});
// Initialize progress bars
const progressBars = document.querySelectorAll('.progress-bar');
progressBars.forEach(bar => {
const progress = bar.getAttribute('data-progress');
const progressElement = bar.querySelector('.progress');
setTimeout(() => {
progressElement.style.width = `${progress}%`;
}, 300);
});
});
// Update progress bars to 100%
document.addEventListener('DOMContentLoaded', () => {
const progressBars = document.querySelectorAll('.progress-bar');
progressBars.forEach(bar => {
const progressElement = bar.querySelector('.progress');
setTimeout(() => {
progressElement.style.width = '100%';
}, 300);
});
});
// Add preview functionality
function togglePreview(element) {
const previewContent = element.nextElementSibling;
const isHidden = previewContent.style.display === 'none';
if (isHidden) {
// Load preview content
previewContent.innerHTML = `
<div class="p-4 bg-gray-50 rounded-lg mt-4">
<h4 class="font-semibold mb-2">Schnelle Übung:</h4>
<div class="interactive-question mb-4">
<!-- Dynamic content based on topic -->
</div>
</div>
`;
gsap.to(previewContent, {
height: 'auto',
opacity: 1,
duration: 0.3,
display: 'block'
});
} else {
gsap.to(previewContent, {
height: 0,
opacity: 0,
duration: 0.3,
onComplete: () => {
previewContent.style.display = 'none';
}
});
}
}
// Add card hover effects
document.querySelectorAll('.topic-card').forEach(card => {
card.addEventListener('mouseenter', () => {
gsap.to(card.querySelector('.topic-icon'), {
rotate: -10,
scale: 1.2,
duration: 0.3
});
});
card.addEventListener('mouseleave', () => {
gsap.to(card.querySelector('.topic-icon'), {
rotate: 0,
scale: 1,
duration: 0.3
});
});
});
function handleSearch() {
const searchTerm = document.getElementById('searchInput').value.toLowerCase();
const topicCards = document.querySelectorAll('.topic-card');
topicCards.forEach(card => {
const title = card.querySelector('.topic-title').textContent.toLowerCase();
const description = card.querySelector('.topic-description').textContent.toLowerCase();
const relatedTopics = Array.from(card.querySelectorAll('.related-topics li'))
.map(li => li.textContent.toLowerCase())
.join(' ');
const content = `${title} ${description} ${relatedTopics}`;
if (content.includes(searchTerm)) {
card.style.display = 'block';
// Optional: Add animation for appearing cards
gsap.to(card, {
opacity: 1,
y: 0,
duration: 0.3
});
} else {
card.style.display = 'none';
}
});
}
</script>
<!-- Code injected by live-server -->
</body></html>

406
webseite/topic.php Normal file
View File

@@ -0,0 +1,406 @@
<!DOCTYPE html>
<?php
require_once ("classes/SubjectData.php");
require_once ("classes/TopicData.php");
$subjectData = SubjectData::fromName($_GET["subject"]);
$topicData = TopicData::fromName($_GET["subject"], $_GET["topic"]);
?>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo($topicData->displayName); ?> - <?php echo($subjectData->displayName); ?></title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
:root {
--primary: #7C3AED;
--primary-light: #9F67FF;
--primary-dark: #6D28D9;
--bg-color: #F4F7FE;
--card-bg: #ffffff;
--text-primary: #1E293B;
--text-secondary: #64748B;
--accent: #F59E0B;
}
body {
background-color: var(--bg-color);
min-height: 100vh;
display: flex;
overflow-x: hidden;
}
/* Left Sidebar Styles */
.sidebar {
width: 280px;
height: 100vh;
background: var(--primary);
padding: 2rem;
position: fixed;
left: 0;
top: 0;
transition: transform 0.3s ease;
z-index: 50;
}
.sidebar-header {
color: white;
margin-bottom: 2rem;
display: flex;
align-items: center;
gap: 1rem;
}
.sidebar-header i {
font-size: 2rem;
}
.nav-link {
display: flex;
align-items: center;
padding: 1rem;
color: rgba(255, 255, 255, 0.8);
text-decoration: none;
border-radius: 12px;
margin-bottom: 0.5rem;
transition: all 0.2s ease;
}
.nav-link:hover {
background: rgba(255, 255, 255, 0.1);
color: white;
transform: translateX(5px);
}
.nav-link i {
margin-right: 1rem;
font-size: 1.25rem;
}
/* Main Content Styles */
.main-content {
margin-left: 280px;
margin-right: 300px;
padding: 2rem;
flex: 1;
}
.search-container {
position: sticky;
top: 0;
background: var(--card-bg);
padding: 1rem;
border-radius: 12px;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
margin-bottom: 2rem;
z-index: 40;
}
.search-box {
width: 100%;
padding: 0.75rem 1rem;
border: 2px solid #E2E8F0;
border-radius: 12px;
outline: none;
font-size: 1rem;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}
.search-box:focus {
border-color: var(--primary);
box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(124, 58, 237, 0.15);
}
/* Content Card Styles */
.content-card {
background: var(--card-bg);
border-radius: 20px;
padding: 2rem;
margin-bottom: 2rem;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.content-card:hover {
transform: translateY(-5px);
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}
.content-title {
font-size: 2rem;
color: var(--text-primary);
margin-bottom: 1rem;
}
.content-text {
color: var(--text-secondary);
line-height: 1.7;
margin-bottom: 1.5rem;
}
/* Right Sidebar Styles */
.right-sidebar {
width: 300px;
height: 100vh;
position: fixed;
right: 0;
top: 0;
padding: 2rem;
background: var(--card-bg);
border-left: 1px solid rgba(0, 0, 0, 0.1);
}
.related-topics {
background: rgba(124, 58, 237, 0.05);
padding: 1.25rem;
border-radius: 12px;
margin-bottom: 1.5rem;
}
.related-topics h3 {
color: var(--primary);
margin-bottom: 1rem;
}
.topic-tag {
display: inline-block;
padding: 0.5rem 1rem;
background: white;
border-radius: 20px;
margin: 0.25rem;
font-size: 0.9rem;
color: var(--text-secondary);
border: 1px solid rgba(124, 58, 237, 0.2);
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
cursor: pointer;
}
.topic-tag:hover {
background: var(--primary);
color: white;
transform: translateY(-3px);
box-shadow: 0 4px 12px rgba(124, 58, 237, 0.2);
}
/* Exercise Section Styles */
.exercise-section {
background: linear-gradient(135deg, var(--primary-light), var(--primary));
padding: 1.5rem;
border-radius: 12px;
color: white;
margin-top: 2rem;
position: relative;
overflow: hidden;
}
.exercise-section::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1));
pointer-events: none;
}
.download-btn {
display: inline-flex;
align-items: center;
gap: 0.5rem;
background: rgba(255, 255, 255, 0.1);
color: white;
padding: 0.75rem 1.25rem;
border-radius: 10px;
text-decoration: none;
margin: 0.5rem;
backdrop-filter: blur(5px);
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.download-btn:hover {
background: rgba(255, 255, 255, 0.2);
transform: translateY(-3px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
/* Responsive Design */
@media (max-width: 1200px) {
.right-sidebar {
display: none;
}
.main-content {
margin-right: 0;
}
}
@media (max-width: 768px) {
.sidebar {
transform: translateX(-100%);
}
.sidebar.active {
transform: translateX(0);
}
.main-content {
margin-left: 0;
}
}
/* Active nav link style */
.nav-link.active {
background: rgba(255, 255, 255, 0.15);
color: white;
font-weight: 600;
}
/* List style improvement */
.content-text li {
position: relative;
padding-left: 1.5rem;
margin-bottom: 0.5rem;
}
.content-text li::before {
content: '•';
color: var(--primary);
position: absolute;
left: 0;
font-weight: bold;
}
/* Add this CSS to your existing styles */
document.head.insertAdjacentHTML('beforeend', `
<style>
mark {
background-color: rgba(124, 58, 237, 0.2);
color: inherit;
padding: 0 2px;
border-radius: 2px;
transition: background-color 0.3s ease;
}
mark:hover {
background-color: rgba(124, 58, 237, 0.4);
}
</style>
`);
</style>
</head>
<body>
<!-- Left Sidebar -->
<nav class="sidebar">
<div class="sidebar-header">
<i class="fas fa-graduation-cap"></i>
<h2><?php echo($subjectData->displayName); ?></h2>
</div>
<a href="homepage.php" class="nav-link">
<i class="fas fa-home"></i> Homepage
</a>
<a href="subject.php?subject=<?php echo($subjectData->id); ?>" class="nav-link">
<i class="fas fa-book"></i> <?php echo($subjectData->displayName); ?> Übersicht
</a>
<a href="#" class="nav-link active">
<i class="fas fa-calculator"></i> <?php echo($topicData->displayName); ?>
</a>
</nav>
<!-- Main Content -->
<main class="main-content">
<div class="search-container">
<input type="text" class="search-box" id="searchInput" placeholder="Suche nach Themen, Übungen oder Hilfe..." oninput="handleContentSearch()">
</div>
<div class="content-card">
<h1 class="content-title"><?php echo($topicData->displayName); ?></h1>
<p class="content-text">
<?php echo($topicData->description); ?>
</p>
<p class="content-text">
<?php echo($topicData->article); ?>
</p>
<div class="exercise-section">
<h3 style="margin-bottom: 1rem;">Übungen herunterladen:</h3>
<div style="display: flex; flex-wrap: wrap; gap: 0.5rem;">
<?php
foreach ($topicData->files as $file) {
?>
<a href="#" class="download-btn">
<i class="fas fa-file-pdf"></i>
<?php echo($file); ?>
</a>
<?php
}
?>
</div>
</div>
</div>
</main>
<!-- Right Sidebar -->
<aside class="right-sidebar">
<div class="related-topics">
<h3>Verwandte Themen</h3>
<div style="display: flex; flex-wrap: wrap; gap: 0.5rem;">
<?php
foreach ($topicData->relatedTopics as $relatedTopic) {
?>
<span class="topic-tag"><?php echo($relatedTopic); ?></span>
<?php
}
?>
</div>
</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>