MediaWiki:Common.js: Revizyonlar arasındaki fark
MediaWiki arayüz sayfası
More actions
C. Karakuş (mesaj | katkılar) Değişiklik özeti yok |
C. Karakuş (mesaj | katkılar) Değişiklik özeti yok |
||
| 1. satır: | 1. satır: | ||
// ========================================== | // ========================================================================== | ||
// KIZILBASHICA BİRLEŞİK | // KIZILBASHICA NİHAİ BİRLEŞİK JAVASCRIPT DOSYASI | ||
// ========================================== | // ========================================================================== | ||
$(document).ready(function() { | $(document).ready(function() { | ||
var ns = mw.config.get('wgNamespaceNumber'); | var ns = mw.config.get('wgNamespaceNumber'); | ||
var pageName = mw.config.get('wgTitle'); | var pageName = mw.config.get('wgTitle'); | ||
var baseUrl = mw.config.get('wgArticlePath') || '/wiki/$1'; | |||
// | // ---------------------------------------------------------------------- | ||
// 1. TARTIŞMA LİNKLERİNİ "KAYNAK" ALANINA YÖNLENDİRME | |||
// ---------------------------------------------------------------------- | |||
if (ns === 0) { | if (ns === 0) { | ||
// | // Üst bar, mobil menü ve yan drawer'daki tüm Tartışma linklerini hedefler | ||
$('a[href*="Tart%C4%B1%C5%9Fma:"], a[href*="Talk:"]').each(function() { | $('a[href*="Tart%C4%B1%C5%9Fma:"], a[href*="Talk:"]').each(function() { | ||
$(this).attr('href', baseUrl.replace('$1', 'Kaynak:' + encodeURIComponent(pageName))); | $(this).attr('href', baseUrl.replace('$1', 'Kaynak:' + encodeURIComponent(pageName))); | ||
}); | }); | ||
} | |||
// ---------------------------------------------------------------------- | |||
// 2. KAYNAK AD ALANINDA (ID: 3000) ŞABLONU TAM OTOMATİK ÇALIŞTIRMA (2. YÖNTEM) | |||
// ---------------------------------------------------------------------- | |||
if (ns === 3000) { | |||
// Eğer sayfa henüz oluşturulmadıysa veya veritabanında boşsa | |||
if ($('.noarticletext').length > 0 || $('.mw-noarticletext').length > 0 || mw.config.get('wgArticleId') === 0) { | |||
// Standart "Bu sayfada metin yok" uyarısını gizle | |||
$('.noarticletext, .mw-noarticletext').hide(); | |||
var container = $('#mw-content-text'); | |||
container.html('<div id="loading-cite" style="color: var(--kb-text-sub); font-style: italic; padding: 10px;">Kaynak arayüzü yükleniyor...</div>'); | |||
// MediaWiki API ile Şablon:AlıntıYap'ı o maddeye özel dinamik olarak render et | |||
$.ajax({ | |||
url: mw.util.wikiScript('api'), | |||
data: { | |||
action: 'parse', | |||
text: '{{AlıntıYap|madde=' + pageName + '}}', | |||
contentmodel: 'wikitext', | |||
format: 'json' | |||
}, | |||
success: function(data) { | |||
if (data && data.parse && data.parse.text) { | |||
container.html(data.parse.text['*']); | |||
} else { | |||
container.html('<p>Kaynak şablonu yüklenirken bir hata oluştu.</p>'); | |||
} | |||
}, | |||
error: function() { | |||
container.html('<p>Kaynak şablonu API bağlantısı kurulamadı.</p>'); | |||
} | |||
}); | |||
} | |||
} | } | ||
}); | }); | ||
// ---------------------------------------------------------------------- | |||
// 3. DİNAMİK ELEMENT GÖZLEMCİSİ (MUTATION OBSERVER) | |||
// (Komut Paleti Türkçeleştirme + Menü Düzeltme + Zar Butonu Entegrasyonu) | |||
// ---------------------------------------------------------------------- | |||
const observer = new MutationObserver((mutations) => { | const observer = new MutationObserver((mutations) => { | ||
mutations.forEach((mutation) => { | mutations.forEach((mutation) => { | ||
// | // A. GENEL MENÜ TÜRKÇELEŞTİRME | ||
const menuHeadings = document.querySelectorAll('.citizen-menu__heading'); | const menuHeadings = document.querySelectorAll('.citizen-menu__heading'); | ||
menuHeadings.forEach(heading => { | menuHeadings.forEach(heading => { | ||
| 31. satır: | 69. satır: | ||
}); | }); | ||
// | // B. KOMUT PALETİ İŞLEMLERİ | ||
const palette = document.querySelector('.citizen-command-palette'); | const palette = document.querySelector('.citizen-command-palette'); | ||
if (palette) { | if (palette) { | ||
// RASTGELE SAYFA (ZAR) BUTONU EKLEME | |||
const inputArea = palette.querySelector('.citizen-command-palette-header__input-area'); | const inputArea = palette.querySelector('.citizen-command-palette-header__input-area'); | ||
const customBtnCheck = palette.querySelector('#citizen-custom-random-btn'); | const customBtnCheck = palette.querySelector('#citizen-custom-random-btn'); | ||
| 44. satır: | 81. satır: | ||
randomBtn.id = 'citizen-custom-random-btn'; | randomBtn.id = 'citizen-custom-random-btn'; | ||
randomBtn.title = 'Rastgele Sayfa Getir'; | randomBtn.title = 'Rastgele Sayfa Getir'; | ||
// İstediğiniz orijinal Wikimedia zar ikonu | |||
randomBtn.innerHTML = '<span class="citizen-ui-icon mw-ui-icon-wikimedia-die"></span>'; | randomBtn.innerHTML = '<span class="citizen-ui-icon mw-ui-icon-wikimedia-die"></span>'; | ||
randomBtn.addEventListener('click', function() { | randomBtn.addEventListener('click', function() { | ||
const | const randomUrl = mw.config.get('wgArticlePath') || '/wiki/$1'; | ||
window.location.href = | window.location.href = randomUrl.replace('$1', 'Özel:Rastgele'); | ||
}); | }); | ||
| 54. satır: | 93. satır: | ||
} | } | ||
// | // PALET İÇİ TÜRKÇELEŞTİRMELER | ||
// | // 1. "Recent" Başlığı | ||
const allElements = palette.querySelectorAll('*'); | const allElements = palette.querySelectorAll('*'); | ||
allElements.forEach(el => { | allElements.forEach(el => { | ||
| 64. satır: | 102. satır: | ||
}); | }); | ||
// 2. "Page" ve "Action" Rozetleri | |||
const badges = palette.querySelectorAll('[class*="badge"], [class*="item-badge"], .citizen-command-palette__item-badge'); | const badges = palette.querySelectorAll('[class*="badge"], [class*="item-badge"], .citizen-command-palette__item-badge'); | ||
badges.forEach(badge => { | badges.forEach(badge => { | ||
const text = badge.textContent.trim(); | const text = badge.textContent.trim(); | ||
if (text === 'Page') badge.innerHTML = 'Sayfa'; | if (text === 'Page') { | ||
else if (text === 'Action') badge.innerHTML = 'Eylem'; | badge.innerHTML = 'Sayfa'; | ||
} else if (text === 'Action') { | |||
badge.innerHTML = 'Eylem'; | |||
} | |||
}); | }); | ||
// 3. "Create or edit page" Açıklamaları | |||
const descriptions = palette.querySelectorAll('[class*="description"], [class*="item-description"]'); | const descriptions = palette.querySelectorAll('[class*="description"], [class*="item-description"]'); | ||
descriptions.forEach(desc => { | descriptions.forEach(desc => { | ||
| 78. satır: | 121. satır: | ||
}); | }); | ||
// 4. Değişken Alt Footer Notları (Tüm Varyasyonlar) | |||
const note = palette.querySelector('[class*="footer-note"]'); | const note = palette.querySelector('[class*="footer-note"]'); | ||
if (note) { | if (note) { | ||
| 92. satır: | 136. satır: | ||
} | } | ||
// 5. Klavye İpuçları (Seç, Gezin, Eylemler, Kapat) | |||
const hints = palette.querySelectorAll('[class*="keyboard-hint"]'); | const hints = palette.querySelectorAll('[class*="keyboard-hint"]'); | ||
hints.forEach(hint => { | hints.forEach(hint => { | ||
| 107. satır: | 152. satır: | ||
}); | }); | ||
// Dinamik sayfa hareketlerini sürekli olarak izlemeye al | |||
observer.observe(document.body, { childList: true, subtree: true }); | observer.observe(document.body, { childList: true, subtree: true }); | ||
11.09, 7 Temmuz 2026 tarihindeki hâli
// ==========================================================================
// KIZILBASHICA NİHAİ BİRLEŞİK JAVASCRIPT DOSYASI
// ==========================================================================
$(document).ready(function() {
var ns = mw.config.get('wgNamespaceNumber');
var pageName = mw.config.get('wgTitle');
var baseUrl = mw.config.get('wgArticlePath') || '/wiki/$1';
// ----------------------------------------------------------------------
// 1. TARTIŞMA LİNKLERİNİ "KAYNAK" ALANINA YÖNLENDİRME
// ----------------------------------------------------------------------
if (ns === 0) {
// Üst bar, mobil menü ve yan drawer'daki tüm Tartışma linklerini hedefler
$('a[href*="Tart%C4%B1%C5%9Fma:"], a[href*="Talk:"]').each(function() {
$(this).attr('href', baseUrl.replace('$1', 'Kaynak:' + encodeURIComponent(pageName)));
});
}
// ----------------------------------------------------------------------
// 2. KAYNAK AD ALANINDA (ID: 3000) ŞABLONU TAM OTOMATİK ÇALIŞTIRMA (2. YÖNTEM)
// ----------------------------------------------------------------------
if (ns === 3000) {
// Eğer sayfa henüz oluşturulmadıysa veya veritabanında boşsa
if ($('.noarticletext').length > 0 || $('.mw-noarticletext').length > 0 || mw.config.get('wgArticleId') === 0) {
// Standart "Bu sayfada metin yok" uyarısını gizle
$('.noarticletext, .mw-noarticletext').hide();
var container = $('#mw-content-text');
container.html('<div id="loading-cite" style="color: var(--kb-text-sub); font-style: italic; padding: 10px;">Kaynak arayüzü yükleniyor...</div>');
// MediaWiki API ile Şablon:AlıntıYap'ı o maddeye özel dinamik olarak render et
$.ajax({
url: mw.util.wikiScript('api'),
data: {
action: 'parse',
text: '{{AlıntıYap|madde=' + pageName + '}}',
contentmodel: 'wikitext',
format: 'json'
},
success: function(data) {
if (data && data.parse && data.parse.text) {
container.html(data.parse.text['*']);
} else {
container.html('<p>Kaynak şablonu yüklenirken bir hata oluştu.</p>');
}
},
error: function() {
container.html('<p>Kaynak şablonu API bağlantısı kurulamadı.</p>');
}
});
}
}
});
// ----------------------------------------------------------------------
// 3. DİNAMİK ELEMENT GÖZLEMCİSİ (MUTATION OBSERVER)
// (Komut Paleti Türkçeleştirme + Menü Düzeltme + Zar Butonu Entegrasyonu)
// ----------------------------------------------------------------------
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
// A. GENEL MENÜ TÜRKÇELEŞTİRME
const menuHeadings = document.querySelectorAll('.citizen-menu__heading');
menuHeadings.forEach(heading => {
if (heading.textContent.trim() === 'Last modified') {
heading.textContent = 'Son değişiklikler';
}
});
// B. KOMUT PALETİ İŞLEMLERİ
const palette = document.querySelector('.citizen-command-palette');
if (palette) {
// RASTGELE SAYFA (ZAR) BUTONU EKLEME
const inputArea = palette.querySelector('.citizen-command-palette-header__input-area');
const customBtnCheck = palette.querySelector('#citizen-custom-random-btn');
if (inputArea && !customBtnCheck) {
const randomBtn = document.createElement('div');
randomBtn.id = 'citizen-custom-random-btn';
randomBtn.title = 'Rastgele Sayfa Getir';
// İstediğiniz orijinal Wikimedia zar ikonu
randomBtn.innerHTML = '<span class="citizen-ui-icon mw-ui-icon-wikimedia-die"></span>';
randomBtn.addEventListener('click', function() {
const randomUrl = mw.config.get('wgArticlePath') || '/wiki/$1';
window.location.href = randomUrl.replace('$1', 'Özel:Rastgele');
});
inputArea.appendChild(randomBtn);
}
// PALET İÇİ TÜRKÇELEŞTİRMELER
// 1. "Recent" Başlığı
const allElements = palette.querySelectorAll('*');
allElements.forEach(el => {
if (el.childNodes.length === 1 && el.textContent.trim() === 'Recent') {
el.textContent = 'Son Aramalar';
}
});
// 2. "Page" ve "Action" Rozetleri
const badges = palette.querySelectorAll('[class*="badge"], [class*="item-badge"], .citizen-command-palette__item-badge');
badges.forEach(badge => {
const text = badge.textContent.trim();
if (text === 'Page') {
badge.innerHTML = 'Sayfa';
} else if (text === 'Action') {
badge.innerHTML = 'Eylem';
}
});
// 3. "Create or edit page" Açıklamaları
const descriptions = palette.querySelectorAll('[class*="description"], [class*="item-description"]');
descriptions.forEach(desc => {
if (desc.textContent.trim() === 'Create or edit page') {
desc.textContent = 'Sayfa oluştur veya düzenle';
}
});
// 4. Değişken Alt Footer Notları (Tüm Varyasyonlar)
const note = palette.querySelector('[class*="footer-note"]');
if (note) {
const noteHTML = note.innerHTML;
if (noteHTML.includes('for all commands') || noteHTML.includes('all commands')) {
note.innerHTML = 'Tüm komutlar için <code>/</code> yazın';
} else if (noteHTML.includes('for namespace') || noteHTML.includes('namespace')) {
note.innerHTML = 'Ad alanlarında aramak için <code>:</code> yazın';
} else if (noteHTML.includes('to search for users') || noteHTML.includes('for users')) {
note.innerHTML = 'Kullanıcıları aramak için <code>@</code> yazın';
} else if (noteHTML.includes('to search for templates') || noteHTML.includes('for templates')) {
note.innerHTML = 'Şablonları aramak için <code>{{</code> yazın';
}
}
// 5. Klavye İpuçları (Seç, Gezin, Eylemler, Kapat)
const hints = palette.querySelectorAll('[class*="keyboard-hint"]');
hints.forEach(hint => {
const label = hint.querySelector('[class*="label"]');
if (label) {
const text = label.textContent.trim();
if (text === 'Select') label.textContent = 'Seç';
else if (text === 'Navigate') label.textContent = 'Gezin';
else if (text === 'Actions') label.textContent = 'Eylemler';
else if (text === 'Close') label.textContent = 'Kapat';
}
});
}
});
});
// Dinamik sayfa hareketlerini sürekli olarak izlemeye al
observer.observe(document.body, { childList: true, subtree: true });