/
developer_atatanoff
/
notauth
Обзор
Документация
Войти
/
developer_atatanoff
/
notauth
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
static/js/security.js
55 строк
2 KB
Алексей Николаевич Татанов
Забракованный вариант
19 апр 2024, 15:21
19 апр 2024, 15:21
74c3a19
Код
Авторство
О чём код?
autotypingText( { typingSpeed: 50, // скорость печатания switchTimeout: 1000, // время ожидания перед переключением между элементами element: document.getElementById( 'Ticker' ), data: [ { text: 'Слушайте, я не узнаю вас в гриме!\nАвторизуйтесь пожалуйста...' }, { text: 'Если вы не знаете как это сделать,\nобратитесь в техническую поддержку.' }, ], } ) function autotypingText( args ){ let itemCount = Number( args.data.length ); let curItemIndex = -1; let currentLength = 0; let theText = ''; runTheTicker(); function runTheTicker(){ let theHold // Переход к следующему элементу if( currentLength === 0 ){ curItemIndex++; curItemIndex = curItemIndex % itemCount; theText = args.data[curItemIndex].text.replace( /"/g, '-' ); } // Располагаем текущий текст в анкор с печатанием args.element.innerHTML = theText.substring( 0, currentLength ) + znak(); // Преобразуем длину для подстроки и определяем таймер if( currentLength !== theText.length ){ currentLength++; theHold = args.typingSpeed; } else{ currentLength = 0; theHold = args.switchTimeout; } // Повторяем цикл с учетом задержки setTimeout( runTheTicker, theHold ); } function znak(){ return ( currentLength === theText.length ) ? '' : '|'; } }