Skip to content

Commit

Permalink
Formatted printed logs and WIP towards allowing user to specify times…
Browse files Browse the repository at this point in the history
…tamp to display

Co-authored-by: Benjamin Ross <[email protected]
  • Loading branch information
Blake Bender committed Jun 27, 2018
1 parent 192c34e commit fbf017a
Show file tree
Hide file tree
Showing 4 changed files with 510 additions and 4 deletions.
18 changes: 17 additions & 1 deletion fileManagement.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var stream = require('stream');
var linesIndex = { timestamps: [], fileNames: [], fileOffsets: [], lengths: []};

function openFile () {

console.log("openFile");
dialog.showOpenDialog({ filters: [
{ name: 'Log Files, Text Files', extensions: ['log', 'txt'] }
]},function (fileNames) {
Expand Down Expand Up @@ -53,6 +53,7 @@ function indexFile(fileName) {
linesIndex.lengths.push(length);
// Start display at beginning after loading new file
displayLines(linesIndex.timestamps[0]);
populateTimeList();
});
}

Expand Down Expand Up @@ -89,6 +90,10 @@ function displayLines(timestamp) {
index++;
}

var withBreaks = buffer.toString().split("\n").join("<br />");

document.querySelector('#textGoesHere').innerHTML = withBreaks;

console.log(buffer.toString());

// while (we still need to read more lines)
Expand All @@ -100,4 +105,15 @@ function displayLines(timestamp) {

}

function populateTimeList()
{
var options = '';

for(var i = 0; i < linesIndex.timestamps.length; i++)
options += '<option value="' + linesIndex.timestamps[i] +'">' + new Date(linesIndex.timestamps[i]).toString() + linesIndex.timestamps[i] + "</option>";

timestampComboBox.innerHTML = options;
}

var timestampComboBox = document.getElementById('timestamps');
document.querySelector('#fileOpenButton').addEventListener('click', openFile);
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ <h1>Hello World!</h1>
Chrome <script>document.write(process.versions.chrome)</script>,
and Electron <script>document.write(process.versions.electron)</script>.
<button id="fileOpenButton">Open</button>
<p id="textGoesHere"></p>
</body>
<script>
var remote = require('electron').remote;
var dialog = remote.require('electron').dialog;
require('./fileManagement.js')
require('./fileManagement.js');
</script>
</html>

Loading

0 comments on commit fbf017a

Please sign in to comment.