(function (root) { 'use strict'; var messages = { saved: 'このブラウザに保存しました。', saving: 'このブラウザに保存中…', error: '保存できませんでした。ブラウザの保存設定と空き容量を確認してください。', empty: 'コピーするコードがありません。', copyError: 'コピーできませんでした。コードを選択して手動でコピーしてください。' }; function copyField(field) { if (!field || !field.value) { return Promise.resolve(false); } function fallback() { field.focus(); field.select(); try { return root.document.execCommand('copy'); } catch (error) { return false; } } if (root.navigator.clipboard && root.isSecureContext) { return root.navigator.clipboard.writeText(field.value) .then(function () { return true; }).catch(fallback); } return Promise.resolve(fallback()); } function bindCopies() { root.document.addEventListener('click', function (event) { var button = event.target.closest('[data-copy-target]'); if (!button) { return; } var field = root.document.getElementById(button.getAttribute('data-copy-target')); var status = root.document.getElementById('copy_output_status') || root.document.getElementById('tb-copy-status'); if (!field || !status) { return; } if (!field.value) { status.textContent = messages.empty; return; } copyField(field).then(function (ok) { status.textContent = ok ? (button.getAttribute('data-copy-label') || 'HTML') + 'をコピーしました。' : messages.copyError; }); }); } function syncSettingsFields(document, settings, exportId) { var json = JSON.stringify(settings); document.querySelectorAll('.user_settings_json').forEach(function (field) { field.value = json; }); var exported = document.getElementById(exportId); if (exported) { exported.value = JSON.stringify(settings, null, 2); } } function updateMobilePreview(frame, preview) { if (!frame || !preview) { return; } const copy = preview.cloneNode(true); copy.querySelectorAll('style').forEach(function (style) { style.textContent = style.textContent.replace(/
' + '' + '' + '' + copy.innerHTML + ''; frame.replaceWith(nextFrame); } function revealManualAnchor() { var id; try { id = decodeURIComponent(root.location.hash.slice(1)); } catch (error) { return; } var target = root.document.getElementById(id); if (!target) { return; } var parent = target.parentElement; while (parent) { if (parent.tagName === 'DETAILS') { parent.open = true; } parent = parent.parentElement; } target.scrollIntoView(); } if (root.document && root.addEventListener) { root.document.addEventListener('DOMContentLoaded', revealManualAnchor); root.addEventListener('hashchange', revealManualAnchor); } root.SeriesUI = { messages: messages, copyField: copyField, bindCopies: bindCopies, syncSettingsFields: syncSettingsFields, updateMobilePreview: updateMobilePreview }; }(typeof window === 'undefined' ? globalThis : window));