Spaces:
No application file
No application file
Update browser_automation_ui.html
Browse files
browser_automation_ui.html
CHANGED
|
@@ -147,12 +147,12 @@
|
|
| 147 |
function downloadCurrentScreenshot(){if(!lastScreenshot)return alert('No screenshot');const a=document.createElement('a');a.href=`data:image/png;base64,${lastScreenshot}`;a.download=`screenshot_${Date.now()}.png`;a.click();}
|
| 148 |
|
| 149 |
async function closeSession(id){if(!confirm(`Close session\n${id}?`))return;try{
|
| 150 |
-
await apiPost(`/browser/close
|
| 151 |
await refreshSessions();}catch(e){handleErr(e)}}
|
| 152 |
|
| 153 |
async function closeAllSessions(){const list=document.querySelectorAll('.session-item');if(!list.length)return alert('No sessions');
|
| 154 |
if(!confirm(`Close ALL ${list.length} sessions?`))return;try{
|
| 155 |
-
for(const li of list){await apiPost(`/browser/close
|
| 156 |
|
| 157 |
async function refreshSessions(){try{
|
| 158 |
const res=await apiGet('/sessions');const ul=document.getElementById('sessionList');ul.innerHTML='';(res.sessions||[]).forEach(s=>{
|
|
|
|
| 147 |
function downloadCurrentScreenshot(){if(!lastScreenshot)return alert('No screenshot');const a=document.createElement('a');a.href=`data:image/png;base64,${lastScreenshot}`;a.download=`screenshot_${Date.now()}.png`;a.click();}
|
| 148 |
|
| 149 |
async function closeSession(id){if(!confirm(`Close session\n${id}?`))return;try{
|
| 150 |
+
await apiPost(`/browser/close/`,${id});log(`✖ closed ${id}`);if(id===currentSessionId){currentSessionId=null;document.getElementById('screenshot').src='';}
|
| 151 |
await refreshSessions();}catch(e){handleErr(e)}}
|
| 152 |
|
| 153 |
async function closeAllSessions(){const list=document.querySelectorAll('.session-item');if(!list.length)return alert('No sessions');
|
| 154 |
if(!confirm(`Close ALL ${list.length} sessions?`))return;try{
|
| 155 |
+
for(const li of list){await apiPost(`/browser/close/`,${li.dataset.id});}currentSessionId=null;document.getElementById('screenshot').src='';lastScreenshot=null;await refreshSessions();log('✖ all sessions closed');}catch(e){handleErr(e)}}
|
| 156 |
|
| 157 |
async function refreshSessions(){try{
|
| 158 |
const res=await apiGet('/sessions');const ul=document.getElementById('sessionList');ul.innerHTML='';(res.sessions||[]).forEach(s=>{
|