Results 1 to 3 of 3
  1. #1
    kenny724 is offline Member
    Join Date
    Sep 2011
    Posts
    1
    Rep Power
    0

    Default Strange behavior of jova script

    Hey, everyone. I'm not exactly sure what happened to this java script. Any pointers would be helpful.

    The time is displayed correctly...but the session expiration is 5 hours behind the current time. Somewhat confusing...can someone look at the code and help? Thanks.

    function validateTime(timeStr) {
    // Checks if time is in HH:MM:SS AM/PM format.
    // The seconds and AM/PM are optional.
    if(timeStr == '') return false;
    timeStr = timeStr.toUpperCase();
    var timePat = /^(\d{1,2}):(\d{2})?(\s?(AM|am|PM|pm))?$/;
    var pm_times = 0;
    var matchArray = timeStr.match(timePat);
    hour = matchArray[1];
    minute = matchArray[2];
    ampm = matchArray[4];
    if (ampm == 'PM' && hour < 12) pm_times = 12 * 3600;
    return pm_times + (hour * 3600) + (minute * 60);
    }

    $(function() {
    $('#nav').droppy({speed: 130});
    var options1 = {format: '%I:%M:%S %p' }
    $('#jclock1').jclock(options1).addClass('ui-state-active ui-corner-all');


    $('#timeout').everyTime(5000,function(i) {
    var cookiename = 'time_left=';
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ')
    c = c.substring(1,c.length);
    if (c.indexOf(cookiename) == 0) {
    var data = c.substring(cookiename.length,c.length);
    data = unescape(data.replace(/\+/,' '));
    data = 'Session expires<br/>at ' + data;
    }
    }
    $('#timeout').html(data);
    }).addClass('ui-state-error ui-corner-all');

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default Re: Strange behavior of jova script

    Javascript != Java.
    This is a Java forum.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: Strange behavior of jova script

    Off topic, locking.

    db

Similar Threads

  1. Strange HashMap behavior
    By mjdousti in forum Advanced Java
    Replies: 2
    Last Post: 08-24-2011, 08:41 PM
  2. Strange Arrays behavior
    By amro in forum New To Java
    Replies: 10
    Last Post: 11-03-2010, 07:08 AM
  3. Replies: 6
    Last Post: 09-04-2009, 02:48 AM
  4. Strange behavior with Thread.sleep()
    By Steve11235 in forum Advanced Java
    Replies: 16
    Last Post: 05-04-2009, 05:24 AM
  5. strange refreshing behavior
    By diggitydoggz in forum New To Java
    Replies: 4
    Last Post: 12-27-2008, 04:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •