MediaWiki:Common.js:修订间差异

MediaWiki系统消息页面
(创建页面,内容为“→‎这里的任何JavaScript将为所有用户在每次页面加载时加载。:​ →‎SimpleMathJax支持预览设置:​ function waitForMathJax($content) { if (typeof MathJax === 'undefined') { setTimeout(function () { waitForMathJax($content); }, 1000); } else { MathJax.Hub.Queue(["Typeset", MathJax.Hub, $content[0]]).execute(); } } mw.hook('wikipage.content').add(waitForMathJax);”
 
无编辑摘要
标签已被回退
第11行: 第11行:


mw.hook('wikipage.content').add(waitForMathJax);
mw.hook('wikipage.content').add(waitForMathJax);
{
const scrollTextLists = document.querySelectorAll('.scroll-text-list>ul');
setInterval(function() {
for (var i = 0; i < scrollTextLists.length; ++i) {
(function() {
var list = scrollTextLists[i];
if (list.children.length < 2) {
return;
}
var repeat = 5;
var scrollBehavior = setInterval(function() {
if (repeat === 0) {
list.appendChild(list.firstElementChild);
list.style.marginTop = '0px';
clearInterval(scrollBehavior);
return;
}
--repeat
list.style.marginTop = (repeat - 5) * 5 + 'px';
}, 40)
})();
}
}, 2000);
}

2023年7月19日 (三) 20:56的版本

/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */

/* SimpleMathJax支持预览设置 */
function waitForMathJax($content) {
  if (typeof MathJax === 'undefined') {
    setTimeout(function () { waitForMathJax($content); }, 1000);
  } else {
    MathJax.Hub.Queue(["Typeset", MathJax.Hub, $content[0]]).execute();
  }
}

mw.hook('wikipage.content').add(waitForMathJax);

{
	const scrollTextLists = document.querySelectorAll('.scroll-text-list>ul');
	setInterval(function() {
		for (var i = 0; i < scrollTextLists.length; ++i) {
			(function() {
				var list = scrollTextLists[i];
				if (list.children.length < 2) {
					return;
				}
				var repeat = 5;
				var scrollBehavior = setInterval(function() {
					if (repeat === 0) {
						list.appendChild(list.firstElementChild);
						list.style.marginTop = '0px';
						clearInterval(scrollBehavior);
						return;
					}
					--repeat
					list.style.marginTop = (repeat - 5) * 5 + 'px';
				}, 40)
			})();
		}
	}, 2000);
}