Skip to content

Commit

Permalink
Removed validate function
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexVOiceover committed Jan 24, 2024
1 parent b9d4ce4 commit 37fd33f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 48 deletions.
16 changes: 7 additions & 9 deletions public/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ body {

h1 {
font-family: var(--font-titles);
text-align: center;
}

p {
Expand Down Expand Up @@ -63,26 +62,25 @@ form {
display: flex;
flex-direction: column;
flex-wrap: wrap;
background-color: var(--neutral);

border: 0.3rem solid var(--neutral);
border-radius: 2px;
padding: 1rem;
width: auto;
max-width: 100%;
}

.backForm {
background: none;
padding: 0;
}
.backForm,
.deleteForm {
background: none;
padding: 0;
border: none;
}

.nameAndDate {
font-style: italic;
justify-content: flex-end;
font-size: small;
margin-bottom: 0.3rem;
}

ul {
Expand All @@ -91,11 +89,11 @@ ul {
}

li {
background-color: var(--neutral);
border: 0.3rem solid var(--neutral);
margin-bottom: 1rem;
padding: 1rem;
border-radius: 2px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
box-shadow: 6px 2px 4px rgba(0, 0, 0, 0.4);
gap: 0.5 rem;
}

Expand Down
40 changes: 1 addition & 39 deletions src/functions.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,3 @@
// function home(errors = {}, values = {}) {
// const title = 'Create post'
// const needBack = false
// const content = /*html*/ `
// <h1>New post</h1>
// <form method="POST">
// <p>
// <label for="nickname">Your Name</label>
// <input
// id="nickname"
// name="nickname"
// value="${values.nickname ? sanitize(values.nickname) : ''}"
// >
// ${validation(errors.nickname)}
// </p>
// <p>
// <label for="message">Text</label>
// <textarea
// id="message"
// name="message">${
// values.message ? sanitize(values.message) : ''
// }</textarea>
// ${validation(errors.message)}
// </p>
// <button class="right-button">Send</button>
// </form>
// `
// return layout(title, content, needBack)
// }

function sanitize(string) {
return string
.replace(/&/g, '&amp;')
Expand All @@ -37,12 +7,4 @@ function sanitize(string) {
.replace(/'/g, '&#039;')
}

function validation(message) {
if (message) {
return `<span style="color: red">${message}</span>`
} else {
return ''
}
}

module.exports = { sanitize, validation }
module.exports = { sanitize }
4 changes: 4 additions & 0 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,8 @@ server.post('/back', (req, res) => {
res.redirect('/')
})

server.post('/showPosts', (req, res) => {
res.redirect('/posts')
})

module.exports = server
4 changes: 4 additions & 0 deletions views/formPage.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,9 @@

<button class="right-button">Send</button>
</form>
<p></p>
<form class="backForm" action="/showPosts" method="POST">
<button type="submit">Show Posts</button>
</form>
</body>
</html>

0 comments on commit 37fd33f

Please sign in to comment.