Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: Enable/Disable buttons at certain times of day

  1. #11
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    We still need to include the CENTER button, and I just realized that we should do this not just on page load, but every minute or so. And, since it looks like it is already getting light there, I changed the values a little:

    Code:
    <tr>
      <td colspan=2 align=center>
      
    <input id="up_button" type="button" value="UP" onclick="setVariable('move=1')">
    
      
      </td>
    </tr>
    <tr>
      <td align=center>
        <input type="button" value="LEFT" onclick="setVariable('move=4')">
        <input id="center_button" type="button" value="CENTER" onclick="setVariable('move=16')">
    <script type="text/javascript" defer="defer">
    <!-- 
    var enableDisable = function(){
    var UTC_hours = new Date().getUTCHours();
    if(UTC_hours >= 3 && UTC_hours < 17)
    document.getElementById('up_button').disabled =
    document.getElementById('center_button').disabled = true;
    else
    document.getElementById('up_button').disabled =
    document.getElementById('center_button').disabled = false;
    }
    setInterval(enableDisable, 1000*60);
    enableDisable();
    // -->
    </script>
        <input type="button" value="RIGHT" onclick="setVariable('move=8')">
      </td>
    </tr>
    <tr>
      <td colspan=2 align=center>
       <input type="button" value="DOWN" onclick="setVariable('move=2')"> 
      </td>
    </tr>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  2. The Following User Says Thank You to jscheuer1 For This Useful Post:

    NairB (06-01-2008)

  3. #12
    Join Date
    Mar 2007
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    SUCCESS, I got it working. Whoopeee.

    John, I added +1 to the code and it works for my desired time to "disable" 5am.

    EDIT - I also added an '=' sign after the 5 as I seen this in your new code!!!!

    I have set it to "enable" again at 10am when the sun is further west out of view.

    Here is what your code looks like john that works for me...

    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() + 1;
    if(UTC_hours >= 5 && UTC_hours < 10)
    document.getElementById('up_button').disabled = true;
    // -->
    </script>
    Also, I have manipulated the code to do the "CENTER" button too and that works also...yipeee....

    Code:
    <input id="center_button" type="button" value="CENTER" onclick="setVariable('move=1')">
    <script type="text/javascript" defer="defer">
    <!-- 
    var UTC_hours = new Date().getUTCHours() + 1;
    if(UTC_hours >= 5 && UTC_hours < 10)
    document.getElementById('center_button').disabled = true;
    // -->
    </script>
    So at 5am both "UP" & "CENTER" buttons will disable, then at 10am both enable.....great.

    I adjusted my PC clock to check both works.

    I'm very happy with this....thanks very much John

    A very happy NairB
    Last edited by NairB; 06-01-2008 at 05:23 AM.

  4. #13
    Join Date
    Mar 2007
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Oh I just noticed your new code above my last post....we must have posted at the same time lol.

    I will try your new code to see how that works.

    EDIT - GREAT I am now using the new code John and it works just fine.

    Many thanks again friend.

    NairB
    Last edited by NairB; 06-01-2008 at 06:42 AM.

  5. #14
    Join Date
    Mar 2007
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Hi John,

    I thought I would update you. I was worried that even although the disable code will work locally, that someone in another time zone could still have full control of my cam in another timezone, as you warned.....so I got thinking...

    I have cam up with another method to protect my cam. The biggest threat is first thing in the morning as the sun rises to the right of the cam above the church. So I have written code where as the remote viewer clicks "right", the cam will also move "down" after 5 seconds. Each time "right" is clicked, the cam will move "down" automatically taking the cam out of direct sunlight danger.

    Code:
    <tr>
    
      <td colspan=2 align=center>
    
    <script language="JavaScript">
    <!-- hide
    
    function timer() {
      setTimeout("setVariable('move=2')", 5000);
    }
    
    // -->
    </script>
      
    <input disabled type="button" value="UP" onclick="setVariable('move=1')">
     </td>
        </tr>
    
    <tr>
      <td align=center>
        <input type="button" value="LEFT" onclick="setVariable('move=4')">
        <input type="button" value="CENTER" onclick="setVariable('move=16')">
        <input type="button" value="RIGHT" onclick="timer(setVariable('move=8'))">
      </td>
    </tr>
    <tr>
      <td colspan=2 align=center>
       <input type="button" value="DOWN" onclick="setVariable('move=2')"> 
      </td>
    </tr>
    See for yourself....its probably the best way to do this although I can never use the " UP" button. At least my remote viewers can still see the sky to the left of center as some want to "weather watch" lol.....a crazy bunch they are lol.

    Thanks again,

    NairB
    Last edited by NairB; 06-04-2008 at 07:05 AM.

  6. #15
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I'm all for anything you can do to protect that camera. As I said before about the code I wrote, it will work as long as the user's clock is accurate. What I didn't spell out though is that since it converts their time to UTC time - it doesn't matter what timezone they are in, as long as they are all well intentioned.

    Even with your updated code, a user may enter commands directly into the browser's address bar, and thereby do whatever they like with the camera.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #16
    Join Date
    Mar 2007
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1 View Post
    I'm all for anything you can do to protect that camera. As I said before about the code I wrote, it will work as long as the user's clock is accurate. What I didn't spell out though is that since it converts their time to UTC time - it doesn't matter what timezone they are in, as long as they are all well intentioned.

    Even with your updated code, a user may enter commands directly into the browser's address bar, and thereby do whatever they like with the camera.
    Oh so even if folk in the east coast of US look at my cam here in UK, the buttons will be "disabled"?? If so I will use both methods....its better than none John don't you agree.

    I imagine most folks in the world have fairly accurate clocks John, whether they have good intentions is another matter.

    I will put your code back on with the timer code I added and re-enable the "UP" button again.

    -NairB

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •