MCPcopy
hub / github.com/IPADS-SAI/MobiAgent / sendInputText

Function sendInputText

collect/manual/static/js/script.js:1232–1320  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1230}
1231
1232async function sendInputText() {
1233 const inputText = document.getElementById('inputText');
1234 const text = inputText.value.trim();
1235
1236 if (!text) {
1237 updateStatus('请输入文本内容', 'error');
1238 return;
1239 }
1240
1241 if (!isCollecting) {
1242 updateStatus('请先开始数据收集', 'error');
1243 hideInputModal();
1244 return;
1245 }
1246
1247 try {
1248 updateStatus('正在发送文本...', 'info');
1249
1250 // 如果正在自动刷新,暂时停止以避免冲突
1251 const wasAutoRefreshing = autoRefreshEnabled;
1252 if (wasAutoRefreshing) {
1253 console.log('文本输入操作开始,暂停自动刷新');
1254 stopAutoRefresh();
1255 }
1256
1257 hideInputModal();
1258 const response = await fetch('/input', {
1259 method: 'POST',
1260 headers: {
1261 'Content-Type': 'application/json',
1262 },
1263 body: JSON.stringify({
1264 text: text
1265 })
1266 });
1267 if (response.ok) {
1268 const result = await response.json();
1269
1270 if (result.suspended) {
1271 updateStatus(`✋ 文本已发送但未记录(人工介入模式): "${text}"`, 'info');
1272 } else {
1273 updateStatus(`文本输入完成: "${text}"`, 'success');
1274 }
1275
1276 // 如果不在suspend模式下,才刷新截图
1277 if (!result.suspended) {
1278 // 显示加载动画
1279 showLoadingAnimation();
1280
1281 // 操作完成后刷新截图和UI元素信息
1282 setTimeout(async () => {
1283 await refreshScreenshot(true); // 传入true显示加载动画
1284 console.log('输入操作后已刷新UI元素信息');
1285
1286 // 如果之前开启了自动刷新,重新开启
1287 if (wasAutoRefreshing && isCollecting) {
1288 setTimeout(() => {
1289 console.log('重新开启自动刷新');

Callers

nothing calls this directly

Calls 8

updateStatusFunction · 0.85
hideInputModalFunction · 0.85
stopAutoRefreshFunction · 0.85
showLoadingAnimationFunction · 0.85
refreshScreenshotFunction · 0.85
startAutoRefreshFunction · 0.85
logMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected