Spaces:
Running
Running
Promote version d6bab03 to main
Browse filesPromoted commit d6bab03d251e0f239d685f11a8e433f4524c0196 to main branch
- admin.html +2 -2
- components/slide-menu.js +33 -185
- dining.html +1 -1
- index.html +62 -114
admin.html
CHANGED
|
@@ -44,8 +44,8 @@
|
|
| 44 |
</button>
|
| 45 |
</div>
|
| 46 |
<script>
|
| 47 |
-
function
|
| 48 |
-
document.getElementById('login-btn')?.addEventListener('click', () => {
|
| 49 |
const username = document.getElementById('username').value;
|
| 50 |
const password = document.getElementById('password').value;
|
| 51 |
|
|
|
|
| 44 |
</button>
|
| 45 |
</div>
|
| 46 |
<script>
|
| 47 |
+
function initPage() {
|
| 48 |
+
document.getElementById('login-btn')?.addEventListener('click', () => {
|
| 49 |
const username = document.getElementById('username').value;
|
| 50 |
const password = document.getElementById('password').value;
|
| 51 |
|
components/slide-menu.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
|
| 2 |
class SlideMenu extends HTMLElement {
|
| 3 |
constructor() {
|
| 4 |
super();
|
|
@@ -19,235 +18,84 @@ class SlideMenu extends HTMLElement {
|
|
| 19 |
box-sizing: border-box;
|
| 20 |
display: flex;
|
| 21 |
flex-direction: column;
|
| 22 |
-
overflow-y: auto;
|
| 23 |
}
|
| 24 |
:host(.open) {
|
| 25 |
right: 0;
|
| 26 |
}
|
| 27 |
.close-btn {
|
| 28 |
-
position:
|
| 29 |
-
top:
|
| 30 |
-
|
| 31 |
-
background:
|
| 32 |
-
color: white;
|
| 33 |
border: none;
|
| 34 |
-
|
| 35 |
-
height: 30px;
|
| 36 |
-
border-radius: 50%;
|
| 37 |
-
font-size: 16px;
|
| 38 |
cursor: pointer;
|
| 39 |
-
margin-bottom: 10px;
|
| 40 |
-
z-index: 1;
|
| 41 |
}
|
| 42 |
.menu-title {
|
| 43 |
margin-top: 0;
|
| 44 |
color: #3b82f6;
|
| 45 |
padding-bottom: 10px;
|
| 46 |
border-bottom: 1px solid #eee;
|
| 47 |
-
font-size: 1.25rem;
|
| 48 |
-
}
|
| 49 |
-
.menu-section {
|
| 50 |
-
margin-bottom: 15px;
|
| 51 |
-
}
|
| 52 |
-
.section-title {
|
| 53 |
-
color: #64748b;
|
| 54 |
-
font-size: 0.875rem;
|
| 55 |
-
font-weight: 600;
|
| 56 |
-
margin: 15px 0 8px 0;
|
| 57 |
-
padding-left: 8px;
|
| 58 |
}
|
| 59 |
.menu-item {
|
| 60 |
-
padding: 12px
|
| 61 |
-
margin:
|
| 62 |
-
background: #
|
| 63 |
border-radius: 8px;
|
| 64 |
cursor: pointer;
|
| 65 |
display: flex;
|
| 66 |
align-items: center;
|
| 67 |
-
transition:
|
| 68 |
-
font-size: 0.9375rem;
|
| 69 |
}
|
| 70 |
.menu-item:hover {
|
| 71 |
-
background: #
|
| 72 |
-
transform: translateX(3px);
|
| 73 |
-
}
|
| 74 |
-
.menu-item.active {
|
| 75 |
-
background: #3b82f6;
|
| 76 |
-
color: white;
|
| 77 |
-
}
|
| 78 |
-
.menu-item.active i {
|
| 79 |
-
color: white;
|
| 80 |
}
|
| 81 |
.menu-item i {
|
| 82 |
-
margin-right:
|
| 83 |
color: #3b82f6;
|
| 84 |
-
width: 20px;
|
| 85 |
-
text-align: center;
|
| 86 |
-
}
|
| 87 |
-
.divider {
|
| 88 |
-
height: 1px;
|
| 89 |
-
background: #e2e8f0;
|
| 90 |
-
margin: 15px 0;
|
| 91 |
-
}
|
| 92 |
-
.user-profile {
|
| 93 |
-
display: flex;
|
| 94 |
-
align-items: center;
|
| 95 |
-
padding: 12px;
|
| 96 |
-
background: #f1f5f9;
|
| 97 |
-
border-radius: 8px;
|
| 98 |
-
margin-bottom: 15px;
|
| 99 |
-
}
|
| 100 |
-
.user-avatar {
|
| 101 |
-
width: 40px;
|
| 102 |
-
height: 40px;
|
| 103 |
-
border-radius: 50%;
|
| 104 |
-
background: #3b82f6;
|
| 105 |
-
color: white;
|
| 106 |
-
display: flex;
|
| 107 |
-
align-items: center;
|
| 108 |
-
justify-content: center;
|
| 109 |
-
margin-right: 12px;
|
| 110 |
-
font-weight: bold;
|
| 111 |
-
}
|
| 112 |
-
.user-info {
|
| 113 |
-
flex: 1;
|
| 114 |
-
}
|
| 115 |
-
.user-name {
|
| 116 |
-
font-weight: 600;
|
| 117 |
-
margin-bottom: 2px;
|
| 118 |
-
}
|
| 119 |
-
.user-role {
|
| 120 |
-
font-size: 0.75rem;
|
| 121 |
-
color: #64748b;
|
| 122 |
}
|
| 123 |
</style>
|
| 124 |
<div>
|
| 125 |
<button class="close-btn">×</button>
|
|
|
|
| 126 |
|
| 127 |
-
<
|
| 128 |
-
|
| 129 |
-
<
|
| 130 |
-
<div class="user-info">
|
| 131 |
-
<div class="user-name">User</div>
|
| 132 |
-
<div class="user-role">Student</div>
|
| 133 |
-
</div>
|
| 134 |
-
</div>
|
| 135 |
-
<h2 class="menu-title">Main Navigation</h2>
|
| 136 |
-
|
| 137 |
-
<div class="menu-section">
|
| 138 |
-
<div class="menu-item active" id="home-option">
|
| 139 |
-
<i class="fas fa-home"></i>
|
| 140 |
-
<span>Home</span>
|
| 141 |
-
</div>
|
| 142 |
-
<div class="menu-item" id="attendance-option">
|
| 143 |
-
<i class="fas fa-clipboard-check"></i>
|
| 144 |
-
<span>Attendance</span>
|
| 145 |
-
</div>
|
| 146 |
-
<div class="menu-item" id="dining-option">
|
| 147 |
-
<i class="fas fa-utensils"></i>
|
| 148 |
-
<span>Dining Hall</span>
|
| 149 |
-
</div>
|
| 150 |
</div>
|
| 151 |
-
<div class="divider"></div>
|
| 152 |
|
| 153 |
-
<div class="menu-
|
| 154 |
-
<
|
| 155 |
-
<
|
| 156 |
-
<i class="fas fa-sun"></i>
|
| 157 |
-
<span>Breakfast</span>
|
| 158 |
-
</div>
|
| 159 |
-
<div class="menu-item" id="lunch-option">
|
| 160 |
-
<i class="fas fa-utensils"></i>
|
| 161 |
-
<span>Lunch</span>
|
| 162 |
-
</div>
|
| 163 |
-
<div class="menu-item" id="dinner-option">
|
| 164 |
-
<i class="fas fa-moon"></i>
|
| 165 |
-
<span>Dinner</span>
|
| 166 |
-
</div>
|
| 167 |
-
<div class="menu-item" id="supper-option">
|
| 168 |
-
<i class="fas fa-bed"></i>
|
| 169 |
-
<span>Supper</span>
|
| 170 |
-
</div>
|
| 171 |
</div>
|
| 172 |
|
| 173 |
-
<div class="
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
<div class="section-title">Admin</div>
|
| 177 |
-
<div class="menu-item" id="admin-option">
|
| 178 |
-
<i class="fas fa-user-shield"></i>
|
| 179 |
-
<span>Admin Panel</span>
|
| 180 |
-
</div>
|
| 181 |
-
<div class="menu-item" id="stats-option">
|
| 182 |
-
<i class="fas fa-chart-bar"></i>
|
| 183 |
-
<span>Statistics</span>
|
| 184 |
-
</div>
|
| 185 |
-
<div class="menu-item" id="settings-option">
|
| 186 |
-
<i class="fas fa-cog"></i>
|
| 187 |
-
<span>Settings</span>
|
| 188 |
-
</div>
|
| 189 |
</div>
|
| 190 |
</div>
|
| 191 |
`;
|
| 192 |
}
|
| 193 |
-
|
| 194 |
connectedCallback() {
|
| 195 |
-
|
| 196 |
-
closeBtn.addEventListener('click', () => {
|
| 197 |
this.classList.remove('open');
|
| 198 |
});
|
| 199 |
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
{ id: 'attendance-option', view: 'attendance' },
|
| 204 |
-
{ id: 'dining-option', view: 'dining' },
|
| 205 |
-
{ id: 'admin-option', view: 'admin' },
|
| 206 |
-
{ id: 'stats-option', view: 'stats' },
|
| 207 |
-
{ id: 'settings-option', view: 'settings' }
|
| 208 |
-
];
|
| 209 |
-
|
| 210 |
-
navItems.forEach(item => {
|
| 211 |
-
const element = this.shadowRoot.getElementById(item.id);
|
| 212 |
-
if (element) {
|
| 213 |
-
element.addEventListener('click', () => {
|
| 214 |
-
if (window.navigateTo) {
|
| 215 |
-
window.navigateTo(item.view);
|
| 216 |
-
}
|
| 217 |
-
this.classList.remove('open');
|
| 218 |
-
});
|
| 219 |
-
}
|
| 220 |
});
|
| 221 |
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
{ id: 'lunch-option', meal: 'lunch' },
|
| 226 |
-
{ id: 'dinner-option', meal: 'dinner' },
|
| 227 |
-
{ id: 'supper-option', meal: 'supper' }
|
| 228 |
-
];
|
| 229 |
-
|
| 230 |
-
mealItems.forEach(item => {
|
| 231 |
-
const element = this.shadowRoot.getElementById(item.id);
|
| 232 |
-
if (element) {
|
| 233 |
-
element.addEventListener('click', () => {
|
| 234 |
-
if (window.showMealMenu) {
|
| 235 |
-
window.showMealMenu(item.meal);
|
| 236 |
-
}
|
| 237 |
-
this.classList.remove('open');
|
| 238 |
-
});
|
| 239 |
-
}
|
| 240 |
});
|
| 241 |
-
}
|
| 242 |
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
const activeItem = this.shadowRoot.getElementById(`${view}-option`);
|
| 248 |
-
if (activeItem) {
|
| 249 |
-
activeItem.classList.add('active');
|
| 250 |
-
}
|
| 251 |
}
|
| 252 |
}
|
|
|
|
| 253 |
customElements.define('slide-menu', SlideMenu);
|
|
|
|
|
|
|
| 1 |
class SlideMenu extends HTMLElement {
|
| 2 |
constructor() {
|
| 3 |
super();
|
|
|
|
| 18 |
box-sizing: border-box;
|
| 19 |
display: flex;
|
| 20 |
flex-direction: column;
|
|
|
|
| 21 |
}
|
| 22 |
:host(.open) {
|
| 23 |
right: 0;
|
| 24 |
}
|
| 25 |
.close-btn {
|
| 26 |
+
position: absolute;
|
| 27 |
+
top: 10px;
|
| 28 |
+
right: 10px;
|
| 29 |
+
background: none;
|
|
|
|
| 30 |
border: none;
|
| 31 |
+
font-size: 20px;
|
|
|
|
|
|
|
|
|
|
| 32 |
cursor: pointer;
|
|
|
|
|
|
|
| 33 |
}
|
| 34 |
.menu-title {
|
| 35 |
margin-top: 0;
|
| 36 |
color: #3b82f6;
|
| 37 |
padding-bottom: 10px;
|
| 38 |
border-bottom: 1px solid #eee;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
}
|
| 40 |
.menu-item {
|
| 41 |
+
padding: 12px;
|
| 42 |
+
margin: 8px 0;
|
| 43 |
+
background: #f5f5f5;
|
| 44 |
border-radius: 8px;
|
| 45 |
cursor: pointer;
|
| 46 |
display: flex;
|
| 47 |
align-items: center;
|
| 48 |
+
transition: background 0.2s;
|
|
|
|
| 49 |
}
|
| 50 |
.menu-item:hover {
|
| 51 |
+
background: #e5e5e5;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
}
|
| 53 |
.menu-item i {
|
| 54 |
+
margin-right: 10px;
|
| 55 |
color: #3b82f6;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
}
|
| 57 |
</style>
|
| 58 |
<div>
|
| 59 |
<button class="close-btn">×</button>
|
| 60 |
+
<h2 class="menu-title">Menu Options</h2>
|
| 61 |
|
| 62 |
+
<div class="menu-item" id="admin-option">
|
| 63 |
+
<i class="fas fa-user-shield"></i>
|
| 64 |
+
<span>Admin Login</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
</div>
|
|
|
|
| 66 |
|
| 67 |
+
<div class="menu-item" id="attendance-option">
|
| 68 |
+
<i class="fas fa-clipboard-list"></i>
|
| 69 |
+
<span>Attendance Form</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
</div>
|
| 71 |
|
| 72 |
+
<div class="menu-item" id="dining-option">
|
| 73 |
+
<i class="fas fa-utensils"></i>
|
| 74 |
+
<span>Dining Hall Check-in</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
</div>
|
| 76 |
</div>
|
| 77 |
`;
|
| 78 |
}
|
|
|
|
| 79 |
connectedCallback() {
|
| 80 |
+
this.shadowRoot.querySelector('.close-btn').addEventListener('click', () => {
|
|
|
|
| 81 |
this.classList.remove('open');
|
| 82 |
});
|
| 83 |
|
| 84 |
+
this.shadowRoot.querySelector('#admin-option').addEventListener('click', () => {
|
| 85 |
+
navigateTo('admin');
|
| 86 |
+
this.classList.remove('open');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
});
|
| 88 |
|
| 89 |
+
this.shadowRoot.querySelector('#attendance-option').addEventListener('click', () => {
|
| 90 |
+
navigateTo('index');
|
| 91 |
+
this.classList.remove('open');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
});
|
|
|
|
| 93 |
|
| 94 |
+
this.shadowRoot.querySelector('#dining-option').addEventListener('click', () => {
|
| 95 |
+
navigateTo('dining');
|
| 96 |
+
this.classList.remove('open');
|
| 97 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
}
|
| 99 |
}
|
| 100 |
+
|
| 101 |
customElements.define('slide-menu', SlideMenu);
|
dining.html
CHANGED
|
@@ -109,7 +109,7 @@
|
|
| 109 |
<p>© 2023 Dining Hall Check-in System. All rights reserved.</p>
|
| 110 |
</footer>
|
| 111 |
<script>
|
| 112 |
-
function
|
| 113 |
// Student data organized by class and form
|
| 114 |
const students = {
|
| 115 |
// Form 1
|
|
|
|
| 109 |
<p>© 2023 Dining Hall Check-in System. All rights reserved.</p>
|
| 110 |
</footer>
|
| 111 |
<script>
|
| 112 |
+
function initPage() {
|
| 113 |
// Student data organized by class and form
|
| 114 |
const students = {
|
| 115 |
// Form 1
|
index.html
CHANGED
|
@@ -690,126 +690,74 @@ function updateDateTime() {
|
|
| 690 |
});
|
| 691 |
</script>
|
| 692 |
<script src="components/slide-menu.js"></script>
|
|
|
|
| 693 |
<script>
|
| 694 |
-
//
|
| 695 |
-
const
|
| 696 |
-
|
| 697 |
-
|
| 698 |
-
|
| 699 |
-
|
| 700 |
-
|
| 701 |
-
|
| 702 |
-
|
| 703 |
-
|
| 704 |
-
|
| 705 |
-
|
| 706 |
-
|
| 707 |
-
|
| 708 |
-
|
| 709 |
-
|
| 710 |
-
|
| 711 |
-
|
| 712 |
-
|
| 713 |
-
|
| 714 |
-
menuBtn.style.borderRadius = '50%';
|
| 715 |
-
menuBtn.style.width = '50px';
|
| 716 |
-
menuBtn.style.height = '50px';
|
| 717 |
-
menuBtn.style.fontSize = '20px';
|
| 718 |
-
menuBtn.style.cursor = 'pointer';
|
| 719 |
-
menuBtn.style.boxShadow = '0 2px 10px rgba(0,0,0,0.2)';
|
| 720 |
-
|
| 721 |
-
menuBtn.addEventListener('click', () => {
|
| 722 |
-
document.querySelector('slide-menu').classList.add('open');
|
| 723 |
-
});
|
| 724 |
|
| 725 |
-
|
| 726 |
-
|
| 727 |
-
// Add view container
|
| 728 |
-
const viewContainer = document.createElement('div');
|
| 729 |
-
viewContainer.id = 'view-container';
|
| 730 |
-
document.body.insertBefore(viewContainer, document.querySelector('footer'));
|
| 731 |
-
|
| 732 |
-
// Store original content
|
| 733 |
-
this.views.attendance = document.querySelector('.container').outerHTML;
|
| 734 |
-
|
| 735 |
-
// Load admin and dining views
|
| 736 |
-
this.loadView('admin');
|
| 737 |
-
this.loadView('dining');
|
| 738 |
-
},
|
| 739 |
-
|
| 740 |
-
loadView: function(view) {
|
| 741 |
-
if (this.views[view]) return;
|
| 742 |
-
|
| 743 |
-
fetch(`/${view}.html`)
|
| 744 |
-
.then(response => response.text())
|
| 745 |
-
.then(html => {
|
| 746 |
-
const parser = new DOMParser();
|
| 747 |
-
const doc = parser.parseFromString(html, 'text/html');
|
| 748 |
-
const content = doc.querySelector('.container').outerHTML;
|
| 749 |
-
this.views[view] = content;
|
| 750 |
-
})
|
| 751 |
-
.catch(err => console.error('Error loading view:', err));
|
| 752 |
-
},
|
| 753 |
-
|
| 754 |
-
switchView: function(view) {
|
| 755 |
-
if (this.currentView === view) return;
|
| 756 |
-
|
| 757 |
-
// Hide current view
|
| 758 |
-
document.querySelector('.container').style.display = 'none';
|
| 759 |
-
|
| 760 |
-
// Show new view
|
| 761 |
-
if (!this.views[view]) {
|
| 762 |
-
console.error('View not loaded:', view);
|
| 763 |
-
return;
|
| 764 |
-
}
|
| 765 |
-
|
| 766 |
-
// Create container if it doesn't exist
|
| 767 |
-
if (!document.querySelector(`.container-${view}`)) {
|
| 768 |
-
const container = document.createElement('div');
|
| 769 |
-
container.className = `container container-${view}`;
|
| 770 |
-
container.style.display = 'block';
|
| 771 |
-
container.innerHTML = this.views[view];
|
| 772 |
-
document.getElementById('view-container').appendChild(container);
|
| 773 |
-
} else {
|
| 774 |
-
document.querySelector(`.container-${view}`).style.display = 'block';
|
| 775 |
-
}
|
| 776 |
-
|
| 777 |
-
this.currentView = view;
|
| 778 |
-
|
| 779 |
-
// Update URL without reload
|
| 780 |
-
history.pushState({ view }, '', `?view=${view}`);
|
| 781 |
-
|
| 782 |
-
// Initialize view if needed
|
| 783 |
-
if (typeof window[`init${view.charAt(0).toUpperCase() + view.slice(1)}`] === 'function') {
|
| 784 |
-
window[`init${view.charAt(0).toUpperCase() + view.slice(1)}`]();
|
| 785 |
-
}
|
| 786 |
-
},
|
| 787 |
-
|
| 788 |
-
handlePopState: function(event) {
|
| 789 |
-
const view = event.state?.view || 'attendance';
|
| 790 |
-
this.switchView(view);
|
| 791 |
-
}
|
| 792 |
-
};
|
| 793 |
|
| 794 |
-
//
|
| 795 |
-
document.
|
| 796 |
-
|
| 797 |
-
|
| 798 |
-
|
| 799 |
-
|
| 800 |
-
|
| 801 |
-
|
| 802 |
-
|
| 803 |
-
|
| 804 |
-
|
| 805 |
-
|
| 806 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 807 |
});
|
| 808 |
|
| 809 |
-
//
|
| 810 |
-
window.navigateTo = function(
|
| 811 |
-
|
|
|
|
| 812 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 813 |
</script>
|
| 814 |
<script>
|
| 815 |
// Add menu toggle button
|
|
|
|
| 690 |
});
|
| 691 |
</script>
|
| 692 |
<script src="components/slide-menu.js"></script>
|
| 693 |
+
<slide-menu></slide-menu>
|
| 694 |
<script>
|
| 695 |
+
// Add menu toggle button
|
| 696 |
+
const menuBtn = document.createElement('button');
|
| 697 |
+
menuBtn.innerHTML = '<i class="fas fa-bars"></i>';
|
| 698 |
+
menuBtn.style.position = 'fixed';
|
| 699 |
+
menuBtn.style.right = '20px';
|
| 700 |
+
menuBtn.style.top = '20px';
|
| 701 |
+
menuBtn.style.zIndex = '999';
|
| 702 |
+
menuBtn.style.background = '#3b82f6';
|
| 703 |
+
menuBtn.style.color = 'white';
|
| 704 |
+
menuBtn.style.border = 'none';
|
| 705 |
+
menuBtn.style.borderRadius = '50%';
|
| 706 |
+
menuBtn.style.width = '50px';
|
| 707 |
+
menuBtn.style.height = '50px';
|
| 708 |
+
menuBtn.style.fontSize = '20px';
|
| 709 |
+
menuBtn.style.cursor = 'pointer';
|
| 710 |
+
menuBtn.style.boxShadow = '0 2px 10px rgba(0,0,0,0.2)';
|
| 711 |
+
|
| 712 |
+
menuBtn.addEventListener('click', () => {
|
| 713 |
+
document.querySelector('slide-menu').classList.add('open');
|
| 714 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 715 |
|
| 716 |
+
document.body.appendChild(menuBtn);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 717 |
|
| 718 |
+
// Main content container
|
| 719 |
+
const mainContent = document.createElement('div');
|
| 720 |
+
mainContent.id = 'main-content';
|
| 721 |
+
document.querySelector('.container').appendChild(mainContent);
|
| 722 |
+
|
| 723 |
+
// Function to load content dynamically
|
| 724 |
+
function loadContent(page) {
|
| 725 |
+
fetch(`${page}.html`)
|
| 726 |
+
.then(response => response.text())
|
| 727 |
+
.then(html => {
|
| 728 |
+
const parser = new DOMParser();
|
| 729 |
+
const doc = parser.parseFromString(html, 'text/html');
|
| 730 |
+
const content = doc.querySelector('.container').innerHTML;
|
| 731 |
+
document.getElementById('main-content').innerHTML = content;
|
| 732 |
+
document.title = doc.title;
|
| 733 |
+
|
| 734 |
+
// Reinitialize any necessary scripts
|
| 735 |
+
if (typeof initPage === 'function') {
|
| 736 |
+
initPage();
|
| 737 |
+
}
|
| 738 |
+
})
|
| 739 |
+
.catch(err => console.error('Error loading page:', err));
|
| 740 |
+
}
|
| 741 |
+
|
| 742 |
+
// Initial page load
|
| 743 |
+
window.addEventListener('DOMContentLoaded', () => {
|
| 744 |
+
const path = window.location.pathname.split('/').pop() || 'index.html';
|
| 745 |
+
const page = path.replace('.html', '');
|
| 746 |
+
loadContent(page);
|
| 747 |
});
|
| 748 |
|
| 749 |
+
// Handle navigation
|
| 750 |
+
window.navigateTo = function(page) {
|
| 751 |
+
history.pushState({}, '', `${page}.html`);
|
| 752 |
+
loadContent(page);
|
| 753 |
};
|
| 754 |
+
|
| 755 |
+
// Handle back/forward navigation
|
| 756 |
+
window.addEventListener('popstate', () => {
|
| 757 |
+
const path = window.location.pathname.split('/').pop() || 'index.html';
|
| 758 |
+
const page = path.replace('.html', '');
|
| 759 |
+
loadContent(page);
|
| 760 |
+
});
|
| 761 |
</script>
|
| 762 |
<script>
|
| 763 |
// Add menu toggle button
|