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 (V4)
   🧠 MIPPEDIA DATA - SMART CONTEXT + AUTO THUMBNAIL (V5)
   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,
             Total Clean Empty State Engine (Bypass All Elements)
             Total Clean Empty State, Dynamic Noindex SEO,
            User-Group Based Edit Lock (Sysop Only Bypass)
   ========================================================= */
   ========================================================= */
(function() {
(function() {
Baris 72: Baris 73:
         }
         }


         // --- 🧠 1. PERBAIKAN TOTAL: FUNGSI EMPTY STATE SWITCHER SAPU BERSIH ---
         // --- 🧠 FUNGSI EMPTY STATE SWITCHER + USER LOCK + NOINDEX ENGINE ---
         function toggleMippediaLayout(isEmpty) {
         function toggleMippediaLayout(isEmpty) {
             var $mainContent = $('#mw-content-text');
             var $mainContent = $('#mw-content-text');
             var $existingNotice = $('#mip-empty-state-notice');
             var $existingNotice = $('#mip-empty-state-notice');
           
            // Ambil data grup pengguna saat ini (Bawaan MediaWiki)
            var userGroups = mw.config.get('wgUserGroups') || [];
            var isSysop = userGroups.indexOf('sysop') !== -1; // Cek apa dia pengurus
            // Target elemen tombol edit bawaan skin MediaWiki & ikon pensil kustom dari common.js lu
            var $editElements = $('#ca-edit, .mw-editsection, .wb-editsection, .mip-edit-trigger, [id*="edit"], [class*="edit-pencil"]');
            var $metaRobots = $('meta[name="robots"]');


             if (isEmpty) {
             if (isEmpty) {
                 // Buat kotak pemberitahuan terlebih dahulu jika belum ada
                 // 1. BUAT KOTAK PEMBERITAHUAN
                 if (!$existingNotice.length) {
                 if (!$existingNotice.length) {
                     var noticeHtml =  
                     var noticeHtml =  
Baris 88: Baris 97:
                             '</div>' +
                             '</div>' +
                         '</div>';
                         '</div>';
                   
                    // Tempelkan di bagian paling atas kontainer utama
                     $mainContent.prepend(noticeHtml);
                     $mainContent.prepend(noticeHtml);
                 }
                 }


                 // Sembunyikan TOTAL semua anak elemen langsung dari #mw-content-text KECUALI kotak notice kita
                 // 2. SEMBUNYIKAN ELEMEN INTERFACES
                // Ini akan mematikan infobox template, tabel, ataupun div kotak-kotak dari common.js lu
                 $mainContent.children().not('#mip-empty-state-notice').hide();
                 $mainContent.children().not('#mip-empty-state-notice').hide();
                 $descSection.hide();
                 $descSection.hide();
                // 3. SELEKSI KUNCI EDIT (Jika bukan pengurus/sysop, kunci tombol editnya total)
                if (!isSysop) {
                    $editElements.css({ 'pointer-events': 'none', 'opacity': '0.3', 'cursor': 'not-allowed' }).hide();
                    // Matikan shortcut tombol edit 'E' di keyboard biar ga bisa kecolongan lewat keyboard
                    $(document).on('keydown.miplock', function(e) {
                        if (e.key.toLowerCase() === 'e' && !$(e.target).is('input, textarea')) {
                            e.preventDefault();
                            return false;
                        }
                    });
                }
                // 4. DINAMIS NOINDEX UNTUK GOOGLE & MESIN PENCARI
                mw.config.set('wgRobotsPolicies', { 'index': 'noindex', 'follow': 'nofollow' });
                if ($metaRobots.length) {
                    $metaRobots.attr('content', 'noindex, nofollow');
                } else {
                    $('head').append('<meta name="robots" content="noindex, nofollow">');
                }
             } else {
             } else {
                 // Jika kondisi normal, hapus notice dan tampilkan kembali semua elemen anak tanpa pilih kasih
                 // --- KONDISI NORMAL (ARTIKEL AKTIF) ---
                 if ($existingNotice.length) $existingNotice.remove();
                 if ($existingNotice.length) $existingNotice.remove();
                 $mainContent.children().show();
                 $mainContent.children().show();
                 $descSection.show();
                 $descSection.show();
                // Kembalikan tombol edit normal seperti semula
                $editElements.css({ 'pointer-events': 'auto', 'opacity': '1', 'cursor': 'pointer' }).show();
                $(document).off('keydown.miplock');
                // Kembalikan hak indeks Google secara normal
                mw.config.set('wgRobotsPolicies', { 'index': 'index', 'follow': 'follow' });
                if ($metaRobots.length) {
                    $metaRobots.attr('content', 'index, follow');
                }
             }
             }
         }
         }