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-08 16:01:03 +00:00
|
|
|
<title>Thoughts</title>
|
2020-09-06 16:00:44 +00:00
|
|
|
|
2020-09-06 16:39:00 +00:00
|
|
|
{% load static %}
|
2020-09-08 16:01:03 +00:00
|
|
|
<link href="{% static 'main/main.css' %}" rel="stylesheet">
|
|
|
|
|
|
|
|
<link rel="icon" sizes="192x192" href="{% static 'images/favicon-192x192.png'%}">
|
|
|
|
<link rel="apple-touch-icon" href="{% static 'images/apple-touch-icon.png'%}"/>
|
2020-09-06 03:12:54 +00:00
|
|
|
</head>
|
|
|
|
<body>
|
2020-09-06 18:17:49 +00:00
|
|
|
<header><span class="text">Thoughts</span>{% if authenticated %}
|
|
|
|
<a href="/post" class="text" style="border: none">Post</a>
|
|
|
|
{% endif %}</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>
|
|
|
|
|
2020-09-06 18:17:49 +00:00
|
|
|
<!-- <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 17:41:13 +00:00
|
|
|
|
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);
|
2020-09-08 16:32:00 +00:00
|
|
|
const ampm = time.getHours() >= 12 ? "pm" : "am";
|
|
|
|
let hours = time.getHours() % 12; // 0-23
|
2020-09-08 16:01:03 +00:00
|
|
|
if (hours === 0) {
|
|
|
|
hours = 12;
|
|
|
|
}
|
|
|
|
let minutes = time.getMinutes().toString();
|
|
|
|
if (minutes.length < 2) {
|
|
|
|
minutes = "0" + minutes;
|
|
|
|
}
|
|
|
|
timestampEl.textContent = `${time.getFullYear()}-${time.getMonth()}-${time.getDate()}, ${hours}:${minutes}${ampm}`
|
2020-09-06 16:00:44 +00:00
|
|
|
}
|
|
|
|
</script>
|
2020-09-06 03:12:54 +00:00
|
|
|
</body>
|
2020-09-08 16:01:03 +00:00
|
|
|
</html>
|