MediaWiki:Common.js: Revizyonlar arasındaki fark

korna ansiklopedisi sitesinden
Gezinti kısmına atlaArama kısmına atla
Değişiklik özeti yok
Değişiklik özeti yok
1. satır: 1. satır:
$(function() {
$(function() {
     // 1. SOSYAL MEDYA LİNKLERİ (ORJİNAL KODUNUZ)
     // 1. SOSYAL MEDYA LİNKLERİ
     var links = [
     var links = [
         {  
         {  
33. satır: 33. satır:
                 href: link.url,
                 href: link.url,
                 title: link.text,
                 title: link.text,
                 target: '_blank',
                 target: '_blank'
                rel: 'noopener noreferrer'
             })
             })
             .append($('<img>', {  
             .append($('<img>', { src: link.icon, alt: link.text }))
                src: link.icon,  
                alt: link.text,
                loading: 'lazy'
            }))
             .append(link.text)
             .append(link.text)
         );
         );
     });
     });


     // 3. MEDIAVIEWER DÜZELTMESİ (GÜNCELLENMİŞ)
     // 3. MEDIAVIEWER AYARLARI (GÜNCELLENMİŞ)
     function initMediaViewer() {
     function handleImageClick(e) {
         $('a.image').off('click').on('click', function(e) {
         e.preventDefault();
            e.preventDefault();
        var $link = $(this);
            var $this = $(this);
        var imageUrl = $link.attr('href');
            var imgSrc = $this.find('img').attr('src') || $this.attr('href');
       
           
        // Eğer URL dosya sayfasına işaret ediyorsa, direkt resim URL'sini al
            // GÜNCEL MEDIAVIEWER API KULLANIMI
        if (imageUrl.includes('/Dosya:')) {
            mw.loader.using('mmv').then(function() {
            imageUrl = imageUrl.replace('/index.php/Dosya:', '/images/').replace('/Dosya:', '/');
                if (mw.mmv && mw.mmv.lightboxbox) {
        }
                    mw.mmv.lightboxbox.open(imgSrc);
       
                } else if (mw.mmv && mw.mmv.openImage) {
        // MediaViewer'ı dene
                    mw.mmv.openImage(imgSrc); // Eski sürümler için
        mw.loader.using('mmv').then(function() {
                 } else {
            if (mw.mmv && mw.mmv.lightboxbox) {
                    window.location.href = $this.attr('href'); // Fallback
                mw.mmv.lightboxbox.open(imageUrl);
                }
            } else {
            }).catch(function() {
                // Fallback: Resmi yeni sekmede aç
                window.location.href = $this.attr('href'); // Fallback
                 window.open(imageUrl, '_blank');
            });
            }
        }).catch(function() {
            // Fallback 2: Orjinal linke git
            window.location.href = $link.attr('href');
         });
         });
     }
     }
71. satır: 69. satır:
     $('#firstHeading').before($socialBar);
     $('#firstHeading').before($socialBar);
      
      
     // MEDIAVIEWER İNİT (YENİ YÖNTEM)
     // Resim linklerini dinle
    $(document).on('click', 'a.image', handleImageClick);
   
    // MediaViewer yüklendikten sonra tekrar init et
     mw.loader.using('mmv').then(function() {
     mw.loader.using('mmv').then(function() {
         initMediaViewer();
         $('a.image').off('click').on('click', handleImageClick);
    }).catch(function() {
        console.warn('MediaViewer yüklenemedi, 2. deneme...');
        setTimeout(initMediaViewer, 1000);
     });
     });
});
});

21.40, 3 Nisan 2025 tarihindeki hâli

$(function() {
    // 1. SOSYAL MEDYA LİNKLERİ
    var links = [
        { 
            icon: '//videoliq.com.tr/images/d/dd/Discord.png?20250402213537',
            text: 'Discord', 
            url: 'https://discord.gg/a4jGxPkHTc' 
        },
        {
            icon: '//upload.wikimedia.org/wikipedia/commons/8/82/Telegram_logo.svg',
            text: 'Telegram',
            url: 'https://videoliq.com.tr/acmadik.php'
        },
        {
            icon: '//videoliq.com.tr/images/7/76/Sitwatch.png?20250402214911',
            text: 'SitWatch',
            url: 'https://sitwatch.net/profile/EncyclopediaKorna'
        },
        {
            icon: '//upload.wikimedia.org/wikipedia/commons/8/83/Steam_icon_logo.svg',
            text: 'Steam',
            url: 'https://videoliq.com.tr/acmadik.php'
        }
    ];

    // 2. SOSYAL MEDYA BARINI OLUŞTUR
    var $socialBar = $('<div id="korna-social-header"></div>');
    var $linksContainer = $('<div id="korna-social-links"></div>');
    
    links.forEach(function(link) {
        $linksContainer.append(
            $('<a>', {
                href: link.url,
                title: link.text,
                target: '_blank'
            })
            .append($('<img>', { src: link.icon, alt: link.text }))
            .append(link.text)
        );
    });

    // 3. MEDIAVIEWER AYARLARI (GÜNCELLENMİŞ)
    function handleImageClick(e) {
        e.preventDefault();
        var $link = $(this);
        var imageUrl = $link.attr('href');
        
        // Eğer URL dosya sayfasına işaret ediyorsa, direkt resim URL'sini al
        if (imageUrl.includes('/Dosya:')) {
            imageUrl = imageUrl.replace('/index.php/Dosya:', '/images/').replace('/Dosya:', '/');
        }
        
        // MediaViewer'ı dene
        mw.loader.using('mmv').then(function() {
            if (mw.mmv && mw.mmv.lightboxbox) {
                mw.mmv.lightboxbox.open(imageUrl);
            } else {
                // Fallback: Resmi yeni sekmede aç
                window.open(imageUrl, '_blank');
            }
        }).catch(function() {
            // Fallback 2: Orjinal linke git
            window.location.href = $link.attr('href');
        });
    }

    // 4. SAYFA YÜKLENDİĞİNDE ÇALIŞTIR
    $socialBar.append($linksContainer);
    $('#firstHeading').before($socialBar);
    
    // Resim linklerini dinle
    $(document).on('click', 'a.image', handleImageClick);
    
    // MediaViewer yüklendikten sonra tekrar init et
    mw.loader.using('mmv').then(function() {
        $('a.image').off('click').on('click', handleImageClick);
    });
});