Skip to content
This repository was archived by the owner on Jul 2, 2024. It is now read-only.

Commit 8069b35

Browse files
committed
feat : 북마크 버튼을 포스트 상단에도 추가 (#36)
- 블로그 포스트를 상단 블로그명 바로 옆에도 추가하도록 개선함 - 블로그 버튼 끼리 색깔이 동기화가 안되는 문제가 있음
1 parent 615fd22 commit 8069b35

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

frontend/src/bookmark.js

+18-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
function add_bookmark_button() {
2-
var bookmarkButton = createElement("button", { class: "bookmark-button" });
1+
function createBookmarkButton() {
2+
const bookmarkButton = createElement("button", { class: "bookmark-button" });
33
bookmarkButton.innerHTML =
44
'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M12 .587l3.668 7.568 8.332 1.151-6.064 5.828 1.48 8.279-7.416-3.967-7.417 3.967 1.481-8.279-6.064-5.828 8.332-1.151z"/></svg>';
55

6-
document.querySelector(".name").append(bookmarkButton);
7-
86
bookmarkButton.addEventListener("click", () => {
97
if (bookmarkButton.classList.contains("yellow-bookmark-button")) {
108
bookmarkButton.classList.remove("yellow-bookmark-button");
@@ -27,18 +25,30 @@ function add_bookmark_button() {
2725
payload: window.location.pathname.split("/")[1].substring(1),
2826
},
2927
(response) => {
30-
console.log(response.is_bookmarked);
3128
if (response.is_bookmarked) {
3229
bookmarkButton.classList.add("yellow-bookmark-button");
3330
} else {
3431
bookmarkButton.classList.remove("yellow-bookmark-button");
3532
}
3633
}
3734
);
35+
36+
return bookmarkButton;
3837
}
3938

40-
console.log(document.querySelector(".bookmark-button"));
4139
if (document.querySelector(".bookmark-button") == null) {
42-
add_bookmark_button();
43-
console.log("SUCCES add bookmark button");
40+
var blogProfile = document.querySelector("div > div.name");
41+
console.log(blogProfile);
42+
if (blogProfile != null && blogProfile != undefined) {
43+
var bookmarkButton = createBookmarkButton();
44+
blogProfile.append(bookmarkButton);
45+
console.log("SUCCES add bookmark button in blog profile");
46+
}
47+
48+
var username = document.querySelector("div.information > span.username");
49+
if (username != null && username != undefined) {
50+
var bookmarkButton = createBookmarkButton();
51+
username.after(bookmarkButton);
52+
console.log("SUCCES add bookmark button in top of post");
53+
}
4454
}

0 commit comments

Comments
 (0)