simoncck commited on
Commit
42a75da
·
verified ·
1 Parent(s): b187097

Update browser_automation_ui.html

Browse files
Files changed (1) hide show
  1. browser_automation_ui.html +7 -1
browser_automation_ui.html CHANGED
@@ -146,10 +146,16 @@
146
 
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){
150
  if(!confirm(`Close session\n${id}?`))return;
151
  try{
152
- await apiPost('/browser/close', { session_id: id });
153
  // log(`✖ closed ${id}`);if(id===currentSessionId){currentSessionId=null;document.getElementById('screenshot').src='';}
154
  // await refreshSessions();
155
  }catch(e){
 
146
 
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 apiDelete(path) {
150
+ const r = await fetch('/api' + path, { method: 'DELETE' });
151
+ if (!r.ok) throw new Error(await r.text());
152
+ return r.json ? r.json() : {};
153
+ }
154
+
155
  async function closeSession(id){
156
  if(!confirm(`Close session\n${id}?`))return;
157
  try{
158
+ await apiDelete(`/browser/close/${id}`);
159
  // log(`✖ closed ${id}`);if(id===currentSessionId){currentSessionId=null;document.getElementById('screenshot').src='';}
160
  // await refreshSessions();
161
  }catch(e){