Jump to content

Texan78

Members
  • Posts

    272
  • Joined

  • Last visited

Everything posted by Texan78

  1. I have tried your suggestion but then it doesn't show any color background. I have tried this, which works... switch($event->nodeValue) { Problem I am having now is, it should only be showing one alert but it shows multiple alerts if they are in the array. They are listed in the array by the order in which I wanted them to display if they exist in the RSS feed I am parsing. So for example, it should only be displaying Flood Warning and not Flash Flood Watch. Here is the relevant code.... $alertValues = array('Tornado Warning', 'Severe Thunderstorm Warning', 'Tornado Watch', 'Severe Thunderstorm Watch', 'Flash Flood Warning', 'Flood Warning', 'Flash Flood Watch', 'Flood Watch', 'Flood Advisory', 'Winter Storm Warning', 'Winter Storm Watch', 'Winter Weather Advisory', 'Special Weather Statement'); $events = array_intersect($alertValues, $events); // Set the alert colors for the banner background switch($event->nodeValue) { case 'Tornado Warning': $alertColor = 'rgba(255, 0, 0, 0.4)'; break; case 'Severe Thunderstorm Warning': $alertColor = 'rgba(255, 165, 0, 0.4)'; break; case 'Tornado Watch': $alertColor = 'rgba(255, 255, 0, 0.4)'; break; case 'Severe Thunderstorm Watch': $alertColor = 'rgba(219, 112, 147, 0.4)'; break; case 'Flash Flood Warning': $alertColor = 'rgba(139, 0, 0, 0.4)'; break; case 'Flash Flood Watch': $alertColor = 'rgba(46, 139, 87, 0.4)'; break; case 'Flood Warning': $alertColor = 'rgba(0, 255, 0, 0.4)'; break; case 'Flood Watch': $alertColor = 'rgba(46, 139, 87, 0.4)'; break; case 'Flood Advisory': $alertColor = 'rgba(0, 255, 127, 0.4)'; break; case 'Winter Storm Warning': $alertColor = 'rgba(255, 105, 180, 0.4)'; break; case 'Winter Storm Watch': $alertColor = 'rgba(70, 130, 180, 0.4)'; break; case 'Winter Weather Advisory': $alertColor = 'rgba(123, 104, 238, 0.4)'; break; case 'Special Weather Statement': $alertColor = 'rgba(255, 228, 181, 0.4)'; } // Lets assign some styles for the banner $bannerStyle = '"color:' . $alertText . '; width:100%; border-top-style:solid; border-bottom-style:solid; border-color:#FFF; border-width:1px; font-size:12px; text-shadow: 0 1px 1px #111; font-weight:700; font-family: Arial,Helvetica,sans-serif; text-align: center; background-color:' . $alertColor . '; margin-bottom:5px; padding: .2em 0em .2em 0em"'; // Lets assembly the banners to display foreach ($events as $message) { echo '<div style=' . $bannerStyle . '> <strong>WEATHER BROADCAST ALERT - ' . $message . '</strong>... Dallas County, listen now to our LIVE NOAA Weather Radio Stream <a href=" ' . $feed . '" class="NWRLink" onclick="return popup(this, \'noaa\')" title="Live NOAA Radio For Dallas County">[Click here to listen]</a> </div>'; } I think it is because of this below that is at the end of the code but I am not sure how to change that to only display one. I think the foreach statement makes it so it displays each value in the array. So how could I change that so it only shows the one with the most priority, priority is set in the array as the first one already? foreach ($events as $message) {
  2. Ah that makes perfect sense. I didn't think about the value being a boolean. Thank you very much for pointing that out. I was able to finish what I was needing to do with that value. Just to check my work for what I needed it for. Would this be correct? It seems to work and it is light weight. if ($status == "true") { echo $notify; } Meaning that if it is true, display the contents of the $notify variable. Seems to work through testing. Would this be correct, seeing any problems with that? -Thanks
  3. Hello, I have ran into a snag for something that is very elementary I am doing. It has been a while since I have worked with json and php so it could just be a simple lapse in memory. I have a json string I am trying to parse and this is the output of the string, very simple, cut and dry. All I need from that string is the "active" value. This is the very simple php code I have to parse it, which in the past works great and as outlined later works. <?php $jsonPath = "REMOVED_URL_BUT_GOES_HERE"; // URL to json data // Lets get and parse the data and create the variables $json_string = file_get_contents($jsonPath); $parsed_json = json_decode($json_string); $status = $parsed_json->active; echo $status; ?> So with the above php code when I echo the variable status, it should return the value as false but, instead I get nothing. Now as I said I would outline later, to troubleshoot and test if I do echo $json_string; then it outputs the entire string as it should so I know it is getting the contents. For some reason that I am simply overlooking it is not pulling the value for active for the $status variable. What am I missing or overlooking? -Thanks!
  4. Hello, I have a small script that depending on the title of the div the background has a different color. This use to work fine but, all of a sudden it just shows the color of the first case statement in the switch. Any suggestions what might be causing this? The title are based from an RSS feed that is parsed just for a little background on what is displayed and when. As you can see from the screen shot, this should be greenish color but, it is showing red and is taking the color of the first case. I tested this by removing the first one and then it shows yellow which is the second one. So that is how I determined it is not going down the line to display the correct color for the correct title. It is just stopping at the first title regardless if it is correct and just showing the first color. //Set path to data file #$data = "http://alerts.weather.gov/cap/".$zone.".atom"; $data = "http://alerts.weather.gov/cap/wwaatmget.php?x=".$zone."&y=1"; ## End Configurable data ## $alertColor = ' '; $alertText = '#FFF'; // get path info & protect for cross-site scripting vulnerability $sri = ($_SERVER['REQUEST_URI']) ? str_replace('#SA', '', htmlspecialchars(strip_tags($_SERVER['REQUEST_URI']))) : ''; // Lets parse the feed $dom = new DOMDocument(); $dom->load($data); $events = []; foreach ($dom->getElementsByTagNameNS("urn:oasis:names:tc:emergency:cap:1.1", "event") as $event) { $events[] = $event->nodeValue; } $alertValues = array('Tornado Warning', 'Severe Thunderstorm Warning', 'Tornado Watch', 'Severe Thunderstorm Watch', 'Flash Flood Warning', 'Flash Flood Watch', 'Flood Warning', 'Flood Watch', 'Flood Advisory', 'Winter Storm Warning', 'Winter Storm Watch', 'Winter Weather Advisory', 'Special Weather Statement'); $events = array_intersect($alertValues, $events); // Set the alert colors for the banner background switch(TRUE) { case 'Tornado Warning': $alertColor = 'rgba(255, 0, 0, 0.4)'; break; case 'Severe Thunderstorm Warning': $alertColor = 'rgba(255, 165, 0, 0.4)'; break; case 'Tornado Watch': $alertColor = 'rgba(255, 255, 0, 0.4)'; break; case 'Severe Thunderstorm Watch': $alertColor = 'rgba(219, 112, 147, 0.4)'; break; case 'Flash Flood Warning': $alertColor = 'rgba(139, 0, 0, 0.4)'; break; case 'Flash Flood Watch': $alertColor = 'rgba(46, 139, 87, 0.4)'; break; case 'Flood Warning': $alertColor = 'rgba(0, 255, 0, 0.4)'; break; case 'Flood Watch': $alertColor = 'rgba(46, 139, 87, 0.4)'; break; case 'Flood Advisory': $alertColor = 'rgba(0, 255, 127, 0.4)'; break; case 'Winter Storm Warning': $alertColor = 'rgba(255, 105, 180, 0.4)'; break; case 'Winter Storm Watch': $alertColor = 'rgba(70, 130, 180, 0.4)'; break; case 'Winter Weather Advisory': $alertColor = 'rgba(123, 104, 238, 0.4)'; break; case 'Special Weather Statement': $alertColor = 'rgba(255, 228, 181, 0.4)'; } // Lets assign some styles for the banner $bannerStyle = '"color:' . $alertText . '; width:100%; border-top-style:solid; border-bottom-style:solid; border-color:#FFF; border-width:1px; font-size:12px; text-shadow: 0 1px 1px #111; font-weight:700; font-family: Arial,Helvetica,sans-serif; text-align: center; background-color:' . $alertColor . '; margin-bottom:5px; padding: .2em 0em .2em 0em"'; // Lets assembly the banners to display foreach ($events as $message) { echo '<div style=' . $bannerStyle . '> <strong>WEATHER BROADCAST ALERT - ' . $message . '</strong>... Listen now to our LIVE NOAA Weather Radio Stream <a href=" ' . $feed . '" class="NWRLink" onclick="return popup(this, \'noaa\')" title="Live NOAA Radio For Dallas County">[Click here to listen]</a> </div>'; }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.