-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
196 lines (155 loc) · 6.44 KB
/
main.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
// ##### MODO CLARO - OBSCURO ##### //
const headeR = document.getElementById("header-");
//console.log(headeR)
const maiN = document.getElementById("main-");
//console.log(maiN)
const divAsideImg = document.getElementById("div-asideImg");
//console.log(divAsideImg)
const divAsideTxt = document.getElementById("div-asideTxt");
//console.log(divAsideTxt)
const modeButton = document.getElementById("btn-claro");
modeButton.addEventListener("click", () => newMode());
const newMode = () => {
divAsideTxt.classList.toggle("bright-header");
divAsideImg.classList.toggle("bright-header");
headeR.classList.toggle("bright-header");
maiN.classList.toggle("bright-header");
if (divAsideTxt.classList.contains("bright-header")) {
modeButton.innerText = "🌑 Modo obscuro";
} else {
modeButton.innerText = "💡 Modo claro";
}
};
// ####### ESCONDER ASIDES ######## //
const btnTxt = document.getElementById("btn-txt");
const btnImg = document.getElementById("btn-img");
const asideTxt = document.getElementById("aside-Txt");
const asideImg = document.getElementById("aside-Img");
btnTxt.addEventListener("click", () => meJuiTxt());
btnImg.addEventListener("click", () => meJuiImg());
const meJuiTxt = () => {
asideImg.classList.add("noToy");
asideTxt.classList.remove("noToy");
};
const meJuiImg = () => {
asideTxt.classList.add("noToy");
asideImg.classList.remove("noToy");
};
// ##### DESCARGAR MEME ##### //
const downloadButton = document.getElementById("btn-descarga");
const meme = document.getElementById("recuadro-padre");
downloadButton.addEventListener("click", () => downloadMeme());
const downloadMeme = () => {
domtoimage.toBlob(meme).then(function (blob) {
window.saveAs(blob, "mi-meme.png");
});
};
// *************** ASIDE IMG ************** //
// MEME URL
const urlInput = document.getElementById("url-input");
const imgMeme = document.getElementById("img-meme");
urlInput.addEventListener("input", (e) => changeBackground(e));
const changeBackground = (e) => {
imgMeme.style.backgroundImage = `url('${e.target.value}')`;
imgMeme.style.backgroundSize = "contain";
imgMeme.style.backgroundRepeat = "no-repeat";
imgMeme.style.backgroundPosition = "center";
};
// BG COLOR
const inputCircle = document.getElementById("input-circle");
//console.log(inputCircle.value)
const colorName = document.getElementById("input-ColorName");
//console.log(colorName)
inputCircle.addEventListener("input", () => changeBGcolor());
const changeBGcolor = () => {
let circleColorChoose = inputCircle.value;
imgMeme.style.backgroundColor = `${circleColorChoose}`;
colorName.innerHTML = circleColorChoose;
};
// BACKGROUND select //
const effectSelect = document.getElementById("effect-select");
//console.log(effectSelect)
effectSelect.addEventListener("change", () => changeEffects());
function changeEffects() {
imgMeme.style.backgroundBlendMode = `${effectSelect.value}`;
};
// FILTROS IMG
const brightFilter = document.getElementById("bright-filter");
brightFilter.addEventListener("input", () => filtros());
//console.log(brightFilter);
const opFilter = document.getElementById("op-filter");
opFilter.addEventListener("input", () => filtros());
// console.log(opFilter.value);
const contrastFilter = document.getElementById("contrast-filter");
contrastFilter.addEventListener("input", () => filtros());
// console.log(contrastFilter.value);
const blurFilter = document.getElementById("blur-filter");
blurFilter.addEventListener("input", () => filtros());
// console.log(blurFilter.value);
const grayScaleFilter = document.getElementById("gray-scale-filter");
grayScaleFilter.addEventListener("input", () => filtros());
// console.log(grayScaleFilter.value);
const sepiaFilter = document.getElementById("sepia-filter");
sepiaFilter.addEventListener("input", () => filtros());
// console.log(sepiaFilter.value);
const satFilter = document.getElementById("sat-filter");
satFilter.addEventListener("input", () => filtros());
// console.log(satFilter.value);
const hueFilter = document.getElementById("hue-filter");
hueFilter.addEventListener("input", () => filtros());
// console.log(satFilter.value);
const negativeFilter = document.getElementById("negative-filter");
negativeFilter.addEventListener("input", () => filtros());
// console.log(negativeFilter.value);
const filtros = () => {
imgMeme.style.filter = `brightness(${brightFilter.value}) opacity(${opFilter.value}) blur(${blurFilter.value}px) contrast(${contrastFilter.value}%) grayscale(${grayScaleFilter.value}%) hue-rotate(${hueFilter.value}deg) sepia(${sepiaFilter.value}%) saturate(${satFilter.value}%) invert(${negativeFilter.value})`;
};
// RESET BUTTON
const buttonReset = document.getElementById("button-reset");
//console.log(buttonReset)
buttonReset.addEventListener("click", () => resetButton());
const resetButton = () => {
imgMeme.style.filter = "none";
};
// ########### < ASIDE TXT > ########### //
// tOP y BOTTOM TEXT
const topText = document.getElementById("top-text");
const topTextMeme = document.getElementById("topText-meme");
//console.log(topTextMeme)
topText.addEventListener("input", () => changeText());
const bottomText = document.getElementById("bottom-text");
const bottomTextMeme = document.getElementById("bottom-textMeme");
bottomText.addEventListener("input", () => changeText());
const changeText = () => {
topTextMeme.innerText = topText.value;
bottomTextMeme.innerText = bottomText.value;
};
// CHECKBOX SIN TEXTO SUP/INF
const checkboxTxtSup = document.getElementById("checkbox-txtSup");
checkboxTxtSup.addEventListener("change", () => hiddenTxtTop());
//console.log(checkboxTxtSup.checked);
const checkboxTxtInf = document.getElementById("checkbox-txtInf");
checkboxTxtInf.addEventListener("change", () => hiddenTxtBottom());
const hiddenTxtTop = () => {
//console.log(checkboxTxtSup.checked);
if (checkboxTxtSup.checked) {
topTextMeme.classList.add("noToy");
} else {
topTextMeme.classList.remove("noToy");
}
};
const hiddenTxtBottom = () => {
if (checkboxTxtInf.checked) {
bottomTextMeme.classList.add("noToy");
} else {
bottomTextMeme.classList.remove("noToy");
}
};
// SELECT FUENTES
// ---- NO FUNCIONAAAAAAAAAAAA
const selectorFuentes = document.getElementById('selector-fuentes');
//console.log(selectorFuentes);
const eleccionFuentes = () => {
topText.style.fontFamily = `${selectorFuentes.value}`;
bottomText.style.fontFamily = `${selectorFuentes.value}`;
}