MediaWiki:Common.js: Perbedaan antara revisi

Tidak ada ringkasan suntingan
Tanda: Suntingan perangkat seluler Suntingan peramban seluler
Tidak ada ringkasan suntingan
Tanda: Suntingan perangkat seluler Suntingan peramban seluler
Baris 1: Baris 1:
/* ==========================================================
/* ==========================================================
   🧠 MIPPEDIA DATA - SMART CONTEXT + AUTO THUMBNAIL (V8)
   🧠 MIPPEDIA DATA - SMART CONTEXT + AUTO THUMBNAIL (V9.1 - HOTFIX)
   Features: Priority Check (ID > EN > CONCISE), Auto-Age,  
   Features: Priority Check (ID > EN > CONCISE), Auto-Age,  
             Auto-Bold, Smart Links, Dynamic Context,
             Auto-Bold, Smart Links, Dynamic Context,
             Targeted Isolation (Hanya Sembunyikan Tabel Data Utama),  
             Targeted Isolation (Safe for Forms), Dynamic Noindex,
            Dynamic Noindex, User-Group Based Edit Lock (Sysop Bypass)
            Aesthetic Centered Empty State (Regex Hotfix Implemented)
   ========================================================= */
   ========================================================= */
(function() {
(function() {
Baris 18: Baris 18:
             currentYear = 2026;
             currentYear = 2026;


         // --- KONFIGURASI PROYEK (Tetap Utuh) ---
         // --- KONFIGURASI PROYEK ---
         var projects = [
         var projects = [
             { id: 'id', name: 'Mippedia bahasa Indonesia', url: 'https://id.mippedia.org/api.php', base: 'https://id.mippedia.org/wiki/', label: 'Mippedia Indonesia' },
             { id: 'id', name: 'Mippedia bahasa Indonesia', url: 'https://id.mippedia.org/api.php', base: 'https://id.mippedia.org/wiki/', label: 'Mippedia Indonesia' },
Baris 25: Baris 25:
         ];
         ];


         // --- FUNGSI TOOLS (TETAP UTUH) ---
        // --- 🎨 ANIMASI & ISOLASI STYLE ---
        if (!$('#mip-clean-style').length) {
            $('head').append(
                '<style id="mip-clean-style">' +
                    '@keyframes mipFadeInUp {' +
                        'from { opacity: 0; transform: translateY(15px); }' +
                        'to { opacity: 1; transform: translateY(0); }' +
                    '}' +
                    '#mip-empty-state-notice {' +
                        'animation: mipFadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;' +
                    '}' +
                '</style>'
            );
        }
 
         // --- FUNGSI TOOLS ---
         function applyAutoBold(text) { return text.replace(new RegExp('(' + pageTitle + ')', 'gi'), '<strong>$1</strong>'); }
         function applyAutoBold(text) { return text.replace(new RegExp('(' + pageTitle + ')', 'gi'), '<strong>$1</strong>'); }
         function cleanExtract(text) { return text.replace(/\[\d+\]/g, '').replace(/\{\{[^}]+\}\}/g, '').replace(/\(\s*\)/g, '').replace(/\s\s+/g, ' ').trim(); }
         function cleanExtract(text) { return text.replace(/\[\d+\]/g, '').replace(/\{\{[^}]+\}\}/g, '').replace(/\(\s*\)/g, '').replace(/\s\s+/g, ' ').trim(); }
Baris 51: Baris 66:
         }
         }


         // --- SMART LINKS PORTAL BERBASIS INTERWIKI VALID ---
         // --- SMART LINKS PORTAL ---
         function buildSmartLinks(currentId, validatedEnTitle) {
         function buildSmartLinks(currentId, validatedEnTitle) {
             $portalLinks.empty();
             $portalLinks.empty();
Baris 73: Baris 88:
         }
         }


         // --- 🧠 FUNGSI UTAMA SWITCHER TARGETED ISOLATION ---
         // --- 🧠 RENDER EMPTY STATE MINIMALIS ---
         function toggleMippediaLayout(isEmpty) {
         function toggleMippediaLayout(isEmpty) {
             var $existingNotice = $('#mip-empty-state-notice');
             var $existingNotice = $('#mip-empty-state-notice');
           
            // Cek status grup pengguna
             var userGroups = mw.config.get('wgUserGroups') || [];
             var userGroups = mw.config.get('wgUserGroups') || [];
             var isSysop = userGroups.indexOf('sysop') !== -1;
             var isSysop = userGroups.indexOf('sysop') !== -1;


            // Selector elemen data bawaan repositori Wikibase / Mippedia Data asli
             var $wikiDataElements = $mainContent.children().not('#mip-empty-state-notice, #mip-desc-section, script, style, .printfooter');
             var $wikiDataElements = $mainContent.children().not('#mip-empty-state-notice, #mip-desc-section, script, style, .printfooter');
             var $editElements = $('#ca-edit, .mw-editsection, .wb-editsection, .mip-edit-trigger, [id*="edit"], [class*="edit-pencil"]');
             var $editElements = $('#ca-edit, .mw-editsection, .wb-editsection, .mip-edit-trigger, [id*="edit"], [class*="edit-pencil"]');
Baris 87: Baris 99:


             if (isEmpty) {
             if (isEmpty) {
                // 1. TAMPILKAN KOTAK PEMBERITAHUAN
                 if (!$existingNotice.length) {
                 if (!$existingNotice.length) {
                    // Hotfix baris penutup SVG dipisah bauran string agar lolos filter MediaWiki
                     var noticeHtml =  
                     var noticeHtml =  
                         '<div id="mip-empty-state-notice" style="margin: 15px 0; padding: 20px; border-left: 5px solid #d9534f; background-color: #fdf7f7; border-radius: 4px; font-family: sans-serif; line-height: 1.6; display: block;">' +
                         '<div id="mip-empty-state-notice" style="text-align: center; max-width: 550px; margin: 60px auto; padding: 10px; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, sans-serif;">' +
                             '<h4 style="color: #d9534f; margin-top: 0; margin-bottom: 8px; font-size: 1.15em; font-weight: bold;">⚠️ Item Data Tidak Memiliki Sumber Artikel</h4>' +
                            '<!-- Ikon Warning Besar Modern -->' +
                             '<p style="color: #333; margin: 0 0 10px 0; font-size: 0.95em;">Item data ini saat ini <strong>tidak memiliki artikel rujukan satu pun</strong> di Mippedia Indonesia, Mippedia Inggris, maupun Mippedia Indonesia Ringkas.</p>' +
                            '<div style="margin-bottom: 25px; display: inline-block;">' +
                             '<div style="font-size: 0.88em; color: #777; border-top: 1px solid #eed3d3; padding-top: 8px; font-style: italic;">' +
                                '<svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="#d9534f" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">' +
                                    '<path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path>' +
                                    '<line x1="12" y1="9" x2="12" y2="13"></line>' +
                                    '<line x1="12" y1="17" x2="12.01" y2="17"></line>' +
                                '</' + 'svg>' +
                            '</div>' +
                            '<!-- Judul Utama -->' +
                             '<h4 style="color: #2c3e50; margin: 0 0 12px 0; font-size: 1.35em; font-weight: 700; letter-spacing: -0.3px;">Item Data Tidak Memiliki Sumber Artikel</h4>' +
                            '<!-- Deskripsi Utama -->' +
                             '<p style="color: #555; margin: 0 0 20px 0; font-size: 0.98em; line-height: 1.6;">' +
                                'Item data ini saat ini <strong>tidak memiliki artikel rujukan satu pun</strong> di Mippedia Indonesia, Mippedia Inggris, maupun Mippedia Indonesia Ringkas.' +
                            '</p>' +
                            '<!-- Catatan Kaki Info Kecil (Dimmed) -->' +
                             '<div style="font-size: 0.85em; color: #a0a0a0; line-height: 1.5; font-style: italic; border-top: 1px solid #f0f0f0; padding-top: 15px;">' +
                                 'Informasi: Item data yang tidak terikat dengan artikel ensiklopedia apa pun dalam ekosistem Mippedia akan dihapus secara otomatis oleh pengurus dalam waktu dekat.' +
                                 'Informasi: Item data yang tidak terikat dengan artikel ensiklopedia apa pun dalam ekosistem Mippedia akan dihapus secara otomatis oleh pengurus dalam waktu dekat.' +
                             '</div>' +
                             '</div>' +
Baris 100: Baris 125:
                 }
                 }


                // 2. SEMBUNYIKAN HANYA ELEMEN DATA ASLI (Bukan seluruh konten pembungkus)
                 $wikiDataElements.hide();
                 $wikiDataElements.hide();
                 $descSection.hide();
                 $descSection.hide();


                // 3. LOCK EDIT UNTUK USER BIASA
                 if (!isSysop) {
                 if (!isSysop) {
                     $editElements.css({ 'pointer-events': 'none', 'opacity': '0.3', 'cursor': 'not-allowed' }).hide();
                     $editElements.css({ 'pointer-events': 'none', 'opacity': '0.3', 'cursor': 'not-allowed' }).hide();
Baris 115: Baris 138:
                 }
                 }


                // 4. METADATA ROBOTS NOINDEX FOR SEO SECURITY
                 mw.config.set('wgRobotsPolicies', { 'index': 'noindex', 'follow': 'nofollow' });
                 mw.config.set('wgRobotsPolicies', { 'index': 'noindex', 'follow': 'nofollow' });
                 if ($metaRobots.length) {
                 if ($metaRobots.length) {
Baris 124: Baris 146:


             } else {
             } else {
                // --- RESET KONDISI LAYOUT NORMAL ---
                 if ($existingNotice.length) $existingNotice.remove();
                 if ($existingNotice.length) $existingNotice.remove();
                  
                  
                // Kembalikan visibilitas elemen data bawaan secara natural
                 $wikiDataElements.show();
                 $wikiDataElements.show();
                 $descSection.show();
                 $descSection.show();


                // Lepas keylock edit (TANPA MEMAKSA TRIGGER `.show()` PADA TOMBOL JIKA JALAN NORMAL)
                 if (!isSysop) {
                 if (!isSysop) {
                     $(document).off('keydown.miplock');
                     $(document).off('keydown.miplock');
                 }
                 }


                // Aktifkan kembali hak index Google Search Engine
                 mw.config.set('wgRobotsPolicies', { 'index': 'index', 'follow': 'follow' });
                 mw.config.set('wgRobotsPolicies', { 'index': 'index', 'follow': 'follow' });
                 if ($metaRobots.length) {
                 if ($metaRobots.length) {
Baris 144: Baris 162:
         }
         }


         // --- SISTEM PRIORITAS (MIPPEDIA ID > EN > CONCISE) ---
         // --- SISTEM PRIORITAS ---
         var cached = JSON.parse(localStorage.getItem(cacheKey) || "{}");
         var cached = JSON.parse(localStorage.getItem(cacheKey) || "{}");
         var globalEnTitle = cached.enTitle || "";  
         var globalEnTitle = cached.enTitle || "";  
Baris 179: Baris 197:
         }
         }


        // --- ANTRIAN PRIORITAS DENGAN VALIDASI INTERWIKI ---
         function fetchPriorityData(index, newTS, img) {
         function fetchPriorityData(index, newTS, img) {
             if (index >= projects.length) {
             if (index >= projects.length) {
Baris 267: Baris 284:
             buildSmartLinks(p.id, enTitle);
             buildSmartLinks(p.id, enTitle);
              
              
            // Handlers (TETAP UTUH)
             $(document).off('click', '.mip-read-btn').on('click', '.mip-read-btn', function() { $(this).hide(); $('.mip-dots').hide(); $('.mip-more').fadeIn(); });
             $(document).off('click', '.mip-read-btn').on('click', '.mip-read-btn', function() { $(this).hide(); $('.mip-dots').hide(); $('.mip-more').fadeIn(); });
             $(document).off('click', '#mip-toggle-orig').on('click', '#mip-toggle-orig', function() {
             $(document).off('click', '#mip-toggle-orig').on('click', '#mip-toggle-orig', function() {