Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Cumulus MX V4 beta test release 4.0.0 (build 4019) - 03 April 2024

Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

JavaScript 'Viewer' of Cumulus generated NOAA style reports

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

Moderator: daj

User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: JavaScript 'Viewer' of Cumulus generated NOAA style repo

Post by beteljuice »

It's more devious than that !

If I look at my examples with IE8 the 'rules' are obeyed, but apparently (having done a google and reading M$ support) it's all down to the DOCTYPE declaration as to wether IE8 obeys the <pre> white-space and line return rules.
Image
......................Imagine, what you will KNOW tomorrow !
hystrix
Posts: 8
Joined: Thu 29 Dec 2011 4:51 pm
Weather Station: Fine offset
Operating System: Windows 7
Location: Somerset, UK

Re: JavaScript 'Viewer' of Cumulus generated NOAA style repo

Post by hystrix »

radelrama wrote:Hi beetlejuice and thx a lot for that code!!

I'm using an non-php Webserver and included Cumulus with Steelgauges in my web page since very little time, I have only data for this month...
I was looking for a simple solution to display reports, downloaded thankfully and adapted your files according to your instructions, generated/copied reports month/year.
The reports page loads, counts files correctly, but stays on

"Looking for files reports/NOAAMO0312.txt

Report for ???? ???"


Other users web pages (with the exactly same code) DO display correctly, so shame on me: What am I doing wrong?
Didn't change any code... Tried renaming files for Jan/Feb reports to exist, doesn't change anything.

Well, tried the whole day and humbly asking for help...


Thx 4 help,
Radelrama
I have exactly the same problem. I have created and uploaded NOAA files for 2012, but get exactly the same issue as Radelrama describes above. Can anyone help? The URL to my NOAA page is http://deadwing.webplus.net/DW9194/NOAA-reports.html

Many thanks.
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: JavaScript 'Viewer' of Cumulus generated NOAA style repo

Post by beteljuice »

For some reason your server returns a code 302 (found / temp redirect) which then for a browser (but not the code) goes to a 404 (file not found).

The 404s are the result of the code looking for all possible files from Jan start year to Dec this year.

Time to get your hands dirty !

Go into the .js file with notepad or similar, go down to

function betelLoader (url, nav, thisnum)

Look for this line:

