Skip to content

Commit

Permalink
feat Site: turn welcome page into splash screen
Browse files Browse the repository at this point in the history
  • Loading branch information
prplwtf committed May 26, 2024
1 parent 7fc0f77 commit b35961e
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 69 deletions.
27 changes: 27 additions & 0 deletions src/components/elements/MissingConfigurationElement.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
function MissingConfigurationElement() {
return `
<div class="row mb-4 pb-3">
<div class="col-6">
<div class="bg-dark-subtle rounded-4 py-2 px-3">
<p class="m-0 text-center">
<code class="text-dark">
Configuration.example.yml
</code>
</p>
</div>
</div>
<div class="col-1" style="margin-top: 5px;">
<i class="bi bi-arrow-right h4 text-danger-emphasis"></i>
</div>
<div class="col-5">
<div class="bg-dark-subtle rounded-4 py-2 px-3">
<p class="m-0 text-center">
<code class="text-danger-emphasis">
Configuration.yml
</code>
</p>
</div>
</div>
</div>
`
}
50 changes: 0 additions & 50 deletions src/components/sections/WelcomeSection.js

This file was deleted.

21 changes: 14 additions & 7 deletions src/configuration/FetchConfiguration.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
let ConfigurationURL = "./configuration/Configuration.yml"

async function FetchConfiguration() {
var xhr = new XMLHttpRequest()
let ConfigurationURL = "./configuration/Configuration.yml"
if(window.location.hostname == "gravity.prpl.wtf") {
ConfigurationURL = "./configuration/Configuration.example.yml"
}
xhr.open("GET", ConfigurationURL, true)
xhr.onreadystatechange = async function () {
if (xhr.readyState == 4 && xhr.status == 200) {
Expand All @@ -13,9 +11,18 @@ async function FetchConfiguration() {
return;
}
if (xhr.readyState == 4 && xhr.status == 404) {
window.Configuration = false
await RenderConfiguration()
return console.error("Configuration.yml could not be found!")
if(ConfigurationURL != "./configuration/Configuration.example.yml") {
ProgressBar(99.99, 5)
App.innerHTML = `${MissingConfigurationElement()}`
setTimeout(() => {
ProgressBar(100)
ConfigurationURL = "./configuration/Configuration.example.yml"
FetchConfiguration()
}, 5000);
} else {
await RenderConfiguration()
return console.error("Configuration.yml could not be found!")
}
}
}
xhr.send()
Expand Down
1 change: 1 addition & 0 deletions src/imports/ImportElements.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ async function ImportElements() {
{ Identifier: "FooterElement", Path: "FooterElement.js" },
{ Identifier: "LinkElement", Path: "LinkElement.js" },
{ Identifier: "ConnectionElement", Path: "ConnectionElement.js" },
{ Identifier: "MissingConfigurationElement", Path: "MissingConfigurationElement.js" },
]

for (let i = Elements.length - 1; i >= 0; i--) {
Expand Down
5 changes: 3 additions & 2 deletions src/router/ProgressBar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var IsAnimating = false

function ProgressBar(length) {
function ProgressBar(length, duration) {
if(IsAnimating) return;

ProgressBarElement.style.opacity = 1
Expand All @@ -19,6 +19,7 @@ function ProgressBar(length) {
return;
}

ProgressBarElement.style.width = length+"%"
ProgressBarElement.style = `width: ${length}%; --TransitionWidthDuration: ${duration || 0.4}s;`

IsAnimating = false
}
10 changes: 0 additions & 10 deletions src/router/Route.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
function Route(view) {
if(!window.Configuration) {view = "#welcome"}
if(window.Configuration && view == "#welcome") {view = "#"}
window.location.hash = view
Unload("Section")
ProgressBar(25)
Expand Down Expand Up @@ -30,14 +28,6 @@ function Route(view) {
})
}

// #welcome
if(view == "#welcome") {
return Import("./src/components/sections/WelcomeSection.js", "Section", function() {
App.innerHTML = `${WelcomeSection()}`
ProgressBar(100)
})
}

ProgressBar(100)
return App.innerHTML = `An unknown error occured, check your browser console for more information.`
}
Expand Down

0 comments on commit b35961e

Please sign in to comment.