From b1217105ec383071def855d157a76ea5ef0d18b8 Mon Sep 17 00:00:00 2001 From: alopezlago Date: Tue, 25 Apr 2023 23:33:56 -0700 Subject: [PATCH 1/5] Move the script to set light/dark mode to a common JS file. This means browsers can cache the JS file and apply it to each website instead of loading it each time the website is fetched. --- client/about.html | 13 +------------ client/api-info.html | 13 +------------ client/apply-theme.js | 10 ++++++++++ client/backups.html | 13 +------------ client/database/index.html | 13 +------------ client/multiplayer/index.html | 13 +------------ client/multiplayer/room.html | 13 +------------ client/singleplayer/bonuses.html | 13 +------------ client/singleplayer/tossups.html | 13 +------------ 9 files changed, 18 insertions(+), 96 deletions(-) create mode 100644 client/apply-theme.js diff --git a/client/about.html b/client/about.html index 8016acfbe..a0124d2cd 100644 --- a/client/about.html +++ b/client/about.html @@ -12,18 +12,7 @@ - + diff --git a/client/api-info.html b/client/api-info.html index c6774fe08..5168f876c 100644 --- a/client/api-info.html +++ b/client/api-info.html @@ -12,18 +12,7 @@ - + diff --git a/client/apply-theme.js b/client/apply-theme.js new file mode 100644 index 000000000..56e8a2353 --- /dev/null +++ b/client/apply-theme.js @@ -0,0 +1,10 @@ +if (localStorage.getItem('color-theme') === 'dark') { + document.querySelector('#custom-css').setAttribute('href', "/bootstrap/dark.css"); +} else if (localStorage.getItem('color-theme') === 'light') { + document.querySelector('#custom-css').setAttribute('href', "/bootstrap/light.css"); +} else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { + // Get OS preferred color scheme + document.querySelector('#custom-css').setAttribute('href', "/bootstrap/dark.css"); +} else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) { + document.querySelector('#custom-css').setAttribute('href', "/bootstrap/light.css"); +} \ No newline at end of file diff --git a/client/backups.html b/client/backups.html index b17912927..b7a2f52db 100644 --- a/client/backups.html +++ b/client/backups.html @@ -12,18 +12,7 @@ - + diff --git a/client/database/index.html b/client/database/index.html index a921cf331..7c0a021b9 100644 --- a/client/database/index.html +++ b/client/database/index.html @@ -12,18 +12,7 @@ - + diff --git a/client/multiplayer/index.html b/client/multiplayer/index.html index c4b675034..e179c3f7b 100644 --- a/client/multiplayer/index.html +++ b/client/multiplayer/index.html @@ -11,18 +11,7 @@ - + diff --git a/client/multiplayer/room.html b/client/multiplayer/room.html index cc43d2980..da333a70f 100644 --- a/client/multiplayer/room.html +++ b/client/multiplayer/room.html @@ -16,18 +16,7 @@ - + diff --git a/client/singleplayer/bonuses.html b/client/singleplayer/bonuses.html index 10303fab0..308bd18c9 100644 --- a/client/singleplayer/bonuses.html +++ b/client/singleplayer/bonuses.html @@ -17,18 +17,7 @@ - + diff --git a/client/singleplayer/tossups.html b/client/singleplayer/tossups.html index a353191d6..762d79954 100644 --- a/client/singleplayer/tossups.html +++ b/client/singleplayer/tossups.html @@ -17,18 +17,7 @@ - + From 6c134f059ab6f3616b9aaf0add5d138dc49bc533 Mon Sep 17 00:00:00 2001 From: alopezlago Date: Wed, 26 Apr 2023 13:18:37 -0700 Subject: [PATCH 2/5] Fix linter issues --- client/apply-theme.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/apply-theme.js b/client/apply-theme.js index 56e8a2353..bd22b4da3 100644 --- a/client/apply-theme.js +++ b/client/apply-theme.js @@ -1,10 +1,10 @@ if (localStorage.getItem('color-theme') === 'dark') { - document.querySelector('#custom-css').setAttribute('href', "/bootstrap/dark.css"); + document.querySelector('#custom-css').setAttribute('href', '/bootstrap/dark.css'); } else if (localStorage.getItem('color-theme') === 'light') { document.querySelector('#custom-css').setAttribute('href', "/bootstrap/light.css"); } else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { // Get OS preferred color scheme - document.querySelector('#custom-css').setAttribute('href', "/bootstrap/dark.css"); + document.querySelector('#custom-css').setAttribute('href', '/bootstrap/dark.css'); } else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) { - document.querySelector('#custom-css').setAttribute('href', "/bootstrap/light.css"); + document.querySelector('#custom-css').setAttribute('href', '/bootstrap/light.css'); } \ No newline at end of file From 0e634421b6f5210dccd65acc034329f4d23fba9e Mon Sep 17 00:00:00 2001 From: alopezlago Date: Wed, 26 Apr 2023 13:21:38 -0700 Subject: [PATCH 3/5] Update api-docs to use the applyTheme script --- client/api-docs/check-answer.html | 13 +------------ client/api-docs/index.html | 13 +------------ client/api-docs/multiplayer/room-list.html | 13 +------------ client/api-docs/num-packets.html | 13 +------------ client/api-docs/packet-bonuses.html | 13 +------------ client/api-docs/packet-tossups.html | 13 +------------ client/api-docs/packet.html | 13 +------------ client/api-docs/random-name.html | 13 +------------ client/api-docs/random-question.html | 13 +------------ client/api-docs/report-question.html | 13 +------------ client/api-docs/schemas.html | 13 +------------ client/api-docs/set-list.html | 13 +------------ 12 files changed, 12 insertions(+), 144 deletions(-) diff --git a/client/api-docs/check-answer.html b/client/api-docs/check-answer.html index 27b6e244d..33c5c1fe7 100644 --- a/client/api-docs/check-answer.html +++ b/client/api-docs/check-answer.html @@ -12,18 +12,7 @@ - + diff --git a/client/api-docs/index.html b/client/api-docs/index.html index 6d86cde55..0926e9d4c 100644 --- a/client/api-docs/index.html +++ b/client/api-docs/index.html @@ -12,18 +12,7 @@ - + diff --git a/client/api-docs/multiplayer/room-list.html b/client/api-docs/multiplayer/room-list.html index a9eb0edb0..68e88df4d 100644 --- a/client/api-docs/multiplayer/room-list.html +++ b/client/api-docs/multiplayer/room-list.html @@ -12,18 +12,7 @@ - + diff --git a/client/api-docs/num-packets.html b/client/api-docs/num-packets.html index ec723c571..3b94676e1 100644 --- a/client/api-docs/num-packets.html +++ b/client/api-docs/num-packets.html @@ -12,18 +12,7 @@ - + diff --git a/client/api-docs/packet-bonuses.html b/client/api-docs/packet-bonuses.html index fcf0486be..b6f3c8a24 100644 --- a/client/api-docs/packet-bonuses.html +++ b/client/api-docs/packet-bonuses.html @@ -12,18 +12,7 @@ - + diff --git a/client/api-docs/packet-tossups.html b/client/api-docs/packet-tossups.html index d9a6232d9..aa0f0aae3 100644 --- a/client/api-docs/packet-tossups.html +++ b/client/api-docs/packet-tossups.html @@ -12,18 +12,7 @@ - + diff --git a/client/api-docs/packet.html b/client/api-docs/packet.html index 25c8937b2..26ab7145e 100644 --- a/client/api-docs/packet.html +++ b/client/api-docs/packet.html @@ -12,18 +12,7 @@ - + diff --git a/client/api-docs/random-name.html b/client/api-docs/random-name.html index 9c2d7bfd4..729dd0eb4 100644 --- a/client/api-docs/random-name.html +++ b/client/api-docs/random-name.html @@ -12,18 +12,7 @@ - + diff --git a/client/api-docs/random-question.html b/client/api-docs/random-question.html index de1858af9..b96eba384 100644 --- a/client/api-docs/random-question.html +++ b/client/api-docs/random-question.html @@ -12,18 +12,7 @@ - + diff --git a/client/api-docs/report-question.html b/client/api-docs/report-question.html index c8d487923..ee53872d0 100644 --- a/client/api-docs/report-question.html +++ b/client/api-docs/report-question.html @@ -12,18 +12,7 @@ - + diff --git a/client/api-docs/schemas.html b/client/api-docs/schemas.html index 671c5d264..aedb7bcf3 100644 --- a/client/api-docs/schemas.html +++ b/client/api-docs/schemas.html @@ -12,18 +12,7 @@ - + diff --git a/client/api-docs/set-list.html b/client/api-docs/set-list.html index 05cccdcb5..58c3d5df8 100644 --- a/client/api-docs/set-list.html +++ b/client/api-docs/set-list.html @@ -12,18 +12,7 @@ - + From aee00810a505a26d7590f4d14aa2825d67bb5be2 Mon Sep 17 00:00:00 2001 From: alopezlago Date: Wed, 26 Apr 2023 13:22:55 -0700 Subject: [PATCH 4/5] Fix double quote issue --- client/apply-theme.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/apply-theme.js b/client/apply-theme.js index bd22b4da3..742855ad7 100644 --- a/client/apply-theme.js +++ b/client/apply-theme.js @@ -1,7 +1,7 @@ if (localStorage.getItem('color-theme') === 'dark') { document.querySelector('#custom-css').setAttribute('href', '/bootstrap/dark.css'); } else if (localStorage.getItem('color-theme') === 'light') { - document.querySelector('#custom-css').setAttribute('href', "/bootstrap/light.css"); + document.querySelector('#custom-css').setAttribute('href', '/bootstrap/light.css'); } else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { // Get OS preferred color scheme document.querySelector('#custom-css').setAttribute('href', '/bootstrap/dark.css'); From e2569bf88b309f659ffdc69b564f2fd9888cd565 Mon Sep 17 00:00:00 2001 From: Geoffrey Wu Date: Wed, 26 Apr 2023 17:34:58 -0400 Subject: [PATCH 5/5] preload `light.css` --- client/about.html | 1 + client/api-docs/check-answer.html | 5 ++++- client/api-docs/index.html | 1 + client/api-docs/multiplayer/room-list.html | 1 + client/api-docs/num-packets.html | 5 ++++- client/api-docs/packet-bonuses.html | 8 ++++++-- client/api-docs/packet-tossups.html | 8 ++++++-- client/api-docs/packet.html | 11 ++++++++--- client/api-docs/random-name.html | 5 ++++- client/api-docs/random-question.html | 7 +++++-- client/api-docs/report-question.html | 5 ++++- client/api-docs/schemas.html | 21 ++++++++++++--------- client/api-docs/set-list.html | 5 ++++- client/backups.html | 1 + client/database/index.html | 1 + client/multiplayer/index.html | 1 + client/multiplayer/room.html | 1 + client/singleplayer/bonuses.html | 1 + client/singleplayer/tossups.html | 1 + 19 files changed, 66 insertions(+), 23 deletions(-) diff --git a/client/about.html b/client/about.html index 55d8f42c8..71d5cc4f9 100644 --- a/client/about.html +++ b/client/about.html @@ -11,6 +11,7 @@ + diff --git a/client/api-docs/check-answer.html b/client/api-docs/check-answer.html index 33c5c1fe7..bfe4da5d8 100644 --- a/client/api-docs/check-answer.html +++ b/client/api-docs/check-answer.html @@ -11,6 +11,7 @@ + @@ -111,7 +112,9 @@
Other
-

GET qbreader.org/api/check-answer

+

+
GET qbreader.org/api/check-answer
+

Judge an answer to be correct, incorrect, or prompt. Directed prompts are supported. diff --git a/client/api-docs/index.html b/client/api-docs/index.html index 0926e9d4c..c1e7a5740 100644 --- a/client/api-docs/index.html +++ b/client/api-docs/index.html @@ -11,6 +11,7 @@ + diff --git a/client/api-docs/multiplayer/room-list.html b/client/api-docs/multiplayer/room-list.html index 68e88df4d..ce1b6df11 100644 --- a/client/api-docs/multiplayer/room-list.html +++ b/client/api-docs/multiplayer/room-list.html @@ -11,6 +11,7 @@ + diff --git a/client/api-docs/num-packets.html b/client/api-docs/num-packets.html index 3b94676e1..f81b12f98 100644 --- a/client/api-docs/num-packets.html +++ b/client/api-docs/num-packets.html @@ -11,6 +11,7 @@ + @@ -111,7 +112,9 @@

Other
-

GET qbreader.org/api/num-packets

+

+
GET qbreader.org/api/num-packets
+

Get the number of packets in a set. diff --git a/client/api-docs/packet-bonuses.html b/client/api-docs/packet-bonuses.html index b6f3c8a24..49eab31a0 100644 --- a/client/api-docs/packet-bonuses.html +++ b/client/api-docs/packet-bonuses.html @@ -11,6 +11,7 @@ + @@ -111,7 +112,9 @@

Other
-

GET qbreader.org/api/packet-bonuses

+

+
GET qbreader.org/api/packet-bonuses
+

Get only bonuses from a packet. @@ -150,7 +153,8 @@

Returns

  • - bonuses: Bonus[] + bonuses: Bonus[]
    An array of diff --git a/client/api-docs/packet-tossups.html b/client/api-docs/packet-tossups.html index aa0f0aae3..a6d1c7ac5 100644 --- a/client/api-docs/packet-tossups.html +++ b/client/api-docs/packet-tossups.html @@ -11,6 +11,7 @@ + @@ -111,7 +112,9 @@
    Other
    -

    GET qbreader.org/api/packet-tossups

    +

    +
    GET qbreader.org/api/packet-tossups
    +

    Get only tossups from a packet. @@ -150,7 +153,8 @@

    Returns

    • - tossups: Tossup[] + tossups: Tossup[]
      An array of diff --git a/client/api-docs/packet.html b/client/api-docs/packet.html index 26ab7145e..b0789971a 100644 --- a/client/api-docs/packet.html +++ b/client/api-docs/packet.html @@ -11,6 +11,7 @@ + @@ -111,7 +112,9 @@
      Other
      -

      GET qbreader.org/api/packet

      +

      +
      GET qbreader.org/api/packet
      +

      Get a specific packet from a set. @@ -150,7 +153,8 @@

      Returns

      • - tossups: Tossup[] + tossups: Tossup[]
        An array of @@ -161,7 +165,8 @@

        Returns

      • - bonuses: Bonus[] + bonuses: Bonus[]
        An array of diff --git a/client/api-docs/random-name.html b/client/api-docs/random-name.html index 729dd0eb4..aa2f89417 100644 --- a/client/api-docs/random-name.html +++ b/client/api-docs/random-name.html @@ -11,6 +11,7 @@ + @@ -111,7 +112,9 @@
        Other
        -

        GET qbreader.org/api/random-name

        +

        +
        GET qbreader.org/api/random-name
        +

        Get a random adjective-noun pair that can be used as a name. diff --git a/client/api-docs/random-question.html b/client/api-docs/random-question.html index b96eba384..d96696fcb 100644 --- a/client/api-docs/random-question.html +++ b/client/api-docs/random-question.html @@ -11,6 +11,7 @@ + @@ -111,7 +112,9 @@

        Other
        -

        POST qbreader.org/api/random-question

        +

        +
        POST qbreader.org/api/random-question
        +

        Get random questions from the database. @@ -177,7 +180,7 @@

        Parameters

      • This API endpoint does not check for consistency between categories and subcategories.
      • For example, requesting the "History" and the "Biology" - and "Chemistry" subcategories will return no questions.
      • + and "Chemistry" subcategories will return no questions.
    • diff --git a/client/api-docs/report-question.html b/client/api-docs/report-question.html index ee53872d0..2541c5665 100644 --- a/client/api-docs/report-question.html +++ b/client/api-docs/report-question.html @@ -11,6 +11,7 @@ + @@ -111,7 +112,9 @@
      Other
    -

    POST qbreader.org/api/report-question

    +

    +
    POST qbreader.org/api/report-question
    +

    Report a question error. diff --git a/client/api-docs/schemas.html b/client/api-docs/schemas.html index aedb7bcf3..c4d8050f8 100644 --- a/client/api-docs/schemas.html +++ b/client/api-docs/schemas.html @@ -11,6 +11,7 @@ + @@ -216,7 +217,9 @@

    Tossup

-

Bonus

+ +

Bonus

+
    @@ -332,10 +335,10 @@

    Tossup

    "number": 1, }) }).then(res => res.json()) - .then(data => data[0]) - .then(data => { - document.getElementById("tossupExample").innerText = JSON.stringify(data, null, 4); - }); + .then(data => data[0]) + .then(data => { + document.getElementById("tossupExample").innerText = JSON.stringify(data, null, 4); + }); } function getBonusExample() { @@ -349,10 +352,10 @@

    Tossup

    "number": 1, }) }).then(res => res.json()) - .then(data => data[0]) - .then(data => { - document.getElementById("bonusExample").innerText = JSON.stringify(data, null, 4); - }); + .then(data => data[0]) + .then(data => { + document.getElementById("bonusExample").innerText = JSON.stringify(data, null, 4); + }); } getTossupExample(); diff --git a/client/api-docs/set-list.html b/client/api-docs/set-list.html index 58c3d5df8..fc4ccc786 100644 --- a/client/api-docs/set-list.html +++ b/client/api-docs/set-list.html @@ -11,6 +11,7 @@ + @@ -111,7 +112,9 @@
    Other
