PluginProbe
Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor / 2.0.7
Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor v2.0.7
2.0.13 2.0.12 2.0.11 2.0.10 2.0.9 trunk 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8
blockenberg / blocks / show-notes / frontend.js

frontend.js in Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor 2.0.7, at blocks/show-notes/frontend.js

228 lines 11.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function () {
2 'use strict';
3
4 var _typoKeys = {
5 family:'font-family', weight:'font-weight', style:'font-style',
6 decoration:'text-decoration', transform:'text-transform',
7 sizeDesktop:'font-size-d', sizeTablet:'font-size-t', sizeMobile:'font-size-m',
8 lineHeightDesktop:'line-height-d', lineHeightTablet:'line-height-t', lineHeightMobile:'line-height-m',
9 letterSpacingDesktop:'letter-spacing-d', letterSpacingTablet:'letter-spacing-t', letterSpacingMobile:'letter-spacing-m',
10 wordSpacingDesktop:'word-spacing-d', wordSpacingTablet:'word-spacing-t', wordSpacingMobile:'word-spacing-m'
11 };
12 function typoCssVarsForEl(el, obj, prefix) {
13 if (!obj || typeof obj !== 'object') return;
14 Object.keys(_typoKeys).forEach(function (k) {
15 var v = obj[k];
16 if (v === undefined || v === '' || v === null) return;
17 if (k === 'sizeDesktop' || k === 'sizeTablet' || k === 'sizeMobile') v = v + (obj.sizeUnit || 'px');
18 else if (k === 'lineHeightDesktop' || k === 'lineHeightTablet' || k === 'lineHeightMobile') v = v + (obj.lineHeightUnit || '');
19 else if (k === 'letterSpacingDesktop' || k === 'letterSpacingTablet' || k === 'letterSpacingMobile') v = v + (obj.letterSpacingUnit || 'px');
20 else if (k === 'wordSpacingDesktop' || k === 'wordSpacingTablet' || k === 'wordSpacingMobile') v = v + (obj.wordSpacingUnit || 'px');
21 el.style.setProperty(prefix + _typoKeys[k], String(v));
22 });
23 }
24
25 function mk(tag, cls, styles) {
26 var d = document.createElement(tag);
27 if (cls) d.className = cls;
28 if (styles) Object.keys(styles).forEach(function (k) { d.style[k] = styles[k]; });
29 return d;
30 }
31 function tx(tag, cls, text, styles) {
32 var d = mk(tag, cls, styles);
33 d.textContent = text;
34 return d;
35 }
36 function ap(parent) {
37 Array.prototype.slice.call(arguments, 1).forEach(function (c) { if (c) parent.appendChild(c); });
38 return parent;
39 }
40
41 var resIcon = { article: '📄', video: '🎥', tool: '🛠️', download: '⬇️', link: '🔗' };
42
43 function sectionHead(label, a) {
44 var d = mk('div', 'bkbg-sn-section-head', {
45 color: a.accentColor,
46 borderBottomColor: a.accentColor
47 });
48 d.textContent = label;
49 return d;
50 }
51
52 function init() {
53 document.querySelectorAll('.bkbg-show-notes-app').forEach(function (appEl) {
54 if (appEl.dataset.rendered) return;
55 appEl.dataset.rendered = '1';
56
57 var a;
58 try { a = JSON.parse(appEl.dataset.opts || '{}'); } catch (e) { return; }
59
60 var lh = ((a.lineHeight || 168) / 100).toFixed(2);
61
62 var wrap = mk('div', 'bkbg-sn-wrap', {
63 border: '1px solid ' + (a.borderColor || '#e5e7eb'),
64 borderRadius: (a.borderRadius || 12) + 'px',
65 overflow: 'hidden',
66 background: a.bgColor || '#fff'
67 });
68 typoCssVarsForEl(wrap, a.titleTypo, '--bksn-tt-');
69 typoCssVarsForEl(wrap, a.bodyTypo, '--bksn-bt-');
70 typoCssVarsForEl(wrap, a.typoQuote, '--bksn-qt-');
71
72 // ── Header ───────────────────────────────────────────────────
73 var header = mk('div', 'bkbg-sn-header', { background: a.headerBg || '#0f172a' });
74
75 if (a.showEpisodeMeta) {
76 var pRow = mk('div', 'bkbg-sn-podcast-row');
77 if (a.podcastName) ap(pRow, tx('span', 'bkbg-sn-podcast-name', a.podcastName, { color: a.metaColor || '#94a3b8' }));
78 if (a.episodeNumber) {
79 ap(pRow, tx('span', 'bkbg-sn-dot', '·', { color: a.metaColor || '#94a3b8' }));
80 ap(pRow, tx('span', 'bkbg-sn-ep-num', a.episodeNumber, { color: a.metaColor || '#94a3b8' }));
81 }
82 if (a.season) {
83 ap(pRow, tx('span', 'bkbg-sn-dot', '/', { color: a.metaColor || '#94a3b8' }));
84 ap(pRow, tx('span', 'bkbg-sn-ep-num', a.season, { color: a.metaColor || '#94a3b8' }));
85 }
86 ap(header, pRow);
87 }
88
89 var titleEl = mk('h2', 'bkbg-sn-title', { color: a.headerColor || '#fff' });
90 titleEl.textContent = a.episodeTitle || '';
91 ap(header, titleEl);
92
93 if (a.showMeta && (a.publishDate || a.duration)) {
94 var metaRow = mk('div', 'bkbg-sn-meta');
95 if (a.publishDate) ap(metaRow, tx('span', 'bkbg-sn-meta-item', '�
96 ' + a.publishDate, { color: a.metaColor || '#94a3b8' }));
97 if (a.duration) ap(metaRow, tx('span', 'bkbg-sn-meta-item', '' + a.duration, { color: a.metaColor || '#94a3b8' }));
98 ap(header, metaRow);
99 }
100
101 ap(wrap, header);
102
103 // ── Body ─────────────────────────────────────────────────────
104 var body = mk('div', 'bkbg-sn-body');
105
106 // Intro
107 if (a.showIntro && a.intro) {
108 var introBox = mk('div', 'bkbg-sn-intro', { background: a.introBg || '#f8fafc', borderRadius: '8px' });
109 var introP = mk('p', '', { margin: '0', color: a.introColor || '#374151', lineHeight: lh });
110 introP.textContent = a.intro;
111 ap(introBox, introP);
112 ap(body, introBox);
113 }
114
115 // Featured Quote
116 if (a.showQuote && a.quoteHighlight) {
117 var fig = mk('figure', 'bkbg-sn-quote', {
118 background: a.quoteBg || '#f0f9ff',
119 borderLeftColor: a.quoteBorder || '#3b82f6'
120 });
121 var bq = mk('blockquote', '', { margin: '0 0 8px', fontStyle: 'italic', color: a.quoteColor || '#0369a1', lineHeight: lh });
122 bq.textContent = '\u201c' + a.quoteHighlight + '\u201d';
123 ap(fig, bq);
124 if (a.quoteSpeaker) {
125 var figcap = tx('figcaption', '', '' + a.quoteSpeaker, { color: a.quoteColor || '#0369a1', fontSize: '12px', fontWeight: '700', opacity: '.8' });
126 ap(fig, figcap);
127 }
128 ap(body, fig);
129 }
130
131 // Sponsors
132 if (a.showSponsors && a.sponsors && a.sponsors.length) {
133 var spSection = mk('div', 'bkbg-sn-sponsors-section');
134 ap(spSection, sectionHead(a.sponsorsLabel || 'Sponsors', a));
135 a.sponsors.forEach(function (sp) {
136 var card = mk('div', 'bkbg-sn-sponsor', {
137 background: a.sponsorBg || '#fffbeb',
138 borderColor: a.sponsorBorder || '#fbbf24'
139 });
140 var top = mk('div', 'bkbg-sn-sponsor-top');
141 ap(top, tx('strong', 'bkbg-sn-sponsor-name', sp.name, { color: '#713f12' }));
142 if (sp.code) ap(top, tx('span', 'bkbg-sn-sponsor-code', 'Code: ' + sp.code));
143 ap(card, top);
144 if (sp.description) {
145 var desc = mk('p', 'bkbg-sn-sponsor-desc', { color: a.sponsorColor || '#374151', fontSize: (a.fontSize - 1) + 'px' });
146 desc.textContent = sp.description;
147 ap(card, desc);
148 }
149 ap(spSection, card);
150 });
151 ap(body, spSection);
152 }
153
154 // Chapters
155 if (a.showChapters && a.chapters && a.chapters.length) {
156 var chSection = mk('div', 'bkbg-sn-chapters-section');
157 ap(chSection, sectionHead(a.chaptersLabel || 'Chapters', a));
158 a.chapters.forEach(function (ch) {
159 var row = mk('div', 'bkbg-sn-chapter', { borderBottomColor: a.borderColor || '#e5e7eb' });
160 ap(row, tx('span', 'bkbg-sn-chapter-time', ch.time, {
161 background: a.chapterTimeBg || '#f1f5f9',
162 color: a.chapterTimeColor || '#475569'
163 }));
164 ap(row, tx('span', 'bkbg-sn-chapter-title', ch.title, { color: a.chapterTitleColor || '#111827' }));
165 ap(chSection, row);
166 });
167 ap(body, chSection);
168 }
169
170 // Links Mentioned
171 if (a.showLinks && a.links && a.links.length) {
172 var lkSection = mk('div', 'bkbg-sn-links-section');
173 ap(lkSection, sectionHead(a.linksLabel || 'Links Mentioned', a));
174 a.links.forEach(function (lnk) {
175 var item = mk('div', 'bkbg-sn-link', { borderBottomColor: a.borderColor || '#e5e7eb' });
176 var anchor = mk('a', 'bkbg-sn-link-title');
177 anchor.textContent = lnk.title;
178 anchor.href = lnk.url || '#';
179 anchor.target = '_blank';
180 anchor.rel = 'noopener';
181 anchor.style.color = a.linkColor || '#2563eb';
182 ap(item, anchor);
183 if (lnk.description) ap(item, tx('span', 'bkbg-sn-link-desc', lnk.description, { color: a.linkDescColor || '#6b7280' }));
184 ap(lkSection, item);
185 });
186 ap(body, lkSection);
187 }
188
189 // Resources
190 if (a.showResources && a.resources && a.resources.length) {
191 var rsSection = mk('div', 'bkbg-sn-resources-section');
192 ap(rsSection, sectionHead(a.resourcesLabel || 'Episode Resources', a));
193 a.resources.forEach(function (r) {
194 var row = mk('div', 'bkbg-sn-resource', { borderLeftColor: a.accentColor || '#3b82f6' });
195 ap(row, tx('span', 'bkbg-sn-resource-icon', resIcon[r.type] || '🔗'));
196 var rtitle = mk('a', 'bkbg-sn-resource-title');
197 rtitle.textContent = r.title;
198 rtitle.href = r.url || '#';
199 rtitle.target = '_blank';
200 rtitle.rel = 'noopener';
201 rtitle.style.color = a.linkColor || '#2563eb';
202 ap(row, rtitle);
203 ap(rsSection, row);
204 });
205 ap(body, rsSection);
206 }
207
208 // Tags
209 if (a.showTags && a.tags && a.tags.length) {
210 var tagRow = mk('div', 'bkbg-sn-tags');
211 a.tags.forEach(function (tag) {
212 ap(tagRow, tx('span', 'bkbg-sn-tag', tag, {
213 background: a.tagBg || '#eff6ff',
214 color: a.tagColor || '#1d4ed8'
215 }));
216 });
217 ap(body, tagRow);
218 }
219
220 ap(wrap, body);
221 appEl.appendChild(wrap);
222 });
223 }
224
225 if (document.readyState !== 'loading') { init(); }
226 else { document.addEventListener('DOMContentLoaded', init); }
227 })();
228