Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"edjApp": true,
"edjLogparser": true,
"edScoopables": true,
"edjGetdistance": true,
"edj": true,
"console": false,
"process": true,
Expand Down Expand Up @@ -105,4 +106,4 @@
"off"
]
}
}
}
3 changes: 2 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"edjApp": true,
"edjLogparser": true,
"edScoopables": true,
"edjGetdistance": true,
"edj": true,
"console": false,
"process": true,
Expand All @@ -17,4 +18,4 @@
"unused": true,
"esversion": 6,
"varstmt": true
}
}
9 changes: 8 additions & 1 deletion edj.filereader.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ edj = {
sel.removeAllRanges();
sel.addRange(r2);
document.execCommand('copy');
//todo: update on new file selection
}
t.contenteditable = false;
},
Expand All @@ -49,6 +50,10 @@ edj = {
edj.fileOnLoad(res.target.result);
};
fr.readAsText(edj.lastFile, 'UTF-8');
//one file uploaded, stop monitoring for changes.
if (_files.length === 1) {
return;
}
setTimeout(() => {
edj.monitorChanges(_selDir);
}, 1000);
Expand Down Expand Up @@ -109,6 +114,8 @@ edj = {
l++;
}
edj.lastLine = l;
// assuming parsing is done, go ahead and get the distance
edjGetdistance.request(edjdata.player.pos.Body);
edjGui.updateGui();
},
isJson(line) {
Expand Down Expand Up @@ -161,4 +168,4 @@ edj = {
const files = await edj.loadLogFiles();
edj.monitorChanges(files);
}
}());
}());
19 changes: 19 additions & 0 deletions edj.getdistance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* edjGui */
edjGetdistance = {
request(sysname) {
const req = new XMLHttpRequest();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'XMLHttpRequest' is not defined.

// true parameter denotes asynchronous
req.overrideMimeType('application/json');
req.open('GET', `https://elitebgs.kodeblox.com/api/eddb/v3/bodies?name=${sysname.toString()}`, true);
req.onreadystatechange = function () {
if (req.readyState == 4 && req.status == '200') {
const jsonResponse = JSON.parse(req.responseText);
console.log(jsonResponse.docs[0].distance_to_arrival);
edjdata.player.pos.DistanceToArrival = jsonResponse.docs[0].distance_to_arrival;
edjGui.updateGui();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'edjGui' is not defined.

}
};
req.send(null);
},
};

3 changes: 2 additions & 1 deletion edj.gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const edjGui = {
const playerPos = edjGui.get_cmdr_position();
if (playerPos.length > 0) {
document.getElementById('location').innerText = `in ${playerPos.join(', ')}`;
document.getElementById('body').innerText = `${edjdata.player.pos.Body} is ${edjdata.player.pos.DistanceToArrival} LS from the primary star.`;
} else {
document.getElementById('location').innerText = 'at an unknown position';
}
Expand All @@ -38,4 +39,4 @@ const edjGui = {

return items;
},
};
};
Loading