← Back to the game

Slides version

Three rounds built from the same study guide. Paste this into Apps Script to generate the deck.

  1. In Google Slides, open Extensions > Apps Script.
  2. Delete any existing code, paste the script below, and click Save.
  3. Reload your Slides tab, then choose Jeopardy > 1. Build game.
  4. Choose Jeopardy > 2. Open host controller. The sidebar holds the clue, the team scores and both boards: click a dollar amount, Show answer, then a team's + or - to score it. The amount blanks out and the board returns, and Next round / Final Jeopardy appear as each round fills up.

Script

/**
 * JEOPARDY for Google Slides
 * Topic: Forces, Motion, Inertia & Weight (8th Grade Physical Science)
 *
 * HOW TO USE
 * 1. In Google Slides: Extensions > Apps Script. Delete any code, paste this, Save.
 * 2. Reload the Slides tab. A "Jeopardy" menu appears.
 * 3. Jeopardy > 1. Build game   (approve permissions the first time)
 * 4. Jeopardy > 2. Open host controller. Keep the sidebar open while you host.
 *
 * HOSTING FROM THE SIDEBAR
 * - Click a dollar amount: the clue slide comes up.
 * - "Show answer" brings up the answer slide. "No answer" blanks the amount.
 * - Click a team + or - to score the clue: the amount blanks and the board returns.
 * - When a round is finished the sidebar offers Next round / Final Jeopardy.
 * - Reset board (sidebar or menu) brings every dollar amount back.
 * (Google Slides cannot run scripts in Present mode, so the sidebar drives the deck.
 * The links built into the slides still work in Present mode.)
 */

var BLUE = '#0A1FA8';
var NAVY = '#060B6B';
var GOLD = '#FFCC00';

var ROUNDS = [
  {
    "name": "JEOPARDY!",
    "values": [
      100,
      200,
      300,
      400
    ],
    "cats": [
      {
        "name": "Key Terms",
        "clues": [
          [
            "A push or a pull on an object.",
            "What is a force?"
          ],
          [
            "The amount of matter in an object, measured in kilograms.",
            "What is mass?"
          ],
          [
            "Forces that do not cancel out and cause a change in motion.",
            "What are unbalanced forces?"
          ],
          [
            "Any change in motion: speeding up, slowing down, or changing direction.",
            "What is acceleration?"
          ]
        ]
      },
      {
        "name": "Inertia",
        "clues": [
          [
            "The tendency of an object to resist a change in its motion.",
            "What is inertia?"
          ],
          [
            "Which has more inertia: a 50 kg skater or a 100 kg skater?",
            "Who is the 100 kg skater? (greater mass = greater inertia)"
          ],
          [
            "A passenger lunges forward against the seat belt when a car brakes suddenly because of this.",
            "What is inertia?"
          ],
          [
            "True or False: Inertia is a force that pushes objects forward.",
            "What is False? Inertia is a tendency to resist changes in motion, not a force."
          ]
        ]
      },
      {
        "name": "Friction",
        "clues": [
          [
            "Friction does this to motion.",
            "What is opposes (counters) it?"
          ],
          [
            "Friction occurs whenever two of these touch.",
            "What are surfaces?"
          ],
          [
            "This type of friction acts between a skateboard's wheels and the pavement.",
            "What is rolling friction?"
          ],
          [
            "True or False: With no friction on a smooth, flat surface, a moving skateboard would eventually stop because of inertia.",
            "What is False? Inertia keeps it rolling without an unbalanced force."
          ]
        ]
      },
      {
        "name": "Newton's 2nd Law",
        "clues": [
          [
            "The formula for net force.",
            "What is F = m x a?"
          ],
          [
            "Acceleration equals net force divided by this.",
            "What is mass?"
          ],
          [
            "Doubling the net force on a skateboard while mass stays the same does this to its acceleration.",
            "What is it doubles? (direct relationship)"
          ],
          [
            "Two skaters push with the same force, but Skater A has twice the mass of Skater B. A's acceleration compared to B's.",
            "What is half as much? (inverse relationship)"
          ]
        ]
      }
    ]
  },
  {
    "name": "DOUBLE JEOPARDY!",
    "values": [
      200,
      400,
      600,
      800
    ],
    "cats": [
      {
        "name": "Weight & Gravity",
        "clues": [
          [
            "The SI unit for weight and force.",
            "What is the Newton (N)?"
          ],
          [
            "Earth's acceleration due to gravity, approximately.",
            "What is 9.8 m/s squared?"
          ],
          [
            "The approximate acceleration due to gravity on the moon.",
            "What is 1.6 m/s squared?"
          ],
          [
            "On the moon, a rock's mass stays the same but its weight is about this fraction of its Earth weight.",
            "What is one-sixth?"
          ]
        ]
      },
      {
        "name": "Relationships",
        "clues": [
          [
            "When one variable increases, the other increases too.",
            "What is a direct relationship?"
          ],
          [
            "When one variable increases, the other decreases.",
            "What is an inverse relationship?"
          ],
          [
            "Mass and acceleration, for a constant force, have this type of relationship.",
            "What is an inverse relationship?"
          ],
          [
            "Weight and mass on Earth have this relationship, so doubling mass doubles weight.",
            "What is a direct relationship?"
          ]
        ]
      },
      {
        "name": "Do the Math",
        "clues": [
          [
            "The net force on a 50 kg skater and board accelerating at 0.8 m/s squared.",
            "What is 40 N?"
          ],
          [
            "The acceleration of a 50 kg object acted on by a net force of 25 N.",
            "What is 0.5 m/s squared?"
          ],
          [
            "The weight in Newtons of a 52 kg person on Earth (g = 9.8 m/s squared).",
            "What is 509.6 N (about 510 N)?"
          ],
          [
            "That 509.6 N weight in pounds, to the nearest whole number (1 N = 0.225 lb).",
            "What is 115 pounds?"
          ]
        ]
      },
      {
        "name": "Formulas & Units",
        "clues": [
          [
            "One Newton equals this many pounds.",
            "What is 0.225?"
          ],
          [
            "The formula for weight.",
            "What is W = m x g?"
          ],
          [
            "Dividing Newtons by kilograms leaves these units for acceleration.",
            "What is m/s squared?"
          ],
          [
            "To convert Newtons to pounds, you do this.",
            "What is multiply by 0.225?"
          ]
        ]
      },
      {
        "name": "Skate Park",
        "clues": [
          [
            "A skater slowing down by dragging a foot on the pavement is an example of this.",
            "What is acceleration?"
          ],
          [
            "The force pulling a skateboard back down to the ground when it is mid-air.",
            "What is gravity?"
          ],
          [
            "The natural unbalanced force that would eventually stop a rolling skateboard.",
            "What is rolling friction?"
          ],
          [
            "Newton's first law says a moving object keeps its speed and direction unless acted on by this.",
            "What is an unbalanced force?"
          ]
        ]
      }
    ]
  }
];

