The editors' meeting has been canceled for technical reasons.

MediaWiki:Common.js:修订间差异

来自NeuroWiki
跳转到导航 跳转到搜索
无编辑摘要
标签已被回退
无编辑摘要
标签已被回退
第2行: 第2行:
// 检查当前页面是否为首页
// 检查当前页面是否为首页
if (mw.config.get('wgPageName') === '首页') {
if (mw.config.get('wgPageName') === '首页') {
    // 在指定页面上运行的JavaScript代码
// 在指定页面上运行的JavaScript代码
document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('DOMContentLoaded', function() {
    const div = document.querySelector('.rotating-div');
const div = document.querySelector('.rotating-div');
    if (!div) return;  // 确保元素存在
if (!div) return;  // 确保元素存在
 
    div.addEventListener('mousemove', (event) => {
div.addEventListener('mousemove', (event) => {
        const rect = div.getBoundingClientRect();
const rect = div.getBoundingClientRect();
        const x = event.clientX - rect.left - rect.width / 2;
const x = event.clientX - rect.left - rect.width / 2;
        const y = event.clientY - rect.top - rect.height / 2;
const y = event.clientY - rect.top - rect.height / 2;
       
        const maxAngle = 8;
const maxAngle = 8;
        const xAngle = (maxAngle * x) / (rect.width / 2);
const xAngle = (maxAngle * x) / (rect.width / 2);
        const yAngle = -(maxAngle * y) / (rect.height / 2);
const yAngle = -(maxAngle * y) / (rect.height / 2);
       
        const distance = Math.sqrt(x*x + y*y);
const distance = Math.sqrt(x*x + y*y);
        const maxDistance = Math.sqrt((rect.width / 2) ** 2 + (rect.height / 2) ** 2);
const maxDistance = Math.sqrt((rect.width / 2) ** 2 + (rect.height / 2) ** 2);
        const colorIntensity = Math.min(1, distance / maxDistance);
const colorIntensity = Math.min(1, distance / maxDistance);
        const colorValue = 153 + (102 * colorIntensity);
const colorValue = 153 + (102 * colorIntensity);
 
        div.style.transform = `rotateX(${yAngle}deg) rotateY(${xAngle}deg)`;
div.style.transform = `rotateX(${yAngle}deg) rotateY(${xAngle}deg)`;
        div.style.backgroundColor = `rgb(${colorValue}, ${colorValue}, ${colorValue})`;
div.style.backgroundColor = `rgb(${colorValue}, ${colorValue}, ${colorValue})`;
    });
});
 
    div.addEventListener('mouseleave', () => {
div.addEventListener('mouseleave', () => {
        div.style.transform = 'rotateX(0deg) rotateY(0deg)';
div.style.transform = 'rotateX(0deg) rotateY(0deg)';
        div.style.backgroundColor = '#999';
div.style.backgroundColor = '#999';
    });
});
});
});
}
}

2024年10月28日 (一) 22:01的版本

/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
// 检查当前页面是否为首页
if (mw.config.get('wgPageName') === '首页') {
	// 在指定页面上运行的JavaScript代码
	document.addEventListener('DOMContentLoaded', function() {
		const div = document.querySelector('.rotating-div');
		if (!div) return;  // 确保元素存在
	
		div.addEventListener('mousemove', (event) => {
			const rect = div.getBoundingClientRect();
			const x = event.clientX - rect.left - rect.width / 2;
			const y = event.clientY - rect.top - rect.height / 2;
			
			const maxAngle = 8;
			const xAngle = (maxAngle * x) / (rect.width / 2);
			const yAngle = -(maxAngle * y) / (rect.height / 2);
			
			const distance = Math.sqrt(x*x + y*y);
			const maxDistance = Math.sqrt((rect.width / 2) ** 2 + (rect.height / 2) ** 2);
			const colorIntensity = Math.min(1, distance / maxDistance);
			const colorValue = 153 + (102 * colorIntensity);
	
			div.style.transform = `rotateX(${yAngle}deg) rotateY(${xAngle}deg)`;
			div.style.backgroundColor = `rgb(${colorValue}, ${colorValue}, ${colorValue})`;
		});
	
		div.addEventListener('mouseleave', () => {
			div.style.transform = 'rotateX(0deg) rotateY(0deg)';
			div.style.backgroundColor = '#999';
		});
	});
}