- new storeDb.ts: DB+FS layer (folders w/ parent_id, videos w/ global id)
- depth cap: sub-folder cannot have children (enforced in createFolder)
- video id: editable anytime (changeVideoId), uniqueness via PK
- routes:
- public /folder/:topName[/:subName], /video/:topName[/:subName]/:videoId
- admin /op/folder/:topName[/:subName], id-based /op/folders/:id/*
and /op/videos/:id/* (rename/changeId/delete/save + idAvailable check)
- views: breadcrumb + subFolder grid; 플레이리스트 추가 button shows at 2단계
- client JS: id-based mutation endpoints, share URL data attribute,
in-site player pushes share URL to address bar
- store.ts slimmed to Account + readAccounts (FS layer moved to storeDb)
- pickIntId accepts numeric JSON bodies
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
73 lines
2.2 KiB
JavaScript
73 lines
2.2 KiB
JavaScript
(function () {
|
|
var ctxMenu = document.getElementById('ctxMenu')
|
|
if (!ctxMenu) return
|
|
var targetShareUrl = 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()
|
|
targetShareUrl = card.getAttribute('data-share-url')
|
|
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' && targetShareUrl) {
|
|
copyUrl(location.origin + targetShareUrl)
|
|
}
|
|
hideCtx()
|
|
})
|
|
|
|
function copyUrl(text) {
|
|
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
navigator.clipboard.writeText(text).then(function () {
|
|
flashToast('주소가 복사되었습니다.')
|
|
}, function () { fallbackCopy(text) })
|
|
} else {
|
|
fallbackCopy(text)
|
|
}
|
|
}
|
|
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)
|
|
}
|
|
})()
|