屏幕颜色检测

免费在线屏幕测试 - 专业显示器检测工具 | 视觉族

别人的网站很好,我写了一个差不多的。

html 复制代码
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<title>DisplayTest</title>
</head>
<style>
body {  }
button { width:30px; height:30px; border:1px solid gray; }
a { text-decoration:none; }
#panel { text-align:center; }
</style>
<body>
<div id="panel">
<button class="button_color"></button> <button class="button_color"></button> <button class="button_color"></button> <button class="button_color"></button> <button class="button_color"></button> <button class="button_color"></button> <button class="button_color"></button> <button class="button_color"></button> <button id="button_fullscreen">↕</button><br>
<a href="https://www.shijuezu.com/" target="_blank">视觉族</a> <a href="https://www.htmlcolorname.com/" target="_blank">HTMLColorName</a>
</div>
<script>
var colors = [ 'white', 'black', 'red', 'green', 'blue', 'yellow', 'fuchsia', 'cyan' ];
var id = 0;
var timerId;
var delay = 2000;

var buttons = document.querySelectorAll('.button_color');
for (i=0; i<buttons.length; i++) {
	buttons[i].style.background = colors[i];
    buttons[i].addEventListener('click', function() {		
		id = Array.prototype.indexOf.call(buttons, this);
		document.body.style.background = colors[id];
		timerId = setTimeout(() => { panel.style.display = 'none'; document.documentElement.style.cursor = 'none'; }, delay);
	});
}

function EEFullscreen() {
	if (!document.fullscreenElement){
		document.documentElement.requestFullscreen();
		button_fullscreen.textContent = '╬';
	} else {
		document.exitFullscreen();
		button_fullscreen.textContent = '↕';
	}
}

function hidePanel() {
	panel.style.display = 'none';
	document.documentElement.style.cursor = 'none';
}

button_fullscreen.onclick = function(){
	EEFullscreen();
}

document.onkeydown = function(e){
	//console.log(e.code);
	if (e.code === 'KeyF') {
		EEFullscreen();
	} else if (e.code === 'ArrowLeft') {
		if (id == 0) {
			id = colors.length - 1;
		} else {
			id--;
		}
		buttons[id].focus();
		document.body.style.background = colors[id];
		timerId = setTimeout(() => {  }, delay);
	} else if (e.code === 'ArrowRight') {
		if (id == colors.length - 1) {
			id = 0;
		} else {
			id++;
		}
		buttons[id].focus();
		document.body.style.background = colors[id];
		timerId = setTimeout(() => { hidePanel(); }, delay);
	}
}

document.onmousemove = function(e){
	clearTimeout(timerId);
	panel.style.display = 'block';
	document.documentElement.style.cursor = 'auto';
	timerId = setTimeout(() => { hidePanel(); }, delay);
}

timerId = setTimeout(() => { hidePanel(); }, delay);
</script>
</body>
</html>
相关推荐
默_笙2 小时前
🧀 让大模型的答案"流"出来:NestJS AI 模块 + SSE + RxJS 实战
javascript·人工智能
mbshqqb2 小时前
TypeScript基础教程之同步生成器
前端·javascript·typescript
尤水就下2 小时前
🔥预热:在线文档的 block 架构是如何实现的(未完待续...)
前端·javascript·架构
全栈项目管理程序猿3 小时前
ArcGIS JS 基础教程(29):CSVLayer 表格点位图层
前端·javascript
骑着蜗牛撵大象3273 小时前
豆包 Seed 驱动的记账智能体:从拍票抽取到月报生成的全链路落地记录
java·前端·javascript·结构化输出·豆包seed·多模态识别·记账系统
溪语流沙3 小时前
【Web全栈进阶】前端世界观:现代工具链与框架为什么存在
前端·javascript·vue.js
kyriewen4 小时前
我逐个测了 JSON.stringify 的 7 个坑:第 1 个就在丢数据
前端·javascript·程序员
song5014 小时前
React Native for OpenHarmony 实战:三方库 react-native-ratings 的鸿蒙化适配指南
javascript·react native·react.js·分类·harmonyos
朱包林5 小时前
iTerm2终端配置指南
linux·javascript·python·云原生·容器·kubernetes·云计算
谢亮_vipxieliang5 小时前
JavaScript this 指向完全指南:调用位置决定一切
开发语言·javascript·ecmascript