Skip to main content
removeu 14 caracteres do conteúdo; tags editadas
Fonte Link
user28595
user28595

Boa tarde!

Boa tarde!

identação
Fonte Link
Sorack
  • 26,5mil
  • 6
  • 43
  • 96

function startTimer(duration, display) {

function startTimer(duration, display) {

var timer = duration, minutes, seconds;
    myInterval = setInterval(function () {
    minutes = parseInt(timer / 60, 10)
    seconds = parseInt(timer % 60, 10);
    minutes = minutes < 10 ? "0" + minutes : minutes;
    seconds = seconds < 10 ? "0" + seconds : seconds;
    display.textContent = minutes + ":" + seconds;

        $(".txtTempo").html(minutes + ":" + seconds);

        if (--timer < 0) {
            $("#min").html("00:00");
            clearInterval(myInterval);
        }
                    
        else{
            var Tempo = $("#Cronometro").val();
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:30"){
                    document.getElementById('min').style.color='red';
                }
            } 
            if(Tempo === "1"){                    
                if($("#min").html() === "00:29"){
                    document.getElementById('min').style.color='black';
                }
            } 
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:28"){
                    document.getElementById('min').style.color='red';
                }
            } 
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:27"){
                    document.getElementById('min').style.color='black';
                }
            }   
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:26"){
                    document.getElementById('min').style.color='red';
                }
            }

            if(Tempo === "1"){                    
                if($("#min").html() === "00:25"){
                    document.getElementById('min').style.color='black';
                }
            } 
            if(Tempo === "1"){                    
                if($("#min").html() === "00:24"){
                    document.getElementById('min').style.color='red';
                }
            }     
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:23"){
                    document.getElementById('min').style.color='black';
                }
            }      
            if(Tempo === "1"){                    
                if($("#min").html() === "00:22"){
                    document.getElementById('min').style.color='red';
                }
            }    
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:21"){
                    document.getElementById('min').style.color='black';
                }
            }    
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:20"){
                    document.getElementById('min').style.color='red';
                }
            }     
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:19"){
                    document.getElementById('min').style.color='black';
                }
            }     
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:18"){
                    document.getElementById('min').style.color='red';
                }
            }                 
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:17"){
                    document.getElementById('min').style.color='black';
                }
            } 

             if(Tempo === "1"){                    
                if($("#min").html() === "00:16"){
                    document.getElementById('min').style.color='red';
                }
            } 
            
    
            if(Tempo === "1"){
                if($("#min").html() === "00:15"){
                    $("body").attr("class","background-pulse");
                    document.getElementById('min').style.color='black';
                }
            } 
             if(Tempo === "1"){                    
                if($("#min").html() === "00:14"){
                    document.getElementById('min').style.color='red';
                }
            }                 
             if(Tempo === "1"){                    
                if($("#min").html() === "00:13"){
                    document.getElementById('min').style.color='black';
                }
            } 
             if(Tempo === "1"){                    
                if($("#min").html() === "00:12"){
                    document.getElementById('min').style.color='red';
                }
            }    
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:11"){
                    document.getElementById('min').style.color='black';
                }
            }                 
            
            if(Tempo === "1"){
                if($("#min").html() === "00:10"){
                $('#modal').modal('show');
                 document.getElementById('min').style.color='red';
                }
            }  
            
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:09"){
                    document.getElementById('min').style.color='black';
                }
            }     
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:08"){
                    document.getElementById('min').style.color='red';
                }
            }  
            
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:07"){
                    document.getElementById('min').style.color='black';
                }
            }    
            
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:06"){
                    document.getElementById('min').style.color='red';
                }
            }                 
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:05"){
                    document.getElementById('min').style.color='black';
                }
            }                 
                                            
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:04"){
                    document.getElementById('min').style.color='red';
                }
            }                 
                                            
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:03"){
                    document.getElementById('min').style.color='black';
                }
            }                 
                                            
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:02"){
                    document.getElementById('min').style.color='red';
                }
            }                 
                                            
                        
            if(Tempo === "1"){
                if($("#min").html() === "00:01"){
                    $('#modal').modal('hide');
                }
            }  

            if(Tempo === "1"){
                if($("#min").html() === "00:01"){
                    $('#modal2').modal('show');
                }
            }                          
        }
    }, 1000);
}