var FINAL = {
  "category": "Skate Park Physics",
  "clue": "A 52 kg skater visits the moon, where g is 1.6 m/s squared. Using W = m x g, this is the skater's weight in Newtons.",
  "answer": "What is 83.2 N? (mass stays 52 kg, but weight is much less)"
};

/* ---------- Helpers ---------- */

function styleShape(sh, text, size, color, bold) {
  var tr = sh.getText();
  tr.setText(text);
  tr.getTextStyle().setFontFamily('Arial').setFontSize(size).setForegroundColor(color).setBold(bold);
  tr.getParagraphStyle().setParagraphAlignment(SlidesApp.ParagraphAlignment.CENTER);
  sh.setContentAlignment(SlidesApp.ContentAlignment.MIDDLE);
  return sh;
}

function newSlide(pres, color) {
  var s = pres.appendSlide(SlidesApp.PredefinedLayout.BLANK);
  s.getBackground().setSolidFill(color);
  return s;
}

function label(slide, text, l, t, w, h, size, color, bold) {
  return styleShape(slide.insertTextBox(text, l, t, w, h), text, size, color, bold);
}

function box(slide, l, t, w, h, fill, text, size, color, bold) {
  var sh = slide.insertShape(SlidesApp.ShapeType.RECTANGLE, l, t, w, h);
  sh.getFill().setSolidFill(fill);
  sh.getBorder().getLineFill().setSolidFill('#000000');
  sh.getBorder().setWeight(2);
  return styleShape(sh, text, size, color, bold);
}

function loadMap() {
  var raw = PropertiesService.getDocumentProperties().getProperty('JEO');
  if (!raw) { throw new Error('Run Jeopardy > 1. Build game first.'); }
  return JSON.parse(raw);
}

function cellShape(pres, rec, cell) {
  return pres.getSlideById(rec.boardId).getPageElementById(cell.shape).asShape();
}

function paintCell(sh, lab, clueSlide) {
  styleShape(sh, lab, 30, GOLD, true);
  sh.setLinkSlide(clueSlide);
}

