// Name That Box Score – global initializer for WordPress
(function () {
// Question data
var NTBS_QUESTIONS = [
// EASY
{
stat: “71 PTS, 10 REB, 5 AST vs Clippers (Apr. 24, 1994)”,
difficulty: “easy”,
answer: “David Robinson”,
choices: [“David Robinson”, “Shaquille O’Neal”, “Hakeem Olajuwon”, “Karl Malone”]
},
{
stat: “81 PTS, 6 REB, 2 AST vs Raptors (Jan. 22, 2006)”,
difficulty: “easy”,
answer: “Kobe Bryant”,
choices: [“Kobe Bryant”, “LeBron James”, “Allen Iverson”, “Tracy McGrady”]
},
{
stat: “100 PTS, 25 REB vs Knicks (Mar. 2, 1962)”,
difficulty: “easy”,
answer: “Wilt Chamberlain”,
choices: [“Wilt Chamberlain”, “Bill Russell”, “Kareem Abdul-Jabbar”, “Elgin Baylor”]
},
{
stat: “60 PTS, 7 REB, 10 AST vs Jazz (Apr. 13, 2016)”,
difficulty: “easy”,
answer: “Kobe Bryant”,
choices: [“Kobe Bryant”, “Stephen Curry”, “Damian Lillard”, “James Harden”]
},
{
stat: “62 PTS, 8 REB, 4 AST vs Trail Blazers (Jan. 3, 2021)”,
difficulty: “easy”,
answer: “Stephen Curry”,
choices: [“Stephen Curry”, “Klay Thompson”, “Damian Lillard”, “Devin Booker”]
},
// MEDIUM
{
stat: “30 PTS, 20 REB, 10 AST vs Knicks (Jan. 4, 2020)”,
difficulty: “medium”,
answer: “Giannis Antetokounmpo”,
choices: [“Giannis Antetokounmpo”, “Nikola Jokić”, “Luka Dončić”, “Joel Embiid”]
},
{
stat: “37 PTS in a quarter vs Kings (Jan. 23, 2015)”,
difficulty: “medium”,
answer: “Klay Thompson”,
choices: [“Klay Thompson”, “Stephen Curry”, “James Harden”, “Paul George”]
},
{
stat: “55 PTS, 11 REB, 7 AST vs Bucks (Feb. 3, 2009)”,
difficulty: “medium”,
answer: “LeBron James”,
choices: [“LeBron James”, “Dwyane Wade”, “Carmelo Anthony”, “Dirk Nowitzki”]
},
{
stat: “70 PTS, 8 REB, 6 AST vs Celtics (Mar. 24, 2017)”,
difficulty: “medium”,
answer: “Devin Booker”,
choices: [“Devin Booker”, “Damian Lillard”, “Bradley Beal”, “Kyrie Irving”]
},
{
stat: “53 PTS, 18 REB, 5 BLK vs Hornets (Mar. 20, 1990)”,
difficulty: “medium”,
answer: “Michael Jordan”,
choices: [“Michael Jordan”, “Patrick Ewing”, “Hakeem Olajuwon”, “David Robinson”]
},
// HARD
{
stat: “20 PTS, 20 REB, 20 AST vs Nets (Apr. 2, 2019)”,
difficulty: “hard”,
answer: “Russell Westbrook”,
choices: [“Russell Westbrook”, “Magic Johnson”, “Oscar Robertson”, “Chris Paul”]
},
{
stat: “40 PTS, 24 REB, 13 AST vs Lakers (Jan. 13, 1962)”,
difficulty: “hard”,
answer: “Oscar Robertson”,
choices: [“Oscar Robertson”, “Wilt Chamberlain”, “Elgin Baylor”, “Jerry West”]
},
{
stat: “52 PTS, 9 REB, 7 AST vs Bulls (Mar. 7, 2017)”,
difficulty: “hard”,
answer: “Damian Lillard”,
choices: [“Damian Lillard”, “Kyrie Irving”, “John Wall”, “Jimmy Butler”]
},
{
stat: “60 PTS, 11 REB, 10 AST vs Knicks (Jan. 26, 2017)”,
difficulty: “hard”,
answer: “James Harden”,
choices: [“James Harden”, “Russell Westbrook”, “Kobe Bryant”, “Luka Dončić”]
},
{
stat: “51 PTS, 8 REB, 12 AST vs Mavericks (Dec. 30, 2022)”,
difficulty: “hard”,
answer: “Luka Dončić”,
choices: [“Luka Dončić”, “Ja Morant”, “Trae Young”, “Donovan Mitchell”]
},
// INSANE
{
stat: “53 PTS, 19 REB, 17 AST vs Magic (Jan. 15, 2009)”,
difficulty: “insane”,
answer: “LeBron James”,
choices: [“LeBron James”, “Nikola Jokić”, “Tracy McGrady”, “Grant Hill”]
},
{
stat: “51 PTS, 22 REB, 7 AST vs Pistons (Jan. 21, 1962)”,
difficulty: “insane”,
answer: “Wilt Chamberlain”,
choices: [“Wilt Chamberlain”, “Bill Russell”, “Jerry Lucas”, “Bob Pettit”]
},
{
stat: “38 PTS, 18 REB, 13 AST, 5 STL vs Spurs (Feb. 6, 2010)”,
difficulty: “insane”,
answer: “LeBron James”,
choices: [“LeBron James”, “Dwyane Wade”, “Tracy McGrady”, “Kobe Bryant”]
},
{
stat: “41 PTS, 20 REB, 12 AST vs Knicks (Dec. 26, 2018)”,
difficulty: “insane”,
answer: “Giannis Antetokounmpo”,
choices: [“Giannis Antetokounmpo”, “Anthony Davis”, “Joel Embiid”, “DeMarcus Cousins”]
},
{
stat: “47 PTS, 18 REB, 5 AST, 5 BLK vs Nets (Nov. 15, 2000)”,
difficulty: “insane”,
answer: “Shaquille O’Neal”,
choices: [“Shaquille O’Neal”, “Tim Duncan”, “Kevin Garnett”, “Chris Webber”]
}
];
function shuffle(array) {
for (var i = array.length – 1; i > 0; i–) {
var j = Math.floor(Math.random() * (i + 1));
var t = array[i];
array[i] = array[j];
array[j] = t;
}
return array;
}
function initBoxScoreQuiz() {
var root = document.getElementById(“ntbs-quiz”);
if (!root || root.getAttribute(“data-ntbs-ready”) === “1”) return;
root.setAttribute(“data-ntbs-ready”, “1”);
var statEl = document.getElementById(“ntbs-statline”);
var diffEl = document.getElementById(“ntbs-diff”);
var optsEl = document.getElementById(“ntbs-options”);
var qnumEl = document.getElementById(“ntbs-qnum”);
var scoreEl = document.getElementById(“ntbs-score”);
var streakEl = document.getElementById(“ntbs-streak”);
var nextBtn = document.getElementById(“ntbs-next”);
var resetBtn = document.getElementById(“ntbs-reset”);
var order = shuffle(NTBS_QUESTIONS.slice());
var state = { index: 0, score: 0, streak: 0, locked: false };
function setDifficultyBadge(diff) {
diffEl.className = “ntbs-difficulty”;
var label = “Easy”;
if (diff === “medium”) {
diffEl.classList.add(“ntbs-medium”);
label = “Medium”;
} else if (diff === “hard”) {
diffEl.classList.add(“ntbs-hard”);
label = “Hard”;
} else if (diff === “insane”) {
diffEl.classList.add(“ntbs-insane”);
label = “Insane”;
}
diffEl.textContent = label.toUpperCase();
}
function renderQuestion() {
var q = order[state.index];
statEl.textContent = q.stat;
setDifficultyBadge(q.difficulty);
qnumEl.textContent = (state.index + 1) + ” / ” + order.length;
scoreEl.textContent = state.score;
streakEl.textContent = “x” + state.streak;
optsEl.innerHTML = “”;
var choices = shuffle(q.choices.slice());
for (var i = 0; i < choices.length; i++) {
(function(choice, idx) {
var li = document.createElement("li");
li.className = "ntbs-option";
li.setAttribute("data-choice", choice);
var left = document.createElement("div");
left.textContent = choice;
var right = document.createElement("div");
right.className = "ntbs-option-label";
right.textContent = String.fromCharCode(65 + idx); // A,B,C,D
li.appendChild(left);
li.appendChild(right);
li.addEventListener("click", function () {
if (state.locked) return;
state.locked = true;
if (choice === q.answer) {
li.classList.add("correct");
state.score += 1;
state.streak += 1;
} else {
li.classList.add("wrong");
state.streak = 0;
// highlight the real answer
var kids = optsEl.children;
for (var k = 0; k < kids.length; k++) {
if (kids[k].getAttribute("data-choice") === q.answer) {
kids[k].classList.add("correct");
}
}
}
scoreEl.textContent = state.score;
streakEl.textContent = "x" + state.streak;
});
optsEl.appendChild(li);
})(choices[i], i);
}
state.locked = false;
nextBtn.disabled = false;
}
function nextQuestion() {
if (state.index < order.length - 1) {
state.index += 1;
renderQuestion();
} else {
nextBtn.disabled = true;
}
}
function resetQuiz() {
order = shuffle(NTBS_QUESTIONS.slice());
state.index = 0;
state.score = 0;
state.streak = 0;
state.locked = false;
renderQuestion();
}
nextBtn.addEventListener("click", nextQuestion);
resetBtn.addEventListener("click", resetQuiz);
renderQuestion();
}
// Make sure it runs both on normal load and when WP does partial loads
function tryInit() {
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", initBoxScoreQuiz);
} else {
initBoxScoreQuiz();
}
}
tryInit();
// If your theme uses AJAX navigation (rare), re-init when URL changes
window.addEventListener("pageshow", function () {
initBoxScoreQuiz();
});
})();
You must be logged in to post a comment Login