#errorCatcher Echo
#encoding UTF-8
#set global $page = "reports"

    #include "header.html.tmpl"
    
    <script>        
        jQuery(document).ready(function() {
            var month = getURLvar("mo");
            var year = getURLvar("yr");
            if ( ( year !== undefined ) && ( month !== undefined ) ) {
                url = '$relative_url/NOAA/NOAA-'+year+'-'+month+'.txt';
            } else if ( year !== undefined ) {
                url = '$relative_url/NOAA/NOAA-'+year+'.txt';
            } else {
                url = '$relative_url/NOAA/$default_noaa_file';
            }
            
            // Load the file into the pre
            //jQuery('#noaa_contents').load( url );
            populatePre( url );
            
            // Change the direct href link
            jQuery(".noaa_direct_link").attr( "href", url );
        });
        
        // Change the div to the right NOAA file
        // I normally use PHP for this, but JavaScript seems to work well 
for the skin
        // Source: https://stackoverflow.com/a/18933218/1177153
        function populatePre(url) {
            var xhr = new XMLHttpRequest();
            xhr.onload = function () {
                raw_content = this.responseText;
                updated_content = 
raw_content.replace('<sup>','').replace('</sup>','').replace('&deg;','');
                document.getElementById('noaa_contents').textContent = 
updated_content;
            };
            xhr.open('GET', url);
            xhr.send();
        }
    </script>

    <div class="site-inner">
        <main class="content">    
            <article class="weewx reports" itemscope 
itemtype="https://schema.org/CreativeWork";>

                #include "page-header.inc"

                <div class="noaa_reports">
                    <H1>$obs.label.reports_title</H1>
                    <div class="row">
                        <div class="col-sm-12 wx-year-row">
                            $noaa_header_html
                        </div>
                    </div>
                    <a href="#" 
class="noaa_direct_link">$obs.label.reports_click_here_link</a> 
$obs.label.reports_view_more
                    <br><br>
                    <div class="noaa_report_container">
                        <pre id="noaa_contents"></pre>
                    </div> <!-- END noaa_report_container -->
                </div> <!-- END noaa_reports -->

            </article>
        </main>
    </div>


    #include "footer.html.tmpl"


-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/ffc4bf5a-4e1f-42de-92e8-b9a155c92504n%40googlegroups.com.

Reply via email to