MCPcopy Create free account
hub / github.com/dajie111/nodeseek-userscript / updateColorHistory

Function updateColorHistory

notes.js:564–603  ·  view source on GitHub ↗
(panel, type)

Source from the content-addressed store, hash-verified

562 }
563
564 function updateColorHistory(panel, type) {
565 const key = type === 'font' ? LS_KEYS.fontColors : LS_KEYS.bgColors;
566 const history = readJSON(key, []);
567
568 panel.innerHTML = '';
569
570 if (history.length === 0) {
571 const emptyMsg = createElement('div', { className: 'nsn-history-empty' }, ['暂无历史颜色']);
572 panel.appendChild(emptyMsg);
573 } else {
574 const grid = createElement('div', { className: 'nsn-color-grid' });
575 history.forEach(color => {
576 const colorBlock = createElement('div', {
577 className: 'nsn-color-block',
578 style: { backgroundColor: color },
579 title: color
580 });
581 colorBlock.addEventListener('mousedown', (e) => {
582 e.preventDefault();
583 e.stopPropagation();
584 saveSelection();
585 });
586 colorBlock.addEventListener('click', (e) => {
587 e.preventDefault();
588 e.stopPropagation();
589 restoreSelection();
590 if (type === 'font') {
591 fontColorPicker.value = color;
592 cmd('foreColor', color);
593 } else {
594 bgColorPicker.value = color;
595 cmd('backColor', color);
596 }
597 hideAllHistoryPanels();
598 });
599 grid.appendChild(colorBlock);
600 });
601 panel.appendChild(grid);
602 }
603 }
604
605 function toggleHistoryPanel(panel, btn) {
606 const isVisible = panel.classList.contains('show');

Callers 1

buildToolbarFunction · 0.85

Calls 5

readJSONFunction · 0.85
createElementFunction · 0.85
saveSelectionFunction · 0.85
restoreSelectionFunction · 0.85
hideAllHistoryPanelsFunction · 0.85

Tested by

no test coverage detected