global: snapshot

This commit is contained in:
k
2024-10-08 21:47:46 +02:00
parent 068bb07d6e
commit 79ffbf3d1d
25 changed files with 2696 additions and 1480 deletions
+236 -46
View File
@@ -15,11 +15,12 @@
<meta name="mobile-web-app-capable" content="yes" />
<script type="module" crossorigin src="./script.js"></script>
<!-- ------ -->
<!-- Styles -->
<!-- ------ -->
<!-- Tailwind Base -->
<style>
/* Tailwind base */
*,
::after,
::before,
@@ -217,6 +218,7 @@
}
</style>
<!-- Custom -->
<style>
:root {
--default-font-family: "Satoshi";
@@ -803,6 +805,23 @@
color: var(--orange);
}
summary {
list-style: none;
display: flex;
align-items: center;
cursor: pointer;
position: relative;
&::marker,
&::-webkit-details-marker {
display: none;
}
&:hover {
color: var(--orange);
}
}
svg {
width: 20px;
height: 20px;
@@ -888,21 +907,8 @@
}
> details > summary {
list-style: none;
display: flex;
align-items: center;
cursor: pointer;
position: relative;
&::marker,
&::-webkit-details-marker {
display: none;
}
&:hover {
color: var(--orange);
}
details[open] > & {
&::after {
content: "";
@@ -1024,49 +1030,56 @@
}
> #dashboards {
display: flex;
flex-direction: column;
z-index: 50;
margin: -0.5px calc(-1.5rem - 1px);
display: flex;
> table {
flex: 1;
table-layout: auto;
border-collapse: separate;
border-spacing: 0px 1px;
border: 1px;
border-top: 0;
padding: 0.25rem 0;
margin: -0.5px;
/* font-size: var(--font-size-xs);
line-height: var(--line-height-xs); */
> details {
/* border: 1px; */
caption {
border-bottom-style: dashed !important;
border-width: 1px;
padding: 0.375rem 0.625rem;
> summary {
margin: -0.5px;
display: block;
padding: 0.5rem 1.5rem;
text-align: left;
}
tr {
border: 1px;
&:hover,
&:hover * {
color: var(--orange) !important;
details[open] > & {
border-bottom-style: dashed !important;
border-bottom-width: 1px;
}
}
td {
padding: 0.125rem 0.625rem;
text-align: right;
> table {
border: 1px;
border-top-width: 0px;
margin: -0.5px;
width: calc(100% + 1px);
border-collapse: separate;
&:first-child {
text-align: left;
color: var(--off-color);
table-layout: auto;
padding: 0.375rem 1.5rem;
tr {
/* border: 1px; */
&:hover,
&:hover * {
color: var(--orange) !important;
}
> i {
color: var(--off-color);
td {
padding: 0.125rem 0;
text-align: right;
&:first-child {
text-align: left;
color: var(--off-color);
}
> i {
color: var(--off-color);
}
}
}
}
@@ -1373,7 +1386,184 @@
}
</style>
<!-- Flex Masonry -->
<style>
.flexmasonry {
display: flex;
flex-flow: column wrap;
align-content: space-between;
}
.flexmasonry-item {
width: 100%;
.flexmasonry-cols-2 & {
width: 50%;
&:nth-child(2n + 1) {
order: 1;
}
&:nth-child(2n) {
order: 2;
}
}
.flexmasonry-cols-3 & {
width: 33.333%;
&:nth-child(3n + 1) {
order: 1;
}
&:nth-child(3n + 2) {
order: 2;
}
&:nth-child(3n) {
order: 3;
}
}
.flexmasonry-cols-4 & {
width: 25%;
&:nth-child(4n + 1) {
order: 1;
}
&:nth-child(4n + 2) {
order: 2;
}
&:nth-child(4n + 3) {
order: 3;
}
&:nth-child(4n) {
order: 4;
}
}
.flexmasonry-cols-5 & {
width: 20%;
&:nth-child(5n + 1) {
order: 1;
}
&:nth-child(5n + 2) {
order: 2;
}
&:nth-child(5n + 3) {
order: 3;
}
&:nth-child(5n + 4) {
order: 4;
}
&:nth-child(5n) {
order: 5;
}
}
.flexmasonry-cols-6 & {
width: 16.666%;
&:nth-child(6n + 1) {
order: 1;
}
&:nth-child(6n + 2) {
order: 2;
}
&:nth-child(6n + 3) {
order: 3;
}
&:nth-child(6n + 4) {
order: 4;
}
&:nth-child(6n + 5) {
order: 5;
}
&:nth-child(6n) {
order: 6;
}
}
.flexmasonry-cols-7 & {
width: 14.285%;
&:nth-child(7n + 1) {
order: 1;
}
&:nth-child(7n + 2) {
order: 2;
}
&:nth-child(7n + 3) {
order: 3;
}
&:nth-child(7n + 4) {
order: 4;
}
&:nth-child(7n + 5) {
order: 5;
}
&:nth-child(7n + 6) {
order: 6;
}
&:nth-child(7n) {
order: 7;
}
}
.flexmasonry-cols-8 & {
width: 12.5%;
&:nth-child(8n + 1) {
order: 1;
}
&:nth-child(8n + 2) {
order: 2;
}
&:nth-child(8n + 3) {
order: 3;
}
&:nth-child(8n + 4) {
order: 4;
}
&:nth-child(8n + 5) {
order: 5;
}
&:nth-child(8n + 6) {
order: 6;
}
&:nth-child(8n + 7) {
order: 7;
}
&:nth-child(8n) {
order: 8;
}
}
}
.flexmasonry-break {
content: "";
flex-basis: 100%;
width: 0 !important;
margin: 0;
}
.flexmasonry-break-1 {
order: 1;
}
.flexmasonry-break-2 {
order: 2;
}
.flexmasonry-break-3 {
order: 3;
}
.flexmasonry-break-4 {
order: 4;
}
.flexmasonry-break-5 {
order: 5;
}
.flexmasonry-break-6 {
order: 6;
}
.flexmasonry-break-7 {
order: 7;
}
</style>
<!-- ------- -->
<!-- Scripts -->
<!-- ------- -->
<script>
// @ts-check
+3
View File
@@ -0,0 +1,3 @@
URL + Version:
https://unpkg.com/browse/flexmasonry@latest/
@@ -0,0 +1,198 @@
const defaultOptions = {
/*
* If `responsive` is `true`, `breakpointCols` will be used to determine
* how many columns a grid should have at a given responsive breakpoint.
*/
responsive: true,
/*
* A list of how many columns should be shown at different responsive
* breakpoints, defined by media queries.
*/
breakpointCols: {
1500: 5,
1200: 4,
992: 3,
768: 2,
576: 1,
},
/*
* If `responsive` is `false`, this number of columns will always be shown,
* no matter the width of the screen.
*/
numCols: 4,
};
let _resizeId = null;
let _options = {};
let _targets = [];
function init(targets, options = {}) {
if (typeof targets === "string") {
_targets = document.querySelectorAll(targets);
} else {
_targets = targets;
}
_options = Object.assign(defaultOptions, options);
_targets.forEach(function (target) {
setUp(target);
// setHeight(target);
});
addEventListeners();
return this;
}
function setUp(target) {
target.classList.add("flexmasonry");
if (_options.responsive) {
target.classList.add("flexmasonry-responsive");
}
setColsClass(target);
Array.from(target.children).forEach(function (item) {
item.classList.add("flexmasonry-item");
});
addBreakElements(target);
}
// function onLoad() {
// _targets.forEach(function (target) {
// setHeight(target);
// });
// }
function onResize() {
if (_resizeId) {
window.cancelAnimationFrame(_resizeId);
}
_resizeId = window.requestAnimationFrame(function () {
refreshAll();
});
}
function addEventListeners() {
// window.addEventListener("load", onLoad);
window.addEventListener("resize", onResize);
}
function removeEventListeners() {
// window.removeEventListener("load", onLoad);
window.removeEventListener("resize", onResize);
}
// function setHeight(target) {
// if (getCurrentCols(target) < 2) {
// target.style.removeProperty("height");
// return;
// }
// let heights = [];
// Array.from(target.children).forEach(function (item) {
// if (item.classList.contains("flexmasonry-break")) {
// return;
// }
// const comp = window.getComputedStyle(item);
// const order = comp.getPropertyValue("order");
// const height = comp.getPropertyValue("height");
// if (!heights[order - 1]) {
// heights[order - 1] = 0;
// }
// heights[order - 1] += Math.ceil(parseFloat(height));
// });
// const maxHeight = Math.max(...heights);
// target.style.height = maxHeight + "px";
// }
function addBreakElements(target) {
const breakEls = target.querySelectorAll(".flexmasonry-break");
if (Array.from(breakEls).length === getCurrentCols(target) - 1) {
return;
}
for (let i = 1; i < getCurrentCols(target); i++) {
const breakDiv = document.createElement("div");
breakDiv.classList.add("flexmasonry-break");
breakDiv.classList.add("flexmasonry-break-" + i);
target.appendChild(breakDiv);
}
}
function removeBreakElements(target) {
const breakEls = target.querySelectorAll(".flexmasonry-break");
if (Array.from(breakEls).length === getCurrentCols(target) - 1) {
return;
}
Array.from(breakEls).forEach(function (breakEl) {
breakEl.parentNode.removeChild(breakEl);
});
}
function setColsClass(target) {
if (target.classList.contains("flexmasonry-cols-" + getCurrentCols(target))) {
return;
}
target.className = target.className.replace(/(flexmasonry-cols-\d+)/, "");
target.classList.add("flexmasonry-cols-" + getCurrentCols(target));
}
function getCurrentCols(target) {
if (!_options.responsive) {
return _options.numCols;
}
const descendingMinWidths = Object.keys(_options.breakpointCols)
.map((key) => Number(key))
.sort()
.reverse();
for (const minWidth of descendingMinWidths) {
if (target.clientWidth >= minWidth) {
return _options.breakpointCols[minWidth];
}
}
return 1;
}
function refresh(target, options = {}) {
_options = Object.assign(defaultOptions, options);
setColsClass(target);
removeBreakElements(target);
addBreakElements(target);
// setHeight(target);
return this;
}
function refreshAll(options = {}) {
_targets.forEach(function (target) {
refresh(target, options);
});
return this;
}
function destroyAll() {
removeEventListeners();
}
export default {
init,
refresh,
refreshAll,
destroyAll,
};
@@ -0,0 +1,170 @@
.flexmasonry {
display: flex;
flex-flow: column wrap;
align-content: space-between;
}
.flexmasonry-item {
width: 100%;
}
.flexmasonry-cols-2 .flexmasonry-item {
width: 50%;
}
.flexmasonry-cols-3 .flexmasonry-item {
width: 33.333%;
}
.flexmasonry-cols-4 .flexmasonry-item {
width: 25%;
}
.flexmasonry-cols-5 .flexmasonry-item {
width: 20%;
}
.flexmasonry-cols-6 .flexmasonry-item {
width: 16.666%;
}
.flexmasonry-cols-7 .flexmasonry-item {
width: 14.285%;
}
.flexmasonry-cols-8 .flexmasonry-item {
width: 12.5%;
}
.flexmasonry-cols-2 .flexmasonry-item:nth-child(2n + 1) {
order: 1;
}
.flexmasonry-cols-2 .flexmasonry-item:nth-child(2n) {
order: 2;
}
.flexmasonry-cols-3 .flexmasonry-item:nth-child(3n + 1) {
order: 1;
}
.flexmasonry-cols-3 .flexmasonry-item:nth-child(3n + 2) {
order: 2;
}
.flexmasonry-cols-3 .flexmasonry-item:nth-child(3n) {
order: 3;
}
.flexmasonry-cols-4 .flexmasonry-item:nth-child(4n + 1) {
order: 1;
}
.flexmasonry-cols-4 .flexmasonry-item:nth-child(4n + 2) {
order: 2;
}
.flexmasonry-cols-4 .flexmasonry-item:nth-child(4n + 3) {
order: 3;
}
.flexmasonry-cols-4 .flexmasonry-item:nth-child(4n) {
order: 4;
}
.flexmasonry-cols-5 .flexmasonry-item:nth-child(5n + 1) {
order: 1;
}
.flexmasonry-cols-5 .flexmasonry-item:nth-child(5n + 2) {
order: 2;
}
.flexmasonry-cols-5 .flexmasonry-item:nth-child(5n + 3) {
order: 3;
}
.flexmasonry-cols-5 .flexmasonry-item:nth-child(5n + 4) {
order: 4;
}
.flexmasonry-cols-5 .flexmasonry-item:nth-child(5n) {
order: 5;
}
.flexmasonry-cols-6 .flexmasonry-item:nth-child(6n + 1) {
order: 1;
}
.flexmasonry-cols-6 .flexmasonry-item:nth-child(6n + 2) {
order: 2;
}
.flexmasonry-cols-6 .flexmasonry-item:nth-child(6n + 3) {
order: 3;
}
.flexmasonry-cols-6 .flexmasonry-item:nth-child(6n + 4) {
order: 4;
}
.flexmasonry-cols-6 .flexmasonry-item:nth-child(6n + 5) {
order: 5;
}
.flexmasonry-cols-6 .flexmasonry-item:nth-child(6n) {
order: 6;
}
.flexmasonry-cols-7 .flexmasonry-item:nth-child(7n + 1) {
order: 1;
}
.flexmasonry-cols-7 .flexmasonry-item:nth-child(7n + 2) {
order: 2;
}
.flexmasonry-cols-7 .flexmasonry-item:nth-child(7n + 3) {
order: 3;
}
.flexmasonry-cols-7 .flexmasonry-item:nth-child(7n + 4) {
order: 4;
}
.flexmasonry-cols-7 .flexmasonry-item:nth-child(7n + 5) {
order: 5;
}
.flexmasonry-cols-7 .flexmasonry-item:nth-child(7n + 6) {
order: 6;
}
.flexmasonry-cols-7 .flexmasonry-item:nth-child(7n) {
order: 7;
}
.flexmasonry-cols-8 .flexmasonry-item:nth-child(8n + 1) {
order: 1;
}
.flexmasonry-cols-8 .flexmasonry-item:nth-child(8n + 2) {
order: 2;
}
.flexmasonry-cols-8 .flexmasonry-item:nth-child(8n + 3) {
order: 3;
}
.flexmasonry-cols-8 .flexmasonry-item:nth-child(8n + 4) {
order: 4;
}
.flexmasonry-cols-8 .flexmasonry-item:nth-child(8n + 5) {
order: 5;
}
.flexmasonry-cols-8 .flexmasonry-item:nth-child(8n + 6) {
order: 6;
}
.flexmasonry-cols-8 .flexmasonry-item:nth-child(8n + 7) {
order: 7;
}
.flexmasonry-cols-8 .flexmasonry-item:nth-child(8n) {
order: 8;
}
.flexmasonry-break {
content: "";
flex-basis: 100%;
width: 0 !important;
margin: 0;
}
.flexmasonry-break-1 {
order: 1;
}
.flexmasonry-break-2 {
order: 2;
}
.flexmasonry-break-3 {
order: 3;
}
.flexmasonry-break-4 {
order: 4;
}
.flexmasonry-break-5 {
order: 5;
}
.flexmasonry-break-6 {
order: 6;
}
.flexmasonry-break-7 {
order: 7;
}
+1828 -1267
View File
File diff suppressed because it is too large Load Diff
+40 -38
View File
@@ -3,6 +3,8 @@
const version = "v1";
self.addEventListener("install", (_event) => {
console.log("service-worker: install");
const event = /** @type {any} */ (_event);
event.waitUntil(
@@ -17,66 +19,66 @@ self.addEventListener("install", (_event) => {
"/packages/lightweight-charts/v4.2.0/script.js",
"/assets/fonts/satoshi/2024-09/font.var.woff2",
]);
})
}),
);
// @ts-ignore
self.skipWaiting();
});
/**
* @param {Response | undefined} cachedResponse
* @param {Response | undefined} badResponse
*/
function pickCorrectResponse(cachedResponse, badResponse) {
if (cachedResponse) {
return cachedResponse;
} else {
return caches
.match("/")
.then((response) => {
return response ?? badResponse;
})
.catch(() => {
return badResponse;
});
}
}
self.addEventListener("fetch", (_event) => {
const event = /** @type {any} */ (_event);
/** @type {Request} */
const request = event.request;
const { url, method } = request;
let request = event.request;
const method = request.method;
let url = request.url;
const { pathname, origin } = new URL(url);
const slashMatches = url.match(/\//g);
const dotMatches = pathname.split("/").at(-1)?.match(/./g);
const endsWithDotHtml = pathname.endsWith(".html");
const slashApiSlashMatches = url.match(/\/api\//g);
if (
slashMatches &&
slashMatches.length <= 3 &&
!slashApiSlashMatches &&
(!dotMatches || endsWithDotHtml)
) {
url = `${origin}/`;
}
request = new Request(url, request.mode !== "navigate" ? request : undefined);
console.log(`service-worker: fetching: ${url}`);
event.respondWith(
caches.match(request).then((cachedResponse) => {
caches.match(request).then(async (cachedResponse) => {
return fetch(request)
.then((response) => {
const { status } = response;
// @ts-ignore
if (method !== "GET" || url.includes("/api/")) {
if (method !== "GET" || slashApiSlashMatches) {
// API calls are cached in script.js
return response;
}
return caches.open(version).then((cache) => {
if (status === 200 || status === 304) {
if (status === 200) {
cache.put(request, response.clone());
}
return response;
} else {
return pickCorrectResponse(cachedResponse, response);
} else if (status === 200 || status === 304) {
if (status === 200) {
const clonedResponse = response.clone();
caches.open(version).then((cache) => {
cache.put(request, clonedResponse);
});
}
});
return response;
} else {
return cachedResponse || response;
}
})
.catch(() => {
return pickCorrectResponse(cachedResponse, undefined);
console.log("service-worker: offline");
return cachedResponse;
});
})
}),
);
});
+3 -3
View File
File diff suppressed because one or more lines are too long
+19 -15
View File
@@ -77,21 +77,23 @@ type SeriesBlueprint = {
} & AnySpecificSeriesBlueprint;
type Unit =
| "US Dollars"
| ""
| "Bitcoin"
| "Percentage"
| "Height"
| "Count"
| "Megabytes"
| "Transactions"
| "Weight"
| "Ratio"
| "Virtual Bytes"
| "Seconds"
| "Coinblocks"
| "ExaHash / Second"
| "Count"
| "Date"
| "Dollars / (PetaHash / Second)"
| "";
| "ExaHash / Second"
| "Height"
| "Megabytes"
| "Percentage"
| "Ratio"
| "Satoshis"
| "Seconds"
| "Transactions"
| "US Dollars"
| "Virtual Bytes"
| "Weight";
interface PartialOption {
icon: string;
@@ -107,6 +109,7 @@ interface PartialHomeOption extends PartialOption {
interface PartialDashboardOption extends PartialOption {
title: string;
description: string;
defaultOpen?: false;
groups: {
name: string;
unit?: Unit;
@@ -114,6 +117,7 @@ interface PartialDashboardOption extends PartialOption {
name: string;
path?: LastPath;
unit?: Unit;
long?: true;
}[];
}[];
}
@@ -194,7 +198,7 @@ interface OHLC {
interface ResourceDataset<
Scale extends TimeScale,
Type extends OHLC | number = number
Type extends OHLC | number = number,
> {
scale: Scale;
url: string;
@@ -212,7 +216,7 @@ interface FetchedResult<
SingleValueData | ValuedCandlestickData
> = DatasetValue<
Type extends number ? SingleValueData : ValuedCandlestickData
>
>,
> {
at: Date | null;
json: Signal<FetchedJSON<Scale, Type> | null>;
@@ -242,7 +246,7 @@ interface FetchedChunk {
type FetchedDataset<
Scale extends TimeScale,
Type extends number | OHLC
Type extends number | OHLC,
> = Scale extends "date"
? FetchedDateDataset<Type>
: FetchedHeightDataset<Type>;