forked from RahulBRB/ID-Card-Generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
111 lines (90 loc) · 3.64 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
const showImg = document.getElementById("user-image");
const hidePara = document.getElementById("droptext");
document.getElementById("generate-button").addEventListener("click", function (event) {
event.preventDefault();
const userName = document.getElementById("name").value;
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 !== "") {
document.getElementById("user-name").textContent = userName;
}
if (userTitle !== "") {
document.getElementById("user-title").textContent = userTitle;
}
if (userLocation !== "") {
document.getElementById("user-location").textContent = userLocation;
}
if (userImageUrl) {
showImg.style.display = 'inline';
hidePara.style.display = 'none';
document.getElementById("user-image").src = userImageUrl.replace(/["']/g, '');
}
if (userPhone !== "") {
document.getElementById("user-phone").textContent = userPhone; // Update phone element
}
if (userEmail !== "") {
document.getElementById("user-email").textContent = userEmail; // Update email element
}
if (userAbout !== "") {
if (userAbout.length > 200) {
userAbout = userAbout.substring(0, 200); // Truncate if longer than 200 characters
}
document.getElementById("user-about").textContent = userAbout;
}
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];
var paragraphs = document.getElementsByClassName("pp");
var heading = document.getElementsByClassName("hh");
prev.style.backgroundColor=collb;
abou.style.backgroundColor=collb;
for (i = 0; i < paragraphs.length; i++) {
paragraphs[i].style.color =collt;
}
for (i = 0; i < heading.length; i++) {
heading[i].style.color =collh;
}
}
color();
});
const dropArea = document.getElementById("Profile");
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();
const image = e.dataTransfer.files[0];
var imageUrl = URL.createObjectURL(image);
console.log(imageUrl);
showImg.style.display = 'inline';
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() {
applyTransformations();
});
rotateSlider.addEventListener("input", function() {
applyTransformations();
});
function applyTransformations() {
const scaleValue = zoomSlider.value;
const rotateValue = rotateSlider.value;
userImage.style.transform = `scale(${scaleValue}) rotate(${rotateValue}deg)`;
}