Think about this a little more. What happens when a user leaves the page? I got the impression that the camera remains where it was left. If so, even with this disabled at times, the camera could inadvertently get left at an angle that would later burn it out.
I'm also curious (but this isn't too important here), what happens when two users try to control the camera at once.
Have you lost any cameras yet?
Getting back to using javascript for this, there is no reliable way, unless we can at least get the time from the server.
A very unreliable method that depends upon well intentioned users with accurate clocks, and upon a camera that cannot be left in a bad spot as mentioned above would be:
HTML Code:
<input id="up_button" type="button" value="UP" onclick="setVariable('move=1')">
<script type="text/javascript" defer="defer">
<!--
var UTC_hours = new Date().getUTCHours();
if(UTC_hours > 5 && UTC_hours < 17)
document.getElementById('up_button').disabled = true;
// -->
</script>
That will kill the button for a twelve hour period, from 5am to 5pm GMT. You may change the range to suit, but remember - at different times of the year, things will be different - so make the range as broad as possible. UTC is the same as GMT, both skip changes in DST, and for user's with accurate clocks, it will be the same value regardless of their time zone. You must determine the difference between UTC time and your locale, and add/subtract the difference between your zone and UTC here (IMPORTANT):
Code:
var UTC_hours = new Date().getUTCHours() - 5;
with full awareness that if DST is used in your area, that will throw things off a little at those times, so the range should be padded by an extra hour in one direction or the other. Also sunrise and sunset varies, you will want to cover all times in the year that the camera could possibly be in jeopardy.
Maybe you should just rent a room on the other side of the street.
Bookmarks