mirror of
https://github.com/nxshock/gallery.git
synced 2024-11-27 00:11:00 +05:00
221 lines
6.1 KiB
HTML
221 lines
6.1 KiB
HTML
|
<!DOCTYPE html>
|
||
|
<html>
|
||
|
|
||
|
<head>
|
||
|
<meta charset="utf-8">
|
||
|
<title>Gallery</title>
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||
|
<link rel="shortcut icon" href="#" type="image/x-icon">
|
||
|
<style>
|
||
|
:root {
|
||
|
--base00: #282c34;
|
||
|
--base01: #353b45;
|
||
|
--base02: #3e4451;
|
||
|
--base03: #545862;
|
||
|
--base04: #565c64;
|
||
|
--base05: #abb2bf;
|
||
|
--base06: #b6bdca;
|
||
|
--base07: #c8ccd4;
|
||
|
--base08: #e06c75;
|
||
|
--base09: #d19a66;
|
||
|
--base0A: #e5c07b;
|
||
|
--base0B: #98c379;
|
||
|
--base0C: #56b6c2;
|
||
|
--base0D: #61afef;
|
||
|
--base0E: #c678dd;
|
||
|
--base0F: #be5046;
|
||
|
}
|
||
|
|
||
|
* {
|
||
|
font-family: Verdana;
|
||
|
font-size: 16px;
|
||
|
color: var(--base05);
|
||
|
margin: 0;
|
||
|
padding: 0;
|
||
|
}
|
||
|
|
||
|
body {
|
||
|
background-color: var(--base00);
|
||
|
display: flex;
|
||
|
justify-content: space-between;
|
||
|
flex-wrap: nowrap;
|
||
|
flex-direction: column;
|
||
|
}
|
||
|
|
||
|
ul {
|
||
|
list-style-type: none;
|
||
|
display: flex;
|
||
|
flex-wrap: wrap;
|
||
|
}
|
||
|
|
||
|
body>ul>li {
|
||
|
width: 240px;
|
||
|
height: 240px;
|
||
|
display: flex;
|
||
|
align-items: center;
|
||
|
justify-content: center;
|
||
|
border: 1px solid var(--base01);
|
||
|
}
|
||
|
|
||
|
body>ul>li>a {
|
||
|
position: relative;
|
||
|
width: 100%;
|
||
|
height: 100%;
|
||
|
}
|
||
|
|
||
|
body>ul>li>a>span {
|
||
|
position: absolute;
|
||
|
left: 0;
|
||
|
bottom: 0;
|
||
|
z-index: 1;
|
||
|
width: 100%;
|
||
|
background-color: var(--base00);
|
||
|
}
|
||
|
|
||
|
body>ul>li>img {
|
||
|
width: 100%;
|
||
|
height: 100%;
|
||
|
cursor: pointer;
|
||
|
}
|
||
|
/* The Modal (background) */
|
||
|
|
||
|
.modal {
|
||
|
display: none;
|
||
|
position: fixed;
|
||
|
z-index: 2;
|
||
|
/* padding-top: 100px; */
|
||
|
left: 0;
|
||
|
top: 0;
|
||
|
width: 100%;
|
||
|
height: 100%;
|
||
|
overflow: auto;
|
||
|
background-color: rgb(0, 0, 0);
|
||
|
background-color: rgba(0, 0, 0, 0.9);
|
||
|
}
|
||
|
/* Modal Content (image) */
|
||
|
|
||
|
#modal-content {
|
||
|
margin: auto;
|
||
|
display: block;
|
||
|
width: 100%;
|
||
|
height: 100%;
|
||
|
object-fit: contain;
|
||
|
}
|
||
|
/* The Close Button */
|
||
|
|
||
|
.close {
|
||
|
position: absolute;
|
||
|
top: 15px;
|
||
|
right: 35px;
|
||
|
color: var(--base05);
|
||
|
font-size: 40px;
|
||
|
font-weight: bold;
|
||
|
}
|
||
|
|
||
|
.close:hover,
|
||
|
.close:focus {
|
||
|
color: #bbb;
|
||
|
text-decoration: none;
|
||
|
cursor: pointer;
|
||
|
}
|
||
|
</style>
|
||
|
</head>
|
||
|
|
||
|
<body>
|
||
|
<ul>
|
||
|
{{range .}} {{if eq .ItemType 1}}
|
||
|
<li>
|
||
|
<a href="/{{.Path}}"><img src="/preview/{{.Path}}"><span>{{.Path.Base}}</span></a>{{end}} {{if eq .ItemType 2}}
|
||
|
<li><img src="/preview/{{.Path}}"></li>{{end}} {{if eq .ItemType 3}}
|
||
|
<li><img src="/preview/{{.Path}}"></li>{{end}} {{end}}
|
||
|
</ul>
|
||
|
|
||
|
<!-- The Modal -->
|
||
|
<div id="myModal" class="modal">
|
||
|
<span class="close">×</span>
|
||
|
<!--<img class="modal-content" id="img01">-->
|
||
|
</div>
|
||
|
</body>
|
||
|
|
||
|
<script>
|
||
|
var imageIndex = 0
|
||
|
|
||
|
document.addEventListener('keydown', (event) => {
|
||
|
let childNumber = 0
|
||
|
if (event.key == "ArrowRight") {
|
||
|
imageIndex += 1
|
||
|
if (document.querySelector("body > ul").children.length == imageIndex) {
|
||
|
imageIndex -= 1
|
||
|
return
|
||
|
}
|
||
|
childNumber = imageIndex + 1
|
||
|
} else if (event.key == "ArrowLeft") {
|
||
|
imageIndex -= 1
|
||
|
if (imageIndex < 0) {
|
||
|
imageIndex = 0
|
||
|
return
|
||
|
}
|
||
|
childNumber = imageIndex + 1
|
||
|
}
|
||
|
document.querySelector("body > ul > li:nth-child(" + childNumber + ") > img").click()
|
||
|
}, false);
|
||
|
|
||
|
// document.title = decodeURI(window.location.pathname).substring(1, window.location.pathname.length - 1) + " :: Gallery"
|
||
|
|
||
|
// Get the modal
|
||
|
var modal = document.getElementById('myModal');
|
||
|
|
||
|
// Get the image and insert it inside the modal - use its "alt" text as a caption
|
||
|
// var img = document.getElementById('myImg');
|
||
|
var modalImg = document.getElementById("img01");
|
||
|
|
||
|
for (let img of document.querySelectorAll('body > ul > li > img')) {
|
||
|
img.onclick = function() {
|
||
|
try {
|
||
|
document.getElementById("modal-content").remove()
|
||
|
} catch {}
|
||
|
|
||
|
imageIndex = Array.from(img.parentNode.parentNode.children).indexOf(img.parentNode)
|
||
|
modal.style.display = "block"
|
||
|
|
||
|
let tag = ""
|
||
|
|
||
|
switch (this.src.split('.').pop().toLowerCase()) {
|
||
|
case "jpg":
|
||
|
case "jpeg":
|
||
|
case "png":
|
||
|
case "bmp":
|
||
|
case "gif":
|
||
|
case "avif":
|
||
|
tag = "img"
|
||
|
break;
|
||
|
case "mkv":
|
||
|
case "webm":
|
||
|
case "mp4":
|
||
|
case "mov":
|
||
|
case "avi":
|
||
|
case "3gp":
|
||
|
tag = "video"
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
let imgModal = document.createElement(tag)
|
||
|
imgModal.id = "modal-content"
|
||
|
imgModal.src = this.src.replace("/preview/", "/view/")
|
||
|
imgModal.setAttribute("controls", "controls")
|
||
|
|
||
|
document.getElementById("myModal").append(imgModal)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Get the <span> element that closes the modal
|
||
|
var span = document.getElementsByClassName("close")[0];
|
||
|
|
||
|
// When the user clicks on <span> (x), close the modal
|
||
|
span.onclick = function() {
|
||
|
modal.style.display = "none";
|
||
|
document.getElementById("modal-content").remove()
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
</html>
|