1. /**
  2. * Compares the values of two HTML documents for scheduled runs.
  3. * Outputs simple error messages if differences are found.
  4. *
  5. * @param {string} html1 The first HTML document as a string.
  6. * @param {string} html2 The second HTML document as a string.
  7. */
  8. function compareHtmlDocuments(html1, html2) {
  9. if (!html1 || !html2) {
  10. console.error("Error: Both HTML documents must be provided.");
  11. return;
  12. }
  13. if (html1 === html2) {
  14. console.log("HTML documents are identical.");
  15. return;
  16. }
  17. // Use a simple string comparison for basic differences
  18. if (html1 !== html2) {
  19. console.warn("Differences found between HTML documents:");
  20. //Simple comparison, could be improved with DOM parsing for more granular differences
  21. if (html1.length !== html2.length) {
  22. console.warn("Length mismatch: HTML1 has " + html1.length + " characters, HTML2 has " + html2.length);
  23. } else {
  24. for (let i = 0; i < html1.length; i++) {
  25. if (html1[i] !== html2[i]) {
  26. console.warn("Character mismatch at index " + i + ": HTML1='" + html1[i] + "', HTML2='" + html2[i] + "'");
  27. }
  28. }
  29. }
  30. }
  31. }

Add your comment