One thing this plugin can do that server-side code can’t is being able to expire a page while the user is on it. For example, say you have a form that you want users to be able to complete, but you want to stop anyone from submitting after a certain deadline. With a server-side language, you can prevent the user from accessing the page and submitting once the deadline is passed, but you can’t prevent him from accessing the page before the deadline, and then leaving it open even after the deadline passes. You could stop him when he tries to submit, but not while he’s filling out the form.
One of the drawbacks I came across while developing this plugin was the current datetime being pulled from the client. This presents two problems:
All the user has to do is set their local machine’s time to be within your time range, and access will be granted again.
Time ranges are relevant to the user’s timezone, meaning the page will be expired for different users at different times globally.
To get around this, I provide an option for pulling the atomic time from a time service, and also providing an option to specify a global timezone. You can also just use the user’s local timezone, but time from the time service. The timezone will be pulled from another service based on the user’s IP address.
As always, this plugin is open-source. Feel free to fork and modify. I’d also appreciate any help fixing the known bugs already in the code.
On a side-note, I’m excited for jQuery’s new plugins site that will be held together by git repositories and CommonJS packages. I’m including a package.json file in all my plugin repositories in anticipation for the site launch. However, the current package spec is living, so changes may come to those as the spec changes.