function cellValue(cell) {
  return parseInt(String(cell.label).replace(/[^0-9]/g, ''), 10) || 0;
}

/* ---------- Where the host is in the deck ---------- */

function getPos() {
  var raw = PropertiesService.getDocumentProperties().getProperty('JEO_POS');
  if (!raw) { return { kind: 'board', r: 0 }; }
  try { return JSON.parse(raw); } catch (e) { return { kind: 'board', r: 0 }; }
}

function setPos(pos) {
  PropertiesService.getDocumentProperties().setProperty('JEO_POS', JSON.stringify(pos));
  return pos;
}


/* ---------- Build ---------- */

function buildGame() {
  var pres = SlidesApp.getActivePresentation();
  var W = pres.getPageWidth();
  var H = pres.getPageHeight();
  var old = pres.getSlides();
  var map = { rounds: [], final: {} };

  var t = newSlide(pres, NAVY);
  label(t, 'JEOPARDY!', 0, H * 0.25, W, 90, 64, GOLD, true);
  label(t, 'Forces, Motion, Inertia & Weight', 0, H * 0.55, W, 40, 24, '#FFFFFF', false);

  ROUNDS.forEach(function (rd) {
    var board = newSlide(pres, NAVY);
    label(board, rd.name, 0, 2, W, 30, 18, GOLD, true);
    var gw = (W - 20) / rd.cats.length;
    var gh = (H - 44) / (rd.values.length + 1);
    var rec = { name: rd.name, boardId: board.getObjectId(), cats: [] };

    rd.cats.forEach(function (cat, c) {
      var left = 10 + c * gw;
      box(board, left, 34, gw - 4, gh - 4, BLUE, cat.name.toUpperCase(), 13, '#FFFFFF', true);
      var crec = { name: cat.name, cells: [] };

      rd.values.forEach(function (val, i) {
        var lab = '$' + val;
        var q = cat.clues[i];
        var cell = box(board, left, 34 + (i + 1) * gh, gw - 4, gh - 4, BLUE, lab, 30, GOLD, true);
        var cs = newSlide(pres, BLUE);
        var as = newSlide(pres, BLUE);

        label(cs, cat.name.toUpperCase() + '  -  ' + lab, 0, 10, W, 30, 16, GOLD, true);
        label(cs, q[0], 40, 50, W - 80, H - 130, 30, '#FFFFFF', true);
        box(cs, W / 2 - 80, H - 60, 160, 40, GOLD, 'SHOW ANSWER', 16, '#000000', true).setLinkSlide(as);

        label(as, q[0], 40, 10, W - 80, 110, 18, '#C9D1FF', false);
        label(as, q[1], 40, 125, W - 80, H - 200, 30, GOLD, true);
        box(as, W / 2 - 80, H - 60, 160, 40, GOLD, 'BACK TO BOARD', 16, '#000000', true).setLinkSlide(board);

        cell.setLinkSlide(cs);
        crec.cells.push({
          label: lab,
          shape: cell.getObjectId(),
          clue: cs.getObjectId(),
          answer: as.getObjectId(),
          q: q[0],
          a: q[1]
        });
      });
      rec.cats.push(crec);
    });
    map.rounds.push(rec);
  });

  var fc = newSlide(pres, NAVY);
  var fq = newSlide(pres, BLUE);
  var fa = newSlide(pres, BLUE);
  label(fc, 'FINAL JEOPARDY!', 0, H * 0.2, W, 70, 48, GOLD, true);
  label(fc, 'Category: ' + FINAL.category, 0, H * 0.5, W, 50, 30, '#FFFFFF', true);
  box(fc, W / 2 - 80, H - 60, 160, 40, GOLD, 'SHOW CLUE', 16, '#000000', true).setLinkSlide(fq);
  label(fq, FINAL.clue, 40, 30, W - 80, H - 120, 30, '#FFFFFF', true);
  box(fq, W / 2 - 80, H - 60, 160, 40, GOLD, 'SHOW ANSWER', 16, '#000000', true).setLinkSlide(fa);
  label(fa, FINAL.answer, 40, 30, W - 80, H - 120, 30, GOLD, true);
  map.final = { category: fc.getObjectId(), clue: fq.getObjectId(), answer: fa.getObjectId() };

  PropertiesService.getDocumentProperties().setProperty('JEO', JSON.stringify(map));
  setPos({ kind: 'board', r: 0 });
  old.forEach(function (s) { s.remove(); });
  SlidesApp.getUi().alert('Game built! Now choose Jeopardy > 2. Open host controller.');
}


