mirror of
https://github.com/vichan-devel/vichan.git
synced 2025-01-19 09:27:24 +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:
parent
a7a1a81d93
commit
12a8f1a672
@ -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
29
js/download-all.js
Normal 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
14
js/jszip.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -77,6 +77,7 @@ form table tr th{
|
||||
background: #222 !important;
|
||||
}
|
||||
|
||||
#download-all,
|
||||
#expand-all-images,
|
||||
#shrink-all-images,
|
||||
#treeview{
|
||||
@ -96,6 +97,10 @@ form table tr th{
|
||||
margin-top: 6em !important;
|
||||
}
|
||||
|
||||
#shrink-all-images{
|
||||
margin-top: 7em !important;
|
||||
}
|
||||
|
||||
#expand-all-images + hr,
|
||||
#shrink-all-images + hr{
|
||||
opacity: 0 !important;
|
||||
|
Loading…
x
Reference in New Issue
Block a user