Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

212
Visualizações
Filemaker: webviewer timer

I’m trying to make in FileMaker a web viewer to show some “countdown” for my medical office.

I’m trying to adapt this code I have found on internet:

     "data:text/html,<html>
<head>
<script type='text/javascript'>

/*Setting JavaScript Variables to value of FileMaker fields*/
var targetTimeTxt = '" & Timer::Timestamp_End & "';
var status = '" & Timer::Status & "';
var labelTxt = '" & Timer::Label & "';
/*End FileMaker Fields*/

var currentTime = new Date();
var targetTime = new Date(targetTimeTxt);
var remaining = Math.floor((targetTime - currentTime)/1000);

function setClock()
{
    var currentTime = new Date();
    var clock = document.getElementById('clock');
    var labelobj = document.getElementById('label1');
    var secondsRemaining=0;
    if(labelTxt=='')
    {
        labelobj.innerHTML='Timer';
    }
    else
    {
        labelobj.innerHTML=labelTxt;
    }

    if (targetTime>currentTime)
    {
        secondsRemaining=Math.floor((targetTime - currentTime)/1000);
    }

    var hours = Math.floor( secondsRemaining / 3600 );
    var minutes = Math.floor((secondsRemaining%3600) / 60 );
    if(minutes<10)minutes='0' + minutes;
    var seconds = secondsRemaining%60;
    if(seconds<10)seconds='0'+seconds;

    clock.innerHTML=hours + ':' + minutes + ':' + seconds;

    if(targetTimeTxt=='' || status=='Acknowledged' || ( secondsRemaining==0 && Math.floor(currentTime/1000)%2==0 ) )
    {
        document.body.style.backgroundColor='#FFFFFF';
        if ( targetTimeTxt=='' || status=='Acknowledged' )
        {
            clock.innerHTML='--:--:--';
        }
    }
    else if(secondsRemaining==0)
    {
        document.body.style.backgroundColor='#FFFF00';
        document.getElementById('sound1').Play();
    }

    setTimeout('setClock();',1000);
}

</script>
</head>
<body style='margin:4px;padding:0;font-size:14px;font-weight:bold;font-family: Arial, Helvetica, sans-serif;text-align:center;background-color:#FFFFFF;' onload='setClock();'>
<div id='label1' style='font-size:10px;font-weight:bold;'>
</div>
<div id='clock'>
</div>
<embed src='file:///System/Library/Sounds/Glass.aiff' autostart='false'  id='sound1'
enablejavascript='true' width='0' height='0'>
</body></html>" 

The FileMaker Var are correct, and the time stamp end car get dd/mm/yyyy hh:mm:ss results.

The web viewer works, but the timer starts always with a 2640:mm:ss….. indeed of the duration time. I suspect there is an error in the calculation of the code, but I have no idea where to look.

Can someone help me? I hanno no idea of Java programming. Thanks.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Here is something very simple you could use as your starting point:

Let ([
seconds = Timer::Timestamp_End - Get(CurrentTimestamp) ;
html = "data:text/html, <html>
<head>
<script type='text/javascript' language='javascript'>
function count_down(seconds) {
i = seconds; 
h = Math.floor(i/3600);
m = Math.floor(i%3600/60);
s = i%60;
if (m < 10) { m = '0' + m };
if (s < 10) { s = '0' + s };
if (i > 0) { 
document.getElementById('hr').innerHTML = h;
document.getElementById('min').innerHTML = m;
document.getElementById('sec').innerHTML = s;
i--;
setTimeout('count_down(i)', 1000);
}
else {
document.getElementById('timer').innerHTML = 'Expired';
}
}
</script>
</head>
<body onload='count_down(«seconds»)'> 
<div id='timer'><span id='hr'></span>:<span id='min'></span>:<span id='sec'></span></div>
</body>
</html>" 
] ;
Substitute ( html ; "«seconds»" ; GetAsNumber ( seconds ) )
)

This assumes the Timestamp_End field is a Timestamp field.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda