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 +4 -4
- data/assets/jekyll-dice-tray/dice_tray.js +18 -30
- data/lib/jekyll/dice_tray/html_rewriter.rb +1 -1
- data/lib/jekyll/dice_tray/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1e3b5e6ffc89df4600f4c4a25d765e3bc5efcd96d3671817cfc19c0edf540e7f
|
|
4
|
+
data.tar.gz: eeb98f0a9a72e5caac9dfa0608f402cfefb90c914c0ecacf2dc170d6484decd8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
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
|
-
"
|
|
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>
|