diff --git a/main.js b/main.js index f52c708..ed807d1 100644 --- a/main.js +++ b/main.js @@ -1,5 +1,10 @@ -document.getElementById('convert-button').addEventListener('click', function () { +document.getElementById('convert-button').addEventListener('click', function() { const markdownText = document.getElementById('markdown-input').value; + if (markdownText.trim() === '') { + alert('Please enter some Markdown text.'); + return; + } + const htmlContent = marked.parse(markdownText); const formattedHtml = ` @@ -18,11 +23,25 @@ document.getElementById('convert-button').addEventListener('click', function () document.getElementById('html-output').textContent = formattedHtml; }); -document.getElementById('copy-button').addEventListener('click', function () { +document.getElementById('copy-html-button').addEventListener('click', function() { const htmlOutput = document.getElementById('html-output').textContent; - navigator.clipboard.writeText(htmlOutput).then(function () { + navigator.clipboard.writeText(htmlOutput).then(function() { alert('HTML copied to clipboard!'); - }, function (err) { + }, function(err) { alert('Could not copy text: ', err); }); -}); \ No newline at end of file +}); + +document.getElementById('copy-markdown-button').addEventListener('click', function() { + const markdownInput = document.getElementById('markdown-input').value; + navigator.clipboard.writeText(markdownInput).then(function() { + alert('Markdown copied to clipboard!'); + }, function(err) { + alert('Could not copy text: ', err); + }); +}); + +document.getElementById('preview-button').addEventListener('click', function() { + const htmlContent = marked.parse(document.getElementById('markdown-input').value); + document.getElementById('html-preview').innerHTML = htmlContent; +});