Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ router.get("/", async (req, res) => {
let contests = await Contest.find({}, { rankings: 0 }).sort({
startTime: "desc",
});

res.render("index", {
contests: contests,
title: "Leetcode Rating Predictor",
Expand Down
17 changes: 15 additions & 2 deletions views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<% } else { %>
<td>Virtual</td>
<% } %>
<td><%= contest.startTime %></td>
<td class="startTime"><%= contest.startTime %></td>
<td><%= (contest.endTime - contest.startTime)/60000 %> minutes</td>
</tr>
<% } %>
Expand All @@ -54,9 +54,22 @@
<script src="https://cdn.jsdelivr.net/npm/simple-datatables@latest" type="text/javascript"></script>
<script>

new simpleDatatables.DataTable("#contest-table", {
const dataTable = new simpleDatatables.DataTable("#contest-table", {
searchable: true,
fixedHeight: true,
sortable:false,
});

const contests = document.getElementsByClassName('startTime')
for (let contest of contests) {
let startTime = new Date(contest.textContent)
contest.textContent = startTime.toLocaleString()
}
dataTable.on('datatable.page', function(page) {
const contests = document.getElementsByClassName('startTime')
for (let contest of contests) {
let startTime = new Date(contest.textContent)
contest.textContent = startTime.toLocaleString()
}
})
</script>