|
@@ -7,7 +7,117 @@
|
|
|
|
|
|
<jsp:include page="/WEB-INF/jsp/include/head.jsp"></jsp:include>
|
|
|
<script>
|
|
|
+ let targetFeed = null;
|
|
|
+ const loadingArticles = document.querySelector('#article-loading');
|
|
|
+ const articleList = document.querySelector('#article-list');
|
|
|
|
|
|
+ const setLoading = (type) => {
|
|
|
+ let loadingDisplay = null;
|
|
|
+ let contentDisplay = null;
|
|
|
+
|
|
|
+ if(type === 'on') {
|
|
|
+ loadingDisplay = 'block';
|
|
|
+ contentDisplay = 'none';
|
|
|
+ } else if(type === 'off') {
|
|
|
+ loadingDisplay = 'none';
|
|
|
+ contentDisplay = 'block';
|
|
|
+ }
|
|
|
+
|
|
|
+ loadingArticles.style.display = loadingDisplay;
|
|
|
+ articleList.style.display = contentDisplay;
|
|
|
+ }
|
|
|
+
|
|
|
+ const focusFeed = () => {
|
|
|
+ // 이미 포커싱되었으면 중단
|
|
|
+ if(event.target.parentNode.classList.contains('active')) {
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+
|
|
|
+ const currentFeed = event.target.parentNode; // 포커싱할 피드
|
|
|
+ const focusedFeed = (currentFeed.id === 'favorite-feed') ? document.querySelector('#your-feed') : document.querySelector('#favorite-feed'); // 현재 포커싱되어있는 피드
|
|
|
+
|
|
|
+ currentFeed.classList.add('active');
|
|
|
+ focusedFeed.classList.remove('active');
|
|
|
+
|
|
|
+ // targetFeed 초기화
|
|
|
+ targetFeed = currentFeed;
|
|
|
+ setLoading('on');
|
|
|
+ }
|
|
|
+
|
|
|
+ const displayArticles = (articles) => {
|
|
|
+ articles.forEach(article => {
|
|
|
+ const domParser = new DOMParser();
|
|
|
+
|
|
|
+ // 게시글 정보
|
|
|
+ const domStrArticleMeta =
|
|
|
+ `
|
|
|
+ <div class="article-meta">
|
|
|
+ <div class="metadata">
|
|
|
+ <a href="javascript.void(0);">
|
|
|
+ <img src"/resources/images/avatar.png" alt="avatar">
|
|
|
+ </a>
|
|
|
+ <div class="article-info">
|
|
|
+ <a href="javascript.void(0);" class="name">\${article.writerName}</a>
|
|
|
+ <span class="date"></span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <button class="favorite-btn" onclick="favoriteBtn(\${article.id})">
|
|
|
+ <i class="fas fa-heart"></i>
|
|
|
+ <span class="count">\${article.favoriteNum}</span>
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ `;
|
|
|
+ const divArticleMeta = domParser.parseFromString(domStrArticleMeta, 'text/html').body.firstChild;
|
|
|
+ divArticleMeta.querySelector('.date').textContent = new Date(article.create).toLocaleString();
|
|
|
+
|
|
|
+ // 게시글 좋아요한 경우 active
|
|
|
+ if (article.favorite) {
|
|
|
+ divArticleMeta.querySelector('.favorite-btn').classList.add('active');
|
|
|
+ }
|
|
|
+
|
|
|
+ // 게시글 내용 및 게시글태그
|
|
|
+ const domStrPreviewLink =
|
|
|
+ `
|
|
|
+ <a href="/article/\${articleId}" class="preview-link">
|
|
|
+ <h1 class="preview-title">\${articleTitle}</h1>
|
|
|
+ <p>\${articleSubtitle}</p>
|
|
|
+ <div class="tag-data">
|
|
|
+ <span>Read more...</span>
|
|
|
+ <ul class="tag-list">
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+ </a>
|
|
|
+ `;
|
|
|
+ const aPreviewLink = domParser.parseFromString(domStrPreviewLink, 'text/html').body.firstChild;
|
|
|
+ const ul = aPreviewLink.querySelector('.tag-list');
|
|
|
+
|
|
|
+ if (article.tags !== '') {
|
|
|
+ article.tags.split(',').forEach(tag => {
|
|
|
+ if(!tagSet.has(tag)) {
|
|
|
+ tagSet.add(tag);
|
|
|
+ }
|
|
|
+
|
|
|
+ const li = document.createElement('li');
|
|
|
+ li.classList.add('tag');
|
|
|
+ li.textContent = tag;
|
|
|
+ ul.appendChild(li);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 게시글 완성
|
|
|
+ const articlePreview = document.createElement('article');
|
|
|
+ articlePreview.classList.add('article-preview');
|
|
|
+ articlePreview.append(divArticleMeta, aPreviewLink);
|
|
|
+ articleList.appendChild(articlePreview);
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ window.onload = () => {
|
|
|
+ targetFeed = document.querySelector('.nav-item.active');
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
</script>
|
|
|
</head>
|
|
@@ -25,7 +135,14 @@
|
|
|
<h4 class="user-name">username</h4>
|
|
|
<p class="profile-bio">short bio</p>
|
|
|
<a href="settings.html" class="action-btn btn-sm">
|
|
|
- <i class="fas fa-cog"></i> Edit Profile Settings
|
|
|
+ <c:choose>
|
|
|
+ <c:when test="{id eq ssId}">
|
|
|
+ <i class="fas fa-cog"></i> Edit Profile Settings
|
|
|
+ </c:when>
|
|
|
+ <c:otherwise>
|
|
|
+ <i class="fas fa-plus"></i> Follow Gerome
|
|
|
+ </c:otherwise>
|
|
|
+ </c:choose>
|
|
|
</a>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -38,103 +155,113 @@
|
|
|
<!-- 토글 버튼으로 피드 내용 보기 -->
|
|
|
<div class="toggle">
|
|
|
<ul class="nav">
|
|
|
- <li class="nav-item active">
|
|
|
- <a href="#">My Articles</a>
|
|
|
+ <li id="your-feed" class="nav-item active">
|
|
|
+ <a href="javascript:void(0);" onclick="focusFeed()">My Articles</a>
|
|
|
</li>
|
|
|
- <li class="nav-item">
|
|
|
- <a href="userpage-favorited.html">Favorited Articles</a>
|
|
|
+ <li id="favoreted-feed" class="nav-item">
|
|
|
+ <a href="javascript:void(0);" onclick="focusFeed()">Favorited Articles</a>
|
|
|
</li>
|
|
|
</ul>
|
|
|
</div>
|
|
|
+
|
|
|
+ <!-- Content -->
|
|
|
<div class="article">
|
|
|
- <article class="article-preview">
|
|
|
- <div class="article-meta">
|
|
|
- <div class="metadata">
|
|
|
- <a href="#" class="profile-link">
|
|
|
- <img src="img/avatar.jpg" alt="">
|
|
|
- </a>
|
|
|
- <div class="article-info">
|
|
|
- <a href="#" class="name">username</a>
|
|
|
- <span class=date>November 24, 2021</span>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- <button class="favorite-btn">
|
|
|
- <i class="fas fa-heart"></i>
|
|
|
- <span class="count">564</span>
|
|
|
- </button>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <a href="article-my.html" class="preview-link">
|
|
|
- <h1 class="preview-title">Create a new implementation</h1>
|
|
|
- <p>join the community by creating a new implementation</p>
|
|
|
- <div class="tag-data">
|
|
|
- <span>Read more...</span>
|
|
|
- <ul class="tag-list">
|
|
|
- <li class="tag">implementations</li>
|
|
|
- <li class="tag">implementations</li>
|
|
|
- </ul>
|
|
|
- </div>
|
|
|
- </a>
|
|
|
+ <!-- Article Loading -->
|
|
|
+ <article id="article-loading">
|
|
|
+ Loading articles...
|
|
|
</article>
|
|
|
- <article class="article-preview">
|
|
|
- <div class="article-meta">
|
|
|
- <div class="metadata">
|
|
|
- <a href="#" class="profile-link">
|
|
|
- <img src="img/avatar.jpg" alt="">
|
|
|
- </a>
|
|
|
- <div class="article-info">
|
|
|
- <a href="#" class="name">username</a>
|
|
|
- <span class=date>November 24, 2021</span>
|
|
|
+
|
|
|
+ <!-- Article List -->
|
|
|
+ <div id="article-list" style="display: none;">
|
|
|
+ <!-- <article class="article-preview">
|
|
|
+ <div class="article-meta">
|
|
|
+ <div class="metadata">
|
|
|
+ <a href="#" class="profile-link">
|
|
|
+ <img src="img/avatar.jpg" alt="">
|
|
|
+ </a>
|
|
|
+ <div class="article-info">
|
|
|
+ <a href="#" class="name">username</a>
|
|
|
+ <span class=date>November 24, 2021</span>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- <button class="favorite-btn">
|
|
|
- <i class="fas fa-heart"></i>
|
|
|
- <span class="count">564</span>
|
|
|
- </button>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <a href="article-my.html" class="preview-link">
|
|
|
- <h1 class="preview-title">Create a new implementation</h1>
|
|
|
- <p>join the community by creating a new implementation</p>
|
|
|
- <div class="tag-data">
|
|
|
- <span>Read more...</span>
|
|
|
- <ul class="tag-list">
|
|
|
- <li class="tag">implementations</li>
|
|
|
- </ul>
|
|
|
- </div>
|
|
|
- </a>
|
|
|
- </article>
|
|
|
- <article class="article-preview">
|
|
|
- <div class="article-meta">
|
|
|
- <div class="metadata">
|
|
|
- <a href="#" class="profile-link">
|
|
|
- <img src="img/avatar.jpg" alt="">
|
|
|
- </a>
|
|
|
- <div class="article-info">
|
|
|
- <a href="#" class="name">username</a>
|
|
|
- <span class=date>November 24, 2021</span>
|
|
|
+ <div>
|
|
|
+ <button class="favorite-btn">
|
|
|
+ <i class="fas fa-heart"></i>
|
|
|
+ <span class="count">564</span>
|
|
|
+ </button>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div>
|
|
|
- <button class="favorite-btn">
|
|
|
- <i class="fas fa-heart"></i>
|
|
|
- <span class="count">564</span>
|
|
|
- </button>
|
|
|
+ <a href="article-my.html" class="preview-link">
|
|
|
+ <h1 class="preview-title">Create a new implementation</h1>
|
|
|
+ <p>join the community by creating a new implementation</p>
|
|
|
+ <div class="tag-data">
|
|
|
+ <span>Read more...</span>
|
|
|
+ <ul class="tag-list">
|
|
|
+ <li class="tag">implementations</li>
|
|
|
+ <li class="tag">implementations</li>
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+ </a>
|
|
|
+ </article>
|
|
|
+ <article class="article-preview">
|
|
|
+ <div class="article-meta">
|
|
|
+ <div class="metadata">
|
|
|
+ <a href="#" class="profile-link">
|
|
|
+ <img src="img/avatar.jpg" alt="">
|
|
|
+ </a>
|
|
|
+ <div class="article-info">
|
|
|
+ <a href="#" class="name">username</a>
|
|
|
+ <span class=date>November 24, 2021</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <button class="favorite-btn">
|
|
|
+ <i class="fas fa-heart"></i>
|
|
|
+ <span class="count">564</span>
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
- <a href="article-my.html" class="preview-link">
|
|
|
- <h1 class="preview-title">Create a new implementation</h1>
|
|
|
- <p>join the community by creating a new implementation</p>
|
|
|
- <div class="tag-data">
|
|
|
- <span>Read more...</span>
|
|
|
- <ul class="tag-list">
|
|
|
- <li class="tag">implementations</li>
|
|
|
- </ul>
|
|
|
+ <a href="article-my.html" class="preview-link">
|
|
|
+ <h1 class="preview-title">Create a new implementation</h1>
|
|
|
+ <p>join the community by creating a new implementation</p>
|
|
|
+ <div class="tag-data">
|
|
|
+ <span>Read more...</span>
|
|
|
+ <ul class="tag-list">
|
|
|
+ <li class="tag">implementations</li>
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+ </a>
|
|
|
+ </article>
|
|
|
+ <article class="article-preview">
|
|
|
+ <div class="article-meta">
|
|
|
+ <div class="metadata">
|
|
|
+ <a href="#" class="profile-link">
|
|
|
+ <img src="img/avatar.jpg" alt="">
|
|
|
+ </a>
|
|
|
+ <div class="article-info">
|
|
|
+ <a href="#" class="name">username</a>
|
|
|
+ <span class=date>November 24, 2021</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <button class="favorite-btn">
|
|
|
+ <i class="fas fa-heart"></i>
|
|
|
+ <span class="count">564</span>
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- </a>
|
|
|
- </article>
|
|
|
+ <a href="article-my.html" class="preview-link">
|
|
|
+ <h1 class="preview-title">Create a new implementation</h1>
|
|
|
+ <p>join the community by creating a new implementation</p>
|
|
|
+ <div class="tag-data">
|
|
|
+ <span>Read more...</span>
|
|
|
+ <ul class="tag-list">
|
|
|
+ <li class="tag">implementations</li>
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+ </a>
|
|
|
+ </article> -->
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|