Files
XP-System/views/quests.ejs
T
2021-04-04 21:57:34 -07:00

46 lines
1.8 KiB
Plaintext

<style>
#back {
position: absolute;
left: 10px;
top: 10px;
}
#div-container {
position: absolute;
left: 300px;
top: 50px;
}
</style>
<script>
// Catch url Parameter
window.onload = function () {
const queryString = window.location.search;
if (queryString != null) {
const urlParams = new URLSearchParams(queryString);
const id = urlParams.get('id');
document.getElementById('div-container').innerHTML = "<h2>Uh oh, there was an issue getting the quest id! :(</h2>";
<% if(quests.length == 0) { %>
document.getElementById('div-container').innerHTML = "<h2>Uh oh, theres no quests :(</h2>";
<% } else if(quests.length > 0) { %>
<% quests.forEach(function (quest) { %>
if('<%= quest._id %>' == id) {
document.getElementById('div-container').innerHTML += '<div id="quest">';
document.getElementById('quest').innerHTML += '<h1 class="title"><%= quest.title %></h1>';
document.getElementById('quest').innerHTML += '<h2 class="title">Campaign: <%= quest.campaign %></h2>'
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>
<a id='back' href="/dashboard" class="btn btn-secondary">Back to Dashboard</a>
<!-- Quest container -->
<div id='div-container'></div>