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 SMART-FALLBACK ( | 🧠 MIPPEDIA DATA SMART-FALLBACK (POSITION UPDATED) | ||
- Layout: Sumber di baris baru | |||
- Format: Sumber Dari : [Nama Proyek] | |||
========================================================== */ | ========================================================== */ | ||
(function() { | (function() { | ||
| Baris 11: | Baris 12: | ||
var pageTitle = mw.config.get('wgPageName'); | var pageTitle = mw.config.get('wgPageName'); | ||
var projects = [ | var projects = [ | ||
{ name: 'Mippedia bahasa Indonesia', url: 'https://id.mippedia.org/api.php', base: 'https://id.mippedia.org/wiki/' }, | { name: 'Mippedia bahasa Indonesia', url: 'https://id.mippedia.org/api.php', base: 'https://id.mippedia.org/wiki/' }, | ||
| Baris 18: | Baris 18: | ||
]; | ]; | ||
function cleanExtract(text) { | function cleanExtract(text) { | ||
return text.replace(/\{\{[^}]+\}\}/g, '').replace(/\(\s*\)/g, '').replace(/\s\s+/g, ' ').trim(); | return text.replace(/\{\{[^}]+\}\}/g, '').replace(/\(\s*\)/g, '').replace(/\s\s+/g, ' ').trim(); | ||
} | } | ||
function fetchDescription(index) { | function fetchDescription(index) { | ||
if (index >= projects.length) { | if (index >= projects.length) { | ||
$descSection.hide(); | $descSection.hide(); | ||
return; | return; | ||
| Baris 32: | Baris 29: | ||
var p = projects[index]; | var p = projects[index]; | ||
$descBox.html('<div class="mip-loading-shimmer"></div>'); | $descBox.html('<div class="mip-loading-shimmer"></div>'); | ||
$descSection.show(); | $descSection.show(); | ||
| Baris 49: | Baris 44: | ||
if (extract !== "") { | if (extract !== "") { | ||
var sourceLink = p.base + encodeURIComponent(pageTitle); | var sourceLink = p.base + encodeURIComponent(pageTitle); | ||
extract + | // --- BAGIAN YANG DIUBAH POSISINYA --- | ||
' <a href="' + sourceLink + '" target="_blank" style="color: #6a5acd; font-weight: bold; text-decoration: none;"> | var formattedContent = | ||
).fadeIn(400); | '<div style="margin-bottom: 12px;">' + extract + '</div>' + | ||
'<div style="font-size: 0.9em; color: #777;">' + | |||
'Sumber Dari : <a href="' + sourceLink + '" target="_blank" style="color: #6a5acd; font-weight: bold; text-decoration: none;">' + p.name + '.</a>' + | |||
'</div>'; | |||
$descBox.hide().html(formattedContent).fadeIn(400); | |||
return; | return; | ||
} | } | ||
} | } | ||
fetchDescription(index + 1); | fetchDescription(index + 1); | ||
}, | }, | ||
error: function() { | error: function() { | ||
fetchDescription(index + 1); | fetchDescription(index + 1); | ||
} | } | ||
| Baris 68: | Baris 65: | ||
} | } | ||
fetchDescription(0); | fetchDescription(0); | ||
// | // CSS Shimmer tetap sama | ||
if ($('#mip-shimmer-style').length === 0) { | |||
$('<style id="mip-shimmer-style">').text(` | |||
.mip-loading-shimmer { height: 16px; width: 100%; background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%); background-size: 200% 100%; animation: mip-shimmer 1.5s infinite; border-radius: 4px; } | |||
@keyframes mip-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } } | |||
`).appendTo('head'); | |||
} | |||
}); | }); | ||
})(); | })(); | ||
Revisi per 14 April 2026 22.51
/* ==========================================================
🧠 MIPPEDIA DATA SMART-FALLBACK (POSITION UPDATED)
- Layout: Sumber di baris baru
- Format: Sumber Dari : [Nama Proyek]
========================================================== */
(function() {
$(document).ready(function() {
var $descSection = $('#mip-desc-section');
var $descBox = $('#mip-auto-description');
if (!$descBox.length) return;
var pageTitle = mw.config.get('wgPageName');
var projects = [
{ name: 'Mippedia bahasa Indonesia', url: 'https://id.mippedia.org/api.php', base: 'https://id.mippedia.org/wiki/' },
{ name: 'Mippedia bahasa Inggris', url: 'https://en.mippedia.org/api.php', base: 'https://en.mippedia.org/wiki/' },
{ name: 'Mippedia bahasa Indonesia ringkas', url: 'https://concise.mippedia.org/api.php', base: 'https://concise.mippedia.org/wiki/' }
];
function cleanExtract(text) {
return text.replace(/\{\{[^}]+\}\}/g, '').replace(/\(\s*\)/g, '').replace(/\s\s+/g, ' ').trim();
}
function fetchDescription(index) {
if (index >= projects.length) {
$descSection.hide();
return;
}
var p = projects[index];
$descBox.html('<div class="mip-loading-shimmer"></div>');
$descSection.show();
$.ajax({
url: p.url,
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 = cleanExtract(pages[pageId].extract);
if (extract !== "") {
var sourceLink = p.base + encodeURIComponent(pageTitle);
// --- BAGIAN YANG DIUBAH POSISINYA ---
var formattedContent =
'<div style="margin-bottom: 12px;">' + extract + '</div>' +
'<div style="font-size: 0.9em; color: #777;">' +
'Sumber Dari : <a href="' + sourceLink + '" target="_blank" style="color: #6a5acd; font-weight: bold; text-decoration: none;">' + p.name + '.</a>' +
'</div>';
$descBox.hide().html(formattedContent).fadeIn(400);
return;
}
}
fetchDescription(index + 1);
},
error: function() {
fetchDescription(index + 1);
}
});
}
fetchDescription(0);
// CSS Shimmer tetap sama
if ($('#mip-shimmer-style').length === 0) {
$('<style id="mip-shimmer-style">').text(`
.mip-loading-shimmer { height: 16px; width: 100%; background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%); background-size: 200% 100%; animation: mip-shimmer 1.5s infinite; border-radius: 4px; }
@keyframes mip-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
`).appendTo('head');
}
});
})();