Skip to content

Commit

Permalink
Add header to each matrix scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
kneasle committed Jun 23, 2024
1 parent ae4a7e4 commit 9098759
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions main-page/ts/matrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,20 @@ function main() {
window.addEventListener("load", main);

function makeMatrix(elem: HTMLElement, distance: number) {
fetch(random_url())
const url = random_url();
fetch(url)
.then((response: Response) => response.text())
.then((code: string) => {
// Parse the URL to add a header line to the code
const parts = /https:\/\/raw.githubusercontent.com\/kneasle\/(.+)\/[0-9a-f]+\/(.*)/.exec(url);
const repoSlug = parts![1];
const file = parts![2];
const textToDisplay =
`[[Writing file: ${file} from github.com/kneasle/${repoSlug}]]\n\n${code}`;

// Create the matrix
const speed = 30 + 20 * Math.random();
matrices.push(new Matrix(code, elem, speed, distance));
matrices.push(new Matrix(textToDisplay, elem, speed, distance));
});
}

Expand Down

0 comments on commit 9098759

Please sign in to comment.