Files
make_video_site/public/public-folder.js
claude-bot 6ee089b9b7 fix(folder): copy raw video stream URL instead of player page
영상 주소 복사 결과를 /player/:id 가 아닌 실제 스트리밍 엔드포인트
/api/video/:id/file 로 변경. 공개/관리자 양쪽 모두 적용.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 18:45:37 +09:00

76 lines
2.3 KiB
JavaScript

(function () {
var ctxMenu = document.getElementById('ctxMenu')
if (!ctxMenu) return
var targetId = null
function showCtx(x, y) {
ctxMenu.style.left = x + 'px'
ctxMenu.style.top = y + 'px'
ctxMenu.hidden = false
}
function hideCtx() { ctxMenu.hidden = true }
document.querySelectorAll('.videoCard').forEach(function (card) {
card.addEventListener('contextmenu', function (e) {
e.preventDefault()
targetId = card.getAttribute('data-video-id') || card.getAttribute('data-id')
showCtx(e.clientX, e.clientY)
})
})
document.addEventListener('click', function (e) {
if (!ctxMenu.contains(e.target)) hideCtx()
})
document.addEventListener('scroll', hideCtx, true)
ctxMenu.addEventListener('click', function (e) {
var btn = e.target.closest('button')
if (!btn) return
var action = btn.getAttribute('data-action')
if (action === 'copyUrl' && targetId) {
copyVideoUrl(targetId)
}
hideCtx()
})
function copyVideoUrl(id) {
var url = location.origin + '/api/video/' + encodeURIComponent(id) + '/file'
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(url).then(function () {
flashToast('주소가 복사되었습니다.')
}, function () {
fallbackCopy(url)
})
} else {
fallbackCopy(url)
}
}
function fallbackCopy(text) {
try {
var ta = document.createElement('textarea')
ta.value = text
ta.style.position = 'fixed'
ta.style.left = '-9999px'
document.body.appendChild(ta)
ta.focus(); ta.select()
var ok = document.execCommand && document.execCommand('copy')
document.body.removeChild(ta)
if (ok) flashToast('주소가 복사되었습니다.')
else window.prompt('주소를 복사하세요:', text)
} catch (e) {
window.prompt('주소를 복사하세요:', text)
}
}
function flashToast(msg) {
var el = document.createElement('div')
el.className = 'flashToast'
el.textContent = msg
document.body.appendChild(el)
requestAnimationFrame(function () { el.classList.add('show') })
setTimeout(function () {
el.classList.remove('show')
setTimeout(function () { el.parentNode && el.parentNode.removeChild(el) }, 200)
}, 1500)
}
})()