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 (V3)
   🧠 MIPPEDIA DATA - SMART CONTEXT + AUTO THUMBNAIL (V4)
   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,
             Auto-Hide Empty State Engine (Real-Time Switch)
             Total Clean Empty State Engine (Bypass All Elements)
   ========================================================== */
   ========================================================= */
(function() {
(function() {
     $(document).ready(function() {
     $(document).ready(function() {
Baris 72: Baris 72:
         }
         }


         // --- 🧠 FUNGSI PENGATUR SWITCH STATE (NORMAL VS EMPTY STATE) ---
         // --- 🧠 1. PERBAIKAN TOTAL: FUNGSI EMPTY STATE SWITCHER SAPU BERSIH ---
         function toggleMippediaLayout(isEmpty) {
         function toggleMippediaLayout(isEmpty) {
            // Kita targetkan elemen Infobox MediaWiki standar (.infobox) beserta seluruh tabel (.wikitable / table) di luar deskripsi utama
             var $mainContent = $('#mw-content-text');
             var $targetElements = $('.infobox, table, .mip-hide-target');
             var $existingNotice = $('#mip-empty-state-notice');
             var $existingNotice = $('#mip-empty-state-notice');


             if (isEmpty) {
             if (isEmpty) {
                 // Sembunyikan infobox dan semua tabel di atas/bawah infobox
                 // Buat kotak pemberitahuan terlebih dahulu jika belum ada
                $targetElements.hide();
                $descSection.hide();
 
                // Munculkan pesan peringatan kosong jika belum ada
                 if (!$existingNotice.length) {
                 if (!$existingNotice.length) {
                     var noticeHtml =  
                     var noticeHtml =  
                         '<div id="mip-empty-state-notice" style="margin: 20px 0; padding: 20px; border-left: 5px solid #d9534f; background-color: #fdf7f7; border-radius: 4px; font-family: sans-serif; line-height: 1.6;">' +
                         '<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;">' +
                             '<h4 style="color: #d9534f; margin-top: 0; margin-bottom: 8px; font-size: 1.15em; font-weight: bold;">⚠️ Item Data Tidak Memiliki Sumber Artikel</h4>' +
                             '<h4 style="color: #d9534f; margin-top: 0; margin-bottom: 8px; font-size: 1.15em; font-weight: bold;">⚠️ Item Data Tidak Memiliki Sumber Artikel</h4>' +
                             '<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>' +
                             '<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>' +
Baris 93: Baris 88:
                             '</div>' +
                             '</div>' +
                         '</div>';
                         '</div>';
                     $('#mw-content-text').prepend(noticeHtml);
                   
                    // Tempelkan di bagian paling atas kontainer utama
                     $mainContent.prepend(noticeHtml);
                 }
                 }
                // Sembunyikan TOTAL semua anak elemen langsung dari #mw-content-text KECUALI kotak notice kita
                // Ini akan mematikan infobox template, tabel, ataupun div kotak-kotak dari common.js lu
                $mainContent.children().not('#mip-empty-state-notice').hide();
                $descSection.hide();
             } else {
             } else {
                 // Jika normal / sudah ada artikel, pastikan notice hilang dan semua layout kembali normal
                 // Jika kondisi normal, hapus notice dan tampilkan kembali semua elemen anak tanpa pilih kasih
                 if ($existingNotice.length) $existingNotice.remove();
                 if ($existingNotice.length) $existingNotice.remove();
                 $targetElements.show();
                 $mainContent.children().show();
                 $descSection.show();
                 $descSection.show();
             }
             }
Baris 122: Baris 124:
                     }
                     }


                    // Jika cache mendeteksi keadaan kosong (isEmpty), kita tetap force run API untuk validasi real-time status barunya
                     if (cached.content && cached.ts === latestTS && latestTS !== "0" && !cached.isEmpty) {
                     if (cached.content && cached.ts === latestTS && latestTS !== "0" && !cached.isEmpty) {
                         toggleMippediaLayout(false);
                         toggleMippediaLayout(false);
Baris 141: Baris 142:
         // --- ANTRIAN PRIORITAS DENGAN VALIDASI INTERWIKI DARI ID & CONCISE ---
         // --- ANTRIAN PRIORITAS DENGAN VALIDASI INTERWIKI DARI ID & CONCISE ---
         function fetchPriorityData(index, newTS, img) {
         function fetchPriorityData(index, newTS, img) {
            // 🧠 KONDISI JIKA KETIGA SUMBER DI-CHECK DAN SEBELUMNYA GAK ADA ARTIKEL SAMA SEKALI
             if (index >= projects.length) {
             if (index >= projects.length) {
                // Simpan status kosong ke localstorage agar tidak membebani load berikutnya
                 localStorage.setItem(cacheKey, JSON.stringify({isEmpty: true, ts: newTS, content: ""}));
                 localStorage.setItem(cacheKey, JSON.stringify({isEmpty: true, ts: newTS, content: ""}));
                 toggleMippediaLayout(true);
                 toggleMippediaLayout(true);
Baris 207: Baris 206:
         function finalize(p, c, t, o, ts, img, customUrl, enTitle) {
         function finalize(p, c, t, o, ts, img, customUrl, enTitle) {
             localStorage.setItem(cacheKey, JSON.stringify({isEmpty: false, p:p, content:c, isTrans:t, orig:o, ts:ts, img:img, customUrl: customUrl, enTitle: enTitle}));
             localStorage.setItem(cacheKey, JSON.stringify({isEmpty: false, p:p, content:c, isTrans:t, orig:o, ts:ts, img:img, customUrl: customUrl, enTitle: enTitle}));
             toggleMippediaLayout(false); // Kembalikan layout ke normal
             toggleMippediaLayout(false);  
             renderAll(p, c, t, o, img, customUrl, enTitle);
             renderAll(p, c, t, o, img, customUrl, enTitle);
         }
         }