Skip to content
Open
Show file tree
Hide file tree
Changes from 8 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
5 changes: 3 additions & 2 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let builds:
}[]
| null = null;

fetch("https://raw.githubusercontent.com/nornagon/cdda-data/main/builds.json")
fetch(`${process.env.CDDA_DATA_SOURCE}/builds.json`)
.then((d) => d.json())
.then((b) => {
builds = b;
Expand All @@ -33,7 +33,8 @@ fetch("https://raw.githubusercontent.com/nornagon/cdda-data/main/builds.json")
const url = new URL(location.href);
const version = url.searchParams.get("v") ?? "latest";
const locale = url.searchParams.get("lang");
data.setVersion(version, locale);
const enabledMods = url.searchParams.get("m")?.split(",") ?? [];
data.setVersion(version, locale, enabledMods);

const tilesets = [
{
Expand Down
57 changes: 43 additions & 14 deletions src/JsonView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,52 @@ import { t } from "@transifex/native";
export let obj: any;
export let buildNumber: string | undefined;
const _context = "View/Edit on GitHub";

const urlView = `https://github.com/CleverRaven/Cataclysm-DDA/blob/${
buildNumber ?? "master"
}`;
const urlEdit = `https://github.dev/CleverRaven/Cataclysm-DDA/blob/${
buildNumber ?? "master"
}`;

function allSources(o: any): any[] {
const sources: any[] = [];
sources.push(o.__self);
while (o.__prevSelf) {
sources.push(o.__prevSelf);
o = o.__prevSelf;
}
return sources.reverse();
}
Copy link
Owner

Choose a reason for hiding this comment

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

share code with the helper in data.ts?

</script>

<pre>{JSON.stringify(
obj,
(key, value) => (key === "__filename" ? undefined : value),
(key, value) =>
["__mod", "__filename", "__self", "__prevSelf"].includes(key)
? undefined
: value,
2
)}</pre>
{#if obj.__filename}
<a
href={`https://github.com/CleverRaven/Cataclysm-DDA/blob/${
buildNumber ?? "master"
}/${obj.__filename}`}
target="_blank">{t("View", { _context })}</a>
/
<a
href={`https://github.dev/CleverRaven/Cataclysm-DDA/blob/${
buildNumber ?? "master"
}/${obj.__filename}`}
target="_blank">{t("Edit on GitHub", { _context })}</a>
{/if}
{#each allSources(obj) as o}
<details>
<summary
>{o.__mod}
{#if o.__filename}
<a href={`${urlView}/${o.__filename}`} target="_blank"
>{t("View", { _context })}</a>
/
<a href={`${urlEdit}/${o.__filename}`} target="_blank"
>{t("Edit on GitHub", { _context })}</a>
{/if}
</summary>
<pre>{JSON.stringify(
o,
(key, value) =>
["__mod", "__filename", "__self", "__prevSelf"].includes(key)
? undefined
: value,
2
)}</pre>
</details>
{/each}
Loading