-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Hans Acker
committed
Jul 18, 2024
1 parent
91861fc
commit 287c8cc
Showing
7 changed files
with
38 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// const distanceN = (v0, v1) => Math.hypot.apply(null, v0.map((v, i) => v - v1[i])); | ||
export const distance3 = (v0, v1) => Math.hypot(v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2]); // subtract vectors, return length | ||
export const trimPrefix = (str, prefix) => (str.startsWith(prefix) ? str.slice(prefix.length) : str).trim(); | ||
export const makeTd = (textContent) => { const td = document.createElement("td"); td.textContent = td.title = textContent; return td; }; | ||
|
||
export function addRow(tbody, tr) { | ||
while (tbody.childElementCount >= listLength) { | ||
tbody.lastElementChild.remove(); | ||
} | ||
|
||
tbody.prepend(tr); | ||
} | ||
|
||
export function whatGame(data) { | ||
try { | ||
// no decision if gameversion is not set or set to CAPI-<endpoint> | ||
// https://github.com/EDCD/EDDN/blob/live/docs/Developers.md#gameversions-and-gamebuild | ||
const gameversion = data.header.gameversion; | ||
if (gameversion && (gameversion.startsWith("CAPI-Legacy-") || parseInt(gameversion) < 4)) { | ||
return "Legacy"; | ||
} | ||
|
||
// https://github.com/EDCD/EDDN/blob/live/docs/Developers.md#horizons-and-odyssey-flags | ||
const msg = data.message; | ||
return msg.odyssey ? "Odyssey" : msg.horizons ? "Horizons" : msg.horizons === false ? "Base" : "Unknown"; | ||
} catch(error) { | ||
console.log("gameversion error:", error); | ||
return "Unknown"; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.