Я пытаюсь сделать так, чтобы мой сценарий регистрировал строки только один раз.Таким образом, когда создается новая строка, она регистрирует только новые строки ... Этот скрипт регистрирует все строки одновременно.Я хотел бы найти способ сделать так, чтобы он регистрировал только .innerText
только что созданных дочерних элементов в этом элементе с идентификатором "team_log_actual".
Дочерние элементы можно добавлять в любой момент времени.
Вот мой сценарий:
setInterval(function() {
var logelement = $('#team_log_actual');
var foo = document.getElementById('team_log_actual');
for (let i = 0; i < foo.children.length; i++) {
//console.log(foo.children[i].innerText);
//" [Owner] Master3 used station: Helm (Starter)." <---Printed Example.
var PRINTactions = foo.children[i].innerText;
var PRINTactionsEle = foo.children[i];
var fields = PRINTactions.split(/ /);
var Username = fields[2]; //grabs the second field from the splitted string. which is the username..
var text1 = fields[3];
var text2 = fields[4];
var text3 = fields[5];
var text4 = fields[6];
var text5 = fields[7];
var text6 = fields[8];
var text7 = fields[9];
var text8 = fields[10];
var text9 = fields[11];
var text10 = fields[12];
//Defined multiple just in case. Each field will contain a string. If one is there, but it's highly unlikely to go past 5-6.
var combinetext = fields[3] + " " + fields[4] + " " + fields[5] + " " + fields[6] + " " + fields[7];
if (combinetext.includes("in ejector") == true) {
console.log(Username + " : " + combinetext) // log the Username and the combinedtext. Only if the combinetext includes the string "in ejector".
}
}
}, 10000); // Run every 10 seconds.