{{ template "base.html" . }}

{{ define "extrahead" }}
	<script src="{{ static "js/templates.js" }}"></script>
{{ end }}

{{ define "content" }}
<div class="content-block">
	{{ template "timeline_item.html" .Snippet }}
</div>
{{ if .CanEditSnippet }}
	{{ template "snippet_edit.html" . }}
	<script>
		document.querySelector(".timeline-item .edit").addEventListener("click", function(ev) {
			if (ev.target.classList.contains("edit")) {
				let parent = ev.target.parentElement;
				while (parent && !parent.classList.contains("timeline-item")) {
					parent = parent.parentElement;
				}
				if (parent && parent.classList.contains("timeline-item")) {
					editTimelineSnippet(parent);
				}
			}
		});
	</script>
{{ end }}
{{ end }}
