2017-06-15 17:21:22 +01:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
2017-09-11 19:46:43 +01:00
|
|
|
<title>Pogo Loading</title>
|
2017-09-11 17:54:57 +01:00
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
2017-09-19 20:28:59 +01:00
|
|
|
|
2017-06-15 17:21:22 +01:00
|
|
|
<link rel="stylesheet" href="/assets/styles.css">
|
2017-09-07 04:02:59 +01:00
|
|
|
|
2017-09-03 17:53:17 +01:00
|
|
|
<!-- Custom CSS stylings from admin -->
|
|
|
|
<link rel="stylesheet" href="/assets/custom.css">
|
2017-06-15 17:21:22 +01:00
|
|
|
</head>
|
|
|
|
<body>
|
2017-08-12 08:24:57 +01:00
|
|
|
<div class="container">
|
2017-11-21 18:38:58 +00:00
|
|
|
<div class="main">
|
2017-06-18 21:57:43 +01:00
|
|
|
<h1 id="title" class="title">Loading</h1>
|
2017-09-11 17:54:57 +01:00
|
|
|
<h3><a href="/admin" class="adminlink">Admin</a></h3>
|
2017-06-18 21:57:43 +01:00
|
|
|
|
2017-09-19 20:28:59 +01:00
|
|
|
<div id="podcasts" class="podcastlist">
|
|
|
|
|
|
|
|
</div>
|
2017-11-21 18:38:58 +00:00
|
|
|
</div>
|
2017-09-19 20:28:59 +01:00
|
|
|
<footer>
|
|
|
|
<p>Pogo licensed under the GPLv3 | <a href="/rss">RSS Feed</a>
|
|
|
|
</footer>
|
|
|
|
</div>
|
2017-06-18 21:57:43 +01:00
|
|
|
<script>
|
2017-09-11 17:54:57 +01:00
|
|
|
/*
|
|
|
|
* Function for aggregating podcast episodes and
|
|
|
|
* displaying them.
|
|
|
|
*
|
|
|
|
* Will not be written in ES6 _yet_ until all browsers
|
|
|
|
* support it, avoiding frameworks because of bulk.
|
|
|
|
*/
|
2017-06-18 21:57:43 +01:00
|
|
|
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-09-11 17:54:57 +01:00
|
|
|
for (i=0;i<json.items.length; i++){
|
2017-06-18 21:57:43 +01:00
|
|
|
var div = document.createElement('div');
|
2017-09-11 17:45:57 +01:00
|
|
|
div.className = 'podcastitem';
|
2017-08-12 08:24:57 +01:00
|
|
|
|
2017-09-07 04:02:59 +01:00
|
|
|
// Hacky date workaround - convert our Go date output to unix timestamp,
|
2017-08-12 08:24:57 +01:00
|
|
|
// then convert that into a string
|
2017-09-11 17:54:57 +01:00
|
|
|
// Leaves RSS readers happy and date readable on the frontend.
|
2017-08-12 08:24:57 +01:00
|
|
|
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
|
2017-09-11 17:54:57 +01:00
|
|
|
div.innerHTML = '<h3 class="podcasttitle">'+
|
|
|
|
json.items[i].title+' <small class="podcastdate">'+
|
|
|
|
datestring+'</small></h3><p class="podcastdesc">'+
|
|
|
|
json.items[i].summary+'</p><audio controls class="podcastaudio"><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
|
2017-09-11 17:45:57 +01:00
|
|
|
// generates the .json file - it's consistent as far as I've been able to see
|
2017-08-12 08:24:57 +01:00
|
|
|
// 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>
|