dongsik22 Claude Opus 4.7 (1M context) commited on
Commit
b80911e
·
1 Parent(s): b5a0fab

refactor: 스킵 마킹 progressbar 마커 제거, 메뉴 안에 시간 표시

Browse files

기존 progressbar 위 노란 띠 마커가 progressbar 정렬·디바이스별 위치
문제로 정확하지 않음. 사용자 요청대로 마커 다 제거하고 우클릭 메뉴
안에서만 현재 마킹된 시간 확인하는 단순한 UX로 통일.

- #skipMarkers, .skip-markers CSS 모두 제거
- renderSkipMarkers 함수 제거 (loadedmetadata/durationchange/canplay
핸들러도 같이 정리)
- 컨텍스트 메뉴 각 항목에 .t 시간 표시 span 추가:
'오프닝 시작 1:26' '오프닝 끝 2:38' 등
미마킹 항목은 '—' 회색 표시
- updateSkipMenuLabels(): 메뉴 열 때마다 fav.skip 읽어 갱신
- applySkipMark / showMenu 시점에 호출

자동 스킵 동작(timeupdate 핸들러)은 그대로 — 마킹된 구간 자동 건너뜀.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Files changed (1) hide show
  1. index.html +25 -61
index.html CHANGED
@@ -179,30 +179,18 @@
179
  .zoom-ctrl .zc-time { font-variant-numeric: tabular-nums; min-width: 100px; font-size: 12px; }
180
  .zoom-ctrl .zc-bar { flex: 1; height: 4px; cursor: pointer; accent-color: #e50914;
181
  background: rgba(255,255,255,0.3); border-radius: 2px; -webkit-appearance: none; appearance: none; }
182
- /* 스킵 구간 시각 표시 — zc-bar progressbar 위에 노랑 띠 (일반·풀스크린 공용) */
183
- .skip-markers .skip-range { position: absolute; top: 0; bottom: 0;
184
- background: rgba(255, 200, 0, 0.7); border-radius: 2px;
185
- box-shadow: 0 0 4px rgba(255,200,0,0.5); }
186
- /* 마커 위에 작은 시간 라벨 */
187
- .skip-markers .skip-range::before {
188
- content: attr(data-label); position: absolute;
189
- bottom: 100%; left: 50%; transform: translateX(-50%);
190
- background: rgba(20,22,28,0.92); color: #ffd54a; font-size: 10px;
191
- padding: 1px 6px; border-radius: 3px; white-space: nowrap;
192
- margin-bottom: 3px; font-variant-numeric: tabular-nums; line-height: 1.4;
193
- opacity: 0.9; pointer-events: none;
194
- }
195
- @media (max-width: 1023.98px) {
196
- .skip-markers .skip-range::before { font-size: 9px; padding: 1px 4px; }
197
- }
198
  /* 스킵 마킹 컨텍스트 메뉴 */
199
  .skip-ctx-menu { position: absolute; z-index: 2147483647; background: rgba(20,22,28,0.96);
200
  border: 1px solid rgba(255,255,255,0.15); border-radius: 8px; padding: 4px;
201
  box-shadow: 0 4px 20px rgba(0,0,0,0.6); min-width: 180px; }
202
  .skip-ctx-menu[hidden] { display: none; }
203
- .skip-ctx-menu button { display: block; width: 100%; text-align: left;
204
  background: transparent; border: 0; color: #e3e6eb; font-size: 13px;
205
  padding: 8px 12px; border-radius: 4px; cursor: pointer; }
 
 
 
 
206
  .skip-ctx-menu button:hover { background: rgba(255,255,255,0.08); }
