@jjlmoya/utils-chrono 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +65 -0
- package/scripts/postinstall.mjs +27 -0
- package/src/category/ChronoCategorySEO.astro +8 -0
- package/src/category/i18n/de.ts +23 -0
- package/src/category/i18n/en.ts +23 -0
- package/src/category/i18n/es.ts +23 -0
- package/src/category/i18n/fr.ts +23 -0
- package/src/category/i18n/id.ts +23 -0
- package/src/category/i18n/it.ts +23 -0
- package/src/category/i18n/ja.ts +23 -0
- package/src/category/i18n/ko.ts +23 -0
- package/src/category/i18n/nl.ts +23 -0
- package/src/category/i18n/pl.ts +23 -0
- package/src/category/i18n/pt.ts +23 -0
- package/src/category/i18n/ru.ts +23 -0
- package/src/category/i18n/sv.ts +23 -0
- package/src/category/i18n/tr.ts +23 -0
- package/src/category/i18n/zh.ts +23 -0
- package/src/category/index.ts +42 -0
- package/src/components/PreviewNavSidebar.astro +116 -0
- package/src/components/PreviewToolbar.astro +143 -0
- package/src/data.ts +11 -0
- package/src/entries.ts +32 -0
- package/src/env.d.ts +5 -0
- package/src/index.ts +28 -0
- package/src/layouts/PreviewLayout.astro +117 -0
- package/src/pages/[locale]/[slug].astro +161 -0
- package/src/pages/[locale].astro +251 -0
- package/src/pages/index.astro +4 -0
- package/src/tests/faq_count.test.ts +19 -0
- package/src/tests/i18n_coverage.test.ts +36 -0
- package/src/tests/locale_completeness.test.ts +29 -0
- package/src/tests/mocks/astro_mock.js +2 -0
- package/src/tests/no_h1_in_components.test.ts +48 -0
- package/src/tests/schemas_fulfillment.test.ts +23 -0
- package/src/tests/seo_length.test.ts +22 -0
- package/src/tests/shared-test-helpers.ts +56 -0
- package/src/tests/slug_language_code_format.test.ts +23 -0
- package/src/tests/slug_uniqueness.test.ts +81 -0
- package/src/tests/title_quality.test.ts +55 -0
- package/src/tests/tool_exports.test.ts +34 -0
- package/src/tests/tool_validation.test.ts +18 -0
- package/src/tool/beat-rate-converter/beat-rate-converter.css +301 -0
- package/src/tool/beat-rate-converter/bibliography.astro +16 -0
- package/src/tool/beat-rate-converter/bibliography.ts +12 -0
- package/src/tool/beat-rate-converter/client.ts +46 -0
- package/src/tool/beat-rate-converter/component.astro +15 -0
- package/src/tool/beat-rate-converter/components/ConverterPanel.astro +87 -0
- package/src/tool/beat-rate-converter/entry.ts +42 -0
- package/src/tool/beat-rate-converter/i18n/de.ts +138 -0
- package/src/tool/beat-rate-converter/i18n/en.ts +138 -0
- package/src/tool/beat-rate-converter/i18n/es.ts +138 -0
- package/src/tool/beat-rate-converter/i18n/fr.ts +138 -0
- package/src/tool/beat-rate-converter/i18n/id.ts +138 -0
- package/src/tool/beat-rate-converter/i18n/it.ts +138 -0
- package/src/tool/beat-rate-converter/i18n/ja.ts +138 -0
- package/src/tool/beat-rate-converter/i18n/ko.ts +138 -0
- package/src/tool/beat-rate-converter/i18n/nl.ts +138 -0
- package/src/tool/beat-rate-converter/i18n/pl.ts +138 -0
- package/src/tool/beat-rate-converter/i18n/pt.ts +138 -0
- package/src/tool/beat-rate-converter/i18n/ru.ts +138 -0
- package/src/tool/beat-rate-converter/i18n/sv.ts +138 -0
- package/src/tool/beat-rate-converter/i18n/tr.ts +138 -0
- package/src/tool/beat-rate-converter/i18n/zh.ts +138 -0
- package/src/tool/beat-rate-converter/index.ts +11 -0
- package/src/tool/beat-rate-converter/seo.astro +16 -0
- package/src/tool/crown-reference-guide/bibliography.astro +16 -0
- package/src/tool/crown-reference-guide/bibliography.ts +20 -0
- package/src/tool/crown-reference-guide/client.ts +193 -0
- package/src/tool/crown-reference-guide/component.astro +69 -0
- package/src/tool/crown-reference-guide/components/CrownView.astro +40 -0
- package/src/tool/crown-reference-guide/components/MovementSelector.astro +26 -0
- package/src/tool/crown-reference-guide/components/PositionPanel.astro +59 -0
- package/src/tool/crown-reference-guide/crown-reference-guide.css +383 -0
- package/src/tool/crown-reference-guide/entry.ts +60 -0
- package/src/tool/crown-reference-guide/i18n/de.ts +207 -0
- package/src/tool/crown-reference-guide/i18n/en.ts +207 -0
- package/src/tool/crown-reference-guide/i18n/es.ts +207 -0
- package/src/tool/crown-reference-guide/i18n/fr.ts +207 -0
- package/src/tool/crown-reference-guide/i18n/id.ts +207 -0
- package/src/tool/crown-reference-guide/i18n/it.ts +207 -0
- package/src/tool/crown-reference-guide/i18n/ja.ts +207 -0
- package/src/tool/crown-reference-guide/i18n/ko.ts +207 -0
- package/src/tool/crown-reference-guide/i18n/nl.ts +207 -0
- package/src/tool/crown-reference-guide/i18n/pl.ts +207 -0
- package/src/tool/crown-reference-guide/i18n/pt.ts +207 -0
- package/src/tool/crown-reference-guide/i18n/ru.ts +207 -0
- package/src/tool/crown-reference-guide/i18n/sv.ts +207 -0
- package/src/tool/crown-reference-guide/i18n/tr.ts +207 -0
- package/src/tool/crown-reference-guide/i18n/zh.ts +207 -0
- package/src/tool/crown-reference-guide/index.ts +11 -0
- package/src/tool/crown-reference-guide/seo.astro +16 -0
- package/src/tool/crown-reference-guide/utils.ts +0 -0
- package/src/tool/demagnetizing-timer/bibliography.astro +16 -0
- package/src/tool/demagnetizing-timer/bibliography.ts +12 -0
- package/src/tool/demagnetizing-timer/client.ts +221 -0
- package/src/tool/demagnetizing-timer/component.astro +15 -0
- package/src/tool/demagnetizing-timer/components/TimerPanel.astro +92 -0
- package/src/tool/demagnetizing-timer/demagnetizing-timer.css +389 -0
- package/src/tool/demagnetizing-timer/entry.ts +50 -0
- package/src/tool/demagnetizing-timer/helpers/field.ts +134 -0
- package/src/tool/demagnetizing-timer/i18n/de.ts +143 -0
- package/src/tool/demagnetizing-timer/i18n/en.ts +143 -0
- package/src/tool/demagnetizing-timer/i18n/es.ts +143 -0
- package/src/tool/demagnetizing-timer/i18n/fr.ts +143 -0
- package/src/tool/demagnetizing-timer/i18n/id.ts +143 -0
- package/src/tool/demagnetizing-timer/i18n/it.ts +143 -0
- package/src/tool/demagnetizing-timer/i18n/ja.ts +143 -0
- package/src/tool/demagnetizing-timer/i18n/ko.ts +143 -0
- package/src/tool/demagnetizing-timer/i18n/nl.ts +143 -0
- package/src/tool/demagnetizing-timer/i18n/pl.ts +143 -0
- package/src/tool/demagnetizing-timer/i18n/pt.ts +143 -0
- package/src/tool/demagnetizing-timer/i18n/ru.ts +143 -0
- package/src/tool/demagnetizing-timer/i18n/sv.ts +143 -0
- package/src/tool/demagnetizing-timer/i18n/tr.ts +143 -0
- package/src/tool/demagnetizing-timer/i18n/zh.ts +143 -0
- package/src/tool/demagnetizing-timer/index.ts +11 -0
- package/src/tool/demagnetizing-timer/seo.astro +16 -0
- package/src/tool/demagnetizing-timer/utils.ts +0 -0
- package/src/tool/power-reserve-estimator/bibliography.astro +16 -0
- package/src/tool/power-reserve-estimator/bibliography.ts +16 -0
- package/src/tool/power-reserve-estimator/client.ts +139 -0
- package/src/tool/power-reserve-estimator/component.astro +15 -0
- package/src/tool/power-reserve-estimator/components/EstimatorPanel.astro +150 -0
- package/src/tool/power-reserve-estimator/entry.ts +51 -0
- package/src/tool/power-reserve-estimator/i18n/de.ts +158 -0
- package/src/tool/power-reserve-estimator/i18n/en.ts +158 -0
- package/src/tool/power-reserve-estimator/i18n/es.ts +158 -0
- package/src/tool/power-reserve-estimator/i18n/fr.ts +158 -0
- package/src/tool/power-reserve-estimator/i18n/id.ts +158 -0
- package/src/tool/power-reserve-estimator/i18n/it.ts +158 -0
- package/src/tool/power-reserve-estimator/i18n/ja.ts +158 -0
- package/src/tool/power-reserve-estimator/i18n/ko.ts +158 -0
- package/src/tool/power-reserve-estimator/i18n/nl.ts +158 -0
- package/src/tool/power-reserve-estimator/i18n/pl.ts +158 -0
- package/src/tool/power-reserve-estimator/i18n/pt.ts +158 -0
- package/src/tool/power-reserve-estimator/i18n/ru.ts +158 -0
- package/src/tool/power-reserve-estimator/i18n/sv.ts +158 -0
- package/src/tool/power-reserve-estimator/i18n/tr.ts +158 -0
- package/src/tool/power-reserve-estimator/i18n/zh.ts +158 -0
- package/src/tool/power-reserve-estimator/index.ts +11 -0
- package/src/tool/power-reserve-estimator/power-reserve-estimator.css +402 -0
- package/src/tool/power-reserve-estimator/seo.astro +16 -0
- package/src/tool/strap-taper-calculator/bibliography.astro +16 -0
- package/src/tool/strap-taper-calculator/bibliography.ts +12 -0
- package/src/tool/strap-taper-calculator/client.ts +129 -0
- package/src/tool/strap-taper-calculator/component.astro +15 -0
- package/src/tool/strap-taper-calculator/components/CalculatorPanel.astro +114 -0
- package/src/tool/strap-taper-calculator/entry.ts +56 -0
- package/src/tool/strap-taper-calculator/i18n/de.ts +152 -0
- package/src/tool/strap-taper-calculator/i18n/en.ts +152 -0
- package/src/tool/strap-taper-calculator/i18n/es.ts +152 -0
- package/src/tool/strap-taper-calculator/i18n/fr.ts +152 -0
- package/src/tool/strap-taper-calculator/i18n/id.ts +152 -0
- package/src/tool/strap-taper-calculator/i18n/it.ts +152 -0
- package/src/tool/strap-taper-calculator/i18n/ja.ts +152 -0
- package/src/tool/strap-taper-calculator/i18n/ko.ts +152 -0
- package/src/tool/strap-taper-calculator/i18n/nl.ts +152 -0
- package/src/tool/strap-taper-calculator/i18n/pl.ts +152 -0
- package/src/tool/strap-taper-calculator/i18n/pt.ts +152 -0
- package/src/tool/strap-taper-calculator/i18n/ru.ts +152 -0
- package/src/tool/strap-taper-calculator/i18n/sv.ts +152 -0
- package/src/tool/strap-taper-calculator/i18n/tr.ts +152 -0
- package/src/tool/strap-taper-calculator/i18n/zh.ts +152 -0
- package/src/tool/strap-taper-calculator/index.ts +11 -0
- package/src/tool/strap-taper-calculator/seo.astro +16 -0
- package/src/tool/strap-taper-calculator/strap-taper-calculator.css +320 -0
- package/src/tool/watch-accuracy-tracker/bibliography.astro +16 -0
- package/src/tool/watch-accuracy-tracker/bibliography.ts +12 -0
- package/src/tool/watch-accuracy-tracker/chart.ts +126 -0
- package/src/tool/watch-accuracy-tracker/client.ts +287 -0
- package/src/tool/watch-accuracy-tracker/component.astro +35 -0
- package/src/tool/watch-accuracy-tracker/components/AccuracyTracker.astro +96 -0
- package/src/tool/watch-accuracy-tracker/components/DriftPredictor.astro +126 -0
- package/src/tool/watch-accuracy-tracker/components/LogHistory.astro +66 -0
- package/src/tool/watch-accuracy-tracker/entry.ts +94 -0
- package/src/tool/watch-accuracy-tracker/i18n/de.ts +167 -0
- package/src/tool/watch-accuracy-tracker/i18n/en.ts +167 -0
- package/src/tool/watch-accuracy-tracker/i18n/es.ts +167 -0
- package/src/tool/watch-accuracy-tracker/i18n/fr.ts +167 -0
- package/src/tool/watch-accuracy-tracker/i18n/id.ts +167 -0
- package/src/tool/watch-accuracy-tracker/i18n/it.ts +167 -0
- package/src/tool/watch-accuracy-tracker/i18n/ja.ts +167 -0
- package/src/tool/watch-accuracy-tracker/i18n/ko.ts +167 -0
- package/src/tool/watch-accuracy-tracker/i18n/nl.ts +167 -0
- package/src/tool/watch-accuracy-tracker/i18n/pl.ts +167 -0
- package/src/tool/watch-accuracy-tracker/i18n/pt.ts +167 -0
- package/src/tool/watch-accuracy-tracker/i18n/ru.ts +167 -0
- package/src/tool/watch-accuracy-tracker/i18n/sv.ts +167 -0
- package/src/tool/watch-accuracy-tracker/i18n/tr.ts +167 -0
- package/src/tool/watch-accuracy-tracker/i18n/zh.ts +167 -0
- package/src/tool/watch-accuracy-tracker/index.ts +9 -0
- package/src/tool/watch-accuracy-tracker/logger.ts +105 -0
- package/src/tool/watch-accuracy-tracker/seo.astro +16 -0
- package/src/tool/watch-accuracy-tracker/utils.ts +99 -0
- package/src/tool/watch-accuracy-tracker/watch-accuracy-tracker.css +564 -0
- package/src/tool/watch-savings-planner/bibliography.astro +16 -0
- package/src/tool/watch-savings-planner/bibliography.ts +8 -0
- package/src/tool/watch-savings-planner/client.ts +271 -0
- package/src/tool/watch-savings-planner/component.astro +33 -0
- package/src/tool/watch-savings-planner/components/AddGoalForm.astro +49 -0
- package/src/tool/watch-savings-planner/components/GoalCard.astro +58 -0
- package/src/tool/watch-savings-planner/entry.ts +62 -0
- package/src/tool/watch-savings-planner/i18n/de.ts +153 -0
- package/src/tool/watch-savings-planner/i18n/en.ts +155 -0
- package/src/tool/watch-savings-planner/i18n/es.ts +153 -0
- package/src/tool/watch-savings-planner/i18n/fr.ts +153 -0
- package/src/tool/watch-savings-planner/i18n/id.ts +153 -0
- package/src/tool/watch-savings-planner/i18n/it.ts +153 -0
- package/src/tool/watch-savings-planner/i18n/ja.ts +153 -0
- package/src/tool/watch-savings-planner/i18n/ko.ts +153 -0
- package/src/tool/watch-savings-planner/i18n/nl.ts +153 -0
- package/src/tool/watch-savings-planner/i18n/pl.ts +153 -0
- package/src/tool/watch-savings-planner/i18n/pt.ts +153 -0
- package/src/tool/watch-savings-planner/i18n/ru.ts +153 -0
- package/src/tool/watch-savings-planner/i18n/sv.ts +153 -0
- package/src/tool/watch-savings-planner/i18n/tr.ts +153 -0
- package/src/tool/watch-savings-planner/i18n/zh.ts +153 -0
- package/src/tool/watch-savings-planner/index.ts +11 -0
- package/src/tool/watch-savings-planner/seo.astro +16 -0
- package/src/tool/watch-savings-planner/utils.ts +0 -0
- package/src/tool/watch-savings-planner/watch-savings-planner.css +460 -0
- package/src/tool/water-resistance-converter/bibliography.astro +16 -0
- package/src/tool/water-resistance-converter/bibliography.ts +16 -0
- package/src/tool/water-resistance-converter/client.ts +56 -0
- package/src/tool/water-resistance-converter/component.astro +15 -0
- package/src/tool/water-resistance-converter/components/ConverterPanel.astro +113 -0
- package/src/tool/water-resistance-converter/entry.ts +52 -0
- package/src/tool/water-resistance-converter/i18n/de.ts +148 -0
- package/src/tool/water-resistance-converter/i18n/en.ts +148 -0
- package/src/tool/water-resistance-converter/i18n/es.ts +148 -0
- package/src/tool/water-resistance-converter/i18n/fr.ts +148 -0
- package/src/tool/water-resistance-converter/i18n/id.ts +148 -0
- package/src/tool/water-resistance-converter/i18n/it.ts +148 -0
- package/src/tool/water-resistance-converter/i18n/ja.ts +148 -0
- package/src/tool/water-resistance-converter/i18n/ko.ts +148 -0
- package/src/tool/water-resistance-converter/i18n/nl.ts +148 -0
- package/src/tool/water-resistance-converter/i18n/pl.ts +148 -0
- package/src/tool/water-resistance-converter/i18n/pt.ts +148 -0
- package/src/tool/water-resistance-converter/i18n/ru.ts +148 -0
- package/src/tool/water-resistance-converter/i18n/sv.ts +148 -0
- package/src/tool/water-resistance-converter/i18n/tr.ts +148 -0
- package/src/tool/water-resistance-converter/i18n/zh.ts +148 -0
- package/src/tool/water-resistance-converter/index.ts +11 -0
- package/src/tool/water-resistance-converter/seo.astro +16 -0
- package/src/tool/water-resistance-converter/water-resistance-converter.css +254 -0
- package/src/tool/wrist-presence-calculator/bibliography.astro +16 -0
- package/src/tool/wrist-presence-calculator/bibliography.ts +12 -0
- package/src/tool/wrist-presence-calculator/client.ts +180 -0
- package/src/tool/wrist-presence-calculator/component.astro +23 -0
- package/src/tool/wrist-presence-calculator/components/CalculatorInputs.astro +97 -0
- package/src/tool/wrist-presence-calculator/components/FitResult.astro +68 -0
- package/src/tool/wrist-presence-calculator/components/Visualizer.astro +16 -0
- package/src/tool/wrist-presence-calculator/entry.ts +59 -0
- package/src/tool/wrist-presence-calculator/helpers/canvas.ts +189 -0
- package/src/tool/wrist-presence-calculator/helpers/results.ts +78 -0
- package/src/tool/wrist-presence-calculator/i18n/de.ts +139 -0
- package/src/tool/wrist-presence-calculator/i18n/en.ts +155 -0
- package/src/tool/wrist-presence-calculator/i18n/es.ts +139 -0
- package/src/tool/wrist-presence-calculator/i18n/fr.ts +139 -0
- package/src/tool/wrist-presence-calculator/i18n/id.ts +139 -0
- package/src/tool/wrist-presence-calculator/i18n/it.ts +139 -0
- package/src/tool/wrist-presence-calculator/i18n/ja.ts +139 -0
- package/src/tool/wrist-presence-calculator/i18n/ko.ts +139 -0
- package/src/tool/wrist-presence-calculator/i18n/nl.ts +139 -0
- package/src/tool/wrist-presence-calculator/i18n/pl.ts +139 -0
- package/src/tool/wrist-presence-calculator/i18n/pt.ts +139 -0
- package/src/tool/wrist-presence-calculator/i18n/ru.ts +139 -0
- package/src/tool/wrist-presence-calculator/i18n/sv.ts +139 -0
- package/src/tool/wrist-presence-calculator/i18n/tr.ts +139 -0
- package/src/tool/wrist-presence-calculator/i18n/zh.ts +155 -0
- package/src/tool/wrist-presence-calculator/index.ts +11 -0
- package/src/tool/wrist-presence-calculator/seo.astro +16 -0
- package/src/tool/wrist-presence-calculator/utils.ts +30 -0
- package/src/tool/wrist-presence-calculator/wrist-presence-calculator.css +372 -0
- package/src/tools.ts +26 -0
- package/src/types.ts +70 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { SEORenderer } from '@jjlmoya/utils-shared';
|
|
3
|
+
import { crownReferenceGuide } from './index';
|
|
4
|
+
import type { KnownLocale } from '../../types';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
locale?: KnownLocale;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const { locale = 'en' } = Astro.props;
|
|
11
|
+
const loader = crownReferenceGuide.i18n[locale] || crownReferenceGuide.i18n.en;
|
|
12
|
+
const content = await loader?.();
|
|
13
|
+
if (!content) return null;
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
{content.seo?.length > 0 && <SEORenderer content={{ locale, sections: content.seo }} />}
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { Bibliography as SharedBibliography } from '@jjlmoya/utils-shared';
|
|
3
|
+
import { demagnetizingTimer } from './index';
|
|
4
|
+
import type { KnownLocale } from '../../types';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
locale?: KnownLocale;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const { locale = 'en' } = Astro.props as Props;
|
|
11
|
+
const loader = demagnetizingTimer.i18n[locale] || demagnetizingTimer.i18n.en;
|
|
12
|
+
const content = await loader?.();
|
|
13
|
+
if (!content) return null;
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
{content && <SharedBibliography links={content.bibliography} />}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BibliographyEntry } from '../../types';
|
|
2
|
+
|
|
3
|
+
export const bibliography: BibliographyEntry[] = [
|
|
4
|
+
{
|
|
5
|
+
name: 'How to Demagnetize a Watch Movement',
|
|
6
|
+
url: 'https://en.wikipedia.org/wiki/Demagnetization',
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
name: 'How to Demagnetize A Watch',
|
|
10
|
+
url: 'https://teddybaldassarre.com/en-int/blogs/watches/how-to-demagnetize-a-watch',
|
|
11
|
+
},
|
|
12
|
+
];
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { MagneticField } from './helpers/field';
|
|
2
|
+
|
|
3
|
+
const mainEl = document.querySelector('.tool-main-card') as HTMLElement;
|
|
4
|
+
const ui = mainEl ? JSON.parse(mainEl.dataset.ui || '{}') : {};
|
|
5
|
+
|
|
6
|
+
let duration = 1;
|
|
7
|
+
let elapsed = 0;
|
|
8
|
+
let running = false;
|
|
9
|
+
let animFrameId: number | null = null;
|
|
10
|
+
let startTimestamp: number | null = null;
|
|
11
|
+
|
|
12
|
+
const fieldCanvas = document.getElementById('field-canvas') as HTMLCanvasElement;
|
|
13
|
+
const field = new MagneticField(fieldCanvas);
|
|
14
|
+
|
|
15
|
+
const circle = document.getElementById('timer-circle') as HTMLElement;
|
|
16
|
+
const glowRing = document.getElementById('timer-glow-ring') as HTMLElement;
|
|
17
|
+
const progressRing = document.getElementById('timer-progress-ring') as SVGElement;
|
|
18
|
+
const timerValue = document.getElementById('timer-value') as HTMLElement;
|
|
19
|
+
const timerStatus = document.getElementById('timer-status') as HTMLElement;
|
|
20
|
+
const startBtn = document.getElementById('start-btn') as HTMLButtonElement;
|
|
21
|
+
const stopBtn = document.getElementById('stop-btn') as HTMLButtonElement;
|
|
22
|
+
const resetBtn = document.getElementById('reset-btn') as HTMLButtonElement;
|
|
23
|
+
const chips = document.querySelectorAll('.chip') as NodeListOf<HTMLButtonElement>;
|
|
24
|
+
|
|
25
|
+
const circumference = 326.73;
|
|
26
|
+
let audioCtx: AudioContext | null = null;
|
|
27
|
+
|
|
28
|
+
function getAudioContext(): AudioContext {
|
|
29
|
+
if (!audioCtx) {
|
|
30
|
+
audioCtx = new (window.AudioContext || (window as unknown as { webkitAudioContext: typeof AudioContext }).webkitAudioContext)();
|
|
31
|
+
}
|
|
32
|
+
return audioCtx;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function playBeep(frequency: number, durationMs: number, volume = 0.25, type: OscillatorType = 'sine') {
|
|
36
|
+
try {
|
|
37
|
+
const ctx = getAudioContext();
|
|
38
|
+
const osc = ctx.createOscillator();
|
|
39
|
+
const gain = ctx.createGain();
|
|
40
|
+
osc.type = type;
|
|
41
|
+
osc.frequency.value = frequency;
|
|
42
|
+
gain.gain.value = volume;
|
|
43
|
+
gain.gain.exponentialRampToValueAtTime(0.001, ctx.currentTime + durationMs / 1000);
|
|
44
|
+
osc.connect(gain);
|
|
45
|
+
gain.connect(ctx.destination);
|
|
46
|
+
osc.start(ctx.currentTime);
|
|
47
|
+
osc.stop(ctx.currentTime + durationMs / 1000);
|
|
48
|
+
} catch {
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function playStartBeep() {
|
|
53
|
+
playBeep(523, 80, 0.2);
|
|
54
|
+
setTimeout(() => playBeep(659, 80, 0.2), 80);
|
|
55
|
+
setTimeout(() => playBeep(784, 120, 0.25), 160);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function playEndBeep() {
|
|
59
|
+
playBeep(784, 100, 0.25);
|
|
60
|
+
setTimeout(() => playBeep(659, 100, 0.2), 100);
|
|
61
|
+
setTimeout(() => playBeep(523, 200, 0.25), 200);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function playTickBeep() {
|
|
65
|
+
playBeep(880, 30, 0.12);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
let pulseAnimFrame: number | null = null;
|
|
69
|
+
|
|
70
|
+
function startPulseAnimation() {
|
|
71
|
+
let phase = 0;
|
|
72
|
+
const step = 0.05;
|
|
73
|
+
|
|
74
|
+
function tick() {
|
|
75
|
+
phase += step;
|
|
76
|
+
const s = 1 + Math.sin(phase * Math.PI * 2) * 0.02;
|
|
77
|
+
glowRing.style.transform = `translate(-50%, -50%) scale(${s})`;
|
|
78
|
+
glowRing.style.opacity = String(0.3 + Math.sin(phase * Math.PI * 2) * 0.15);
|
|
79
|
+
pulseAnimFrame = requestAnimationFrame(tick);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (pulseAnimFrame) cancelAnimationFrame(pulseAnimFrame);
|
|
83
|
+
pulseAnimFrame = requestAnimationFrame(tick);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function stopPulseAnimation() {
|
|
87
|
+
if (pulseAnimFrame) {
|
|
88
|
+
cancelAnimationFrame(pulseAnimFrame);
|
|
89
|
+
pulseAnimFrame = null;
|
|
90
|
+
}
|
|
91
|
+
glowRing.style.transform = 'translate(-50%, -50%) scale(1)';
|
|
92
|
+
glowRing.style.opacity = '0';
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function setPhase(phase: 'ready' | 'pressing' | 'releasing' | 'complete') {
|
|
96
|
+
circle.className = 'timer-circle';
|
|
97
|
+
|
|
98
|
+
if (phase === 'pressing') {
|
|
99
|
+
circle.classList.add('phase-pressing');
|
|
100
|
+
timerStatus.textContent = ui.holdPhase || 'Hold the button...';
|
|
101
|
+
timerStatus.className = 'timer-status-pill status-pressing';
|
|
102
|
+
startPulseAnimation();
|
|
103
|
+
} else if (phase === 'releasing') {
|
|
104
|
+
circle.classList.add('phase-releasing');
|
|
105
|
+
timerStatus.textContent = ui.releasePhase || 'Release now!';
|
|
106
|
+
timerStatus.className = 'timer-status-pill status-releasing';
|
|
107
|
+
stopPulseAnimation();
|
|
108
|
+
glowRing.style.opacity = '0.6';
|
|
109
|
+
} else if (phase === 'complete') {
|
|
110
|
+
circle.classList.add('phase-complete');
|
|
111
|
+
timerStatus.textContent = ui.completePhase || 'Done!';
|
|
112
|
+
timerStatus.className = 'timer-status-pill status-complete';
|
|
113
|
+
glowRing.style.opacity = '0.2';
|
|
114
|
+
} else {
|
|
115
|
+
timerStatus.textContent = ui.ready || 'Ready';
|
|
116
|
+
timerStatus.className = 'timer-status-pill';
|
|
117
|
+
stopPulseAnimation();
|
|
118
|
+
glowRing.style.opacity = '0';
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function updateDisplay(time: number) {
|
|
123
|
+
timerValue.textContent = time.toFixed(1);
|
|
124
|
+
const progress = Math.min(time / duration, 1);
|
|
125
|
+
const offset = circumference * (1 - progress);
|
|
126
|
+
progressRing.setAttribute('stroke-dashoffset', offset.toString());
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function stopTimer() {
|
|
130
|
+
running = false;
|
|
131
|
+
if (animFrameId !== null) {
|
|
132
|
+
cancelAnimationFrame(animFrameId);
|
|
133
|
+
animFrameId = null;
|
|
134
|
+
}
|
|
135
|
+
startBtn.disabled = false;
|
|
136
|
+
stopBtn.disabled = true;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
let lastTickSecond = -1;
|
|
140
|
+
|
|
141
|
+
function tick(timestamp: number) {
|
|
142
|
+
if (!startTimestamp) {
|
|
143
|
+
startTimestamp = timestamp;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const rawElapsed = (timestamp - startTimestamp) / 1000;
|
|
147
|
+
elapsed = Math.min(rawElapsed, duration);
|
|
148
|
+
|
|
149
|
+
updateDisplay(elapsed);
|
|
150
|
+
|
|
151
|
+
const currentSecond = Math.floor(elapsed);
|
|
152
|
+
if (currentSecond > lastTickSecond) {
|
|
153
|
+
lastTickSecond = currentSecond;
|
|
154
|
+
if (elapsed < duration) {
|
|
155
|
+
playTickBeep();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (elapsed >= duration) {
|
|
160
|
+
setPhase('releasing');
|
|
161
|
+
playEndBeep();
|
|
162
|
+
stopTimer();
|
|
163
|
+
setTimeout(() => {
|
|
164
|
+
setPhase('complete');
|
|
165
|
+
}, 1000);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
animFrameId = requestAnimationFrame(tick);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function startTimer() {
|
|
173
|
+
if (running) return;
|
|
174
|
+
running = true;
|
|
175
|
+
elapsed = 0;
|
|
176
|
+
startTimestamp = null;
|
|
177
|
+
lastTickSecond = -1;
|
|
178
|
+
startBtn.disabled = true;
|
|
179
|
+
stopBtn.disabled = false;
|
|
180
|
+
field.resize();
|
|
181
|
+
field.start();
|
|
182
|
+
setPhase('pressing');
|
|
183
|
+
playStartBeep();
|
|
184
|
+
updateDisplay(0);
|
|
185
|
+
animFrameId = requestAnimationFrame(tick);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function resetTimer() {
|
|
189
|
+
stopTimer();
|
|
190
|
+
field.stop();
|
|
191
|
+
elapsed = 0;
|
|
192
|
+
startTimestamp = null;
|
|
193
|
+
lastTickSecond = -1;
|
|
194
|
+
updateDisplay(0);
|
|
195
|
+
setPhase('ready');
|
|
196
|
+
circle.className = 'timer-circle';
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
startBtn.addEventListener('click', startTimer);
|
|
200
|
+
|
|
201
|
+
stopBtn.addEventListener('click', () => {
|
|
202
|
+
field.stop();
|
|
203
|
+
stopTimer();
|
|
204
|
+
setPhase('ready');
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
resetBtn.addEventListener('click', resetTimer);
|
|
208
|
+
|
|
209
|
+
chips.forEach((chip) => {
|
|
210
|
+
chip.addEventListener('click', () => {
|
|
211
|
+
if (running) return;
|
|
212
|
+
chips.forEach((c) => c.classList.remove('active'));
|
|
213
|
+
chip.classList.add('active');
|
|
214
|
+
duration = parseInt(chip.dataset.duration || '1', 10);
|
|
215
|
+
resetTimer();
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
window.addEventListener('resize', () => field.resize());
|
|
220
|
+
|
|
221
|
+
resetTimer();
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
import TimerPanel from './components/TimerPanel.astro';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
ui: Record<string, string>;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const { ui } = Astro.props;
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
<div class="tool-main-card" data-ui={JSON.stringify(ui)}>
|
|
12
|
+
<TimerPanel labels={ui} />
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<script src="./client.ts"></script>
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
---
|
|
2
|
+
interface Props {
|
|
3
|
+
labels: Record<string, string>;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
const { labels } = Astro.props;
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
<div class="timer-panel">
|
|
10
|
+
<div class="timer-display-section">
|
|
11
|
+
<div class="timer-circle-wrapper">
|
|
12
|
+
<canvas class="field-canvas" id="field-canvas"></canvas>
|
|
13
|
+
<div class="timer-circle" id="timer-circle">
|
|
14
|
+
<svg class="timer-svg" viewBox="0 0 120 120">
|
|
15
|
+
<defs>
|
|
16
|
+
<filter id="glow">
|
|
17
|
+
<feGaussianBlur stdDeviation="2.5" result="blur" />
|
|
18
|
+
<feMerge>
|
|
19
|
+
<feMergeNode in="blur" />
|
|
20
|
+
<feMergeNode in="SourceGraphic" />
|
|
21
|
+
</feMerge>
|
|
22
|
+
</filter>
|
|
23
|
+
</defs>
|
|
24
|
+
<circle class="timer-bg-ring" cx="60" cy="60" r="52" />
|
|
25
|
+
<circle class="timer-progress-ring" id="timer-progress-ring" cx="60" cy="60" r="52"
|
|
26
|
+
stroke-dasharray="326.73" stroke-dashoffset="0" filter="url(#glow)" />
|
|
27
|
+
</svg>
|
|
28
|
+
<div class="timer-text" id="timer-text">
|
|
29
|
+
<span class="timer-value" id="timer-value">0.0</span>
|
|
30
|
+
<span class="timer-unit" id="timer-unit">{labels.seconds || "s"}</span>
|
|
31
|
+
</div>
|
|
32
|
+
<div class="timer-glow-ring" id="timer-glow-ring"></div>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
<div class="timer-status-pill" id="timer-status">{labels.ready || "Ready"}</div>
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
<div class="timer-controls">
|
|
39
|
+
<button type="button" class="timer-btn start-btn" id="start-btn">
|
|
40
|
+
<svg class="btn-icon" viewBox="0 0 24 24" width="18" height="18">
|
|
41
|
+
<path d="M8 5v14l11-7z" fill="currentColor" />
|
|
42
|
+
</svg>
|
|
43
|
+
{labels.startButton || "Start"}
|
|
44
|
+
</button>
|
|
45
|
+
<button type="button" class="timer-btn stop-btn" id="stop-btn" disabled>
|
|
46
|
+
<svg class="btn-icon" viewBox="0 0 24 24" width="18" height="18">
|
|
47
|
+
<rect x="6" y="6" width="12" height="12" rx="1" fill="currentColor" />
|
|
48
|
+
</svg>
|
|
49
|
+
{labels.stopButton || "Stop"}
|
|
50
|
+
</button>
|
|
51
|
+
<button type="button" class="timer-btn reset-btn" id="reset-btn">
|
|
52
|
+
<svg class="btn-icon" viewBox="0 0 24 24" width="18" height="18">
|
|
53
|
+
<path d="M17.65 6.35A7.958 7.958 0 0012 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08A5.99 5.99 0 0112 18c-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z" fill="currentColor" />
|
|
54
|
+
</svg>
|
|
55
|
+
</button>
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
<div class="duration-selector">
|
|
59
|
+
<div class="chip-group-label">{labels.durationLabel || "Pulse"}</div>
|
|
60
|
+
<div class="chip-group">
|
|
61
|
+
<button type="button" class="chip active" data-duration="1">1s</button>
|
|
62
|
+
<button type="button" class="chip" data-duration="2">2s</button>
|
|
63
|
+
<button type="button" class="chip" data-duration="3">3s</button>
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
|
|
67
|
+
<div class="steps-section">
|
|
68
|
+
<div class="step-row">
|
|
69
|
+
<div class="step-marker">1</div>
|
|
70
|
+
<span class="step-text">{labels.step1 || "Place watch on demagnetizer."}</span>
|
|
71
|
+
</div>
|
|
72
|
+
<div class="step-row">
|
|
73
|
+
<div class="step-marker">2</div>
|
|
74
|
+
<span class="step-text">{labels.step2 || "Press Start, hold button for set duration."}</span>
|
|
75
|
+
</div>
|
|
76
|
+
<div class="step-row">
|
|
77
|
+
<div class="step-marker">3</div>
|
|
78
|
+
<span class="step-text">{labels.step3 || "Release button, move watch away slowly."}</span>
|
|
79
|
+
</div>
|
|
80
|
+
<div class="step-row">
|
|
81
|
+
<div class="step-marker">4</div>
|
|
82
|
+
<span class="step-text">{labels.step4 || "Repeat 2–3 times, rotating the watch."}</span>
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
<div class="tip-row">
|
|
87
|
+
<svg class="tip-icon" viewBox="0 0 24 24" width="16" height="16">
|
|
88
|
+
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" fill="currentColor" />
|
|
89
|
+
</svg>
|
|
90
|
+
<span class="tip-text">{labels.tipContent || "Keep the watch at least 1 meter away when powered on."}</span>
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|