Author Topic: Script for New WPC 3-7 Day Forecasts  (Read 473 times)

0 Members and 1 Guest are viewing this topic.

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Script for New WPC 3-7 Day Forecasts
« on: July 18, 2018, 02:05:26 PM »
Tom Abell, who's always searching for interesting pages, found this page on the NWS's WPC.

I managed to scrape it and adapt it for the Saratoga template and create a Stand Alone version as well.

It wil NEVER validate, in my hands anyway, because even the NWS WPC page throws tons of errors.

It took considerable creativity to get everything sized and lined up, so there's no guarantee that the '$divWidth' parameter will work for different template widths.  Therefore if you try to use it there may be some size adjustments that you will need to do.

It's available on my scripts page as 'US 3 to 7 Day Forecasts'.
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: Script for New WPC 3-7 Day Forecasts
« Reply #1 on: July 19, 2018, 12:30:33 AM »
One problem with my script is that I used/referenced Ken True's renamed Leaflet CSS and JS files from his 'wxquake' script, like this:
Code: [Select]
<link rel="stylesheet" href="quake-json.css"/>
<script type="text/javascript" src="quake-json.js"></script>
</head>
The map obviously won't display without these resources.  I've attached them here in a zip in case you need them.

An alternative would be to use a hosted version of Leaflet:
Code: [Select]
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.3/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@1.3.3/dist/leaflet.js" type="text/javascript"></script>
</head>
but the zoom in and out boxes aren't very attractive this way.

I have also added the 'quake-json.zip' to the 'wxwpcmedr.zip' on my scripts page.
« Last Edit: July 19, 2018, 01:01:07 AM by gwwilk »
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: Script for New WPC 3-7 Day Forecasts
« Reply #2 on: July 19, 2018, 03:34:28 PM »
John Gillett correctly pointed out that the code for a Saratoga-template Widescreen view wasn't working correctly.  This was an oversight in the initial code, and it has been corrected in the latest version now available on my site.

I've added code to detect the presence of an altered footer, 'footer-invalid.php' that suppresses the CSS and HTML validation links.  If present it is used, if not your standard Saratoga-template 'footer.php' will be used.  By removing from 'footer.php'
Code: [Select]
          <a href="https://validator.w3.org/check?uri=referer"><?php langtrans('Valid'); ?>
          <?php  print (isset($useHTML5) and $useHTML5)?'HTML5':'XHTML 1.0'?></a> |
          <a href="https://jigsaw.w3.org/css-validator/check/referer"><?php langtrans('Valid'); ?> CSS</a>
I added the 'footer-invalid.php' to my website several years ago because of the 'invalid' code present in the NWS Main Site which persists in this Saratoga-template adaptation as well as this auto-updating version.
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline jgillett

  • Forecaster
  • *****
  • Posts: 1187
  • Boltek, Win7 Pro, ToA
    • TiggrWeather Phoenix
Re: Script for New WPC 3-7 Day Forecasts
« Reply #3 on: July 19, 2018, 06:07:41 PM »
Perfect. Thank you, Jerry.
John
W7JKG