diff --git a/client/database/index.js b/client/database/index.js index 743a2f732..705fe2859 100644 --- a/client/database/index.js +++ b/client/database/index.js @@ -153,6 +153,7 @@ function highlightBonusQuery({ function TossupCard({ tossup, highlightedTossup, + hideAnswerline, showCardFooter, fontSize = 16 }) { @@ -160,13 +161,18 @@ function TossupCard({ const packetName = tossup.packet.name; function clickToCopy() { let textdata = `${tossup.question}\nANSWER: ${tossup.answer}`; + let tag = ''; if (tossup.category && tossup.subcategory && tossup.category !== tossup.subcategory) { - textdata += `\n<${tossup.category} / ${tossup.subcategory}>`; + tag += `${tossup.category} / ${tossup.subcategory}`; } else if (tossup.category) { - textdata += `\n<${tossup.category}>`; + tag += `${tossup.category}`; } else if (tossup.subcategory) { - textdata += `\n<${tossup.subcategory}>`; + tag += `${tossup.subcategory}`; } + if (tossup.alternate_subcategory) { + tag += ` (${tossup.alternate_subcategory})`; + } + textdata += `\n<${tag}>`; navigator.clipboard.writeText(textdata); const toast = new bootstrap.Toast(document.getElementById('clipboard-toast')); toast.show(); @@ -262,7 +268,7 @@ function TossupCard({ className: "my-3" }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("b", null, "ANSWER:"), " ", /*#__PURE__*/React.createElement("span", { dangerouslySetInnerHTML: { - __html: highlightedTossup?.formatted_answer ?? highlightedTossup.answer + __html: hideAnswerline ? '' : highlightedTossup?.formatted_answer ?? highlightedTossup.answer } }))), /*#__PURE__*/React.createElement("div", { className: `card-footer clickable ${!showCardFooter && 'd-none'}`, @@ -284,6 +290,7 @@ function TossupCard({ function BonusCard({ bonus, highlightedBonus, + hideAnswerlines, showCardFooter, fontSize = 16 }) { @@ -300,13 +307,18 @@ function BonusCard({ textdata += `${getBonusPartLabel(bonus, i)} ${bonus.parts[i]}\n`; textdata += `ANSWER: ${bonus.answers[i]}\n`; } + let tag = ''; if (bonus.category && bonus.subcategory && bonus.category !== bonus.subcategory) { - textdata += `<${bonus.category} / ${bonus.subcategory}>`; + tag += `${bonus.category} / ${bonus.subcategory}`; } else if (bonus.category) { - textdata += `<${bonus.category}>`; + tag += `${bonus.category}`; } else if (bonus.subcategory) { - textdata += `<${bonus.subcategory}>`; + tag += `${bonus.subcategory}`; + } + if (bonus.alternate_subcategory) { + tag += ` (${bonus.alternate_subcategory})`; } + textdata += `<${tag}>`; navigator.clipboard.writeText(textdata); const toast = new bootstrap.Toast(document.getElementById('clipboard-toast')); toast.show(); @@ -404,7 +416,7 @@ function BonusCard({ } })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("b", null, "ANSWER: "), /*#__PURE__*/React.createElement("span", { dangerouslySetInnerHTML: { - __html: (highlightedBonus?.formatted_answers ?? highlightedBonus.answers)[i] + __html: hideAnswerlines ? '' : (highlightedBonus?.formatted_answers ?? highlightedBonus.answers)[i] } }))))), /*#__PURE__*/React.createElement("div", { className: `card-footer clickable ${!showCardFooter && 'd-none'}`, @@ -565,6 +577,7 @@ function QueryForm() { const [diacritics, setDiacritics] = React.useState(false); const [exactPhrase, setExactPhrase] = React.useState(false); const [powermarkOnly, setPowermarkOnly] = React.useState(false); + const [hideAnswerlines, setHideAnswerlines] = React.useState(false); const [showCardFooters, setShowCardFooters] = React.useState(true); const [currentlySearching, setCurrentlySearching] = React.useState(false); let [tossupPaginationNumber, setTossupPaginationNumber] = React.useState(1); @@ -748,6 +761,7 @@ function QueryForm() { key: i, tossup: tossups[i], highlightedTossup: highlightedTossups[i], + hideAnswerline: hideAnswerlines, showCardFooter: showCardFooters, fontSize: fontSize })); @@ -758,6 +772,7 @@ function QueryForm() { key: i, bonus: bonuses[i], highlightedBonus: highlightedBonuses[i], + hideAnswerlines: hideAnswerlines, showCardFooter: showCardFooters, fontSize: fontSize })); @@ -1022,6 +1037,20 @@ function QueryForm() { htmlFor: "toggle-powermark-only" }, "Powermarked tossups only")), /*#__PURE__*/React.createElement("div", { className: "form-check form-switch" + }, /*#__PURE__*/React.createElement("input", { + className: "form-check-input", + type: "checkbox", + role: "switch", + id: "toggle-hide-answerlines", + checked: hideAnswerlines, + onChange: () => { + setHideAnswerlines(!hideAnswerlines); + } + }), /*#__PURE__*/React.createElement("label", { + className: "form-check-label", + htmlFor: "toggle-hide-answerlines" + }, "Hide answerlines")), /*#__PURE__*/React.createElement("div", { + className: "form-check form-switch" }, /*#__PURE__*/React.createElement("input", { className: "form-check-input", type: "checkbox", diff --git a/client/database/index.jsx b/client/database/index.jsx index 55a049e1e..b48f484d8 100644 --- a/client/database/index.jsx +++ b/client/database/index.jsx @@ -275,21 +275,28 @@ function highlightBonusQuery({ bonus, regExp, searchType = 'all', ignoreWordOrde } -function TossupCard({ tossup, highlightedTossup, showCardFooter, fontSize = 16 }) { +function TossupCard({ tossup, highlightedTossup, hideAnswerline, showCardFooter, fontSize = 16 }) { const _id = tossup._id; const packetName = tossup.packet.name; function clickToCopy() { let textdata = `${tossup.question}\nANSWER: ${tossup.answer}`; + let tag = ''; if (tossup.category && tossup.subcategory && tossup.category !== tossup.subcategory) { - textdata += `\n<${tossup.category} / ${tossup.subcategory}>`; + tag += `${tossup.category} / ${tossup.subcategory}`; } else if (tossup.category) { - textdata += `\n<${tossup.category}>`; + tag += `${tossup.category}`; } else if (tossup.subcategory) { - textdata += `\n<${tossup.subcategory}>`; + tag += `${tossup.subcategory}`; } + if (tossup.alternate_subcategory) { + tag += ` (${tossup.alternate_subcategory})`; + } + + textdata += `\n<${tag}>`; + navigator.clipboard.writeText(textdata); const toast = new bootstrap.Toast(document.getElementById('clipboard-toast')); @@ -382,7 +389,7 @@ function TossupCard({ tossup, highlightedTossup, showCardFooter, fontSize = 16 }
ANSWER:
@@ -400,7 +407,7 @@ function TossupCard({ tossup, highlightedTossup, showCardFooter, fontSize = 16 } } -function BonusCard({ bonus, highlightedBonus, showCardFooter, fontSize = 16 }) { +function BonusCard({ bonus, highlightedBonus, hideAnswerlines, showCardFooter, fontSize = 16 }) { const _id = bonus._id; const packetName = bonus.packet.name; const bonusLength = bonus.parts.length; @@ -417,14 +424,22 @@ function BonusCard({ bonus, highlightedBonus, showCardFooter, fontSize = 16 }) { textdata += `ANSWER: ${bonus.answers[i]}\n`; } + let tag = ''; + if (bonus.category && bonus.subcategory && bonus.category !== bonus.subcategory) { - textdata += `<${bonus.category} / ${bonus.subcategory}>`; + tag += `${bonus.category} / ${bonus.subcategory}`; } else if (bonus.category) { - textdata += `<${bonus.category}>`; + tag += `${bonus.category}`; } else if (bonus.subcategory) { - textdata += `<${bonus.subcategory}>`; + tag += `${bonus.subcategory}`; } + if (bonus.alternate_subcategory) { + tag += ` (${bonus.alternate_subcategory})`; + } + + textdata += `<${tag}>`; + navigator.clipboard.writeText(textdata); const toast = new bootstrap.Toast(document.getElementById('clipboard-toast')); @@ -518,7 +533,9 @@ function BonusCard({ bonus, highlightedBonus, showCardFooter, fontSize = 16 }) {

ANSWER: - +
, )} @@ -633,6 +650,7 @@ function QueryForm() { const [diacritics, setDiacritics] = React.useState(false); const [exactPhrase, setExactPhrase] = React.useState(false); const [powermarkOnly, setPowermarkOnly] = React.useState(false); + const [hideAnswerlines, setHideAnswerlines] = React.useState(false); const [showCardFooters, setShowCardFooters] = React.useState(true); const [currentlySearching, setCurrentlySearching] = React.useState(false); @@ -824,12 +842,12 @@ function QueryForm() { const tossupCards = []; for (let i = 0; i < highlightedTossups.length; i++) { - tossupCards.push(); + tossupCards.push(); } const bonusCards = []; for (let i = 0; i < highlightedBonuses.length; i++) { - bonusCards.push(); + bonusCards.push(); } React.useEffect(async () => { @@ -945,6 +963,10 @@ function QueryForm() { {setPowermarkOnly(!powermarkOnly);}} /> +
+ {setHideAnswerlines(!hideAnswerlines);}} /> + +
{setShowCardFooters(!showCardFooters);}} />