-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreatePost.js
42 lines (30 loc) · 1.06 KB
/
createPost.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
/* const chooseCategory = document.getElementById("choose-catedory");
const categoryInput = document.getElementById("add-category");
const categoryBtn = document.getElementById("add-category-btn"); */
const bannerImg = document.querySelector(".banner-img");
const uploadBanner = document.getElementById("uploadBanner");
/* categoryBtn.addEventListener("click", (e) => {
e.preventDefault();
let value = categoryInput.value;
if (value) {
let option = document.createElement("option");
option.value = value.toLowerCase();
option.textContent = value;
option.setAttribute("selected", true);
chooseCategory.appendChild(option);
categoryInput.value = "";
alert(`New category "${value}" added!`);
} else {
alert("Please enter a category name");
}
}); */
uploadBanner.addEventListener("change", () => {
const file = uploadBanner.files[0];
if (file) {
const reader = new FileReader();
reader.addEventListener("load", function () {
bannerImg.setAttribute("src", this.result);
});
reader.readAsDataURL(file);
}
});