jclock icon indicating copy to clipboard operation
jclock copied to clipboard

NaN on iOS

Open retsofcm opened this issue 11 years ago • 1 comments

I'm trying to fix an issue on an existing website that was built a few years ago and originally running version 2.0.2 of jclock (I believe) until I updated it. The developer who originally created this site is long gone and I'm still very new to Javascript.

From what I can tell, they simply have a backend where they can input +1, +2, +3 etc "hours from now" and the clock on the website updates to match the time (http://www.acesamedaycouriers.com/).

The previous developer calls jclock in script.js like this:

jQuery(function(jQuery) { var startTime = parseInt(jQuery('.jclock').html(), 10) * 1000; var options = { format: '%H:%M', seedTime: startTime }; jQuery('.jclock').jclock(options); });

If I comment out the startTime variable and seedTime option, the widget works fine on both the desktop and iOS version. Putting it back in causes Apple devices to display NaN (although, it works fine in Safari). I'm assuming this is because of the way the parseInt line is written and they can't read the output? But I'm not sure what I can do to fix it. Would you have any advice for me?

Thank you!

retsofcm avatar May 27 '14 10:05 retsofcm

Wanted to leave a note for others with a potentially similar problem as I have solved this issue.

iOS outputs as NaN because when the output milliseconds get edited by our Javascript. iOS looks at the milliseconds, decides a number that length is a telephone number and wraps it in a link. Then the JS looks at it and sees a link instead of a number, hence NaN:NaN. Got around this issue with a meta tag in the end.

retsofcm avatar May 28 '14 14:05 retsofcm