MediaWiki:Gadget-blamefinder.js: различия между версиями
Ланселот (обсуждение | вклад) Нет описания правки |
Ланселот (обсуждение | вклад) Нет описания правки |
||
| Строка 25: | Строка 25: | ||
'use strict'; | 'use strict'; | ||
if (window.self !== window.top) { | if (window.self !== window.top) { | ||
console.log('BlameFinder: не запускаемся в iframe по соображениям безопасности'); | console.log('BlameFinder: не запускаемся в iframe по соображениям безопасности'); | ||
| Строка 31: | Строка 30: | ||
} | } | ||
var scriptPath = '/w'; | var scriptPath = '/w'; | ||
try { | try { | ||
| Строка 41: | Строка 39: | ||
} | } | ||
function escapeHtml(text) { | function escapeHtml(text) { | ||
if (text === undefined || text === null) return ''; | if (text === undefined || text === null) return ''; | ||
| Строка 64: | Строка 61: | ||
} | } | ||
function createSafeElement(tag, options) { | function createSafeElement(tag, options) { | ||
var element = document.createElement(tag); | var element = document.createElement(tag); | ||
| Строка 107: | Строка 103: | ||
} | } | ||
function createSafeLink(url, text, title) { | function createSafeLink(url, text, title) { | ||
var safeUrl = ''; | var safeUrl = ''; | ||
| Строка 132: | Строка 127: | ||
} | } | ||
function validateTitle(title) { | function validateTitle(title) { | ||
if (!title || typeof title !== 'string') return null; | if (!title || typeof title !== 'string') return null; | ||
var cleaned = title.replace(/[\x00-\x1F\x7F<>"']/g, '').trim(); | var cleaned = title.replace(/[\x00-\x1F\x7F<>"']/g, '').trim(); | ||
return cleaned.length > 0 ? cleaned : null; | return cleaned.length > 0 ? cleaned : null; | ||
} | } | ||
function isDarkTheme() { | function isDarkTheme() { | ||
try { | try { | ||
| Строка 153: | Строка 144: | ||
} | } | ||
function getPageInfo() { | function getPageInfo() { | ||
var title = null; | var title = null; | ||
| Строка 233: | Строка 223: | ||
} | } | ||
function cycApiRequest(params, callback, errorCallback) { | function cycApiRequest(params, callback, errorCallback) { | ||
var apiUrl = scriptPath + '/api.php'; | var apiUrl = scriptPath + '/api.php'; | ||
| Строка 318: | Строка 307: | ||
} | } | ||
var logPanel = null; | var logPanel = null; | ||
var logEntries = []; | var logEntries = []; | ||
| Строка 369: | Строка 357: | ||
var clearButton = createSafeElement('button', { | var clearButton = createSafeElement('button', { | ||
id: 'blame-clear', | id: 'blame-clear', | ||
className: 'blame-log-btn', | |||
text: 'Очистить', | text: 'Очистить', | ||
css: { | css: { | ||
| Строка 382: | Строка 371: | ||
var toggleButton = createSafeElement('button', { | var toggleButton = createSafeElement('button', { | ||
id: 'blame-toggle', | id: 'blame-toggle', | ||
className: 'blame-log-btn', | |||
text: 'Скрыть', | text: 'Скрыть', | ||
css: { | css: { | ||
| Строка 391: | Строка 381: | ||
} | } | ||
}); | }); | ||
['color', 'border-color'].forEach(function(prop) { | |||
clearButton.style.setProperty(prop, '#36c', 'important'); | |||
toggleButton.style.setProperty(prop, '#36c', 'important'); | |||
}); | |||
clearButton.style.setProperty('background', 'none', 'important'); | |||
toggleButton.style.setProperty('background', 'none', 'important'); | |||
buttonContainer.appendChild(clearButton); | buttonContainer.appendChild(clearButton); | ||
| Строка 465: | Строка 462: | ||
} | } | ||
function addButton() { | function addButton() { | ||
addLog('Инициализация BlameFinder для wiki.peresvet.artushak.ru', 'info'); | addLog('Инициализация BlameFinder для wiki.peresvet.artushak.ru', 'info'); | ||
| Строка 506: | Строка 502: | ||
} | } | ||
var selectionActive = false; | var selectionActive = false; | ||
var selectionTimer = null; | var selectionTimer = null; | ||
var selectionHandlers = {}; | var selectionHandlers = {}; | ||
function activateSelectionMode() { | function activateSelectionMode() { | ||
if (selectionActive) { | if (selectionActive) { | ||
| Строка 646: | Строка 640: | ||
} | } | ||
function findAuthor(text) { | function findAuthor(text) { | ||
var pageInfo = getPageInfo(); | var pageInfo = getPageInfo(); | ||
| Строка 853: | Строка 846: | ||
} | } | ||
function showResult(result) { | function showResult(result) { | ||
var rev = result.rev; | var rev = result.rev; | ||
| Строка 1048: | Строка 1040: | ||
} | } | ||
var pageInfo = getPageInfo(); | var pageInfo = getPageInfo(); | ||