1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-29 01:34:31 +01:00
vichan/js/download-all.js
hugofragata 5ce9f6fa1a Added download-all feature without instanceconfig
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 DIDN'T modified inc/instance-config.php to include the
download-all.js and jszip.min.js. That goes in the next commit.

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-07 14:58:25 +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);
})})