diff --git a/rdp-proxy/entrypoint.sh b/rdp-proxy/entrypoint.sh index 2e38397..08b9141 100644 --- a/rdp-proxy/entrypoint.sh +++ b/rdp-proxy/entrypoint.sh @@ -40,8 +40,10 @@ cat > /opt/portal/index.html < /opt/portal/index.html < e.preventDefault()); + (function(){ + const p = document.querySelector('.nav-panel'); + const SK = 'rdp_nav_pos'; + try { const s = JSON.parse(localStorage.getItem(SK)); if(s){p.style.left=s.x+'px';p.style.top=s.y+'px';} } catch(e){} + let ox, oy, dragged = false; + p.addEventListener('pointerdown', e => { + if (e.target.closest('button')) return; + dragged = false; + ox = e.clientX - p.getBoundingClientRect().left; + oy = e.clientY - p.getBoundingClientRect().top; + p.setPointerCapture(e.pointerId); + p.classList.add('dragging'); + }); + p.addEventListener('pointermove', e => { + if (!p.hasPointerCapture(e.pointerId)) return; + dragged = true; + const x = Math.max(0, Math.min(window.innerWidth - p.offsetWidth, e.clientX - ox)); + const y = Math.max(0, Math.min(window.innerHeight - p.offsetHeight, e.clientY - oy)); + p.style.left = x + 'px'; + p.style.top = y + 'px'; + }); + p.addEventListener('pointerup', () => { + p.classList.remove('dragging'); + if (dragged) try { localStorage.setItem(SK, JSON.stringify({x: parseInt(p.style.left), y: parseInt(p.style.top)})); } catch(e){} + }); + })(); + connect();