demo-HTML-over-WebSockets-i.../apps/front/templates/partials/blog/single.html

70 lines
2.2 KiB
HTML
Raw Normal View History

2021-03-13 10:39:24 +01:00
<div class="container grid-md">
<article>
<h1>{{ post.title }}</h1>
<h2>{{ post.author }}</h2>
<div>{{ post.content }}</div>
</article>
<section id="comments">
<hr>
<h3>Comments</h3>
2021-03-21 12:53:47 +01:00
{# Form add comment #}
<form>
<div class="form-group">
<label class="form-label" for="new-name">Name</label>
<input class="form-input" type="text" id="new-name" placeholder="Name" value="{{ newName }}">
</div>
<div class="form-group">
<label class="form-label" for="new-message">Message</label>
<textarea class="form-input" id="new-message" placeholder="New message" rows="3">{{ newMessage }}</textarea>
</div>
<button data-id="{{ post.id }}" id="publish" class="btn">Publish</button>
{% if error %}
<div class="toast toast-error">
Fill in all fields
</div>
{% endif %}
</form>
<hr>
{# End Form add comment #}
{# All comment #}
2021-03-13 10:39:24 +01:00
{% for comment in comments %}
2021-03-21 12:53:47 +01:00
<article class="tile">
2021-03-13 10:39:24 +01:00
<div class="tile-icon">
<i class="icon icon-file centered"></i>
</div>
<div class="tile-content">
<p class="tile-title">{{ comment.name }}</p>
<p class="tile-subtitle">{{ comment.body }}</p>
</div>
2021-03-21 12:53:47 +01:00
</article>
2021-03-13 10:39:24 +01:00
<hr>
{% endfor %}
2021-03-21 12:53:47 +01:00
{# End All comment #}
2021-03-13 10:39:24 +01:00
</section>
2021-03-21 12:53:47 +01:00
</div>
<script>
// Open article
newName = document.querySelector('#new-name');
newMessage = document.querySelector('#new-message');
publish = document.querySelector('#publish');
publish.addEventListener('click', (event) => {
event.preventDefault();
document.$CHAT_SOCKET.send(JSON.stringify({
selector: "#main",
template: "partials/blog/single.html",
data: {
id: event.target.dataset.id,
newName: newName.value,
newMessage: newMessage.value,
newComment: true
}
}))
});
</script>