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 AUTO-DESCRIPTION ( | 🧠 MIPPEDIA DATA AUTO-DESCRIPTION (SMART CHECK EDITION) | ||
========================================================== */ | ========================================================== */ | ||
(function() { | (function() { | ||
$(document).ready(function() { | $(document).ready(function() { | ||
var $descSection = $('#mip-desc-section'); | |||
var $descBox = $('#mip-auto-description'); | var $descBox = $('#mip-auto-description'); | ||
| Baris 21: | Baris 22: | ||
var pageId = Object.keys(pages)[0]; | var pageId = Object.keys(pages)[0]; | ||
// JIKA ARTIKEL ADA (Bukan -1) | |||
if (pageId != "-1") { | if (pageId != "-1") { | ||
var extract = pages[pageId].extract; | var extract = pages[pageId].extract; | ||
// PEMBERSIHAN TOTAL | // PEMBERSIHAN TOTAL | ||
extract = extract.replace(/\{\{[^}]+\}\}/g, '') | extract = extract.replace(/\{\{[^}]+\}\}/g, '') | ||
.replace(/\(\s*\)/g, '') | .replace(/\(\s*\)/g, '') | ||
.replace(/\s\s+/g, ' ') | .replace(/\s\s+/g, ' ') | ||
.trim(); | .trim(); | ||
var sourceLink = 'https://id.mippedia.org/wiki/' + encodeURIComponent(pageTitle); | if (extract !== "") { | ||
var sourceLink = 'https://id.mippedia.org/wiki/' + encodeURIComponent(pageTitle); | |||
// Masukkan teks dan tampilkan section-nya | |||
$descBox.html( | |||
extract + | |||
' <a href="' + sourceLink + '" target="_blank" style="color: #6a5acd; font-weight: bold; text-decoration: none;">Dari Mippedia ↗️</a>' | |||
} | ); | ||
$descSection.show(); // Munculin section kalau ada isinya | |||
} | |||
} | |||
// JIKA GAK ADA ARTIKEL: Section tetep sembunyi (display: none) | |||
} | } | ||
}); | }); | ||
Revisi per 14 April 2026 22.21
/* ==========================================================
🧠 MIPPEDIA DATA AUTO-DESCRIPTION (SMART CHECK EDITION)
========================================================== */
(function() {
$(document).ready(function() {
var $descSection = $('#mip-desc-section');
var $descBox = $('#mip-auto-description');
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];
// JIKA ARTIKEL ADA (Bukan -1)
if (pageId != "-1") {
var extract = pages[pageId].extract;
// PEMBERSIHAN TOTAL
extract = extract.replace(/\{\{[^}]+\}\}/g, '')
.replace(/\(\s*\)/g, '')
.replace(/\s\s+/g, ' ')
.trim();
if (extract !== "") {
var sourceLink = 'https://id.mippedia.org/wiki/' + encodeURIComponent(pageTitle);
// Masukkan teks dan tampilkan section-nya
$descBox.html(
extract +
' <a href="' + sourceLink + '" target="_blank" style="color: #6a5acd; font-weight: bold; text-decoration: none;">Dari Mippedia ↗️</a>'
);
$descSection.show(); // Munculin section kalau ada isinya
}
}
// JIKA GAK ADA ARTIKEL: Section tetep sembunyi (display: none)
}
});
}
});
})();