|
@@ -18,7 +18,8 @@
|
|
|
// 2. 태그를 클릭한 경우
|
|
|
const filterArticle = (option) => {
|
|
|
const { clickedTag, clickedFeed } = option;
|
|
|
- const articles = window.document.querySelectorAll('.article-preview');
|
|
|
+ const articles = window.document.querySelectorAll('.article-preview');
|
|
|
+ const articleList = document.querySelector('#article-list');
|
|
|
|
|
|
articles.forEach(article => {
|
|
|
const writerName = article.querySelector('.name').textContent;
|
|
@@ -43,6 +44,10 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // if ((targetFeed.id === 'global-feed' && display === 'none') || (targetFeed.id === 'your-feed' && display === 'none')) {
|
|
|
+ // articleList.innerHTML = `<article class="noArticle">Feed not here yet.</article>`
|
|
|
+ // }
|
|
|
+
|
|
|
article.style.display = display;
|
|
|
});
|
|
|
};
|
|
@@ -89,6 +94,7 @@
|
|
|
}, 2000);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
function favoriteBtn(indexNumber) {
|
|
|
const favBtn = document.querySelectorAll('.favorite-btn');
|
|
|
if ("${ssIsLogin}" === "true") {
|
|
@@ -102,6 +108,7 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
window.onload = (event) => {
|
|
|
|
|
|
ssIsLogin = "${ssIsLogin}";
|
|
@@ -131,7 +138,7 @@
|
|
|
|
|
|
console.log(JSON.stringify(article))
|
|
|
const domParser = new DOMParser();
|
|
|
-
|
|
|
+
|
|
|
//태그 배열 생성
|
|
|
const tagsArray = article.tags.split(',')
|
|
|
tagsArray.forEach(tag => {
|
|
@@ -144,6 +151,9 @@
|
|
|
`
|
|
|
<div class="article-meta">
|
|
|
<div class="metadata">
|
|
|
+ <a href="#" class="profile-link">
|
|
|
+ <img src="/resources/images/avatar.png" alt="avatar">
|
|
|
+ </a>
|
|
|
<div class="article-info">
|
|
|
<a href="#" class="name"></a>
|
|
|
<span class="date"></span>
|
|
@@ -156,7 +166,7 @@
|
|
|
</button>
|
|
|
</div>
|
|
|
</div>
|
|
|
- `;
|
|
|
+ `;
|
|
|
const divArticleMeta = domParser.parseFromString(domStrArticleMeta, 'text/html').body.firstChild;
|
|
|
divArticleMeta.querySelector('.name').textContent = article.writerName;
|
|
|
divArticleMeta.querySelector('.date').textContent = new Date(article.created).toLocaleString();
|
|
@@ -174,12 +184,12 @@
|
|
|
</ul>
|
|
|
</div>
|
|
|
</a>
|
|
|
- `;
|
|
|
+ `;
|
|
|
const aPreviewLink = domParser.parseFromString(domStrPreviewLink, 'text/html').body.firstChild;
|
|
|
aPreviewLink.querySelector('.preview-title').textContent = article.title;
|
|
|
aPreviewLink.querySelector('p').textContent = article.subtitle;
|
|
|
const ul = aPreviewLink.querySelector('.tag-list');
|
|
|
-
|
|
|
+
|
|
|
if (article.tags !== '') {
|
|
|
article.tags.split(',').forEach(tag => {
|
|
|
if (!tagSet.has(tag)) {
|
|
@@ -203,10 +213,10 @@
|
|
|
articlePreview.style.display = (username === article.writerName) ? 'block' : 'none';
|
|
|
}
|
|
|
|
|
|
- articleList.appendChild(articlePreview);
|
|
|
- console.log(articlePreview);
|
|
|
+ articleList.appendChild(articlePreview);
|
|
|
});
|
|
|
|
|
|
+ //태그 정렬
|
|
|
const tags = Array.from(tagSet);
|
|
|
const tagList = window.document.querySelector('#tag-list');
|
|
|
function getSortedArr(array) {
|
|
@@ -214,6 +224,7 @@
|
|
|
pv[cv] = (pv[cv] || 0) + 1;
|
|
|
return pv;
|
|
|
}, {});
|
|
|
+
|
|
|
const result = [];
|
|
|
for (let key in counts) {
|
|
|
result.push([key, counts[key]]);
|
|
@@ -222,21 +233,22 @@
|
|
|
result.sort((first, second) => {
|
|
|
return second[1] - first[1];
|
|
|
});
|
|
|
- return result;
|
|
|
+
|
|
|
+ return result.slice(0, 10);
|
|
|
}
|
|
|
|
|
|
getSortedArr(tagArray).forEach(tag => {
|
|
|
const a = document.createElement('a');
|
|
|
const tagString = tag.join(',');
|
|
|
const tagValue = tagString.substring(0, tagString.lastIndexOf(','));
|
|
|
- const tagCount = tagString.substring(tagString.lastIndexOf(',')+1);
|
|
|
+ const tagCount = tagString.substring(tagString.lastIndexOf(',') + 1);
|
|
|
+
|
|
|
a.classList.add("tag");
|
|
|
a.textContent = `\${tagValue} (\${tagCount})`
|
|
|
a.onclick = () => {
|
|
|
filterArticle({ 'clickedTag': tagValue });
|
|
|
}
|
|
|
tagList.appendChild(a);
|
|
|
- console.log(tagList.appendChild(a));
|
|
|
});
|
|
|
|
|
|
// hide loadings
|
|
@@ -301,9 +313,10 @@
|
|
|
<article id="article-loading">
|
|
|
loading articles...
|
|
|
</article>
|
|
|
-
|
|
|
+
|
|
|
<!-- article list -->
|
|
|
<div id="article-list" style="display: none;">
|
|
|
+ <!-- <article class="noArticle" style="display: none;">Feed not here yet.</article> -->
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|