Sha256: ca6361a8ebe268311b74d5ebf23242116f9a2eb1130b66773e83809b3ffb6746
Contents?: true
Size: 965 Bytes
Versions: 9
Compression:
Stored size: 965 Bytes
Contents
/* global JsDiff */ $(() => { $(".diff-i18n_html, .diff-i18n").each(function(_index, element) { const diffElement = $(element); const valueElement = diffElement.find(".diff__value"); const oldValue = valueElement.data("old-value"). replace(/</g, "<"). replace(/>/g, ">"); const newValue = valueElement.data("new-value"). replace(/</g, "<"). replace(/>/g, ">"); const diff = JsDiff.diffChars(oldValue, newValue); let outputHTML = ""; diff.forEach(({added, removed, value}) => { let color = ""; if (added) { color = "#89ffaa"; } else if (removed) { color = "red"; } if (added || removed) { outputHTML += `<span style="background-color: ${color}">${value}</span>`; } else { outputHTML += value; } }); outputHTML = outputHTML.replace(/\n/g, "<br><br>"); valueElement.html(outputHTML); }); })
Version data entries
9 entries across 9 versions & 1 rubygems