No-Quest-ID-catch

This commit is contained in:
SowinskiBraeden committed 2021-04-04 21:57:34 -07:00
1 parent 292f517b89
commit 60d029433d
1 file changed
+21 -16
+21 -16
View File
@@ -15,22 +15,27 @@
// Catch url Parameter // Catch url Parameter
window.onload = function () { window.onload = function () {
const queryString = window.location.search; const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString); if (queryString != null) {
const id = urlParams.get('id'); const urlParams = new URLSearchParams(queryString);
<% if(quests.length == 0) { %> const id = urlParams.get('id');
document.getElementById('div-container').innerHTML = "<h2>Uh oh, theres no quests :(</h2>"; document.getElementById('div-container').innerHTML = "<h2>Uh oh, there was an issue getting the quest id! :(</h2>";
<% } else if(quests.length > 0) { %> <% if(quests.length == 0) { %>
<% quests.forEach(function (quest) { %> document.getElementById('div-container').innerHTML = "<h2>Uh oh, theres no quests :(</h2>";
if('<%= quest._id %>' == id) { <% } else if(quests.length > 0) { %>
document.getElementById('div-container').innerHTML += '<div id="quest">'; <% quests.forEach(function (quest) { %>
document.getElementById('quest').innerHTML += '<h1 class="title"><%= quest.title %></h1>'; if('<%= quest._id %>' == id) {
document.getElementById('quest').innerHTML += '<h2 class="title">Campaign: <%= quest.campaign %></h2>' document.getElementById('div-container').innerHTML += '<div id="quest">';
document.getElementById('quest').innerHTML += '<p class="info">XP: <%= quest.xp %></p>'; document.getElementById('quest').innerHTML += '<h1 class="title"><%= quest.title %></h1>';
document.getElementById('quest').innerHTML += '<p class="info">Expires: <%= quest.expiry %></p>'; document.getElementById('quest').innerHTML += '<h2 class="title">Campaign: <%= quest.campaign %></h2>'
document.getElementById('quest').innerHTML += `<h3 class="info">Instructions: <%= quest.instruction %></h3>`; document.getElementById('quest').innerHTML += '<p class="info">XP: <%= quest.xp %></p>';
} document.getElementById('quest').innerHTML += '<p class="info">Expires: <%= quest.expiry %></p>';
<% }) %> document.getElementById('quest').innerHTML += `<h3 class="info">Instructions: <%= quest.instruction %></h3>`;
<% } %> }
<% }) %>
<% } %>
} else {
document.getElementById('div-container').innerHTML = "<h2>Uh oh, there was an issue getting the quest id :(</h2>";
}
} }
</script> </script>