MCPcopy Create free account
hub / github.com/dajie111/nodeseek-userscript / _bindStatsMessageOnce

Function _bindStatsMessageOnce

focus.js:371–425  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

369 border: '0', borderRadius: '0', display: 'block', background: '#fff',
370 overflow: 'auto', WebkitOverflowScrolling: 'touch',
371 position: 'relative', zIndex: '1', visibility: 'hidden',
372 });
373 } else {
374 Object.assign(iframe.style, {
375 width: '100%', height: '100%', minHeight: '0',
376 border: '0', borderRadius: '12px', display: 'block', background: 'transparent',
377 position: 'relative', zIndex: '1', visibility: 'hidden',
378 });
379 }
380
381 closeBtn.style.visibility = 'visible';
382
383 dialog.appendChild(loadingLayer);
384 dialog.appendChild(iframe);
385 dialog.appendChild(dragArea);
386 dialog.appendChild(closeBtn);
387 document.body.appendChild(dialog);
388 self._statsIframe = iframe;
389 self._initDraggable(dialog, dragArea, closeBtn);
390 self._bindStatsMessageOnce();
391
392 iframe.onload = function () {
393 clearTimeout(loadTimer);
394 loadingLayer.style.display = 'none';
395 iframe.style.visibility = 'visible';
396 if (!isMobile()) {
397 dialog.style.height = HB_STATS_PANEL_H;
398 dialog.style.maxHeight = HB_STATS_PANEL_H;
399 }
400 // iframe 加载完成后派发合成 mouseup,避免拖拽中 iframe 覆盖鼠标导致拖拽状态残留
401 document.body.style.userSelect = '';
402 document.dispatchEvent(new MouseEvent('mouseup', { bubbles: true }));
403 };
404
405 /* 超时检测:20 秒未加载完成则显示错误提示 */
406 const loadTimer = setTimeout(function () {
407 if (loadingLayer.style.display === 'none') return;
408 spinner.style.display = 'none';
409 loadingText.textContent = '连接失败,请稍后重试';
410 loadingText.style.fontSize = '15px';
411 loadingText.style.color = '#e74c3c';
412 const retryBtn = document.createElement('button');
413 retryBtn.textContent = '重新加载';
414 retryBtn.style.cssText = 'margin-top:12px;padding:6px 18px;border:1px solid #17a2b8;border-radius:6px;background:#17a2b8;color:#fff;font-size:13px;cursor:pointer;font-family:inherit;';
415 retryBtn.onclick = function () {
416 loadingText.textContent = '加载中…';
417 loadingText.style.fontSize = '14px';
418 loadingText.style.color = '#666';
419 retryBtn.remove();
420 spinner.style.display = '';
421 iframe.style.visibility = 'hidden';
422 iframe.src = self.hbServiceBase + '/hotspot_stats.html?embed=1&t=' + Date.now();
423 };
424 loadingLayer.appendChild(retryBtn);
425 }, 20000);
426
427 iframe.src = self.hbServiceBase + '/hotspot_stats.html?embed=1';
428 },

Callers

nothing calls this directly

Calls 1

appendHtmlFragmentFunction · 0.85

Tested by

no test coverage detected