фиксы и фичи
This commit is contained in:
182
template.html
182
template.html
@@ -23,11 +23,6 @@
|
||||
<meta name="keywords" content="RomkaZVO, mashup, mashup su, файлы, обмен, скачать, загрузить" />
|
||||
|
||||
<script>
|
||||
// Отключаем все alert на странице (на случай, если где-то закрались)
|
||||
window.alert = function() {
|
||||
console.log('Alert был заблокирован');
|
||||
};
|
||||
|
||||
function getCookie(name) {
|
||||
const value = `; ${document.cookie}`;
|
||||
const parts = value.split(`; ${name}=`);
|
||||
@@ -41,6 +36,54 @@
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
<style>
|
||||
/* Стили для кнопки копирования */
|
||||
.copy-btn {
|
||||
background: transparent;
|
||||
color: var(--text-secondary);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 6px;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
cursor: pointer;
|
||||
font-size: 0.85rem;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: all 0.2s ease;
|
||||
opacity: 0.7;
|
||||
}
|
||||
.copy-btn:hover {
|
||||
background: var(--accent-blue);
|
||||
color: white;
|
||||
border-color: var(--accent-blue);
|
||||
opacity: 1;
|
||||
transform: scale(1.05);
|
||||
}
|
||||
/* Уведомление */
|
||||
#copyNotification {
|
||||
position: fixed;
|
||||
bottom: 80px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
background: var(--accent-green);
|
||||
color: white;
|
||||
padding: 12px 24px;
|
||||
border-radius: 8px;
|
||||
font-weight: 600;
|
||||
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
|
||||
z-index: 3000;
|
||||
transition: opacity 0.3s;
|
||||
opacity: 1;
|
||||
}
|
||||
@media (max-width: 480px) {
|
||||
.copy-btn {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<button class="theme-toggle" onclick="toggleTheme()">🌙</button>
|
||||
@@ -101,25 +144,25 @@
|
||||
const content = document.getElementById('previewContent');
|
||||
const title = document.getElementById('previewTitle');
|
||||
const frame = document.getElementById('previewFrame');
|
||||
|
||||
|
||||
if (!modal || !content || !title || !frame) {
|
||||
console.error('Modal elements not found!');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
frame.style.display = 'none';
|
||||
|
||||
|
||||
title.textContent = '🔒 Введите пароль для папки: ' + folderName;
|
||||
|
||||
|
||||
const oldContainer = document.getElementById('passwordFormContainer');
|
||||
if (oldContainer) {
|
||||
oldContainer.remove();
|
||||
}
|
||||
|
||||
|
||||
const container = document.createElement('div');
|
||||
container.id = 'passwordFormContainer';
|
||||
container.style.cssText = 'display:flex;justify-content:center;align-items:center;padding:2rem;flex-grow:1;min-height:300px;';
|
||||
|
||||
|
||||
container.innerHTML = `
|
||||
<div style="background:var(--bg-secondary);border:1px solid var(--border-color);border-radius:12px;padding:2rem;max-width:400px;width:100%;text-align:center;box-shadow:0 4px 20px rgba(0,0,0,0.1);">
|
||||
<div style="font-size:3rem;margin-bottom:1rem;">🔒</div>
|
||||
@@ -136,9 +179,9 @@
|
||||
<button onclick="closePreview()" style="background:transparent;border:none;color:var(--text-secondary);cursor:pointer;font-size:0.9rem;margin-top:0.5rem;">✖ Закрыть</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
|
||||
content.appendChild(container);
|
||||
|
||||
|
||||
content.style.width = '500px';
|
||||
content.style.height = 'auto';
|
||||
content.style.maxWidth = '90vw';
|
||||
@@ -148,10 +191,10 @@
|
||||
content.style.left = '50%';
|
||||
content.style.top = '50%';
|
||||
content.style.transform = 'translate(-50%, -50%)';
|
||||
|
||||
|
||||
modal.style.display = 'block';
|
||||
document.body.style.overflow = 'hidden';
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
const input = container.querySelector('input[type="password"]');
|
||||
if (input) input.focus();
|
||||
@@ -170,6 +213,51 @@
|
||||
return true;
|
||||
};
|
||||
|
||||
// ========== НОВАЯ ФУНКЦИЯ КОПИРОВАНИЯ ==========
|
||||
window.copyLink = function(path) {
|
||||
const url = window.location.origin + path;
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard.writeText(url).then(function() {
|
||||
showNotification('✅ Ссылка скопирована!');
|
||||
}).catch(function() {
|
||||
fallbackCopy(url);
|
||||
});
|
||||
} else {
|
||||
fallbackCopy(url);
|
||||
}
|
||||
};
|
||||
|
||||
function fallbackCopy(text) {
|
||||
const textarea = document.createElement('textarea');
|
||||
textarea.value = text;
|
||||
textarea.style.position = 'fixed';
|
||||
textarea.style.left = '-9999px';
|
||||
textarea.style.top = '-9999px';
|
||||
document.body.appendChild(textarea);
|
||||
textarea.select();
|
||||
try {
|
||||
document.execCommand('copy');
|
||||
showNotification('✅ Ссылка скопирована!');
|
||||
} catch (e) {
|
||||
alert('Не удалось скопировать ссылку');
|
||||
}
|
||||
document.body.removeChild(textarea);
|
||||
}
|
||||
|
||||
function showNotification(msg) {
|
||||
const old = document.getElementById('copyNotification');
|
||||
if (old) old.remove();
|
||||
const div = document.createElement('div');
|
||||
div.id = 'copyNotification';
|
||||
div.textContent = msg;
|
||||
document.body.appendChild(div);
|
||||
setTimeout(() => {
|
||||
div.style.opacity = '0';
|
||||
setTimeout(() => div.remove(), 400);
|
||||
}, 2500);
|
||||
}
|
||||
// ==============================================
|
||||
|
||||
window.scrollToTop = function() {
|
||||
window.scrollTo({
|
||||
top: 0,
|
||||
@@ -189,13 +277,13 @@
|
||||
window.toggleTheme = function() {
|
||||
const isDark = document.body.classList.contains('dark-theme');
|
||||
const newTheme = isDark ? 'light' : 'dark';
|
||||
|
||||
|
||||
document.body.classList.toggle('dark-theme');
|
||||
document.documentElement.classList.toggle('dark-theme');
|
||||
|
||||
|
||||
const button = document.querySelector('.theme-toggle');
|
||||
button.textContent = isDark ? '🌙' : '☀️';
|
||||
|
||||
|
||||
const date = new Date();
|
||||
date.setFullYear(date.getFullYear() + 1);
|
||||
document.cookie = 'theme=' + newTheme + '; expires=' + date.toUTCString() + '; path=/';
|
||||
@@ -206,26 +294,26 @@
|
||||
const frame = document.getElementById('previewFrame');
|
||||
const content = document.getElementById('previewContent');
|
||||
const title = document.getElementById('previewTitle');
|
||||
|
||||
|
||||
const oldContainer = document.getElementById('passwordFormContainer');
|
||||
if (oldContainer) {
|
||||
oldContainer.remove();
|
||||
}
|
||||
|
||||
|
||||
frame.style.display = 'block';
|
||||
|
||||
|
||||
const fileName = fileUrl.split('/').pop();
|
||||
title.textContent = 'Предпросмотр: ' + fileName;
|
||||
|
||||
|
||||
const fileExt = fileName.split('.').pop().toLowerCase();
|
||||
const imageTypes = ['jpg', 'jpeg', 'png', 'gif', 'webp', 'bmp', 'svg', 'ico'];
|
||||
const textTypes = ['txt', 'md', 'html', 'htm', 'css', 'js', 'json', 'xml', 'csv'];
|
||||
const audioTypes = ['mp3', 'wav', 'ogg', 'flac', 'm4a', 'aac'];
|
||||
const videoTypes = ['mp4', 'webm', 'ogv', 'mov', 'avi', 'mkv'];
|
||||
const isPDF = fileExt === 'pdf';
|
||||
|
||||
|
||||
frame.src = '';
|
||||
|
||||
|
||||
let imgContainer = document.getElementById('previewImageContainer');
|
||||
if (!imgContainer) {
|
||||
imgContainer = document.createElement('div');
|
||||
@@ -235,29 +323,29 @@
|
||||
}
|
||||
imgContainer.style.display = 'none';
|
||||
imgContainer.innerHTML = '';
|
||||
|
||||
|
||||
if (imageTypes.includes(fileExt)) {
|
||||
frame.style.display = 'none';
|
||||
imgContainer.style.display = 'flex';
|
||||
|
||||
|
||||
const img = document.createElement('img');
|
||||
img.src = fileUrl;
|
||||
img.alt = fileName;
|
||||
img.className = 'preview-image';
|
||||
|
||||
|
||||
img.onload = function() {
|
||||
adjustModalForImage(this);
|
||||
};
|
||||
|
||||
|
||||
img.onerror = function() {
|
||||
console.error('Failed to load image:', fileUrl);
|
||||
frame.style.display = 'block';
|
||||
imgContainer.style.display = 'none';
|
||||
frame.src = fileUrl;
|
||||
};
|
||||
|
||||
|
||||
imgContainer.appendChild(img);
|
||||
|
||||
|
||||
content.style.width = '90vw';
|
||||
content.style.height = '90vh';
|
||||
content.style.maxWidth = 'none';
|
||||
@@ -267,11 +355,11 @@
|
||||
content.style.left = 'auto';
|
||||
content.style.top = 'auto';
|
||||
content.style.transform = 'none';
|
||||
|
||||
|
||||
} else {
|
||||
frame.style.display = 'block';
|
||||
imgContainer.style.display = 'none';
|
||||
|
||||
|
||||
if (textTypes.includes(fileExt)) {
|
||||
content.style.width = '80vw';
|
||||
content.style.height = '70vh';
|
||||
@@ -299,16 +387,16 @@
|
||||
content.style.maxWidth = '1000px';
|
||||
content.style.maxHeight = '800px';
|
||||
}
|
||||
|
||||
|
||||
content.style.margin = '2% auto';
|
||||
content.style.position = 'relative';
|
||||
content.style.left = 'auto';
|
||||
content.style.top = 'auto';
|
||||
content.style.transform = 'none';
|
||||
|
||||
|
||||
frame.src = fileUrl;
|
||||
}
|
||||
|
||||
|
||||
modal.style.display = 'block';
|
||||
document.body.style.overflow = 'hidden';
|
||||
};
|
||||
@@ -317,22 +405,22 @@
|
||||
const content = document.getElementById('previewContent');
|
||||
const maxWidth = window.innerWidth * 0.95;
|
||||
const maxHeight = window.innerHeight * 0.95;
|
||||
|
||||
|
||||
const imgWidth = img.naturalWidth;
|
||||
const imgHeight = img.naturalHeight;
|
||||
|
||||
|
||||
let scale = 1;
|
||||
|
||||
|
||||
if (imgWidth > maxWidth) {
|
||||
scale = Math.min(scale, maxWidth / imgWidth);
|
||||
}
|
||||
if (imgHeight > maxHeight) {
|
||||
scale = Math.min(scale, maxHeight / imgHeight);
|
||||
}
|
||||
|
||||
|
||||
const displayWidth = imgWidth * scale;
|
||||
const displayHeight = imgHeight * scale;
|
||||
|
||||
|
||||
content.style.width = (displayWidth + 20) + 'px';
|
||||
content.style.height = (displayHeight + 80) + 'px';
|
||||
content.style.margin = 'auto';
|
||||
@@ -346,17 +434,17 @@
|
||||
const modal = document.getElementById('previewModal');
|
||||
const frame = document.getElementById('previewFrame');
|
||||
const content = document.getElementById('previewContent');
|
||||
|
||||
|
||||
modal.style.display = 'none';
|
||||
frame.src = '';
|
||||
frame.classList.remove('pdf');
|
||||
frame.style.display = 'block';
|
||||
|
||||
|
||||
const oldContainer = document.getElementById('passwordFormContainer');
|
||||
if (oldContainer) {
|
||||
oldContainer.remove();
|
||||
}
|
||||
|
||||
|
||||
content.style.width = '';
|
||||
content.style.height = '';
|
||||
content.style.maxWidth = '';
|
||||
@@ -366,16 +454,16 @@
|
||||
content.style.left = '';
|
||||
content.style.top = '';
|
||||
content.style.transform = '';
|
||||
|
||||
|
||||
const imgContainer = document.getElementById('previewImageContainer');
|
||||
if (imgContainer) {
|
||||
imgContainer.style.display = 'none';
|
||||
imgContainer.innerHTML = '';
|
||||
}
|
||||
|
||||
|
||||
const title = document.getElementById('previewTitle');
|
||||
title.textContent = 'Предпросмотр файла';
|
||||
|
||||
|
||||
document.body.style.overflow = 'auto';
|
||||
};
|
||||
|
||||
@@ -394,7 +482,7 @@
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const savedTheme = getCookie('theme');
|
||||
const button = document.querySelector('.theme-toggle');
|
||||
|
||||
|
||||
if (savedTheme === 'dark') {
|
||||
document.body.classList.add('dark-theme');
|
||||
button.textContent = '☀️';
|
||||
|
||||
Reference in New Issue
Block a user