Code: Select all

	 if(x.readyState == 4 && x.status == 400) { // file does not exist
and change it to:

Code: Select all

	 if(x.readyState == 4 && x.status >= 302) { // file does not exist
Image
......................Imagine, what you will KNOW tomorrow !
hystrix
Posts: 8
Joined: Thu 29 Dec 2011 4:51 pm
Weather Station: Fine offset
Operating System: Windows 7
Location: Somerset, UK

Re: JavaScript 'Viewer' of Cumulus generated NOAA style repo

Post by hystrix »

beteljuice wrote:For some reason your server returns a code 302 (found / temp redirect) which then for a browser (but not the code) goes to a 404 (file not found).

The 404s are the result of the code looking for all possible files from Jan start year to Dec this year.

Time to get your hands dirty !

Go into the .js file with notepad or similar, go down to

function betelLoader (url, nav, thisnum)

Look for this line:

Code: Select all

	 if(x.readyState == 4 && x.status == 400) { // file does not exist
and change it to:

Code: Select all

	 if(x.readyState == 4 && x.status >= 302) { // file does not exist
Many thanks for your quick response. I just changed the noaarep.js file per your instructions, and unfortunately it still does not work :( . Any ideas?

UPDATE: By the way - I put in dummy files for August through December and it works OK, so this can be a workaround if I can't get the script working. I have removed them for now, as it would be great if I could get it functioning correctly.
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: JavaScript 'Viewer' of Cumulus generated NOAA style repo

Post by beteljuice »

I forgot about 304 being a valid entry, but thats not the problem !
The 302 redirects to a 404, but due to the way your server is set-up it is being considered 'cross-domain" so the fetch script folds :bash:

Try this fix instead:

Code: Select all

if((x.readyState == 4 && x.status >= 400) || x.status == 302) { // file does not exist
If that doen't work it needs someone with a better understanding than me of ajax calls I'm afraid :oops:
Image
......................Imagine, what you will KNOW tomorrow !
User avatar
mcrossley
Posts: 12756
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: JavaScript 'Viewer' of Cumulus generated NOAA style repo

Post by mcrossley »

The problem is the the XMLHttpRequest returns a status = 0 to the redirect (which is the 302). So I think you will have to test for that instead?

Code: Select all

if(x.readyState === 4 && (x.status === 400 || x.status === 0)) { // file does not exist
Edit: added missing brace!
Last edited by mcrossley on Mon 02 Jul 2012 6:07 pm, edited 1 time in total.
hystrix
Posts: 8
Joined: Thu 29 Dec 2011 4:51 pm
Weather Station: Fine offset
Operating System: Windows 7
Location: Somerset, UK

Re: JavaScript 'Viewer' of Cumulus generated NOAA style repo

Post by hystrix »

mcrossley wrote:The problem is the the XMLHttpRequest returns a status = 0 to the redirect (which is the 302). So I think you will have to test for that instead?

Code: Select all

if(x.readyState === 4 && (x.status === 400 || x.status === 0) { // file does not exist
Many thanks to you and beteljuice - I have finally got it working!....once I had added the missing bracket ;)

Code: Select all

if(x.readyState === 4 && (x.status === 400 || x.status === 0)) { // file does not exist
Thanks again for your quick responses.
User avatar
mcrossley
Posts: 12756
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: JavaScript 'Viewer' of Cumulus generated NOAA style repo

Post by mcrossley »

hystrix wrote:..once I had added the missing bracket ;)
Doh! :roll:
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: JavaScript 'Viewer' of Cumulus generated NOAA style repo

Post by beteljuice »

Thanks Mark, although I don't understand it :P

Edit: why === (logic test), and where's >= 400 gone ?
Image
......................Imagine, what you will KNOW tomorrow !
User avatar
mcrossley
Posts: 12756
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: JavaScript 'Viewer' of Cumulus generated NOAA style repo

Post by mcrossley »

beteljuice wrote:Thanks Mark, although I don't understand it :P

Edit: why === (logic test)
Just good practice, you should always use the exactly equals === unless there is a good reason to use the 'equivalent' == comparison to avoid getting caught by auto-casting issues.
beteljuice wrote:and where's >= 400 gone ?
I just took your original code

Code: Select all

if(x.readyState == 4 && x.status == 400) { // file does not exist
and added in the check for a state=4 status=0. I haven't actually looked at your code, just what has been posted on this thread! :o
I guess that really should be >== 400, or even just replace the whole lot with

Code: Select all

if(x.readyState === 4 && x.status !== 200)
I'm not sure if this is generally applicable or just to this hosting provider who is using a redirect for 404 errors - I've not seen that before.
glenn.vadney
Posts: 6
Joined: Sat 22 Dec 2012 4:54 am
Weather Station: Ambient Weather WS-2080
Operating System: Windows 7 Home Premium
Location: Fallon, Nevada, USA

Re: JavaScript 'Viewer' of Cumulus generated NOAA style repo

Post by glenn.vadney »

Can anyone help me and tell me what I'm doing wrong........ why the NOAA report won't display in columns ?

http://webpages.charter.net/cgvad1/noaa.htm

Thanks,

Glenn
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: JavaScript 'Viewer' of Cumulus generated NOAA style repo

Post by beteljuice »

The only problem that I can see at this moment in time is that you 'neatened up' the code - which stuffs the first line in the <pre> section of the report ;)

Should be:

Code: Select all

					<pre>
<!-- Report displays here --><span id="theReport"></span>
					</pre>
This bit <!-- Report displays here --><span id="theReport"></span> MUST be at the start of the line.
Image
......................Imagine, what you will KNOW tomorrow !
glenn.vadney
Posts: 6
Joined: Sat 22 Dec 2012 4:54 am
Weather Station: Ambient Weather WS-2080
Operating System: Windows 7 Home Premium
Location: Fallon, Nevada, USA

Re: JavaScript 'Viewer' of Cumulus generated NOAA style repo

Post by glenn.vadney »

Thanks Beteljuice............ tried that and it moved the text all the way to the left but still no columns.............

http://webpages.charter.net/cgvad1/noaa.htm


Glenn
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: JavaScript 'Viewer' of Cumulus generated NOAA style repo

Post by beteljuice »

Not sure what you mean ?

There are no columns in the report itself - just character spacing.
NOAA Style Reports:
The word Style is IMPORTANT - these are NOT NOAA reports !
It also means that the layout is 'fixed' and is meant to look like the old teleprinter output.
This is the way the software(s) have created them and is nothing to do with the script !
As far as I can see the report and it's nav menu look like everyones elses, are you seeing something different ?
Image
......................Imagine, what you will KNOW tomorrow !
gemini06720
Posts: 1700
Joined: Mon 10 Aug 2009 10:16 pm
Weather Station: No weather station
Operating System: No operating system
Location: World...

Re: JavaScript 'Viewer' of Cumulus generated NOAA style repo

Post by gemini06720 »

Glenn, the only problem I can see with your page is that the display of the report is too large (width wise) for the space available within the white portion of the page - you might have to adjust some of the CSS properties (unfortunately, I cannot guide you on that 'adventure' as I do not use the 'Sunny Weather' template set). May I suggest that you contact Jacques Desroches (the designer of those templates) for some assistance.
Post Reply