From 173d5d7cf0c573fbd5cd6258c6bb704b2dfe20d9 Mon Sep 17 00:00:00 2001 From: floppydiskette Date: Thu, 12 Dec 2024 19:18:16 +0000 Subject: [PATCH] wah! --- css/wah.css | 1 + gauges/index.php | 31 ++++ includes/head.inc.php | 7 +- includes/header.inc.php | 2 +- js/setpagedata.js | 324 ++++++++++++++++++++-------------------- today-yest/index.php | 242 ++++++++++++++++++++++++++++++ today/index.php | 2 +- yesterday/index.php | 4 +- 8 files changed, 443 insertions(+), 170 deletions(-) create mode 100644 gauges/index.php create mode 100644 today-yest/index.php diff --git a/css/wah.css b/css/wah.css index 82436c5..3524c57 100644 --- a/css/wah.css +++ b/css/wah.css @@ -145,6 +145,7 @@ table.mx-datatable { border: var(--border); filter: var(--shadow-small); background-color: var(--background); + margin-bottom: 5px; } table.mx-datatable th { diff --git a/gauges/index.php b/gauges/index.php new file mode 100644 index 0000000..7421aa1 --- /dev/null +++ b/gauges/index.php @@ -0,0 +1,31 @@ + + + + + + + + + +
+ +
+ + + Status: + + Page data updated +
+ +
+ + + \ No newline at end of file diff --git a/includes/head.inc.php b/includes/head.inc.php index a2b1f32..9d45eb9 100644 --- a/includes/head.inc.php +++ b/includes/head.inc.php @@ -1,9 +1,8 @@ - -Cumulus MX - +wah's the weather? + @@ -11,4 +10,4 @@ - + \ No newline at end of file diff --git a/includes/header.inc.php b/includes/header.inc.php index a6b546d..8dcf06d 100644 --- a/includes/header.inc.php +++ b/includes/header.inc.php @@ -9,7 +9,7 @@ now | today | yesterday | - today-yest | + today-yest | gauges | records | charts | diff --git a/js/setpagedata.js b/js/setpagedata.js index 56d567d..3a688b5 100644 --- a/js/setpagedata.js +++ b/js/setpagedata.js @@ -24,214 +24,214 @@ let menu = mobileMenu = ""; let initialLoad = true; window.onresize = function () { - borderpatrol(); + borderpatrol(); }; let borderpatrol = function () { - var contentMargin = $("#Header").outerHeight(true); - if ($('#Header').hasClass('w3-top')) { - $('#Content').css('margin-top', headerMargin + contentMargin + 'px'); - } else { - $('#Content').css('margin-top', headerMargin + 'px'); - } - contentMargin = $('#Footer').outerHeight(true); - if ($('#Footer').hasClass('w3-bottom')) { - $('#Content').css('margin-bottom', footerMargin + contentMargin + 'px'); - } else { - $('#Content').css('margin-bottom', footerMargin + 'px'); - } + var contentMargin = $("#Header").outerHeight(true); + if ($('#Header').hasClass('w3-top')) { + $('#Content').css('margin-top', headerMargin + contentMargin + 'px'); + } else { + $('#Content').css('margin-top', headerMargin + 'px'); + } + contentMargin = $('#Footer').outerHeight(true); + if ($('#Footer').hasClass('w3-bottom')) { + $('#Content').css('margin-bottom', footerMargin + contentMargin + 'px'); + } else { + $('#Content').css('margin-bottom', footerMargin + 'px'); + } }; // end function let createMainMenu = function (src, submenu) { - let classMain = 'w3-bar-item w3-btn w3-theme-hvr at-slim w3-hide-small w3-hide-medium'; - let classMainSub = 'w3-bar-item w3-btn w3-theme-d5-hvr at-slim'; + let classMain = 'w3-bar-item w3-btn w3-theme-hvr at-slim w3-hide-small w3-hide-medium'; + let classMainSub = 'w3-bar-item w3-btn w3-theme-d5-hvr at-slim'; - src.forEach(function (itm) { - if (itm.menu !== 'n') { // wanted in main menu - if (itm.submenu) { // drop down - menu += '
\n'; - menu += '\t\n'; - menu += '\t
\n'; - // add the sub-menu items - createMainMenu(itm.items, true); - menu += '\t\n
\n'; - } else { - infill = (itm.new_window ? ' target="_blank"' : ''); + src.forEach(function (itm) { + if (itm.menu !== 'n') { // wanted in main menu + if (itm.submenu) { // drop down + menu += '
\n'; + menu += '\t\n'; + menu += '\t
\n'; + // add the sub-menu items + createMainMenu(itm.items, true); + menu += '\t\n
\n'; + } else { + infill = (itm.new_window ? ' target="_blank"' : ''); - if (itm.forum) { - if (cmx_data.forumurl != '') { - menu += '' + itm.title + '\n'; - } - } else if (itm.webcam) { - if (cmx_data.webcamurl != '') { - menu += '' + itm.title + '\n'; - } - } else { - menu += '' + itm.title + '\n'; - } - } - } - }); + if (itm.forum) { + if (cmx_data.forumurl != '') { + menu += '' + itm.title + '\n'; + } + } else if (itm.webcam) { + if (cmx_data.webcamurl != '') { + menu += '' + itm.title + '\n'; + } + } else { + menu += '' + itm.title + '\n'; + } + } + } + }); - // if we are processing a sub menu, return to the main loop - if (submenu) - return; + // if we are processing a sub menu, return to the main loop + if (submenu) + return; - menu += ''; + menu += ''; - // stick the menus into the page - $('#Main_Menu').html(menu); + // stick the menus into the page + $('#Main_Menu').html(menu); }; let createMobileMenu = function (src, submenu) { - let classMobile = 'w3-bar-item w3-btn w3-theme-hvr at-slim'; - let styleMobile = submenu ? 'padding-left: 30px !important;' : ''; + let classMobile = 'w3-bar-item w3-btn w3-theme-hvr at-slim'; + let styleMobile = submenu ? 'padding-left: 30px !important;' : ''; - src.forEach(function (itm) { - if (itm.menu !== 'w') { // wanted in narrow menu - // mobile menu - if (itm.submenu) { - mobileMenu += '\t\n'; - createMobileMenu(itm.items, true); - } else { - infill = (itm.new_window ? " target='_blank'" : ""); - if (itm.forum && cmx_data.forumurl != '') { - mobileMenu += '' + itm.title + '\n'; - } else if (itm.webcam && cmx_data.webcamurl != '') { - mobileMenu += '' + itm.title + '\n'; - } else { - mobileMenu += '' + itm.title + '\n'; - } - } - } - }); + src.forEach(function (itm) { + if (itm.menu !== 'w') { // wanted in narrow menu + // mobile menu + if (itm.submenu) { + mobileMenu += '\t\n'; + createMobileMenu(itm.items, true); + } else { + infill = (itm.new_window ? " target='_blank'" : ""); + if (itm.forum && cmx_data.forumurl != '') { + mobileMenu += '' + itm.title + '\n'; + } else if (itm.webcam && cmx_data.webcamurl != '') { + mobileMenu += '' + itm.title + '\n'; + } else { + mobileMenu += '' + itm.title + '\n'; + } + } + } + }); - // if we are processing a sub menu, return to the main loop - if (submenu) - return; + // if we are processing a sub menu, return to the main loop + if (submenu) + return; - // stick the menus into the page - $('#Main_Menu_Mobile').html(mobileMenu); + // stick the menus into the page + $('#Main_Menu_Mobile').html(mobileMenu); }; let setupPage = function () { - // static header & footer - if (fixedHeader) { - $('#Header').addClass('w3-top'); - } else { - $('#Header').removeClass('w3-top'); - } - if (fixedFooter) { - $('#Footer').addClass('w3-bottom'); - } else { - $('#Footer').removeClass('w3-bottom'); - } - // Page content top and bottom margins - borderpatrol(); + // static header & footer + if (fixedHeader) { + $('#Header').addClass('w3-top'); + } else { + $('#Header').removeClass('w3-top'); + } + if (fixedFooter) { + $('#Footer').addClass('w3-bottom'); + } else { + $('#Footer').removeClass('w3-bottom'); + } + // Page content top and bottom margins + borderpatrol(); }; let toggleMenu = function (menuid) { - $('#' + menuid).toggleClass('w3-show'); + $('#' + menuid).toggleClass('w3-show'); }; let dropDown = function (panel) { - var btn = $('#' + panel.id); - var sub = $('#sub_' + panel.id); - if (sub.hasClass('w3-show')) { - sub.removeClass('w3-show'); - btn.attr('aria-expanded', false); - } else { - // Close other dropdowns first - $('.w3-dropdown-content').removeClass('w3-show'); - sub.addClass('w3-show'); - btn.attr('aria-expanded', true); - } + var btn = $('#' + panel.id); + var sub = $('#sub_' + panel.id); + if (sub.hasClass('w3-show')) { + sub.removeClass('w3-show'); + btn.attr('aria-expanded', false); + } else { + // Close other dropdowns first + $('.w3-dropdown-content').removeClass('w3-show'); + sub.addClass('w3-show'); + btn.attr('aria-expanded', true); + } }; let getPageData = function (resolve, reject) { - $.getJSON('data/websitedata.json?_=' + Date.now(), function (json) { - console.log('Data success'); - // auto update every 60 seconds, only the index and today pages - // Some sites may have index.htm as the default page, and thus not have a page name - let pageName = window.location.href.split('/').pop().split('.')[0]; - if (pageName == 'index' || pageName == 'today' || pageName == 'todayYest' || pageName == '') { - setTimeout(function () { - getPageData(null, null); - }, 60 * 1000); - } + $.getJSON('data/websitedata.json?_=' + Date.now(), function (json) { + console.log('Data success'); + // auto update every 60 seconds, only the index and today pages + // Some sites may have index.htm as the default page, and thus not have a page name + let pageName = window.location.href.split('/').pop().split('.')[0]; + if (pageName == 'index' || pageName == 'today' || pageName == 'todayYest' || pageName == '') { + setTimeout(function () { + getPageData(null, null); + }, 60 * 1000); + } - cmx_data = json; + cmx_data = json; - // Set some header stuff - $(document).prop('title', cmx_data.location + ' weather'); - $('meta[name=description]').attr('content', cmx_data.location + ' weather data'); - $('meta[name=keywords]').attr('content', $('meta[name=keywords]').attr('content') + ', ' + cmx_data.location); + // Set some header stuff + // $(document).prop('title', cmx_data.location + ' weather'); + // $('meta[name=description]').attr('content', cmx_data.location + ' weather data'); + $('meta[name=keywords]').attr('content', $('meta[name=keywords]').attr('content') + ', ' + cmx_data.location); - // do the menus - if (initialLoad) { - $.getScript(load_menu, function () { // path is relative to the page - allows for multiple vars to be available and ignores comments ;-) - createMainMenu(menuSrc, false); - createMobileMenu(menuSrc, false); - borderpatrol(); // duplicated here to ensure things OK if initial menu wrapped - }); - initialLoad = false; - } + // do the menus + if (initialLoad) { + $.getScript(load_menu, function () { // path is relative to the page - allows for multiple vars to be available and ignores comments ;-) + createMainMenu(menuSrc, false); + createMobileMenu(menuSrc, false); + borderpatrol(); // duplicated here to ensure things OK if initial menu wrapped + }); + initialLoad = false; + } - // Show/hide Apparent/Feels Like - if (cmx_data.options.useApparent === "1") { - $('[data-cmx-apparent]').removeClass('w3-hide'); - $('[data-cmx-feels]').addClass('w3-hide'); - } + // Show/hide Apparent/Feels Like + if (cmx_data.options.useApparent === "1") { + $('[data-cmx-apparent]').removeClass('w3-hide'); + $('[data-cmx-feels]').addClass('w3-hide'); + } - if (cmx_data.options.showSolar === "1") { - $('[data-cmx-solar]').removeClass('w3-hide'); - } else { - $('[data-cmx-solar-gauge]').addClass('w3-hide'); // Gauges do not draw correctly if hidden from the start - } + if (cmx_data.options.showSolar === "1") { + $('[data-cmx-solar]').removeClass('w3-hide'); + } else { + $('[data-cmx-solar-gauge]').addClass('w3-hide'); // Gauges do not draw correctly if hidden from the start + } - if (cmx_data.options.showUV === "1") { - $('[data-cmx-uv]').removeClass('w3-hide'); - } else { - $('[data-cmx-uv-gauge]').addClass('w3-hide'); // Gauges do not draw correctly if hidden from the start - } + if (cmx_data.options.showUV === "1") { + $('[data-cmx-uv]').removeClass('w3-hide'); + } else { + $('[data-cmx-uv-gauge]').addClass('w3-hide'); // Gauges do not draw correctly if hidden from the start + } - // Update all spans having data-cmxdata with data values - $('[data-cmxdata]').each(function () { - this.innerHTML = cmx_data[this.dataset.cmxdata]; - }); + // Update all spans having data-cmxdata with data values + $('[data-cmxdata]').each(function () { + this.innerHTML = cmx_data[this.dataset.cmxdata]; + }); - if (cmx_data.currcond != '') { - $('#currCond').removeClass('w3-hide'); - } + if (cmx_data.currcond != '') { + $('#currCond').removeClass('w3-hide'); + } - // Use this to trigger other scripts on the page - if (null !== resolve) { - resolve(); - } - }) - .fail(function (jqxhr, textStatus, error) { - let err = textStatus + ', ' + error; - console.log('Data Request Failed: ' + err); + // Use this to trigger other scripts on the page + if (null !== resolve) { + resolve(); + } + }) + .fail(function (jqxhr, textStatus, error) { + let err = textStatus + ', ' + error; + console.log('Data Request Failed: ' + err); - if (null !== reject) { - reject(); - } + if (null !== reject) { + reject(); + } - // lets try that again - setTimeout(function () { - getPageData(resolve, reject); - }, 5000); - }); + // lets try that again + setTimeout(function () { + getPageData(resolve, reject); + }, 5000); + }); }; // Get the main page data let dataLoadedPromise = new Promise((myResolve, myReject) => { - $(document).ready(function () { - setupPage(); - getPageData(myResolve, myReject); - }); + $(document).ready(function () { + setupPage(); + getPageData(myResolve, myReject); + }); }); diff --git a/today-yest/index.php b/today-yest/index.php new file mode 100644 index 0000000..8777389 --- /dev/null +++ b/today-yest/index.php @@ -0,0 +1,242 @@ + + + + + + + + + +
+ +
+

Today vs Yesterday ()

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Temperature and HumidityTodayYesterday
High Temperature at  at
Low Temperature at  at
Temperature Range  
High Apparent Temperature at  at
Low Apparent Temperature at  at
High Feels Like at  at
Low Feels Like at  at
Low Wind Chill at  at
High Heat Index at  at
High Humidity %at  %at +
Low Humidity %at +  %at +
RainfallTodayYesterday
Rainfall  
Rainfall Rate Max /hrat  /hrat
High Hourly Rainfall  + at   + at
High 24 Hour Rainfall  + at   + at
WindTodayYesterday
Highest Gust at  at
Highest Avg Speed at  at
Wind Run  
Dominant Direction° + °
Pressure (sea level)TodayYesterday
High Pressure at  at
Low Pressure at  at
+ + Page data updated +
+ +
+ + + \ No newline at end of file diff --git a/today/index.php b/today/index.php index 1edd33a..2e79dcf 100644 --- a/today/index.php +++ b/today/index.php @@ -18,7 +18,7 @@
-

Data for today ()

+

Data for today ()

diff --git a/yesterday/index.php b/yesterday/index.php index 53be492..eab9674 100644 --- a/yesterday/index.php +++ b/yesterday/index.php @@ -18,7 +18,7 @@
-

Data for yesterday ()

+

Data for yesterday ()

Temperature and Humidity
@@ -146,4 +146,4 @@ - + \ No newline at end of file
Temperature and Humidity