From 424c8a6f76119da6fe9b6d97f7d5712389d8f7d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?tr=C3=A9meur?= Date: Fri, 8 Nov 2024 18:03:09 +0000 Subject: [PATCH] Minimal styling for search page, allow search for a whole deck, allow case-insensitive search --- build/style.css | 4 ++++ searchgen.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/build/style.css b/build/style.css index eb0be8c..3c21706 100644 --- a/build/style.css +++ b/build/style.css @@ -558,3 +558,7 @@ form * { span.sorttitle { font-weight: bold; } + +span.searchresults { + font-family: monospace; +} diff --git a/searchgen.py b/searchgen.py index adf53df..8b23999 100644 --- a/searchgen.py +++ b/searchgen.py @@ -54,7 +54,7 @@ def searchgen(): os.remove(thefile) skel.headerwrite(thefile,"search") content = open(thefile,"a") - content.write("

card search

\n
\n \n \n \n
\n

\n

\n

\n

\n

\n

\n

\n\n \n \n") + content.write("];\n const searchstring = document.getElementById('cardinput').value;\n const searcharray = searchstring.replaceAll(' ','').toLowerCase().split(',');\n const hpwfound = [];\n const mpwfound = [];\n const lpwfound = [];\n const hptfound = [];\n const mptfound = [];\n const lptfound = [];\n for (const element of searcharray) {\n let cardend = element.substring(element.length, element.length - 2);\n if (!(thecards.includes(cardend))) {\n for (const ending of thecards) {\n searcharray.push(element + ending);\n };\n };\n };\n for (const element of searcharray) {\n if (hpw.includes(element)) {\n hpwfound.push(element);\n } else if (mpw.includes(element)) {\n mpwfound.push(element);\n } else if (lpw.includes(element)) {\n lpwfound.push(element);\n } else if (hpt.includes(element)) {\n hptfound.push(element);\n } else if (mpt.includes(element)) {\n mptfound.push(element);\n } else if (lpt.includes(element)) {\n lptfound.push(element);\n };\n };\n if ((hpwfound.length) > 0) {\n document.getElementById('hpwfound').innerHTML = 'Wanted (high priority): ' + hpwfound.join(', ') + '';\n } else {\n document.getElementById('hpwfound').innerHTML = '';\n };\n if ((mpwfound.length) > 0) {\n document.getElementById('mpwfound').innerHTML = 'Wanted (medium priority): ' + mpwfound.join(', ') + '';\n } else {\n document.getElementById('mpwfound').innerHTML = '';\n };\n if ((lpwfound.length) > 0) {\n document.getElementById('lpwfound').innerHTML = 'Wanted (low priority): ' + lpwfound.join(', ') + '';\n } else {\n document.getElementById('lpwfound').innerHTML = '';\n };\n if ((hptfound.length) > 0) {\n document.getElementById('hptfound').innerHTML = 'Will trade out for high priority cards only: ' + hptfound.join(', ') + '';\n } else {\n document.getElementById('hptfound').innerHTML = '';\n };\n if ((mptfound.length) > 0) {\n document.getElementById('mptfound').innerHTML = 'Will trade out for high or medium priority cards: ' + mptfound.join(', ') + '';\n } else {\n document.getElementById('mptfound').innerHTML = '';\n };\n if ((lptfound.length) > 0) {\n document.getElementById('lptfound').innerHTML = 'Will trade out for any wanted card: ' + lptfound.join(', ') + '';\n } else {\n document.getElementById('lptfound').innerHTML = '';\n };\n if ((hpwfound.length) + (mpwfound.length) + (lpwfound.length) + (hptfound.length) + (mptfound.length) + (lptfound.length) == 0) {\n document.getElementById('nothing').innerHTML = 'No results';\n } else {\n document.getElementById('nothing').innerHTML = '';\n }\n }\n\n \n \n") content.close() if __name__ == "__main__":