MediaWiki:Common.js: различия между версиями
Pok (обсуждение | вклад) Нет описания правки |
Pok (обсуждение | вклад) Нет описания правки |
||
| Строка 1074: | Строка 1074: | ||
function refreshForProject(projectName, menuNode) { | function refreshForProject(projectName, menuNode) { | ||
var root = getContentRoot(); | |||
if (!root) return; | |||
var loadingImgHTML = '<img alt="Файл:Silva-loading.gif" src="/images/4/45/Silva-loading.gif?20260316201152" decoding="async" width="16" height="16" style="vertical-align:middle;margin-right:6px">'; | |||
var placeholder = document.createElement("div"); | |||
placeholder.className = "ajax-load-placeholder"; | |||
placeholder.innerHTML = loadingImgHTML + '<span class="ajax-load-text">Загрузка...</span>'; | |||
root.innerHTML = ''; | |||
if (menuNode) { | |||
root.appendChild(menuNode); | |||
} | |||
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, { | ||
targetRoot: | placeholder: placeholder, | ||
targetRoot: root, | |||
keepNode: menuNode | keepNode: menuNode | ||
}); | }); | ||
}) | }) | ||
.fail(function () { | .fail(function () { | ||
placeholder.textContent = "Ошибка загрузки страницы."; | |||
}); | }); | ||
} | } | ||