Cauanne commited on
Commit
d6bf05e
·
verified ·
1 Parent(s): 66df0de

Upload index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +60 -28
templates/index.html CHANGED
@@ -510,17 +510,58 @@ function resetThreads(){
510
  /* ── SOCKET.IO ── */
511
  let socket=null,running=false;
512
  function initSocket(){
513
- socket=io({
 
514
  transports: ['polling', 'websocket'],
515
- reconnection: true,
516
- reconnectionAttempts: Infinity,
517
- reconnectionDelay: 500,
518
- reconnectionDelayMax: 2000,
519
- timeout: 20000,
520
- autoConnect: true
521
  });
522
 
523
- socket.on('sync_state', d => {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
524
  updateStats(d);
525
  if(d.running){
526
  running = true;
@@ -748,32 +789,23 @@ async function doStart(){
748
  const cards=document.getElementById('cardsInput').value.trim();
749
  if(!cards){toast('Cole os cartões antes de iniciar!','err');return}
750
  const threads=parseInt(document.getElementById('thrSlider').value)||1;
 
 
 
 
 
 
751
  clearLives();
752
  clearLog();
753
- document.getElementById('progBar').style.width='0%';
754
- document.getElementById('progPct').textContent='0%';
755
- document.getElementById('progLbl').textContent='0 / 0';
756
- document.getElementById('vLive').textContent='0';
757
- document.getElementById('vDie').textContent='0';
758
- document.getElementById('vErr').textContent='0';
759
- document.getElementById('vTot').textContent='0';
760
- document.getElementById('rLive').textContent='0%';
761
- document.getElementById('rDie').textContent='0%';
762
- document.getElementById('rErr').textContent='0%';
763
- document.getElementById('rTot').textContent='0 checked';
764
  resetThreads();
765
- try{
766
- const r=await fetch('/api/start',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({cards,threads})});
767
- const d=await r.json();
768
- if(!r.ok)toast(d.msg||'Erro ao iniciar','err');
769
- }catch(e){toast('Erro de conexão','err')}
770
  }
771
 
772
  async function doStop(){
773
- try{
774
- document.getElementById('btnStop').disabled=true;
775
- await fetch('/api/stop',{method:'POST'});
776
- }catch(e){toast('Erro ao parar','err')}
777
  }
778
 
779
  async function downloadLives(){
 
510
  /* ── SOCKET.IO ── */
511
  let socket=null,running=false;
512
  function initSocket(){
513
+ // Configuração ultra-compatível para Hugging Face
514
+ socket = io({
515
  transports: ['polling', 'websocket'],
516
+ upgrade: true,
517
+ rememberUpgrade: true
 
 
 
 
518
  });
519
 
520
+ socket.on('update_stats', d => {
521
+ updateStats(d);
522
+ });
523
+
524
+ socket.on('log', d => {
525
+ addLog(d.type, d.badge, d.card, d.msg, null, d.slot, d.tempo);
526
+ });
527
+
528
+ socket.on('thread_status', d => {
529
+ if (d.status === 'active') {
530
+ threadStart(d.id, d.card);
531
+ } else {
532
+ threadDone(d.id, d.status);
533
+ }
534
+ });
535
+
536
+ socket.on('live_card', d => {
537
+ addLive(d.card, d.tempo, d.msg);
538
+ pulseLive();
539
+ playLiveSound();
540
+ toast('🟢 LIVE: ' + d.card.split('|')[0], 'ok');
541
+ });
542
+
543
+ socket.on('set_ui', d => {
544
+ setUI(d.on);
545
+ if (!d.on) {
546
+ running = false;
547
+ stopEl();
548
+ resetThreads();
549
+ } else {
550
+ running = true;
551
+ startEl();
552
+ }
553
+ });
554
+
555
+ socket.on('process_complete', d => {
556
+ addLog('info', 'SYS', null, '✔ Checker finalizado!', null, null, null);
557
+ toast('Checker finalizado!', 'info');
558
+ running = false;
559
+ setUI(false);
560
+ stopEl();
561
+ resetThreads();
562
+ });
563
+
564
+ socket.on('sync_state_disabled', d => {
565
  updateStats(d);
566
  if(d.running){
567
  running = true;
 
789
  const cards=document.getElementById('cardsInput').value.trim();
790
  if(!cards){toast('Cole os cartões antes de iniciar!','err');return}
791
  const threads=parseInt(document.getElementById('thrSlider').value)||1;
792
+
793
+ if(!socket || !socket.connected) {
794
+ toast('Erro: Socket não conectado. Aguarde...','err');
795
+ return;
796
+ }
797
+
798
  clearLives();
799
  clearLog();
 
 
 
 
 
 
 
 
 
 
 
800
  resetThreads();
801
+
802
+ socket.emit('start_process', {cards, threads});
 
 
 
803
  }
804
 
805
  async function doStop(){
806
+ if(socket && socket.connected) {
807
+ socket.emit('stop_process');
808
+ }
 
809
  }
810
 
811
  async function downloadLives(){