From 6a3ac7165dccdef11d13714d2b221f958976f59b Mon Sep 17 00:00:00 2001 From: "Wraithan (Chris McDonald)" Date: Sat, 10 Feb 2018 12:19:08 -0800 Subject: [PATCH 1/3] fix bug with ls() that prevented including .txt files --- src/NetscriptFunctions.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/NetscriptFunctions.js b/src/NetscriptFunctions.js index 04da98c3c..eb0512309 100644 --- a/src/NetscriptFunctions.js +++ b/src/NetscriptFunctions.js @@ -816,6 +816,16 @@ function NetscriptFunctions(workerScript) { } } + for (var i = 0; i < server.textFiles.length; i++) { + if (filter) { + if (server.textFiles[i].fn.includes(filter)) { + allFiles.push(server.textFiles[i].fn); + } + } else { + allFiles.push(server.textFiles[i].fn); + } + } + //Sort the files alphabetically then print each allFiles.sort(); return allFiles; From fe4a6d90f80c5a60f0ec6c86a47182e86959e143 Mon Sep 17 00:00:00 2001 From: "Wraithan (Chris McDonald)" Date: Sat, 10 Feb 2018 12:25:13 -0800 Subject: [PATCH 2/3] Fix documentation to include grep parameter to ls() netscript function --- doc/source/netscriptfunctions.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/source/netscriptfunctions.rst b/doc/source/netscriptfunctions.rst index 4723b54fc..ebda208a2 100644 --- a/doc/source/netscriptfunctions.rst +++ b/doc/source/netscriptfunctions.rst @@ -326,9 +326,10 @@ scp ls ^^ -.. js:function:: ls(hostname/ip) +.. js:function:: ls(hostname/ip, [grep]) :param string hostname/ip: Hostname or IP of the target server + :param string grep: a substring to search for in the filename. Returns an array with the filenames of all files on the specified server (as strings). The returned array is sorted in alphabetic order From 8445edeaf07e945af8125f58608aba1e0a4be8a7 Mon Sep 17 00:00:00 2001 From: "Wraithan (Chris McDonald)" Date: Sat, 10 Feb 2018 12:52:56 -0800 Subject: [PATCH 3/3] 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);