|
@@ -0,0 +1,126 @@
|
|
|
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
|
|
|
+<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
|
|
|
+<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
|
|
|
+<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
|
|
|
+<%@ taglib uri = "http://java.sun.com/jsp/jstl/functions" prefix = "fn" %>
|
|
|
+<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
|
|
|
+
|
|
|
+<jsp:include page="/WEB-INF/jsp/include/head.jsp"></jsp:include>
|
|
|
+<script>
|
|
|
+ const validateForm = () => {
|
|
|
+ // client side validation
|
|
|
+ const editorForm = window.document.forms['editorForm'];
|
|
|
+ const articleTitle = editorForm['articleTitle'].value;
|
|
|
+ console.log(articleTitle);
|
|
|
+ if(articleTitle === null || articleTitle === ""){
|
|
|
+ alert("제목을 입력해주세요.");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ const subtitle = editorForm['subtitle'].value;
|
|
|
+ if(subtitle === null || subtitle === ""){
|
|
|
+ alert("부제목을 입력해주세요.");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ const articleBody = editorForm['article-body'].value;
|
|
|
+ if(articleBody === null || articleBody === ""){
|
|
|
+ alert("내용을 입력해주세요.");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ let tagList = [];
|
|
|
+ let index = 0;
|
|
|
+
|
|
|
+ // 엔터키 누를 시 태그 추가됨
|
|
|
+ function enterKey() {
|
|
|
+ if(window.event.keyCode === 13) {
|
|
|
+ let tag = event.target.value;
|
|
|
+ tagList.push(tag);
|
|
|
+ //태그 중복제거
|
|
|
+ let tags = tagList.filter((val, idx) => {
|
|
|
+ return tagList.indexOf(val) === idx;
|
|
|
+ });
|
|
|
+ event.preventDefault();
|
|
|
+ document.querySelector('.tag-list').innerHTML = tags.map((item, index) =>
|
|
|
+ `<span class="tag">
|
|
|
+ <i class="fas fa-times deleteBtn"
|
|
|
+ data-value=\${item}
|
|
|
+ onclick="delBtn()"> </i>
|
|
|
+ \${item}
|
|
|
+ </span>`
|
|
|
+ ).join("");
|
|
|
+ event.target.value = "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 태그 삭제
|
|
|
+ function delBtn(){
|
|
|
+ event.target.parentElement.remove();
|
|
|
+
|
|
|
+ let delList = document.querySelectorAll( ".deleteBtn" );
|
|
|
+ tagList = []
|
|
|
+ delList.forEach((val , idx) => {
|
|
|
+ tagList.push(val.dataset.value);
|
|
|
+ });
|
|
|
+ }
|
|
|
+</script>
|
|
|
+</head>
|
|
|
+<body>
|
|
|
+ <jsp:include page="/WEB-INF/jsp/include/header.jsp"></jsp:include>
|
|
|
+
|
|
|
+ <!-- Editor -->
|
|
|
+ <div class="container main editor-page">
|
|
|
+ <div class="row">
|
|
|
+ <div class="col-10">
|
|
|
+ <form
|
|
|
+ name="editorForm"
|
|
|
+ id="editor-form"
|
|
|
+ class="form-group"
|
|
|
+ method="post"
|
|
|
+ action="/"
|
|
|
+ onsubmit="return validateForm()">
|
|
|
+ <div class="form-data">
|
|
|
+ <input
|
|
|
+ type="text"
|
|
|
+ class="form-control"
|
|
|
+ name="articleTitle"
|
|
|
+ placeholder ="Article Title"
|
|
|
+ autocomplete="off"
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ <div class="form-data">
|
|
|
+ <input
|
|
|
+ type="text"
|
|
|
+ class="form-control form-control-sm"
|
|
|
+ name="subtitle"
|
|
|
+ placeholder ="What's this article about?"
|
|
|
+ autocomplete="off"
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ <div class="form-data">
|
|
|
+ <textarea
|
|
|
+ class="form-control form-control-sm"
|
|
|
+ rows="8"
|
|
|
+ name="article-body"
|
|
|
+ placeholder="Write your article (in markdown)"
|
|
|
+ ></textarea>
|
|
|
+ </div>
|
|
|
+ <div class="form-data">
|
|
|
+ <input
|
|
|
+ type="text"
|
|
|
+ class="form-control form-control-sm tag-form"
|
|
|
+ name="tags"
|
|
|
+ placeholder="Enter tags"
|
|
|
+ autocomplete="off"
|
|
|
+ onkeydown="enterKey()">
|
|
|
+ <div class="tag-list">
|
|
|
+
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <button class="btn-signUp">Publish Article</button>
|
|
|
+ </form>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</body>
|
|
|
+</html>
|