From 9d581a1019d1b62fe4be3300e57292b79fe484fe Mon Sep 17 00:00:00 2001 From: Vivek Panjwani Date: Fri, 20 Oct 2023 15:34:04 +0530 Subject: [PATCH] Update script.js --- script.js | 46 +++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/script.js b/script.js index f870b0c..cd0c976 100644 --- a/script.js +++ b/script.js @@ -1,5 +1,6 @@ const showImg = document.getElementById("user-image"); const hidePara = document.getElementById("droptext"); + document.getElementById("generate-button").addEventListener("click", function (event) { event.preventDefault(); @@ -7,6 +8,8 @@ document.getElementById("generate-button").addEventListener("click", function (e const userTitle = document.getElementById("title").value; const userLocation = document.getElementById("location").value; const userImageUrl = document.getElementById("image-url").value; + const userPhone = document.getElementById("phone").value; + const userEmail = document.getElementById("email").value; let userAbout = document.getElementById("about").value; if (userName !== "") { @@ -27,6 +30,14 @@ document.getElementById("generate-button").addEventListener("click", function (e document.getElementById("user-image").src = userImageUrl.replace(/["']/g, ''); } + if (userPhone !== "") { + document.getElementById("user-phone").textContent = userPhone; + } + + if (userEmail !== "") { + document.getElementById("user-email").textContent = userEmail; + } + if (userAbout !== "") { if (userAbout.length > 200) { userAbout = userAbout.substring(0, 200); // Truncate if longer than 200 characters @@ -35,29 +46,29 @@ document.getElementById("generate-button").addEventListener("click", function (e } function color() { - const collt=document.getElementById("coll-text").value; - const collh=document.getElementById("coll-head").value; - const collb=document.getElementById("coll-back").value; - const prev=document.getElementsByClassName("preview")[0]; - const abou=document.getElementsByClassName("About")[0]; + const collt = document.getElementById("coll-text").value; + const collh = document.getElementById("coll-head").value; + const collb = document.getElementById("coll-back").value; + const prev = document.getElementsByClassName("preview")[0]; + const abou = document.getElementsByClassName("About")[0]; var paragraphs = document.getElementsByClassName("pp"); var heading = document.getElementsByClassName("hh"); - prev.style.backgroundColor=collb; - abou.style.backgroundColor=collb; + prev.style.backgroundColor = collb; + abou.style.backgroundColor = collb; for (i = 0; i < paragraphs.length; i++) { - paragraphs[i].style.color =collt; + paragraphs[i].style.color = collt; } - + for (i = 0; i < heading.length; i++) { - heading[i].style.color =collh; + heading[i].style.color = collh; } } + color(); - -}); +}); const dropArea = document.getElementById("Profile"); @@ -65,10 +76,13 @@ dropArea.addEventListener("dragover", (e) => { e.preventDefault(); dropArea.classList.add("change"); }); + dropArea.addEventListener("dragleave", () => { dropArea.classList.remove("change"); }); + var imageUrl; + dropArea.addEventListener("drop", (e) => { dropArea.classList.remove("change"); e.preventDefault(); @@ -76,21 +90,20 @@ dropArea.addEventListener("drop", (e) => { var imageUrl = URL.createObjectURL(image); console.log(imageUrl); showImg.style.display = 'inline'; - hidePara.style.display = 'none'; + hidePara.style display = 'none'; const imageElement = document.getElementById("user-image"); imageElement.src = imageUrl; }); - const userImage = document.getElementById("user-image"); const zoomSlider = document.getElementById("zoom-slider"); const rotateSlider = document.getElementById("rotate-slider"); -zoomSlider.addEventListener("input", function() { +zoomSlider.addEventListener("input", function () { applyTransformations(); }); -rotateSlider.addEventListener("input", function() { +rotateSlider.addEventListener("input", function () { applyTransformations(); }); @@ -99,4 +112,3 @@ function applyTransformations() { const rotateValue = rotateSlider.value; userImage.style.transform = `scale(${scaleValue}) rotate(${rotateValue}deg)`; } -