Versie 0.2.0
This commit is contained in:
commit
e77d8fd373
495 files changed
+81026
No files matched your search
@@ -0,0 +1,32 @@
|
||||
// Generated, do not edit. sha256:bee329db148fa1f318902e8add4230015eac6bdf80b4700aa7a993e8d1c5e7ee
|
||||
import { momentumOf } from '../price/momentum.js';
|
||||
import { esc } from '../ui/escape.js';
|
||||
import { t } from '../i18n/index.js';
|
||||
|
||||
export function momentumOn(instance) {
|
||||
const p = instance && instance.params;
|
||||
return !(p && p.momentum === false);
|
||||
}
|
||||
|
||||
export function momentumDotHtml(assetId, on) {
|
||||
if (!on || assetId == null) return '';
|
||||
const { up, down, tone } = momentumOf(assetId);
|
||||
if (!tone) return '';
|
||||
const n = up + down;
|
||||
const pct = Math.round(((tone === 'up' ? up : down) / n) * 100);
|
||||
const hint = t(tone === 'up' ? 'dashboard.momentumUp' : 'dashboard.momentumDown', { pct, n });
|
||||
return `<span class="momentum-dot is-${tone}" title="${esc(hint)}"></span>`;
|
||||
}
|
||||
|
||||
export function renderMomentumSetting(host, instance, commit) {
|
||||
const row = document.createElement('div');
|
||||
row.className = 'dash-set-row';
|
||||
row.innerHTML = `<label class="clockw-check"><span class="toggle-switch"><input type="checkbox" data-momentum${momentumOn(instance) ? ' checked' : ''}/><span class="toggle-track"></span></span><span class="clockw-check-name">${esc(t('dashboard.momentum'))}</span></label>`;
|
||||
host.appendChild(row);
|
||||
row.addEventListener('change', e => {
|
||||
const box = e.target.closest('[data-momentum]');
|
||||
if (!box) return;
|
||||
instance.params = { ...(instance.params || {}), momentum: box.checked };
|
||||
commit();
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user