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 (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 ( | Targeted Isolation (Safe for Forms), Dynamic Noindex, | ||
Aesthetic Centered Empty State (Regex Hotfix Implemented) | |||
========================================================= */ | ========================================================= */ | ||
(function() { | (function() { | ||
| Baris 18: | Baris 18: | ||
currentYear = 2026; | currentYear = 2026; | ||
// --- KONFIGURASI PROYEK | // --- 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 | // --- 🎨 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 | // --- SMART LINKS PORTAL --- | ||
function buildSmartLinks(currentId, validatedEnTitle) { | function buildSmartLinks(currentId, validatedEnTitle) { | ||
$portalLinks.empty(); | $portalLinks.empty(); | ||
| Baris 73: | Baris 88: | ||
} | } | ||
// --- 🧠 | // --- 🧠 RENDER EMPTY STATE MINIMALIS --- | ||
function toggleMippediaLayout(isEmpty) { | function toggleMippediaLayout(isEmpty) { | ||
var $existingNotice = $('#mip-empty-state-notice'); | var $existingNotice = $('#mip-empty-state-notice'); | ||
var userGroups = mw.config.get('wgUserGroups') || []; | var userGroups = mw.config.get('wgUserGroups') || []; | ||
var isSysop = userGroups.indexOf('sysop') !== -1; | var isSysop = userGroups.indexOf('sysop') !== -1; | ||
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) { | ||
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=" | '<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: # | '<!-- Ikon Warning Besar Modern -->' + | ||
'<p style="color: # | '<div style="margin-bottom: 25px; display: inline-block;">' + | ||
'<div style="font-size: 0. | '<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: | ||
} | } | ||
$wikiDataElements.hide(); | $wikiDataElements.hide(); | ||
$descSection.hide(); | $descSection.hide(); | ||
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: | ||
} | } | ||
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 { | ||
if ($existingNotice.length) $existingNotice.remove(); | if ($existingNotice.length) $existingNotice.remove(); | ||
$wikiDataElements.show(); | $wikiDataElements.show(); | ||
$descSection.show(); | $descSection.show(); | ||
if (!isSysop) { | if (!isSysop) { | ||
$(document).off('keydown.miplock'); | $(document).off('keydown.miplock'); | ||
} | } | ||
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 | // --- 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: | ||
} | } | ||
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); | ||
$(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() { | ||