-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from TheSecretOrganization/reindent
reindent files
- Loading branch information
Showing
8 changed files
with
130 additions
and
129 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
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
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,5 +1,5 @@ | ||
<div class="h-100 d-flex align-items-center justify-content-center"> | ||
<div> | ||
<p>Page not found</p> | ||
</div> | ||
<div> | ||
<p>Page not found</p> | ||
</div> | ||
</div> |
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,11 +1,11 @@ | ||
<div id="gameSelection" class="d-flex justify-content-center"> | ||
<button id="pongBtn" class="btn btn-secondary">Pong</button> | ||
<button id="game2Btn" class="btn btn-secondary">Tic-Tac-Toe</button> | ||
<button id="pongBtn" class="btn btn-secondary">Pong</button> | ||
<button id="game2Btn" class="btn btn-secondary">Tic-Tac-Toe</button> | ||
</div> | ||
<div id="game"> | ||
<button id="backBtn" class="btn btn-dark">Back</button> | ||
<div class="center-content"> | ||
<canvas id="gameCanvas" width="800" height="600"></canvas> | ||
</div> | ||
<button id="backBtn" class="btn btn-dark">Back</button> | ||
<div class="center-content"> | ||
<canvas id="gameCanvas" width="800" height="600"></canvas> | ||
</div> | ||
</div> | ||
<div id="gameAgain" class="center-content"></div> |
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,5 +1,5 @@ | ||
<div class="h-100 d-flex align-items-center justify-content-center"> | ||
<div> | ||
<p>This is Index</p> | ||
</div> | ||
<div> | ||
<p>This is Index</p> | ||
</div> | ||
</div> |
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
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,87 +1,87 @@ | ||
/* General */ | ||
html { | ||
box-sizing: border-box; | ||
font-size: 100%; | ||
height: 100%; | ||
scroll-behavior: smooth; | ||
box-sizing: border-box; | ||
font-size: 100%; | ||
height: 100%; | ||
scroll-behavior: smooth; | ||
} | ||
|
||
*, *::before, *::after { | ||
box-sizing: inherit; | ||
box-sizing: inherit; | ||
} | ||
|
||
body { | ||
min-height: 100%; | ||
line-height: 1.5; | ||
margin: 0; | ||
padding: 0; | ||
font-family: 'Arial', sans-serif; | ||
background-color: #f5f5f5; | ||
color: #333; | ||
min-height: 100%; | ||
line-height: 1.5; | ||
margin: 0; | ||
padding: 0; | ||
font-family: 'Arial', sans-serif; | ||
background-color: #f5f5f5; | ||
color: #333; | ||
} | ||
|
||
.list-group-item { | ||
padding: 10px; | ||
cursor: pointer; | ||
text-align: center; | ||
padding: 10px; | ||
cursor: pointer; | ||
text-align: center; | ||
} | ||
|
||
.list-group-item.active { | ||
background-color: #007bff; | ||
color: white; | ||
background-color: #007bff; | ||
color: white; | ||
} | ||
|
||
/* Page Content */ | ||
#page-container-wrapper { | ||
position: relative; | ||
position: relative; | ||
} | ||
|
||
/* Sidebar Toggle */ | ||
#sidebar-toggle { | ||
position: fixed; | ||
top: 1rem; | ||
left: 1rem; | ||
font-size: 20px; | ||
z-index: 1050; | ||
transition: all 0.3s ease; | ||
position: fixed; | ||
top: 1rem; | ||
left: 1rem; | ||
font-size: 20px; | ||
z-index: 1050; | ||
transition: all 0.3s ease; | ||
} | ||
|
||
#sidebar-toggle.toggled { | ||
margin-left: 250px; | ||
margin-left: 250px; | ||
} | ||
|
||
/* Sidebar */ | ||
#sidebar-wrapper { | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
height: 100vh; | ||
width: 250px; | ||
border-radius: 0 5px 5px 0; | ||
transition: all 0.3s ease; | ||
z-index: 1000; | ||
text-align: center; | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
height: 100vh; | ||
width: 250px; | ||
border-radius: 0 5px 5px 0; | ||
transition: all 0.3s ease; | ||
z-index: 1000; | ||
text-align: center; | ||
} | ||
|
||
#sidebar-wrapper.toggled { | ||
margin-left: -250px; | ||
margin-left: -250px; | ||
} | ||
|
||
#sidebar-wrapper .sidebar-heading { | ||
padding: 1rem; | ||
font-size: 1.5rem; | ||
padding: 1rem; | ||
font-size: 1.5rem; | ||
} | ||
|
||
#sidebar-wrapper .list-group-item { | ||
padding: 1rem 1.5rem; | ||
padding: 1rem 1.5rem; | ||
} | ||
|
||
#game { | ||
display: none; | ||
margin-block: 5px; | ||
display: none; | ||
margin-block: 5px; | ||
} | ||
|
||
#gameCanvas { | ||
background-color: black; | ||
border: 3px solid lightskyblue; | ||
background-color: black; | ||
border: 3px solid lightskyblue; | ||
} |
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,87 +1,88 @@ | ||
|
||
function route(e) { | ||
e.preventDefault(); | ||
window.history.pushState({}, "", e.target.getAttribute('data-route')); | ||
handleLocation(); | ||
e.preventDefault(); | ||
window.history.pushState({}, "", e.target.getAttribute('data-route')); | ||
handleLocation(); | ||
}; | ||
|
||
async function fetchPage(pageName) { | ||
const response = await fetch(`/api/pages/${pageName}/`); | ||
if (!response.ok) { | ||
console.error(`Failed to fetch ${pageName}: ${response.statusText}`); | ||
return null; | ||
} | ||
const data = await response.json(); | ||
if (data.error) { | ||
console.error(`Failed to fetch ${pageName}: ${data.error}`); | ||
return null; | ||
} | ||
return data.html; | ||
const response = await fetch(`/api/pages/${pageName}/`); | ||
if (!response.ok) { | ||
console.error(`Failed to fetch ${pageName}: ${response.statusText}`); | ||
return null; | ||
} | ||
const data = await response.json(); | ||
if (data.error) { | ||
console.error(`Failed to fetch ${pageName}: ${data.error}`); | ||
return null; | ||
} | ||
return data.html; | ||
}; | ||
|
||
function loadScripts() { | ||
const container = document.getElementById("page-container"); | ||
const scripts = container.querySelectorAll('script'); | ||
const container = document.getElementById("page-container"); | ||
const scripts = container.querySelectorAll('script'); | ||
|
||
scripts.forEach(script => { | ||
const newScript = document.createElement('script'); | ||
if (script.src) { | ||
newScript.src = script.src; | ||
} else { | ||
newScript.textContent = script.textContent; | ||
} | ||
document.body.appendChild(newScript); | ||
document.body.removeChild(newScript); | ||
}); | ||
scripts.forEach(script => { | ||
const newScript = document.createElement('script'); | ||
if (script.src) { | ||
newScript.src = script.src; | ||
} else { | ||
newScript.textContent = script.textContent; | ||
} | ||
document.body.appendChild(newScript); | ||
document.body.removeChild(newScript); | ||
}); | ||
}; | ||
|
||
function updateTitle(pageName) { | ||
const titles = { | ||
"index": "Home", | ||
"games": "Games", | ||
"404": "Page Not Found" | ||
}; | ||
const title = titles[pageName] || "Page Not Found"; | ||
document.title = title; | ||
const titles = { | ||
"index": "Home", | ||
"games": "Games", | ||
"404": "Page Not Found" | ||
}; | ||
const title = titles[pageName] || "Page Not Found"; | ||
document.title = title; | ||
}; | ||
|
||
function updateActiveRoute(path) { | ||
document.querySelectorAll('#sidebar-list .list-group-item').forEach(item => { | ||
item.classList.remove('active'); | ||
}); | ||
const activeRoute = document.querySelector(`[data-route="${path}"]`); | ||
if (activeRoute) { | ||
activeRoute.classList.add('active'); | ||
} | ||
document.querySelectorAll('#sidebar-list .list-group-item').forEach(item => { | ||
item.classList.remove('active'); | ||
}); | ||
const activeRoute = document.querySelector(`[data-route="${path}"]`); | ||
if (activeRoute) { | ||
activeRoute.classList.add('active'); | ||
} | ||
} | ||
|
||
async function handleLocation() { | ||
let path = window.location.pathname; | ||
let pageName = path === '/' ? 'index' : path.substring(1); | ||
let html = await fetchPage(pageName); | ||
if (html === null) { | ||
html = await fetchPage('404'); | ||
} | ||
let path = window.location.pathname; | ||
let pageName = path === '/' ? 'index' : path.substring(1); | ||
let html = await fetchPage(pageName); | ||
if (html === null) { | ||
html = await fetchPage('404'); | ||
} | ||
|
||
document.getElementById("page-container").innerHTML = html; | ||
loadScripts(); | ||
updateTitle(pageName); | ||
updateActiveRoute(path); | ||
document.getElementById("page-container").innerHTML = html; | ||
loadScripts(); | ||
updateTitle(pageName); | ||
updateActiveRoute(path); | ||
}; | ||
|
||
document.addEventListener("DOMContentLoaded", () => { | ||
window.onpopstate = handleLocation; | ||
window.route = route; | ||
handleLocation(); | ||
window.onpopstate = handleLocation; | ||
window.route = route; | ||
handleLocation(); | ||
}); | ||
|
||
document.addEventListener("click", (e) => { | ||
if (e?.target?.hasAttribute('data-route')) { | ||
route(e); | ||
} | ||
if (e?.target?.hasAttribute('data-route')) { | ||
route(e); | ||
} | ||
}); | ||
|
||
document.getElementById("sidebar-toggle").addEventListener("click", function (e) { | ||
e.preventDefault(); | ||
document.getElementById("sidebar-wrapper").classList.toggle("toggled"); | ||
this.classList.toggle("toggled"); | ||
e.preventDefault(); | ||
document.getElementById("sidebar-wrapper").classList.toggle("toggled"); | ||
this.classList.toggle("toggled"); | ||
}); |