Я был вдохновлен этим превосходным примером [https://jsfiddle.net/jaitsujin/zrdgsjht/] и реализован его с помощью бата прогресса, и я надеется, что это было создано. Полезно для кого -то < /p>
[url=public/
...
var links = [];
var links2 = [];
$('.gallery').on('click', '.pdf_link', function () {
links.push($(this).attr('href'));
console.log(links);
});
$('.gallery').on('click', '.thumb', function () {
$(this).removeClass().addClass('thumbChecked');
$(this).css("border", "2px solid #c32032");
links.push($(this).attr('href'));
links2.push($(this).attr('alt'));
console.log(links);
console.log(links2);
if (links.length != 0) {
$('.download').css("display", "block");
}
});
$('.gallery').on('click', '.thumbChecked', function () {
$(this).removeClass().addClass('thumb');
$(this).css("border", "2px solid white");
var itemtoRemove = $(this).attr('href');
var itemtoRemove = $(this).attr('alt');
links.splice($.inArray(itemtoRemove, links), 1);
links2.splice($.inArray(itemtoRemove, links2), 1);
console.log(links);
console.log(links2);
if (links.length == 0) {
$('.download').css("display", "none");
$("#result")
.removeClass()
.text("");
}
});
function generateZIP() {
NProgress.start();
console.log('TEST');
var zip = new JSZip();
var count = 0;
var zipFilename = "LB_Images_AR.zip";
links.forEach(function (url, i) {
var filename = links;
filename = filename.replace("https://www.turismofvgfoto.it/images/","").replace("ar/","");
// loading a file and add it in a zip file
JSZipUtils.getBinaryContent(url, function (err, data) {
if (err) {
throw err; // or handle the error
}
zip.file(filename, data, { binary: true });
count++;
if (count == links.length) {
zip.generateAsync({ type: 'blob' }).then(function (content) {
saveAs(content, zipFilename);
NProgress.done();
pnotify_zip ();
});
}
});
});
}
function generateZIP2() {
NProgress.start();
console.log('TEST');
var zip = new JSZip();
var count = 0;
var zipFilename = "LB_Images_FHD.zip";
links2.forEach(function (url, i) {
var filename = links2;
filename = filename.replace("https://www.turismofvgfoto.it/images/","").replace("fhd/","");
// loading a file and add it in a zip file
JSZipUtils.getBinaryContent(url, function (err, data) {
if (err) {
throw err; // or handle the error
}
zip.file(filename, data, { binary: true });
count++;
if (count == links2.length) {
zip.generateAsync({ type: 'blob' }).then(function (content) {
saveAs(content, zipFilename);
NProgress.done();
pnotify_zip ();
});
}
});
});
}
/**
* Reset the message.
*/
function resetMessage () {
$("#result")
.removeClass()
.text("");
}
function pnotify_zip () {
$.pnotify.defaults.history = false;
$.pnotify({
title: 'CREAZIONE ZIP',
text: ("Immagini aggiunte con successo al file ZIP appena creato!"),
type: 'success'});
}
< /code>
Теперь мне нужно добавить файл PDF, уже присутствующий в коде выше внутри Body < /p>
[url=public/
Подробнее здесь: https://stackoverflow.com/questions/795 ... and-jquery
Мобильная версия