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 638: | Baris 638: | ||
/* ========================================================== | /* ========================================================== | ||
🛡️ MIPPEDIA AUTO-PROTECTION SYSTEM | 🛡️ MIPPEDIA AUTO-PROTECTION SYSTEM (ADAPTIVE & AUTO-NOTIF) | ||
Fitur: Request Protect, Auto-Lock, & | Fitur: Request Protect, Auto-Lock, & Pesan Otomatis ke User | ||
========================================================== */ | ========================================================== */ | ||
$(document).ready(function() { | $(document).ready(function() { | ||
| Baris 655: | Baris 655: | ||
} | } | ||
// --- 2. TOMBOL | // --- 2. TOMBOL DINAMIS (DI HALAMAN BERKAS) --- | ||
if (ns === 6) { | if (ns === 6 && user) { // Khusus user login | ||
var api = new mw.Api(); | |||
api.get({ action: 'query', prop: 'info', titles: pageName, inprop: 'protection' }).done(function(data) { | |||
var $protBtn = $('<button>').html('<span>🔒</span> | var page = data.query.pages[Object.keys(data.query.pages)[0]]; | ||
var protections = page.protection; | |||
var isFull = false; | |||
var isSemi = false; | |||
protections.forEach(function(p) { | |||
if (p.type === 'edit') { | |||
if (p.level === 'sysop') isFull = true; | |||
if (p.level === 'autoconfirmed') isSemi = true; | |||
} | |||
}); | |||
// Jika Full, tombol hilang. Jika Semi, tombol minta Penuh. | |||
if (isFull) return; | |||
var btnLabel = isSemi ? '🔒 Minta Perlindungan Penuh' : '🔒 Minta Perlindungan'; | |||
var reqType = isSemi ? 'Perlindungan Penuh' : 'Perlindungan'; | |||
var $protBtn = $('<button>').html('<span>🔒</span> ' + btnLabel).css({ | |||
'background': '#d33', 'color': '#fff', 'border': 'none', 'padding': '5px 15px', | 'background': '#d33', 'color': '#fff', 'border': 'none', 'padding': '5px 15px', | ||
'border-radius': '20px', 'font-size': '11px', 'font-weight': '800', 'cursor': 'pointer', 'margin': '10px 5px' | 'border-radius': '20px', 'font-size': '11px', 'font-weight': '800', 'cursor': 'pointer', 'margin': '10px 5px' | ||
}); | }); | ||
$protBtn.click(function() { | $protBtn.click(function() { | ||
var talkPage = "Pembicaraan_Berkas:" + mw.config.get('wgTitle'); | var talkPage = "Pembicaraan_Berkas:" + mw.config.get('wgTitle'); | ||
sessionStorage.setItem('mippedia_protect_text', "Halo Pengurus Mippedia,\n\nSaya memohon | sessionStorage.setItem('mippedia_protect_text', "Halo Pengurus Mippedia,\n\nSaya memohon " + reqType + " untuk berkas [[:" + pageName + "]] guna menghindari penyalahgunaan."); | ||
window.location.href = mw.util.getUrl(talkPage, { action: 'edit', section: 'new', preloadtitle: 'Permintaan Perlindungan Berkas' }); | window.location.href = mw.util.getUrl(talkPage, { action: 'edit', section: 'new', preloadtitle: 'Permintaan Perlindungan Berkas' }); | ||
}); | }); | ||
setTimeout(function() { $('#firstHeading').after($protBtn); }, 650); | setTimeout(function() { $('#firstHeading').after($protBtn); }, 650); | ||
} | }); | ||
} | } | ||
| Baris 693: | Baris 712: | ||
var $btnReject = $('<button>').text('TOLAK').css({'background':'#555','color':'#fff','border':'none','padding':'8px 12px','cursor':'pointer'}); | var $btnReject = $('<button>').text('TOLAK').css({'background':'#555','color':'#fff','border':'none','padding':'8px 12px','cursor':'pointer'}); | ||
// FUNGSI EKSEKUSI PROTEKSI | // FUNGSI EKSEKUSI PROTEKSI (Tetap menjaga sistem kirim pesan otomatis ke user) | ||
function executeProtect(level, levelName) { | function executeProtect(level, levelName) { | ||
var editRight = (level === 'sysop') ? 'sysop' : 'autoconfirmed'; | var editRight = (level === 'sysop') ? 'sysop' : 'autoconfirmed'; | ||
api.postWithToken('csrf', { | api.postWithToken('csrf', { | ||
action: 'protect', | action: 'protect', | ||
title: filePage, | title: filePage, | ||
protections: 'edit=' + editRight + '|move=' + editRight, | protections: 'edit=' + editRight + '|move=' + editRight, | ||
expiry: | expiry: 'infinite', | ||
reason: 'Permintaan disetujui: ' + levelName | reason: 'Permintaan disetujui: ' + levelName | ||
}).done(function() { | }).done(function() { | ||
api.get({ action: 'query', prop: 'revisions', titles: pageName, rvprop: 'content' }).done(function(res) { | api.get({ action: 'query', prop: 'revisions', titles: pageName, rvprop: 'content' }).done(function(res) { | ||
var content = res.query.pages[Object.keys(res.query.pages)[0]].revisions[0]['*']; | var content = res.query.pages[Object.keys(res.query.pages)[0]].revisions[0]['*']; | ||
| Baris 712: | Baris 728: | ||
api.postWithToken('edit', { action: 'edit', title: pageName, text: newText, summary: 'Status: Protection Granted' }).done(function() { | api.postWithToken('edit', { action: 'edit', title: pageName, text: newText, summary: 'Status: Protection Granted' }).done(function() { | ||
// | // FITUR OTOMATIS KIRIM PESAN (TIDAK DIBUANG) | ||
var msg = "\n== Notifikasi Perlindungan ==\nHalo [[" + requester + "]], permohonan perlindungan untuk [[:" + filePage + "]] telah '''DISETUJUI''' dengan tingkat '''" + levelName + "'''. --[[Pengguna:Admin|Admin]] ([[Pembicaraan Pengguna:Admin|bicara]]) 10 April 2026 17. | var msg = "\n== Notifikasi Perlindungan ==\nHalo [[" + requester + "]], permohonan perlindungan untuk [[:" + filePage + "]] telah '''DISETUJUI''' dengan tingkat '''" + levelName + "'''. --[[Pengguna:Admin|Admin]] ([[Pembicaraan Pengguna:Admin|bicara]]) 10 April 2026 17.37 (UTC)"; | ||
api.postWithToken('edit', { action: 'edit', title: "Pembicaraan_Pengguna:" + requester, section: 'new', text: msg }).done(function() { | api.postWithToken('edit', { action: 'edit', title: "Pembicaraan_Pengguna:" + requester, section: 'new', text: msg }).done(function() { | ||
location.reload(); | location.reload(); | ||
| Baris 731: | Baris 747: | ||
var newText = content.replace("Status: 🕒 Sedang diajukan", "Status: ❌ '''Ditolak'''\n\n''Alasan: " + alasan + "''"); | var newText = content.replace("Status: 🕒 Sedang diajukan", "Status: ❌ '''Ditolak'''\n\n''Alasan: " + alasan + "''"); | ||
api.postWithToken('edit', { action: 'edit', title: pageName, text: newText, summary: 'Status: Protection Rejected' }).done(function() { | api.postWithToken('edit', { action: 'edit', title: pageName, text: newText, summary: 'Status: Protection Rejected' }).done(function() { | ||
var msg = "\n== Notifikasi Perlindungan ==\nHalo [[" + requester + "]], permohonan perlindungan untuk [[:" + filePage + "]] '''DITOLAK''' karena: ''" + alasan + "''. --[[Pengguna:Admin|Admin]] ([[Pembicaraan Pengguna:Admin|bicara]]) 10 April 2026 17. | // FITUR OTOMATIS KIRIM PESAN PENOLAKAN | ||
var msg = "\n== Notifikasi Perlindungan ==\nHalo [[" + requester + "]], permohonan perlindungan untuk [[:" + filePage + "]] '''DITOLAK''' karena: ''" + alasan + "''. --[[Pengguna:Admin|Admin]] ([[Pembicaraan Pengguna:Admin|bicara]]) 10 April 2026 17.37 (UTC)"; | |||
api.postWithToken('edit', { action: 'edit', title: "Pembicaraan_Pengguna:" + requester, section: 'new', text: msg }).done(function() { | api.postWithToken('edit', { action: 'edit', title: "Pembicaraan_Pengguna:" + requester, section: 'new', text: msg }).done(function() { | ||
location.reload(); | location.reload(); | ||