The editors' meeting has been canceled for technical reasons.

MediaWiki:Common.js:修订间差异

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

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

/* 这里的任何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';
    });
});
}