MediaWiki:Common.js:修订间差异
MediaWiki界面页面
更多操作
无编辑摘要 |
无编辑摘要 |
||
| 第37行: | 第37行: | ||
var total = (data.query.statistics['cirrussearch-article-words'] || 0); | var total = (data.query.statistics['cirrussearch-article-words'] || 0); | ||
// | // 缓动函数(ease-out):前快后慢 | ||
function easeOutQuad(t) { | |||
function easeOutQuad(t) { | |||
return t * (2 - t); | return t * (2 - t); | ||
} | } | ||
function | var duration = 2000; // 动画总时长 | ||
var startTime = null; | |||
function animate(timestamp) { | |||
if (!startTime) startTime = timestamp; | if (!startTime) startTime = timestamp; | ||
var | var time = timestamp - startTime; | ||
var progress = Math.min( | var progress = Math.min(time / duration, 1); | ||
var eased = easeOutQuad(progress); | var eased = easeOutQuad(progress); | ||
var | var currentVal = Math.floor(eased * total); | ||
$el.text( | $el.text(currentVal.toLocaleString()); | ||
if (progress < 1) { | if (progress < 1) { | ||
requestAnimationFrame(animate); | |||
requestAnimationFrame( | |||
} | } | ||
} | } | ||
requestAnimationFrame( | requestAnimationFrame(animate); | ||
}).fail(function () { | }).fail(function () { | ||
console.error('字数统计 API 请求失败'); | console.error('字数统计 API 请求失败'); | ||
2026年1月17日 (六) 16:40的版本
//Microsoft 和 Google 分析
document.head.insertAdjacentHTML('beforeend',`
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-GVZPTSXG1H"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-GVZPTSXG1H');
</script>
`);
document.head.insertAdjacentHTML('beforeend',`
<script type="text/javascript">
(function(c,l,a,r,i,t,y){
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window, document, "clarity", "script", "uewoetn0au");
</script>
`);
document.head.insertAdjacentHTML('beforeend',`
<meta name="baidu-site-verification" content="codeva-38vNyP0io6" />
`);
mw.loader.using(['mediawiki.util', 'mediawiki.api']).then(function () {
$(function () {
var $el = $('#wiki-wordcount-number');
if (!$el.length) return;
new mw.Api().get({
action: 'query',
meta: 'siteinfo',
siprop: 'statistics',
format: 'json'
}).done(function (data) {
var total = (data.query.statistics['cirrussearch-article-words'] || 0);
// 缓动函数(ease-out):前快后慢
function easeOutQuad(t) {
return t * (2 - t);
}
var duration = 2000; // 动画总时长
var startTime = null;
function animate(timestamp) {
if (!startTime) startTime = timestamp;
var time = timestamp - startTime;
var progress = Math.min(time / duration, 1);
var eased = easeOutQuad(progress);
var currentVal = Math.floor(eased * total);
$el.text(currentVal.toLocaleString());
if (progress < 1) {
requestAnimationFrame(animate);
}
}
requestAnimationFrame(animate);
}).fail(function () {
console.error('字数统计 API 请求失败');
});
});
});