Skip to content

Commit 7532e68

Browse files
committed
Sync common.js (again).
1 parent ebde535 commit 7532e68

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

common/common.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ require(["core/pubsubhub"], (respecEvents) => {
177177
require(["core/pubsubhub"], (respecEvents) => {
178178
"use strict";
179179
respecEvents.sub('end-all', (documentElement) => {
180+
// Add example button selection logic
180181
for (const button of document.querySelectorAll(".ds-selector-tabs .selectors button")) {
181182
button.onclick = () => {
182183
const ex = button.closest(".ds-selector-tabs");
@@ -186,6 +187,18 @@ require(["core/pubsubhub"], (respecEvents) => {
186187
ex.querySelector("." + button.dataset.selects).classList.add("selected");
187188
}
188189
}
190+
191+
// Add playground links
192+
for (const link of document.querySelectorAll("a.playground")) {
193+
// First pre element of aside
194+
const pre = link.closest("aside").querySelector("pre");
195+
const content = unComment(document, pre.textContent)
196+
.replace(/(\*\*\*\*|####)/g, '');
197+
link.setAttribute('aria-label', 'playground link');
198+
link.setAttribute('href',
199+
'https://json-ld.org/playground-dev/#startTab=tab-expanded&json-ld=' +
200+
encodeURI(content));
201+
}
189202
});
190203
});
191204

0 commit comments

Comments
 (0)