download frame, fixes #3163

This commit is contained in:
j 2018-09-12 19:57:29 +02:00
parent 019faffecf
commit 5a17f77f7a
2 changed files with 24 additions and 0 deletions

View file

@ -163,6 +163,11 @@ pandora.ui.editor = function(data) {
pandora.$ui[dialog] && pandora.$ui[dialog].remove();
pandora.$ui[dialog] = pandora.ui[dialog](data).open();
},
downloadframe: function(data_) {
var url = '/' + ui.item + '/' + Ox.max(pandora.site.video.resolutions) + 'p' + data_.position + '.jpg',
name = data.title + ' - ' + Ox.formatDuration(data_.position) + '.jpg';
pandora.saveURL(url, name)
},
downloadvideo: function() {
pandora.ui.downloadVideoDialog({
item: ui.item,

View file

@ -2577,6 +2577,25 @@ pandora.openURL = function(url) {
}
};
pandora.saveURL = function(url, name) {
var link = document.createElement('a');
if (typeof link.download === 'string') {
link.href = url;
link.setAttribute('download', name ? name : true);
//Firefox requires the link to be in the body
document.body.appendChild(link);
//simulate click
link.click();
//remove the link when done
document.body.removeChild(link);
} else {
window.open(url);
}
}
pandora.signin = function(data) {
// fixme: this is still voodoo
pandora.user = Ox.extend(data.user, {