diff --git a/client/404.html b/client/404.html index a0f0b4f33..ce87eaa57 100644 --- a/client/404.html +++ b/client/404.html @@ -38,7 +38,7 @@ diff --git a/client/about/index.html b/client/about/index.html index 81420b909..664095709 100644 --- a/client/about/index.html +++ b/client/about/index.html @@ -38,7 +38,7 @@ diff --git a/client/about/privacy-policy.html b/client/about/privacy-policy.html index 1163914cc..f00058a0b 100644 --- a/client/about/privacy-policy.html +++ b/client/about/privacy-policy.html @@ -38,7 +38,7 @@ diff --git a/client/about/terms-of-service.html b/client/about/terms-of-service.html index 33de7185f..5acbc0546 100644 --- a/client/about/terms-of-service.html +++ b/client/about/terms-of-service.html @@ -38,7 +38,7 @@ diff --git a/client/admin/category-reports/index.html b/client/admin/category-reports/index.html index 828067a3e..0c09bcd84 100644 --- a/client/admin/category-reports/index.html +++ b/client/admin/category-reports/index.html @@ -37,7 +37,7 @@ diff --git a/client/admin/geoword/category-stats.html b/client/admin/geoword/category-stats.html index bd46df557..78e1f583e 100644 --- a/client/admin/geoword/category-stats.html +++ b/client/admin/geoword/category-stats.html @@ -37,7 +37,7 @@ diff --git a/client/admin/geoword/compare.html b/client/admin/geoword/compare.html index 87485dca2..b66ca01ad 100644 --- a/client/admin/geoword/compare.html +++ b/client/admin/geoword/compare.html @@ -38,7 +38,7 @@ diff --git a/client/admin/geoword/index.html b/client/admin/geoword/index.html index a7e013433..bf25eb4aa 100644 --- a/client/admin/geoword/index.html +++ b/client/admin/geoword/index.html @@ -37,7 +37,7 @@ diff --git a/client/admin/geoword/leaderboard.html b/client/admin/geoword/leaderboard.html index 43944a45d..52afc6262 100644 --- a/client/admin/geoword/leaderboard.html +++ b/client/admin/geoword/leaderboard.html @@ -37,7 +37,7 @@ diff --git a/client/admin/geoword/manage-payments.html b/client/admin/geoword/manage-payments.html index 1304ee60f..b0aaa23c0 100644 --- a/client/admin/geoword/manage-payments.html +++ b/client/admin/geoword/manage-payments.html @@ -37,7 +37,7 @@ diff --git a/client/admin/geoword/protests.html b/client/admin/geoword/protests.html index d101041d6..0bfc48a8c 100644 --- a/client/admin/geoword/protests.html +++ b/client/admin/geoword/protests.html @@ -37,7 +37,7 @@ diff --git a/client/admin/geoword/stats.html b/client/admin/geoword/stats.html index b47d37764..a8999b397 100644 --- a/client/admin/geoword/stats.html +++ b/client/admin/geoword/stats.html @@ -37,7 +37,7 @@ diff --git a/client/admin/index.html b/client/admin/index.html index c66be2b95..c9e3c9c96 100644 --- a/client/admin/index.html +++ b/client/admin/index.html @@ -38,7 +38,7 @@ diff --git a/client/admin/leaderboard/index.html b/client/admin/leaderboard/index.html index 373aae535..fdbbde990 100644 --- a/client/admin/leaderboard/index.html +++ b/client/admin/leaderboard/index.html @@ -38,7 +38,7 @@ diff --git a/client/admin/question-management/packet.html b/client/admin/question-management/packet.html index 862547a98..7fed86638 100644 --- a/client/admin/question-management/packet.html +++ b/client/admin/question-management/packet.html @@ -38,7 +38,7 @@ diff --git a/client/admin/question-management/set.html b/client/admin/question-management/set.html index 27062cfb2..ec6b366aa 100644 --- a/client/admin/question-management/set.html +++ b/client/admin/question-management/set.html @@ -38,7 +38,7 @@ diff --git a/client/db/backups.html b/client/db/backups.html index c42713676..4e5ddae34 100644 --- a/client/db/backups.html +++ b/client/db/backups.html @@ -39,7 +39,7 @@ diff --git a/client/db/bonus-to-html.js b/client/db/bonus-to-html.js new file mode 100644 index 000000000..f0d4f4de3 --- /dev/null +++ b/client/db/bonus-to-html.js @@ -0,0 +1,23 @@ +import getBonusPartLabel from '../scripts/utilities/get-bonus-part-label.js'; + +export default function bonusToHTML (bonus) { + const div = document.createElement('div'); + const span1 = document.createElement('span'); + span1.innerHTML = `${bonus.number}. ${bonus.leadin}`; + div.appendChild(span1); + div.appendChild(document.createElement('br')); + + for (let i = 0; i < bonus.parts.length; i++) { + const span1 = document.createElement('span'); + span1.innerHTML = `${getBonusPartLabel(bonus, i)} ${bonus.parts[i]}`; + div.appendChild(span1); + div.appendChild(document.createElement('br')); + const span2 = document.createElement('span'); + span2.innerHTML = `ANSWER: ${bonus.answers[i]}`; + div.appendChild(span2); + div.appendChild(document.createElement('br')); + } + + div.appendChild(document.createTextNode(`<${bonus.category} / ${bonus.subcategory}${bonus.alternate_subcategory ? ' / ' + bonus.alternate_subcategory : ''}>`)); + return div; +} diff --git a/client/db/explorer/bonus.html b/client/db/bonus/index.html similarity index 97% rename from client/db/explorer/bonus.html rename to client/db/bonus/index.html index 38f9fb5e0..280f40be4 100644 --- a/client/db/explorer/bonus.html +++ b/client/db/bonus/index.html @@ -39,7 +39,7 @@ @@ -98,7 +98,7 @@
Set:
- Back to all sets + Back to all sets
@@ -122,9 +122,7 @@ - - - + diff --git a/client/db/explorer/bonus.js b/client/db/bonus/index.js similarity index 88% rename from client/db/explorer/bonus.js rename to client/db/bonus/index.js index f97df2096..bf986a333 100644 --- a/client/db/explorer/bonus.js +++ b/client/db/bonus/index.js @@ -1,15 +1,16 @@ -import { bonusToHTML, mongoIdToDate } from './utilities.js'; +import bonusToHTML from '../bonus-to-html.js'; +import mongoIdToDate from '../mongo-id-to-date.js'; const bonusId = new URLSearchParams(window.location.search).get('_id'); const { bonus } = await fetch('/api/bonus?' + new URLSearchParams({ _id: bonusId })).then(res => res.json()); document.getElementById('spinner').classList.add('d-none'); -document.getElementById('packet-link').href = `./packet?_id=${bonus.packet._id}`; +document.getElementById('packet-link').href = `../packet/?_id=${bonus.packet._id}`; document.getElementById('packet-number').textContent = bonus.packet.number; document.getElementById('packet-name').textContent = bonus.packet.name; -document.getElementById('set-name').href = `./set?_id=${bonus.set._id}`; +document.getElementById('set-name').href = `../set/?_id=${bonus.set._id}`; document.getElementById('set-name').textContent = bonus.set.name; document.getElementById('bonus').appendChild(bonusToHTML(bonus)); diff --git a/client/db/explorer/utilities.js b/client/db/explorer/utilities.js deleted file mode 100644 index 26bd6724d..000000000 --- a/client/db/explorer/utilities.js +++ /dev/null @@ -1,42 +0,0 @@ -import getBonusPartLabel from '../../scripts/utilities/get-bonus-part-label.js'; - -export function bonusToHTML (bonus) { - const div = document.createElement('div'); - const span1 = document.createElement('span'); - span1.innerHTML = `${bonus.number}. ${bonus.leadin}`; - div.appendChild(span1); - div.appendChild(document.createElement('br')); - - for (let i = 0; i < bonus.parts.length; i++) { - const span1 = document.createElement('span'); - span1.innerHTML = `${getBonusPartLabel(bonus, i)} ${bonus.parts[i]}`; - div.appendChild(span1); - div.appendChild(document.createElement('br')); - const span2 = document.createElement('span'); - span2.innerHTML = `ANSWER: ${bonus.answers[i]}`; - div.appendChild(span2); - div.appendChild(document.createElement('br')); - } - - div.appendChild(document.createTextNode(`<${bonus.category} / ${bonus.subcategory}${bonus.alternate_subcategory ? ' / ' + bonus.alternate_subcategory : ''}>`)); - return div; -} - -export function mongoIdToDate (_id) { - const timestamp = _id.toString().substring(0, 8); - return new window.Date(parseInt(timestamp, 16) * 1000); -} - -export function tossupToHTML (tossup) { - const div = document.createElement('div'); - const span1 = document.createElement('span'); - span1.innerHTML = `${tossup.number}. ${tossup.question}`; - div.appendChild(span1); - div.appendChild(document.createElement('br')); - const span2 = document.createElement('span'); - span2.innerHTML = `ANSWER: ${tossup.answer}`; - div.appendChild(span2); - div.appendChild(document.createElement('br')); - div.appendChild(document.createTextNode(`<${tossup.category} / ${tossup.subcategory}${tossup.alternate_subcategory ? ' / ' + tossup.alternate_subcategory : ''}>`)); - return div; -} diff --git a/client/db/frequency-list/index.html b/client/db/frequency-list/index.html index d2abf6d4c..94c20bcc7 100644 --- a/client/db/frequency-list/index.html +++ b/client/db/frequency-list/index.html @@ -39,7 +39,7 @@ diff --git a/client/db/frequency-list/subcategory.html b/client/db/frequency-list/subcategory.html index c0d2531c3..16c316cee 100644 --- a/client/db/frequency-list/subcategory.html +++ b/client/db/frequency-list/subcategory.html @@ -39,7 +39,7 @@ diff --git a/client/db/index.html b/client/db/index.html index b43600d72..4c9f5d51f 100644 --- a/client/db/index.html +++ b/client/db/index.html @@ -39,7 +39,7 @@ diff --git a/client/db/mongo-id-to-date.js b/client/db/mongo-id-to-date.js new file mode 100644 index 000000000..49b93570b --- /dev/null +++ b/client/db/mongo-id-to-date.js @@ -0,0 +1,4 @@ +export default function mongoIdToDate (_id) { + const timestamp = _id.toString().substring(0, 8); + return new window.Date(parseInt(timestamp, 16) * 1000); +} diff --git a/client/db/explorer/packet.html b/client/db/packet/index.html similarity index 96% rename from client/db/explorer/packet.html rename to client/db/packet/index.html index 82442ef5f..65889a3dd 100644 --- a/client/db/explorer/packet.html +++ b/client/db/packet/index.html @@ -39,7 +39,7 @@ @@ -95,13 +95,13 @@
Packet () of :
- Back to all sets + Back to all sets
Loading...
- + diff --git a/client/db/explorer/packet.js b/client/db/packet/index.js similarity index 85% rename from client/db/explorer/packet.js rename to client/db/packet/index.js index 912ac56e8..5f6cac2e6 100644 --- a/client/db/explorer/packet.js +++ b/client/db/packet/index.js @@ -1,4 +1,5 @@ -import { tossupToHTML, bonusToHTML } from './utilities.js'; +import bonusToHTML from '../bonus-to-html.js'; +import tossupToHTML from '../tossup-to-html.js'; const packetId = new URLSearchParams(window.location.search).get('_id'); @@ -9,7 +10,7 @@ document.getElementById('spinner').classList.add('d-none'); document.getElementById('packet-name').textContent = packet.name; document.getElementById('packet-number').textContent = packet.number; document.getElementById('set-name').textContent = packet.set.name; -document.getElementById('set-name').href = './set?_id=' + packet.set._id; +document.getElementById('set-name').href = '../set/?_id=' + packet.set._id; for (const tossup of tossups) { const div = tossupToHTML(tossup); @@ -33,7 +34,7 @@ for (const bonus of bonuses) { function getQuestionLink (type, _id) { const a = document.createElement('a'); - a.href = `./${type}?_id=${_id}`; + a.href = `../${type}/?_id=${_id}`; a.textContent = ` Link to ${type}`; return a; } diff --git a/client/db/explorer/index.html b/client/db/set-list/index.html similarity index 98% rename from client/db/explorer/index.html rename to client/db/set-list/index.html index 2091c4324..a8173be96 100644 --- a/client/db/explorer/index.html +++ b/client/db/set-list/index.html @@ -39,7 +39,7 @@ diff --git a/client/db/explorer/index.js b/client/db/set-list/index.js similarity index 97% rename from client/db/explorer/index.js rename to client/db/set-list/index.js index 139e95e05..1adb67261 100644 --- a/client/db/explorer/index.js +++ b/client/db/set-list/index.js @@ -7,7 +7,7 @@ await fetch('/api/db-explorer/set-metadata?' + new URLSearchParams({ includeCoun data.forEach(({ _id, setName, difficulty, standard }) => { const row = table.insertRow(-1); const a = document.createElement('a'); - a.href = `./set?_id=${_id}`; + a.href = `../set/?_id=${_id}`; a.textContent = setName; row.insertCell(-1).appendChild(a); row.insertCell(-1).textContent = difficulty; diff --git a/client/db/explorer/set.html b/client/db/set/index.html similarity index 96% rename from client/db/explorer/set.html rename to client/db/set/index.html index cd100480a..579d53af7 100644 --- a/client/db/explorer/set.html +++ b/client/db/set/index.html @@ -39,7 +39,7 @@ @@ -93,7 +93,7 @@
View here: - Back to all sets + Back to all sets
@@ -109,7 +109,7 @@
Loading...
- + diff --git a/client/db/explorer/set.js b/client/db/set/index.js similarity index 95% rename from client/db/explorer/set.js rename to client/db/set/index.js index fa1aea843..ffe6e553b 100644 --- a/client/db/explorer/set.js +++ b/client/db/set/index.js @@ -12,7 +12,7 @@ fetch('/api/db-explorer/packet-metadata?' + new URLSearchParams({ setId })) const row = table.insertRow(-1); row.insertCell(-1).textContent = packetNumber; const a = document.createElement('a'); - a.href = `./packet?_id=${_id}`; + a.href = `../packet/?_id=${_id}`; a.textContent = packetName; row.insertCell(-1).appendChild(a); row.insertCell(-1).textContent = tossupCount; diff --git a/client/db/tossup-to-html.js b/client/db/tossup-to-html.js new file mode 100644 index 000000000..76aa9aa45 --- /dev/null +++ b/client/db/tossup-to-html.js @@ -0,0 +1,13 @@ +export default function tossupToHTML (tossup) { + const div = document.createElement('div'); + const span1 = document.createElement('span'); + span1.innerHTML = `${tossup.number}. ${tossup.question}`; + div.appendChild(span1); + div.appendChild(document.createElement('br')); + const span2 = document.createElement('span'); + span2.innerHTML = `ANSWER: ${tossup.answer}`; + div.appendChild(span2); + div.appendChild(document.createElement('br')); + div.appendChild(document.createTextNode(`<${tossup.category} / ${tossup.subcategory}${tossup.alternate_subcategory ? ' / ' + tossup.alternate_subcategory : ''}>`)); + return div; +} diff --git a/client/db/explorer/tossup.html b/client/db/tossup/index.html similarity index 97% rename from client/db/explorer/tossup.html rename to client/db/tossup/index.html index a856fc160..b7061992b 100644 --- a/client/db/explorer/tossup.html +++ b/client/db/tossup/index.html @@ -39,7 +39,7 @@ @@ -98,7 +98,7 @@
Set:
- Back to all sets + Back to all sets
@@ -122,7 +122,7 @@ - + diff --git a/client/db/explorer/tossup.js b/client/db/tossup/index.js similarity index 88% rename from client/db/explorer/tossup.js rename to client/db/tossup/index.js index 5986f400d..5fa7705c9 100644 --- a/client/db/explorer/tossup.js +++ b/client/db/tossup/index.js @@ -1,15 +1,16 @@ -import { mongoIdToDate, tossupToHTML } from './utilities.js'; +import mongoIdToDate from '../mongo-id-to-date.js'; +import tossupToHTML from '../tossup-to-html.js'; const tossupId = new URLSearchParams(window.location.search).get('_id'); const { tossup } = await fetch('/api/tossup?' + new URLSearchParams({ _id: tossupId })).then(res => res.json()); document.getElementById('spinner').classList.add('d-none'); -document.getElementById('packet-link').href = `./packet?_id=${tossup.packet._id}`; +document.getElementById('packet-link').href = `../packet/?_id=${tossup.packet._id}`; document.getElementById('packet-number').textContent = tossup.packet.number; document.getElementById('packet-name').textContent = tossup.packet.name; -document.getElementById('set-name').href = `./set?_id=${tossup.set._id}`; +document.getElementById('set-name').href = `../set/?_id=${tossup.set._id}`; document.getElementById('set-name').textContent = tossup.set.name; document.getElementById('tossup').appendChild(tossupToHTML(tossup)); diff --git a/client/geoword/confirmation.html b/client/geoword/confirmation.html index cd7e4e3cf..fd2ccb032 100644 --- a/client/geoword/confirmation.html +++ b/client/geoword/confirmation.html @@ -38,7 +38,7 @@ diff --git a/client/geoword/index.html b/client/geoword/index.html index 2aec2218b..5d980f7af 100644 --- a/client/geoword/index.html +++ b/client/geoword/index.html @@ -38,7 +38,7 @@ diff --git a/client/geoword/login.html b/client/geoword/login.html index 25513503f..69b0cb3dd 100644 --- a/client/geoword/login.html +++ b/client/geoword/login.html @@ -37,7 +37,7 @@ diff --git a/client/geoword/paid/play/division.html b/client/geoword/paid/play/division.html index c35938119..ce7bb6608 100644 --- a/client/geoword/paid/play/division.html +++ b/client/geoword/paid/play/division.html @@ -38,7 +38,7 @@ diff --git a/client/geoword/paid/play/game.html b/client/geoword/paid/play/game.html index 4faa06e3f..b0cfed2ed 100644 --- a/client/geoword/paid/play/game.html +++ b/client/geoword/paid/play/game.html @@ -38,7 +38,7 @@ diff --git a/client/geoword/paid/results/category-stats.html b/client/geoword/paid/results/category-stats.html index b537f1f5c..7aa33e0fa 100644 --- a/client/geoword/paid/results/category-stats.html +++ b/client/geoword/paid/results/category-stats.html @@ -38,7 +38,7 @@ diff --git a/client/geoword/paid/results/compare.html b/client/geoword/paid/results/compare.html index 500035478..c1b6ff250 100644 --- a/client/geoword/paid/results/compare.html +++ b/client/geoword/paid/results/compare.html @@ -38,7 +38,7 @@ diff --git a/client/geoword/paid/results/leaderboard.html b/client/geoword/paid/results/leaderboard.html index a3ecd07d8..76429e2b0 100644 --- a/client/geoword/paid/results/leaderboard.html +++ b/client/geoword/paid/results/leaderboard.html @@ -37,7 +37,7 @@ diff --git a/client/geoword/paid/results/packet.html b/client/geoword/paid/results/packet.html index 58a6bba52..2cb48d7b1 100644 --- a/client/geoword/paid/results/packet.html +++ b/client/geoword/paid/results/packet.html @@ -37,7 +37,7 @@ diff --git a/client/geoword/paid/results/stats.html b/client/geoword/paid/results/stats.html index 2be47c549..cc5a367dd 100644 --- a/client/geoword/paid/results/stats.html +++ b/client/geoword/paid/results/stats.html @@ -38,7 +38,7 @@ diff --git a/client/geoword/payment.html b/client/geoword/payment.html index cbe58bbf1..216c7f7be 100644 --- a/client/geoword/payment.html +++ b/client/geoword/payment.html @@ -41,7 +41,7 @@ diff --git a/client/index.html b/client/index.html index 06abaf8b1..8fbd3df97 100644 --- a/client/index.html +++ b/client/index.html @@ -38,7 +38,7 @@ @@ -120,7 +120,7 @@
Question Database

Search - DB Explorer + Set List

Answerlines have been aggregated into frequency lists by category.

Frequency List

diff --git a/client/play/bonuses/solo/index.html b/client/play/bonuses/solo/index.html index 98c2183ff..172e3e658 100644 --- a/client/play/bonuses/solo/index.html +++ b/client/play/bonuses/solo/index.html @@ -38,7 +38,7 @@ diff --git a/client/play/index.html b/client/play/index.html index b2099fb85..3f0c4bfbc 100644 --- a/client/play/index.html +++ b/client/play/index.html @@ -38,7 +38,7 @@ diff --git a/client/play/tossups/mp/index.html b/client/play/tossups/mp/index.html index fe5c8b13d..04efc43d3 100644 --- a/client/play/tossups/mp/index.html +++ b/client/play/tossups/mp/index.html @@ -37,7 +37,7 @@ diff --git a/client/play/tossups/mp/room.html b/client/play/tossups/mp/room.html index e35f76f9d..89a026b64 100644 --- a/client/play/tossups/mp/room.html +++ b/client/play/tossups/mp/room.html @@ -37,7 +37,7 @@ diff --git a/client/play/tossups/solo/index.html b/client/play/tossups/solo/index.html index e9d0758da..125872689 100644 --- a/client/play/tossups/solo/index.html +++ b/client/play/tossups/solo/index.html @@ -38,7 +38,7 @@ diff --git a/client/settings/index.html b/client/settings/index.html index 6875eb810..40198933a 100644 --- a/client/settings/index.html +++ b/client/settings/index.html @@ -38,7 +38,7 @@ diff --git a/client/tools/api-docs/bonus.html b/client/tools/api-docs/bonus.html index 84ee70260..90fa6ebaf 100644 --- a/client/tools/api-docs/bonus.html +++ b/client/tools/api-docs/bonus.html @@ -38,7 +38,7 @@ diff --git a/client/tools/api-docs/check-answer.html b/client/tools/api-docs/check-answer.html index a3a77b072..3853e2a20 100644 --- a/client/tools/api-docs/check-answer.html +++ b/client/tools/api-docs/check-answer.html @@ -38,7 +38,7 @@ diff --git a/client/tools/api-docs/frequency-list.html b/client/tools/api-docs/frequency-list.html index 256f33e7d..c4a334f4f 100644 --- a/client/tools/api-docs/frequency-list.html +++ b/client/tools/api-docs/frequency-list.html @@ -38,7 +38,7 @@ diff --git a/client/tools/api-docs/index.html b/client/tools/api-docs/index.html index 13e13ac89..a23f09fa5 100644 --- a/client/tools/api-docs/index.html +++ b/client/tools/api-docs/index.html @@ -38,7 +38,7 @@ diff --git a/client/tools/api-docs/multiplayer/room-list.html b/client/tools/api-docs/multiplayer/room-list.html index 601dbb428..5d368db68 100644 --- a/client/tools/api-docs/multiplayer/room-list.html +++ b/client/tools/api-docs/multiplayer/room-list.html @@ -38,7 +38,7 @@ diff --git a/client/tools/api-docs/num-packets.html b/client/tools/api-docs/num-packets.html index 73781e700..0ebb92e1f 100644 --- a/client/tools/api-docs/num-packets.html +++ b/client/tools/api-docs/num-packets.html @@ -38,7 +38,7 @@ diff --git a/client/tools/api-docs/packet.html b/client/tools/api-docs/packet.html index ae0511a4d..cb03aee2e 100644 --- a/client/tools/api-docs/packet.html +++ b/client/tools/api-docs/packet.html @@ -38,7 +38,7 @@ diff --git a/client/tools/api-docs/query.html b/client/tools/api-docs/query.html index 45e146e60..c1bb19dc3 100644 --- a/client/tools/api-docs/query.html +++ b/client/tools/api-docs/query.html @@ -38,7 +38,7 @@ diff --git a/client/tools/api-docs/question-stats/bonus.html b/client/tools/api-docs/question-stats/bonus.html index 1d53995d2..2968c386c 100644 --- a/client/tools/api-docs/question-stats/bonus.html +++ b/client/tools/api-docs/question-stats/bonus.html @@ -38,7 +38,7 @@ diff --git a/client/tools/api-docs/question-stats/tossup.html b/client/tools/api-docs/question-stats/tossup.html index d29024757..8e7399e9a 100644 --- a/client/tools/api-docs/question-stats/tossup.html +++ b/client/tools/api-docs/question-stats/tossup.html @@ -38,7 +38,7 @@ diff --git a/client/tools/api-docs/random-bonus.html b/client/tools/api-docs/random-bonus.html index 2a940e418..be54e54d6 100644 --- a/client/tools/api-docs/random-bonus.html +++ b/client/tools/api-docs/random-bonus.html @@ -38,7 +38,7 @@ diff --git a/client/tools/api-docs/random-name.html b/client/tools/api-docs/random-name.html index 064c33d0e..39693984b 100644 --- a/client/tools/api-docs/random-name.html +++ b/client/tools/api-docs/random-name.html @@ -38,7 +38,7 @@ diff --git a/client/tools/api-docs/random-tossup.html b/client/tools/api-docs/random-tossup.html index 908211941..f58b9538c 100644 --- a/client/tools/api-docs/random-tossup.html +++ b/client/tools/api-docs/random-tossup.html @@ -38,7 +38,7 @@ diff --git a/client/tools/api-docs/report-question.html b/client/tools/api-docs/report-question.html index 0a9efa165..6d633c3d7 100644 --- a/client/tools/api-docs/report-question.html +++ b/client/tools/api-docs/report-question.html @@ -38,7 +38,7 @@ diff --git a/client/tools/api-docs/schemas/index.html b/client/tools/api-docs/schemas/index.html index b9b667272..7ad855c68 100644 --- a/client/tools/api-docs/schemas/index.html +++ b/client/tools/api-docs/schemas/index.html @@ -38,7 +38,7 @@ diff --git a/client/tools/api-docs/set-list.html b/client/tools/api-docs/set-list.html index ddc1ae3aa..8976c336e 100644 --- a/client/tools/api-docs/set-list.html +++ b/client/tools/api-docs/set-list.html @@ -38,7 +38,7 @@ diff --git a/client/tools/api-docs/tossup.html b/client/tools/api-docs/tossup.html index dc77316db..d98a495af 100644 --- a/client/tools/api-docs/tossup.html +++ b/client/tools/api-docs/tossup.html @@ -38,7 +38,7 @@ diff --git a/client/tools/packet-parser/index.html b/client/tools/packet-parser/index.html index ba375fb10..99c6d9e83 100644 --- a/client/tools/packet-parser/index.html +++ b/client/tools/packet-parser/index.html @@ -38,7 +38,7 @@ diff --git a/client/tools/tb-splitter/index.html b/client/tools/tb-splitter/index.html index 4b858996d..fbbe85194 100644 --- a/client/tools/tb-splitter/index.html +++ b/client/tools/tb-splitter/index.html @@ -38,7 +38,7 @@ diff --git a/client/user/edit-password.html b/client/user/edit-password.html index 14c1cd549..2e7daccaa 100644 --- a/client/user/edit-password.html +++ b/client/user/edit-password.html @@ -38,7 +38,7 @@ diff --git a/client/user/edit-profile.html b/client/user/edit-profile.html index 506bd1793..a822977a3 100644 --- a/client/user/edit-profile.html +++ b/client/user/edit-profile.html @@ -38,7 +38,7 @@ diff --git a/client/user/forgot-password.html b/client/user/forgot-password.html index 6db7e6528..18a0538a3 100644 --- a/client/user/forgot-password.html +++ b/client/user/forgot-password.html @@ -38,7 +38,7 @@ diff --git a/client/user/login.html b/client/user/login.html index fe5ae4819..d4c7dda48 100644 --- a/client/user/login.html +++ b/client/user/login.html @@ -38,7 +38,7 @@ diff --git a/client/user/my-profile.html b/client/user/my-profile.html index 313112bdc..fe04be498 100644 --- a/client/user/my-profile.html +++ b/client/user/my-profile.html @@ -38,7 +38,7 @@ diff --git a/client/user/reset-password.html b/client/user/reset-password.html index 2c013067d..ff159d17b 100644 --- a/client/user/reset-password.html +++ b/client/user/reset-password.html @@ -38,7 +38,7 @@ diff --git a/client/user/signup.html b/client/user/signup.html index cf5ee6efa..250b29eb3 100644 --- a/client/user/signup.html +++ b/client/user/signup.html @@ -38,7 +38,7 @@ diff --git a/client/user/stars/bonuses.html b/client/user/stars/bonuses.html index 0a33be1c9..dcc129037 100644 --- a/client/user/stars/bonuses.html +++ b/client/user/stars/bonuses.html @@ -38,7 +38,7 @@ diff --git a/client/user/stars/tossups.html b/client/user/stars/tossups.html index 119b19d89..61f6305c3 100644 --- a/client/user/stars/tossups.html +++ b/client/user/stars/tossups.html @@ -38,7 +38,7 @@ diff --git a/client/user/stats/bonus-graph.html b/client/user/stats/bonus-graph.html index 116c527ca..54c41cdcb 100644 --- a/client/user/stats/bonus-graph.html +++ b/client/user/stats/bonus-graph.html @@ -42,7 +42,7 @@ diff --git a/client/user/stats/bonuses.html b/client/user/stats/bonuses.html index 915e323e8..64a8e3a8c 100644 --- a/client/user/stats/bonuses.html +++ b/client/user/stats/bonuses.html @@ -38,7 +38,7 @@ diff --git a/client/user/stats/tossup-graph.html b/client/user/stats/tossup-graph.html index 97d4326ee..43c73392a 100644 --- a/client/user/stats/tossup-graph.html +++ b/client/user/stats/tossup-graph.html @@ -42,7 +42,7 @@ diff --git a/client/user/stats/tossups.html b/client/user/stats/tossups.html index 6cfdbb58e..5f8aa636b 100644 --- a/client/user/stats/tossups.html +++ b/client/user/stats/tossups.html @@ -38,7 +38,7 @@ diff --git a/client/user/verify-failed.html b/client/user/verify-failed.html index 56711c900..dc1c01dfd 100644 --- a/client/user/verify-failed.html +++ b/client/user/verify-failed.html @@ -38,7 +38,7 @@ diff --git a/routes/db.js b/routes/db.js deleted file mode 100644 index 029f76bcb..000000000 --- a/routes/db.js +++ /dev/null @@ -1,34 +0,0 @@ -import { escapeHTML } from '../client/scripts/utilities/strings.js'; -import getBonus from '../database/qbreader/get-bonus.js'; -import getTossup from '../database/qbreader/get-tossup.js'; - -import { Router } from 'express'; -import fs from 'fs'; -import { ObjectId } from 'mongodb'; -const router = Router(); - -router.get('/explorer/bonus', async (req, res) => { - let _id = new URLSearchParams(req.query).get('_id'); - try { _id = new ObjectId(_id); } catch (e) { return res.status(400).send('Invalid ID'); } - const bonus = await getBonus(_id); - if (!bonus) return res.sendStatus(404); - const description = `Bonus: ${bonus.answers_sanitized.map(a => escapeHTML(removeParentheses(a))).join(' / ')} [${bonus.set.name}]`; - const file = fs.readFileSync('./client/db/explorer/bonus.html', { encoding: 'utf8' }); - res.send(file.replace('', ``)); -}); - -router.get('/explorer/tossup', async (req, res) => { - let _id = new URLSearchParams(req.query).get('_id'); - try { _id = new ObjectId(_id); } catch (e) { return res.status(400).send('Invalid ID'); } - const tossup = await getTossup(_id); - if (!tossup) return res.sendStatus(404); - const description = `Tossup: ${escapeHTML(removeParentheses(tossup.answer_sanitized))} [${tossup.set.name}]`; - const file = fs.readFileSync('./client/db/explorer/tossup.html', { encoding: 'utf8' }); - res.send(file.replace('', ``)); -}); - -function removeParentheses (answer) { - return answer.replace(/[([].*/g, ''); -} - -export default router; diff --git a/routes/db/bonus.js b/routes/db/bonus.js new file mode 100644 index 000000000..6060cd1ab --- /dev/null +++ b/routes/db/bonus.js @@ -0,0 +1,28 @@ +import { escapeHTML } from '../../client/scripts/utilities/strings.js'; +import getBonus from '../../database/qbreader/get-bonus.js'; +import queryRedirect from '../../server/query-redirect.js'; + +import { Router } from 'express'; +import fs from 'fs'; +import { ObjectId } from 'mongodb'; +const router = Router(); + +function removeParentheses (answer) { + return answer.replace(/[([].*/g, ''); +} + +router.get('/', async (req, res) => { + if (req.originalUrl.split('?')[0].at(-1) !== '/') { return queryRedirect('/db/bonus/')(req, res); } + + let _id = new URLSearchParams(req.query).get('_id'); + try { _id = new ObjectId(_id); } catch (e) { return res.status(400).send('Invalid ID'); } + + const bonus = await getBonus(_id); + if (!bonus) { return res.sendStatus(404); } + + const description = `Bonus: ${bonus.answers_sanitized.map(a => escapeHTML(removeParentheses(a))).join(' / ')} [${bonus.set.name}]`; + const file = fs.readFileSync('./client/db/bonus/index.html', { encoding: 'utf8' }); + res.send(file.replace('', ``)); +}); + +export default router; diff --git a/routes/db/index.js b/routes/db/index.js new file mode 100644 index 000000000..71d9bfe38 --- /dev/null +++ b/routes/db/index.js @@ -0,0 +1,10 @@ +import bonusRouter from './bonus.js'; +import tossupRouter from './tossup.js'; + +import { Router } from 'express'; +const router = Router(); + +router.use('/bonus', bonusRouter); +router.use('/tossup', tossupRouter); + +export default router; diff --git a/routes/db/tossup.js b/routes/db/tossup.js new file mode 100644 index 000000000..5b00a6657 --- /dev/null +++ b/routes/db/tossup.js @@ -0,0 +1,28 @@ +import { escapeHTML } from '../../client/scripts/utilities/strings.js'; +import getTossup from '../../database/qbreader/get-tossup.js'; +import queryRedirect from '../../server/query-redirect.js'; + +import { Router } from 'express'; +import fs from 'fs'; +import { ObjectId } from 'mongodb'; +const router = Router(); + +function removeParentheses (answer) { + return answer.replace(/[([].*/g, ''); +} + +router.get('/', async (req, res) => { + if (req.originalUrl.split('?')[0].at(-1) !== '/') { return queryRedirect('/db/tossup/')(req, res); } + + let _id = new URLSearchParams(req.query).get('_id'); + try { _id = new ObjectId(_id); } catch (e) { return res.status(400).send('Invalid ID'); } + + const tossup = await getTossup(_id); + if (!tossup) { return res.sendStatus(404); } + + const description = `Tossup: ${escapeHTML(removeParentheses(tossup.answer_sanitized))} [${tossup.set.name}]`; + const file = fs.readFileSync('./client/db/tossup/index.html', { encoding: 'utf8' }); + res.send(file.replace('', ``)); +}); + +export default router; diff --git a/routes/index.js b/routes/index.js index 1c9c0dfbd..ae6583be8 100644 --- a/routes/index.js +++ b/routes/index.js @@ -1,7 +1,7 @@ import adminRouter from './admin.js'; import apiRouter from './api/index.js'; import authRouter from './auth/index.js'; -import dbRouter from './db.js'; +import dbRouter from './db/index.js'; import geowordRouter from './geoword/index.js'; import playRouter from './play/index.js'; import userRouter from './user.js'; diff --git a/routes/redirects.js b/routes/redirects.js index 6a6d210c4..7326bb7a8 100644 --- a/routes/redirects.js +++ b/routes/redirects.js @@ -19,6 +19,9 @@ router.get('/frequency-list', queryRedirect('/db/frequency-list/')); router.get('/frequency-list/subcategory', queryRedirect('/db/frequency-list/subcategory')); router.get('/tools/db-explorer/:param', (req, res) => queryRedirect('/db/explorer/' + req.params.param)(req, res)); +router.get('/db/explorer/', (_req, res) => res.redirect('/db/set-list')); +router.get('/db/explorer/:param', (req, res) => queryRedirect('/db/' + req.params.param + '/')(req, res)); + router.get('/user', (_req, res) => res.redirect('/user/login')); export default router;