function Start() {
var Tempo = $("#Cronometro").val();
var fiveMinutes = 90 * Tempo,
    display = document.querySelector('#min');

$(".txtTempo").show();
startTimer(fiveMinutes, display);
$("#btnPlay").attr("disabled","disabled");
};

function Stop() {
$("#min, .txtTempo").html("00:00");
$(".txtTempo").hide();
clearInterval(myInterval);
$("body").removeAttr("class");
$("#msgHold").hide();
$("#btnPlay").removeAttr("disabled");
document.getElementById('min').style.color='black';
};

document.getElementById('min').style.fontWeight="bold";

function startTimer(duration, display) {

var timer = duration, minutes, seconds;
    myInterval = setInterval(function () {
    minutes = parseInt(timer / 60, 10)
    seconds = parseInt(timer % 60, 10);
    minutes = minutes < 10 ? "0" + minutes : minutes;
    seconds = seconds < 10 ? "0" + seconds : seconds;
    display.textContent = minutes + ":" + seconds;

        $(".txtTempo").html(minutes + ":" + seconds);

        if (--timer < 0) {
            $("#min").html("00:00");
            clearInterval(myInterval);
        }
                    
        else{
            var Tempo = $("#Cronometro").val();
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:30"){
                    document.getElementById('min').style.color='red';
                }
            } 
            if(Tempo === "1"){                    
                if($("#min").html() === "00:29"){
                    document.getElementById('min').style.color='black';
                }
            } 
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:28"){
                    document.getElementById('min').style.color='red';
                }
            } 
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:27"){
                    document.getElementById('min').style.color='black';
                }
            }   
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:26"){
                    document.getElementById('min').style.color='red';
                }
            }

            if(Tempo === "1"){                    
                if($("#min").html() === "00:25"){
                    document.getElementById('min').style.color='black';
                }
            } 
            if(Tempo === "1"){                    
                if($("#min").html() === "00:24"){
                    document.getElementById('min').style.color='red';
                }
            }     
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:23"){
                    document.getElementById('min').style.color='black';
                }
            }      
            if(Tempo === "1"){                    
                if($("#min").html() === "00:22"){
                    document.getElementById('min').style.color='red';
                }
            }    
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:21"){
                    document.getElementById('min').style.color='black';
                }
            }    
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:20"){
                    document.getElementById('min').style.color='red';
                }
            }     
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:19"){
                    document.getElementById('min').style.color='black';
                }
            }     
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:18"){
                    document.getElementById('min').style.color='red';
                }
            }                 
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:17"){
                    document.getElementById('min').style.color='black';
                }
            } 

             if(Tempo === "1"){                    
                if($("#min").html() === "00:16"){
                    document.getElementById('min').style.color='red';
                }
            } 
            
    
            if(Tempo === "1"){
                if($("#min").html() === "00:15"){
                    $("body").attr("class","background-pulse");
                    document.getElementById('min').style.color='black';
                }
            } 
             if(Tempo === "1"){                    
                if($("#min").html() === "00:14"){
                    document.getElementById('min').style.color='red';
                }
            }                 
             if(Tempo === "1"){                    
                if($("#min").html() === "00:13"){
                    document.getElementById('min').style.color='black';
                }
            } 
             if(Tempo === "1"){                    
                if($("#min").html() === "00:12"){
                    document.getElementById('min').style.color='red';
                }
            }    
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:11"){
                    document.getElementById('min').style.color='black';
                }
            }                 
            
            if(Tempo === "1"){
                if($("#min").html() === "00:10"){
                $('#modal').modal('show');
                 document.getElementById('min').style.color='red';
                }
            }  
            
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:09"){
                    document.getElementById('min').style.color='black';
                }
            }     
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:08"){
                    document.getElementById('min').style.color='red';
                }
            }  
            
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:07"){
                    document.getElementById('min').style.color='black';
                }
            }    
            
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:06"){
                    document.getElementById('min').style.color='red';
                }
            }                 
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:05"){
                    document.getElementById('min').style.color='black';
                }
            }                 
                                            
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:04"){
                    document.getElementById('min').style.color='red';
                }
            }                 
                                            
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:03"){
                    document.getElementById('min').style.color='black';
                }
            }                 
                                            
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:02"){
                    document.getElementById('min').style.color='red';
                }
            }                 
                                            
                        
            if(Tempo === "1"){
                if($("#min").html() === "00:01"){
                    $('#modal').modal('hide');
                }
            }  

            if(Tempo === "1"){
                if($("#min").html() === "00:01"){
                    $('#modal2').modal('show');
                }
            }                          
        }
    }, 1000);
}

