Page 5 of 8

Re: Auto-refresh Website Index Page Without Using Meta Refre

Posted: Sat 16 Feb 2013 9:30 am
by loades
steve wrote:Unregistered and 'new' users can't download files from the forum. Now that your first post has been approved, you should be able to download the attachments.
Yes, that was it!

I really don't understand javascript, php, html etc., I just keep cutting 'n pasting and changing things until I see what I want! My site is www.loades.net/weather and the only thing which I can't seem to get right is the 'next update in x seconds'. It counts down from 15 seconds, not the 10 second realtime interval set in Cumulus and which I'd like to see. Which part of which file needs changing to correct this?

Thanks in advance.

Malcolm

Re: Auto-refresh Website Index Page Without Using Meta Refre

Posted: Sat 16 Feb 2013 9:39 am
by vaggos
Did you add jquery and realtimereader?

Re: Auto-refresh Website Index Page Without Using Meta Refre

Posted: Sat 16 Feb 2013 9:53 am
by loades
vaggos wrote:Did you add jquery and realtimereader?
Yes, they are both there.

Malcolm

Re: Auto-refresh Website Index Page Without Using Meta Refre

Posted: Sat 16 Feb 2013 9:58 am
by vaggos
And the
<script src="jquery.js" type="text/javascript"></script>
<script src="realtimereader.js" type="text/javascript"></script>
above head?
I do it in my site and works fine

Re: Auto-refresh Website Index Page Without Using Meta Refre

Posted: Sat 16 Feb 2013 10:29 am
by loades
vaggos wrote:And the
<script src="jquery.js" type="text/javascript"></script>
<script src="realtimereader.js" type="text/javascript"></script>
above head?
I do it in my site and works fine
Thanks for trying, but this already appears between <head> and </head> in indexT.htm

Malcolm

Re: Auto-refresh Website Index Page Without Using Meta Refre

Posted: Sat 16 Feb 2013 11:29 am
by Synewave
To change the countdown interval, edit realtimereader.js .

Change the second line 'var update_seconds=15;' value to whatever you want.

Then upload the modified file to the webserver.

Note that I chose 15 seconds as that works well with the 48sec interval that Cumulus uploads the realtime.txt files.

Re: Auto-refresh Website Index Page Without Using Meta Refre

Posted: Sat 16 Feb 2013 3:57 pm
by loades
Synewave wrote:To change the countdown interval, edit realtimereader.js .

Change the second line 'var update_seconds=15;' value to whatever you want.

Then upload the modified file to the webserver.

Note that I chose 15 seconds as that works well with the 48sec interval that Cumulus uploads the realtime.txt files.
Thank you!

Malcolm

Re: Auto-refresh Website Index Page Without Using Meta Refre

Posted: Tue 19 Feb 2013 10:29 pm
by ttexsun
Thanks Paul, I am sorry it has taken me so long to get back to you. I downloaded the file and placed it in the indexT.html file and it works fine about the timer, but the "The Conditions At Local Time" does not change. Any more help would be greatly appreciated. ttexsun

Re: Auto-refresh Website Index Page Without Using Meta Refre

Posted: Sun 09 Jun 2013 8:46 pm
by tul9033
I've updated the code with the new webtags. One thing I'd like to change is the date display. "It is now showing Conditions at local time 15:40:36 on 09/06/13". I'd like to change the 09/16/13 to June 6th 2013. The "date" below appears to be responsible for the date displayed. I've tried a few of the tags in the wiki FAQ without success.
<caption>Conditions at local time <span id="time"></span> on <span id="date"></span></caption>

Is there a way to just force a refresh automatically when you go to one of the other pages? If I go to any of the other pages; gauges, today yesterday, etc I must manually refresh the page to get the updated data.
Thanks!

Re: Auto-refresh Website Index Page Without Using Meta Refre