207
  .skip-ctx-menu button[data-skip="clear"] { color: #ff9090; border-top: 1px solid rgba(255,255,255,0.1); margin-top: 2px; }
208
  .zoom-ctrl .zc-bar::-webkit-slider-thumb { -webkit-appearance: none; appearance: none;
@@ -794,12 +782,12 @@
794
  <!-- 오프닝/엔딩 스킵 버튼 (chapter 또는 사용자 마킹 구간 진입 시 표시) -->
795
  <button id="btnSkip" class="skip-btn" hidden>스킵 ⏭</button>
796
  <!-- (제거됨) — 이제 zoom-ctrl이 일반/풀스크린 공용이라 skipMarkers 하나로 통일 -->
797
- <!-- 스킵 마킹 컨텍스트 메뉴 (비디오 우클릭/길게 누르기) -->
798
  <div id="skipCtxMenu" class="skip-ctx-menu" hidden>
799
- <button data-skip="opStart">⏵ 오프닝 시작 마킹</button>
800
- <button data-skip="opEnd">⏵ 오프닝 끝 마킹</button>
801
- <button data-skip="edStart">⏵ 엔딩 시작 마킹</button>
802
- <button data-skip="edEnd">⏵ 엔딩 끝 마킹</button>
803
  <button data-skip="clear">✕ 마킹 초기화</button>
804
  </div>
805
  <!-- H-11: 화질 선택 / H-5: 오디오·자막 -->
@@ -824,10 +812,7 @@
824
  <div id="zoomCtrl" class="zoom-ctrl">
825
  <button id="zcPlay" class="zc-btn" title="재생/일시정지 (Space/K)">▶</button>
826
  <span id="zcTime" class="zc-time">0:00 / 0:00</span>
827
- <div class="zc-bar-wrap" style="flex:1; position:relative; display:flex; align-items:center;">
828
- <input id="zcBar" class="zc-bar" type="range" min="0" max="1000" value="0" style="width:100%;" />
829
- <div id="skipMarkers" class="skip-markers" style="position:absolute; left:0; right:0; top:50%; transform:translateY(-50%); height:6px; pointer-events:none;"></div>
830
- </div>
831
  <button id="zcMute" class="zc-btn" title="음소거 (M)">🔊</button>
832
  <input id="zcVol" class="zc-vol" type="range" min="0" max="100" value="100" title="볼륨" />
833
  <button id="zcReset" class="zc-btn zc-fs-only" title="줌 1배로">↺</button>
@@ -1652,32 +1637,17 @@ let _currentHls = null;
1652
  // 현재 영상의 chapter (anilife) - { op:{start,end}, ed:{start,end} } 또는 null
1653
  let _currentSkips = null;
1654
 
1655
- // zoom-ctrl(일반/풀스크린 공용) progressbar 위에 스킵 구간 시각 표시
1656
- function renderSkipMarkers() {
1657
- const host = document.getElementById('skipMarkers');
1658
- if (!host) return;
1659
- host.innerHTML = '';
1660
- const v = document.getElementById('player');
1661
- const dur = v?.duration;
1662
- if (!_currentSkips || !dur || !isFinite(dur) || dur <= 0) return;
1663
- const fmt = (s) => `${Math.floor(s/60)}:${String(Math.floor(s%60)).padStart(2,'0')}`;
1664
- const add = (start, end, label) => {
1665
- if (start == null || end == null) return;
1666
- const e = isFinite(end) ? end : dur;
1667
- if (e <= start) return;
1668
- const left = Math.max(0, (start / dur) * 100);
1669
- const width = Math.min(100, ((e - start) / dur) * 100);
1670
- const el = document.createElement('div');
1671
- el.className = 'skip-range';
1672
- el.style.left = left + '%';
1673
- el.style.width = width + '%';
1674
- const labelText = `${label} ${fmt(start)}–${isFinite(end) ? fmt(end) : '끝'}`;
1675
- el.setAttribute('data-label', labelText);
1676
- el.title = `${label}: ${fmt(start)} ~ ${isFinite(end) ? fmt(end) : '끝'} (자동 스킵)`;
1677
- host.appendChild(el);
1678
- };
1679
- if (_currentSkips.op) add(_currentSkips.op.start, _currentSkips.op.end, '오프닝');
1680
- if (_currentSkips.ed) add(_currentSkips.ed.start, _currentSkips.ed.end, '엔딩');
1681
  }
1682
 
1683
  // 스킵 마킹 공통 적용 함수 — 키보드·우클릭 메뉴 공통 진입점.
@@ -1716,7 +1686,7 @@ function applySkipMark(kind) {
1716
  if (fav.skip.edStart != null) skips.ed = { start: fav.skip.edStart, end: (typeof fav.skip.edEnd === 'number' && fav.skip.edEnd > fav.skip.edStart) ? fav.skip.edEnd : Infinity };
1717
  _currentSkips = (skips.op || skips.ed) ? skips : null;
1718
  } else { _currentSkips = null; }
1719
- renderSkipMarkers();
1720
  if (typeof showToast === 'function') showToast(msg);
1721
  }
1722
 
@@ -1727,6 +1697,7 @@ function applySkipMark(kind) {
1727
  if (!wrap || !menu) return;
1728
  function showMenu(clientX, clientY) {
1729
  if (!currentFavId) return; // 재생 중일 때만
 
1730
  const rect = wrap.getBoundingClientRect();
1731
  let x = clientX - rect.left, y = clientY - rect.top;
1732
  menu.hidden = false;
@@ -1787,7 +1758,6 @@ async function playEpisode(id, sid, nid, opts = {}) {
1787
  if (_currentHls) { try { _currentHls.destroy(); } catch {} _currentHls = null; }
1788
 
1789
  _currentSkips = null;
1790
- renderSkipMarkers(); // 이전 영상 마커 즉시 지우기
1791
  // 사용자가 마킹한 오프닝/엔딩 구간 적용 (같은 시리즈 = 같은 fav 안에서 모든 회차 공통).
1792
  // tvchak·anilife 둘 다 동일하게 동작. 사용자 마킹은 anilife 자동 chapter보다 우선.
1793
  if (fav?.skip) {
@@ -3336,19 +3306,13 @@ function setupRateMemory() {
3336
  saveFavs();
3337
  }
3338
  });
3339
- // 새 영상 loadedmetadata 시 시리즈 기억 속도 적용 + 스킵 마커 그리기
3340
  v.addEventListener('loadedmetadata', () => {
3341
  const fav = favs.find(f => f.id === currentFavId);
3342
  if (fav && typeof fav.lastPlaybackRate === 'number' && fav.lastPlaybackRate > 0) {
3343
  try { v.playbackRate = fav.lastPlaybackRate; } catch {}
3344
  }
3345
- renderSkipMarkers();
3346
  });
3347
- // duration이 늦게 잡히는 케이스(HLS 등) 안전망 — duration 갱신 시마다 마커 재계산
3348
- v.addEventListener('durationchange', () => renderSkipMarkers());
3349
- // 일부 hls.js 환경에서 위 두 이벤트 모두 너무 일찍 떠 duration이 0인 채로 끝남.
3350
- // canplay 시점에 한 번 더 그리기 시도.
3351
- v.addEventListener('canplay', () => renderSkipMarkers());
3352
  }
3353
 
3354
  // ─── C8: 재생 실패 자동 재시도 + 토스트 ───
 
179
  .zoom-ctrl .zc-time { font-variant-numeric: tabular-nums; min-width: 100px; font-size: 12px; }
180
  .zoom-ctrl .zc-bar { flex: 1; height: 4px; cursor: pointer; accent-color: #e50914;
181
  background: rgba(255,255,255,0.3); border-radius: 2px; -webkit-appearance: none; appearance: none; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
  /* 스킵 마킹 컨텍스트 메뉴 */
183
  .skip-ctx-menu { position: absolute; z-index: 2147483647; background: rgba(20,22,28,0.96);
184
  border: 1px solid rgba(255,255,255,0.15); border-radius: 8px; padding: 4px;
185
  box-shadow: 0 4px 20px rgba(0,0,0,0.6); min-width: 180px; }
186
  .skip-ctx-menu[hidden] { display: none; }
187
+ .skip-ctx-menu button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
188
  background: transparent; border: 0; color: #e3e6eb; font-size: 13px;
189
  padding: 8px 12px; border-radius: 4px; cursor: pointer; }
190
+ .skip-ctx-menu button .lbl { flex: 1; }
191
+ .skip-ctx-menu button .t { color: #ffd54a; font-variant-numeric: tabular-nums;
192
+ font-size: 11px; min-width: 44px; text-align: right; }
193
+ .skip-ctx-menu button .t:empty::before { content: '—'; color: #555; }
194
  .skip-ctx-menu button:hover { background: rgba(255,255,255,0.08); }
195
  .skip-ctx-menu button[data-skip="clear"] { color: #ff9090; border-top: 1px solid rgba(255,255,255,0.1); margin-top: 2px; }
196
  .zoom-ctrl .zc-bar::-webkit-slider-thumb { -webkit-appearance: none; appearance: none;
 
782
  <!-- 오프닝/엔딩 스킵 버튼 (chapter 또는 사용자 마킹 구간 진입 시 표시) -->
783
  <button id="btnSkip" class="skip-btn" hidden>스킵 ⏭</button>
784
  <!-- (제거됨) — 이제 zoom-ctrl이 일반/풀스크린 공용이라 skipMarkers 하나로 통일 -->
785
+ <!-- 스킵 마킹 컨텍스트 메뉴 (비디오 우클릭/길게 누르기). 각 항목 옆에 현재 마킹된 시간 표시 -->
786
  <div id="skipCtxMenu" class="skip-ctx-menu" hidden>
787
+ <button data-skip="opStart"><span class="lbl">오프닝 시작</span><span class="t" data-key="opStart"></span></button>
788
+ <button data-skip="opEnd"><span class="lbl">오프닝 끝</span><span class="t" data-key="opEnd"></span></button>
789
+ <button data-skip="edStart"><span class="lbl">엔딩 시작</span><span class="t" data-key="edStart"></span></button>
790
+ <button data-skip="edEnd"><span class="lbl">엔딩 끝</span><span class="t" data-key="edEnd"></span></button>
791
  <button data-skip="clear">✕ 마킹 초기화</button>
792
  </div>
793
  <!-- H-11: 화질 선택 / H-5: 오디오·자막 -->
 
812
  <div id="zoomCtrl" class="zoom-ctrl">
813
  <button id="zcPlay" class="zc-btn" title="재생/일시정지 (Space/K)">▶</button>
814
  <span id="zcTime" class="zc-time">0:00 / 0:00</span>
815
+ <input id="zcBar" class="zc-bar" type="range" min="0" max="1000" value="0" style="flex:1;" />
 
 
 
816
  <button id="zcMute" class="zc-btn" title="음소거 (M)">🔊</button>
817
  <input id="zcVol" class="zc-vol" type="range" min="0" max="100" value="100" title="볼륨" />
818
  <button id="zcReset" class="zc-btn zc-fs-only" title="줌 1배로">↺</button>
 
1637
  // 현재 영상의 chapter (anilife) - { op:{start,end}, ed:{start,end} } 또는 null
1638
  let _currentSkips = null;
1639
 
1640
+ // 스킵 마킹 시각 표시는 우클릭 메뉴 안에서만 (progressbar 마커는 제거됨).
1641
+ // 메뉴 열 때마다 fav.skip 읽어 각 버튼의 .t에 시간 텍스트 채움.
1642
+ function updateSkipMenuLabels() {
1643
+ const menu = document.getElementById('skipCtxMenu');
1644
+ if (!menu) return;
1645
+ const fav = currentFavId ? favs.find(f => f.id === currentFavId && (f.source || 'tvchak') === (currentFavSource || 'tvchak')) : null;
1646
+ const s = fav?.skip || {};
1647
+ const fmt = (n) => (typeof n === 'number') ? `${Math.floor(n/60)}:${String(Math.floor(n%60)).padStart(2,'0')}` : '';
1648
+ for (const el of menu.querySelectorAll('.t')) {
1649
+ el.textContent = fmt(s[el.dataset.key]);
1650
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1651
  }
1652
 
1653
  // 스킵 마킹 공통 적용 함수 — 키보드·우클릭 메뉴 공통 진입점.
 
1686
  if (fav.skip.edStart != null) skips.ed = { start: fav.skip.edStart, end: (typeof fav.skip.edEnd === 'number' && fav.skip.edEnd > fav.skip.edStart) ? fav.skip.edEnd : Infinity };
1687
  _currentSkips = (skips.op || skips.ed) ? skips : null;
1688
  } else { _currentSkips = null; }
1689
+ updateSkipMenuLabels();
1690
  if (typeof showToast === 'function') showToast(msg);
1691
  }
1692
 
 
1697
  if (!wrap || !menu) return;
1698
  function showMenu(clientX, clientY) {
1699
  if (!currentFavId) return; // 재생 중일 때만
1700
+ updateSkipMenuLabels(); // 메뉴 열 때마다 현재 마킹된 시간 표시 갱신
1701
  const rect = wrap.getBoundingClientRect();
1702
  let x = clientX - rect.left, y = clientY - rect.top;
1703
  menu.hidden = false;
 
1758
  if (_currentHls) { try { _currentHls.destroy(); } catch {} _currentHls = null; }
1759
 
1760
  _currentSkips = null;
 
1761
  // 사용자가 마킹한 오프닝/엔딩 구간 적용 (같은 시리즈 = 같은 fav 안에서 모든 회차 공통).
1762
  // tvchak·anilife 둘 다 동일하게 동작. 사용자 마킹은 anilife 자동 chapter보다 우선.
1763
  if (fav?.skip) {
 
3306
  saveFavs();
3307
  }
3308
  });
3309
+ // 새 영상 loadedmetadata 시 시리즈 기억 속도 적용
3310
  v.addEventListener('loadedmetadata', () => {
3311
  const fav = favs.find(f => f.id === currentFavId);
3312
  if (fav && typeof fav.lastPlaybackRate === 'number' && fav.lastPlaybackRate > 0) {
3313
  try { v.playbackRate = fav.lastPlaybackRate; } catch {}
3314
  }
 
3315
  });
 
 
 
 
 
3316
  }
3317
 
3318
  // ─── C8: 재생 실패 자동 재시도 + 토스트 ───