From 740cc09ac3496a48aad415d4c60d52f1aac20e86 Mon Sep 17 00:00:00 2001
From: Poopthon <107613841+Poopthon@users.noreply.github.com>
Date: Tue, 31 Dec 2024 22:39:28 +0800
Subject: [PATCH 1/3] Update script.js
---
script.js | 67 ++++++++++++++++++++++++++++---------------------------
1 file changed, 34 insertions(+), 33 deletions(-)
diff --git a/script.js b/script.js
index 695272f..4f1a186 100644
--- a/script.js
+++ b/script.js
@@ -324,25 +324,6 @@ function packTags() {
else container.classList.remove('centred');
}
-async function setTags() {
- const tagsList = data.tagsV2[data.filters.subject];
- let tagsHtml = ``;
- for (const [tagGroup, subTags] of Object.entries(tagsList)) {
- tagsHtml += `${tagGroup}`;
- if (subTags.length > 0) {
- tagsHtml += ``;
- }
- tagsHtml += ``;
- }
- document.getElementById('tagsContainer').innerHTML = tagsHtml;
- if (document.getElementById('modifyTags')) setModifyTags();
- packTags();
-}
-
async function search() {
data.filters.year = document.getElementById('yearSelect').value;
data.filters.calculator = document.getElementById('calculatorSelect').value;
@@ -357,19 +338,37 @@ async function search() {
const allQuestions = data.questionsRaw[data.filters.subject];
data.questions = [];
- allQuestions.forEach(function(question, index) {
- if (data.filters.mode == 'untagged') {
- if (question.tags.length == 0) data.questions.push(allQuestions[index]);
- } else if ((data.filters.year == "all" || JSON.stringify(question.year) == data.filters.year) && (data.filters.source == 'all' || question.source == data.filters.source) && (data.filters.type == 'all' || question.type == data.filters.type || question.soruce == data.filters.type) && (data.filters.calculator == 'all' || (question.calculator == data.filters.calculator)) && !data.filters.nTags.some(tag => question.tags.includes(tag))) {
- if (data.filters.mode == 'and') {
- if (data.filters.tags.every(tag => question.tags.includes(tag))) {
- data.questions.push(allQuestions[index]);
- }
- } else {
- if (data.filters.tags.length == 0 || data.filters.tags.some(tag => question.tags.includes(tag))) {
- data.questions.push(allQuestions[index]);
- }
- }
+ allQuestions.forEach(function (question, index) {
+ let matches = true;
+
+ // Check tags (all tags in "tags" must match)
+ if (data.filters.tags.length > 0) {
+ matches = data.filters.tags.every(tag => question.tags.includes(tag));
+ }
+
+ // Check excluded tags (none of the "nTags" should be present)
+ if (matches && data.filters.nTags.some(tag => question.tags.includes(tag))) {
+ matches = false;
+ }
+
+ // Check type
+ if (matches && data.filters.type !== 'all') {
+ matches = question.type === data.filters.type;
+ }
+
+ // Check year
+ if (matches && data.filters.year !== 'all') {
+ matches = question.year == data.filters.year;
+ }
+
+ // Check calculator
+ if (matches && data.filters.calculator !== 'all') {
+ matches = question.calculator === data.filters.calculator;
+ }
+
+ // Add the question if it matches all filters
+ if (matches) {
+ data.questions.push(allQuestions[index]);
}
});
@@ -377,6 +376,8 @@ async function search() {
renderPageResults();
}
+}
+
function renderPageResults() {
data.filters.resultsPerPage = parseInt(document.getElementById('lengthSelect').value);
const start = data.filters.currentPage * data.filters.resultsPerPage;
@@ -1031,4 +1032,4 @@ window.addEventListener("load", async function() {
});
});
-window.addEventListener("resize", adjustZoomForOverflow);
\ No newline at end of file
+window.addEventListener("resize", adjustZoomForOverflow);
From 99a112fc054fbed8b189758cea22c3b19ac5893d Mon Sep 17 00:00:00 2001
From: Poopthon <107613841+Poopthon@users.noreply.github.com>
Date: Tue, 31 Dec 2024 22:49:01 +0800
Subject: [PATCH 2/3] Update script.js
---
script.js | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/script.js b/script.js
index 4f1a186..69a5234 100644
--- a/script.js
+++ b/script.js
@@ -336,12 +336,12 @@ async function search() {
localStorage.setItem('WACEDB_FILTERS', JSON.stringify(data.filters));
const allQuestions = data.questionsRaw[data.filters.subject];
-
+
data.questions = [];
allQuestions.forEach(function (question, index) {
let matches = true;
- // Check tags (all tags in "tags" must match)
+ // Check included tags (all tags in "tags" must match)
if (data.filters.tags.length > 0) {
matches = data.filters.tags.every(tag => question.tags.includes(tag));
}
@@ -376,7 +376,6 @@ async function search() {
renderPageResults();
}
-}
function renderPageResults() {
data.filters.resultsPerPage = parseInt(document.getElementById('lengthSelect').value);
From ce3a1dac789610ac1760b634b2ed62e1895d25b1 Mon Sep 17 00:00:00 2001
From: Poopthon <107613841+Poopthon@users.noreply.github.com>
Date: Tue, 31 Dec 2024 23:03:22 +0800
Subject: [PATCH 3/3] Update script.js
---
script.js | 66 +++++++++++++++++++++++++++----------------------------
1 file changed, 33 insertions(+), 33 deletions(-)
diff --git a/script.js b/script.js
index 69a5234..2130204 100644
--- a/script.js
+++ b/script.js
@@ -324,6 +324,25 @@ function packTags() {
else container.classList.remove('centred');
}
+async function setTags() {
+ const tagsList = data.tagsV2[data.filters.subject];
+ let tagsHtml = ``;
+ for (const [tagGroup, subTags] of Object.entries(tagsList)) {
+ tagsHtml += `${tagGroup}`;
+ if (subTags.length > 0) {
+ tagsHtml += ``;
+ }
+ tagsHtml += ``;
+ }
+ document.getElementById('tagsContainer').innerHTML = tagsHtml;
+ if (document.getElementById('modifyTags')) setModifyTags();
+ packTags();
+}
+
async function search() {
data.filters.year = document.getElementById('yearSelect').value;
data.filters.calculator = document.getElementById('calculatorSelect').value;
@@ -336,39 +355,21 @@ async function search() {
localStorage.setItem('WACEDB_FILTERS', JSON.stringify(data.filters));
const allQuestions = data.questionsRaw[data.filters.subject];
-
+
data.questions = [];
- allQuestions.forEach(function (question, index) {
- let matches = true;
-
- // Check included tags (all tags in "tags" must match)
- if (data.filters.tags.length > 0) {
- matches = data.filters.tags.every(tag => question.tags.includes(tag));
- }
-
- // Check excluded tags (none of the "nTags" should be present)
- if (matches && data.filters.nTags.some(tag => question.tags.includes(tag))) {
- matches = false;
- }
-
- // Check type
- if (matches && data.filters.type !== 'all') {
- matches = question.type === data.filters.type;
- }
-
- // Check year
- if (matches && data.filters.year !== 'all') {
- matches = question.year == data.filters.year;
- }
-
- // Check calculator
- if (matches && data.filters.calculator !== 'all') {
- matches = question.calculator === data.filters.calculator;
- }
-
- // Add the question if it matches all filters
- if (matches) {
- data.questions.push(allQuestions[index]);
+ allQuestions.forEach(function(question, index) {
+ if (data.filters.mode == 'untagged') {
+ if (question.tags.length == 0) data.questions.push(allQuestions[index]);
+ } else if ((data.filters.year == "all" || JSON.stringify(question.year) == data.filters.year) && (data.filters.source == 'all' || question.source == data.filters.source) && (data.filters.type == 'all' || question.type == data.filters.type || question.soruce == data.filters.type) && (data.filters.calculator == 'all' || (question.calculator == data.filters.calculator)) && !data.filters.nTags.some(tag => question.tags.includes(tag))) {
+ if (data.filters.mode == 'and') {
+ if (data.filters.tags.every(tag => question.tags.includes(tag))) {
+ data.questions.push(allQuestions[index]);
+ }
+ } else {
+ if (data.filters.tags.length == 0 || data.filters.tags.every(tag => question.tags.includes(tag))) {
+ data.questions.push(allQuestions[index]);
+ }
+ }
}
});
@@ -376,7 +377,6 @@ async function search() {
renderPageResults();
}
-
function renderPageResults() {
data.filters.resultsPerPage = parseInt(document.getElementById('lengthSelect').value);
const start = data.filters.currentPage * data.filters.resultsPerPage;