-

GET qbreader.org/api/set-list

+

+
GET qbreader.org/api/set-list
+

Get a list of all the sets in the database. diff --git a/client/backups.html b/client/backups.html index 8b5aa2d2a..15bd18c07 100644 --- a/client/backups.html +++ b/client/backups.html @@ -11,6 +11,7 @@ + diff --git a/client/database/index.html b/client/database/index.html index ce685c4f8..e402c21e8 100644 --- a/client/database/index.html +++ b/client/database/index.html @@ -11,6 +11,7 @@ + diff --git a/client/multiplayer/index.html b/client/multiplayer/index.html index 74f910d88..76158ec37 100644 --- a/client/multiplayer/index.html +++ b/client/multiplayer/index.html @@ -10,6 +10,7 @@ + diff --git a/client/multiplayer/room.html b/client/multiplayer/room.html index 8c4539f63..6da91fe21 100644 --- a/client/multiplayer/room.html +++ b/client/multiplayer/room.html @@ -15,6 +15,7 @@ crossorigin="anonymous"> + diff --git a/client/singleplayer/bonuses.html b/client/singleplayer/bonuses.html index 018a08295..ea03c011c 100644 --- a/client/singleplayer/bonuses.html +++ b/client/singleplayer/bonuses.html @@ -16,6 +16,7 @@ crossorigin="anonymous"> + diff --git a/client/singleplayer/tossups.html b/client/singleplayer/tossups.html index 931820d34..98d953ac8 100644 --- a/client/singleplayer/tossups.html +++ b/client/singleplayer/tossups.html @@ -16,6 +16,7 @@ crossorigin="anonymous"> +