app
Component Widgets
Public Made by Adomby adom
Reusable component widgets for pinouts, thermal vias, molecule relationships, reviewed chip outlines and lightweight four-level LOD cache listings.
← Commit history
pinout: download via data:, not blob: (the sandbox CSP has no blob:, so the button did nothing)
1 file changed
+8−4
widgets/pinout-widget.js+8−4@@ -213,10 +213,14 @@ _exportJson() { return JSON.stringify(this.toJSON(), null, 2); } _exportName() { const d = this._data || {}; return ((d.mpn || 'pinout') + (d.package ? '-' + d.package : '')).replace(/[^\w.-]+/g, '_') + '.pins.json'; } _download() {- const blob = new Blob([this._exportJson()], { type: 'application/json' });- const url = URL.createObjectURL(blob), a = document.createElement('a');- a.href = url; a.download = this._exportName(); document.body.appendChild(a); a.click();- a.remove(); setTimeout(() => URL.revokeObjectURL(url), 1000);+ // A data: URL, not a blob:. As a registered widget this renders inside the+ // wiki's sandboxed frame, whose CSP has no blob:, so createObjectURL is+ // refused at runtime and the button does nothing at all. data: is the only+ // download route that works in every host we render in.+ const a = document.createElement('a');+ a.href = 'data:application/json;charset=utf-8,' + encodeURIComponent(this._exportJson());+ a.download = this._exportName();+ document.body.appendChild(a); a.click(); a.remove(); } async _copy(btn) { const txt = this._exportJson(), done = () => { if (!btn) return; const o = btn.textContent; btn.textContent = 'copied'; btn.classList.add('ok'); setTimeout(() => { btn.textContent = o; btn.classList.remove('ok'); }, 1100); };