WhisperMaPhone/main/templates/whispermaphone/index.html

55 lines
2.1 KiB
HTML
Raw Normal View History

2020-09-06 03:12:54 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
2020-09-06 16:39:00 +00:00
<meta name="viewport" content="width=device-width, initial-scale=1">
2020-09-06 03:12:54 +00:00
<title>Title</title>
2020-09-06 16:00:44 +00:00
2020-09-06 16:39:00 +00:00
{% load static %}
<link href="{% static "main/main.css" %}" rel="stylesheet">
2020-09-06 03:12:54 +00:00
</head>
<body>
2020-09-06 16:39:00 +00:00
<header><span class="text">Thoughts</span></header>
2020-09-06 04:06:16 +00:00
2020-09-06 16:00:44 +00:00
<section class="main-wrap">
2020-09-06 04:06:16 +00:00
{% for thought in thoughts %}
2020-09-06 16:00:44 +00:00
<div class="thought">
<div class="main-text">{{thought.text}}</div>
2020-09-06 17:23:30 +00:00
<div class="extended-text">{{thought.extended_text}}</div>
<span class="timestamp">{{thought.posted|date:"r"}}</span>
2020-09-06 04:06:16 +00:00
</div>
2020-09-06 16:39:00 +00:00
<hr class="thought-end">
{% endfor %}
2020-09-06 16:00:44 +00:00
</section>
<footer>Copyright Matthias @2020{% if authenticated %}
<a href="/post" style="color: var(--text-color); margin-left: 100px; text-decoration: none">POST</a>
{% endif %}</footer>
2020-09-06 16:00:44 +00:00
<script>
const els = document.querySelectorAll(".thought");
for (let el of els) {
const extended = el.querySelector(".extended-text");
2020-09-06 17:23:30 +00:00
extended.classList.add("hidden");
2020-09-06 16:00:44 +00:00
if (extended.textContent.length) {
const text = el.querySelector(".main-text");
const showMoreButton = document.createElement("button");
showMoreButton.appendChild(document.createTextNode("Show More"));
2020-09-06 17:23:30 +00:00
showMoreButton.classList.add("show-more");
2020-09-06 16:00:44 +00:00
showMoreButton.addEventListener("click", evt => {
// Remove our-self
showMoreButton.parentNode.removeChild(showMoreButton);
// Show the extended text
extended.classList.remove("hidden");
})
text.appendChild(showMoreButton);
}
2020-09-06 17:23:30 +00:00
const timestampEl = el.querySelector(".timestamp");
const time = new Date(timestampEl.textContent);
const ampm = time.getHours() > 12 ? "pm" : "am";
timestampEl.textContent = `${time.getFullYear()}-${time.getMonth()}-${time.getDate()}, ${Math.abs(time.getHours() - 12)}:${time.getMinutes()}${ampm}`
2020-09-06 16:00:44 +00:00
}
</script>
2020-09-06 03:12:54 +00:00
</body>
</html>