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

Commit c5306af

Browse files
committed
feat : 알림이 없을 때 표시되는 메시지 추가 (#15)
알림이 없을 때 아래와 같은 메시지가 출력됩니다. ``` Velog Helper를 사용해보세요! 새 글 알림이 없습니다. 블로그에 가서 별 모양 북마크 버튼을 눌러보세요. 이미 눌렀다면 잠시만 기다려주세요. (최대 15분) ```
1 parent 5b58605 commit c5306af

File tree

1 file changed

+74
-24
lines changed

1 file changed

+74
-24
lines changed

frontend/src/util.js

Lines changed: 74 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,90 @@ function createElement(tag, attrs) {
77
return el;
88
}
99

10+
function createNoticeitem(item, isNotice) {
11+
const itemDiv = createElement("div", { class: "notice-item" });
12+
13+
const BlogImgContainer = createElement("a", {
14+
class: "notice-blog-img-container",
15+
href: `https://velog.io/@${item.user}/`,
16+
target: "_blank",
17+
});
18+
19+
const itemBlogImg = createElement("img", {
20+
src: item.user_img,
21+
class: "notice-blog-img",
22+
});
23+
24+
BlogImgContainer.append(itemBlogImg);
25+
26+
const itemTitle = createElement("a", {
27+
class: "notice-post-title",
28+
href: `https://velog.io/@${item.user}/${item.link}`,
29+
target: "_blank",
30+
});
31+
32+
itemTitle.innerHTML = item.title;
33+
const itemDate = createElement("div", { class: "notice-date" });
34+
35+
if (isNotice) {
36+
itemTitle.setAttribute("style", "width : 350px;");
37+
itemTitle.setAttribute("href", item.link);
38+
itemDate.setAttribute("style", "width : 0;padding : 0;");
39+
itemDate.innerHTML = "";
40+
} else {
41+
itemDate.innerHTML = item.created_at.substring(5, 10);
42+
}
43+
44+
itemDiv.append(BlogImgContainer, itemTitle, itemDate);
45+
return itemDiv;
46+
}
47+
1048
function createNoticeItems() {
1149
const noticeItemsDiv = createElement("div", { class: "notice-item-div" });
1250
chrome.runtime.sendMessage(
1351
{
1452
message: "get_new_post",
1553
},
1654
(response) => {
17-
response.data.forEach(function (item, index, array) {
18-
const itemDiv = createElement("div", { class: "notice-item" });
19-
20-
const BlogImgContainer = createElement("a", {
21-
class: "notice-blog-img-container",
22-
href: `https://velog.io/@${item.user}/`,
23-
target: "_blank",
24-
});
25-
26-
const itemBlogImg = createElement("img", {
27-
src: item.user_img,
28-
class: "notice-blog-img",
29-
});
30-
31-
BlogImgContainer.append(itemBlogImg);
55+
if (response.data.length == 0) {
56+
const items = [
57+
{
58+
user_img:
59+
"https://lh3.googleusercontent.com/QO4AoAGH0U9IcMouWT_m2GNvMy4P4eFwmEpVxakU4xOwGH9YpGMSgsU5alalzZf2PFg6KGL3DbA0khc8a7xiNQnuwg=w128-h128-e365-rj-sc0x00ffffff",
60+
link: "https://github.com/junah201/velog-helper",
61+
title: "Velog Helper를 사용해보세요!",
62+
},
63+
{
64+
user_img:
65+
"https://lh3.googleusercontent.com/QO4AoAGH0U9IcMouWT_m2GNvMy4P4eFwmEpVxakU4xOwGH9YpGMSgsU5alalzZf2PFg6KGL3DbA0khc8a7xiNQnuwg=w128-h128-e365-rj-sc0x00ffffff",
66+
link: "https://github.com/junah201/velog-helper",
67+
title: "새 글 알림이 없습니다.",
68+
},
69+
{
70+
user_img:
71+
"https://lh3.googleusercontent.com/QO4AoAGH0U9IcMouWT_m2GNvMy4P4eFwmEpVxakU4xOwGH9YpGMSgsU5alalzZf2PFg6KGL3DbA0khc8a7xiNQnuwg=w128-h128-e365-rj-sc0x00ffffff",
72+
link: "https://github.com/junah201/velog-helper",
73+
title: "블로그에 가서 별 모양 북마크 버튼을 눌러보세요.",
74+
},
75+
{
76+
user_img:
77+
"https://lh3.googleusercontent.com/QO4AoAGH0U9IcMouWT_m2GNvMy4P4eFwmEpVxakU4xOwGH9YpGMSgsU5alalzZf2PFg6KGL3DbA0khc8a7xiNQnuwg=w128-h128-e365-rj-sc0x00ffffff",
78+
link: "https://github.com/junah201/velog-helper",
79+
title: "이미 눌렀다면 잠시만 기다려주세요. (최대 15분)",
80+
},
81+
];
3282

33-
const itemTitle = createElement("a", {
34-
class: "notice-post-title",
35-
href: `https://velog.io/@${item.user}/${item.link}`,
36-
target: "_blank",
83+
items.forEach(function (item, index, array) {
84+
noticeItemsDiv.append(
85+
createNoticeitem((item = item), (isNotice = true))
86+
);
3787
});
88+
}
3889

39-
itemTitle.innerHTML = item.title;
40-
const itemDate = createElement("div", { class: "notice-date" });
41-
itemDate.innerHTML = item.created_at.substring(5, 10);
42-
itemDiv.append(BlogImgContainer, itemTitle, itemDate);
43-
noticeItemsDiv.append(itemDiv);
90+
response.data.forEach(function (item, index, array) {
91+
noticeItemsDiv.append(
92+
createNoticeitem((item = item), (isNotice = false))
93+
);
4494
});
4595
}
4696
);

0 commit comments

Comments
 (0)