|
@@ -1,4 +1,5 @@
|
|
$(document).ready(function() {
|
|
$(document).ready(function() {
|
|
|
|
+ var loadIndex = null;
|
|
|
|
|
|
new WOW({
|
|
new WOW({
|
|
mobile: false,
|
|
mobile: false,
|
|
@@ -243,70 +244,104 @@ $(document).ready(function() {
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
- // 创建全屏遮罩层
|
|
|
|
- $('.album-thumb-detail').on('click', function (event) {
|
|
|
|
- // 如果点击的是 download-icon,阻止后续代码执行
|
|
|
|
- if ($(event.target).closest('.download-icon').length) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
|
|
+ var checkDownloadStatus = function() {
|
|
|
|
+ var intervalId = setInterval(function() {
|
|
|
|
+ $.ajax({
|
|
|
|
+ url: '/download-status',
|
|
|
|
+ method: 'GET',
|
|
|
|
+ dataType: 'json',
|
|
|
|
+ success: function(response) {
|
|
|
|
+ if (response.status == 0) {
|
|
|
|
+ clearInterval(intervalId);
|
|
|
|
+ layer.close(loadIndex); // 关闭加载层
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }, 1000); // 每秒请求一次
|
|
|
|
+ }
|
|
|
|
|
|
- // 获取当前点击的 .album-thumb-detail 的父级 .grid-album 元素
|
|
|
|
- var $parentAlbum = $(this).closest('.grid-album');
|
|
|
|
|
|
+ // 放大图片 start
|
|
|
|
+// 创建全屏遮罩层
|
|
|
|
+ $('.album-thumb-detail').on('click', function (event) {
|
|
|
|
+ // 如果点击的是 download-icon,阻止后续代码执行
|
|
|
|
+ if ($(event.target).closest('.download-icon').length) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
|
|
- // 获取当前父级下所有 .album-thumb-detail img 的 src
|
|
|
|
- var imageSrcArray = [];
|
|
|
|
- $parentAlbum.find('.album-thumb-detail img').each(function () {
|
|
|
|
- src = $(this).attr('data-src')
|
|
|
|
- // newSrc = src.split('?')[0];
|
|
|
|
- imageSrcArray.push(src);
|
|
|
|
- });
|
|
|
|
|
|
+ // 获取当前点击的 .album-thumb-detail 的父级 .grid-album 元素
|
|
|
|
+ var $parentAlbum = $(this).closest('.grid-album');
|
|
|
|
|
|
- // 获取当前点击图片在数组中的索引
|
|
|
|
- var $albumThumbs = $parentAlbum.find('.album-thumb-detail');
|
|
|
|
- var currentImageIndex = $albumThumbs.index(this);
|
|
|
|
- // console.log(currentImageIndex);
|
|
|
|
-
|
|
|
|
- const $fullscreenMask = $('<div>').addClass('fullscreen-mask');
|
|
|
|
- const $fullscreenImg = $('<img>').attr('src', imageSrcArray[currentImageIndex]);
|
|
|
|
- const $btnLeft = $('<div>').addClass('fullscreen-btn fullscreen-btn-left').html('<');
|
|
|
|
- const $btnRight = $('<div>').addClass('fullscreen-btn fullscreen-btn-right').html('>');
|
|
|
|
-
|
|
|
|
- $fullscreenMask.append($fullscreenImg, $btnLeft, $btnRight);
|
|
|
|
-
|
|
|
|
- // 将遮罩层添加到 body
|
|
|
|
- $('body').append($fullscreenMask);
|
|
|
|
- setTimeout(function () {
|
|
|
|
- $fullscreenMask.addClass('active');
|
|
|
|
- }, 10);
|
|
|
|
-
|
|
|
|
- // 点击遮罩层时关闭
|
|
|
|
- $fullscreenMask.on('click', function (e) {
|
|
|
|
- if (!$(e.target).is($btnLeft) && !$(e.target).is($btnRight)) {
|
|
|
|
- $fullscreenMask.removeClass('active');
|
|
|
|
- setTimeout(function () {
|
|
|
|
- $fullscreenMask.remove();
|
|
|
|
- }, 300);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ // 获取当前父级下所有 .album-thumb-detail img 的 src
|
|
|
|
+ var imageSrcArray = [];
|
|
|
|
+ $parentAlbum.find('.album-thumb-detail img').each(function () {
|
|
|
|
+ src = $(this).attr('data-src');
|
|
|
|
+ // newSrc = src.split('?')[0];
|
|
|
|
+ imageSrcArray.push(src);
|
|
|
|
+ });
|
|
|
|
|
|
- // 点击左按钮显示上一张图片
|
|
|
|
- $btnLeft.on('click', function () {
|
|
|
|
- currentImageIndex--;
|
|
|
|
- if (currentImageIndex < 0) {
|
|
|
|
- currentImageIndex = imageSrcArray.length - 1;
|
|
|
|
- }
|
|
|
|
- $fullscreenImg.attr('src', imageSrcArray[currentImageIndex]);
|
|
|
|
- });
|
|
|
|
|
|
+ // 获取当前点击图片在数组中的索引
|
|
|
|
+ var $albumThumbs = $parentAlbum.find('.album-thumb-detail');
|
|
|
|
+ var currentImageIndex = $albumThumbs.index(this);
|
|
|
|
+ // console.log(currentImageIndex);
|
|
|
|
+
|
|
|
|
+ const $fullscreenMask = $('<div>').addClass('fullscreen-mask');
|
|
|
|
+ const $fullscreenImg = $('<img>').attr('src', imageSrcArray[currentImageIndex]);
|
|
|
|
+ const $btnLeft = $('<div>').addClass('fullscreen-btn fullscreen-btn-left').html('<');
|
|
|
|
+ const $btnRight = $('<div>').addClass('fullscreen-btn fullscreen-btn-right').html('>');
|
|
|
|
+ const $btnDownload = $('<div>').addClass('fullscreen-btn fullscreen-btn-download').html('⭳'); // 下载图标
|
|
|
|
+
|
|
|
|
+ $fullscreenMask.append($fullscreenImg, $btnLeft, $btnRight, $btnDownload);
|
|
|
|
+
|
|
|
|
+ // 将遮罩层添加到 body
|
|
|
|
+ $('body').append($fullscreenMask);
|
|
|
|
+ setTimeout(function () {
|
|
|
|
+ $fullscreenMask.addClass('active');
|
|
|
|
+ }, 10);
|
|
|
|
+
|
|
|
|
+ // 点击遮罩层时关闭
|
|
|
|
+ $fullscreenMask.on('click', function (e) {
|
|
|
|
+ if (!$(e.target).is($btnLeft) && !$(e.target).is($btnRight) && !$(e.target).is($btnDownload)) {
|
|
|
|
+ $fullscreenMask.removeClass('active');
|
|
|
|
+ setTimeout(function () {
|
|
|
|
+ $fullscreenMask.remove();
|
|
|
|
+ }, 300);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
|
|
- // 点击右按钮显示下一张图片
|
|
|
|
- $btnRight.on('click', function () {
|
|
|
|
- currentImageIndex++;
|
|
|
|
- if (currentImageIndex >= imageSrcArray.length) {
|
|
|
|
- currentImageIndex = 0;
|
|
|
|
- }
|
|
|
|
- $fullscreenImg.attr('src', imageSrcArray[currentImageIndex]);
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
|
|
+ // 点击左按钮显示上一张图片
|
|
|
|
+ $btnLeft.on('click', function () {
|
|
|
|
+ currentImageIndex--;
|
|
|
|
+ if (currentImageIndex < 0) {
|
|
|
|
+ currentImageIndex = imageSrcArray.length - 1;
|
|
|
|
+ }
|
|
|
|
+ $fullscreenImg.attr('src', imageSrcArray[currentImageIndex]);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 点击右按钮显示下一张图片
|
|
|
|
+ $btnRight.on('click', function () {
|
|
|
|
+ currentImageIndex++;
|
|
|
|
+ if (currentImageIndex >= imageSrcArray.length) {
|
|
|
|
+ currentImageIndex = 0;
|
|
|
|
+ }
|
|
|
|
+ $fullscreenImg.attr('src', imageSrcArray[currentImageIndex]);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 点击下载按钮下载当前图片
|
|
|
|
+ $btnDownload.on('click', function (e) {
|
|
|
|
+
|
|
|
|
+ e.stopPropagation(); // 阻止事件冒泡
|
|
|
|
+ const currentImageSrc = imageSrcArray[currentImageIndex];
|
|
|
|
+
|
|
|
|
+ // 下载图片 js urlencode
|
|
|
|
+ url = '/download-image?url='+encodeURIComponent(currentImageSrc);
|
|
|
|
+ window.location.href = url;
|
|
|
|
+ console.log(url);
|
|
|
|
+ loadIndex = layer.load(2, { shade: [0.8, '#000'] });
|
|
|
|
+ checkDownloadStatus();
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 放大图片 end
|
|
|
|
|
|
|
|
|
|
const $overlay = $('#overlay');
|
|
const $overlay = $('#overlay');
|
|
@@ -384,7 +419,7 @@ $(document).ready(function() {
|
|
setInterval(fetchUpdate, 20000); // 10000 毫秒 = 10 秒
|
|
setInterval(fetchUpdate, 20000); // 10000 毫秒 = 10 秒
|
|
}
|
|
}
|
|
|
|
|
|
- var loadIndex = null;
|
|
|
|
|
|
+
|
|
var downdHref = function() {
|
|
var downdHref = function() {
|
|
// 查找 .album-tab 中带有 is-active 类的 <a> 标签
|
|
// 查找 .album-tab 中带有 is-active 类的 <a> 标签
|
|
let activeTab = $('.album-tab a.is-active').attr('href');
|
|
let activeTab = $('.album-tab a.is-active').attr('href');
|
|
@@ -401,21 +436,7 @@ $(document).ready(function() {
|
|
}
|
|
}
|
|
|
|
|
|
//ajax 定时请求 /download-status,直到返回状态为 0 时
|
|
//ajax 定时请求 /download-status,直到返回状态为 0 时
|
|
- var checkDownloadStatus = function() {
|
|
|
|
- var intervalId = setInterval(function() {
|
|
|
|
- $.ajax({
|
|
|
|
- url: '/download-status',
|
|
|
|
- method: 'GET',
|
|
|
|
- dataType: 'json',
|
|
|
|
- success: function(response) {
|
|
|
|
- if (response.status == 0) {
|
|
|
|
- clearInterval(intervalId);
|
|
|
|
- layer.close(loadIndex); // 关闭加载层
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }, 1000); // 每秒请求一次
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
|
|
// 监听 .download-all 的点击事件
|
|
// 监听 .download-all 的点击事件
|
|
$('.download-all').on('click', function() {
|
|
$('.download-all').on('click', function() {
|