/* ---------- Host controller ---------- */

function openController() {
  loadMap();
  SlidesApp.getUi().showSidebar(HtmlService.createHtmlOutput(controllerHtml()).setTitle('Jeopardy Host'));
}

function getState() {
  var pres = SlidesApp.getActivePresentation();
  var m = loadMap();
  var pos = getPos();

  var rounds = m.rounds.map(function (rec) {
    var left = 0;
    var cats = rec.cats.map(function (cat) {
      return {
        name: cat.name,
        vals: cat.cells.map(function (cell) {
          var used = cellShape(pres, rec, cell).getText().isEmpty();
          if (!used) { left += 1; }
          return { label: cell.label, used: used };
        })
      };
    });
    return { name: rec.name, cats: cats, left: left };
  });

  var current = null;
  if (pos.kind === 'clue' && m.rounds[pos.r] && m.rounds[pos.r].cats[pos.c]) {
    var cat = m.rounds[pos.r].cats[pos.c];
    var cell = cat.cells[pos.i];
    if (cell) {
      current = {
        r: pos.r,
        c: pos.c,
        i: pos.i,
        category: cat.name,
        label: cell.label,
        value: cellValue(cell),
        clue: cell.q || '',
        answer: cell.a || '',
        shown: !!pos.shown
      };
    }
  }

  return {
    teams: getTeams(),
    rounds: rounds,
    current: current,
    spot: pos.kind,
    roundIndex: pos.r || 0,
    finalStep: pos.kind === 'final' ? pos.step : null
  };
}

function pickClue(r, c, i) {
  var m = loadMap();
  if (!m.rounds[r] || !m.rounds[r].cats[c] || !m.rounds[r].cats[c].cells[i]) {
    throw new Error('That clue is not on the board.');
  }
  setPos({ kind: 'clue', r: r, c: c, i: i, shown: false });
  SlidesApp.getActivePresentation().getSlideById(m.rounds[r].cats[c].cells[i].clue).selectAsCurrentPage();
  return getState();
}

function showAnswer() {
  var m = loadMap();
  var pos = getPos();
  if (pos.kind !== 'clue') { throw new Error('Pick a clue first.'); }
  setPos({ kind: 'clue', r: pos.r, c: pos.c, i: pos.i, shown: true });
  SlidesApp.getActivePresentation().getSlideById(m.rounds[pos.r].cats[pos.c].cells[pos.i].answer).selectAsCurrentPage();
  return getState();
}

function skipClue() {
  return closeClue(null, 0);
}

function award(teamIndex, correct) {
  return closeClue(teamIndex, correct ? 1 : -1);
}

function closeClue(teamIndex, sign) {
  var pres = SlidesApp.getActivePresentation();
  var m = loadMap();
  var pos = getPos();
  if (pos.kind !== 'clue') { throw new Error('Pick a clue first.'); }

  var rec = m.rounds[pos.r];
  var cell = rec.cats[pos.c].cells[pos.i];
  var sh = cellShape(pres, rec, cell);

  if (teamIndex !== null && teamIndex !== undefined) {
    var teams = getTeams();
    if (teams[teamIndex]) {
      teams[teamIndex].score += sign * cellValue(cell);
      saveTeams(teams);
    }
  }

  sh.removeLink();
  sh.getText().setText('');
  setPos({ kind: 'board', r: pos.r });
  pres.getSlideById(rec.boardId).selectAsCurrentPage();
  return getState();
}

function showBoard(r) {
  var m = loadMap();
  var idx = Math.max(0, Math.min(Number(r) || 0, m.rounds.length - 1));
  setPos({ kind: 'board', r: idx });
  SlidesApp.getActivePresentation().getSlideById(m.rounds[idx].boardId).selectAsCurrentPage();
  return getState();
}

function showFinal(step) {
  var m = loadMap();
  var s = Math.max(0, Math.min(2, Number(step) || 0));
  setPos({ kind: 'final', r: m.rounds.length - 1, step: s });
  SlidesApp.getActivePresentation().getSlideById([m.final.category, m.final.clue, m.final.answer][s]).selectAsCurrentPage();
  return getState();
}

function resetBoard() {
  var pres = SlidesApp.getActivePresentation();
  var m = loadMap();
  m.rounds.forEach(function (rec) {
    rec.cats.forEach(function (cat) {
      cat.cells.forEach(function (cell) {
        paintCell(cellShape(pres, rec, cell), cell.label, pres.getSlideById(cell.clue));
      });
    });
  });
  setPos({ kind: 'board', r: 0 });
  return getState();
}


