pandora_cms/static/html/print.html

62 lines
2 KiB
HTML
Raw Permalink Normal View History

2018-11-15 15:01:29 +00:00
<meta charset="utf-8" />
2018-05-09 15:45:44 +00:00
<script src="/static/oxjs/min/Ox.js"></script>
<script>
function pandora_api(action, data, callback) {
var url = '/api/';
var xhr = new XMLHttpRequest();
xhr.addEventListener('load', function (evt) {
var data = JSON.parse(evt.target.responseText);
callback(data);
});
var formData = new FormData();
formData.append('action', action);
formData.append('data', JSON.stringify(data));
xhr.open('POST', url);
xhr.send(formData);
}
function render() {
var hash = document.location.hash.slice(1).split('/')
if (hash.length == 2) {
var item = hash[0],
time = hash[1].split(','),
in_ = time[0],
out = time[1];
in_ = Ox.parseDuration(in_);
out = Ox.parseDuration(out);
pandora_api('get', {
id: item,
keys: ['title', 'layers']
}, function(result) {
var html = ''
2018-05-09 16:03:57 +00:00
var url = document.location.protocol + '//' + document.location.host + '/' + item + '/' + time[0] + ',' + time[1];
2018-05-09 15:45:44 +00:00
html += '<h1>' + result.data.title + ': ' + time[0] + ' - ' + time[1] + '</h1>'
2018-05-09 16:03:57 +00:00
html += url + '<br><br>'
html += '<a href="' + url + '"><img src="/' + item + '/240p'+in_+'.jpg"></a><br>'
var current
2018-05-09 15:45:44 +00:00
Ox.sortBy(result.data.layers.keywords, 'value').forEach(function(keyword) {
if (keyword['in'] <= out && keyword['out'] >= in_) {
2018-05-09 16:03:57 +00:00
var section = keyword['value'].split(': ')[0]
if (section != current) {
current = section
html += '<br><b>' + section + ':</b><br>';
}
html += keyword['value'].split(': ')[1] + '<br>';
2018-05-09 15:45:44 +00:00
}
})
document.body.innerHTML = html;
});
} else {
}
}
window.onhashchange = render
render()
</script>
<style>
body {
font-family: sans-serif;
}
</style>