Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

141
Views
Listo, listo, listo + iniciar el temporizador

Mi función de conteo funcionó satisfactoriamente. Pero luego quise agregar listo, firme, listo. Es decir, dale al usuario 3 segundos para cambiar su atención del botón en la pantalla a la prueba en sus hojas de papel.

Entonces, lo que necesito: listo, listo, adelante suena, luego un temporizador comienza a contar.

Código

 var ready_steady_go_counter = 0; jQuery(function(){ jQuery('#timer-form').on('submit', function(event){ event.preventDefault(); initiate_minutes(); const ReadySteadyGoPromise = new Promise((resolve, reject) => { function ready_steady_go(){ setTimeout(function () { if (ready_steady_go_counter > 2) { // Ready (0), steady (1), go (2); return; } beep(); ready_steady_go_counter++; ready_steady_go(); // <--- this is the "loop" }, 1000); } ready_steady_go(); }); ReadySteadyGoPromise.then(countup, function(){console.log("Alert (timer)!")}); remove_submit_button(); show_planned_times(); }); }); function tick() { datediffInms = new Date() - startDateTime; seconds_lapsed = Math.round(datediffInms / 1000); } function countup() { setTimeout(function () { // Breakpoint. if (stopped) return; if (!is_paused()) { tick(); show_time_left(); } countup(); // <--- this is the "loop" }, 1000); }

Problema

Ready, ready, go realmente pitidos según lo planeado. Pero la cuenta atrás no comienza . He marcado dónde se encuentra un punto de interrupción con // Breakpoint de interrupción.

Entonces, el intérprete no se detiene en el punto de interrupción. Esto significa que el conteo no ha comenzado.

¿Cómo puedo completar mi tarea?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

La promesa que está creando debe resolverse para que se llame a countup , pero nunca la resuelve.

En esta parte de tu código

 if (ready_steady_go_counter > 2) { // Ready (0), steady (1), go (2); return; }

reemplaza return con resolve(); return y debería funcionar.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!