Posted: Mon 10 Jun 2013 7:12 am
by steve
tul9033 wrote:I've updated the code with the new webtags. One thing I'd like to change is the date display. "It is now showing Conditions at local time 15:40:36 on 09/06/13". I'd like to change the 09/16/13 to June 6th 2013. The "date" below appears to be responsible for the date displayed. I've tried a few of the tags in the wiki FAQ without success.
Most of the Cumulus date/time web tags have an optional 'format' parameter; see the web tag sections in the help and the wiki. But I don't think this setup uses web tags? If not you'll need to amend the code somehow to generate the date format you want.

Re: Auto-refresh Website Index Page Without Using Meta Refre

Posted: Fri 20 Feb 2015 7:09 am
by Palmyweather
Hi all

It has been a while since this topic has been used but I hope someone can help out. I have been using a modified version of this script, the one which Mark (mcrossley) mentioned on September 03, 2011, which until now has been working great. But for some reason it has stopped working with out any known modification.

I liked the one he produced because it indicated by colour which values had been modified.

As this code has not been working for a while, I have gone back to the original posted in this forum to temporary measures.

If anyone has any clues as to why this code no longer works, they would be most appreciated or alternatively a different method of updating data on a page without needing to refresh the page.

Code: Select all

var tick_counter=0;
var j = 8;
var first_run=true;
setInterval('getlivedata()', 1000);

function getlivedata() {

if (j >= 0) {

if (tick_counter <= 0) {

// read realtime.txt file and parse it using a space
j--;

var rawdata = $.ajax({
  url: "http://palmyweather.co.nz/realtime.txt",
  async: false
}).responseText.split(' ');

// Get current values on the page
var temp_out = $("#temp_out").text();
var temp_trend = $("#temp_trend").text();
var hum = $("#hum").text();
var rain_rate = $("#rain_rate").text();
var rain_today = $("#rain_today").text();
var rain_hour = $("#rain_hour").text();
var wind_latest = $("#wind_latest").text();
var wind_avg = $("#wind_avg").text();
var bearing = $("#bearing").text();
var pressure = $("#pressure").text();
var press_trend = $("#press_trend").text();
var wind_gust = $("#wind_gust").text();


// Set all Spans to their values
$("#temp_out").html(rawdata[2]);
$("#temp_trend").html(rawdata[25]);
$("#hum").html(rawdata[3]);
$("#rain_rate").html(rawdata[8]);
$("#rain_today").html(rawdata[9]);
$("#rain_hour").html(rawdata[47]);
$("#wind_avg").html(rawdata[5]);
$("#wind_latest").html(rawdata[5]);
$("#bearing").html(rawdata[11]);
$("#pressure").html(rawdata[10]);
$("#press_trend").html(rawdata[18]);
$("#wind_gust").html(rawdata[6]);
$("#last_contact").html(rawdata[0] +" "+ rawdata[1]);

// is it currently raining, show the icon

if ($("#rain_rate").text() != "0.0") { $("#israining").show();} else { $("#israining").hide();}

// Calculate the Beaufort desc
var beau = rawdata[12];
if (beau=="0"){var bdesc="(Calm)";} else
if (beau=="1"){var bdesc="(Light Air)";} else
if (beau=="2"){var bdesc="(Fresh breeze)";} else
if (beau=="3"){var bdesc="(Moderate breeze)";} else
if (beau=="4"){var bdesc="(Strong breeze)";} else
if (beau=="5"){var bdesc="(Near gale)";} else
if (beau=="6"){var bdesc="(Gale)";} else
if (beau=="7"){var bdesc="(Strong Gale)";} else
if (beau=="8"){var bdesc="(Storm)";} else
if (beau=="9"){var bdesc="(Violent Storm)";} else
if (beau=="10"){var bdesc="(Hurricane)";} else
{ var bdesc="";}
$("#beaufort").html(bdesc);

// highlight if there was a change and show last values
if (first_run==false) {
if (temp_out != $("#temp_out").text()) {$("#temp_out").css("background","yellow"); $("#last_temp_out").text(temp_out);} else {$("#temp_out").css("background","");}
if (temp_trend != $("#temp_trend").text()) {$("#temp_trend").css("background","yellow");$("#last_temp_trend").text(temp_trend);} else {$("#temp_trend").css("background","");}
if (hum != $("#hum").text()) {$("#hum").css("background","yellow"); $("#last_hum").text(hum);} else {$("#hum").css("background","");}
if (rain_rate != $("#rain_rate").text()) {$("#rain_rate").css("background","yellow"); $("#last_rain_rate").text(rain_rate);} else {$("#rain_rate").css("background","");}
if (rain_today != $("#rain_today").text()) {$("#rain_today").css("background","yellow"); $("#last_rain_today").text(rain_today);} else {$("#rain_today").css("background","");}
if (rain_hour != $("#rain_hour").text()) {$("#rain_hour").css("background","yellow"); $("#last_rain_hour").text(rain_hour);} else {$("#rain_hour").css("background","");}
if (wind_avg != $("#wind_avg").text()) {$("#wind_avg").css("background","yellow"); $("#last_wind_avg").text(wind_avg);} else {$("#wind_avg").css("background","");}
if (wind_latest != $("#wind_latest").text()) {$("#wind_latest").css("background","yellow"); $("#last_wind_latest").text(wind_latest); } else {$("#wind_latest").css("background","");}
if (bearing != $("#bearing").text()) {$("#bearing").css("background","yellow"); $("#last_bearing").text(bearing);} else {$("#bearing").css("background","");}
if (pressure != $("#pressure").text()) {$("#pressure").css("background","yellow"); $("#last_pressure").text(pressure);} else {$("#pressure").css("background","");}
if (press_trend != $("#press_trend").text()) {$("#press_trend").css("background","yellow"); $("#last_press_trend").text(press_trend);} else {$("#press_trend").css("background","");}
if (wind_gust != $("#wind_gust").text()) {$("#wind_gust").css("background","yellow"); $("#last_wind_gust").text(wind_gust); } else {$("#wind_gust").css("background","");}

}
else
{
first_run=false;
}
tick_counter=30;
}
else
{
tick_counter--;
$("#refresh_in").html(tick_counter);
}

}
else
{
tick_counter--;
$("#refresh_in").html('<br/> TIMER PAUSED. PLEASE RELOAD PAGE TO GET THE LATEST DATA.');$("#refresh_in").css("background","orange");
}
}
When this code runs, it will not jump back in time for at least one upload and not retrieve any fresh data; the last retrieval of data information will stay static. Upon load, it will also change other environmental factors (such as temperature) to what ever the readings were at the previous time when it jumps back. EG: Current time might be 8pm. Initial load of page shows last contact with station was at 7:59pm before the script takes hold and it will change the time and other data to 7:58pm.

