Please read the posts in the Announcements section about the current status of Cumulus development now that I have retired

Please read this post before posting

Latest Cumulus release v1.9.4 (build 1099) - Nov 28 2014
Latest Cumulus MX release - v3.0.0 build 3043 Jan 20 2017. See this post for download

Auto-refresh Website Index Page Without Using Meta Refresh

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderators: daj, TNETWeather

loades
Posts: 5
Joined: Tue Feb 05, 2013 10:50 am
Weather Station: WH1080
Operating System: XP
Location: Southampton

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

Postby loades » Sat Feb 16, 2013 9:30 am

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

User avatar
vaggos
Posts: 334
Joined: Sat Feb 06, 2010 7:00 pm
Weather Station: PROWEATHER STATION 1080
Operating System: XP SP3, win7, Win10
Location: Acharnes Athens Greece
Contact:

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

Postby vaggos » Sat Feb 16, 2013 9:39 am

Did you add jquery and realtimereader?
Image
Acharnes Athens Greece Meteo station
http://www.meteoacharnes.gr
https://weather.meteoacharnes.gr/
Thanks Sandaysoft

loades
Posts: 5
Joined: Tue Feb 05, 2013 10:50 am
Weather Station: WH1080
Operating System: XP
Location: Southampton

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

Postby loades » Sat Feb 16, 2013 9:53 am

vaggos wrote:Did you add jquery and realtimereader?

Yes, they are both there.

Malcolm

User avatar
vaggos
Posts: 334
Joined: Sat Feb 06, 2010 7:00 pm
Weather Station: PROWEATHER STATION 1080
Operating System: XP SP3, win7, Win10
Location: Acharnes Athens Greece
Contact:

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

Postby vaggos » Sat Feb 16, 2013 9:58 am

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
Image
Acharnes Athens Greece Meteo station
http://www.meteoacharnes.gr
https://weather.meteoacharnes.gr/
Thanks Sandaysoft

loades
Posts: 5
Joined: Tue Feb 05, 2013 10:50 am
Weather Station: WH1080
Operating System: XP
Location: Southampton

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

Postby loades » Sat Feb 16, 2013 10:29 am

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

Synewave
Posts: 642
Joined: Mon Jan 25, 2010 1:55 pm
Weather Station: Watson W-8681
Operating System: Raspian
Location: Brighton, UK
Contact:

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

Postby Synewave » Sat Feb 16, 2013 11:29 am

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.

loades
Posts: 5
Joined: Tue Feb 05, 2013 10:50 am
Weather Station: WH1080
Operating System: XP
Location: Southampton

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

Postby loades » Sat Feb 16, 2013 3:57 pm

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

ttexsun
Posts: 85
Joined: Sun Jan 29, 2012 2:51 pm
Weather Station: Davis Vantage Pro 2
Operating System: Windows8
Location: Georgia USA
Contact:

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

Postby ttexsun » Tue Feb 19, 2013 10:29 pm

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

tul9033
Posts: 45
Joined: Sun Jun 09, 2013 6:45 am
Weather Station: Davis Vantage Vue
Operating System: Windows 7
Location: OK

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

Postby tul9033 » Sun Jun 09, 2013 8:46 pm

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!

User avatar
steve
Cumulus Author
Posts: 26517
Joined: Mon Jun 02, 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

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

Postby steve » Mon Jun 10, 2013 7:12 am

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.
Steve
-----
Hosting available for Cumulus web sites. See http://sandaysoft.com/forum/viewtopic.php?f=2&t=11876

Please read the posts in the Announcements section about the current status of Cumulus development since I have retired from my day job

Palmyweather
Posts: 38
Joined: Sat Nov 28, 2009 9:57 am
Weather Station: W1081
Operating System: Windows 7
Location: New Zealand
Contact:

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

Postby Palmyweather » Fri Feb 20, 2015 7:09 am

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
Check my Palmerston North Weather Station out at http://palmyweather.co.nz .

Image

dazza1223
Posts: 276
Joined: Sun Jan 25, 2015 8:41 pm
Weather Station: davis vantage vue
Operating System: raspberry pi 3
Location: worthing
Contact:

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

Postby dazza1223 » Thu Feb 15, 2018 4:02 pm

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?

dazza1223
Posts: 276
Joined: Sun Jan 25, 2015 8:41 pm
Weather Station: davis vantage vue
Operating System: raspberry pi 3
Location: worthing
Contact:

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

Postby dazza1223 » Tue Feb 27, 2018 10:18 pm

any one want wind dir icons script

Nevizio
Posts: 25
Joined: Wed Feb 10, 2016 8:43 pm
Weather Station: Oregon Scientific wmr-200
Operating System: Windows 10 - Android
Location: Cerratina frazione di Pianella (PE) Abruzzo-Italy

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

Postby Nevizio » Sat Jun 09, 2018 9:01 am

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 ;)

dazza1223
Posts: 276
Joined: Sun Jan 25, 2015 8:41 pm
Weather Station: davis vantage vue
Operating System: raspberry pi 3
Location: worthing
Contact:

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

Postby dazza1223 » Sat Jun 09, 2018 8:50 pm

i use <span class="ajax" id="LastRainTipISO"></span>


but what script you use to up date your tags?


link to your website be good!


Return to “Web site - General”

Who is online

Users browsing this forum: No registered users and 2 guests