From 789590471955f356ba63e2260ad2d1d71c0e096f Mon Sep 17 00:00:00 2001 From: Josh Ashton Date: Sun, 13 Apr 2025 13:57:14 -0600 Subject: [PATCH] hid preview on mobile --- css/base.css | 13 ++++++++++++- js/md_preview.js | 31 ++++++++++++++++++------------- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/css/base.css b/css/base.css index c0072e3..a6dd1ec 100644 --- a/css/base.css +++ b/css/base.css @@ -849,7 +849,18 @@ hr { font-size: 3vw; } - .tag_row {} + .full-height { + border: 1px solid red; + } + + .grid-2x1 { + display: block; + width: 100%; + } + + .grid-2x1>div:last-of-type { + display: none; + } } @media screen and (min-width: 993px) { diff --git a/js/md_preview.js b/js/md_preview.js index 15579c9..dd26e23 100644 --- a/js/md_preview.js +++ b/js/md_preview.js @@ -1,16 +1,21 @@ +const largeScreenMediaQuery = window.matchMedia("(min-width: 993px)"); // Example: 768px is a common breakpoint const textarea = document.querySelector('textarea'); const preview = document.getElementById('md_preview'); -textarea.addEventListener('input', function() { - fetch('functions/preview.php', { // Create a separate preview.php file for real-time updates - method: 'POST', - headers: { - 'Content-Type': 'application/x-www-form-urlencoded', - }, - body: 'markdown=' + encodeURIComponent(this.value), - }) - .then(response => response.text()) - .then(data => { - preview.innerHTML = decodeURIComponent(data); - }); -}); +if (largeScreenMediaQuery.matches) { + textarea.addEventListener('input', function() { + fetch('functions/preview.php', { // Create a separate preview.php file for real-time updates + method: 'POST', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + body: 'markdown=' + encodeURIComponent(this.value), + }) + .then(response => response.text()) + .then(data => { + preview.innerHTML = decodeURIComponent(data); + }); + }); +} else { + preview.style.display = 'none'; +}