feat(folder): right-click "영상 주소 복사" on public and admin
- 공개 폴더(/folder/:name): 새 ctxMenu + public-folder.js 로 우클릭 메뉴 신설
("영상 주소 복사" 만 포함). 좌클릭 재생 기능은 그대로 유지.
- 관리자 폴더(/op/folder/:name): 기존 ctxMenu 에 "영상 주소 복사" 항목과
folder.js 에 copyUrl 핸들러 추가.
- 양쪽 모두 navigator.clipboard.writeText(origin + "/player/" + id) 사용,
실패하면 hidden textarea + execCommand("copy") fallback, 그것도 실패하면
window.prompt 으로 직접 복사 안내. 성공 시 flashToast 로 피드백.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -30,6 +30,8 @@
|
||||
var action = btn.getAttribute('data-action')
|
||||
if (action === 'edit') {
|
||||
location.href = '/op/folder/' + encodeURIComponent(folder) + '/video/editor?id=' + encodeURIComponent(targetId)
|
||||
} else if (action === 'copyUrl') {
|
||||
copyVideoUrl(targetId)
|
||||
} else if (action === 'rename') {
|
||||
var t = window.prompt('새 영상 제목', targetTitle)
|
||||
if (t && t !== targetTitle) {
|
||||
@@ -56,4 +58,44 @@
|
||||
}
|
||||
hideCtx()
|
||||
})
|
||||
|
||||
function copyVideoUrl(id) {
|
||||
var url = location.origin + '/player/' + encodeURIComponent(id)
|
||||
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)
|
||||
}
|
||||
})()
|
||||
|
||||
Reference in New Issue
Block a user