Mouse Clock 1.3.0: glow and font size options; editor fields and neon preset

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tangsongdayoandClaude Opus 5.5 committed 2026-11-20 17:47:00 +08:00
1 parent 3241c06114
commit 32aaf8a191
3 files changed
+72 -20

No files matched your search

+46 -9
View File
@@ -136,6 +136,22 @@
<div id="colors"></div>
</fieldset>
<fieldset>
<legend>外光暈</legend>
<div class="row color">
<label for="f-glowColor">光暈顏色</label>
<input type="color" id="f-glowColor-pick" aria-label="光暈顏色取色器" data-key="glowColor">
<input type="text" id="f-glowColor" data-key="glowColor" maxlength="7" spellcheck="false" autocomplete="off" placeholder="空白=不加">
</div>
<div id="numbersGlow"></div>
<p class="note">範圍設 0 或顏色留空就不加光暈。深色網站搭配亮色光暈最明顯。</p>
</fieldset>
<fieldset>
<legend>字大小</legend>
<div id="numbersFont"></div>
</fieldset>
<fieldset>
<legend>大小與速度</legend>
<div id="numbersMain"></div>
@@ -215,7 +231,7 @@
<a href="https://code.tsdylab.com/tangsongdayo/mouse-clock">原始碼與授權</a> ・ <span id="ver"></span>
</footer>
<script src="mouse-clock.js?v=1.2.0" data-manual></script>
<script src="mouse-clock.js?v=1.3.0" data-manual></script>
<script>
(function () {
'use strict';
@@ -232,6 +248,13 @@
['speed', '跟隨速度', 0.05, 1, 0.05, ''],
['dateSpeed', '日期環轉速', 0, 0.1, 0.005, '']
],
numbersGlow: [
['glowSize', '光暈範圍(px)', 0, 20, 1, '']
],
numbersFont: [
['fontSize', '數字與日期', 6, 30, 1, 'px'],
['handSize', '指針', 8, 40, 1, 'px']
],
numbersMouse: [
['offsetX', '水平', -300, 300, 1, 'px'],
['offsetY', '垂直', -300, 300, 1, 'px']
@@ -246,9 +269,11 @@
['柔和', { dateColor: '#999999', faceColor: '#555555', hourColor: '#b5532f', minuteColor: '#33568b', secondColor: '#3f8f57' }],
['夜光(深色網站)', { dateColor: '#8fa3b8', faceColor: '#e8e4d8', hourColor: '#ff8a65', minuteColor: '#7fb0ff', secondColor: '#9be38f' }],
['糖果', { dateColor: '#c58bd9', faceColor: '#ff7eb6', hourColor: '#ff5c8a', minuteColor: '#5cc8ff', secondColor: '#ffc24b' }],
['墨色', { dateColor: '#888888', faceColor: '#333333', hourColor: '#111111', minuteColor: '#444444', secondColor: '#9b452e' }]
['墨色', { dateColor: '#888888', faceColor: '#333333', hourColor: '#111111', minuteColor: '#444444', secondColor: '#9b452e' }],
['霓虹(深色網站)', { dateColor: '#ff6ec7', faceColor: '#e0fbff', hourColor: '#ff3b6b', minuteColor: '#39c6ff', secondColor: '#b6ff3b', glowColor: '#00e5ff', glowSize: 6 }]
];
var NUM_KEYS = ['size', 'offsetX', 'offsetY', 'touchOffsetX', 'touchOffsetY', 'speed', 'dateSpeed', 'zIndex'];
var NUM_KEYS = ['size', 'offsetX', 'offsetY', 'touchOffsetX', 'touchOffsetY', 'speed', 'dateSpeed', 'zIndex', 'fontSize', 'handSize', 'glowSize'];
var LOOK_KEYS = COLORS.map(function (c) { return c[0]; }).concat(['glowColor', 'glowSize']); // 預設配色會換掉的項目
var state = {};
var mode = 'tag';
@@ -271,7 +296,8 @@
for (k in input || {}) {
if (!(k in DEF)) continue;
v = input[k];
if (/Color$/.test(k)) { v = normColor(v); if (v) o[k] = v; }
if (k === 'glowColor' && String(v).trim() === '') o[k] = '';
else if (/Color$/.test(k)) { v = normColor(v); if (v) o[k] = v; }
else if (NUM_KEYS.indexOf(k) >= 0) { v = Number(v); if (isFinite(v) && String(input[k]).trim() !== '') o[k] = k === 'zIndex' ? Math.max(0, Math.min(2147483647, Math.round(v))) : round(v); }
else if (k === 'lang') { if (v === 'en' || v === 'zh-TW') o[k] = v; }
else if (k === 'reducedMotion') { if (v === 'hide' || v === 'show') o[k] = v; }
@@ -311,7 +337,7 @@
b.innerHTML = '<span class="swatch" aria-hidden="true">' + COLORS.map(function (x) { return '<i style="background:' + c[x[0]] + '"></i>'; }).join('') + '</span>' + p[0];
b.addEventListener('click', function () {
var next = clone(state);
COLORS.forEach(function (x) { next[x[0]] = c[x[0]]; });
LOOK_KEYS.forEach(function (x) { next[x] = c[x]; });
apply(next, true);
say('已套用「' + p[0] + '」配色');
});
@@ -322,7 +348,7 @@
document.querySelectorAll('[data-key]').forEach(function (el) {
var k = el.getAttribute('data-key');
if (el === document.activeElement && el.type !== 'color' && el.type !== 'range' && el.tagName !== 'SELECT') return;
el.value = state[k];
el.value = (el.type === 'color' && !state[k]) ? '#ffffff' : state[k];
el.removeAttribute('aria-invalid');
});
}
@@ -347,7 +373,10 @@
var k = el.getAttribute('data-key');
el.addEventListener('input', function () {
var v = el.value, next = clone(state);
if (/Color$/.test(k)) {
if (k === 'glowColor' && el.type === 'text' && v.trim() === '') {
el.removeAttribute('aria-invalid');
next[k] = '';
} else if (/Color$/.test(k)) {
var c = normColor(v);
if (!c) { el.setAttribute('aria-invalid', 'true'); return; }
el.removeAttribute('aria-invalid');
@@ -357,9 +386,17 @@
el.removeAttribute('aria-invalid');
next[k] = Number(v);
} else next[k] = v;
// 光暈:選了顏色但範圍是 0 → 給預設範圍;調了範圍但沒有顏色 → 給白色
if (k === 'glowColor' && next.glowColor && !(Number(next.glowSize) > 0)) next.glowSize = 6;
if (k === 'glowSize' && Number(next.glowSize) > 0 && !next.glowColor) next.glowColor = '#ffffff';
var prev = state;
state = sanitize(next);
// 同步同一個設定的另一個輸入框
document.querySelectorAll('[data-key="' + k + '"]').forEach(function (o) { if (o !== el) o.value = state[k]; });
// 同步其他輸入框(包含連動改到的光暈欄位)
document.querySelectorAll('[data-key]').forEach(function (o) {
var kk = o.getAttribute('data-key');
if (o === el || (kk !== k && state[kk] === prev[kk])) return;
o.value = (o.type === 'color' && !state[kk]) ? '#ffffff' : state[kk];
});
save(); render();
clearTimeout(startTimer);
startTimer = setTimeout(restart, 30);