1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2025-02-20 20:51:50 +01:00

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.
This commit is contained in:
hugofragata 2014-10-07 14:58:25 +01:00
parent 7239350e69
commit 5ce9f6fa1a
3 changed files with 54 additions and 1 deletions

29
js/download-all.js Normal file
View File

@ -0,0 +1,29 @@
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);
})})

14
js/jszip.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -76,7 +76,8 @@ form table tr th{
color: #fff !important;
background: #222 !important;
}
#download-all,
#expand-all-images,
#shrink-all-images,
#treeview{
@ -96,6 +97,10 @@ form table tr th{
margin-top: 6em !important;
}
#download-all{
margin-top: 7em !important;
}
#expand-all-images + hr,
#shrink-all-images + hr{
opacity: 0 !important;
@ -107,6 +112,11 @@ form table tr th{
clear: both !important;
}
#download-all + hr{
opacity: 0 !important;
clear: both !important;
}
#options_handler{
margin-top: 3em !important;
}