MediaWiki:Common.js: Perbedaan antara revisi
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 - | 🧠 MIPPEDIA DATA - OMNI-SCRIPT PRO | ||
Features: Chaining, Translate, Toggle, Cleaner, Summary, | |||
Auto-Aging (NEW), Project Portal (NEW) | |||
========================================================== */ | ========================================================== */ | ||
(function() { | (function() { | ||
| Baris 7: | Baris 9: | ||
var $descBox = $('#mip-auto-description'); | var $descBox = $('#mip-auto-description'); | ||
var $sourceInfo = $('#mip-source-info'); | var $sourceInfo = $('#mip-source-info'); | ||
var $portalLinks = $('#mip-portal-links'); | |||
var $projectPortal = $('#mip-project-portal'); | |||
if (!$descBox.length) return; | if (!$descBox.length) return; | ||
var pageTitle = mw.config.get('wgPageName'); | var pageTitle = mw.config.get('wgPageName'); | ||
var currentYear = 2026; // Tahun Sekarang sesuai sistem Mippedia | |||
var projects = [ | var projects = [ | ||
{ id: 'id', name: 'Mippedia bahasa Indonesia', url: 'https://id.mippedia.org/api.php', base: 'https://id.mippedia.org/wiki/' }, | { id: 'id', name: 'Mippedia bahasa Indonesia', url: 'https://id.mippedia.org/api.php', base: 'https://id.mippedia.org/wiki/', label: 'Bahasa Indonesia' }, | ||
{ id: 'en', name: 'Mippedia bahasa Inggris', url: 'https://en.mippedia.org/api.php', base: 'https://en.mippedia.org/wiki/' }, | { id: 'en', name: 'Mippedia bahasa Inggris', url: 'https://en.mippedia.org/api.php', base: 'https://en.mippedia.org/wiki/', label: 'English Version' }, | ||
{ id: 'concise', name: 'Mippedia bahasa Indonesia ringkas', url: 'https://concise.mippedia.org/api.php', base: 'https://concise.mippedia.org/wiki/' } | { id: 'concise', name: 'Mippedia bahasa Indonesia ringkas', url: 'https://concise.mippedia.org/api.php', base: 'https://concise.mippedia.org/wiki/', label: 'Versi Ringkas' } | ||
]; | ]; | ||
// 🎂 Fitur 1: Auto-Aging (Hitung Umur Otomatis) | |||
function applyAutoAge(text) { | |||
return text.replace(/(\d{1,2}\s(?:Januari|Februari|Maret|April|Mei|Juni|Juli|Agustus|September|Oktober|November|Desember)\s(\d{4}))/gi, function(match, fullDate, year) { | |||
var age = currentYear - parseInt(year); | |||
return fullDate + " – usia " + age + " tahun"; | |||
}); | |||
} | |||
function cleanExtract(text) { | function cleanExtract(text) { | ||
| Baris 20: | Baris 35: | ||
} | } | ||
function applySummary(text) { | function applySummary(text) { | ||
var limit = 250; | var limit = 250; | ||
| Baris 42: | Baris 56: | ||
var sourceLink = p.base + encodeURIComponent(pageTitle); | var sourceLink = p.base + encodeURIComponent(pageTitle); | ||
// | // Terapkan Auto-Age sebelum ditampilin | ||
$descBox.html(applySummary( | var agedText = applyAutoAge(currentText); | ||
$descBox.html(applySummary(agedText)); | |||
var footer = '<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>'; | var footer = '<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>'; | ||
if (isTranslated) { | if (isTranslated) { | ||
| Baris 54: | Baris 69: | ||
$sourceInfo.html(footer); | $sourceInfo.html(footer); | ||
// | // 🚀 Fitur 3: Project Portal (Tombol Pindah Cepat) | ||
$portalLinks.empty(); | |||
projects.forEach(function(proj) { | |||
if (proj.id !== p.id) { | |||
$portalLinks.append('<a href="' + proj.base + encodeURIComponent(pageTitle) + '" target="_blank" style="font-size: 0.8em; color: #6a5acd; border: 1px solid #6a5acd; padding: 2px 8px; border-radius: 4px; text-decoration: none;">' + proj.label + '</a>'); | |||
} | |||
}); | |||
$projectPortal.fadeIn(); | |||
$(document).off('click', '.mip-read-btn').on('click', '.mip-read-btn', function() { | $(document).off('click', '.mip-read-btn').on('click', '.mip-read-btn', function() { | ||
$(this).hide(); $('.mip-dots').hide(); $('.mip-more').fadeIn(); | $(this).hide(); $('.mip-dots').hide(); $('.mip-more').fadeIn(); | ||
}); | }); | ||
if (isTranslated) { | if (isTranslated) { | ||
$(document).off('click', '#mip-toggle-orig').on('click', '#mip-toggle-orig', function() { | $(document).off('click', '#mip-toggle-orig').on('click', '#mip-toggle-orig', function() { | ||
if ($(this).text() === 'Tampilkan terjemahan') { | |||
renderAll(p, originalText, true, currentText); | |||
} else { | |||
renderAll(p, originalText, true, currentText); // Toggle logic | |||
} | |||
}); | }); | ||
} | } | ||
} | } | ||
| Baris 85: | Baris 98: | ||
$descBox.html('<div class="mip-loading-shimmer"></div>'); | $descBox.html('<div class="mip-loading-shimmer"></div>'); | ||
$sourceInfo.empty(); | $sourceInfo.empty(); | ||
$projectPortal.hide(); | |||
$descSection.show(); | $descSection.show(); | ||
| Baris 97: | Baris 111: | ||
var extract = cleanExtract(pages[pageId].extract); | var extract = cleanExtract(pages[pageId].extract); | ||
if (extract !== "") { | if (extract !== "") { | ||
if (p.id === 'en') { | if (p.id === 'en') { | ||
else { renderAll(p, extract, false); } | translateText(extract, function(translated) { renderAll(p, translated, true, extract); }); | ||
} else { renderAll(p, extract, false); } | |||
return; | return; | ||
} | } | ||