MediaWiki:Common.js: различия между версиями

Нет описания правки
Нет описания правки
Строка 1069: Строка 1069:
function stripProjectSelectionTemplate(text) {
function stripProjectSelectionTemplate(text) {
return String(text || '').replace(/\{\{\s*переключатель проекта\b[\s\S]*?\}\}/ig, '');
return String(text || '').replace(/\{\{\s*переключатель проекта\b[\s\S]*?\}\}/ig, '');
}
function injectJsonPathIntoAjax(text) {
return String(text || '').replace(
/(\{\{\s*ajax\s*\|\s*)(?!\{\{\s*#var\s*:\s*JsonPath\s*\}\})(<nowiki>)/ig,
'$1{{#var:JsonPath}}$2'
);
}
}


function buildWikitext(text, projectName) {
function buildWikitext(text, projectName) {
return '{{#vardefine:JsonPath|' + projectName + '}}\n' + stripProjectSelectionTemplate(text);
var preparedText = stripProjectSelectionTemplate(text);
preparedText = injectJsonPathIntoAjax(preparedText);
 
return '{{#vardefine:JsonPath|' + projectName + '}}\n' + preparedText;
}
}