Skip to content

Commit

Permalink
Fix the gravity output to use the ${OVER} sequence
Browse files Browse the repository at this point in the history
Signed-off-by: RD WebDesign <[email protected]>
  • Loading branch information
rdwebdesign committed Oct 7, 2023
1 parent 79e66f1 commit 4156d96
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions scripts/pi-hole/js/gravity.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,18 @@ function eventsource() {
// Enqueue the next data chunk into our target stream
controller.enqueue(value);
var string = new TextDecoder().decode(value);
// Remove ${OVER} from the string
string = string.replaceAll("\r", "\n");
ta.append(string);

// If a Carriage Return is found ...
if (string.indexOf("\r") === -1) {
ta.append(string);
} else {
// ... remove the last line from the output ...
ta.text(ta.text().substring(0, ta.text().lastIndexOf("\n")) + "\n");
// ... and append the new text to the end of the output,
// without ${OVER} ("CR + ESC[K") or Carriage Return.
ta.append(string.replaceAll("\r", "").replaceAll("\r", ""));
}

if (string.indexOf("Pi-hole blocking is") !== -1) {
alSuccess.show();
}
Expand Down

0 comments on commit 4156d96

Please sign in to comment.