mirror of
https://github.com/vichan-devel/vichan.git
synced 2025-02-21 21:19:36 +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:
parent
7239350e69
commit
5ce9f6fa1a
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
@ -76,7 +76,8 @@ form table tr th{
|
|||||||
color: #fff !important;
|
color: #fff !important;
|
||||||
background: #222 !important;
|
background: #222 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#download-all,
|
||||||
#expand-all-images,
|
#expand-all-images,
|
||||||
#shrink-all-images,
|
#shrink-all-images,
|
||||||
#treeview{
|
#treeview{
|
||||||
@ -96,6 +97,10 @@ form table tr th{
|
|||||||
margin-top: 6em !important;
|
margin-top: 6em !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#download-all{
|
||||||
|
margin-top: 7em !important;
|
||||||
|
}
|
||||||
|
|
||||||
#expand-all-images + hr,
|
#expand-all-images + hr,
|
||||||
#shrink-all-images + hr{
|
#shrink-all-images + hr{
|
||||||
opacity: 0 !important;
|
opacity: 0 !important;
|
||||||
@ -107,6 +112,11 @@ form table tr th{
|
|||||||
clear: both !important;
|
clear: both !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#download-all + hr{
|
||||||
|
opacity: 0 !important;
|
||||||
|
clear: both !important;
|
||||||
|
}
|
||||||
|
|
||||||
#options_handler{
|
#options_handler{
|
||||||
margin-top: 3em !important;
|
margin-top: 3em !important;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user