/
cto_ego
/
website
Обзор
Документация
Войти
/
cto_ego
/
website
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
mod/matrixData.js
133 строки
5 KB
cto_ego
Create: styles.css, bugs.md, changelog.md, handbook.html, img_1.png, config.js, draw.js, formula.js, logger.js, mathf.js, matrixControllerState.js, matrixData.js, save.js, sound.js, ui.js, update.js, index.html, index.js
25 июн 2026, 20:55
Верифицирован
25 июн 2026, 20:55
cb1beff
Код
Авторство
О чём код?
/** * Keep value for matrix */ class MatrixData { constructor() { this.intervalId = null; this.time_update = 10; this.mode_matrix = 'classic'; this.drops = []; this.formulaPoints = []; this.color = 'rgba(0, 0, 0, 0.05)'; this.fontSize = 16; this.columns; this.charArray_my = []; // for my mode this.stop = false; this.way = 'down'; // way of the matrix, down, up, left, right this.keyboard = true; // contol matrix using the keyboard this.colors = TableParams['theme']['green']['colors']; this.ages; this.additionally_mode = [] this.cacheText = ['I always find you', '*'] // for find mode this.loadCacheSettings = {} // for load settings this.draw_axes = false; // for the math mode this.isRecording = false // video recording }; init(control) { this.control = control; this.ages = new Array(Math.ceil(this.columns)).fill(0) } /** * * @param {object} settings * @returns */ loadSettings(settings) { if (settings) { try { this.loadCacheSettings = settings; this.writeInfoLoadJson(); return; } catch (error) { this.loadCacheSettings = {}; Logger.error('Error loadSettings:', {error: error}); }; } }; writeInfoLoadJson() { // Writes information from the configuration file try { const container = document.getElementById('info-load-json'); if (!container) return; // clear container container.textContent = ''; const settings = this.loadCacheSettings; if (!settings) return; // create paragraph const createParagraph = (text) => { const p = document.createElement('p'); p.textContent = text; return p; }; // speed container.appendChild(createParagraph(`Скорость: ${settings.speed}`)); // speed fill container.appendChild(createParagraph(`Скорость затухания: ${settings.speedFill}`)); // alphabet/ text if (settings.mod === 'find') { const findText = document.createElement('p'); findText.textContent = `Текст по центру: ${settings.text[0]}`; container.appendChild(findText); const fillerText = document.createElement('p'); fillerText.textContent = `Заполнитель: ${settings.text[1]}`; container.appendChild(fillerText); } else if (settings.mod === 'classic') { container.appendChild(createParagraph(`Алфавит: ${settings.text.toString()}`)); } // colors const colorsTitle = document.createElement('p'); colorsTitle.textContent = 'Цвета:'; container.appendChild(colorsTitle); const colorsWrapper = document.createElement('div'); colorsWrapper.style.display = 'flex'; colorsWrapper.style.gap = '4px'; (settings.colors || []).forEach(color => { const span = document.createElement('span'); span.style.backgroundColor = color; span.style.width = '20px'; span.style.height = '20px'; span.style.display = 'inline-block'; colorsWrapper.appendChild(span); }); container.appendChild(colorsWrapper); } catch (error) { Logger.warn('method writeInfoLoadJson error:', error); } }; useLoadSettings() { //! нет проверки, Warning. I don't check the values. try { if (Object.keys(this.loadCacheSettings).length > 0) { this.colors = this.loadCacheSettings.colors; this.mode_matrix = this.loadCacheSettings.mod; if (this.mode_matrix == 'find') { this.charArray_my = centerText(this.loadCacheSettings.text[0], this.loadCacheSettings.text[1], this.columns); } else { this.charArray_my = this.loadCacheSettings.text }; this.control.setSpeed(this.loadCacheSettings.speed); this.control.setFillSpeed(this.loadCacheSettings.speedFill); alert('Настройки применены'); } return; } catch (error){ Logger.error("", {error: error}); alert('Ошибка, сброс значений'); this.control.setDefaultMode('classic'); } }; }; let data = new MatrixData(); window.data = data;