1

I have Timer javascript function which works well, but on iOS I can only see aN:aN:aN result. Here is the code:

 function getTimeRemaining(endtime) {
    var t = Date.parse(endtime) - Date.parse(new Date());
    var seconds = Math.floor((t / 1000) % 60);
    var minutes = Math.floor((t / 1000 / 60) % 60);
    var hours = Math.floor((t / (1000 * 60 * 60)) % 24);
    var days = Math.floor(t / (1000 * 60 * 60 * 24));
    return {
      'total': t,
      'days': days,
      'hours': hours,
      'minutes': minutes,
      'seconds': seconds
    };
  }

  function initializeClock(id, endtime) {
    var clock = document.getElementById(id);
    var daysSpan = clock.querySelector('.days');
    var hoursSpan = clock.querySelector('.hours');
    var minutesSpan = clock.querySelector('.minutes');
    var secondsSpan = clock.querySelector('.seconds');

    function updateClock() {
      var t = getTimeRemaining(endtime);

      hoursSpan.innerHTML = ('0' + t.hours).slice(-2);
      minutesSpan.innerHTML = ('0' + t.minutes).slice(-2);
      secondsSpan.innerHTML = ('0' + t.seconds).slice(-2);


      if (t.total <= 0) {
        $( "#end-of-translation" ).submit(); 
      }

        if($("#addtime_form").length == 0) {
          if(t.total <= 300000) {
            $("#addtime-form").append("<input id='addtime_form' type='submit' name='addtime' value='Add 15 minutes'>");
          }
        }
    }

    updateClock();
    var timeinterval = setInterval(updateClock, 1000);
  }

  var now = Date.parse(new Date());
  var seconds = Math.floor((now / 1000) % 60);
  var minutes = Math.floor((now / 1000 / 60) % 60);
  var left_to_hour = 60 * 60 * 1000 - (minutes * 60 + seconds) * 1000;

  initializeClock("clockdiv", deadline);

Can someone tell me why I get NaN instead time?

My second problem is POST request on iOS. I can not find in POST array input type=submit param... so I need to change in the whole project if statements form:

 if( $_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['submit'])) 

to only:

 if( $_SERVER['REQUEST_METHOD'] == 'POST')

Anyone had a similar problem?

L_J
  • 2,351
  • 10
  • 23
  • 28
vegito15
  • 35
  • 4

0 Answers0