I have the following code to show how long a user has left before their session will expire, I am using WordPress. How can I do this? Thanks
<script>
var obj_Span;
var n_Seconds = 0;
var n_Minutes = 0;
var n_Hours = 0;
function F_ConvertNumberToString ( n_Num )
{
var str_Num = String(n_Num);
if ( str_Num.length < 2 ) str_Num = "0" + str_Num;
return str_Num;
}
function F_CountDown ()
{
if ( n_Hours == 0 && n_Minutes == 0 && n_Seconds == 0 )
{
obj_Span.innerHTML = "(Sorry, your session has expired.)";
}
else
{
if ( n_Seconds >= 0 ) n_Seconds --;
if ( n_Seconds < 0 )
{
n_Minutes --;
n_Seconds = 59;
}
if ( n_Minutes >= 0 )
{
window.setTimeout ( "F_CountDown()", 1000 );
}
if ( n_Minutes < 0 )
{
n_Hours --;
n_Minutes = 59;
window.setTimeout ( "F_CountDown()", 1000 );
}
F_UpdateDisplay ();
}
}
function F_UpdateDisplay ( )
{
if ( document.getElementById )
{
if (n_Hours > 0 ) obj_Span.innerHTML = "(Remaining " + F_ConvertNumberToString(n_Hours) + ":" + F_ConvertNumberToString(n_Minutes) + ":" + F_ConvertNumberToString(n_Seconds) + ")";
else obj_Span.innerHTML = "(Remaining " + F_ConvertNumberToString(n_Minutes) + ":" + F_ConvertNumberToString(n_Seconds) + ")";
}
}
function F_StartCountDown ( n_Session )
{
obj_Span = document.getElementById ( "CountDown" );
n_Minutes = n_Session;
n_Hours = Math.floor(n_Minutes/60);
n_Minutes = n_Minutes - (60*n_Hours);
F_CountDown ();
}
</script>
<script>
F_StartCountDown ( " code here... " );
</script>
<span id="CountDown"></span>