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 336: | Baris 336: | ||
/* ========================================================== | /* ========================================================== | ||
🚀 MIPPEDIA DATA - CONTENT GUARD ( | 🚀 MIPPEDIA DATA - CONTENT GUARD (REVISI FINAL) | ||
========================================================== */ | ========================================================== */ | ||
(function() { | (function() { | ||
function isEditMode() { | |||
// Cek apakah ada elemen editor di layar | |||
return $('#wpTextbox1, .editor-container textarea, textarea.mw-ui-input').length > 0; | |||
} | |||
function isContentValid() { | function isContentValid() { | ||
var ns = mw.config.get('wgNamespaceNumber'); | var ns = mw.config.get('wgNamespaceNumber'); | ||
if (ns !== 0) return true; | if (ns !== 0) return true; | ||
var content = $('#wpTextbox1, .editor-container textarea, textarea.mw-ui-input').val() || ""; | var content = $('#wpTextbox1, .editor-container textarea, textarea.mw-ui-input').val() || ""; | ||
return content.includes('{{Infobox'); | return content.includes('{{Infobox'); | ||
} | } | ||
function handleBlock(e) { | function handleBlock(e) { | ||
if (!isContentValid()) { | // CUMA CEGAH JIKA: Kita bener-bener lagi di mode edit | ||
if (isEditMode() && !isContentValid()) { | |||
e.preventDefault(); | e.preventDefault(); | ||
e.stopPropagation(); | e.stopPropagation(); | ||
| Baris 362: | Baris 364: | ||
} | } | ||
// | // 1. Tangkap klik tombol simpan (hanya jika di mode edit) | ||
$(document).on('click mousedown touchstart', | $(document).on('click mousedown touchstart', | ||
'#wpSave | '#wpSave, .editor-save, .mw-ui-button.primary, button[type="submit"].save-button', | ||
function(e) { | function(e) { | ||
return handleBlock(e); | return handleBlock(e); | ||
| Baris 371: | Baris 372: | ||
); | ); | ||
// | // 2. Intersepsi submit form (hanya jika di mode edit) | ||
window.addEventListener('submit', function(e) { | window.addEventListener('submit', function(e) { | ||
if (!isContentValid()) { | if (isEditMode() && !isContentValid()) { | ||
handleBlock(e); | handleBlock(e); | ||
} | } | ||
}, true | }, true); | ||
console.log("Mippedia Guard: | console.log("Mippedia Guard: Smart Mode Aktif (Hanya siaga di editor)"); | ||
})(); | })(); | ||