event-timeline/app/templates/timeline.html
2022-04-26 12:55:48 +01:00

129 lines
4 KiB
HTML

<!doctype html>{% load sass_tags static %}
<html>
<head>
<title>{{ settings.TITLE }}</title>
<meta charset="utf-8">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<link href="{% sass_src 'css/style.scss' %}" rel="stylesheet" type="text/css">
<base target="_blank" >
<link rel="stylesheet" href="{% static 'timeline/css/timeline.css' %}">
<link rel="stylesheet" href="{% static 'timeline/css/fonts/font.default.css' %}">
<style>
html, body {
height:100%;
width:100%;
padding: 0px;
margin: 0px;
}
.tl-timeline {
}
.tl-attribution {
display: none !important;
}
.tl-timeline h1, .tl-timeline h2, .tl-timeline h3, .tl-timeline h4, .tl-timeline h5, .tl-timeline h6 {
text-transform: initial !important;
}
.active {
display: block
}
#intro, #contact {
display: none;
}
.tl-timeline .tl-timegroup-message {
color: #000 !important;
}
</style>
</head>
<body>
<div id="intro">
{{ intro.body | safe }}
</div>
<div id="timeline"></div>
<div id="contact">
<div class="content">
<form class="contact-form" action="/disabled" method="post">
<input type="text" placeholder="Your name" name="name" required><br>
<input type="text" placeholder="Your email" name="email" required><br>
<textarea placeholder="Message" name="message" required></textarea><br>
<input type="submit" value="Send message" />
{% csrf_token %}
</form>
</div>
</div>
<script src="{% static 'timeline/js/timeline.js' %}"></script>
<script>
function submitContact(event) {
event.preventDefault()
event.stopPropagation()
var data = {}
var form = document.querySelector('.contact-form')
form.querySelectorAll('input,textarea').forEach(input => {
if (input.name) {
data[input.name] = input.value
}
})
fetch('/contact/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': data.csrfmiddlewaretoken,
},
body: JSON.stringify(data)
}).then(response => response.json()).then(response => {
if (response.sent) {
var content = document.querySelector('#contact .content')
content.innerHTML = `
Thank you for taking the time to send us a message, we will get back to you soon.
<br><br>
<a href="/" target="_self">Back to Timeline</a>
`
}
})
}
document.querySelector('#contact .contact-form').addEventListener('submit', submitContact)
var data = {{ timeline_json | safe }};
var timeline
function load_timeline() {
timeline = new TL.Timeline('timeline', data, {
hash_bookmark: true,
debug: false,
timenav_height: 100,
});
}
document.querySelector('#intro a[href="#title"]').addEventListener('click', event => {
document.querySelector('#intro').style.display = 'none'
document.querySelector('#contact').style.display = 'none'
document.querySelector('#timeline').style.display = 'block'
load_timeline()
})
if (document.location.hash.slice(1).length) {
load_timeline()
}
function hashchange(event) {
console.log('hc', document.location.hash.slice(1).length, document.location.hash.slice(1))
if (document.location.hash.slice(1) == 'contact') {
document.querySelector('#intro').style.display = 'none'
document.querySelector('#contact').style.display = 'block'
document.querySelector('#timeline').style.display = 'none'
} else if (document.location.hash.slice(1).length) {
document.querySelector('#intro').style.display = 'none'
document.querySelector('#contact').style.display = 'none'
document.querySelector('#timeline').style.display = 'block'
} else {
document.querySelector('#intro').style.display = 'block'
document.querySelector('#contact').style.display = 'none'
document.querySelector('#timeline').style.display = 'none'
}
}
window.addEventListener('hashchange', hashchange)
hashchange()
</script>
</body>
</html>