3 ms·
>6k and a jQuery dependency? Dates aren't as hard as they used to be. I'm working on a pure-JS datepicker for modern browsers that will clock in at under 5k min
by potch 14y ago
>6k and a jQuery dependency? Dates aren't as hard as they used to be. I'm working on a pure-JS datepicker for modern browsers that will clock in at under 5k minified, with no dependencies. Take a look at my work so far here: https://github.com/potch/fortnight.js https://github.com/potch/fortnight.js
(Edited to correct that the likely final minified size will be closer to 5k. Hoping to add accessibility features and localizability.)
- gildas 14y agoIt makes my Chrome and IE9 freeze because of an infinite loop at #228 in the demo.
- potch 14y agoThank you for the bug report!
- lobster_johnson 14y agoFreezes up Chrome 23, Firefox 16.0.2 (shows "stop this script?" box) and Safari 6.0. Opera does not freeze, but the UI is very slow, suggesting something is still wrong.
- potch 14y agoI believe I made a huge mistake in my calendar rendering code. Hoping it's fixed now. Sorry for freezing!
- lobster_johnson 14y agoIt's still happening. Now (unlike before) it does show the widgets, but Chrome goes up to 100% CPU and nothing happens when I click the widgets.
- potch 14y agoI can't reproduce- what version of chrome are you using? I'm re-evaluating all my loops to increase general safety.
- lobster_johnson 14y agoChrome 23 on Mac. Still happening with FF, even after upgrading to 17.0. FF's "Unresponsive script" alert box mentions line 103. It's not just loops that can trigger this stuff. It's also callbacks that trigger the same callbacks.
- lobster_johnson 14y agoIt's the "while (!done)" loop. next(2012-09-24) returns the same date. Not sure why yet.
- lobster_johnson 14y agoYour date arithmetic jumps through some weird hoops to accomplish something really simple. To increment a date by one day, for example, can be done like so: d = new Date(base); d.setDate(d.getDate() + 1); Changing rel() to do this fixes the loop problem, but something else is surely wrong, because the result page now looks like this: http://i.imgur.com/ZUAJg.png http://i.imgur.com/ZUAJg.png
- listenrightmeow 14y agoI have always wondered why javascript date pickers were always over complicated for the job. https://github.com/listenrightmeow/daterange https://github.com/listenrightmeow/daterange Under 5k/100 lines uncompressed. You can easily modify above to work in a prototype fashion without a library. Unfortunately I was lazy when I wrote it and used ender/jquery for selector support.
- lobster_johnson 14y agoIf you are going to offer something you claim to be better, it should be better. I did a "git clone" and opened the example: * The example looks unappealing. Not styled, not bound to a text field. * It's not clear to my why clicking twice in a row produces a range — should this not be accomplished through mouse dragging or similar? * If I select an end date that precedes the start date, it shows an alert box, which apparently is hardwired into the library. Not only does this make it impossible to translate the widget into multiple languages, but it's really not the task of the library to handle the error like this (an "onInvalidRange" or similar should be provided for the app to plug in). * Month name is hardwired, no translation possible. * No week numbers. * No highlighting of today, holidays, or indeed of the selected range. * No way to plug in custom dates that should be highlighted (for example, "booked" dates). In other words, this is incomplete. I can't speak for most people, but it's useless to me. Sure, I could take your code and extend it to fit my app, but I could just as easily write it from scratch -- which defeats the point of reusability. Sorry if this comes across a bit harsh, but you did open yourself to criticism: > I have always wondered why javascript date pickers were always over complicated for the job. Frankly, I suspect you have underestimated the job. :-)
- oxide 14y agoi enjoyed this post.
- city41 14y agoLooks like Chrome's native date pickers are competing with fortnight. When I click on one of the input fields, while holding the click in, I get a fortnight picker. As soon as I let go, I get a native picker.