MediaWiki:Test.js: различия между версиями

Страница интерфейса MediaWiki
Нет описания правки
Нет описания правки
Строка 1: Строка 1:
(function(){
(function () {
var canvas=document.createElement('canvas');
var words = {
canvas.style.position='fixed';
"властью": "#e74c3c",
canvas.style.left='0';
"ответственность": "#9b59b6",
canvas.style.top='0';
"Процедуры": "#2980b9",
canvas.style.width='100%';
"ядерный": "#f1c40f",
canvas.style.height='100%';
"диск": "#e67e22",
canvas.style.pointerEvents='none';
"станции": "#1abc9c",
canvas.style.zIndex='9999';
"ГСБ": "#2c3e50",
document.documentElement.appendChild(canvas);
"увольнение": "#c0392b",
var ctx=canvas.getContext('2d');
"офицера": "#16a085",
var w=0,h=0,flakes=[];
"банановая": "#d35400"
function resize(){w=canvas.width=window.innerWidth;h=canvas.height=window.innerHeight;initFlakes();}
};
function rand(a,b){return Math.random()*(b-a)+a;}
 
function initFlakes(){
 
flakes=[];
function colorize($content) {
var count=Math.max(30,Math.floor(w/30));
var html = $content.html();
for(var i=0;i<count;i++){
for (var word in words) {
flakes.push({
if (!words.hasOwnProperty(word)) continue;
x:rand(0,w),
var color = words[word];
y:rand(-h, h),
var re = new RegExp("\\b(" + word + ")\\b", "g");
r:rand(0.8,2.6),
html = html.replace(re, '<span style="color:' + color + '; font-weight:600;">$1</span>');
vx:rand(-0.3,0.3),
}
vy:rand(0.4,1.2),
$content.html(html);
o:rand(0.3,0.9)
}
});
 
}
mw.hook("wikipage.content").add(function ($content) {
}
colorize($content);
var raf=window.requestAnimationFrame||window.webkitRequestAnimationFrame||function(fn){setTimeout(fn,16);};
});
function loop(){
ctx.clearRect(0,0,w,h);
ctx.beginPath();
for(var i=0;i<flakes.length;i++){
var f=flakes[i];
f.x+=f.vx;
f.y+=f.vy;
f.vx+=Math.sin((Date.now()+i*100)%6000/6000*Math.PI*2)*0.005;
if(f.y>h+10||f.x<-50||f.x>w+50){
f.x=rand(0,w);
f.y=-10;
f.vx=rand(-0.3,0.3);
f.vy=rand(0.4,1.2);
}
ctx.moveTo(f.x,f.y);
ctx.arc(f.x,f.y,f.r,0,Math.PI*2);
}
ctx.fillStyle='rgba(255,255,255,0.9)';
ctx.fill();
raf(loop);
}
window.addEventListener('resize',resize);
resize();
loop();
})();
})();

Версия от 22:04, 16 января 2026

(function () {
var words = {
	"властью": "#e74c3c",
	"ответственность": "#9b59b6",
	"Процедуры": "#2980b9",
	"ядерный": "#f1c40f",
	"диск": "#e67e22",
	"станции": "#1abc9c",
	"ГСБ": "#2c3e50",
	"увольнение": "#c0392b",
	"офицера": "#16a085",
	"банановая": "#d35400"
};


	function colorize($content) {
		var html = $content.html();
		for (var word in words) {
			if (!words.hasOwnProperty(word)) continue;
			var color = words[word];
			var re = new RegExp("\\b(" + word + ")\\b", "g");
			html = html.replace(re, '<span style="color:' + color + '; font-weight:600;">$1</span>');
		}
		$content.html(html);
	}

	mw.hook("wikipage.content").add(function ($content) {
		colorize($content);
	});
})();