Skip to content

Commit

Permalink
assume tossup.question contains powermark bolding
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffrey-wu committed Apr 29, 2024
1 parent 7aa95c4 commit 0811a4e
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 36 deletions.
5 changes: 2 additions & 3 deletions client/admin/category-reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ function TossupCard({
const reason = tossup.reports.map(report => report.description).join('; ') || 'None given';
document.getElementById('report-reason').value = reason;
}
const powerParts = tossup.question.split('(*)');
return /*#__PURE__*/React.createElement("div", {
className: "card my-2"
}, /*#__PURE__*/React.createElement("div", {
Expand All @@ -68,7 +67,7 @@ function TossupCard({
className: "card-body"
}, /*#__PURE__*/React.createElement("span", {
dangerouslySetInnerHTML: {
__html: powerParts.length > 1 ? '<b>' + powerParts[0] + '(*)</b>' + powerParts[1] : tossup.question
__html: tossup.question
}
}), /*#__PURE__*/React.createElement("hr", {
className: "my-3"
Expand Down Expand Up @@ -241,4 +240,4 @@ document.getElementById('new-category').addEventListener('input', function () {
}
});
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render( /*#__PURE__*/React.createElement(Reports, null));
root.render( /*#__PURE__*/React.createElement(Reports, null));
6 changes: 1 addition & 5 deletions client/admin/category-reports.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ function TossupCard({ tossup }) {
document.getElementById('report-reason').value = reason;
}

const powerParts = tossup.question.split('(*)');

return (
<div className="card my-2">
<div className="card-header d-flex justify-content-between clickable" data-bs-toggle="collapse" data-bs-target={`#question-${_id}`}>
Expand All @@ -73,9 +71,7 @@ function TossupCard({ tossup }) {
</div>
<div className="card-container collapse show" id={`question-${_id}`}>
<div className="card-body">
<span dangerouslySetInnerHTML={{
__html: powerParts.length > 1 ? '<b>' + powerParts[0] + '(*)</b>' + powerParts[1] : tossup.question,
}}></span>
<span dangerouslySetInnerHTML={{ __html: tossup.question }}></span>
<hr className="my-3"></hr>
<div><b>ANSWER:</b> <span dangerouslySetInnerHTML={{ __html: tossup?.answer }}></span></div>
</div>
Expand Down
5 changes: 2 additions & 3 deletions client/database/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ function TossupCard({
console.error('Error:', error);
});
}
const powerParts = highlightedTossup.question.split('(*)');
return /*#__PURE__*/React.createElement("div", {
className: "card my-2"
}, /*#__PURE__*/React.createElement("div", {
Expand All @@ -338,7 +337,7 @@ function TossupCard({
}
}, /*#__PURE__*/React.createElement("span", {
dangerouslySetInnerHTML: {
__html: powerParts.length > 1 ? '<b>' + powerParts[0] + '(*)</b>' + powerParts[1] : highlightedTossup.question
__html: highlightedTossup.question
}
}), /*#__PURE__*/React.createElement("hr", {
className: "my-3"
Expand Down Expand Up @@ -1344,4 +1343,4 @@ function QueryForm() {
}));
}
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render( /*#__PURE__*/React.createElement(QueryForm, null));
root.render( /*#__PURE__*/React.createElement(QueryForm, null));
6 changes: 1 addition & 5 deletions client/database/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,6 @@ function TossupCard({ tossup, highlightedTossup, hideAnswerline, showCardFooter,
});
}

const powerParts = highlightedTossup.question.split('(*)');

return (
<div className="card my-2">
<div className="card-header d-flex justify-content-between">
Expand All @@ -475,9 +473,7 @@ function TossupCard({ tossup, highlightedTossup, hideAnswerline, showCardFooter,
</div>
<div className="card-container collapse show" id={`question-${_id}`}>
<div className="card-body" style={{ 'fontSize': `${fontSize}px` }}>
<span dangerouslySetInnerHTML={{
__html: powerParts.length > 1 ? '<b>' + powerParts[0] + '(*)</b>' + powerParts[1] : highlightedTossup.question,
}}></span>
<span dangerouslySetInnerHTML={{ __html: highlightedTossup.question }}></span>
<hr className="my-3"></hr>
<div>
<b>ANSWER:</b> <span dangerouslySetInnerHTML={{ __html: hideAnswerline ? '' : highlightedTossup?.answer }}></span>
Expand Down
12 changes: 1 addition & 11 deletions client/multiplayer/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,10 @@ socket.onmessage = function (event) {
break;

case 'reveal-answer': {
document.getElementById('question').innerHTML = tossup.question;
document.getElementById('answer').innerHTML = 'ANSWER: ' + data.answer;
document.getElementById('pause').disabled = true;
showNextButton();

question = document.getElementById('question').innerHTML;
if (powermarkPosition) {
question = question.slice(0, powermarkPosition) + '(*) ' + question.slice(powermarkPosition);
}
const powerParts = question.split('(*)');
if (powerParts.length > 1) {
document.getElementById('question').innerHTML = `<b>${powerParts[0]}(*)</b>${powerParts[1]}`;
} else {
document.getElementById('question').textContent = question;
}
break;
}

Expand Down
9 changes: 2 additions & 7 deletions client/singleplayer/tossups.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ async function advanceQuestion() {
} while (!isValidCategory(questions[questionNumber - 1], query.categories, query.subcategories));

if (Object.keys(questions[0]).length > 0) {
questionText = questions[questionNumber - 1].question;
questionText = questions[questionNumber - 1].question_sanitized;
questionTextSplit = questionText.split(' ').filter(word => word !== '');
document.getElementById('question-number-info').textContent = questionNumber;
}
Expand Down Expand Up @@ -469,13 +469,8 @@ function readQuestion(expectedReadTime) {


function revealQuestion() {
document.getElementById('question').innerHTML = questions[questionNumber - 1].question;
document.getElementById('answer').innerHTML = 'ANSWER: ' + questions[questionNumber - 1].answer;
let question = (document.getElementById('question').innerHTML);
if (powermarkPosition)
question = question.slice(0, powermarkPosition) + '(*) ' + question.slice(powermarkPosition);

const powerParts = (question + questionTextSplit.join(' ')).split('(*)');
document.getElementById('question').innerHTML = `${powerParts.length > 1 ? '<b>' + powerParts[0] + '(*)</b>' + powerParts[1] : powerParts[0]}`;

document.getElementById('buzz').disabled = true;
document.getElementById('buzz').textContent = 'Buzz';
Expand Down
3 changes: 1 addition & 2 deletions client/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ const createTossupCard = (function () {
questionCounter++;

const { question, answer, category, subcategory, alternate_subcategory, set, packet, number, _id } = tossup;
const powerParts = question.replace(/<\/?b>/g, '').split('(*)');

// append a card containing the question to the history element
const card = document.createElement('div');
Expand All @@ -186,7 +185,7 @@ const createTossupCard = (function () {
</div>
<div class="card-container collapse" id="question-${questionCounter}">
<div class="card-body">
${powerParts.length > 1 ? '<b>' + escapeHTML(powerParts[0]) + '(*)</b>' + escapeHTML(powerParts[1]) : escapeHTML(question)}
${question}
<a class="user-select-none" href="#" id="report-question-${_id}" data-bs-toggle="modal" data-bs-target="#report-question-modal">Report Question</a>
<hr></hr>
<div>ANSWER: ${answer}</div>
Expand Down

0 comments on commit 0811a4e

Please sign in to comment.