(zettel (meta (box-number "2") (created "20260206134600") (published "20260206134600") (role "configuration") (syntax "js") (title "Zettelstore Copy Reference JavaScript") (visibility "public")) (rights 4) (encoding "") (content "/*-----------------------------------------------------------------------------\n * Copyright (c) 2026-present Detlef Stern\n *\n * This file is part of Zettelstore.\n *\n * Zettelstore is licensed under the latest version of the EUPL (European Union\n * Public License). Please see file LICENSE.txt for your rights and obligations\n * under this license.\n *\n * SPDX-License-Identifier: EUPL-1.2\n * SPDX-FileCopyrightText: 2026-present Detlef Stern\n *-----------------------------------------------------------------------------\n */\n\nfunction zsShowNotification(message, success) {\n var notification = document.createElement('div');\n notification.classList.add('notification');\n notification.classList.add(success ? 'success' : 'error');\n notification.textContent = message;\n document.body.appendChild(notification);\n setTimeout(function() {\n if (notification.parentNode) {\n document.body.removeChild(notification);\n }\n }, 1732);\n}\n\ndocument.getElementById('zsCopyReference').addEventListener('click', function(event) {\n event.preventDefault();\n var reference = this.getAttribute('data-ref');\n navigator.clipboard.writeText(reference)\n .then(function() {\n zsShowNotification(\"Reference copied to clipboard.\", true);\n })\n .catch(function(error) {\n console.error(\"Error copying text: \", error);\n zsShowNotification(\"Failed to copy reference. Please try again.\", false);\n });\n });"))