File size: 5,396 Bytes
7cb88eb
79c6f24
 
 
6184298
84837a7
79c6f24
 
 
 
 
 
b2b5861
2f7725e
b2b5861
6184298
 
 
 
84837a7
6184298
 
84837a7
 
6184298
 
 
84837a7
79c6f24
84837a7
6184298
79c6f24
6184298
b2b5861
 
6184298
 
 
 
 
 
 
84837a7
 
79c6f24
84837a7
6184298
79c6f24
6184298
79c6f24
6184298
79c6f24
 
 
6184298
7cb88eb
 
6184298
79c6f24
 
 
 
 
 
 
 
 
 
6184298
7cb88eb
 
 
6184298
7cb88eb
6184298
84837a7
79c6f24
 
 
 
 
 
 
 
 
7cb88eb
 
b2b5861
 
7cb88eb
 
79c6f24
 
 
 
 
 
 
 
84837a7
 
79c6f24
 
84837a7
 
 
 
 
 
 
 
 
 
 
79c6f24
84837a7
 
 
 
 
79c6f24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84837a7
 
 
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139

document.addEventListener('DOMContentLoaded', function() {
    // Initialize admin system and gallery on gallery.html
    if (window.location.pathname.includes('gallery.html')) {
        // Admin login system
        const loginBtn = document.getElementById("loginBtn");
        const logoutBtn = document.getElementById("logoutBtn");
        const uploadArea = document.getElementById("uploadArea");
        const gallery = document.getElementById("gallery");
        const fileInput = document.getElementById("fileInput");
        const uploadBtn = document.getElementById("uploadBtn");
        const uploadMsg = document.getElementById("uploadMsg");
        // Admin password
        const ADMIN_PASSWORD = "gg_mistro.249";  // Keep the same password
function checkLogin() {
            const expires = localStorage.getItem("loginExpires");
            const loggedIn = expires && new Date().getTime() < expires;

            if (loggedIn) {
                uploadArea.style.display = "block";
                logoutBtn.classList.remove("hidden");
                loginBtn.classList.add("hidden");
            } else {
                uploadArea.style.display = "none";
                logoutBtn.classList.add("hidden");
                loginBtn.classList.remove("hidden");
                localStorage.removeItem("loginExpires");
            }
        }

        loginBtn.addEventListener('click', async () => {
            const input = prompt("Enter admin password:");
            if (input) {
                if (input === ADMIN_PASSWORD) {
// Set session to expire in 2 hours
                    const expires = new Date().getTime() + 7200000;
                    localStorage.setItem("loginExpires", expires);
                    checkLogin();
                    alert("Login successful!");
                } else {
                    alert("Incorrect password.");
                }
            }
        });

        logoutBtn.addEventListener('click', () => {
            localStorage.removeItem("loginExpires");
            checkLogin();
            alert("You have been logged out.");
        });
// === IMAGE UPLOAD ===
        uploadBtn.addEventListener('click', () => {
            const files = fileInput.files;
            if (!files.length) return alert("Select image(s) first!");
            uploadMsg.textContent = "Uploading... (0/"+files.length+")";
            uploadMsg.style.display = 'block';
            uploadMsg.style.color = 'white';
for (const file of files) {
                const reader = new FileReader();
                reader.onload = e => {
                    const img = document.createElement("img");
                    img.src = e.target.result;
                    img.classList.add("zoomable");
                    gallery.appendChild(img);
                    saveImage(e.target.result);
                };
                reader.readAsDataURL(file);
            }
            uploadMsg.textContent = "Upload complete! ("+files.length+"/"+files.length+")";
            uploadMsg.style.color = '#00FF7F';
            setTimeout(() => {
                uploadMsg.style.display = 'none';
                fileInput.value = ''; // Clear file input
            }, 3000);
});

        function saveImage(dataUrl) {
            const saved = JSON.parse(localStorage.getItem("images") || "[]");
            saved.push(dataUrl);
            localStorage.setItem("images", JSON.stringify(saved));
        }

        function loadImages() {
            gallery.innerHTML = "";
            const saved = JSON.parse(localStorage.getItem("images") || "[]");
            
            if (saved.length === 0) {
            gallery.innerHTML = '';
return;
            }

            for (const src of saved) {
                const img = document.createElement("img");
                img.src = src;
                img.classList.add("zoomable");
                gallery.appendChild(img);
            }
        }
        loadImages();

        // === IMAGE ZOOM FEATURE ===
        const zoomContainer = document.createElement("div");
        zoomContainer.id = "zoomContainer";
        zoomContainer.style.display = "none";
        zoomContainer.style.position = "fixed";
        zoomContainer.style.top = "0";
        zoomContainer.style.left = "0";
        zoomContainer.style.width = "100%";
        zoomContainer.style.height = "100%";
        zoomContainer.style.background = "rgba(0,0,0,0.8)";
        zoomContainer.style.justifyContent = "center";
        zoomContainer.style.alignItems = "center";
        zoomContainer.style.zIndex = "9999";

        const zoomImg = document.createElement("img");
        zoomImg.style.maxWidth = "90%";
        zoomImg.style.maxHeight = "90%";
        zoomImg.style.borderRadius = "10px";
        zoomImg.style.boxShadow = "0 0 20px #00FF7F";

        zoomContainer.appendChild(zoomImg);
        document.body.appendChild(zoomContainer);

        gallery.addEventListener("click", e => {
            if (e.target.tagName === "IMG") {
                zoomImg.src = e.target.src;
                zoomContainer.style.display = "flex";
                document.body.style.overflow = "hidden";
            }
        });

        zoomContainer.addEventListener("click", () => {
            zoomContainer.style.display = "none";
            document.body.style.overflow = "auto";
        });
    }
    feather.replace();
});