Skip to main content

max / makenotwork

1.1 KB · 26 lines History Blame Raw
1 (function() {
2 var cfg = document.getElementById('tab-item-embed-cfg');
3 var hostUrl = cfg.dataset.hostUrl;
4 var itemId = cfg.dataset.itemId;
5 var itemTitle = cfg.dataset.itemTitle;
6
7 window.copyEmbed = function(btn) {
8 const code = btn.previousElementSibling.textContent;
9 navigator.clipboard.writeText(code).then(() => {
10 btn.textContent = 'Copied!';
11 setTimeout(() => btn.textContent = 'Copy', 1500);
12 });
13 };
14
15 window.switchCardLayout = function(layout) {
16 const iframe = document.getElementById('card-preview');
17 const code = document.getElementById('card-code');
18 const w = layout === 'horizontal' ? 600 : 350;
19 const h = layout === 'horizontal' ? 200 : 400;
20 iframe.src = hostUrl + '/embed/i/' + itemId + '/card?layout=' + layout;
21 iframe.width = w;
22 iframe.height = h;
23 code.textContent = '<iframe src="' + hostUrl + '/embed/i/' + itemId + '/card?layout=' + layout + '" width="' + w + '" height="' + h + '" frameborder="0" title="' + itemTitle + ' on Makenot.work"></iframe>';
24 };
25 })();
26