let bot = new RiveScript(); const message_container = document.querySelector('.messages'); const form = document.querySelector('form'); const input_box = document.querySelector('input'); const brains = [ './begin.rive', './brain.rive' ]; bot.loadFile(brains).then(botReady).catch(botNotReady); form.addEventListener('submit', (e) => { e.preventDefault(); selfReply(input_box.value); input_box.value = ''; }); function getRandomNumber(start, end, increments) { var numbers = []; for(var n = start; n <= end; n += increments) { numbers.push(n); } var randomIndex = Math.floor(Math.random() * numbers.length); return numbers[randomIndex]; } function getWelcomeText() { fetch('./welcome.txt') .then(response => response.text()) .then((data) => { const textArray = data.split(/\r?\n/); textArray.forEach(function (item, index) { botReply(item); document.title = '(3) - Smart Speaker Theatre'; }); }) } function botReply(message){ message_container.innerHTML += `