jekyll-dice-tray 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ee11a49a55ee16f40ee46a91b01a40d3074da6b6bc1cdde28b7bbe36b41386d
4
- data.tar.gz: a35ce460b6c0181c03acc99d38916407eac12d1c6d89feae6412335302cedd64
3
+ metadata.gz: 1e3b5e6ffc89df4600f4c4a25d765e3bc5efcd96d3671817cfc19c0edf540e7f
4
+ data.tar.gz: eeb98f0a9a72e5caac9dfa0608f402cfefb90c914c0ecacf2dc170d6484decd8
5
5
  SHA512:
6
- metadata.gz: c754090c423cbd76a96b532e0bccc16d2cd2e76db5006fae17ed1766b5c8e19305a8838346640117de26bc6793e7c41021dbcf05ce61541095b97bd1dfde5edd
7
- data.tar.gz: 03d2e7cdfaa42614d46fba9fac3eebf0722b6ba324def7a5c40d6f53576aadc0b4f73a17354218aa7ad508b002818c93e49db65f9b1170a37ce389ddbc26e3ea
6
+ metadata.gz: 76359d77b57187df74358db7c49116928b201ce19ffa3130e3af0584087cce008c220baacbea6185f2e5a39686c27b4c78c6010702a9d2576f258158a9df36b7
7
+ data.tar.gz: 0b6e4439a8265f518ee925cb7f497fe5c3daa6c2dfd180d67ba8e7dcbefab68495f25bb50805b4d594d2cf777b3f32ed4a9172c5564c512de072db5d80db1ccd
@@ -46,8 +46,9 @@
46
46
  function parseExpr(input) {
47
47
  var s = String(input || "").trim();
48
48
  if (!s) return { kind: "empty" };
49
- if (s === "/help") return { kind: "help" };
50
- if (s === "/clear") return { kind: "clear" };
49
+ if (s === "/help" || s === "/h") return { kind: "help" };
50
+ if (s === "/clear" || s === "/c") return { kind: "clear" };
51
+ if (s === "/version" || s === "/v") return { kind: "version" };
51
52
 
52
53
  // Allow whitespace variations like "d20 + 2"
53
54
  var compact = s.replace(/\s+/g, "");
@@ -353,21 +354,6 @@
353
354
  return group ? [group.keyIndex] : null;
354
355
  }
355
356
 
356
- function findFollowingTable(node) {
357
- var elNode = node;
358
- while (elNode && elNode !== document.body) {
359
- var sib = elNode.nextElementSibling;
360
- while (sib) {
361
- if (sib.tagName === "TABLE") return sib;
362
- var nested = sib.querySelector && sib.querySelector("table");
363
- if (nested) return nested;
364
- sib = sib.nextElementSibling;
365
- }
366
- elNode = elNode.parentElement;
367
- }
368
- return null;
369
- }
370
-
371
357
  function getLookupTableContext(anchor, rollTotal) {
372
358
  if (!anchor || !anchor.closest || rollTotal == null) return null;
373
359
 
@@ -384,18 +370,13 @@
384
370
  allowedKeys = anchor._jdtAllowedKeyIndices || null;
385
371
  } else {
386
372
  cell = anchor.closest("td, th");
387
- if (cell) {
388
- table = cell.closest("table");
389
- if (!table) return null;
390
- headerRow = findTableHeaderRow(table);
391
- // With a header, only header-cell dice trigger lookup (data cells may contain other dice).
392
- // Without a header, any in-table die can trigger lookup.
393
- if (headerRow && !headerRow.contains(cell)) return null;
394
- } else {
395
- table = findFollowingTable(anchor);
396
- if (!table) return null;
397
- headerRow = findTableHeaderRow(table);
398
- }
373
+ if (!cell) return null;
374
+ table = cell.closest("table");
375
+ if (!table) return null;
376
+ headerRow = findTableHeaderRow(table);
377
+ // With a header, only header-cell dice trigger lookup (data cells may contain other dice).
378
+ // Without a header, any in-table die can trigger lookup.
379
+ if (headerRow && !headerRow.contains(cell)) return null;
399
380
  }
400
381
 
401
382
  var keyColumns = inferKeyColumns(table, headerRow);
@@ -773,11 +754,17 @@
773
754
  function showHelp() {
774
755
  addSystemEntry(
775
756
  "Usage: 1d6, d4, 2d8+1, 2-in-6",
776
- "Click linked dice like 1d20+5, chance like 2-in-6 (roll d6, 1-2 succeed), or bracket modifiers like [+1] (rolls d20+1). Clicking a table die (any dN) shows the matching entry (number or range; any number of side-by-side key/value column groups; headers optional). Commands: /help, /clear",
757
+ "Type the dice you want to roll, without a prefix. Click linked dice notation in a table to show the matching entry (number or range).",
758
+ "Commands: /help, /clear, /version",
777
759
  nowTime()
778
760
  );
779
761
  }
780
762
 
763
+ function showVersion() {
764
+ var version = root.getAttribute("data-version") || "unknown";
765
+ addSystemEntry("dice tray " + version, "", nowTime());
766
+ }
767
+
781
768
  function doRoll(raw, meta) {
782
769
  meta = meta || {};
783
770
  var anchor = meta.anchor || null;
@@ -785,6 +772,7 @@
785
772
  if (p.kind === "empty") return;
786
773
  if (p.kind === "help") return showHelp();
787
774
  if (p.kind === "clear") return clearStorageAndUi();
775
+ if (p.kind === "version") return showVersion();
788
776
  if (p.kind !== "roll" && p.kind !== "bestof2" && p.kind !== "chance") {
789
777
  addSystemEntry("Unrecognized roll: " + p.raw, "Try: 1d6, d4, 2-in-6, 2d8+1 or /help", nowTime());
790
778
  return;
@@ -200,7 +200,7 @@ module Jekyll
200
200
  return html if html.include?('data-dice-tray-root="true"')
201
201
 
202
202
  tray = <<~HTML
203
- <div id="jekyll-dice-tray" data-dice-tray-root="true" aria-live="polite">
203
+ <div id="jekyll-dice-tray" data-dice-tray-root="true" data-version="#{VERSION}" aria-live="polite">
204
204
  <div class="jdt-header">
205
205
  <button type="button" class="jdt-toggle" aria-expanded="false" title="Toggle dice tray">Dice</button>
206
206
  </div>
@@ -1,6 +1,6 @@
1
1
  module Jekyll
2
2
  module DiceTray
3
- VERSION = "0.4.0"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
6
6
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-dice-tray
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - directsun