Sudhakar_1 0 Newbie Poster

The Timer displayed is 1 hr (HH:MM:SS) in decrement order. I have to display a pop out when 50 minutes complete after that remaining 10 minutes one pop up should display saying 10 minutes with 0 sec.

After that for every 2 minutes the pop up appear showing 2 minutes left remaining time out.

Example: It was showing 8 minutes left for time out, but the pop should appear with 8 minutes left.

<head>
<!-- //In header section of the page add below url code: -->
<!-- Sesion time out and session expiry url starts here -->
<s:url id="sessionExpirePopUp" action="sessionOutCiscoGSS" namespace="">
</s:url>
<s:set name='sessionExpirePopUpNew'
    value='#sessionExpirePopUp.replace("&amp;","&")' />
<!-- Sesion time out and session expiry url starts here -->

<script type="text/javascript" language="javascript"
    src="<%=request.getContextPath() %>/jsp/js/jquery.js"></script>
<script type="text/javascript">
    var timeOutSesVal = 1000 * 60 * 50; // 30 min: session validation time
    var timeOutSesExp = 1000 * 60 * 10; // 10 min: session expiry time
    var lastActivitySesVal = new Date().getTime();
    var lastActivitySesTO;
    var reducingTimeSec;
    var Min, Sec;

    /* Sesion time out and session expiry code starts here */
    //below method code is executed until showing sesion validation popup
    var checkTimeout;
    checkTimeOut = function() {
        if (new Date().getTime() > lastActivitySesVal + timeOutSesVal) {
            //      document.getElementById('icwModalWashout').style.visibility = 'visible';
            //      document.getElementById('icwModal4').style.visibility = 'visible';

            lastActivitySesTO = new Date().getTime();
            checkTimeoutSesExp();// this method call is to start expiry timer and show expired message dialog
        } else {
            window.setTimeout(checkTimeOut, 1000 * 60 * 2); // check 10 per second
        }
        // }
    }

    //below method code is executed on click of continue button in first popup
    function checkTimeOutAgain() {
        lastActivitySesVal = new Date().getTime();
        lastActivitySesTO = lastActivitySesVal + 1000 * 60 * 9999;//set some indefinite time to avoid showing session expiry popup
        checkTimeOut();
    }

    //below code is for counter display
    function showXMinXSec() {
        reducingTimeSec = Math
                .floor(((lastActivitySesTO + timeOutSesExp) - new Date()
                        .getTime()) / 1000);
        //calculate minutes and secods
        Min = Math.floor(reducingTimeSec / 60);
        Sec = reducingTimeSec % 60;
        if (Min > 0) {
            window.confirm("your data will be lost in " + Min + " Minutes and "
                    + Sec + " Seconds. Please save your data");
        } else {
            window.confirm("your data will be lost in " + Sec
                    + " Seconds. Please save your data");
        }
    }

    //below method code is executed for showing next/sesion expiry popup
    var checkTimeoutSesExp;
    checkTimeoutSesExp = function() {
        if (new Date().getTime() > lastActivitySesTO + timeOutSesExp) {
            //hide Session Timeout pop up/icwModal4 and enable Session expired/icwModal5 pop up after invalidating session
            document.getElementById('icwModal4').style.visibility = 'hidden';
            //invalidating session
            //      $.ajax({
            //          type: "POST",
            //          url: '<s:property value="#sessionExpirePopUpNew"/>',
            //          dataType: "json",
            //          success: function(){
            //              document.getElementById('icwModal5').style.visibility = 'visible';
            //          },
            /*      error: function(data){
                        alert('Error in ajax call/response!');
                        getElementById('icwModalWashout').style.visibility='hidden';
                    }*/
            //  });
            return false;
        } else {
            //write logic to show X minutes and X seconds
            showXMinXSec();
            window.setTimeout(checkTimeoutSesExp, 1000 * 60 * 2); // check 2 min
        }
    }
</script>
</head>