Author Topic: add my webcam image to rotate using ajax-gizmo  (Read 3959 times)

0 Members and 1 Guest are viewing this topic.

Offline w2swr

  • Member
  • *
  • Posts: 12
add my webcam image to rotate using ajax-gizmo
« on: July 23, 2012, 09:07:05 AM »
Hi,

I am trying to figure out a way (if its even possible) how to get my webcam image to auto update with ajax -gizmo. Anyone have any ideas?

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: add my webcam image to rotate using ajax-gizmo
« Reply #1 on: July 23, 2012, 01:10:45 PM »
I see you're using the dashboard, so you're running ajax.  I use this code, borrowed from a post by Ken True a couple of years ago, on several pages on my site.  This code is what's used to refresh my Nexstorm image.  It times out with the ajax updates, and requires no modification of the ajax*.js file, only the php files.
Code to display the image:
Code: [Select]
    <img src="nexstorm.png" alt="Current Nexstorm Map" width="640" height="480" hspace="5" vspace="5" id="myPull"/>
Note the id="mypull" which links to the inline javascript that's at the bottom of the page before the last [/div], which is main-copy.

Code: [Select]
<span class="ajax" id="imagereLoader">
<script type="text/javascript"><!--
//<![CDATA[
function reloadImage() {
var now = new Date();
if (document.images && (ajaxUpdates < update.maxupdates)) {
document.images.myPull.src = 'nexstorm.png?' + now.getTime();
document.images.myPull2.src = './lightning/wasp2.png?' + now.getTime();
}
setTimeout('reloadImage()',30000);
}
setTimeout('reloadImage()',30000);
//]]>
-->
</script>
</span>

I also have included code to refresh my wasp2 image.  The images keeps reloading until ajax times out, then it stops. These are moderately sized images.

Modification of the dashboard to display webcam thumbnails and update them regularly is also easily done with this technique, although it's a bit more work to get everything lined up properly.  My dashboard has been modified to display both my webcam's thumbnail images:  http://www.gwwilkins.org
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline Albuquerque Weather

  • Senior Contributor
  • ****
  • Posts: 265
    • Albuquerque Amateur Weather
Re: add my webcam image to rotate using ajax-gizmo
« Reply #2 on: July 23, 2012, 02:38:23 PM »
If you are wanting to auto refresh the cam image on home page or on its own page you can use this - works great - just put it where your image is now

<script language="javascript">
var refreshrate=60;
var image="http://yoursite.com/cam/filename.jpg";
var imgheight=240;
var imgwidth=320;
function refresh(){
document.images["pic"].src=image+"?"+new Date();
setTimeout('refresh()', refreshrate*1000);}
document.write('<IMG SRC="'+image+'" ALT="" NAME="pic" ID="pic" WIDTH="'+imgwidth+'" HEIGHT="'+imgheight+'" STYLE="border: 1px solid #000000;">');
if(document.images)window.onload=refresh;
</script>


Offline w2swr

  • Member
  • *
  • Posts: 12
Re: add my webcam image to rotate using ajax-gizmo
« Reply #3 on: July 23, 2012, 04:57:55 PM »
Quote
I see you're using the dashboard
Hi Jerry,
I was planning on leaving the cam image outside of and above the dashboard in the Index page. Will this script work in the index page?

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: add my webcam image to rotate using ajax-gizmo
« Reply #4 on: July 23, 2012, 05:54:02 PM »
Quote
I see you're using the dashboard
Hi Jerry,
I was planning on leaving the cam image outside of and above the dashboard in the Index page. Will this script work in the index page?
I haven't used it that way, but I think it would.  Let us know how it works out for you.
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline w2swr

  • Member
  • *
  • Posts: 12
Re: add my webcam image to rotate using ajax-gizmo
« Reply #5 on: July 23, 2012, 10:06:34 PM »
Jerry, I wasn't able to get it to work outside of the dashboard. I was successful with Albuquerque Weather's script. Thank you both very much for your help.

Mike

For any one interested, here is what I did. In the Index.php ,  I modified the cell for the weather underground IR satellite with this:

Code: [Select]
<td align="center">

      <?php
  
if( $IsSunUp == "1" ){
  
//webcam refresh sctipt
  
print("<script language=\"javascript\">
var refreshrate=60;
var image=\"http://yoursite.com/path/to/webcam.jpg\";
var imgheight=240;
var imgwidth=320;
function refresh(){
document.images[\"pic\"].src=image+\"?\"+new Date();
setTimeout('refresh()', refreshrate*1000);}
document.write('<IMG SRC=\"'+image+'\"  NAME=\"pic\" ID=\"pic\" WIDTH=\"'+imgwidth+'\" HEIGHT=\"'+imgheight+'\" STYLE=\"border: 1px solid #000000;\">');
if(document.images)window.onload=refresh;
</script>"
);
  
//END webcam refresh script
     
}else{

   print 
"<img src=\"http://icons.wunderground.com/data/640x480/"; echo $SITE['WUregion']; print "_ir_anim.gif\" alt=\"Regional Infrared Satellite\"  

      width=\"320\" height=\"240\" style=\"margin: 0px; padding: 0px; border: none\" />"
;     

      
}

  
?>


  </td>

In addition, you may need to add "IsSunUp" to the CU-defs.php
Code: [Select]
$IsSunUp = $WX['IsSunUp'];
All this will give you an auto refreshing webcam by day, and the original weather underground IR Satellite by night.
« Last Edit: July 23, 2012, 10:19:41 PM by w2swr »

Offline Albuquerque Weather

  • Senior Contributor
  • ****
  • Posts: 265
    • Albuquerque Amateur Weather
Re: add my webcam image to rotate using ajax-gizmo
« Reply #6 on: July 23, 2012, 11:19:50 PM »
Happy to help -

Ron
« Last Edit: July 24, 2012, 12:14:09 AM by Albuquerque Weather »

Offline rjkantor

  • Member
  • *
  • Posts: 6
    • Parkland Weather
Re: add my webcam image to rotate using ajax-gizmo
« Reply #7 on: July 02, 2014, 12:16:06 PM »
Hello -

I am trying to get my live cam to update automatically.  I have placed the image in the body of the page in the "main-copy".  I am using a php call to get the image, but my timer is not autofiring.  Any ideas?

Code: [Select]
<center>
<!--  <h3>Weather web cam  live from Parkland, FL</h3>
<img src="SecureImageDisplay.php?t="  alt='Current Parkland Image' width="640" height="480" id="myPull" />
<!--If you add IP Cameras here simply copy the entire line above and use a unique src such as
    SecureImageDisplay2.php leaving ?t= at the end before the double quotes-->

<script language="javascript">
var refreshrate=1;
var image="SecureImageDisplay.php?t=";
var imgheight=480;
var imgwidth=640;
function refresh(){
document.images["pic"].src=image+"?"+new Date();
setTimeout('refresh()', refreshrate*1000);}
document.write('<IMG SRC="'+image+'" ALT="" NAME="pic" ID="pic" WIDTH="'+imgwidth+'" HEIGHT="'+imgheight+'" STYLE="border: 1px solid #000000;">');
if(document.images)window.onload=refresh;
</script>
</center>

Offline AWL

  • Forecaster
  • *****
  • Posts: 727
    • Ardmore Weather Live
Re: add my webcam image to rotate using ajax-gizmo
« Reply #8 on: July 02, 2014, 12:56:09 PM »
This works for mine:


Code: [Select]
<a href="/time_lapse.php"><img src="/webcam/image.jpg" alt="Still Image" id="refresh" /></a>   
<script language="JavaScript" type="text/javascript">
        //<![CDATA[
       var t = 60 // Interval in Seconds
        image ="http://www.xxxxxxxx.com/webcam/image.jpg" //URLs of the Images
        function Start() {
tmp = new Date();
tmp = "?"+tmp.getTime()
document.images["refresh"].src = image+tmp
setTimeout("Start()", t*1000)
       }
     Start();
      //]]>
      </script>

-Doug
« Last Edit: March 19, 2015, 04:43:44 AM by DougW »

Offline rjkantor

  • Member
  • *
  • Posts: 6
    • Parkland Weather
Re: add my webcam image to rotate using ajax-gizmo
« Reply #9 on: July 02, 2014, 01:36:23 PM »
Thanks, that seems to work on my site as well.

Rob