style: apply prettier/eslint quote consistency and add missing comments
This commit is contained in:
@@ -1,14 +1,19 @@
|
||||
import { state } from '../state';
|
||||
import { displayTimeFromAbsolute, absoluteTimeFromDisplay } from '../timeline';
|
||||
import { showControls } from '../controls';
|
||||
import { resolveActiveSegments, renderSegments } from './segments';
|
||||
|
||||
// button label based on segment type
|
||||
const skipLabel = (type: string): string => (type === 'ed' ? 'Skip outro' : 'Skip intro');
|
||||
|
||||
/**
|
||||
* Updates skip button visibility and auto-skip logic.
|
||||
* Called on timeupdate. Shows button when in active segment.
|
||||
*/
|
||||
export const updateSkipButton = (currentTime: number): void => {
|
||||
const btn = state.container.querySelector('[data-skip]') as HTMLButtonElement | null;
|
||||
const displayTime = displayTimeFromAbsolute(currentTime);
|
||||
|
||||
// find segment that contains current time (with delay buffer)
|
||||
const segment = state.activeSegments.find(s => {
|
||||
const delay = Math.min(1, Math.max(0.25, (s.end - s.start) * 0.02));
|
||||
return displayTime >= s.start + delay && displayTime < s.end;
|
||||
@@ -20,12 +25,14 @@ export const updateSkipButton = (currentTime: number): void => {
|
||||
return;
|
||||
}
|
||||
|
||||
// auto-skip: jump to end if enabled
|
||||
const autoSkip = localStorage.getItem('mal:autoskip-enabled') === 'true';
|
||||
if (autoSkip && displayTime >= segment.start && displayTime < segment.end) {
|
||||
state.video.currentTime = absoluteTimeFromDisplay(segment.end + 0.01);
|
||||
return;
|
||||
}
|
||||
|
||||
// show skip button
|
||||
state.activeSkipSegment = segment;
|
||||
if (btn) {
|
||||
btn.textContent = skipLabel(segment.type);
|
||||
@@ -34,11 +41,17 @@ export const updateSkipButton = (currentTime: number): void => {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Syncs autoskip checkbox with localStorage.
|
||||
*/
|
||||
export const updateAutoSkipButton = (): void => {
|
||||
const btn = document.querySelector('[data-autoskip]') as HTMLInputElement | null;
|
||||
btn && (btn.checked = localStorage.getItem('mal:autoskip-enabled') === 'true');
|
||||
};
|
||||
|
||||
/**
|
||||
* Binds autoskip toggle change handler.
|
||||
*/
|
||||
export const setupSkip = (): void => {
|
||||
document.addEventListener('change', e => {
|
||||
const target = e.target as HTMLElement;
|
||||
|
||||
Reference in New Issue
Block a user