function Start() {
var Tempo = $("#Cronometro").val();
var fiveMinutes = 90 * Tempo,
    display = document.querySelector('#min');

$(".txtTempo").show();
startTimer(fiveMinutes, display);
$("#btnPlay").attr("disabled","disabled");
};

function Stop() {
$("#min, .txtTempo").html("00:00");
$(".txtTempo").hide();
clearInterval(myInterval);
$("body").removeAttr("class");
$("#msgHold").hide();
$("#btnPlay").removeAttr("disabled");
document.getElementById('min').style.color='black';
};

document.getElementById('min').style.fontWeight="bold";
function startTimer(duration, display) {

var timer = duration, minutes, seconds;
    myInterval = setInterval(function () {
    minutes = parseInt(timer / 60, 10)
    seconds = parseInt(timer % 60, 10);
    minutes = minutes < 10 ? "0" + minutes : minutes;
    seconds = seconds < 10 ? "0" + seconds : seconds;
    display.textContent = minutes + ":" + seconds;

        $(".txtTempo").html(minutes + ":" + seconds);

        if (--timer < 0) {
            $("#min").html("00:00");
            clearInterval(myInterval);
        }
                    
        else{
            var Tempo = $("#Cronometro").val();
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:30"){
                    document.getElementById('min').style.color='red';
                }
            } 
            if(Tempo === "1"){                    
                if($("#min").html() === "00:29"){
                    document.getElementById('min').style.color='black';
                }
            } 
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:28"){
                    document.getElementById('min').style.color='red';
                }
            } 
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:27"){
                    document.getElementById('min').style.color='black';
                }
            }   
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:26"){
                    document.getElementById('min').style.color='red';
                }
            }

            if(Tempo === "1"){                    
                if($("#min").html() === "00:25"){
                    document.getElementById('min').style.color='black';
                }
            } 
            if(Tempo === "1"){                    
                if($("#min").html() === "00:24"){
                    document.getElementById('min').style.color='red';
                }
            }     
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:23"){
                    document.getElementById('min').style.color='black';
                }
            }      
            if(Tempo === "1"){                    
                if($("#min").html() === "00:22"){
                    document.getElementById('min').style.color='red';
                }
            }    
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:21"){
                    document.getElementById('min').style.color='black';
                }
            }    
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:20"){
                    document.getElementById('min').style.color='red';
                }
            }     
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:19"){
                    document.getElementById('min').style.color='black';
                }
            }     
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:18"){
                    document.getElementById('min').style.color='red';
                }
            }                 
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:17"){
                    document.getElementById('min').style.color='black';
                }
            } 

             if(Tempo === "1"){                    
                if($("#min").html() === "00:16"){
                    document.getElementById('min').style.color='red';
                }
            } 
            
    
            if(Tempo === "1"){
                if($("#min").html() === "00:15"){
                    $("body").attr("class","background-pulse");
                    document.getElementById('min').style.color='black';
                }
            } 
             if(Tempo === "1"){                    
                if($("#min").html() === "00:14"){
                    document.getElementById('min').style.color='red';
                }
            }                 
             if(Tempo === "1"){                    
                if($("#min").html() === "00:13"){
                    document.getElementById('min').style.color='black';
                }
            } 
             if(Tempo === "1"){                    
                if($("#min").html() === "00:12"){
                    document.getElementById('min').style.color='red';
                }
            }    
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:11"){
                    document.getElementById('min').style.color='black';
                }
            }                 
            
            if(Tempo === "1"){
                if($("#min").html() === "00:10"){
                $('#modal').modal('show');
                 document.getElementById('min').style.color='red';
                }
            }  
            
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:09"){
                    document.getElementById('min').style.color='black';
                }
            }     
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:08"){
                    document.getElementById('min').style.color='red';
                }
            }  
            
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:07"){
                    document.getElementById('min').style.color='black';
                }
            }    
            
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:06"){
                    document.getElementById('min').style.color='red';
                }
            }                 
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:05"){
                    document.getElementById('min').style.color='black';
                }
            }                 
                                            
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:04"){
                    document.getElementById('min').style.color='red';
                }
            }                 
                                            
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:03"){
                    document.getElementById('min').style.color='black';
                }
            }                 
                                            
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:02"){
                    document.getElementById('min').style.color='red';
                }
            }                 
                                            
                        
            if(Tempo === "1"){
                if($("#min").html() === "00:01"){
                    $('#modal').modal('hide');
                }
            }  

            if(Tempo === "1"){
                if($("#min").html() === "00:01"){
                    $('#modal2').modal('show');
                }
            }                          
        }
    }, 1000);
}

