I wanted to add a chat system into my project and have set up a text file creation for the logs, pushing the messages with username, time and message, and loading the logs from file when the chat is opened. I made a form component for the chat bubble, and the main form has a list formcomponent container on it with the contained form set to the chat bubble form component but I'm not sure where to go from here. Does anyone know how to dynamically add extra chat bubbles to the list form container in runtime?
Here is my current code:
- Code: Select all
function loadChat(fileContent) {
var lines = fileContent.split('\n');
chatLogsArray = [];
for (var i = 0; i < lines.length; i++) {
var line = lines[i];
var match = line.match(/^(.*?) (\d{2}:\d{2}:\d{2}) - (.*)$/);
if (match) {
var user = match[1];
var time = match[2];
var message = match[3];
chatLogsArray.push({ user: user, time: time, message: message });
}
}
application.output(chatLogsArray);
populateChatList();
}
function populateChatList() {
for (var i = 0; i < chatLogsArray.length; i++) {
var chatEntry = chatLogsArray[i];
var chatComponent = createAndConfigureChatComponent(chatEntry);
addChatComponentToList(chatComponent);
}
}
I currently don't have a function set up for either the createAndConfigureChatComponent(chatEntry) or the addChatComponentToList(chatComponent).
Thanks!
Alasdair