Немає опису редагування
Немає опису редагування
Рядок 121: Рядок 121:
});
});


// Автоматическое исправление всех ссылок на изображения
// Автоматичне визначення тачскріна
$(document).ready(function() {
function initKioskFeatures() {
     // Исправляем все ссылки на файлы
     const isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
    $('a[href*="/images/"]').each(function() {
        var href = $(this).attr('href');
        if (href && href.match(/\.(png|jpg|jpeg|gif)$/i)) {
            // Заменяем на ссылку на страницу файла вместо прямого открытия
            var newHref = href.replace(/\/images\//, '/wiki/File:');
            $(this).attr('href', newHref);
        }
    });
      
      
     // Для страниц с изображениями добавляем кнопку закрытия
     if (isTouchDevice) {
    if (window.location.pathname.indexOf('/images/') !== -1) {
        // Додаємо стиль для тачскріна
         addCloseButton();
        const style = document.createElement('style');
        style.textContent = `
            .touch-friendly { min-height: 44px; font-size: 18px; }
            a { min-height: 44px; display: flex; align-items: center; }
        `;
        document.head.appendChild(style);
       
        // Додаємо перемикач режиму в футер
        const footer = document.querySelector('#footer') || document.body;
        const modeSwitcher = document.createElement('div');
        modeSwitcher.innerHTML = `
            <div style="position:fixed; bottom:10px; right:10px; background:#333; color:white; padding:10px; border-radius:5px;">
                📱 Кіосковий режим |
                <a href="?kiosk=0" style="color:white;">Звичайний режим</a>
            </div>
        `;
         footer.appendChild(modeSwitcher);
     }
     }
});
}


function addCloseButton() {
// Запускаємо при завантаженні
    var closeBtn = document.createElement('button');
$(document).ready(initKioskFeatures);
    closeBtn.innerHTML = 'ЗАКРЫТЬ';
    closeBtn.style.cssText = 'position:fixed; top:10px; right:10px; z-index:9999; background:red; color:white; padding:15px; font-size:20px; border:none; border-radius:5px; cursor:pointer;';
    closeBtn.onclick = function() {
        window.history.back();
    };
    document.body.appendChild(closeBtn);
}