Author Topic: Custom NWS-Alerts.php  (Read 955 times)

0 Members and 1 Guest are viewing this topic.

Offline tmabell

  • Forecaster
  • *****
  • Posts: 444
    • Mishawaka Weather
Custom NWS-Alerts.php
« on: May 10, 2025, 03:09:58 PM »
A friend helped me customize the NWS-Alerts script so that the alert box background colors would match the colors on the NWS Alerts map
 (https://www.weather.gov.  I've tested this operationally for six months and found no issues.  It just works, and it's free to use. While I offer no support, I will respond to questions. 

Offline jaltman

  • Senior Member
  • **
  • Posts: 85
    • Stanley Rapids Weather
Re: Custom NWS-Alerts.php
« Reply #1 on: May 21, 2025, 11:44:50 AM »
Thank you very much for this.  However, what i am seeing from the revised file is that the big icon on the left of the main screen always says ALERT rather than WARNING or STATEMENT or whatever.  NONE is fine.  I have tried to compare your file to the original, but fail to see where its going astray.  Any thoughts appreciated.

Jim
« Last Edit: May 21, 2025, 11:49:47 AM by jaltman »

Offline tmabell

  • Forecaster
  • *****
  • Posts: 444
    • Mishawaka Weather
Re: Custom NWS-Alerts.php
« Reply #2 on: May 22, 2025, 08:31:58 AM »
A few years ago I got a tip from someone who has helped me a lot over the years.  He uses "Compare It!" to do a real, side-by-side comparison between two files.  If you use that you'll see a difference referencing "Big Icons".  I don't use them so I can't comment on whether that difference is causing your issue or not.  You could always ask Ken but remember, this isn't his problem.   

Offline jaltman

  • Senior Member
  • **
  • Posts: 85
    • Stanley Rapids Weather
Re: Custom NWS-Alerts.php
« Reply #3 on: May 22, 2025, 08:40:44 AM »
I use a program called winmerge.  It puts them up side by side and allows you copy left to right or vice versa. It shows no differences between the big icons section.  There another section i have my eye on, but now i have to wait for a warning or alert of some type to try a change.

Thanks.

Jim

Offline tmabell

  • Forecaster
  • *****
  • Posts: 444
    • Mishawaka Weather
Re: Custom NWS-Alerts.php
« Reply #4 on: May 22, 2025, 08:47:33 AM »
Any chance you are missing this?

Code: [Select]
// FUNCTION - convert big icons
function create_bi($a,$b,$c,$d,$e,$g,$h,$i) {
  if($h >= 0 and $h <= 49) { $bi = "A-warn.png"; }
  if($h >= 50 and $h <= 89) { $bi = "A-advisory.png"; }
  if($h >= 90 and $h <= 119) { $bi = "A-watch.png"; }
  if($h >= 120 and $h <= 139) { $bi = "A-statement.png"; }
  if($h == 140) { $bi = "A-air.png"; }
  if($h >= 141 and $h <= 149) { $bi = "A-alert.png"; }
  if($h == 150) { $bi = "A-none.png"; }
  if($i < 2) {$i = '';}
  if($i >= 2) {$i = $i - 1;}
  ($i == 1) ? $alrts = 'alert' : $alrts = 'alerts';
  if($i >= 1) {$i = '&nbsp; +'.$i.' additional '.$alrts;}
  $bico =  ' <a href="'.$b.'?a='.$c.'#WA'.$d.'" title=" &nbsp;Details for '.$a
           .'&nbsp;'.$e.$i.'" style="width:99%; text-decoration:none; padding-top:3px">'.$a.'<br /><img src="'.$g
           .'/'.$bi.'" alt=" &nbsp;Details for '.$a.'&nbsp;'.$e.$i
           .'" width="74" height="18" style="border:none; padding-bottom:3px" /><br /></a>
';
  return $bico;
}// end convert big icons function

Offline jaltman

  • Senior Member
  • **
  • Posts: 85
    • Stanley Rapids Weather
Re: Custom NWS-Alerts.php
« Reply #5 on: May 22, 2025, 08:56:18 AM »
Your original download has a different big icons section.

Jim

Code: [Select]
// FUNCTION - convert big icons
function create_bi($a,$b,$c,$d,$e,$g,$h,$i) {
  global $alert_types;                        // make colors global
  $ix = $h-1;
  $aname = isset($alert_types[$ix]['N'])?$alert_types[$ix]['N']:'unknown';
  $bi = "A-none.png";
  if(strpos($aname,'Warning') !== false) { $bi = "A-warn.png"; }
  if(strpos($aname,'Advisory') !== false) { $bi = "A-advisory.png"; }
  if(strpos($aname,'Watch') !== false) { $bi = "A-watch.png"; }
  if(strpos($aname,'Statement') !== false) { $bi = "A-statement.png"; }
  if(strpos($aname,'Air ') !== false) { $bi = "A-air.png"; }
  if(strpos($aname,'Alert') !== false) { $bi = "A-alert.png"; }
  if($h == 150) { $bi = "A-none.png"; }
  if($i < 2) {$i = '';}
  if($i >= 2) {$i = $i - 1;}
  ($i == 1) ? $alrts = 'alert' : $alrts = 'alerts';
  if($i >= 1) {$i = '&nbsp; +'.$i.' additional '.$alrts;}
  $bico =  ' <a href="'.$b.'?a='.$c.'#WA'.$d.'" title=" &nbsp;Details for '.$a
           .'&nbsp;'.$e.$i.'" style="width:99%; text-decoration:none; padding-top:3px">'.$a.'<br><img src="'.$g
           .'/'.$bi.'" alt=" &nbsp;Details for '.$a.'&nbsp;'.$e.$i
           .'" width="74" height="18" style="border:none; padding-bottom:3px"><br></a>
';
  return $bico;
}
// end convert big icons function


Offline tmabell

  • Forecaster
  • *****
  • Posts: 444
    • Mishawaka Weather
Re: Custom NWS-Alerts.php
« Reply #6 on: May 22, 2025, 08:58:54 AM »
Hope you can isolate your problem and fix it  :-)

Offline jaltman

  • Senior Member
  • **
  • Posts: 85
    • Stanley Rapids Weather
Re: Custom NWS-Alerts.php
« Reply #7 on: May 22, 2025, 09:18:05 AM »
Thanks, i'll get it, but not before i have some form of alert.

Jim
« Last Edit: May 22, 2025, 09:20:30 AM by jaltman »

Offline jaltman

  • Senior Member
  • **
  • Posts: 85
    • Stanley Rapids Weather
Re: Custom NWS-Alerts.php
« Reply #8 on: May 26, 2025, 11:52:56 AM »
tmabell, i wanted to say thanks for sharing your file. I have fixed the big icon problem i had and i now get NOAA offical colors, at least i did last night on the severe thunderstorm watch and warnings we had.  Correct big icons on the sidebar too!
I appreciate your sharing.
Jim

 

anything