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 ( | 🧠 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, | ||
Total Clean Empty State Engine (Bypass All Elements) | |||
========================================================= */ | |||
(function() { | (function() { | ||
$(document).ready(function() { | $(document).ready(function() { | ||
| Baris 72: | Baris 72: | ||
} | } | ||
// --- 🧠 FUNGSI | // --- 🧠 1. PERBAIKAN TOTAL: FUNGSI EMPTY STATE SWITCHER SAPU BERSIH --- | ||
function toggleMippediaLayout(isEmpty) { | function toggleMippediaLayout(isEmpty) { | ||
var $mainContent = $('#mw-content-text'); | |||
var $ | |||
var $existingNotice = $('#mip-empty-state-notice'); | var $existingNotice = $('#mip-empty-state-notice'); | ||
if (isEmpty) { | if (isEmpty) { | ||
// | // Buat kotak pemberitahuan terlebih dahulu jika belum ada | ||
if (!$existingNotice.length) { | if (!$existingNotice.length) { | ||
var noticeHtml = | var noticeHtml = | ||
'<div id="mip-empty-state-notice" style="margin: | '<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>'; | ||
$ | |||
// 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 | // Jika kondisi normal, hapus notice dan tampilkan kembali semua elemen anak tanpa pilih kasih | ||
if ($existingNotice.length) $existingNotice.remove(); | if ($existingNotice.length) $existingNotice.remove(); | ||
$ | $mainContent.children().show(); | ||
$descSection.show(); | $descSection.show(); | ||
} | } | ||
| Baris 122: | Baris 124: | ||
} | } | ||
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) { | ||
if (index >= projects.length) { | if (index >= projects.length) { | ||
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); | toggleMippediaLayout(false); | ||
renderAll(p, c, t, o, img, customUrl, enTitle); | renderAll(p, c, t, o, img, customUrl, enTitle); | ||
} | } | ||