pogo/assets/web/index.html
gmemstr 8738164b8f Made included web interface's purpose clearer
Basically included web interface is being deprecated _for prod only_ in favour of new Vue.js interface in gmemstr/pogo-vue. Included web interface will be updated to ensure routes and features work properly and should not be considered "production ready".
2017-12-21 08:30:32 -08:00

81 lines
2.7 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Pogo Loading</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/assets/styles.css">
<!-- Custom CSS stylings from admin -->
<link rel="stylesheet" href="/assets/custom.css">
</head>
<body>
<div class="container">
<div class="main">
<h1 id="title" class="title">Loading</h1>
<h3><a href="/admin" class="adminlink">Admin</a></h3>
<div id="podcasts" class="podcastlist">
</div>
</div>
<footer>
<p>Pogo licensed under the GPLv3 | <a href="/rss">RSS Feed</a>
</footer>
</div>
<script>
/*
* 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.
*/
get("/json", function(data){
json = JSON.parse(data);
document.title = json.title;
document.getElementById("title").innerHTML = json.title + " DEVELOPMENT MODE";
// Iterate through JSON
for (i=0;i<json.items.length; i++){
var div = document.createElement('div');
div.className = 'podcastitem';
// Hacky date workaround - convert our Go date output to unix timestamp,
// then convert that into a string
// Leaves RSS readers happy and date readable on the frontend.
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 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+'">';
// We can safely do this because of how the Go code actually
// generates the .json file - it's consistent as far as I've been able to see
// Preappend so newest is at the top
var element = document.getElementById("podcasts");
element.insertBefore(div, element.firstChild);
}
});
// Wrap xmlHttp into smaller function, I like
// to include this function whenever I need to
// do such a thing
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>
</body>
</html>