diff --git a/CHANGELOG.md b/CHANGELOG.md index 912178a..b5bc031 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ - The drag ruler will now be colored for other players than the dragging player as well (only if they have at least observer permissions for that token) - The drag ruler won't be shown to other players if they cannot see the dragged token +### Bugfixes +- Drag Ruler will now work on installations where the `foundry.js` has `CRLF` line endings + ## v1.0.1 ### Bugfixes - The GM can now move tokens through walls diff --git a/src/main.js b/src/main.js index bf8b462..f291eaa 100644 --- a/src/main.js +++ b/src/main.js @@ -143,6 +143,8 @@ function strInsertAfter(haystack, needle, strToInsert) { // These patches were written with foundry-0.7.9.js as reference function patchRulerMeasure() { let code = Ruler.prototype.measure.toString() + // Replace CRLF with LF in case foundry.js has CRLF for some reason + code = code.replace(/\r\n/g, "\n") // Remove function signature and closing curly bracket (those are on the first and last line) code = code.slice(code.indexOf("\n"), code.lastIndexOf("\n")) code = strInsertAfter(code, "for ( let [i, d] of distances.entries() ) {\n", "segments[i].startDistance = totalDistance\n") @@ -193,6 +195,8 @@ function getColorForDistance(startDistance, subDistance) { // These patches were written with foundry-0.7.9.js as reference function patchRulerHighlightMeasurement() { let code = Ruler.prototype._highlightMeasurement.toString() + // Replace CRLF with LF in case foundry.js has CRLF for some reason + code = code.replace(/\r\n/g, "\n") // Remove function signature and closing curly bracket (those are on the first and last line) code = code.slice(code.indexOf("\n"), code.lastIndexOf("\n"))