/* ---------- Team scores ---------- */

var TEAMS_KEY = 'JEO_TEAMS';

function getTeams() {
  var raw = PropertiesService.getDocumentProperties().getProperty(TEAMS_KEY);
  var start = [{ name: 'Team 1', score: 0 }, { name: 'Team 2', score: 0 }];
  if (!raw) { return start; }
  try { return JSON.parse(raw); } catch (e) { return start; }
}

function saveTeams(teams) {
  PropertiesService.getDocumentProperties().setProperty(TEAMS_KEY, JSON.stringify(teams));
  return teams;
}

function addTeam() {
  var teams = getTeams();
  if (teams.length < 6) { teams.push({ name: 'Team ' + (teams.length + 1), score: 0 }); }
  saveTeams(teams);
  return { teams: getTeams() };
}

function removeTeam(i) {
  var teams = getTeams();
  if (teams.length > 1) { teams.splice(i, 1); }
  saveTeams(teams);
  return { teams: getTeams() };
}

function renameTeam(i, name) {
  var teams = getTeams();
  if (teams[i]) { teams[i].name = String(name).slice(0, 24) || 'Team ' + (i + 1); }
  saveTeams(teams);
  return { teams: getTeams() };
}

function adjustTeam(i, delta) {
  var teams = getTeams();
  if (teams[i]) { teams[i].score += Number(delta) || 0; }
  saveTeams(teams);
  return { teams: getTeams() };
}

function resetScores() {
  saveTeams(getTeams().map(function (t) { return { name: t.name, score: 0 }; }));
  return { teams: getTeams() };
}


/* ---------- Sidebar ---------- */

