diff --git a/searchgen.py b/searchgen.py index 8b23999..0d78207 100644 --- a/searchgen.py +++ b/searchgen.py @@ -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 = '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.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 = '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__":