|
<!doctype html> |
|
<html lang="en"> |
|
<head> |
|
<meta charset="utf-8"> |
|
<script> |
|
var bucket = window.location.host.split('.')[0] || parse_querystring(window.location).bucket |
|
var url_for = parse_querystring(window.location).download ? c : vlc_url |
|
|
|
document.addEventListener('DOMContentLoaded', function(){ |
|
ajax('GET', s3_url(bucket), function(event){ |
|
get_filenames(event.target.responseXML).forEach(function(filename){ |
|
document.body.appendChild(element('a', {href: url_for(s3_url(bucket, filename))}, |
|
text(filename) |
|
)) |
|
}) |
|
}) |
|
}) |
|
|
|
function c(x){ |
|
return x |
|
} |
|
|
|
function vlc_url(url){ |
|
// Doesn't work on M's iPad for some fucking reason... but works on N's iPhone, with same versions of everything |
|
// 'vlc://s3.amazonaws.com/'+[bucket,filename].join('/') |
|
return 'vlc://'+url |
|
} |
|
|
|
function s3_url(bucket, filename){ |
|
return 'https://s3.amazonaws.com/'+[bucket,filename].join('/') |
|
} |
|
|
|
function get_filenames(bucket_index_xml_document){ |
|
return to_array(bucket_index_xml_document.getElementsByTagName('Contents')).filter(function(contents){ |
|
return contents.getElementsByTagName('Size')[0].textContent != 0 && contents.getElementsByTagName('Key')[0].textContent != 'index.html' |
|
}).map(function(contents){ |
|
return contents.getElementsByTagName('Key')[0].textContent |
|
}) |
|
} |
|
|
|
function to_array(arraylike){ |
|
return Array.prototype.slice.call(arraylike) |
|
} |
|
|
|
function parse_querystring(location){ |
|
var params = {} |
|
location.search.substring(1).split('&').map(function(s){ |
|
return s.split('=') |
|
}).forEach(function(key_value){ |
|
params[key_value[0]] = key_value[1] |
|
}) |
|
return params |
|
} |
|
|
|
function element(tag, attributes, content){ |
|
var element = document.createElement(tag) |
|
Object.keys(attributes).forEach(function(attribute){ |
|
element.setAttribute(attribute, attributes[attribute]) |
|
}) |
|
element.appendChild(content) |
|
return element |
|
} |
|
|
|
function text(text){ |
|
return document.createTextNode(text) |
|
} |
|
|
|
function ajax(method, url, success){ |
|
var xhr = new XMLHttpRequest() |
|
xhr.open(method, url) |
|
xhr.addEventListener('load', success) |
|
xhr.send() |
|
} |
|
</script> |
|
<style> |
|
body { |
|
background-color: #C7D0D5; |
|
} |
|
a { |
|
display: block; |
|
padding: 10px; |
|
margin: 1px; |
|
border-radius: 5px; |
|
background-color: #93B1C6; |
|
|
|
font: 2em -apple-system, BlinkMacSystemFont, helveticaneue, sans-serif; |
|
color: #F5F5F5; |
|
text-decoration: none; |
|
} |
|
a:active { |
|
background-color: #A7A37E; |
|
color: #EFECCA; |
|
} |
|
</style> |
|
</head> |
|
<body> |
|
</body> |
|
</html> |