MediaWiki:Common.js
Tampilan
Catatan: Setelah menerbitkan, Anda mungkin perlu melewati tembolok peramban web Anda untuk melihat perubahan.
- Firefox/Safari: Tekan dan tahan Shift sembari mengeklik Reload, atau tekan Ctrl-F5 atau Ctrl-R (⌘-R di Mac)
- Google Chrome: Tekan Ctrl-Shift-R (⌘-Shift-R di Mac)
- Edge: Tahan Ctrl sembari mengeklik Refresh, atau tekan Ctrl-F5
/* ==========================================================
🧠 MIPPEDIA DATA AUTO-DESCRIPTION (PRO EDITION)
- Clean Template: Hapus {{Lahir}}, {{Lang}}, dll
- Smart Spacing: Perbaikan spasi berantakan
- Accordion: Fitur Tampilkan/Lipat dengan animasi
========================================================== */
(function() {
$(document).ready(function() {
var $descBox = $('#mip-auto-description');
var $wrapper = $('#mip-desc-wrapper');
var $triggerCont = $('#mip-trigger-container');
var $triggerBtn = $('#mip-desc-trigger');
if ($descBox.length) {
var pageTitle = mw.config.get('wgPageName');
var apiUrl = 'https://id.mippedia.org/api.php';
$.ajax({
url: apiUrl,
data: {
action: 'query',
prop: 'extracts',
exintro: true,
explaintext: true,
titles: pageTitle,
format: 'json',
origin: '*'
},
dataType: 'json',
success: function(data) {
var pages = data.query.pages;
var pageId = Object.keys(pages)[0];
if (pageId != "-1") {
var extract = pages[pageId].extract;
// 1. BERSIHKAN TEMPLATE & SPASI (REGEX SAKTI)
// Hapus konten di dalam kurung kurawal {{...}}
extract = extract.replace(/\{\{[^}]+\}\}/g, '');
// Hapus spasi ganda atau renggang yang gak jelas
extract = extract.replace(/\s\s+/g, ' ').trim();
var sourceLink = 'https://id.mippedia.org/wiki/' + encodeURIComponent(pageTitle);
var fullContent = extract + ' <a href="' + sourceLink + '" target="_blank" style="color: #6a5acd; font-weight: bold; text-decoration: none;">Dari Mippedia ↗️</a>';
// 2. TAMPILKAN DATA
$descBox.hide().html(fullContent).fadeIn(500);
// 3. LOGIKA LIPAT (Jika teks lebih tinggi dari 85px)
setTimeout(function() {
if ($descBox.height() > 85) {
$triggerCont.show();
}
}, 600);
}
}
});
// 4. EVENT CLICK (Tampilkan / Sembunyikan)
$triggerBtn.on('click', function() {
if ($wrapper.css('max-height') === '85px') {
$wrapper.css('max-height', $descBox.height() + 50 + 'px');
$(this).text('- Lipat Deskripsi');
} else {
$wrapper.css('max-height', '85px');
$(this).text('+ Tampilkan Selengkapnya');
}
});
}
});
})();