1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2025-01-19 01:24:05 +01:00

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.
This commit is contained in:
hugofragata 2014-10-06 16:50:20 +01:00
parent a7a1a81d93
commit 12a8f1a672
4 changed files with 51 additions and 1 deletions

View File

@ -104,6 +104,8 @@
$config['additional_javascript'][] = 'js/inline-expanding.js';
$config['additional_javascript'][] = 'js/show-backlinks.js';
$config['additional_javascript'][] = 'js/webm-settings.js';
$config['additional_javascript'][] = 'js/download-all.js';
$config['additional_javascript'][] = 'js/jszip.min.js';
$config['additional_javascript'][] = 'js/expand-video.js';
$config['additional_javascript'][] = 'js/treeview.js';
$config['additional_javascript'][] = 'js/quick-post-controls.js';

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{
@ -95,6 +96,10 @@ form table tr th{
#shrink-all-images{
margin-top: 6em !important;
}
#shrink-all-images{
margin-top: 7em !important;
}
#expand-all-images + hr,
#shrink-all-images + hr{