Thanks for your help,
Matt

Re: Auto-refresh Website Index Page Without Using Meta Refresh

Posted: Thu 15 Feb 2018 4:02 pm
by dazza1223
hey mate i saw ur code about adding this

var temptrendicon = rawdata[25];
if (temptrendicon==0){var imagen = "steady1.gif";}
if (temptrendicon>0){var imagen = "up1.gif";}
if (temptrendicon<0){var imagen = "down1.gif";}
$("#temptrendicon").html('<img src="http://www.brisbaneliveweather.com/'+imagen+'"align =absmiddle>');

ive added it but it not working hase this been tested?

Re: Auto-refresh Website Index Page Without Using Meta Refresh

Posted: Tue 27 Feb 2018 10:18 pm
by dazza1223
any one want wind dir icons script

Re: Auto-refresh Website Index Page Without Using Meta Refresh

Posted: Sat 09 Jun 2018 9:01 am
by Nevizio
javascript is great but not all the tags work well for example the one related to the last rain even modifying <#LastRainTipISO> in <span id = "LastRainTipISO"> </ span> does not automatically update forwarding nothing appears in the box. Can someone explain to me why?
Thank you ;)

Re: Auto-refresh Website Index Page Without Using Meta Refresh

Posted: Sat 09 Jun 2018 8:50 pm
by dazza1223
i use <span class="ajax" id="LastRainTipISO"></span>


but what script you use to up date your tags?


link to your website be good!