From 8445edeaf07e945af8125f58608aba1e0a4be8a7 Mon Sep 17 00:00:00 2001 From: "Wraithan (Chris McDonald)" Date: Sat, 10 Feb 2018 12:52:56 -0800 Subject: [PATCH] Change terminal cat to use
 tag for txt files which are
 often data

---
 src/Message.js     |  2 +-
 utils/DialogBox.js | 14 +++++++++++---
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/Message.js b/src/Message.js
index 667c8d147..0b5b9a98a 100644
--- a/src/Message.js
+++ b/src/Message.js
@@ -42,7 +42,7 @@ function showMessage(msg) {
     var txt = "Message received from unknown sender: 

" + "" + msg.msg + "

" + "This message was saved as " + msg.filename + " onto your home computer."; - dialogBoxCreate(txt); + dialogBoxCreate(txt, true); } //Adds a message to a server diff --git a/utils/DialogBox.js b/utils/DialogBox.js index 8425c053b..44554b562 100644 --- a/utils/DialogBox.js +++ b/utils/DialogBox.js @@ -32,7 +32,7 @@ $(document).on('click', '.dialog-box-close-button', function( event ) { var dialogBoxOpened = false; -function dialogBoxCreate(txt) { +function dialogBoxCreate(txt, preformatted) { var container = document.createElement("div"); container.setAttribute("class", "dialog-box-container"); @@ -43,8 +43,16 @@ function dialogBoxCreate(txt) { closeButton.setAttribute("class", "dialog-box-close-button"); closeButton.innerHTML = "×" - var textE = document.createElement("p"); - textE.innerHTML = txt.replace(/(?:\r\n|\r|\n)/g, '
'); + var textE; + if (preformatted) { + // For text files as they are often computed data that + // shouldn't be wrapped and should retain tabstops. + textE = document.createElement("pre"); + textE.innerHTML = txt; + } else { + textE = document.createElement("p"); + textE.innerHTML = txt.replace(/(?:\r\n|\r|\n)/g, '
'); + } content.appendChild(closeButton); content.appendChild(textE);