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 302: | Baris 302: | ||
/* ========================================================== | /* ========================================================== | ||
🚀 MIPPEDIA DATA - AUTO PRELOAD INFOBOX ( | 🚀 MIPPEDIA DATA - AUTO PRELOAD INFOBOX (UNIVERSAL) | ||
========================================================== */ | ========================================================== */ | ||
(function() { | (function() { | ||
function | function injectPreload() { | ||
var action = mw.config.get('wgAction'); | var action = mw.config.get('wgAction'); | ||
var ns = mw.config.get('wgNamespaceNumber'); | var ns = mw.config.get('wgNamespaceNumber'); | ||
var pageExists = mw.config.get('wgArticleId') > 0; | var pageExists = mw.config.get('wgArticleId') > 0; | ||
if ((action === 'edit' || action === 'submit') && ns === 0 && !pageExists) { | if ((action === 'edit' || action === 'submit') && ns === 0 && !pageExists) { | ||
// Gunakan interval untuk memantau kehadiran editor di mobile | |||
// | var retryLimit = 0; | ||
var checkEditor = setInterval(function() { | var checkEditor = setInterval(function() { | ||
var $textbox = $('#wpTextbox1'); | var $textbox = $('#wpTextbox1'); | ||
if ($textbox.length | if ($textbox.length && $textbox.val().trim() === "") { | ||
var pageName = mw.config.get('wgTitle'); | |||
$textbox.val('{{Infobox umum\n|nama = ' + pageName + '\n}}'); | |||
clearInterval(checkEditor); | |||
clearInterval(checkEditor); | |||
} | } | ||
if (++retryLimit > 20) clearInterval(checkEditor); // Stop setelah 10 detik | |||
}, 500); | }, 500); | ||
} | } | ||
} | } | ||
$(document).ready( | $(document).ready(injectPreload); | ||
// | // Jalankan lagi saat user switch editor di mobile | ||
$(window).on(' | $(window).on('hashchange focus click', injectPreload); | ||
})(); | })(); | ||
/* ========================================================== | /* ========================================================== | ||
🚀 MIPPEDIA DATA - CONTENT GUARD ( | 🚀 MIPPEDIA DATA - CONTENT GUARD (ULTRA STRICT) | ||
========================================================== */ | ========================================================== */ | ||
(function() { | (function() { | ||
function | function showGuardNotif(msg) { | ||
$('.mip-guard-notif').remove(); | |||
$('<div class="mip-guard-notif" style="position:fixed; top:20px; left:50%; transform:translateX(-50%); width:90%; max-width:450px; background:#fff5f5; border-left:6px solid #f56565; padding:18px; z-index:99999; border-radius:12px; box-shadow:0 15px 35px rgba(0,0,0,0.4); font-family:sans-serif; text-align:center; color:#742a2a; font-weight:bold;">' + | |||
'🚫 ' + msg + '<br><small style="font-weight:normal;">Klik kotak ini untuk menutup</small>' + | |||
'</div>').appendTo('body').click(function(){ $(this).remove(); }); | |||
} | |||
// Tangkap event submit secara agresif | |||
$(document).on('click mousedown touchstart', '#wpSave, #wpPreview, .editor-save, .mw-ui-button.primary', function(e) { | |||
var ns = mw.config.get('wgNamespaceNumber'); | var ns = mw.config.get('wgNamespaceNumber'); | ||
if (ns !== 0) return; | if (ns !== 0) return; | ||
var content = $('#wpTextbox1').val() || ""; | |||
// Cek keberadaan template Infobox | |||
if (!content.includes('{{Infobox')) { | |||
e.preventDefault(); | |||
e.stopPropagation(); | |||
e.stopImmediatePropagation(); // Matikan semua event lain | |||
showGuardNotif('FORMAT DITOLAK! Namespace Utama WAJIB menggunakan struktur {{Infobox}}. Teks biasa atau huruf asal dilarang.'); | |||
return false; | |||
} | } | ||
}); | |||
} | |||
})(); | })(); | ||