1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-12-01 10:37:18 +01:00
vichan/js/download-all.js
hugofragata 12a8f1a672 Added download-all feature
The button to download all the files in a thread only appears when the
page is a thread, such as treeview. I added the download-all button next
to the treeview one. I modified stylesheets/v8ch.css to include the id
#download-all. I modified inc/instance-config.php to include the
download-all.js and jszip.min.js. I added the files js/jszip.min.js
which is a library to work with zip files in JS and I added
js/download-all.js which goes through all files, adds them to a zip and
then gives it to the user.
2014-10-06 16:50:20 +01:00

29 lines
720 B
JavaScript

if(active_page=='thread')
$(function (){
$('hr:first').before('<div id="download-all" style="text-align:right"><a class="unimportant" href="javascript:void(0)"></a></div>');
$('div#download-all a')
.text(_('Download All'))
.click(function() {
var zip = new JSZip();
var files = document.getElementsByClassName("fileinfo");
for(var i = 0; i < files.length; i++)
{
for(var j = 0; j < files.length; j++)
{
x = 'http://8chan.co/' + files[i].getElementsByTagName('a')[j].src;
zip.file(x);
}
}
var content = zip.generate({type:"blob"});
var fns = document.URL.split('/');
var fn = fns[2] + '/' + fns[4].substring(0, fns[4].length-5);
saveAs(content, fn);
})})