Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

213
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda