Fix #5: Handle installations where foundry.js has CRLF line endings gracefully
This commit is contained in:
@@ -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 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
|
- 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
|
## v1.0.1
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
- The GM can now move tokens through walls
|
- The GM can now move tokens through walls
|
||||||
|
|||||||
@@ -143,6 +143,8 @@ function strInsertAfter(haystack, needle, strToInsert) {
|
|||||||
// These patches were written with foundry-0.7.9.js as reference
|
// These patches were written with foundry-0.7.9.js as reference
|
||||||
function patchRulerMeasure() {
|
function patchRulerMeasure() {
|
||||||
let code = Ruler.prototype.measure.toString()
|
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)
|
// 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 = code.slice(code.indexOf("\n"), code.lastIndexOf("\n"))
|
||||||
code = strInsertAfter(code, "for ( let [i, d] of distances.entries() ) {\n", "segments[i].startDistance = totalDistance\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
|
// These patches were written with foundry-0.7.9.js as reference
|
||||||
function patchRulerHighlightMeasurement() {
|
function patchRulerHighlightMeasurement() {
|
||||||
let code = Ruler.prototype._highlightMeasurement.toString()
|
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)
|
// 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 = code.slice(code.indexOf("\n"), code.lastIndexOf("\n"))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user