MediaWiki:Common.js: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 668: | Строка 668: | ||
newContainer.innerHTML = parsedHTML; | newContainer.innerHTML = parsedHTML; | ||
placeholder.replaceWith(newContainer); | placeholder.replaceWith(newContainer); | ||
var scripts = Array.prototype.slice.call(newContainer.querySelectorAll("script")); | |||
scripts.forEach(function (scr) { | |||
var parent = scr.parentNode; | |||
var scriptNode = document.createElement("script"); | |||
if (scr.src) { | |||
scriptNode.src = scr.src; | |||
if (scr.defer) scriptNode.defer = true; | |||
if (scr.async) scriptNode.async = true; | |||
parent.replaceChild(scriptNode, scr); | |||
} else { | |||
try { | |||
$.globalEval(scr.textContent || scr.innerText || ""); | |||
} catch (e) { | |||
console.warn("Ошибка при исполнении inline-скрипта:", e); | |||
} | |||
parent.removeChild(scr); | |||
} | |||
}); | |||
mw.loader.using(['jquery.tablesorter', 'jquery.makeCollapsible'], function () { | mw.loader.using(['jquery.tablesorter', 'jquery.makeCollapsible'], function () { | ||
| Строка 673: | Строка 692: | ||
$(newContainer).find('.mw-collapsible').makeCollapsible(); | $(newContainer).find('.mw-collapsible').makeCollapsible(); | ||
}); | }); | ||
mw.hook('wikipage.content').fire(newContainer); | |||
} else { | } else { | ||