function controllerHtml() {
  return "<style>\nbody { font-family: Arial, Helvetica, sans-serif; padding: 8px; font-size: 13px; color: #111; }\nh3 { font-size: 12px; margin: 14px 0 4px; text-transform: uppercase; letter-spacing: .06em; color: #333; }\nbutton { margin: 2px; padding: 5px 7px; font-weight: bold; cursor: pointer; border: 1px solid #999; background: #f2f2f2; border-radius: 4px; color: #111; }\nbutton:disabled { opacity: .35; cursor: default; }\n.ok { background: #1E7B34; color: #fff; border: 0; }\n.no { background: #B00020; color: #fff; border: 0; }\n.gold { background: #FFCC00; border: 0; }\n.panel { background: #FFF3B8; padding: 8px; border-radius: 4px; margin-bottom: 8px; }\n.cat { font-size: 12px; margin-top: 6px; color: #333; font-weight: bold; }\n.team { display: flex; align-items: center; gap: 4px; margin: 3px 0; }\n.team input { width: 84px; font-weight: bold; padding: 3px; }\n.pts { min-width: 52px; text-align: right; font-weight: bold; }\n.muted { color: #666; font-size: 12px; }\n.msg { color: #B00020; font-weight: bold; margin-top: 6px; }\n</style>\n<div id=\"cur\"></div>\n<div id=\"score\"></div>\n<div id=\"app\"></div>\n<div id=\"msg\" class=\"msg\"></div>\n<script>\nvar S = null;\nvar curEl = document.getElementById(\"cur\");\nvar scoreEl = document.getElementById(\"score\");\nvar appEl = document.getElementById(\"app\");\nvar msgEl = document.getElementById(\"msg\");\n\nfunction esc(t) {\n  return String(t === null || t === undefined ? \"\" : t)\n    .replace(/&/g, \"&amp;\").replace(/</g, \"&lt;\").replace(/>/g, \"&gt;\").replace(/\"/g, \"&quot;\");\n}\n\nfunction fail(e) {\n  msgEl.innerHTML = esc(e && e.message ? e.message : \"Something went wrong.\");\n}\n\nfunction apply(p) {\n  if (!p) { return; }\n  if (p.rounds) { S = p; } else { S = Object.assign(S || {}, p); }\n  msgEl.innerHTML = \"\";\n  render();\n}\n\nfunction gs(name, args) {\n  var runner = google.script.run.withSuccessHandler(apply).withFailureHandler(fail);\n  return runner[name].apply(runner, args || []);\n}\n\nfunction btn(act, args, label, cls) {\n  return '<button class=\"' + (cls || \"\") + '\" data-act=\"' + act + '\" data-args=\"' + esc(JSON.stringify(args || [])) + '\">' + label + '</button>';\n}\n\nfunction render() {\n  if (!S) { return; }\n  var cur = S.current;\n  var spot = S.spot === \"final\" ? \"Final Jeopardy\" : (S.rounds[S.roundIndex] ? esc(S.rounds[S.roundIndex].name) : \"\");\n\n  var cb = \"\";\n  if (cur) {\n    cb += '<div class=\"panel\"><b>' + esc(cur.category) + ' &middot; ' + esc(cur.label) + '</b>';\n    cb += '<div style=\"color:#333;margin-top:4px\">' + esc(cur.clue) + '</div>';\n    if (cur.shown) {\n      cb += '<div style=\"color:#1E7B34;font-weight:bold;margin-top:6px\">' + esc(cur.answer) + '</div>';\n    }\n    cb += '<div style=\"margin-top:6px\">';\n    cb += btn(\"showAnswer\", [], cur.shown ? \"Answer slide\" : \"Show answer\");\n    cb += btn(\"skipClue\", [], \"No answer\");\n    cb += '</div></div>';\n  } else {\n    cb = '<div class=\"muted\">' + spot + ' - click a dollar amount to start a clue</div>';\n  }\n  curEl.innerHTML = cb;\n\n  var s = \"<h3>Team scores</h3>\";\n  S.teams.forEach(function (t, ti) {\n    s += '<div class=\"team\"><input value=\"' + esc(t.name) + '\" data-team=\"' + ti + '\"><span class=\"pts\">' + (\"$\" + t.score) + '</span>';\n    if (cur) {\n      s += btn(\"award\", [ti, true], \"+\" + cur.value, \"ok\");\n      s += btn(\"award\", [ti, false], \"-\" + cur.value, \"no\");\n    } else {\n      s += btn(\"adjustTeam\", [ti, 100], \"+100\");\n      s += btn(\"adjustTeam\", [ti, -100], \"-100\");\n    }\n    s += btn(\"removeTeam\", [ti], \"X\");\n    s += \"</div>\";\n  });\n  s += '<div>' + btn(\"addTeam\", [], \"+ Add team\") + btn(\"resetScores\", [], \"Reset scores\") + \"</div>\";\n  scoreEl.innerHTML = s;\n\n  var h = \"\";\n  S.rounds.forEach(function (rd, ri) {\n    h += \"<h3>\" + esc(rd.name) + ' <span class=\"muted\">' + (rd.left > 0 ? rd.left + \" left\" : \"complete\") + \"</span></h3>\";\n    h += btn(\"showBoard\", [ri], \"Show board\");\n    if (rd.left === 0 && ri + 1 < S.rounds.length) {\n      h += btn(\"showBoard\", [ri + 1], \"Next round\", \"gold\");\n    }\n    if (rd.left === 0 && ri + 1 === S.rounds.length) {\n      h += btn(\"showFinal\", [0], \"Final Jeopardy\", \"gold\");\n    }\n    rd.cats.forEach(function (cat, ci) {\n      h += '<div class=\"cat\">' + esc(cat.name) + \"</div>\";\n      cat.vals.forEach(function (v, vi) {\n        h += btn(\"pickClue\", [ri, ci, vi], esc(v.label), v.used ? \"used\" : \"\");\n      });\n    });\n  });\n  h += \"<h3>Final Jeopardy</h3>\";\n  h += btn(\"showFinal\", [0], \"Category\") + btn(\"showFinal\", [1], \"Clue\") + btn(\"showFinal\", [2], \"Answer\");\n  h += \"<h3>Deck</h3>\";\n  h += btn(\"resetBoard\", [], \"Reset board\") + btn(\"getState\", [], \"Refresh\");\n  appEl.innerHTML = h;\n}\n\ndocument.addEventListener(\"click\", function (ev) {\n  var b = ev.target && ev.target.closest ? ev.target.closest(\"button[data-act]\") : null;\n  if (!b || b.disabled) { return; }\n  var args = [];\n  try { args = JSON.parse(b.getAttribute(\"data-args\") || \"[]\"); } catch (e) { args = []; }\n  gs(b.getAttribute(\"data-act\"), args);\n});\n\ndocument.addEventListener(\"change\", function (ev) {\n  var t = ev.target;\n  if (!t || !t.getAttribute || t.getAttribute(\"data-team\") === null) { return; }\n  gs(\"renameTeam\", [Number(t.getAttribute(\"data-team\")), t.value]);\n});\n\ngs(\"getState\");\n</script>";
}