MediaWiki:Common.js: различия между версиями
Pok (обсуждение | вклад) Нет описания правки |
Pok (обсуждение | вклад) Нет описания правки |
||
| Строка 1075: | Строка 1075: | ||
} | } | ||
function refreshForProject(projectName | function refreshForProject(projectName) { | ||
var root = getContentRoot(); | var root = getContentRoot(); | ||
if (!root) return; | if (!root) return; | ||
var placeholder = createPlaceholderWithSpinner(); | var placeholder = createPlaceholderWithSpinner(); | ||
root.innerHTML = ''; | root.innerHTML = ''; | ||
root.appendChild(placeholder); | root.appendChild(placeholder); | ||
getPageWikitext() | getPageWikitext() | ||
.then(function (sourceText) { | .then(function (sourceText) { | ||
var wikitext = buildWikitext(sourceText, projectName); | var wikitext = buildWikitext(sourceText, projectName); | ||
return parseAndInjectWikiText(wikitext, { | return parseAndInjectWikiText(wikitext, { | ||
placeholder: placeholder, | placeholder: placeholder, | ||
targetRoot: root | targetRoot: root | ||
}); | }); | ||
}) | }) | ||
.fail(function () { | .fail(function () { | ||
placeholder.textContent = | placeholder.textContent = 'Ошибка загрузки страницы.'; | ||
}); | }); | ||
} | } | ||
| Строка 1150: | Строка 1144: | ||
} | } | ||
var portletList = document.querySelector('#mw-content .mw-portlet-body ul') | var portletList = document.querySelector('#mw-content .mw-portlet-body ul'); | ||
if (portletList) { | if (portletList) { | ||
portletList.appendChild(form); | portletList.appendChild(form); | ||
| Строка 1156: | Строка 1150: | ||
(function (menuNode) { | (function (menuNode) { | ||
var | menuNode.addEventListener('change', function (event) { | ||
var target = event.target; | |||
if (!target || target.tagName !== 'INPUT') return; | |||
if (target.type !== 'radio') return; | |||
if (target.name !== 'js-project-selection') return; | |||
if (!target.checked) return; | |||
})( | refreshForProject(target.value); | ||
}); | |||
})(form); | |||
} | } | ||
} | } | ||