Skip to content
Merged
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
22 changes: 11 additions & 11 deletions frontend/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@
import ProjectManagerView from "./project/ProjectManagerView.svelte";

import { printConsoleArt } from "./console-art.js";
import { selected, selectedResource, settings } from "./stores.js";
import {
selected,
selectedResource,
settings,
dataLength,
} from "./stores.js";
import { keyEventToString, shortcuts } from "./keyboard.js";

import { writable } from "svelte/store";
Expand All @@ -57,20 +62,19 @@
useAssemblyView = false,
useTextView = false,
rootResourceLoadPromise = new Promise((resolve) => {}),
resourceNodeDataMap = {},
resources = {};
let carouselSelection,
currentResource,
rootResource,
modifierView,
bottomLeftPane;
let currentResource, rootResource, modifierView, bottomLeftPane;

// TODO: Move to settings
let riddleAnswered = JSON.parse(window.localStorage.getItem("riddleSolved"));
if (riddleAnswered === null || riddleAnswered === undefined) {
riddleAnswered = false;
}

$: dataLenPromise.then((r) => {
$dataLength = r;
});

$: if ($selected !== undefined) {
currentResource = resources[$selected];
if (currentResource === undefined) {
Expand Down Expand Up @@ -177,13 +181,11 @@ Answer by running riddle.answer('your answer here') from the console.`);
this="{modifierView}"
dataLenPromise="{dataLenPromise}"
bind:modifierView="{modifierView}"
bind:resourceNodeDataMap="{resourceNodeDataMap}"
/>
{:else}
<ResourceTreeView
rootResource="{rootResource}"
bind:bottomLeftPane="{bottomLeftPane}"
bind:resourceNodeDataMap="{resourceNodeDataMap}"
bind:modifierView="{modifierView}"
bind:showProjectManager="{showProjectManager}"
bind:showRootResource="{showRootResource}"
Expand Down Expand Up @@ -211,7 +213,6 @@ Answer by running riddle.answer('your answer here') from the console.`);
dataLenPromise="{dataLenPromise}"
resources="{resources}"
scrollY="{hexScrollY}"
bind:resourceNodeDataMap="{resourceNodeDataMap}"
/>
{/if}
<!--
Expand Down Expand Up @@ -242,7 +243,6 @@ Answer by running riddle.answer('your answer here') from the console.`);
bind:showProjectManager="{showProjectManager}"
bind:resources="{resources}"
bind:rootResource="{rootResource}"
bind:resourceNodeDataMap="{resourceNodeDataMap}"
/>
{/if}

Expand Down
13 changes: 7 additions & 6 deletions frontend/src/hex/ByteclassView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@

import { hexToByteArray } from "../helpers.js";
import { screenHeight } from "./stores.js";
import { selectedResource, settings } from "../stores.js";
import { selectedResource, settings, dataLength } from "../stores.js";

import { onMount } from "svelte";

export let dataLength, currentPosition;
export let currentPosition;
let data = undefined;

$: colorArray = [
Expand Down Expand Up @@ -129,9 +129,9 @@
// Offset Y by 0.5 because of: https://stackoverflow.com/a/48970774
context.strokeRect(
0,
Math.ceil((currentPosition / dataLength) * canvas.height) - 0.5,
Math.ceil((currentPosition / $dataLength) * canvas.height) - 0.5,
alignment,
Math.ceil(($screenHeight / dataLength) * canvas.height)
Math.ceil(($screenHeight / $dataLength) * canvas.height)
);
}
}
Expand All @@ -143,7 +143,8 @@
on:mousedown="{(e) => {
currentPosition =
Math.floor(
Math.floor(dataLength * (e.offsetY / canvas.offsetHeight)) / alignment
Math.floor($dataLength * (e.offsetY / canvas.offsetHeight)) /
alignment
) * alignment;
clicking = true;
}}"
Expand All @@ -157,7 +158,7 @@
if (clicking) {
currentPosition =
Math.floor(
Math.floor(dataLength * (e.offsetY / canvas.offsetHeight)) /
Math.floor($dataLength * (e.offsetY / canvas.offsetHeight)) /
alignment
) * alignment;
clicking = true;
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/hex/EntropyView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@

import { screenHeight } from "./stores.js";
import { hexToByteArray } from "../helpers.js";
import { selectedResource, settings } from "../stores.js";
import { selectedResource, settings, dataLength } from "../stores.js";

import { onMount } from "svelte";
export let dataLength, currentPosition;
export let currentPosition;
let data = undefined;

$: bgcolors = hexToByteArray($settings.background.slice(1));
Expand Down Expand Up @@ -109,9 +109,9 @@
// Offset Y by 0.5 because of: https://stackoverflow.com/a/48970774
context.strokeRect(
0,
Math.ceil((currentPosition / dataLength) * canvas.height) - 0.5,
Math.ceil((currentPosition / $dataLength) * canvas.height) - 0.5,
alignment,
Math.ceil(($screenHeight / dataLength) * canvas.height)
Math.ceil(($screenHeight / $dataLength) * canvas.height)
);
}

Expand All @@ -128,7 +128,7 @@
on:mousedown="{(e) => {
currentPosition =
Math.floor(
Math.floor(dataLength * (e.offsetY / canvas.offsetHeight)) / 16
Math.floor($dataLength * (e.offsetY / canvas.offsetHeight)) / 16
) * 16;
clicking = true;
}}"
Expand All @@ -142,7 +142,7 @@
if (clicking) {
currentPosition =
Math.floor(
Math.floor(dataLength * (e.offsetY / canvas.offsetHeight)) / 16
Math.floor($dataLength * (e.offsetY / canvas.offsetHeight)) / 16
) * 16;
clicking = true;
}
Expand Down
Loading