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 237: | Baris 237: | ||
}); | }); | ||
/* | /* ========================================================== | ||
🚀 MIPPEDIA DATA INTEGRATION (Global Version) | |||
Berfungsi untuk: User Login & Anonim | |||
Posisi: Di bawah Estimasi Waktu Baca (Header) | |||
========================================================== */ | |||
$(document).ready(function() { | $(document).ready(function() { | ||
function | function injectMippediaData() { | ||
// 1. Cari | // 1. Cari template asli | ||
var $dataTemplate = $('.mw-parser-output div:contains("Mippedia Data")').first(); | var $dataTemplate = $('.mw-parser-output div:contains("Mippedia Data")').first(); | ||
var dataUrl = $dataTemplate.find('a').attr('href'); | var dataUrl = $dataTemplate.find('a').attr('href'); | ||
if ($dataTemplate.length && dataUrl) { | // 2. Jika ketemu dan belum pernah di-inject sebelumnya | ||
// | if ($dataTemplate.length && dataUrl && $('#mippedia-data-btn').length === 0) { | ||
var $ | |||
// Buat tombol bergaya metadata yang premium | |||
var $newBtn = $(` | |||
<div id="mippedia-data-btn" style="margin: 10px 0; display: inline-block;"> | |||
<a href="${dataUrl}" target="_blank" style="text-decoration: none !important;"> | |||
<div style="display: flex; align-items: center; background: #36c; color: #fff; padding: 6px 12px; border-radius: 8px; font-family: sans-serif; box-shadow: 0 4px 10px rgba(54,102,204,0.25);"> | |||
<span style="font-size: 14px; margin-right: 8px;"></span> | |||
<span style="font-size: 11px; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase;">Lihat di Mippedia Data</span> | |||
</div> | |||
</a> | |||
</div> | |||
`); | |||
// 3. | // 3. PENEMPATAN POSISI (Target: Di bawah estimasi waktu baca) | ||
var $ | var $targetHeader = $('.tagline, .minerva__subtitle, .estimasi-baca-container'); | ||
if ($ | if ($targetHeader.length) { | ||
$ | // Taruh tepat di bawah estimasi waktu baca atau subtitle | ||
// Hapus template lama | $targetHeader.last().after($newBtn); | ||
$dataTemplate. | // Hapus template lama dari dalam artikel agar tidak dobel | ||
$dataTemplate.hide(); | |||
} else { | |||
// Fallback: Jika header tidak ketemu, taruh di bawah judul utama | |||
$('#firstHeading').after($newBtn); | |||
$dataTemplate.hide(); | |||
} | } | ||
} | } | ||
} | } | ||
// Jalankan | // Jalankan segera dan ulangi sekali lagi untuk memastikan render mobile selesai | ||
injectMippediaData(); | |||
setTimeout( | setTimeout(injectMippediaData, 1500); | ||
}); | }); | ||
| Baris 353: | Baris 367: | ||
/* ========================================================== | /* ========================================================== | ||
🛡️ MIPPEDIA SHIELD | 🛡️ MIPPEDIA SHIELD: PROTEKSI HALAMAN SENSITIF (FULL CODE) | ||
Hanya untuk Pengurus, Birokrat, dan Pengawas. | |||
========================================================== */ | ========================================================== */ | ||
$(document).ready(function() { | $(document).ready(function() { | ||
// 1. DAFTAR HALAMAN YANG DIKUNCI | // 1. DAFTAR HALAMAN YANG MAU DIKUNCI | ||
// Tambah atau hapus di dalam kurung siku ini. Gunakan koma sebagai pemisah. | |||
var protectedPages = [ | var protectedPages = [ | ||
"MediaWiki:", | "MediaWiki:", | ||
| Baris 367: | Baris 382: | ||
]; | ]; | ||
// 2 | // 2. CEK STATUS USER & HALAMAN | ||
var userGroups = mw.config.get('wgUserGroups') || []; | var userGroups = mw.config.get('wgUserGroups') || []; | ||
// Daftar grup yang KEBAL proteksi (bisa akses halaman) | |||
var isStaff = userGroups.some(r => ["sysop", "bureaucrat", "steward", "interface-admin"].includes(r)); | var isStaff = userGroups.some(r => ["sysop", "bureaucrat", "steward", "interface-admin"].includes(r)); | ||
var currentPage = mw.config.get('wgPageName'); | var currentPage = mw.config.get('wgPageName'); | ||
// Cek apakah halaman saat ini masuk dalam daftar proteksi | |||
var shouldProtect = protectedPages.some(prefix => currentPage.startsWith(prefix.replace(/ /g, '_'))); | var shouldProtect = protectedPages.some(prefix => currentPage.startsWith(prefix.replace(/ /g, '_'))); | ||
// | // 3. EKSEKUSI PROTEKSI (Hanya jika user BUKAN staff) | ||
if (shouldProtect && !isStaff) { | |||
if (shouldProtect && !isStaff | |||
// Hapus total konten asli agar tidak bisa diintip/disunting | |||
$('body').addClass('mippedia-locked').html(''); | $('body').addClass('mippedia-locked').html(''); | ||
// Inject CSS khusus untuk tampilan Mobile-Friendly & Auto-Center | |||
$('<style>').prop('type', 'text/css').html(` | $('<style>').prop('type', 'text/css').html(` | ||
html, body { margin: 0!important; padding: 0!important; height: 100%!important; width: 100%!important; overflow: hidden!important; background: #f8f9fa!important; } | html, body { | ||
#protection-wrapper { display: flex; align-items: center; justify-content: center; min-height: 100vh; width: 100vw; padding: 20px; box-sizing: border-box; font-family: sans-serif; } | margin: 0 !important; | ||
.protection-card { width: 100%; max-width: 400px; background: # | padding: 0 !important; | ||
height: 100% !important; | |||
width: 100% !important; | |||
overflow: hidden !important; | |||
background: #f8f9fa !important; | |||
} | |||
#protection-wrapper { | |||
display: flex; | |||
align-items: center; | |||
justify-content: center; | |||
min-height: 100vh; | |||
width: 100vw; | |||
padding: 20px; | |||
box-sizing: border-box; | |||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; | |||
} | |||
.protection-card { | |||
width: 100%; | |||
max-width: 400px; | |||
background: #ffffff; | |||
padding: 40px 25px; | |||
border-radius: 30px; | |||
box-shadow: 0 15px 50px rgba(54, 102, 204, 0.15); | |||
border: 1px solid #eef0f2; | |||
text-align: center; | |||
} | |||
.shield-icon { font-size: 70px; display: block; margin-bottom: 20px; } | .shield-icon { font-size: 70px; display: block; margin-bottom: 20px; } | ||
.lock-title { color: #1a1a1a; font-size: 24px; font-weight: 800; margin | .lock-title { color: #1a1a1a; font-size: 24px; font-weight: 800; margin: 0 0 15px 0; } | ||
.lock-desc { color: #5f6368; font-size: | .lock-desc { color: #5f6368; font-size: 15px; line-height: 1.6; margin-bottom: 25px; } | ||
.admin-notice { background: #fff5f5; color: #d93025; padding: 12px; border-radius: 12px; font-size: | .admin-notice { | ||
.btn-back { background: #36c; color: #fff; border: none; padding: 16px; border-radius: 18px; font-weight: 700; width: 100%; cursor: pointer; } | background: #fff5f5; | ||
color: #d93025; | |||
padding: 12px; | |||
border-radius: 12px; | |||
font-size: 13px; | |||
font-weight: 700; | |||
margin-bottom: 30px; | |||
border: 1px solid #fadbd8; | |||
} | |||
.btn-back { | |||
background: #36c; | |||
color: #fff; | |||
border: none; | |||
padding: 16px; | |||
border-radius: 18px; | |||
font-weight: 700; | |||
font-size: 16px; | |||
width: 100%; | |||
cursor: pointer; | |||
box-shadow: 0 4px 12px rgba(51, 102, 204, 0.3); | |||
} | |||
.link-home { display: block; margin-top: 20px; color: #70757a; font-size: 14px; text-decoration: none; } | |||
.footer-ver { margin-top: 40px; font-size: 10px; color: #bdc1c6; font-weight: bold; letter-spacing: 2px; } | |||
`).appendTo('head'); | `).appendTo('head'); | ||
// Tampilkan layar kunci | |||
var shieldHTML = ` | var shieldHTML = ` | ||
<div id="protection-wrapper"> | <div id="protection-wrapper"> | ||
<div class="protection-card"> | <div class="protection-card"> | ||
<span class="shield-icon">🛡️</span> | <span class="shield-icon">🛡️</span> | ||
<h2 class="lock-title">Akses | <h2 class="lock-title">Akses Dibatasi</h2> | ||
<p class="lock-desc">Halaman ini | <p class="lock-desc"> | ||
<div class="admin-notice">Hanya Administrator yang dapat | Halaman ini telah dilindungi oleh <b>Mippedia Community</b> untuk menjaga stabilitas sistem. | ||
<button class="btn-back" onclick="window.history.back()">Kembali</button> | </p> | ||
<div class="admin-notice"> | |||
Hanya Administrator & Birokrat yang dapat mengakses halaman ini. | |||
</div> | |||
<button class="btn-back" onclick="window.history.back()"> | |||
Kembali ke Halaman Sebelumnya | |||
</button> | |||
<a href="/" class="link-home">Kembali ke Beranda</a> | |||
<div class="footer-ver">MIPPEDIA COMMUNITY SECURE v2.0</div> | |||
</div> | </div> | ||
</div> | </div> | ||
`; | `; | ||
$('body').append(shieldHTML); | $('body').append(shieldHTML); | ||
document.title = "Akses Dilindungi - Mippedia"; | |||
// Ubah judul tab browser | |||
document.title = "Akses Dilindungi - Mippedia bahasa Indonesia, ensiklopedia umum"; | |||
} | } | ||
}); | }); | ||