0
<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>
2
Contributors
1
Reply
9
Views
2 Years
Discussion Span
Last Post by stultuske
0

Sudhakar_1: don't put the description of an issue in one Thread, and the code in another.

Hi.

The Timer displayed is 1 hr (HH:MM:SS) in decrement order. I have to display a pop out when 50 mints complete after that remaining 10 mints one pop up should display saying 10 mints with 0 sec.
After that for every 2 mintues the pop up appear showing 2minutes left remaining time out.
Example: It was showing 8 mintues left for time out, but the pop should appear with 8 minutes left.

You have posted this in the wrong forum. This is a Java forum, yet you are asking about JavaScript. If you think they are related, well .... you could say that JavaScript is to Java as a carpet is to a car.

You will have more luck in the JavaScript forum.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.