/* * tegaki.js - Add support for tegaki drawing * * Usage: * $config['additional_javascript'][] = 'js/jquery.min.js'; (required if both below are in use) * $config['additional_javascript'][] = 'js/ajax.js'; // (optional) to clear state after upload * $config['additional_javascript'][] = 'js/file-selector.js'; // (optional) for thumbnails * $config['additional_javascript'][] = 'js/tegaki/tegaki.min.js'; * $config['additional_javascript'][] = 'js/tegaki.js'; */ function clearTegaki(blob = null) { const edit = document.getElementById('tegaki-edit'); const clear = document.getElementById('tegaki-clear'); const start = document.getElementById('tegaki-start'); const fileInput = document.getElementById('upload_file'); if (typeof FileSelector !== 'undefined' && FileSelector.removeFile) { FileSelector.removeFile(blob); } else { fileInput.value = ''; } toggleButtonState(start, true); toggleButtonState(edit, false, true); toggleButtonState(clear, false, true); } function toggleButtonState(button, isVisible, isDisabled = false) { button.style.display = isVisible ? '' : 'none'; button.disabled = isDisabled; } function initializeTegaki() { if (!['thread', 'index', 'ukko', 'catalog'].includes(active_page)) return; const link = document.createElement('link'); link.rel = 'stylesheet'; link.href = `${configRoot}js/tegaki/tegaki.css`; document.head.appendChild(link); const upload = document.querySelector('#upload'); upload.insertAdjacentHTML('afterend', `