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);