|
|
|
@ -47,6 +47,7 @@ def searchgen():
|
|
|
|
|
mpt.append(card)
|
|
|
|
|
else:
|
|
|
|
|
lpt.append(card)
|
|
|
|
|
previouscard = card
|
|
|
|
|
if not os.path.isdir("build/search"):
|
|
|
|
|
os.mkdir("build/search")
|
|
|
|
|
thefile = "build/search/index.html"
|
|
|
|
@ -96,7 +97,7 @@ def searchgen():
|
|
|
|
|
content.write(", ")
|
|
|
|
|
content.write("'" + card + "'")
|
|
|
|
|
precomma = True
|
|
|
|
|
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 = '<span class=\"sorttitle\">Wanted (high priority):</span> <span class=\"searchresults\">' + hpwfound.join(', ') + '</span>';\n } else {\n document.getElementById('hpwfound').innerHTML = '';\n };\n if ((mpwfound.length) > 0) {\n document.getElementById('mpwfound').innerHTML = '<span class=\"sorttitle\">Wanted (medium priority):</span> <span class=\"searchresults\">' + mpwfound.join(', ') + '</span>';\n } else {\n document.getElementById('mpwfound').innerHTML = '';\n };\n if ((lpwfound.length) > 0) {\n document.getElementById('lpwfound').innerHTML = '<span class=\"sorttitle\">Wanted (low priority):</span> <span class=\"searchresults\">' + lpwfound.join(', ') + '</span>';\n } else {\n document.getElementById('lpwfound').innerHTML = '';\n };\n if ((hptfound.length) > 0) {\n document.getElementById('hptfound').innerHTML = '<span class=\"sorttitle\">Will trade out for <a href=\"/wanted\">high priority cards</a> only:</span> <span class=\"searchresults\">' + hptfound.join(', ') + '</span>';\n } else {\n document.getElementById('hptfound').innerHTML = '';\n };\n if ((mptfound.length) > 0) {\n document.getElementById('mptfound').innerHTML = '<span class=\"sorttitle\">Will trade out for <a href=\"/wanted\">high or medium priority cards</a>:</span> <span class=\"searchresults\">' + mptfound.join(', ') + '</span>';\n } else {\n document.getElementById('mptfound').innerHTML = '';\n };\n if ((lptfound.length) > 0) {\n document.getElementById('lptfound').innerHTML = '<span class=\"sorttitle\">Will trade out for <a href=\"/wanted\">any wanted card</a>:</span> <span class=\"searchresults\">' + lptfound.join(', ') + '</span>';\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</script>\n </main>\n </body>\n</html>")
|
|
|
|
|
content.write("];\n const searchstring = document.getElementById('cardinput').value;\n const searcharray = searchstring.replaceAll(' ','').replaceAll('\\n',',').replaceAll('\\r',',').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 = '<span class=\"sorttitle\">Wanted (high priority):</span> <span class=\"searchresults\">' + hpwfound.join(', ') + '</span>';\n } else {\n document.getElementById('hpwfound').innerHTML = '';\n };\n if ((mpwfound.length) > 0) {\n document.getElementById('mpwfound').innerHTML = '<span class=\"sorttitle\">Wanted (medium priority):</span> <span class=\"searchresults\">' + mpwfound.join(', ') + '</span>';\n } else {\n document.getElementById('mpwfound').innerHTML = '';\n };\n if ((lpwfound.length) > 0) {\n document.getElementById('lpwfound').innerHTML = '<span class=\"sorttitle\">Wanted (low priority):</span> <span class=\"searchresults\">' + lpwfound.join(', ') + '</span>';\n } else {\n document.getElementById('lpwfound').innerHTML = '';\n };\n if ((hptfound.length) > 0) {\n document.getElementById('hptfound').innerHTML = '<span class=\"sorttitle\">Will trade out for <a href=\"/wanted\">high priority cards</a> only:</span> <span class=\"searchresults\">' + hptfound.join(', ') + '</span>';\n } else {\n document.getElementById('hptfound').innerHTML = '';\n };\n if ((mptfound.length) > 0) {\n document.getElementById('mptfound').innerHTML = '<span class=\"sorttitle\">Will trade out for <a href=\"/wanted\">high or medium priority cards</a>:</span> <span class=\"searchresults\">' + mptfound.join(', ') + '</span>';\n } else {\n document.getElementById('mptfound').innerHTML = '';\n };\n if ((lptfound.length) > 0) {\n document.getElementById('lptfound').innerHTML = '<span class=\"sorttitle\">Will trade out for <a href=\"/wanted\">any wanted card</a>:</span> <span class=\"searchresults\">' + lptfound.join(', ') + '</span>';\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</script>\n </main>\n </body>\n</html>")
|
|
|
|
|
content.close()
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|