MediaWiki:Common.js: Revizyonlar arasındaki fark
Gezinti kısmına atla
Arama kısmına atla
Değişiklik özeti yok Etiket: Geri alındı |
Değişiklik özeti yok Etiket: Geri alındı |
||
| 1. satır: | 1. satır: | ||
mw. | (function() { | ||
if (mw.config.get('wgNamespaceNumber') < 0) return; // Özel: ve Dosya: vb. sayfalarda çalışmaz | |||
if (mw.config.get('wgTitle') === 'Anasayfa') return; // Anasayfa hariç | |||
if (mw.config.get('wgNamespaceNumber') !== 0) return; // Wiki sayfası değilse çık | |||
const currentUser = mw.config.get('wgUserName'); | |||
const pageTitle = mw.config.get('wgPageName'); | |||
// | function countWords(text) { | ||
return text.trim().split(/\s+/).length; | |||
} | |||
function countCompoundWords(text) { | |||
return (text.match(/\b\w{2,}\w+\b/g) || []).length; | |||
} | |||
function hasImages() { | |||
return document.querySelectorAll('img').length > 0; | |||
} | |||
function showTemplate(templateName, container=document.body) { | |||
const div = document.createElement('div'); | |||
div.style.cssText = 'border:2px solid #ff6600; background-color:#fff3e6; padding:10px; border-radius:8px; font-weight:bold; color:#333; margin:10px 0;'; | |||
if(templateName === 'Gelismeli') div.textContent = 'Bu sayfa yeterince geliştirilmemiştir. Lütfen içerik ekleyin!'; | |||
if(templateName === 'Tecrübesiz') div.textContent = 'Bu kullanıcı tecrübesiz bir düzenleyicidir. Lütfen katkılarını gözden geçirin.'; | |||
if(templateName === 'Hosgeldin') div.textContent = 'Hoşgeldin! Anasayfanı ve diğer sayfaları kontrol ederek katkıda bulunabilirsin.'; | |||
container.prepend(div); | |||
} | |||
function checkPage() { | |||
const contentEl = document.querySelector('#mw-content-text'); | |||
if(!contentEl) return; | |||
const text = contentEl.innerText || ''; | |||
if(countWords(text) < 3 || countCompoundWords(text) < 3 || !hasImages()) { | |||
showTemplate('Gelismeli'); | |||
// Kullanıcının sayfaları sayılacak (örnek: MediaWiki API kullan) | |||
fetch(`/api.php?action=query&list=allpages&apprefix=User:${currentUser}&format=json`) | |||
.then(res => res.json()) | |||
.then(data => { | |||
const userPages = data.query.allpages || []; | |||
} | let countGelismeli = 0; | ||
userPages.forEach(p => { | |||
// Burada gerçek kontroller için API ile pagecontent alınabilir | |||
if(true) countGelismeli++; // örnek olarak hepsini say | |||
}); | |||
if(countGelismeli >= 5) { | |||
showTemplate('Tecrübesiz'); | |||
showTemplate('Hosgeldin'); | |||
} | |||
}); | |||
} | |||
} | |||
checkPage(); | |||
})(); | |||
14.20, 8 Şubat 2026 tarihindeki hâli
(function() {
if (mw.config.get('wgNamespaceNumber') < 0) return; // Özel: ve Dosya: vb. sayfalarda çalışmaz
if (mw.config.get('wgTitle') === 'Anasayfa') return; // Anasayfa hariç
if (mw.config.get('wgNamespaceNumber') !== 0) return; // Wiki sayfası değilse çık
const currentUser = mw.config.get('wgUserName');
const pageTitle = mw.config.get('wgPageName');
function countWords(text) {
return text.trim().split(/\s+/).length;
}
function countCompoundWords(text) {
return (text.match(/\b\w{2,}\w+\b/g) || []).length;
}
function hasImages() {
return document.querySelectorAll('img').length > 0;
}
function showTemplate(templateName, container=document.body) {
const div = document.createElement('div');
div.style.cssText = 'border:2px solid #ff6600; background-color:#fff3e6; padding:10px; border-radius:8px; font-weight:bold; color:#333; margin:10px 0;';
if(templateName === 'Gelismeli') div.textContent = 'Bu sayfa yeterince geliştirilmemiştir. Lütfen içerik ekleyin!';
if(templateName === 'Tecrübesiz') div.textContent = 'Bu kullanıcı tecrübesiz bir düzenleyicidir. Lütfen katkılarını gözden geçirin.';
if(templateName === 'Hosgeldin') div.textContent = 'Hoşgeldin! Anasayfanı ve diğer sayfaları kontrol ederek katkıda bulunabilirsin.';
container.prepend(div);
}
function checkPage() {
const contentEl = document.querySelector('#mw-content-text');
if(!contentEl) return;
const text = contentEl.innerText || '';
if(countWords(text) < 3 || countCompoundWords(text) < 3 || !hasImages()) {
showTemplate('Gelismeli');
// Kullanıcının sayfaları sayılacak (örnek: MediaWiki API kullan)
fetch(`/api.php?action=query&list=allpages&apprefix=User:${currentUser}&format=json`)
.then(res => res.json())
.then(data => {
const userPages = data.query.allpages || [];
let countGelismeli = 0;
userPages.forEach(p => {
// Burada gerçek kontroller için API ile pagecontent alınabilir
if(true) countGelismeli++; // örnek olarak hepsini say
});
if(countGelismeli >= 5) {
showTemplate('Tecrübesiz');
showTemplate('Hosgeldin');
}
});
}
}
checkPage();
})();