{"id":345,"date":"2012-01-21T14:26:50","date_gmt":"2012-01-21T19:26:50","guid":{"rendered":"http:\/\/www.cloppermillweather.org\/blog\/?p=345"},"modified":"2012-01-24T14:49:00","modified_gmt":"2012-01-24T19:49:00","slug":"weather-advisories","status":"publish","type":"post","link":"https:\/\/www.cloppermillweather.org\/blog\/2012\/01\/21\/weather-advisories\/","title":{"rendered":"Weather Advisories"},"content":{"rendered":"<p>The header of all of my weather Web pages will display any watches, warnings, or advisories issued by the National Weather Service for my local area.\u00a0 They display in a colored box at the top of the page if there are any to be displayed.\u00a0 Otherwise that area of the page is not visible.\u00a0 The problem is that if the status changes and you don&#8217;t refresh the page, the box never appears (or else never goes away).\u00a0 Time to add code to automatically refresh that part of the page periodically.<\/p>\n<p>First I created a JSON representation of the data and a way to transfer it to the browser.\u00a0 Next I wrote Ajax code to retrieve the data every 10 minutes.\u00a0 Finally I wrote code to determine what type of notification it is (warning, watch, or advisory), set the color of the box, make the box visible, and display the message.\u00a0 I already had Javascript code to display the warning in a colored box and to make the box visible, but\u00a0I saw that Knockout could also do this for me.\u00a0 So I adapted my code to provide support functions and let Knockout do the work.<\/p>\n<p>We had a weather advisory today which gave me the opportunity to test the new code and ensure it worked correctly.\u00a0 The advisory appeared at the top of the page while the advisory was in effect, and when it ended the advisory box disappeared from the page.\u00a0 It looks like another successful move to make the page more dynamic and update when conditions change.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The header of all of my weather Web pages will display any watches, warnings, or advisories issued by the National Weather Service for my local area.\u00a0 They display in a colored box at the top of the page if there &hellip; <a href=\"https:\/\/www.cloppermillweather.org\/blog\/2012\/01\/21\/weather-advisories\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-345","post","type-post","status-publish","format-standard","hentry","category-weather"],"_links":{"self":[{"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/posts\/345","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/comments?post=345"}],"version-history":[{"count":0,"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/posts\/345\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/media?parent=345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/categories?post=345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/tags?post=345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}