MediaWiki:Common.js: Perbedaan antara revisi
Tampilan
←Membuat halaman berisi '→========================================================== 🧠 MIPPEDIA DATA AUTO-DESCRIPTION FETCH Narik paragraf pertama dari id.mippedia.org secara otomatis ==========================================================: (function() { $(document).ready(function() { var $descBox = $('#mip-auto-description'); // Cek apakah kotak deskripsi ada dan apakah isinya masih kosong/default if ($descBox.length) {...' 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 (CLEAN UI EDITION) | ||
========================================================== */ | ========================================================== */ | ||
(function() { | (function() { | ||
| Baris 7: | Baris 6: | ||
var $descBox = $('#mip-auto-description'); | var $descBox = $('#mip-auto-description'); | ||
if ($descBox.length) { | if ($descBox.length) { | ||
var pageTitle = mw.config.get('wgPageName'); | var pageTitle = mw.config.get('wgPageName'); | ||
var apiUrl = 'https://id.mippedia.org/api.php'; | var apiUrl = 'https://id.mippedia.org/api.php'; | ||
| Baris 17: | Baris 15: | ||
action: 'query', | action: 'query', | ||
prop: 'extracts', | prop: 'extracts', | ||
exintro: true, | exintro: true, | ||
explaintext: true, | explaintext: true, | ||
titles: pageTitle, | titles: pageTitle, | ||
format: 'json', | format: 'json', | ||
origin: '*' | origin: '*' | ||
}, | }, | ||
dataType: 'json', | dataType: 'json', | ||
| Baris 31: | Baris 29: | ||
var extract = pages[pageId].extract; | var extract = pages[pageId].extract; | ||
// | // Potong teks jika terlalu panjang agar tetap rapi | ||
if (extract.length > | if (extract.length > 450) { | ||
extract = extract.substring(0, | extract = extract.substring(0, 450) + '...'; | ||
} | } | ||
var sourceLink = 'https://id.mippedia.org/wiki/' + encodeURIComponent(pageTitle); | |||
var sourceLink = ' https://id.mippedia.org/wiki/' + encodeURIComponent(pageTitle); | |||
// | // Output dengan styling yang bersih | ||
$descBox.html( | $descBox.hide().html( | ||
extract + | extract + | ||
' <a href="' + sourceLink + '" style="color: #6a5acd; font-weight: bold; text-decoration: none;">Dari Mippedia | ' <a href="' + sourceLink + '" target="_blank" style="color: #6a5acd; font-weight: bold; text-decoration: none; border-bottom: 1px solid transparent; transition: 0.2s;">Dari Mippedia.</a>' | ||
); | ).fadeIn(400); // Kasih efek halus pas muncul | ||
} else { | } else { | ||
if ($descBox.text().includes('Mengambil')) { | |||
if ($descBox.text().includes(' | $descBox.html('<span style="color:#888; font-size: 0.9em;">(Deskripsi belum tersedia di Mippedia utama)</span>'); | ||
$descBox.html('<span style="color:# | |||
} | } | ||
} | } | ||
}, | }, | ||
error: function() { | error: function() { | ||
$descBox.html('<span style="color:# | $descBox.html('<span style="color:#e74c3c;">Gagal memuat deskripsi.</span>'); | ||
} | } | ||
}); | }); | ||
Revisi per 14 April 2026 21.34
/* ==========================================================
🧠 MIPPEDIA DATA AUTO-DESCRIPTION (CLEAN UI EDITION)
========================================================== */
(function() {
$(document).ready(function() {
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];
if (pageId != "-1") {
var extract = pages[pageId].extract;
// Potong teks jika terlalu panjang agar tetap rapi
if (extract.length > 450) {
extract = extract.substring(0, 450) + '...';
}
var sourceLink = 'https://id.mippedia.org/wiki/' + encodeURIComponent(pageTitle);
// Output dengan styling yang bersih
$descBox.hide().html(
extract +
' <a href="' + sourceLink + '" target="_blank" style="color: #6a5acd; font-weight: bold; text-decoration: none; border-bottom: 1px solid transparent; transition: 0.2s;">Dari Mippedia.</a>'
).fadeIn(400); // Kasih efek halus pas muncul
} else {
if ($descBox.text().includes('Mengambil')) {
$descBox.html('<span style="color:#888; font-size: 0.9em;">(Deskripsi belum tersedia di Mippedia utama)</span>');
}
}
},
error: function() {
$descBox.html('<span style="color:#e74c3c;">Gagal memuat deskripsi.</span>');
}
});
}
});
})();