MediaWiki:Common.js: Perbedaan antara revisi
Tampilan
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 - ADVANCED STRUCTURED DATA SYSTEM (V8.0 ULTIMATE | * MIPPEDIA DATA - ADVANCED STRUCTURED DATA SYSTEM (V8.0 ULTIMATE) | ||
* Fitur: | * Fitur: Collapsible Ref, Verified Blue Ticks, Help Tooltips, | ||
* | * Edit Summary, Local Draft, CC0 Licensing, Lock Notifications | ||
* ==================================================================== | * ==================================================================== | ||
*/ | */ | ||
| Baris 15: | Baris 15: | ||
var pageName = mw.config.get('wgPageName'); | var pageName = mw.config.get('wgPageName'); | ||
var | var isSysop = mw.config.get('wgUserGroups').indexOf('sysop') !== -1; | ||
var dataItems = []; | var dataItems = []; | ||
var isLocked = false; | var isLocked = false; | ||
var api = new mw.Api(); | var api = new mw.Api(); | ||
var DRAFT_KEY = 'mippedia_draft_' + pageName; | |||
// 1. | // 1. DATA PLATFORM SOSIAL & MUSIK | ||
var SOCIAL_PLATFORMS = { | var SOCIAL_PLATFORMS = { | ||
applemusic: { name: 'Apple Music', base: 'https://music.apple.com/artist/', color: '#fc3c44', icon: '<svg width="13" height="13" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2zm3.32 12.383c-.328.232-.82.418-1.32.418-1.238 0-1.922-.828-1.922-2.191v-4.14l4.312-.868v1.398l-2.91.586v2.805c0 .734.336 1.148.977 1.148.336 0 .617-.094.863-.258v1.102z"/></svg>' }, | applemusic: { name: 'Apple Music', base: 'https://music.apple.com/artist/', color: '#fc3c44', icon: '<svg width="13" height="13" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2zm3.32 12.383c-.328.232-.82.418-1.32.418-1.238 0-1.922-.828-1.922-2.191v-4.14l4.312-.868v1.398l-2.91.586v2.805c0 .734.336 1.148.977 1.148.336 0 .617-.094.863-.258v1.102z"/></svg>' }, | ||
spotify: { name: 'Spotify', base: 'https://open.spotify.com/artist/', color: '#1db954', icon: '<svg width="13" height="13" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2zm4.586 14.424c-.18.295-.563.387-.857.207-2.35-1.434-5.308-1.758-8.793-.963-.335.077-.67-.133-.746-.468-.077-.334.132-.67.467-.745 3.816-.87 7.092-.493 9.72 1.112.294.18.386.563.209.857zm1.213-2.71c-.226.368-.703.483-1.07.258-2.688-1.652-6.785-2.13-9.965-1.164-.413.125-.85-.108-.975-.522-.125-.413.108-.85.522-.975 3.633-1.102 8.157-.568 11.23 1.332.368.226.483.703.258 1.071zm.14-2.827c-3.225-1.915-8.54-2.092-11.614-1.16-.503.153-1.037-.133-1.19-.636-.152-.503.133-1.037.636-1.19 3.532-1.072 9.404-.865 13.115 1.338.45.267.598.85.33 1.3-.267.45-.85.598-1.3.33z"/></svg>' }, | spotify: { name: 'Spotify', base: 'https://open.spotify.com/artist/', color: '#1db954', icon: '<svg width="13" height="13" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2zm4.586 14.424c-.18.295-.563.387-.857.207-2.35-1.434-5.308-1.758-8.793-.963-.335.077-.67-.133-.746-.468-.077-.334.132-.67.467-.745 3.816-.87 7.092-.493 9.72 1.112.294.18.386.563.209.857zm1.213-2.71c-.226.368-.703.483-1.07.258-2.688-1.652-6.785-2.13-9.965-1.164-.413.125-.85-.108-.975-.522-.125-.413.108-.85.522-.975 3.633-1.102 8.157-.568 11.23 1.332.368.226.483.703.258 1.071zm.14-2.827c-3.225-1.915-8.54-2.092-11.614-1.16-.503.153-1.037-.133-1.19-.636-.152-.503.133-1.037.636-1.19 3.532-1.072 9.404-.865 13.115 1.338.45.267.598.85.33 1.3-.267.45-.85.598-1.3.33z"/></svg>' }, | ||
instagram: { name: 'Instagram', base: 'https://instagram.com/', color: '#e1306c', icon: '<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="2" width="20" height="20" rx="5" ry="5"></rect><path d="M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z"></path | instagram: { name: 'Instagram', base: 'https://instagram.com/', color: '#e1306c', icon: '<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="2" width="20" height="20" rx="5" ry="5"></rect><path d="M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z"></path></svg>' }, | ||
tiktok: { name: 'TikTok', base: 'https://www.tiktok.com/@', color: '#000000', icon: '<svg width="13" height="13" viewBox="0 0 24 24" fill="currentColor"><path d="M19.59 6.69a4.83 4.83 0 0 1-3.77-4.25V2h-3.45v13.67a2.89 2.89 0 1 1-5.2-1.74 2.89 2.89 0 0 1 2.31-2.22V8.2a6.34 6.34 0 0 0-5 6.13 6.34 6.34 0 1 0 10.7-4.52A8.25 8.25 0 0 0 20 10.56V6.69z"/></svg>' }, | tiktok: { name: 'TikTok', base: 'https://www.tiktok.com/@', color: '#000000', icon: '<svg width="13" height="13" viewBox="0 0 24 24" fill="currentColor"><path d="M19.59 6.69a4.83 4.83 0 0 1-3.77-4.25V2h-3.45v13.67a2.89 2.89 0 1 1-5.2-1.74 2.89 2.89 0 0 1 2.31-2.22V8.2a6.34 6.34 0 0 0-5 6.13 6.34 6.34 0 1 0 10.7-4.52A8.25 8.25 0 0 0 20 10.56V6.69z"/></svg>' }, | ||
youtube: { name: 'YouTube', base: 'https://youtube.com/@', color: '#ff0000', icon: '<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M22.54 6.42a2.78 2.78 0 0 0-1.94-2C18.88 4 12 4 12 4s-6.88 0-8.6.46a2.78 2.78 0 0 0-1.94 2A29 29 0 0 0 1 11.75a29 29 0 0 0 .46 5.33A2.78 2.78 0 0 0 3.4 19c1.72.46 8.6.46 8.6.46s6.88 0 8.6-.46a2.78 2.78 0 0 0 1.94-2 29 29 0 0 0 .46-5.25 29 29 0 0 0-.46-5.33z"></path><polygon points="9.75 15.02 15.5 11.75 9.75 8.48 9.75 15.02"></polygon | youtube: { name: 'YouTube', base: 'https://youtube.com/@', color: '#ff0000', icon: '<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M22.54 6.42a2.78 2.78 0 0 0-1.94-2C18.88 4 12 4 12 4s-6.88 0-8.6.46a2.78 2.78 0 0 0-1.94 2A29 29 0 0 0 1 11.75a29 29 0 0 0 .46 5.33A2.78 2.78 0 0 0 3.4 19c1.72.46 8.6.46 8.6.46s6.88 0 8.6-.46a2.78 2.78 0 0 0 1.94-2 29 29 0 0 0 .46-5.25 29 29 0 0 0-.46-5.33z"></path><polygon points="9.75 15.02 15.5 11.75 9.75 8.48 9.75 15.02"></polygon></svg>' } | ||
}; | }; | ||
var PRESET_LABELS = [ | // 2. DOMAIN TERVERIFIKASI | ||
var VERIFIED_DOMAINS = [ | |||
var svgEdit = '<svg | 'kompas.com', 'kompas.id', 'detik.com', 'cnnindonesia.com', 'tribunnews.com', 'kumparan.com', 'tirto.id', | ||
var svgLock = '<svg | 'youtube.com', 'spotify.com', 'apple.com', 'musicbrainz.org', 'billboard.com', 'rollingstone.com', | ||
var svgRef = '<svg | 'bbc.com', 'nytimes.com', 'instagram.com', 'x.com', 'twitter.com', 'facebook.com', 'wikipedia.org' | ||
var | ]; | ||
var svgHelp = '<svg width=" | var PRESET_LABELS = ["Nama Lahir", "Tanggal Lahir", "Tempat Lahir", "Pekerjaan", "Kebangsaan", "Genre", "Situs Web Resmi"]; | ||
var REF_TYPES = { | |||
"Berita": ["Berita Online", "Berita Cetak", "Wawancara"], | |||
"Website": ["Situs Resmi", "Portal", "Database Web"], | |||
"Database Musik": ["MusicBrainz", "Discogs", "Spotify", "Apple Music"], | |||
"Video & Audio": ["YouTube", "Podcast", "Dokumenter"] | |||
}; | |||
// 3. IKON | |||
var svgEdit = '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path></svg>'; | |||
var svgLock = '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg>'; | |||
var svgRef = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>'; | |||
var svgVerified = '<svg width="16" height="16" viewBox="0 0 24 24" fill="#3b82f6" stroke="#ffffff" stroke-width="2"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path><polyline points="22 4 12 14.01 9 11.01"></polyline></svg>'; | |||
var svgHelp = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"></path><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>'; | |||
// | // 4. HELPER | ||
function | function isVerifiedSite(urlStr) { | ||
if (!urlStr) return false; | if(!urlStr) return false; | ||
var domain = extractDomain(urlStr); | |||
return VERIFIED_DOMAINS.some(function(vd) { return domain === vd || domain.endsWith('.' + vd); }); | |||
} | } | ||
function extractDomain(urlStr) { | function extractDomain(urlStr) { | ||
try { return new URL(urlStr. | try { return new URL(urlStr.startsWith('http') ? urlStr : 'https://' + urlStr).hostname.replace(/^www\./, ''); } | ||
catch(e) { return urlStr; } | |||
} | } | ||
function ensureHttps(u) { return (u && !u.match(/^https?:\/\//i)) ? 'https://' + u : u; } | |||
// | // 5. STYLESHEET | ||
var css = ` | var css = ` | ||
#mippedia-data-app { background: #fff; border-radius: 16px; box-shadow: 0 4px 24px rgba(0,0,0,0.06); padding: 20px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; border: 1px solid #e2e8f0; margin-top:20px; } | |||
.md-header { display: flex; flex-wrap: wrap; justify-content: space-between; border-bottom: 1px solid #f1f5f9; padding-bottom: 14px; margin-bottom: 16px; gap: 10px; } | |||
.md-btn-icon { background: #f8fafc; border: 1px solid #cbd5e1; cursor: pointer; color: #4f46e5; padding: 8px 14px; border-radius: 8px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; transition:0.2s; } | |||
.md-btn-icon:hover { background: #f1f5f9; border-color: #94a3b8; } | |||
#mippedia-data-app { background: | .md-row-display { display: flex; justify-content: space-between; padding: 16px 12px; background: #fff; border-radius: 12px; border-bottom: 1px solid #f1f5f9; gap: 12px; } | ||
.md-header { display: flex; justify-content: space-between | |||
.md-btn-icon { background: | |||
.md-btn-icon:hover { | |||
/* | /* Akordeon Referensi Modern */ | ||
.md-ref- | .md-ref-wrap { margin-top: 10px; } | ||
.md-ref- | .md-ref-details { background: #f8fafc; border-left: 3px solid #4f46e5; border-radius: 8px; overflow: hidden; border-top:1px solid #f1f5f9; border-right:1px solid #f1f5f9; border-bottom:1px solid #f1f5f9; transition: 0.3s; } | ||
.md-ref-summary | .md-ref-details summary { display: flex; align-items: center; padding: 10px 14px; font-size: 0.85rem; font-weight: 700; color: #374151; cursor: pointer; user-select: none; list-style: none; gap: 8px; } | ||
.md-ref-details summary::-webkit-details-marker { display: none; } | |||
.md-ref-details[open] summary { border-bottom: 1px dashed #cbd5e1; background: #e0e7ff; color: #3730a3; } | |||
.md-ref-body { padding: 12px 14px; font-size: 0.85rem; display: flex; flex-direction: column; gap: 6px; } | |||
.md-btn-visit { background: #4f46e5; color: #fff; padding: 6px 12px; border-radius: 6px; text-decoration: none; font-size: 0.8rem; display: inline-block; width: fit-content; margin-top: 6px; font-weight:600; } | |||
.md-ref- | |||
.md-ref- | |||
.md- | |||
.md- | |||
.md- | .md-verified-badge { cursor: pointer; display: inline-flex; align-items: center; justify-content: center; margin-left: 5px; vertical-align: text-top; transition: transform 0.2s; } | ||
.md-verified-badge:hover { transform: scale(1.1); } | |||
.md- | |||
/* | /* Form & Notices */ | ||
.md-form-box { background: | .md-form-box { background: #fff; border: 1px solid #cbd5e1; padding: 18px; border-radius: 12px; margin-top: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.05); position:relative; } | ||
.md-input { width: 100%; padding: | .md-input, .md-select { width: 100%; padding: 9px 12px; border: 1px solid #cbd5e1; border-radius: 8px; box-sizing: border-box; } | ||
.md- | .md-cc0-notice { background: #fef2f2; color: #991b1b; padding: 12px; border-radius: 8px; font-size: 0.8rem; line-height: 1.4; border-left: 4px solid #ef4444; margin-bottom: 15px; } | ||
.md-edit-meta { background: #f8fafc; padding: 12px; border-radius: 8px; margin-bottom: 15px; border: 1px solid #e2e8f0; display:flex; flex-direction:column; gap:10px; } | |||
.md-btn { padding: 10px 18px; border: none; border-radius: 8px; font-weight: 700; cursor: pointer; color: white; display: inline-flex; align-items: center; gap: 6px; flex:1; justify-content:center; } | |||
.md-btn-save { background: #4f46e5; } .md-btn-cancel { background: #64748b; } .md-btn-draft { background: #10b981; } | |||
.md- | /* Modal & Tooltips */ | ||
@ | .md-modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 9999; display: flex; align-items: center; justify-content: center; } | ||
.md-modal-box { background: #fff; padding: 24px; border-radius: 12px; max-width: 400px; text-align: center; box-shadow: 0 10px 25px rgba(0,0,0,0.2); animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); } | |||
@keyframes popIn { 0% { transform: scale(0.8); opacity: 0; } 100% { transform: scale(1); opacity: 1; } } | |||
.md-help-icon { color: #64748b; cursor: pointer; margin-left: 6px; } | |||
.md- | .md-help-icon:hover { color: #4f46e5; } | ||
.md-tooltip-popup { position: absolute; background: #1e293b; color: #fff; padding: 10px; border-radius: 8px; font-size: 0.8rem; width: 220px; z-index: 1000; box-shadow: 0 4px 15px rgba(0,0,0,0.1); display: none; line-height: 1.4; text-align: left; } | |||
.md-tooltip-popup::after { content: ''; position: absolute; border-width: 6px; border-style: solid; border-color: #1e293b transparent transparent transparent; top: 100%; left: 15px; } | |||
@media (max-width: 600px) { .md-header { flex-direction: column; align-items: stretch; } .md-form-actions { flex-direction: column; } .md-btn { margin-bottom: 8px; } } | |||
.md-native-render { display: none; } | |||
`; | `; | ||
$('<style>').text(css).appendTo('head'); | $('<style>').text(css).appendTo('head'); | ||
// | // 6. POPUP & MODAL | ||
function showModal(title, text) { | |||
$('.md-modal-overlay').remove(); | |||
var $overlay = $('<div class="md-modal-overlay"></div>'); | |||
var $box = $('<div class="md-modal-box"><h3>' + title + '</h3><p style="font-size:0.9rem; color:#475569; margin:15px 0;">' + text + '</p><button class="md-btn md-btn-save" style="width:100%;">Tutup Mengerti</button></div>'); | |||
$box.find('button').on('click', function() { $overlay.remove(); }); | |||
$overlay.append($box); | |||
$('body').append($overlay); | |||
} | |||
function initTooltips() { | |||
$('.md-help-icon').on('click', function(e) { | |||
$('.md-tooltip-popup').remove(); | |||
e.stopPropagation(); | |||
var $icon = $(this); | |||
var text = $icon.data('help'); | |||
var $tt = $('<div class="md-tooltip-popup">' + text + '</div>'); | |||
$('body').append($tt); | |||
var offset = $icon.offset(); | |||
$tt.css({ top: offset.top - $tt.outerHeight() - 8, left: offset.left - 15 }).fadeIn(200); | |||
}); | |||
$(document).on('click', function() { $('.md-tooltip-popup').fadeOut(200, function(){ $(this).remove(); }); }); | |||
} | |||
// 7. CORE LOGIC | |||
function loadData() { | function loadData() { | ||
return api.get({ action: 'query', prop: 'revisions', titles: pageName, rvprop: 'content', rvslots: 'main', formatversion: 2 }).then(function(data) { | return api.get({ action: 'query', prop: 'revisions', titles: pageName, rvprop: 'content', rvslots: 'main', formatversion: 2 }).then(function(data) { | ||
| Baris 126: | Baris 141: | ||
} | } | ||
function saveData(actionType, $btnEl, originalContent, editSummary, isMinor) { | |||
function saveData(actionType, originalContent) { | if ($btnEl) $btnEl.prop('disabled', true).text('Menyimpan...'); | ||
var summaryTxt = editSummary ? 'Mippedia Data V8: ' + editSummary : 'Mippedia Data V8: ' + actionType; | |||
var jsonStr = JSON.stringify({ locked: isLocked, items: dataItems }); | var jsonStr = JSON.stringify({ locked: isLocked, items: dataItems }); | ||
var wt = "<!-- MIPPEDIA_DATA_START | " + jsonStr + " -->\n<div class=\"md-native-render | var wt = "<!-- MIPPEDIA_DATA_START | " + jsonStr + " -->\n<div class=\"md-native-render\">{| class=\"wikitable\"\n! Data !! Nilai !! Referensi\n"; | ||
dataItems.forEach(function(item) { wt += "|-\n| " + item.prop + " || " + item.val + "\n"; }); | dataItems.forEach(function(item) { wt += "|-\n| " + item.prop + " || " + item.val + " || " + (item.ref ? item.ref.title : '') + "\n"; }); | ||
wt += "|}\n</div>\n<!-- MIPPEDIA_DATA_END -->"; | wt += "|}\n</div>\n<!-- MIPPEDIA_DATA_END -->"; | ||
| Baris 136: | Baris 152: | ||
if(newContent === originalContent) newContent = originalContent.trim() + "\n\n" + wt; | if(newContent === originalContent) newContent = originalContent.trim() + "\n\n" + wt; | ||
api.postWithToken('csrf', { action: 'edit', title: pageName, text: newContent, summary: | api.postWithToken('csrf', { action: 'edit', title: pageName, text: newContent, summary: summaryTxt, minor: isMinor }).done(function() { | ||
localStorage.removeItem( | localStorage.removeItem(DRAFT_KEY); | ||
location.href = location.pathname + "?refresh=" + Date. | location.href = location.pathname + "?refresh=" + new Date().getTime(); | ||
}); | }).fail(function(err) { alert("Gagal: " + err); if($btnEl) $btnEl.prop('disabled', false); }); | ||
} | } | ||
// | // 8. BUILD UI | ||
function buildUI(rawContent) { | function buildUI(rawContent) { | ||
var $app = $('<div id="mippedia-data-app"></div>'); | var $app = $('<div id="mippedia-data-app"></div>'); | ||
var $header = $('<div class="md-header"><h3 | var $header = $('<div class="md-header"><h3 style="margin:0; font-weight:800; color:#0f172a;">' + svgEdit + ' Data Terstruktur</h3><div class="md-actions"></div></div>'); | ||
var $ | |||
if (isSysop) { | |||
var $lockBtn = $('<button class="md-btn-icon" style="color:' + (isLocked ? '#dc2626' : '#4f46e5') + '">' + svgLock + (isLocked ? ' Buka Kunci' : ' Kunci Halaman') + '</button>'); | |||
$lockBtn.on('click', function() { isLocked = !isLocked; saveData(isLocked ? 'Mengunci data' : 'Membuka kunci', $(this), rawContent); }); | |||
$header.find('.md-actions').append($lockBtn); | |||
} | |||
if (!isLocked || isSysop) { | if (!isLocked || isSysop) { | ||
var $addBtn = $('<button class="md-btn-icon | var $addBtn = $('<button class="md-btn-icon">' + svgEdit + ' Tambah</button>'); | ||
$addBtn.on('click', function() { showForm(-1, rawContent); }); | $addBtn.on('click', function() { showForm(-1, rawContent); }); | ||
$ | $header.find('.md-actions').append($addBtn); | ||
} | } | ||
$app.append($header); | $app.append($header); | ||
dataItems.forEach(function(item, index) { | dataItems.forEach(function(item, index) { | ||
var $row = $('<div class="md-row-display | var $row = $('<div class="md-row-display"></div>'); | ||
var $info = $('<div style="flex:1;"></div>'); | var $info = $('<div style="flex:1;"></div>'); | ||
$info.append('<span style="font-size:0.72rem; color:#64748b; font-weight:800; text-transform:uppercase;">' + item.prop + '</span>'); | |||
$info.append('<span | $info.append('<div style="font-size:1.05rem; font-weight:700; color:#0f172a; margin-top:4px;">' + item.val + '</div>'); | ||
$info.append('<span class="md- | |||
if (item.ref && (item.ref.url || item.ref.title)) { | |||
var isVer = isVerifiedSite(item.ref.url); | |||
var verHtml = isVer ? '<span class="md-verified-badge" title="Situs Populer Terverifikasi">' + svgVerified + '</span>' : ''; | |||
var $refHTML = $(` | |||
<div class="md-ref-wrap"> | |||
<details class="md-ref-details"> | |||
<summary>${svgRef} ${item.ref.title || 'Referensi'} ${verHtml}</summary> | |||
<div class="md-ref-body"> | |||
${item.ref.author ? '<div><b>Penulis:</b> ' + item.ref.author + '</div>' : ''} | |||
${item.ref.site ? '<div><b>Situs:</b> ' + item.ref.site + '</div>' : ''} | |||
${item.ref.url ? '<a href="' + ensureHttps(item.ref.url) + '" target="_blank" class="md-btn-visit">Kunjungi Referensi</a>' : ''} | |||
</div> | |||
</details> | |||
</div> | |||
`); | |||
$refHTML.find('.md-verified-badge').on('click', function(e) { | |||
e.preventDefault(); e.stopPropagation(); | |||
showModal('Situs Terverifikasi', 'Centang biru menandakan bahwa referensi berasal dari situs web besar, portal populer, atau pangkalan data resmi yang memiliki reputasi tinggi dan kredibel untuk digunakan sebagai rujukan utama.'); | |||
}); | }); | ||
$info.append($ | $info.append($refHTML); | ||
} | } | ||
$row.append($info); | |||
if (isLocked && !isSysop) { | |||
if ( | var $lockedIcon = $('<button class="md-btn-icon" style="color:#dc2626; border-color:#fca5a5; background:#fef2f2;">' + svgLock + ' Terkunci</button>'); | ||
$lockedIcon.on('click', function() { | |||
var $ | showModal('Akses Ditolak (Dikunci)', 'Halaman Data Terstruktur ini sedang dikunci oleh Pengurus (Sysop). Pengguna biasa atau anonim tidak dapat melakukan penyuntingan untuk sementara waktu demi mencegah vandalisme. Silakan hubungi pengurus jika ada pembaruan data yang sangat penting.'); | ||
}); | |||
$row.append($lockedIcon); | |||
} else { | |||
var $editIcon = $('<button class="md-btn-icon">Edit</button>'); | |||
$editIcon.on('click', function() { showForm(index, rawContent); }); | |||
$row.append($editIcon); | |||
var $ | |||
$ | |||
$row.append($ | |||
} | } | ||
$app.append($row); | $app.append($row); | ||
| Baris 233: | Baris 222: | ||
$app.append('<div id="md-form-container"></div>'); | $app.append('<div id="md-form-container"></div>'); | ||
$('. | $('.md-native-render').hide(); | ||
var $infobox = $('.infobox').first(); | |||
if ($infobox.length) $app.insertAfter($infobox); else $('#mw-content-text .mw-parser-output').append($app); | |||
} | } | ||
// | // 9. FORM & DRAFT LOGIC | ||
function showForm(index, rawContent) { | function showForm(index, rawContent) { | ||
var $ | var $container = $('#md-form-container').empty(); | ||
var | var isNew = index === -1; | ||
if ( | // Cek Draft Lokal | ||
var draftData = localStorage.getItem(DRAFT_KEY); | |||
var currentData = isNew ? { prop:'', val:'', ref:{} } : dataItems[index]; | |||
if (isNew && draftData && confirm("Ditemukan draft yang belum tersimpan sebelumnya. Ingin memuat draft ini?")) { | |||
try { currentData = JSON.parse(draftData); } catch(e) {} | |||
} | |||
var $form = $('<div class="md-form-box"></div>'); | var $form = $('<div class="md-form-box"></div>'); | ||
$form.append('<h4 style="margin:0 0 16px 0; border-bottom:2px solid #e2e8f0; padding-bottom:8px;">' + (isNew ? 'Tambah Data' : 'Edit Data') + '</h4>'); | |||
// | $form.append(` | ||
<div style="margin-bottom:14px;"> | |||
<label style="font-size:0.85rem; font-weight:700;">Label Data <span class="md-help-icon" data-help="Nama bidang data (contoh: Pekerjaan, Sutradara, Tanggal Lahir). Gunakan bahasa yang baku.">${svgHelp}</span></label> | |||
<input type="text" id="md-inp-prop" class="md-input" value="${currentData.prop}"> | |||
</div> | |||
<div style="margin-bottom:14px;"> | |||
<label style="font-size:0.85rem; font-weight:700;">Nilai Data <span class="md-help-icon" data-help="Isi dari data tersebut (contoh: Penyanyi, 15 April 2003).">${svgHelp}</span></label> | |||
<input type="text" id="md-inp-val" class="md-input" value="${currentData.val}"> | |||
</div> | |||
<div style="background:#f8fafc; padding:12px; border-radius:8px; border:1px solid #cbd5e1; margin-bottom:14px;"> | |||
<label style="font-size:0.9rem; font-weight:800; display:block; margin-bottom:8px;">Referensi & Rujukan <span class="md-help-icon" data-help="Masukkan sumber dari mana data ini didapatkan. Jika URL dari situs terkenal, otomatis akan mendapat centang biru.">${svgHelp}</span></label> | |||
<input type="text" id="md-ref-title" class="md-input" placeholder="Judul Referensi" value="${currentData.ref ? (currentData.ref.title||'') : ''}" style="margin-bottom:8px;"> | |||
<input type="url" id="md-ref-url" class="md-input" placeholder="URL Situs (https://...)" value="${currentData.ref ? (currentData.ref.url||'') : ''}" style="margin-bottom:8px;"> | |||
<input type="text" id="md-ref-site" class="md-input" placeholder="Nama Situs / Pangkalan Data" value="${currentData.ref ? (currentData.ref.site||'') : ''}"> | |||
</div> | |||
`); | |||
// Kotak CC0 & Edit Summary | |||
$form.append(` | |||
<div class="md-cc0-notice"> | |||
<b>Perhatian:</b> Setiap data yang Anda terbitkan akan terlihat secara publik dan dirilis di bawah lisensi <b>Creative Commons Zero (CC0)</b>. Jika Anda tidak ingin suntingan Anda digunakan secara bebas dan publik, jangan terbitkan di sini. <span class="md-help-icon" data-help="Lisensi CC0 berarti data ini menjadi domain publik murni dan bisa digunakan oleh siapa saja tanpa batasan.">${svgHelp}</span> | |||
</div> | |||
<div class="md-edit-meta"> | |||
<input type="text" id="md-edit-summary" class="md-input" placeholder="Jelaskan perubahan Anda secara singkat (Opsional)..."> | |||
<label style="font-size:0.85rem; cursor:pointer;"><input type="checkbox" id="md-minor-edit"> Ini adalah suntingan kecil (minor)</label> | |||
</div> | |||
`); | |||
var $actions = $('<div style="display:flex; gap:10px; flex-wrap:wrap;"></div>'); | |||
var $btnSave = $('<button class="md-btn md-btn-save">Terbitkan</button>'); | |||
$ | var $btnDraft = $('<button class="md-btn md-btn-draft">Simpan Draft</button>'); | ||
var $btnCancel = $('<button class="md-btn md-btn-cancel">Batal</button>'); | |||
$actions.append($btnSave, $btnDraft, $btnCancel); | |||
$form.append( | $form.append($actions); | ||
$container.append($form); | |||
initTooltips(); | |||
$('html, body').animate({ scrollTop: $form.offset().top - 30 }, 250); | |||
$ | $btnCancel.on('click', function() { $container.empty(); }); | ||
var | $btnDraft.on('click', function() { | ||
var draftObj = { | |||
prop: $('#md-inp-prop').val(), val: $('#md-inp-val').val(), | |||
ref: { title: $('#md-ref-title').val(), url: $('#md-ref-url').val(), site: $('#md-ref-site').val() } | |||
}; | |||
localStorage.setItem(DRAFT_KEY, JSON.stringify(draftObj)); | |||
alert("Draft berhasil disimpan ke peramban Anda!"); | |||
}); | |||
$btnSave.on('click', function() { | $btnSave.on('click', function() { | ||
if (!$('#md-inp-prop').val() || !$('#md-inp-val').val()) return alert("Label dan Nilai wajib diisi!"); | |||
var refUrl = $('#md-ref-url').val(); | |||
var newItem = { | var newItem = { | ||
prop: $('#inp-prop').val(), val: $('#inp-val').val(), | prop: $('#md-inp-prop').val(), val: $('#md-inp-val').val(), | ||
ref: ($('#md-ref-title').val() || refUrl) ? { title: $('#md-ref-title').val(), url: ensureHttps(refUrl), site: $('#md-ref-site').val() } : null | |||
}; | }; | ||
if (isNew) dataItems.push(newItem); else dataItems[index] = newItem; | |||
saveData(isNew ? 'Tambah data' : 'Edit data', $(this), rawContent, $('#md-edit-summary').val(), $('#md-minor-edit').is(':checked')); | |||
}); | }); | ||
} | } | ||
loadData().then(function(rawContent) { buildUI(rawContent); }); | loadData().then(function(rawContent) { buildUI(rawContent); }); | ||
}); | }); | ||
})(jQuery, mediaWiki); | })(jQuery, mediaWiki); | ||
Revisi per 18 Agustus 2026 02.51
/**
* ====================================================================
* MIPPEDIA DATA - ADVANCED STRUCTURED DATA SYSTEM (V8.0 ULTIMATE)
* Fitur: Collapsible Ref, Verified Blue Ticks, Help Tooltips,
* Edit Summary, Local Draft, CC0 Licensing, Lock Notifications
* ====================================================================
*/
(function($, mw) {
'use strict';
if (mw.config.get('wgNamespaceNumber') !== 0 || mw.config.get('wgIsMainPage')) return;
if (mw.config.get('wgAction') !== 'view') return;
mw.loader.using(['mediawiki.api', 'mediawiki.util']).then(function() {
var pageName = mw.config.get('wgPageName');
var isSysop = mw.config.get('wgUserGroups').indexOf('sysop') !== -1;
var dataItems = [];
var isLocked = false;
var api = new mw.Api();
var DRAFT_KEY = 'mippedia_draft_' + pageName;
// 1. DATA PLATFORM SOSIAL & MUSIK
var SOCIAL_PLATFORMS = {
applemusic: { name: 'Apple Music', base: 'https://music.apple.com/artist/', color: '#fc3c44', icon: '<svg width="13" height="13" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2zm3.32 12.383c-.328.232-.82.418-1.32.418-1.238 0-1.922-.828-1.922-2.191v-4.14l4.312-.868v1.398l-2.91.586v2.805c0 .734.336 1.148.977 1.148.336 0 .617-.094.863-.258v1.102z"/></svg>' },
spotify: { name: 'Spotify', base: 'https://open.spotify.com/artist/', color: '#1db954', icon: '<svg width="13" height="13" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2zm4.586 14.424c-.18.295-.563.387-.857.207-2.35-1.434-5.308-1.758-8.793-.963-.335.077-.67-.133-.746-.468-.077-.334.132-.67.467-.745 3.816-.87 7.092-.493 9.72 1.112.294.18.386.563.209.857zm1.213-2.71c-.226.368-.703.483-1.07.258-2.688-1.652-6.785-2.13-9.965-1.164-.413.125-.85-.108-.975-.522-.125-.413.108-.85.522-.975 3.633-1.102 8.157-.568 11.23 1.332.368.226.483.703.258 1.071zm.14-2.827c-3.225-1.915-8.54-2.092-11.614-1.16-.503.153-1.037-.133-1.19-.636-.152-.503.133-1.037.636-1.19 3.532-1.072 9.404-.865 13.115 1.338.45.267.598.85.33 1.3-.267.45-.85.598-1.3.33z"/></svg>' },
instagram: { name: 'Instagram', base: 'https://instagram.com/', color: '#e1306c', icon: '<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="2" width="20" height="20" rx="5" ry="5"></rect><path d="M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z"></path></svg>' },
tiktok: { name: 'TikTok', base: 'https://www.tiktok.com/@', color: '#000000', icon: '<svg width="13" height="13" viewBox="0 0 24 24" fill="currentColor"><path d="M19.59 6.69a4.83 4.83 0 0 1-3.77-4.25V2h-3.45v13.67a2.89 2.89 0 1 1-5.2-1.74 2.89 2.89 0 0 1 2.31-2.22V8.2a6.34 6.34 0 0 0-5 6.13 6.34 6.34 0 1 0 10.7-4.52A8.25 8.25 0 0 0 20 10.56V6.69z"/></svg>' },
youtube: { name: 'YouTube', base: 'https://youtube.com/@', color: '#ff0000', icon: '<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M22.54 6.42a2.78 2.78 0 0 0-1.94-2C18.88 4 12 4 12 4s-6.88 0-8.6.46a2.78 2.78 0 0 0-1.94 2A29 29 0 0 0 1 11.75a29 29 0 0 0 .46 5.33A2.78 2.78 0 0 0 3.4 19c1.72.46 8.6.46 8.6.46s6.88 0 8.6-.46a2.78 2.78 0 0 0 1.94-2 29 29 0 0 0 .46-5.25 29 29 0 0 0-.46-5.33z"></path><polygon points="9.75 15.02 15.5 11.75 9.75 8.48 9.75 15.02"></polygon></svg>' }
};
// 2. DOMAIN TERVERIFIKASI
var VERIFIED_DOMAINS = [
'kompas.com', 'kompas.id', 'detik.com', 'cnnindonesia.com', 'tribunnews.com', 'kumparan.com', 'tirto.id',
'youtube.com', 'spotify.com', 'apple.com', 'musicbrainz.org', 'billboard.com', 'rollingstone.com',
'bbc.com', 'nytimes.com', 'instagram.com', 'x.com', 'twitter.com', 'facebook.com', 'wikipedia.org'
];
var PRESET_LABELS = ["Nama Lahir", "Tanggal Lahir", "Tempat Lahir", "Pekerjaan", "Kebangsaan", "Genre", "Situs Web Resmi"];
var REF_TYPES = {
"Berita": ["Berita Online", "Berita Cetak", "Wawancara"],
"Website": ["Situs Resmi", "Portal", "Database Web"],
"Database Musik": ["MusicBrainz", "Discogs", "Spotify", "Apple Music"],
"Video & Audio": ["YouTube", "Podcast", "Dokumenter"]
};
// 3. IKON
var svgEdit = '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path></svg>';
var svgLock = '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg>';
var svgRef = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>';
var svgVerified = '<svg width="16" height="16" viewBox="0 0 24 24" fill="#3b82f6" stroke="#ffffff" stroke-width="2"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path><polyline points="22 4 12 14.01 9 11.01"></polyline></svg>';
var svgHelp = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"></path><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>';
// 4. HELPER
function isVerifiedSite(urlStr) {
if(!urlStr) return false;
var domain = extractDomain(urlStr);
return VERIFIED_DOMAINS.some(function(vd) { return domain === vd || domain.endsWith('.' + vd); });
}
function extractDomain(urlStr) {
try { return new URL(urlStr.startsWith('http') ? urlStr : 'https://' + urlStr).hostname.replace(/^www\./, ''); }
catch(e) { return urlStr; }
}
function ensureHttps(u) { return (u && !u.match(/^https?:\/\//i)) ? 'https://' + u : u; }
// 5. STYLESHEET
var css = `
#mippedia-data-app { background: #fff; border-radius: 16px; box-shadow: 0 4px 24px rgba(0,0,0,0.06); padding: 20px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; border: 1px solid #e2e8f0; margin-top:20px; }
.md-header { display: flex; flex-wrap: wrap; justify-content: space-between; border-bottom: 1px solid #f1f5f9; padding-bottom: 14px; margin-bottom: 16px; gap: 10px; }
.md-btn-icon { background: #f8fafc; border: 1px solid #cbd5e1; cursor: pointer; color: #4f46e5; padding: 8px 14px; border-radius: 8px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; transition:0.2s; }
.md-btn-icon:hover { background: #f1f5f9; border-color: #94a3b8; }
.md-row-display { display: flex; justify-content: space-between; padding: 16px 12px; background: #fff; border-radius: 12px; border-bottom: 1px solid #f1f5f9; gap: 12px; }
/* Akordeon Referensi Modern */
.md-ref-wrap { margin-top: 10px; }
.md-ref-details { background: #f8fafc; border-left: 3px solid #4f46e5; border-radius: 8px; overflow: hidden; border-top:1px solid #f1f5f9; border-right:1px solid #f1f5f9; border-bottom:1px solid #f1f5f9; transition: 0.3s; }
.md-ref-details summary { display: flex; align-items: center; padding: 10px 14px; font-size: 0.85rem; font-weight: 700; color: #374151; cursor: pointer; user-select: none; list-style: none; gap: 8px; }
.md-ref-details summary::-webkit-details-marker { display: none; }
.md-ref-details[open] summary { border-bottom: 1px dashed #cbd5e1; background: #e0e7ff; color: #3730a3; }
.md-ref-body { padding: 12px 14px; font-size: 0.85rem; display: flex; flex-direction: column; gap: 6px; }
.md-btn-visit { background: #4f46e5; color: #fff; padding: 6px 12px; border-radius: 6px; text-decoration: none; font-size: 0.8rem; display: inline-block; width: fit-content; margin-top: 6px; font-weight:600; }
.md-verified-badge { cursor: pointer; display: inline-flex; align-items: center; justify-content: center; margin-left: 5px; vertical-align: text-top; transition: transform 0.2s; }
.md-verified-badge:hover { transform: scale(1.1); }
/* Form & Notices */
.md-form-box { background: #fff; border: 1px solid #cbd5e1; padding: 18px; border-radius: 12px; margin-top: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.05); position:relative; }
.md-input, .md-select { width: 100%; padding: 9px 12px; border: 1px solid #cbd5e1; border-radius: 8px; box-sizing: border-box; }
.md-cc0-notice { background: #fef2f2; color: #991b1b; padding: 12px; border-radius: 8px; font-size: 0.8rem; line-height: 1.4; border-left: 4px solid #ef4444; margin-bottom: 15px; }
.md-edit-meta { background: #f8fafc; padding: 12px; border-radius: 8px; margin-bottom: 15px; border: 1px solid #e2e8f0; display:flex; flex-direction:column; gap:10px; }
.md-btn { padding: 10px 18px; border: none; border-radius: 8px; font-weight: 700; cursor: pointer; color: white; display: inline-flex; align-items: center; gap: 6px; flex:1; justify-content:center; }
.md-btn-save { background: #4f46e5; } .md-btn-cancel { background: #64748b; } .md-btn-draft { background: #10b981; }
/* Modal & Tooltips */
.md-modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 9999; display: flex; align-items: center; justify-content: center; }
.md-modal-box { background: #fff; padding: 24px; border-radius: 12px; max-width: 400px; text-align: center; box-shadow: 0 10px 25px rgba(0,0,0,0.2); animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes popIn { 0% { transform: scale(0.8); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.md-help-icon { color: #64748b; cursor: pointer; margin-left: 6px; }
.md-help-icon:hover { color: #4f46e5; }
.md-tooltip-popup { position: absolute; background: #1e293b; color: #fff; padding: 10px; border-radius: 8px; font-size: 0.8rem; width: 220px; z-index: 1000; box-shadow: 0 4px 15px rgba(0,0,0,0.1); display: none; line-height: 1.4; text-align: left; }
.md-tooltip-popup::after { content: ''; position: absolute; border-width: 6px; border-style: solid; border-color: #1e293b transparent transparent transparent; top: 100%; left: 15px; }
@media (max-width: 600px) { .md-header { flex-direction: column; align-items: stretch; } .md-form-actions { flex-direction: column; } .md-btn { margin-bottom: 8px; } }
.md-native-render { display: none; }
`;
$('<style>').text(css).appendTo('head');
// 6. POPUP & MODAL
function showModal(title, text) {
$('.md-modal-overlay').remove();
var $overlay = $('<div class="md-modal-overlay"></div>');
var $box = $('<div class="md-modal-box"><h3>' + title + '</h3><p style="font-size:0.9rem; color:#475569; margin:15px 0;">' + text + '</p><button class="md-btn md-btn-save" style="width:100%;">Tutup Mengerti</button></div>');
$box.find('button').on('click', function() { $overlay.remove(); });
$overlay.append($box);
$('body').append($overlay);
}
function initTooltips() {
$('.md-help-icon').on('click', function(e) {
$('.md-tooltip-popup').remove();
e.stopPropagation();
var $icon = $(this);
var text = $icon.data('help');
var $tt = $('<div class="md-tooltip-popup">' + text + '</div>');
$('body').append($tt);
var offset = $icon.offset();
$tt.css({ top: offset.top - $tt.outerHeight() - 8, left: offset.left - 15 }).fadeIn(200);
});
$(document).on('click', function() { $('.md-tooltip-popup').fadeOut(200, function(){ $(this).remove(); }); });
}
// 7. CORE LOGIC
function loadData() {
return api.get({ action: 'query', prop: 'revisions', titles: pageName, rvprop: 'content', rvslots: 'main', formatversion: 2 }).then(function(data) {
var content = data.query.pages[0].revisions[0].slots.main.content;
var match = content.match(/<!-- MIPPEDIA_DATA_START \| (.*?) -->/);
if (match) { try { var parsed = JSON.parse(match[1]); dataItems = parsed.items || []; isLocked = parsed.locked || false; } catch(e) {} }
return content;
});
}
function saveData(actionType, $btnEl, originalContent, editSummary, isMinor) {
if ($btnEl) $btnEl.prop('disabled', true).text('Menyimpan...');
var summaryTxt = editSummary ? 'Mippedia Data V8: ' + editSummary : 'Mippedia Data V8: ' + actionType;
var jsonStr = JSON.stringify({ locked: isLocked, items: dataItems });
var wt = "<!-- MIPPEDIA_DATA_START | " + jsonStr + " -->\n<div class=\"md-native-render\">{| class=\"wikitable\"\n! Data !! Nilai !! Referensi\n";
dataItems.forEach(function(item) { wt += "|-\n| " + item.prop + " || " + item.val + " || " + (item.ref ? item.ref.title : '') + "\n"; });
wt += "|}\n</div>\n<!-- MIPPEDIA_DATA_END -->";
var newContent = originalContent.replace(/<!-- MIPPEDIA_DATA_START \| .*? -->[\s\S]*?<!-- MIPPEDIA_DATA_END -->/, wt);
if(newContent === originalContent) newContent = originalContent.trim() + "\n\n" + wt;
api.postWithToken('csrf', { action: 'edit', title: pageName, text: newContent, summary: summaryTxt, minor: isMinor }).done(function() {
localStorage.removeItem(DRAFT_KEY);
location.href = location.pathname + "?refresh=" + new Date().getTime();
}).fail(function(err) { alert("Gagal: " + err); if($btnEl) $btnEl.prop('disabled', false); });
}
// 8. BUILD UI
function buildUI(rawContent) {
var $app = $('<div id="mippedia-data-app"></div>');
var $header = $('<div class="md-header"><h3 style="margin:0; font-weight:800; color:#0f172a;">' + svgEdit + ' Data Terstruktur</h3><div class="md-actions"></div></div>');
if (isSysop) {
var $lockBtn = $('<button class="md-btn-icon" style="color:' + (isLocked ? '#dc2626' : '#4f46e5') + '">' + svgLock + (isLocked ? ' Buka Kunci' : ' Kunci Halaman') + '</button>');
$lockBtn.on('click', function() { isLocked = !isLocked; saveData(isLocked ? 'Mengunci data' : 'Membuka kunci', $(this), rawContent); });
$header.find('.md-actions').append($lockBtn);
}
if (!isLocked || isSysop) {
var $addBtn = $('<button class="md-btn-icon">' + svgEdit + ' Tambah</button>');
$addBtn.on('click', function() { showForm(-1, rawContent); });
$header.find('.md-actions').append($addBtn);
}
$app.append($header);
dataItems.forEach(function(item, index) {
var $row = $('<div class="md-row-display"></div>');
var $info = $('<div style="flex:1;"></div>');
$info.append('<span style="font-size:0.72rem; color:#64748b; font-weight:800; text-transform:uppercase;">' + item.prop + '</span>');
$info.append('<div style="font-size:1.05rem; font-weight:700; color:#0f172a; margin-top:4px;">' + item.val + '</div>');
if (item.ref && (item.ref.url || item.ref.title)) {
var isVer = isVerifiedSite(item.ref.url);
var verHtml = isVer ? '<span class="md-verified-badge" title="Situs Populer Terverifikasi">' + svgVerified + '</span>' : '';
var $refHTML = $(`
<div class="md-ref-wrap">
<details class="md-ref-details">
<summary>${svgRef} ${item.ref.title || 'Referensi'} ${verHtml}</summary>
<div class="md-ref-body">
${item.ref.author ? '<div><b>Penulis:</b> ' + item.ref.author + '</div>' : ''}
${item.ref.site ? '<div><b>Situs:</b> ' + item.ref.site + '</div>' : ''}
${item.ref.url ? '<a href="' + ensureHttps(item.ref.url) + '" target="_blank" class="md-btn-visit">Kunjungi Referensi</a>' : ''}
</div>
</details>
</div>
`);
$refHTML.find('.md-verified-badge').on('click', function(e) {
e.preventDefault(); e.stopPropagation();
showModal('Situs Terverifikasi', 'Centang biru menandakan bahwa referensi berasal dari situs web besar, portal populer, atau pangkalan data resmi yang memiliki reputasi tinggi dan kredibel untuk digunakan sebagai rujukan utama.');
});
$info.append($refHTML);
}
$row.append($info);
if (isLocked && !isSysop) {
var $lockedIcon = $('<button class="md-btn-icon" style="color:#dc2626; border-color:#fca5a5; background:#fef2f2;">' + svgLock + ' Terkunci</button>');
$lockedIcon.on('click', function() {
showModal('Akses Ditolak (Dikunci)', 'Halaman Data Terstruktur ini sedang dikunci oleh Pengurus (Sysop). Pengguna biasa atau anonim tidak dapat melakukan penyuntingan untuk sementara waktu demi mencegah vandalisme. Silakan hubungi pengurus jika ada pembaruan data yang sangat penting.');
});
$row.append($lockedIcon);
} else {
var $editIcon = $('<button class="md-btn-icon">Edit</button>');
$editIcon.on('click', function() { showForm(index, rawContent); });
$row.append($editIcon);
}
$app.append($row);
});
$app.append('<div id="md-form-container"></div>');
$('.md-native-render').hide();
var $infobox = $('.infobox').first();
if ($infobox.length) $app.insertAfter($infobox); else $('#mw-content-text .mw-parser-output').append($app);
}
// 9. FORM & DRAFT LOGIC
function showForm(index, rawContent) {
var $container = $('#md-form-container').empty();
var isNew = index === -1;
// Cek Draft Lokal
var draftData = localStorage.getItem(DRAFT_KEY);
var currentData = isNew ? { prop:'', val:'', ref:{} } : dataItems[index];
if (isNew && draftData && confirm("Ditemukan draft yang belum tersimpan sebelumnya. Ingin memuat draft ini?")) {
try { currentData = JSON.parse(draftData); } catch(e) {}
}
var $form = $('<div class="md-form-box"></div>');
$form.append('<h4 style="margin:0 0 16px 0; border-bottom:2px solid #e2e8f0; padding-bottom:8px;">' + (isNew ? 'Tambah Data' : 'Edit Data') + '</h4>');
$form.append(`
<div style="margin-bottom:14px;">
<label style="font-size:0.85rem; font-weight:700;">Label Data <span class="md-help-icon" data-help="Nama bidang data (contoh: Pekerjaan, Sutradara, Tanggal Lahir). Gunakan bahasa yang baku.">${svgHelp}</span></label>
<input type="text" id="md-inp-prop" class="md-input" value="${currentData.prop}">
</div>
<div style="margin-bottom:14px;">
<label style="font-size:0.85rem; font-weight:700;">Nilai Data <span class="md-help-icon" data-help="Isi dari data tersebut (contoh: Penyanyi, 15 April 2003).">${svgHelp}</span></label>
<input type="text" id="md-inp-val" class="md-input" value="${currentData.val}">
</div>
<div style="background:#f8fafc; padding:12px; border-radius:8px; border:1px solid #cbd5e1; margin-bottom:14px;">
<label style="font-size:0.9rem; font-weight:800; display:block; margin-bottom:8px;">Referensi & Rujukan <span class="md-help-icon" data-help="Masukkan sumber dari mana data ini didapatkan. Jika URL dari situs terkenal, otomatis akan mendapat centang biru.">${svgHelp}</span></label>
<input type="text" id="md-ref-title" class="md-input" placeholder="Judul Referensi" value="${currentData.ref ? (currentData.ref.title||'') : ''}" style="margin-bottom:8px;">
<input type="url" id="md-ref-url" class="md-input" placeholder="URL Situs (https://...)" value="${currentData.ref ? (currentData.ref.url||'') : ''}" style="margin-bottom:8px;">
<input type="text" id="md-ref-site" class="md-input" placeholder="Nama Situs / Pangkalan Data" value="${currentData.ref ? (currentData.ref.site||'') : ''}">
</div>
`);
// Kotak CC0 & Edit Summary
$form.append(`
<div class="md-cc0-notice">
<b>Perhatian:</b> Setiap data yang Anda terbitkan akan terlihat secara publik dan dirilis di bawah lisensi <b>Creative Commons Zero (CC0)</b>. Jika Anda tidak ingin suntingan Anda digunakan secara bebas dan publik, jangan terbitkan di sini. <span class="md-help-icon" data-help="Lisensi CC0 berarti data ini menjadi domain publik murni dan bisa digunakan oleh siapa saja tanpa batasan.">${svgHelp}</span>
</div>
<div class="md-edit-meta">
<input type="text" id="md-edit-summary" class="md-input" placeholder="Jelaskan perubahan Anda secara singkat (Opsional)...">
<label style="font-size:0.85rem; cursor:pointer;"><input type="checkbox" id="md-minor-edit"> Ini adalah suntingan kecil (minor)</label>
</div>
`);
var $actions = $('<div style="display:flex; gap:10px; flex-wrap:wrap;"></div>');
var $btnSave = $('<button class="md-btn md-btn-save">Terbitkan</button>');
var $btnDraft = $('<button class="md-btn md-btn-draft">Simpan Draft</button>');
var $btnCancel = $('<button class="md-btn md-btn-cancel">Batal</button>');
$actions.append($btnSave, $btnDraft, $btnCancel);
$form.append($actions);
$container.append($form);
initTooltips();
$('html, body').animate({ scrollTop: $form.offset().top - 30 }, 250);
$btnCancel.on('click', function() { $container.empty(); });
$btnDraft.on('click', function() {
var draftObj = {
prop: $('#md-inp-prop').val(), val: $('#md-inp-val').val(),
ref: { title: $('#md-ref-title').val(), url: $('#md-ref-url').val(), site: $('#md-ref-site').val() }
};
localStorage.setItem(DRAFT_KEY, JSON.stringify(draftObj));
alert("Draft berhasil disimpan ke peramban Anda!");
});
$btnSave.on('click', function() {
if (!$('#md-inp-prop').val() || !$('#md-inp-val').val()) return alert("Label dan Nilai wajib diisi!");
var refUrl = $('#md-ref-url').val();
var newItem = {
prop: $('#md-inp-prop').val(), val: $('#md-inp-val').val(),
ref: ($('#md-ref-title').val() || refUrl) ? { title: $('#md-ref-title').val(), url: ensureHttps(refUrl), site: $('#md-ref-site').val() } : null
};
if (isNew) dataItems.push(newItem); else dataItems[index] = newItem;
saveData(isNew ? 'Tambah data' : 'Edit data', $(this), rawContent, $('#md-edit-summary').val(), $('#md-minor-edit').is(':checked'));
});
}
loadData().then(function(rawContent) { buildUI(rawContent); });
});
})(jQuery, mediaWiki);
/* ==========================================================
⚡ MIPPEDIA SPEED OPTIMIZER - PURE SPEED & STABLE (V1.1)
Features: Instant Link Pre-fetching Engine (No Animation/Pure Performance).
Optimization: Zero-flicker, scoped lifecycle protection, advanced anti-cache clutter.
Target: Built for maximum long-term stability and bulletproof caching.
========================================================= */
(function() {
// Ambil nama host secara dinamis (contoh: data.mippedia.org)
var currentHost = window.location.hostname;
// --- 🗲 ENGINE PRE-FETCH CORES ---
function injectPrefetchLink(url) {
// Jaring Pengaman 1: Jangan injeksi jika link prefetch untuk URL ini sudah ada di head browser
if (document.querySelector('link[href="' + url + '"]')) return;
var prefetcher = document.createElement('link');
prefetcher.rel = 'prefetch';
prefetcher.href = url;
// Jaring Pengaman 2: Failsafe anti-eror cache jika network mendadak sibuk
prefetcher.onerror = function() { prefetcher.remove(); };
document.head.appendChild(prefetcher);
}
function initPrefetchDispatch(href) {
// Memanfaatkan requestIdleCallback agar proses prefetch hanya berjalan saat browser senggang
// sehingga tidak akan membuat scrolling halaman terasa berat/patah-patah
if (window.requestIdleCallback) {
window.requestIdleCallback(function() { injectPrefetchLink(href); });
} else {
setTimeout(function() { injectPrefetchLink(href); }, 20);
}
}
// --- 🎮 COGNITIVE EVENT LISTENERS (UNIVERSAL HOVER & TOUCH) ---
// Mendengarkan area konten utama MediaWiki (Desktop & Tampilan Mobile HP)
$(document).on('mouseenter pointerdown', '#mw-content-text a, .mw-body-content a, #bodyContent a, .mw-parser-output a', function() {
var $link = $(this);
var href = $link.attr('href');
// --- 🛡️ FILTER STRATA TINGGI: ABREVIASI LINK BERGUNA (ANTI CRASH CACHE) ---
// 1. Abaikan link kosong, javascript void, atau buka tab baru (_blank)
if (!href || href.startsWith('#') || href.startsWith('javascript:') || $link.attr('target') === '_blank') return;
// 2. Abaikan link merah (artikel belum ada), link sunting teks, riwayat versi, dan aksi form MediaWiki
if ($link.hasClass('new') || href.includes('action=') || href.includes('diff=') || href.includes('oldid=')) return;
// 3. Abaikan link perkakas krusial pengurus / sistem otentikasi (hindari prefetch logout tidak sengaja)
if (href.includes('Istimewa:') || href.includes('Special:') || href.includes('do=logout')) return;
// Pastikan hanya mengeksekusi routing internal ekosistem Mippedia
var isInternal = href.indexOf(currentHost) !== -1 || href.startsWith('/') || !href.includes('://');
if (isInternal) {
initPrefetchDispatch(href);
}
});
})();
/* ==========================================================
🧠 MIPPEDIA DATA - SMART CONTEXT + AUTO THUMBNAIL (V10.1)
Features: Priority Check (ID > EN > CONCISE), Auto-Age,
Auto-Bold, Smart Links, Dynamic Context,
Targeted Isolation (Safe for Forms), Dynamic Noindex,
Aesthetic Centered Empty State + 🚀 Instant Action Hub (3 Buttons)
Fixes: Mobile View Visibility & Custom Short URL Route (No /w/)
========================================================= */
(function() {
$(document).ready(function() {
var $descSection = $('#mip-desc-section'), $descBox = $('#mip-auto-description'),
$sourceInfo = $('#mip-source-info'), $portalLinks = $('#mip-portal-links'),
$projectPortal = $('#mip-project-portal'), $mainContent = $('#mw-content-text');
if (!$descBox.length) return;
var pageTitle = mw.config.get('wgPageName').replace(/_/g, ' '),
cacheKey = 'mip_smart_context_thumb_' + pageTitle, now = new Date().getTime(),
currentYear = 2026;
// --- KONFIGURASI PROYEK ---
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: 'en', name: 'Mippedia bahasa Inggris', url: 'https://en.mippedia.org/api.php', base: 'https://en.mippedia.org/wiki/', label: 'Mippedia Inggris' },
{ id: 'concise', name: 'Mippedia bahasa Indonesia ringkas', url: 'https://concise.mippedia.org/api.php', base: 'https://concise.mippedia.org/wiki/', label: 'Mippedia Ringkas' }
];
// --- 🎨 ANIMASI, HOVER EFFECT & RESPONSIVE 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 {' +
'display: block !important;' + /* Memaksa tampil di seluler/mobile */
'animation: mipFadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;' +
'}' +
'.mip-btn-container {' +
'display: flex;' +
'flex-wrap: wrap;' + /* Supaya otomatis turun ke bawah kalau di HP */
'justify-content: center;' +
'margin-bottom: 30px;' +
'padding-top: 5px;' +
'}' +
'.mip-action-btn {' +
'display: inline-flex; align-items: center; justify-content: center;' +
'padding: 10px 18px; margin: 6px; font-size: 0.88em; font-weight: 600;' +
'color: #6a5acd !important; background: #ffffff; border: 1.5px solid #6a5acd;' +
'border-radius: 30px; text-decoration: none !important; cursor: pointer;' +
'transition: all 0.25s ease-in-out; box-shadow: 0 2px 5px rgba(106,92,205,0.08);' +
'flex-grow: 1; max-width: 220px; min-width: 150px;' + /* Penyesuaian porsi tombol di HP */
'}' +
'.mip-action-btn:hover {' +
'color: #ffffff !important; background: #6a5acd;' +
'transform: translateY(-2px); box-shadow: 0 4px 12px rgba(106,92,205,0.2);' +
'}' +
'.mip-action-btn:active {' +
'transform: translateY(0);' +
'}' +
'</style>'
);
}
// --- FUNGSI TOOLS ---
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 applyDynamicContext(text) {
var date = new Date();
var hari = ["Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu"];
var bulan = ["Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"];
var tglSkrg = hari[date.getDay()] + ", " + date.getDate() + " " + bulan[date.getMonth()] + " " + date.getFullYear();
return text.replace(/(hari ini|saat ini|sekarang)/gi, '$1 (' + tglSkrg + ')')
.replace(/(\d{1,2}\s(?:Januari|Februari|Maret|April|Mei|Juni|Juli|Agustus|September|Oktober|November|Desember)\s(\d{4}))/gi, function(m, f, y) {
return f + " <span style='color: #444; font-weight: bold;'>– usia " + (currentYear - parseInt(y)) + " tahun</span>";
})
.replace(/(sejak|tahun)\s(\d{4})/gi, function(m, k, y) {
var gap = currentYear - parseInt(y);
if (gap > 0 && gap < 100) return k + " " + y + " <small style='color: #888;'>(" + gap + " thn lalu)</small>";
return m;
});
}
function applySummary(text) {
var limit = 250;
if (text.length <= limit) return '<span>' + text + '</span>';
return '<span>' + text.substring(0, limit) + '</span><span class="mip-dots">... </span><span class="mip-more" style="display:none;">' + text.substring(limit) + '</span><span class="mip-read-btn" style="color: #6a5acd; cursor: pointer; font-weight: bold; margin-left: 5px;">Baca selengkapnya</span>';
}
// --- SMART LINKS PORTAL ---
function buildSmartLinks(currentId, validatedEnTitle) {
$portalLinks.empty();
var validLinks = [];
var checkRequests = projects.filter(p => p.id !== currentId).map(function(p) {
var targetTitle = (p.id === 'en' && validatedEnTitle) ? validatedEnTitle : pageTitle;
if (p.id === 'en' && !validatedEnTitle) return $.Deferred().resolve();
return $.ajax({ url: p.url, data: { action: 'query', titles: targetTitle, format: 'json', origin: '*' }, dataType: 'json' })
.then(function(data) {
if (data.query.pages["-1"] === undefined) {
validLinks.push('<a href="' + p.base + encodeURIComponent(targetTitle) + '" target="_blank" style="color: #6a5acd; text-decoration: underline; font-weight: bold;">' + p.label + '</a>');
}
});
});
$.when.apply($, checkRequests).done(function() {
if (validLinks.length > 0) { $portalLinks.html(validLinks.join(' <span style="color:#ccc; margin: 0 5px;">•</span> ')); $projectPortal.fadeIn(); }
});
}
// --- 🧠 RENDER EMPTY STATE + INTERACTIVE HUB ---
function toggleMippediaLayout(isEmpty) {
var $existingNotice = $('#mip-empty-state-notice');
var userGroups = mw.config.get('wgUserGroups') || [];
var isSysop = userGroups.indexOf('sysop') !== -1;
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 $metaRobots = $('meta[name="robots"]');
if (isEmpty) {
if (!$existingNotice.length) {
// Perbaikan Jalur URL tanpa sub-folder /w/ langsung menembak Short URL root parameter
var createUrlID = 'https://id.mippedia.org/index.php?title=' + encodeURIComponent(pageTitle) + '&action=edit';
var createUrlEN = 'https://en.mippedia.org/index.php?title=' + encodeURIComponent(pageTitle) + '&action=edit';
var createUrlConcise = 'https://concise.mippedia.org/index.php?title=' + encodeURIComponent(pageTitle) + '&action=edit';
var noticeHtml =
'<div id="mip-empty-state-notice" style="text-align: center; max-width: 600px; margin: 40px auto; padding: 10px; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, sans-serif;">' +
'<!-- Ikon Warning Besar -->' +
'<div style="margin-bottom: 22px; display: inline-block;">' +
'<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 Struktur Tidak Memiliki Sumber Artikel</h4>' +
'<!-- Deskripsi Utama -->' +
'<p style="color: #555; margin: 0 0 25px 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>' +
'<!-- 🚀 INSTANT ACTION HUB (Flexbox-Responsive Mobile & URL No /w/) -->' +
'<div class="mip-btn-container">' +
'<a href="' + createUrlID + '" target="_blank" class="mip-action-btn">' +
'<span style="margin-right: 6px;"></span>Buat Artikel ID' +
'</a>' +
'<a href="' + createUrlEN + '" target="_blank" class="mip-action-btn">' +
'<span style="margin-right: 6px;"></span>Buat Artikel EN' +
'</a>' +
'<a href="' + createUrlConcise + '" target="_blank" class="mip-action-btn">' +
'<span style="margin-right: 6px;"></span>Buat Artikel Ringkas' +
'</a>' +
'</div>' +
'<!-- Catatan Kaki Info Kecil -->' +
'<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.' +
'</div>' +
'</div>';
$mainContent.prepend(noticeHtml);
}
$wikiDataElements.hide();
$descSection.hide();
if (!isSysop) {
$editElements.css({ 'pointer-events': 'none', 'opacity': '0.3', 'cursor': 'not-allowed' }).hide();
$(document).on('keydown.miplock', function(e) {
if (e.key.toLowerCase() === 'e' && !$(e.target).is('input, textarea')) {
e.preventDefault();
return false;
}
});
}
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 {
if ($existingNotice.length) $existingNotice.remove();
$wikiDataElements.show();
$descSection.show();
if (!isSysop) {
$(document).off('keydown.miplock');
}
mw.config.set('wgRobotsPolicies', { 'index': 'index', 'follow': 'follow' });
if ($metaRobots.length) {
$metaRobots.attr('content', 'index, follow');
}
}
}
// --- SISTEM PRIORITAS ---
var cached = JSON.parse(localStorage.getItem(cacheKey) || "{}");
var globalEnTitle = cached.enTitle || "";
function init() {
var pPrimary = projects[0];
$.ajax({
url: pPrimary.url,
data: { action: 'query', prop: 'revisions|pageimages|langlinks', lllang: 'en', rvprop: 'timestamp', piprop: 'thumbnail', pithumbsize: 150, titles: pageTitle, format: 'json', origin: '*' },
dataType: 'json',
success: function(res) {
var pg = res.query.pages, id = Object.keys(pg)[0];
var latestTS = (id != "-1") ? pg[id].revisions[0].timestamp : "0";
var thumbUrl = (id != "-1" && pg[id].thumbnail) ? pg[id].thumbnail.source : "";
if (id != "-1" && pg[id].langlinks && pg[id].langlinks[0]) {
globalEnTitle = pg[id].langlinks[0]['*'];
}
if (cached.content && cached.ts === latestTS && latestTS !== "0" && !cached.isEmpty) {
toggleMippediaLayout(false);
renderAll(cached.p, cached.content, cached.isTrans, cached.orig, cached.img, cached.customUrl, cached.enTitle);
} else {
fetchPriorityData(0, latestTS, thumbUrl);
}
},
error: function() {
if (cached.content) {
toggleMippediaLayout(cached.isEmpty || false);
if (!cached.isEmpty) renderAll(cached.p, cached.content, cached.isTrans, cached.orig, cached.img, cached.customUrl, cached.enTitle);
}
}
});
}
function fetchPriorityData(index, newTS, img) {
if (index >= projects.length) {
localStorage.setItem(cacheKey, JSON.stringify({isEmpty: true, ts: newTS, content: ""}));
toggleMippediaLayout(true);
return;
}
var p = projects[index];
if (p.id === 'en') {
if (!globalEnTitle) {
$.ajax({
url: 'https://concise.mippedia.org/api.php',
data: { action: 'query', prop: 'langlinks', lllang: 'en', titles: pageTitle, format: 'json', origin: '*' },
dataType: 'json',
async: false,
success: function(cRes) {
var cPg = cRes.query.pages, cId = Object.keys(cPg)[0];
if (cId != "-1" && cPg[cId].langlinks && cPg[cId].langlinks[0]) {
globalEnTitle = cPg[cId].langlinks[0]['*'];
}
}
});
}
if (globalEnTitle) {
$.ajax({
url: p.url,
data: { action: 'query', prop: 'extracts', exintro: 1, explaintext: 1, titles: globalEnTitle, format: 'json', origin: '*' },
dataType: 'json',
success: function(data) {
var pages = data.query.pages, pageId = Object.keys(pages)[0];
if (pageId != "-1" && pages[pageId].extract) {
var extract = cleanExtract(pages[pageId].extract);
finalize(p, extract, false, "", newTS, img, p.base + encodeURIComponent(globalEnTitle), globalEnTitle);
} else {
fetchPriorityData(index + 1, newTS, img);
}
},
error: function() { fetchPriorityData(index + 1, newTS, img); }
});
} else {
fetchPriorityData(index + 1, newTS, img);
}
} else {
$.ajax({
url: p.url,
data: { action: 'query', prop: 'extracts', exintro: 1, explaintext: 1, titles: pageTitle, format: 'json', origin: '*' },
dataType: 'json',
success: function(data) {
var pages = data.query.pages, pageId = Object.keys(pages)[0];
if (pageId != "-1" && pages[pageId].extract) {
var extract = cleanExtract(pages[pageId].extract);
finalize(p, extract, false, "", newTS, img, p.base + encodeURIComponent(pageTitle), globalEnTitle);
} else {
fetchPriorityData(index + 1, newTS, img);
}
},
error: function() { fetchPriorityData(index + 1, newTS, img); }
});
}
}
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}));
toggleMippediaLayout(false);
renderAll(p, c, t, o, img, customUrl, enTitle);
}
function renderAll(p, currentText, isTranslated, originalText, img, customUrl, enTitle) {
var processedText = applyAutoBold(applyDynamicContext(currentText));
var thumbHtml = img ? '<div style="float: right; margin-left: 15px; margin-bottom: 10px; border: 1px solid #ddd; padding: 3px; background: #fff; border-radius: 4px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);"><img src="'+img+'" style="max-width: 100px; display: block; height: auto;"></div>' : '';
if (!$mainContent.find('#mip-desc-section').length) {
$mainContent.prepend($descSection);
}
$descSection.show();
$descBox.show().html(thumbHtml + applySummary(processedText) + '<div style="clear:both;"></div>');
var targetLink = customUrl ? customUrl : p.base + encodeURIComponent(pageTitle);
var footer = '<div style="font-size: 0.9em; color: #777;">Sumber : <a href="' + targetLink + '" target="_blank" style="color: #6a5acd; font-weight: bold; text-decoration: none;">' + p.name + '.</a>';
if (isTranslated) { footer += '<br><span style="font-size: 0.85em; font-style: italic;">(Diterjemahkan secara otomatis)</span> <span id="mip-toggle-orig" style="color: #6a5acd; cursor: pointer; text-decoration: underline; margin-left: 5px;">Tampilkan versi asli</span>'; }
$sourceInfo.show().html(footer);
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-toggle-orig').on('click', '#mip-toggle-orig', function() {
var isOrig = ($(this).text() === 'Tampilkan versi asli');
var textToDisplay = applyAutoBold(applyDynamicContext(isOrig ? originalText : currentText));
$descBox.html(thumbHtml + applySummary(textToDisplay) + '<div style="clear:both;"></div>');
$(this).text(isOrig ? 'Tampilkan terjemahan' : 'Tampilkan versi asli');
});
}
init();
});
})();
/* ==========================================================
🚀 MIPPEDIA DATA - CORE SYSTEM (ULTIMATE BUNDLE)
Status: FINAL & REVISED (Visual Fix + Permission Logic)
Fix: Mobile Responsive Notification Position
========================================================== */
(function() {
$(document).ready(function() {
// --- 1. FILTER GLOBAL (Namespace 0 & Bukan Halaman Utama) ---
if (mw.config.get('wgNamespaceNumber') !== 0 ||
mw.config.get('wgIsMainPage') ||
mw.config.get('wgAction') !== 'view') return;
var pageTitle = mw.config.get('wgPageName');
var dataPage = 'MediaWiki:Sitelinks-Data.json';
var userGroups = mw.config.get('wgUserGroups');
var isAdmin = userGroups.includes('sysop') || userGroups.includes('interface-admin');
var projects = {
'id': { name: 'ID', url: 'https://id.mippedia.org/api.php', base: 'https://id.mippedia.org/wiki/', color: '#6a5acd' },
'en': { name: 'EN', url: 'https://en.mippedia.org/api.php', base: 'https://en.mippedia.org/wiki/', color: '#4169e1' },
'concise': { name: 'Concise', url: 'https://concise.mippedia.org/api.php', base: 'https://concise.mippedia.org/wiki/', color: '#20b2aa' }
};
// --- 2. KOTAK NOTIFIKASI INFORMASI MODERN (FIXED MOBILE POSITION) ---
function showBoxNotif(title, msg, type) {
$('.mip-box-notif').remove();
var theme = type === 'success' ? {bg:'#e6fffa', border:'#38b2ac', text:'#234e52', icon:''} :
{bg:'#fff5f5', border:'#f56565', text:'#742a2a', icon:''};
// Logika CSS Responsif untuk posisi
var isMobile = window.innerWidth <= 768;
var desktopStyle = "top:25px; right:25px; width:350px;";
var mobileStyle = "top:15px; left:50%; transform:translateX(-50%); width:90%; max-width:400px;";
var finalPos = isMobile ? mobileStyle : desktopStyle;
var $notif = $('<div class="mip-box-notif" style="position:fixed; ' + finalPos + ' background:'+theme.bg+'; border-left:6px solid '+theme.border+'; padding:18px; z-index:10001; border-radius:12px; box-shadow:0 15px 35px rgba(0,0,0,0.2); font-family:sans-serif; animation:mipSlideIn 0.4s ease-out;">' +
'<div style="display:flex; align-items:center; gap:12px; margin-bottom:8px;">' +
'<span style="font-size:20px;">'+theme.icon+'</span>' +
'<strong style="color:'+theme.text+'; font-size:15px; letter-spacing:-0.3px;">'+title+'</strong>' +
'</div>' +
'<p style="margin:0; font-size:13px; color:'+theme.text+'; line-height:1.6; opacity:0.9;">'+msg+'</p>' +
'</div>').appendTo('body');
setTimeout(function() { $notif.fadeOut(function(){ $(this).remove(); }); }, 5500);
}
// --- 3. UI GENERATOR (DIPERTEBAL) ---
// A. Header Pro
var headerHtml = '<div id="mip-header" style="background:#f8f9fa; border:1px solid #ddd; border-left:6px solid #6a5acd; padding:18px; margin-bottom:25px; border-radius:6px; box-shadow:inset 0 0 10px rgba(0,0,0,0.02);">' +
'<div style="display:flex; align-items:center; gap:10px; margin-bottom:8px;">' +
'<span style="background:#6a5acd; color:white; padding:3px 10px; border-radius:4px; font-size:11px; font-weight:bold; text-transform:uppercase; letter-spacing:0.5px;">Basis Data Terstruktur</span>' +
'<strong style="color:#111; font-size:16px;"></strong></div>' +
'<p style="margin:0; font-size:13px; color:#444; line-height:1.6;">' +
'Halaman ini adalah metadata entitas repositori pusat yang disinkronisasi secara otomatis lintas ekosistem. ' +
'Informasi di bawah ini bersifat teknis dan bebas digunakan sebagai referensi data terbuka bagi semua orang di seluruh dunia berdasarkan lisensi atribusi yang sesuai.' +
'</p></div>';
// B. Connector Box
var editBtn = '<span id="mip-open-editor" style="cursor:pointer; font-size:20px; color:#6a5acd; opacity:0.8; transition:0.3s;" onmouseover="this.style.opacity=1" onmouseout="this.style.opacity=0.8">✎</span>';
var connectorHtml = '<div id="mip-connector" style="background:#fff; border:1px solid #e2e8f0; border-radius:16px; padding:22px; margin-top:30px; box-shadow:0 10px 25px rgba(0,0,0,0.04);">' +
'<div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:20px;">' +
'<strong style="font-size:15px; color:#1a202c; display:flex; align-items:center; gap:8px;">ID situs</strong>'+editBtn+'</div>' +
'<div id="mip-display" style="display:flex; gap:12px; flex-wrap:wrap;"><small style="color:#a0aec0;">Mensinkronisasi basis data...</small></div>' +
'<div id="mip-editor" style="display:none; margin-top:20px; border-top:2px solid #f7fafc; padding-top:20px;">' +
Object.keys(projects).map(p => '<div style="margin-bottom:12px; display:flex; gap:10px;"><span style="width:75px; font-size:11px; font-weight:bold; background:#edf2f7; display:flex; align-items:center; justify-content:center; border-radius:8px; color:#4a5568;">'+projects[p].name+'</span><input type="text" id="in-'+p+'" placeholder="Judul artikel di '+projects[p].name+'..." style="flex:1; padding:10px; font-size:13px; border:1.5px solid #e2e8f0; border-radius:10px; outline:none; transition:0.2s;" onfocus="this.style.borderColor=\'#6a5acd\'"></div>').join('') +
'<button id="mip-save" style="width:100%; padding:14px; background:#6a5acd; color:white; border:none; border-radius:12px; font-size:14px; font-weight:bold; cursor:pointer; box-shadow:0 4px 12px rgba(106,90,205,0.3); transition:0.3s;">Terbitkan</button>' +
'</div></div>';
// C. Footer Lisensi Lengkap
var footerHtml = '<div id="mip-footer" style="background:#fafafa; border:1px solid #eee; border-radius:10px; padding:20px; margin-top:30px; text-align:center;">' +
'<div style="font-size:11px; color:#718096; font-weight:800; text-transform:uppercase; letter-spacing:1px; margin-bottom:10px;">Lisensi, Atribusi & Penggunaan Data</div>' +
'<p style="margin:0 0 10px; font-size:13px; color:#4a5568; line-height:1.6;">' +
'Seluruh data terstruktur yang tersaji dalam repositori ini merupakan milik publik dan tersedia di bawah lisensi resmi ' +
'<a href="https://creativecommons.org/licenses/by-sa/4.0/" target="_blank" style="color:#6a5acd; text-decoration:none; font-weight:700;">Creative Commons Attribution-ShareAlike 4.0 International</a>.' +
'</p>' +
'<p style="margin:0; font-size:12px; color:#a0aec0;">Akses API dan penggunaan data secara massal wajib mencantumkan atribusi kepada <strong>Mippedia Community</strong> selaku pengelola proyek.</p></div>';
// Injeksi
$('#mw-content-text').prepend(headerHtml);
$('#mw-content-text').append(connectorHtml).append(footerHtml);
// --- 4. LOGIC ENGINE ---
function loadLinks() {
new mw.Api().get({ action: 'query', prop: 'revisions', titles: dataPage, rvprop: 'content', formatversion: 2 }).done(function(d) {
var json = d.query.pages[0].revisions ? JSON.parse(d.query.pages[0].revisions[0].content) : {};
var data = json[pageTitle] || {};
var $box = $('#mip-display').empty();
var found = false;
Object.keys(projects).forEach(p => {
if (data[p]) {
found = true;
$box.append('<a style="background:'+projects[p].color+'; color:white; padding:8px 16px; border-radius:10px; font-size:12px; font-weight:bold; text-decoration:none; border-bottom:3px solid rgba(0,0,0,0.15);" href="'+projects[p].base+encodeURIComponent(data[p])+'" target="_blank">Mippedia '+projects[p].name+': '+data[p]+'</a>');
$('#in-' + p).val(data[p]);
}
});
if (!found) $box.html('<em style="color:#cbd5e0; font-size:13px;">Entitas ini belum terhubung ke cabang Mippedia manapun.</em>');
});
}
$(document).on('click', '#mip-save', function() {
// CEK IZIN: Tolak user biasa
if (!isAdmin) {
showBoxNotif('Suntingan anda tidak di terbitkan', 'Halaman ini dilindungi. Hanya <b>Pengurus</b> yang memiliki otoritas untuk memodifikasi metadata ekosistem secara langsung.', 'error');
return;
}
var $btn = $(this).text('Sedang Memvalidasi...').prop('disabled', true);
var api = new mw.Api();
var newData = {}, promises = [], invalid = [], isDel = true;
Object.keys(projects).forEach(p => {
var v = $('#in-' + p).val().trim();
if (v) {
isDel = false;
promises.push($.ajax({ url: projects[p].url, data: { action: 'query', titles: v, format: 'json', origin: '*' }, dataType: 'json' }).done(function(res){
if (res.query.pages["-1"]) invalid.push(projects[p].name); else newData[p] = v;
}));
}
});
$.when.apply($, promises).then(function() {
if (invalid.length > 0) {
showBoxNotif('Suntingan anda tidak di terbitkan', 'Artikel dengan judul tersebut tidak ditemukan di basis data Mippedia cabang: ' + invalid.join(', ') + '. Periksa kembali ejaan dan kapitalisasi.', 'error');
$btn.text('Terbitkan').prop('disabled', false); return;
}
api.get({ action: 'query', prop: 'revisions', titles: dataPage, rvprop: 'content', formatversion: 2 }).done(function(r) {
var full = r.query.pages[0].revisions ? JSON.parse(r.query.pages[0].revisions[0].content) : {};
if (isDel) delete full[pageTitle]; else full[pageTitle] = newData;
api.postWithEditToken({ action: 'edit', title: dataPage, text: JSON.stringify(full, null, 2), summary: 'Sync Metadata: ' + pageTitle })
.done(function() {
showBoxNotif('Suntingan anda berhasil di terbitkan!', 'Metadata entitas berhasil disinkronisasi ke seluruh jaringan ekosistem Mippedia.', 'success');
setTimeout(function(){ location.reload(); }, 1500);
}).fail(function(c) {
showBoxNotif('Gagal Menyimpan', 'Terjadi kesalahan pada token API atau koneksi server. Kode: ' + c, 'error');
$btn.text('Simpan & Sinkronkan Data').prop('disabled', false);
});
});
});
});
$(document).on('click', '#mip-open-editor', function() { $('#mip-editor').slideToggle(); });
loadLinks();
});
})();
(function() {
// Fungsi utama suntik teks
function forcePreload() {
var ns = mw.config.get('wgNamespaceNumber');
var pageExists = mw.config.get('wgArticleId') > 0;
// Cek Namespace Utama & Halaman Baru
if (ns === 0 && !pageExists) {
// Cari textarea secara spesifik (Desktop & Mobile punya selector beda)
var $textbox = $('#wpTextbox1, textarea.mw-ui-input, .editor-container textarea');
if ($textbox.length && $textbox.val().trim() === "") {
var pageName = mw.config.get('wgTitle');
$textbox.val('{{Infobox umum\n|nama = ' + pageName + '\n}}');
console.log("Mippedia: Infobox injected!");
}
}
}
// 1. Jalankan pas halaman beres load
$(document).ready(forcePreload);
// 2. Jalankan tiap ada klik (karena mobile buka editor pake klik tanpa refresh)
$(document).on('click', function() {
setTimeout(forcePreload, 800); // Kasih delay dikit nunggu overlay muncul
});
// 3. Pake MutationObserver buat mantau elemen yang baru muncul secara gaib
var observer = new MutationObserver(function() {
forcePreload();
});
observer.observe(document.body, { childList: true, subtree: true });
})();
/* ==========================================================
🚀 MIPPEDIA DATA - CONTENT GUARD (MODIFIED FOR RELATED)
========================================================== */
(function() {
function handleBlock(e) {
var ns = mw.config.get('wgNamespaceNumber');
if (ns !== 0 || mw.config.get('wgIsMainPage')) return;
var $el = $(e.currentTarget);
if ($el.closest('.mw-parser-output').length && $el.text().toLowerCase().includes('buat item')) {
return;
}
var $textbox = $('#wpTextbox1, .editor-container textarea, textarea.mw-ui-input');
if ($textbox.length) {
var content = $textbox.val() || "";
// Pengecekan: Harus ada {{Infobox ATAU setidaknya ada kode #related
var hasInfobox = content.includes('{{Infobox');
var hasRelated = content.includes('#related:');
if (!hasInfobox && !hasRelated) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
window.alert("SUNTINGAN ANDA TIDAK BISA DI TERBITKAN!\n\nMippedia Data bukan tempat untuk menulis artikel ensiklopedia, Jika anda ingin membuat artikel ensiklopedia bukan di sini tempat nya.\n");
return false;
}
}
}
$(document).on('click mousedown touchstart',
'#wpSave, .editor-save, .mw-ui-button.primary, button[type="submit"], .save-button, .header-action button',
function(e) {
handleBlock(e);
}
);
window.addEventListener('submit', function(e) {
handleBlock(e);
}, true);
})();
/* ==========================================================
🛡️ MIPPEDIA CORE SYSTEM - NEURAL ENGINE V12
Update: Brain Upgrade - Semantic Search & Anti-Duplicate
Semua fitur asli (Patroli, Promo, Kategori) tetap UTUH.
========================================================== */
mw.hook('postEdit').add(function() {
var rawUser = mw.config.get('wgUserName');
var userName = rawUser ? rawUser.replace(/_/g, ' ') : 'Anonim';
var isPatroli = (userName === 'Admin');
if (mw.config.get('wgNamespaceNumber') !== 0) return;
var api = new mw.Api();
var pageTitle = mw.config.get('wgPageName').replace(/_/g, ' ');
api.get({
action: 'query',
titles: pageTitle,
prop: 'revisions|categories|links',
rvprop: 'content',
clshow: '!hidden',
pllimit: 'max'
}).done(function(resData) {
var page = resData.query.pages[Object.keys(resData.query.pages)[0]];
if (!page || !page.revisions) return;
var rawContent = page.revisions[0]['*'];
var content = rawContent;
var summaryParts = [];
// --- 2. SUPER INTELLIGENCE RELATED (UPGRADE OTAK V12) ---
// Cek jumlah related saat ini
var currentRelatedMatch = content.match(/\{\{#related:.*?\}\}/g) || [];
// Jika kurang dari 3, kita jalankan otak pencarian canggih
if (currentRelatedMatch.length < 3) {
// Hapus yang lama dulu agar tidak ada duplikat atau "pake yang bekas"
content = content.replace(/\n*\{\{#related:.*?\}\}/g, '');
// Langkah A: Ambil kandidat dari Search Engine (Ranking Skor)
api.get({
action: 'query',
list: 'search',
srsearch: pageTitle, // Gunakan judul sebagai basis pencarian semantic
srlimit: 15,
srprop: ''
}).done(function(searchRes) {
var candidates = {};
// Masukkan hasil pencarian ke pool skor
if (searchRes.query && searchRes.query.search) {
searchRes.query.search.forEach(function(item, index) {
if (item.title === pageTitle) return;
candidates[item.title] = (15 - index); // Skor berdasarkan urutan relevansi
});
}
// Langkah B: Tambah skor jika artikel ada di daftar Link Internal
if (page.links) {
page.links.forEach(function(link) {
if (link.title === pageTitle) return;
candidates[link.title] = (candidates[link.title] || 0) + 5; // Bonus skor link
});
}
// Langkah C: Urutkan berdasarkan skor tertinggi (yang paling nyambung)
var sortedTitles = Object.keys(candidates).sort(function(a, b) {
return candidates[b] - candidates[a];
});
// Ambil TOP 3
var finalRelated = sortedTitles.filter(t => t.indexOf(':') === -1).slice(0, 3);
if (finalRelated.length > 0) {
var relatedTags = '\n\n' + finalRelated.map(t => '{{#related: ' + t + '}}').join('\n');
content += relatedTags;
summaryParts.push('NeuralRelated');
}
runPatroliAndSave();
});
} else {
runPatroliAndSave();
}
function runPatroliAndSave() {
// --- 3. PATROLI ENGINE (FITUR ASLI - TETAP BERFUNGSI) ---
if (isPatroli) {
var placeholders = [];
// Lindungi Brankas: Template, Header, Kategori, Ref, dan Kalimat Pembuka
content = content.replace(/(\{\{[\s\S]*?\}\}|==+.*?==+|\[\[Kategori:.*?\]\]|<ref[\s\S]*?<\/ref>|^.*?adalah)/gi, function(match) {
placeholders.push(match);
return '___MIP_SKIP_' + (placeholders.length - 1) + '___';
});
// Proses Auto-Link (Wajib ambil daftar AllPages dulu)
api.get({ action: 'query', list: 'allpages', apnamespace: 0, aplimit: 'max' }).done(function(apData) {
var allTitles = apData.query.allpages.map(p => p.title);
var lowerTitles = allTitles.map(t => t.toLowerCase());
var tokens = content.split(/(\s+|\[\[|\]\])/);
var inLink = false;
for (var i = 0; i < tokens.length; i++) {
if (tokens[i] === '[[' ) { inLink = true; continue; }
if (tokens[i] === ']]' ) { inLink = false; continue; }
if (inLink || tokens[i].trim().length < 3 || tokens[i].includes('___MIP_SKIP_')) continue;
var wordsInToken = tokens[i].match(/\b\w+\b/g);
if (wordsInToken) {
wordsInToken.forEach(function(word) {
var idx = lowerTitles.indexOf(word.toLowerCase());
if (idx !== -1 && allTitles[idx] !== pageTitle) {
tokens[i] = tokens[i].replace(new RegExp('\\b' + word + '\\b', 'g'), '[[' + allTitles[idx] + '|' + word + ']]');
}
});
}
}
content = tokens.join('');
// Kembalikan dari Brankas
content = content.replace(/___MIP_SKIP_(\d+)___/g, function(match, id) { return placeholders[id]; });
// Bersihkan Link Merah
content = content.replace(/\[\[([^|\]:]+)\]\]/g, function(match, p1) {
return lowerTitles.includes(p1.toLowerCase()) ? match : p1;
});
saveAction();
});
} else {
saveAction();
}
}
function saveAction() {
// --- 4. EKSEKUSI ---
if (content.trim() !== rawContent.trim()) {
api.postWithToken('edit', {
action: 'edit',
title: pageTitle,
text: content,
summary: 'Mippedia Neural Engine V12: ' + summaryParts.join(', '),
bot: true, markasbot: true
}).done(function() { location.reload(); });
}
}
});
});
/* ==========================================================
🌐 MIPPEDIA SHORTDESC - DATA CENTER (PREMIUM UI)
Status: INDEPENDENT & REFINED VISUAL
Storage: MediaWiki:ShortDesc-Data.json
========================================================== */
(function($, mw) {
"use strict";
$(document).ready(function() {
if (mw.config.get('wgNamespaceNumber') !== 0 || mw.config.get('wgIsMainPage')) return;
var pageTitle = mw.config.get('wgPageName');
var storagePage = 'MediaWiki:ShortDesc-Data.json';
var isAdmin = mw.config.get('wgUserGroups').some(g => ['sysop', 'interface-admin'].includes(g));
var langs = {
id: { label: 'Mippedia bahasa Indonesia', short: 'ID', color: '#6366f1' },
en: { label: 'Mippedia bahasa Inggris', short: 'EN', color: '#3b82f6' },
concise: { label: 'Mippedia bahasa Indonesia ringkas', short: 'CON', color: '#14b8a6' }
};
// UI Box dengan Spasi dan Desain Baru
var html = `
<div id="desc-manager" style="background:#ffffff; border:1px solid #f1f5f9; border-left:4px solid #6366f1; border-radius:12px; padding:20px; margin: 20px 0 25px 0; box-shadow:0 4px 12px rgba(0,0,0,0.03); font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;">
<div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:12px;">
<span style="font-size:13px; font-weight:700; color:#475569; text-transform:uppercase; letter-spacing:0.5px; display:flex; align-items:center; gap:6px;">
Label Deskripsi
</span>
<span id="desc-open-editor" style="cursor:pointer; padding:5px; transition:0.2s;" title="Edit Deskripsi">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#94a3b8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path></svg>
</span>
</div>
<div id="desc-status-display" style="display:flex; flex-direction:column; gap:8px;">
<small style="color:#94a3b8; font-style:italic;">Sinkronisasi data...</small>
</div>
<div id="desc-editor" style="display:none; margin-top:18px; border-top:1px dashed #e2e8f0; padding-top:18px;">
${Object.keys(langs).map(k => `
<div style="margin-bottom:12px;">
<label style="display:block; font-size:11px; font-weight:bold; color:#64748b; margin-bottom:4px;">${langs[k].label}</label>
<input type="text" id="desc-in-${k}" placeholder="Tulis deskripsi..." style="width:100%; padding:10px; font-size:13px; border:1px solid #e2e8f0; border-radius:8px; box-sizing:border-box; outline:none; focus:border-color:#6366f1;">
</div>
`).join('')}
<button id="desc-save" style="width:100%; padding:12px; background:#6366f1; color:white; border:none; border-radius:8px; font-size:13px; font-weight:600; cursor:pointer; margin-top:5px;">Terbitkan</button>
</div>
</div>`;
$('.mw-parser-output').prepend(html);
function loadDescStatus() {
new mw.Api().get({ action: 'query', prop: 'revisions', titles: storagePage, rvprop: 'content', formatversion: 2 }).done(function(res) {
var content = res.query.pages[0].revisions ? res.query.pages[0].revisions[0].content : "{}";
var fullData = JSON.parse(content);
var myData = fullData[pageTitle] || {};
var $statusBox = $('#desc-status-display').empty();
var foundAny = false;
Object.keys(langs).forEach(k => {
var val = myData[k];
if (val && val.trim() !== "") {
foundAny = true;
$statusBox.append(`
<div style="display:flex; align-items:center; gap:10px;">
<span style="background:${langs[k].color}15; color:${langs[k].color}; padding:3px 10px; border-radius:20px; font-size:10px; font-weight:800; border:1px solid ${langs[k].color}30; min-width:35px; text-align:center;">${langs[k].short}</span>
<span style="font-size:13px; color:#334155; line-height:1.4;">${val}</span>
</div>
`);
$('#desc-in-' + k).val(val);
}
});
if (!foundAny) {
$statusBox.html('<div style="color:#cbd5e0; font-size:13px; background:#f8fafc; padding:10px; border-radius:8px; border:1px dashed #e2e8f0;">Belum ada metadata deskripsi yang dikaitkan dengan entitas ini.</div>');
}
});
}
$(document).on('click', '#desc-open-editor', function() { $('#desc-editor').slideToggle(); });
$(document).on('click', '#desc-save', function() {
if (!isAdmin) { alert('Akses ditolak. Anda memerlukan izin pengurus.'); return; }
var $btn = $(this).text('Proses Sinkronisasi...').css('opacity','0.7');
var api = new mw.Api();
var newData = { id: $('#desc-in-id').val().trim(), en: $('#desc-in-en').val().trim(), concise: $('#desc-in-concise').val().trim() };
api.get({ action: 'query', prop: 'revisions', titles: storagePage, rvprop: 'content', formatversion: 2 }).done(function(r) {
var json = r.query.pages[0].revisions ? JSON.parse(r.query.pages[0].revisions[0].content) : {};
if (!newData.id && !newData.en && !newData.concise) { delete json[pageTitle]; } else { json[pageTitle] = newData; }
api.postWithEditToken({
action: 'edit',
title: storagePage,
text: JSON.stringify(json, null, 2),
summary: 'Update Entity Description: ' + pageTitle
}).done(function() { location.reload(); });
});
});
loadDescStatus();
});
})(jQuery, mediaWiki);
/* ==========================================================
📍 MIPPEDIA DATA - ULTIMATE TEXT-TO-MAP LOCATOR
Fitur: Deteksi lokasi dari teks dengan database label lengkap
========================================================== */
(function() {
$(document).ready(function() {
var locationText = "";
// --- DAFTAR LABEL SUPER LENGKAP & MASUK AKAL ---
var locationLabels = [
// Umum & Geografis
'lokasi', 'tempat', 'wilayah', 'daerah', 'koordinat', 'alamat',
// Orang (Biografi)
'tempat lahir', 'asal', 'kediaman', 'domisili', 'negara asal',
// Organisasi & Perusahaan
'kantor pusat', 'markas', 'cabang utama', 'titik operasi',
// Makanan & Budaya
'asal wilayah', 'daerah asal', 'negara sumber', 'kawasan',
// Sejarah & Bangunan
'letak', 'posisi', 'titik temu', 'orbit'
];
// Jalankan pencarian di tabel data (infobox atau wikitable)
$('.wikitable tr, .infobox tr, .mip-data-table tr').each(function() {
var label = $(this).find('th').text().toLowerCase().trim();
// Hilangkan karakter spesial kayak titik dua biar matching-nya akurat
label = label.replace(/[:]/g, '');
var isMatch = locationLabels.some(function(target) {
return label === target || label.includes(target);
});
if (isMatch) {
var rawValue = $(this).find('td').text().trim();
// Ambil bagian utama sebelum tanda koma, kurung, atau titik koma
// Misal: "Bandung, Jawa Barat" -> ambil "Bandung"
locationText = rawValue.split(/[,(\[;]/)[0].trim();
if (locationText.length > 2) return false; // Stop jika sudah ketemu yang valid
}
});
// Eksekusi Render Peta
if (locationText && locationText.length > 2) {
var $mapWrapper = $('<div>').css({
'margin': '15px 0',
'padding': '12px',
'border': '1px solid #ddd',
'background': '#ffffff',
'border-radius': '10px',
'box-shadow': '0 4px 12px rgba(0,0,0,0.08)'
});
$mapWrapper.append('<div style="font-weight:bold; font-size:0.9em; margin-bottom:10px; color:#444; display:flex; align-items:center;">' +
'<span style="margin-right:8px;">🗺️</span>Pratinjau Lokasi : ' + locationText + '</div>');
// Embed URL dengan pencarian teks (Nominatim)
var embedUrl = "https://www.openstreetmap.org/export/embed.html?layer=mapnik&q=" + encodeURIComponent(locationText);
var $iframe = $('<iframe>').attr({
'src': embedUrl,
'width': '100%',
'height': '280',
'frameborder': '0',
'style': 'border-radius: 8px; border: 1px solid #eee;'
});
$mapWrapper.append($iframe);
// Link eksternal yang lebih rapi
var gMapsUrl = "https://www.google.com/maps/search/" + encodeURIComponent(locationText);
$mapWrapper.append('<div style="text-align:right; margin-top:8px;">' +
'<a href="' + gMapsUrl + '" target="_blank" style="font-size:0.75em; color:#6a5acd; font-weight:bold; text-decoration:none; text-transform:uppercase; letter-spacing:0.5px;">Buka di Google Maps →</a></div>');
// Masukkan ke bawah section deskripsi otomatis
if ($('#mip-desc-section').length) {
$('#mip-desc-section').after($mapWrapper);
}
}
});
})();