function Start() {
var Tempo = $("#Cronometro").val();
var fiveMinutes = 90 * Tempo,
    display = document.querySelector('#min');

$(".txtTempo").show();
startTimer(fiveMinutes, display);
$("#btnPlay").attr("disabled","disabled");
};

function Stop() {
$("#min, .txtTempo").html("00:00");
$(".txtTempo").hide();
clearInterval(myInterval);
$("body").removeAttr("class");
$("#msgHold").hide();
$("#btnPlay").removeAttr("disabled");
document.getElementById('min').style.color='black';
};

document.getElementById('min').style.fontWeight="bold";
Fonte Link

Guia do browser / Title piscar ao atingir tempo determinado

Boa tarde!

Tenho o seguinte código:

function startTimer(duration, display) {

var timer = duration, minutes, seconds;
    myInterval = setInterval(function () {
    minutes = parseInt(timer / 60, 10)
    seconds = parseInt(timer % 60, 10);
    minutes = minutes < 10 ? "0" + minutes : minutes;
    seconds = seconds < 10 ? "0" + seconds : seconds;
    display.textContent = minutes + ":" + seconds;

        $(".txtTempo").html(minutes + ":" + seconds);

        if (--timer < 0) {
            $("#min").html("00:00");
            clearInterval(myInterval);
        }
                    
        else{
            var Tempo = $("#Cronometro").val();
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:30"){
                    document.getElementById('min').style.color='red';
                }
            } 
            if(Tempo === "1"){                    
                if($("#min").html() === "00:29"){
                    document.getElementById('min').style.color='black';
                }
            } 
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:28"){
                    document.getElementById('min').style.color='red';
                }
            } 
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:27"){
                    document.getElementById('min').style.color='black';
                }
            }   
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:26"){
                    document.getElementById('min').style.color='red';
                }
            }

            if(Tempo === "1"){                    
                if($("#min").html() === "00:25"){
                    document.getElementById('min').style.color='black';
                }
            } 
            if(Tempo === "1"){                    
                if($("#min").html() === "00:24"){
                    document.getElementById('min').style.color='red';
                }
            }     
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:23"){
                    document.getElementById('min').style.color='black';
                }
            }      
            if(Tempo === "1"){                    
                if($("#min").html() === "00:22"){
                    document.getElementById('min').style.color='red';
                }
            }    
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:21"){
                    document.getElementById('min').style.color='black';
                }
            }    
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:20"){
                    document.getElementById('min').style.color='red';
                }
            }     
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:19"){
                    document.getElementById('min').style.color='black';
                }
            }     
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:18"){
                    document.getElementById('min').style.color='red';
                }
            }                 
            
            if(Tempo === "1"){                    
                if($("#min").html() === "00:17"){
                    document.getElementById('min').style.color='black';
                }
            } 

             if(Tempo === "1"){                    
                if($("#min").html() === "00:16"){
                    document.getElementById('min').style.color='red';
                }
            } 
            
    
            if(Tempo === "1"){
                if($("#min").html() === "00:15"){
                    $("body").attr("class","background-pulse");
                    document.getElementById('min').style.color='black';
                }
            } 
             if(Tempo === "1"){                    
                if($("#min").html() === "00:14"){
                    document.getElementById('min').style.color='red';
                }
            }                 
             if(Tempo === "1"){                    
                if($("#min").html() === "00:13"){
                    document.getElementById('min').style.color='black';
                }
            } 
             if(Tempo === "1"){                    
                if($("#min").html() === "00:12"){
                    document.getElementById('min').style.color='red';
                }
            }    
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:11"){
                    document.getElementById('min').style.color='black';
                }
            }                 
            
            if(Tempo === "1"){
                if($("#min").html() === "00:10"){
                $('#modal').modal('show');
                 document.getElementById('min').style.color='red';
                }
            }  
            
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:09"){
                    document.getElementById('min').style.color='black';
                }
            }     
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:08"){
                    document.getElementById('min').style.color='red';
                }
            }  
            
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:07"){
                    document.getElementById('min').style.color='black';
                }
            }    
            
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:06"){
                    document.getElementById('min').style.color='red';
                }
            }                 
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:05"){
                    document.getElementById('min').style.color='black';
                }
            }                 
                                            
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:04"){
                    document.getElementById('min').style.color='red';
                }
            }                 
                                            
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:03"){
                    document.getElementById('min').style.color='black';
                }
            }                 
                                            
            
             if(Tempo === "1"){                    
                if($("#min").html() === "00:02"){
                    document.getElementById('min').style.color='red';
                }
            }                 
                                            
                        
            if(Tempo === "1"){
                if($("#min").html() === "00:01"){
                    $('#modal').modal('hide');
                }
            }  

            if(Tempo === "1"){
                if($("#min").html() === "00:01"){
                    $('#modal2').modal('show');
                }
            }                          
        }
    }, 1000);
}

function Start() {
var Tempo = $("#Cronometro").val();
var fiveMinutes = 90 * Tempo,
    display = document.querySelector('#min');

$(".txtTempo").show();
startTimer(fiveMinutes, display);
$("#btnPlay").attr("disabled","disabled");
};

function Stop() {
$("#min, .txtTempo").html("00:00");
$(".txtTempo").hide();
clearInterval(myInterval);
$("body").removeAttr("class");
$("#msgHold").hide();
$("#btnPlay").removeAttr("disabled");
document.getElementById('min').style.color='black';
};

document.getElementById('min').style.fontWeight="bold";

Ele é um cronômetro que ao faltar 30 segundos para ser finalizado o tempo dele, ele irá mudar de cor e ao faltar 15 segundos, ira piscar um alerta na tela toda e ao clicar no botão "Stop" todas essas interações causadas são pausadas. Alguém saberia me auxiliar se é possível que além desse alerta na tela, a guia do browser / Título, também ficasse piscando? Para o caso da pessoa ver a janela mesmo minimizada piscando?