From 0360314a4c8e81f70cba1fb95c217fe0039f6ce2 Mon Sep 17 00:00:00 2001 From: yeop Date: Wed, 13 Jul 2022 16:23:09 +0900 Subject: [PATCH] Remove textContents when element not changed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 데이터가 입력되지 않았으면 export시 해당 textContent를 지워주는 기능 추가 --- app.js | 13 ++++++++----- index.html | 6 +++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app.js b/app.js index 9af3389..e98c104 100644 --- a/app.js +++ b/app.js @@ -12,8 +12,14 @@ const produceImageBtn = document.querySelector('#export'); const captureModal = document.querySelector('.capture_modal'); const mod = document.querySelectorAll('.mod'); const overlay = document.querySelector('.overlay'); +const inputFields = document.querySelectorAll('.input__field'); const captureExport = function () { + inputFields.forEach((e) => { + if(e.dataset['changed'] != true) { + document.querySelector(`.${e.dataset['set']}`).textContent = ''; + } + }) html2canvas(document.querySelector('#capture'), { logging: true, letterRendering: 1, @@ -24,7 +30,7 @@ const captureExport = function () { }); mod.forEach((e) => e.classList.remove('hidden')); -}; +}; const removeCapture = function () { captureModal.removeChild(captureModal.firstElementChild); @@ -40,13 +46,10 @@ window.addEventListener('keydown', (e) => { } }); -// INPUT IMPLEMENTING - -const inputFields = document.querySelectorAll('.input__field'); - const updateInputValue = function (e) { const target = e.target.dataset.set; document.querySelector(`.${target}`).textContent = e.target.value; + e.dataset['changed'] = true; }; inputFields.forEach((e) => { diff --git a/index.html b/index.html index 3ff94e0..785dec3 100644 --- a/index.html +++ b/index.html @@ -40,9 +40,9 @@

# Thumbnail Maker

- - - + + +