/**
* Compares the values of two HTML documents for scheduled runs.
* Outputs simple error messages if differences are found.
*
* @param {string} html1 The first HTML document as a string.
* @param {string} html2 The second HTML document as a string.
*/
function compareHtmlDocuments(html1, html2) {
if (!html1 || !html2) {
console.error("Error: Both HTML documents must be provided.");
return;
}
if (html1 === html2) {
console.log("HTML documents are identical.");
return;
}
// Use a simple string comparison for basic differences
if (html1 !== html2) {
console.warn("Differences found between HTML documents:");
//Simple comparison, could be improved with DOM parsing for more granular differences
if (html1.length !== html2.length) {
console.warn("Length mismatch: HTML1 has " + html1.length + " characters, HTML2 has " + html2.length);
} else {
for (let i = 0; i < html1.length; i++) {
if (html1[i] !== html2[i]) {
console.warn("Character mismatch at index " + i + ": HTML1='" + html1[i] + "', HTML2='" + html2[i] + "'");
}
}
}
}
}
Add your comment