MediaWiki:Common.js:修订间差异
来自Fuckrooms Wiki
无编辑摘要 |
无编辑摘要 |
||
| 第1行: | 第1行: | ||
(function() { | (function() { | ||
var style = document.createElement('style'); | var style = document.createElement('style'); | ||
style.textContent = '.snowflake { position: fixed; color: #fff; z-index: 9999; user-select: none; } @keyframes fall { 0% { transform: translateY(-100vh) rotate(0deg); } 100% { transform: translateY(100vh) rotate(720deg); } }'; | style.textContent = '.snowflake { position: fixed; color: #fff; z-index: 9999; user-select: none; } @keyframes fall { 0% { transform: translateY(-100vh) rotate(0deg); } 100% { transform: translateY(100vh) rotate(720deg); } }'; | ||
document.head.appendChild(style); | document.head.appendChild(style); | ||
var snowflakes = 35, | var snowflakes = 35, | ||
minSize = 5, | minSize = 5, | ||
| 第13行: | 第13行: | ||
characters = ['❄', '❅', '❆']; | characters = ['❄', '❅', '❆']; | ||
function createSnow() { | function createSnow() { | ||
for(var i = 0; i < snowflakes; i++) { | for(var i = 0; i < snowflakes; i++) { | ||
| 第20行: | 第20行: | ||
flake.textContent = characters[Math.floor(Math.random() * characters.length)]; | flake.textContent = characters[Math.floor(Math.random() * characters.length)]; | ||
flake.style.left = Math.random() * 100 + '%'; | flake.style.left = Math.random() * 100 + '%'; | ||
flake.style.fontSize = Math.random() * (maxSize - minSize) + minSize + 'px'; | flake.style.fontSize = Math.random() * (maxSize - minSize) + minSize + 'px'; | ||
| 第28行: | 第28行: | ||
document.body.appendChild(flake); | document.body.appendChild(flake); | ||
setInterval(function(f) { | setInterval(function(f) { | ||
f.style.transform = 'translateX(' + (Math.random() * 30 - 15) + 'px)'; | f.style.transform = 'translateX(' + (Math.random() * 30 - 15) + 'px)'; | ||
| 第35行: | 第35行: | ||
} | } | ||
window.addEventListener('load', function() { | window.addEventListener('load', function() { | ||
createSnow(); | createSnow(); | ||
2025年4月14日 (一) 05:21的版本
(function() {
var style = document.createElement('style');
style.textContent = '.snowflake { position: fixed; color: #fff; z-index: 9999; user-select: none; } @keyframes fall { 0% { transform: translateY(-100vh) rotate(0deg); } 100% { transform: translateY(100vh) rotate(720deg); } }';
document.head.appendChild(style);
var snowflakes = 35,
minSize = 5,
maxSize = 15,
speed = 5,
characters = ['❄', '❅', '❆'];
function createSnow() {
for(var i = 0; i < snowflakes; i++) {
var flake = document.createElement('div');
flake.className = 'snowflake';
flake.textContent = characters[Math.floor(Math.random() * characters.length)];
flake.style.left = Math.random() * 100 + '%';
flake.style.fontSize = Math.random() * (maxSize - minSize) + minSize + 'px';
flake.style.animation = 'fall ' + (Math.random() * 5 + speed) + 's linear infinite';
flake.style.opacity = Math.random() * 0.5 + 0.5;
document.body.appendChild(flake);
setInterval(function(f) {
f.style.transform = 'translateX(' + (Math.random() * 30 - 15) + 'px)';
}, 2000, flake);
}
}
window.addEventListener('load', function() {
createSnow();
window.addEventListener('resize', function() {
document.querySelectorAll('.snowflake').forEach(function(f) {
f.style.left = Math.random() * 100 + '%';
});
});
});
})();