2017-06-15 17:21:22 +01:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
2017-06-18 21:57:43 +01:00
|
|
|
<title>CMS Loading</title>
|
2017-06-15 17:21:22 +01:00
|
|
|
<link rel="stylesheet" href="/assets/styles.css">
|
2017-09-03 17:53:17 +01:00
|
|
|
<!-- Custom CSS stylings from admin -->
|
|
|
|
<link rel="stylesheet" href="/assets/custom.css">
|
|
|
|
|
2017-08-12 08:24:57 +01:00
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
2017-06-15 17:21:22 +01:00
|
|
|
</head>
|
|
|
|
<body>
|
2017-08-12 08:24:57 +01:00
|
|
|
<div class="container">
|
2017-06-18 21:57:43 +01:00
|
|
|
<h1 id="title" class="title">Loading</h1>
|
2017-09-03 17:53:17 +01:00
|
|
|
<h3><a href="/admin">Admin</a></h3>
|
2017-06-18 21:57:43 +01:00
|
|
|
|
|
|
|
<div id="podcasts">
|
2017-06-20 03:45:51 +01:00
|
|
|
|
2017-06-18 21:57:43 +01:00
|
|
|
</div>
|
2017-06-20 03:45:51 +01:00
|
|
|
<footer>
|
2017-07-15 16:06:37 +01:00
|
|
|
<p>White Rabbit licensed under the GPLv3 | <a href="/rss">RSS</a> <a href="/json">JSON</a></p>
|
2017-06-20 03:45:51 +01:00
|
|
|
</footer>
|
2017-08-12 08:24:57 +01:00
|
|
|
</div>
|
2017-06-18 21:57:43 +01:00
|
|
|
<script>
|
|
|
|
get("/json", function(data){
|
|
|
|
json = JSON.parse(data);
|
|
|
|
document.title = json.title;
|
|
|
|
document.getElementById("title").innerHTML = json.title;
|
|
|
|
|
2017-08-12 08:24:57 +01:00
|
|
|
// Iterate through JSON
|
2017-07-16 18:43:47 +01:00
|
|
|
for (i=0;i<=json.items.length; i++){
|
2017-06-18 21:57:43 +01:00
|
|
|
var div = document.createElement('div');
|
|
|
|
div.className = 'podcast';
|
2017-08-12 08:24:57 +01:00
|
|
|
|
|
|
|
// Hacky date workaround - convert our Go date outpus to unix timestamp,
|
|
|
|
// then convert that into a string
|
|
|
|
date = new Date(Date.parse(json.items[i].date_published))
|
|
|
|
month = date.getMonth()+1;
|
|
|
|
datestring = date.getDate() + "/" + month + "/" + date.getFullYear();
|
|
|
|
|
|
|
|
// Build div for podcast entry
|
|
|
|
div.innerHTML = '<h3>'+json.items[i].title+' <small>'+datestring+'</small></h3><p>'+json.items[i].summary+'</p>'+
|
2017-06-20 03:45:51 +01:00
|
|
|
'<audio controls><source src="'+json.items[i].url+'">';
|
2017-06-18 21:57:43 +01:00
|
|
|
|
2017-08-12 08:24:57 +01:00
|
|
|
// We can safely do this because of how the Go code actually
|
|
|
|
// generates the .json file - it's consistent
|
|
|
|
// Preappend so newest is at the top
|
2017-06-18 21:57:43 +01:00
|
|
|
var element = document.getElementById("podcasts");
|
2017-08-12 08:24:57 +01:00
|
|
|
element.insertBefore(div, element.firstChild);
|
2017-06-18 21:57:43 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-08-12 08:24:57 +01:00
|
|
|
// Wrap xmlHttp into smaller function, I like
|
|
|
|
// to include this function whenever I need to
|
|
|
|
// do such a thing
|
2017-06-18 21:57:43 +01:00
|
|
|
function get(url, callback) {
|
|
|
|
var xmlHttp = new XMLHttpRequest();
|
|
|
|
xmlHttp.onreadystatechange = function() {
|
|
|
|
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
|
|
|
|
callback(xmlHttp.responseText);
|
|
|
|
}
|
|
|
|
xmlHttp.open("GET", url, true);
|
|
|
|
xmlHttp.send(null);
|
|
|
|
}
|
|
|
|
</script>
|
2017-06-15 17:21:22 +01:00
|
|
|
</body>
|
2017-06-18 21:57:43 +01:00
|
|
|
</html>
|