-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjquery.js
More file actions
executable file
·58 lines (54 loc) · 1.57 KB
/
jquery.js
File metadata and controls
executable file
·58 lines (54 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
$(document).ready(function(){
var baseUrl = "./galleryimages";
var pictures = [];
// loading and listing files
function getFiles() {
$.ajax({
type: "GET",
url: baseUrl,
success: function(data) {
pictures = [];
$(data).find("a[href]").each(function() {
var href = $(this).attr('href');
var imagebox;
if (href.indexOf('.webp') > 0) {
imagebox = document.createElement("div");
imagebox.className = "imagebox";
var img = document.createElement("img");
img.src = href;
imagebox.append(img)
$("#viewer").append(imagebox)
}
var datatypes = ["landscape", "flower", "pet", "cat", "dog"]
for (var x of datatypes)
if (href.indexOf(x) > -1)
$(imagebox).toggleClass(x, true)
});
// imageviewer script by 6483 (ty for help <3)
$('.imagebox').click(function(e) {
$('.imageView').addClass('imageView-visible');
$('.imageViewImage img').attr('src', e.currentTarget.childNodes[0].src);
});
$('.imageViewClose').click(function() {
$('.imageView').removeClass('imageView-visible');
});
}
});
}
getFiles();
// navbar sorting
$('.list').click(function(){
const value = $(this).attr('data-filter');
if (value == 'All'){
$('.imagebox').show(0).animate({opacity: 1}, 400);
}
else {
$('.imagebox').not('.'+value).hide(0).animate({opacity: 0}, 400);
$('.imagebox').filter('.'+value).show(0).animate({opacity: 1}, 400);
}
})
// add active class on selected item
$('.list').click(function(){
$(this).addClass('active').siblings().removeClass('active');
})
})