add sauce

This commit is contained in:
floppydiskette 2024-12-11 21:20:28 +00:00
commit b856cb894f
No known key found for this signature in database
48 changed files with 28950 additions and 0 deletions

40
js/alltimerecdata.js Normal file
View file

@ -0,0 +1,40 @@
// Last modified: 2021/03/19 09:15:55
$.getJSON("data/websitedata.json", function (json) {
console.log("success");
var cmx_data = json;
$(document).prop('title', cmx_data['cmx-location'] + ' weather');
$('meta[name=description]').attr('content', cmx_data['cmx-location'] + ' weather data');
$('meta[name=keywords]').attr('content', $('meta[name=keywords]').attr('content') + ', ' + cmx_data['cmx-location'] + ' weather data');
$.getJSON("data/alltimerecdata.json", function (json) {
console.log("success");
Object.keys(json).forEach(key => {
cmx_data[key] = json[key];
});
// Update all spans with id beginning "cmx-"
$('span[id^=cmx-]').each(function () {
this.innerHTML = cmx_data[this.id];
});
// Update all spans with class beginning "cmx-"
$('span[class^=cmx-]').each(function () {
this.innerHTML = cmx_data[this.className];
});
})
.fail(function (jqxhr, textStatus, error) {
var err = textStatus + ", " + error;
console.log("Request Failed: " + err);
});
})
.fail(function (jqxhr, textStatus, error) {
var err = textStatus + ", " + error;
console.log("Request Failed: " + err);
});
$(document).ready(function () {
});

2468
js/cumuluscharts.js Normal file

File diff suppressed because it is too large Load diff

1134
js/historiccharts.js Normal file

File diff suppressed because it is too large Load diff

36
js/menu.js Normal file
View file

@ -0,0 +1,36 @@
/*
Menu configuration file for NEW CuMX template
Last modified: 2022/07/05 11:39:38
menu.js - typical name, you define the one used in setpagedata.js
It is STRONGLY RECOMMENDED that if you customise this file, you create a new file with a different name, e.g. mymenu.js
and change setpagedata.js to use that file. This will avoid your customisations being accidentally overwritten during upgrades
Properties:
.menu - can be 'b' (both menus), 'w' (wide menu ONLY), 'n' (narrow menu ONLY)
.new_window:true - forces the link to open in new browser window
.forum:true - flags a forum link menu item, it will use the url provided in CuMX config, if that is blank the menu item will be hidden
.webcam:true - flags a webcam link menu item, it will use the url provided in CuMX config, if that is blank the menu item will be hidden
*/
menuSrc = [
{title: "Now", menu: "b", url: "index.htm"},
{title: "Today", menu: "b", url: "today.htm"},
{title: "Yesterday", menu: "b", url: "yesterday.htm"},
{title: "Today-Yest", menu: "b", url: "todayyest.htm"},
{title: "Gauges", menu: "b", url: "gauges.htm"},
{title: "Records", menu: "b", submenu: true, items: [
{title: "This Month", menu: "b", url: "thismonth.htm"},
{title: "This Year", menu: "b", url: "thisyear.htm"},
{title: "All Time", menu: "b", url: "record.htm"},
{title: "Monthly", menu: "b", url: "monthlyrecord.htm"}
]},
{title: "Charts", menu: "b", submenu: true, items: [
{title: "Trends", menu: "b", url: "trends.htm"},
{title: "Select-a-graph", menu: "b", url: "selectachart.htm"},
{title: "Historic", menu: "b", url: "historic.htm"}
]},
{title: "Reports", menu: "b", url: "noaareport.htm"},
{title: "Forum", menu: "b", url: "#", forum: true, new_window: true},
{title: "Webcam", menu: "b", url: "#", webcam: true}
];

44
js/menuSample.js Normal file
View file

@ -0,0 +1,44 @@
/*
An example extended/modified Menu configuration file for NEW CuMX template
Last modified: 2021/03/19 09:17:14
menuSample.js - typical name, you define the one used in setpagedata.js
Properties:
.menu - can be 'b' (both menus), 'w' (wide menu ONLY), 'n' (narrow menu ONLY)
.new_window:true - forces the link to open in new browser window
.forum:true - flags a forum link menu item, it will use the url provided in CuMX config, if that is blank the menu item will be hidden
.webcam:true - flags a webcam link menu item, it will use the url provided in CuMX config, if that is blank the menu item will be hidden
*/
menuSrc = [
{ title: "Now", menu: "b", url: "index.htm" },
{ title: "Today", menu: "b", url: "today.htm" },
{ title: "Yesterday", menu: "b", url: "yesterday.htm" },
{ title: "Gauges", menu: "b", url: "gauges.htm" },
{
title: "Records", menu: "b", submenu: true, items: [
{ title: "This Month", menu: "b", url: "thismonth.htm" },
{ title: "This Year", menu: "b", url: "thisyear.htm" },
{ title: "All Time", menu: "b", url: "record.htm" },
{ title: "Monthly", menu: "b", url: "monthlyrecord.htm" }
]
},
{
title: "Charts", menu: "b", submenu: true, items: [
{ title: "Trends", menu: "b", url: "trends.htm" },
{ title: "Select-a-graph", menu: "b", url: "selectachart.htm" },
{ title: "Historic", menu: "b", url: "historic.htm" }
]
},
{ title: "Reports", menu: "b", url: "noaareport.htm" },
{ title: "Forum", menu: "n", url: "#", new_window: true },
{ title: "Webcam", menu: "n", url: "#", new_window: true },
{
title: "Other Links", menu: "w", submenu: true, items: [
{ title: "Cumulus Forum", menu: "w", url: "#", forum: true, new_window: true },
{ title: "Webcam", menu: "b", url: "#", webcam: true, new_window: true },
{ title: "My Cat", menu: "b", url: "mycatpage.htm" },
{ title: "Some Cat", menu: "b", url: "https://pixnio.com/free-images/2020/07/26/2020-07-26-08-52-19-1200x1200.jpg", new_window: true }
]
}
];

74
js/monthlyrecdata.js Normal file
View file

@ -0,0 +1,74 @@
// Last modified: 2022/07/27 15:35:57
$(document).ready(function() {
dataLoadedPromise.then(function() {
var yesterday = new Date()
yesterday.setDate(yesterday.getDate() - 1)
changeData(yesterday.getMonth());
$('#btnMon' + yesterday.getMonth()).attr('aria-pressed', true);
});
});
var monthnames = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
function changeData(month) {
document.getElementById('MonthName').innerHTML = monthnames[month];
document.getElementById('TempH').innerHTML = cmx_data.monthlyrecs.hightemp[month];
document.getElementById('TempHT').innerHTML = cmx_data.monthlyrecs.hightempT[month];
document.getElementById('TempL').innerHTML = cmx_data.monthlyrecs.lowtemp[month];
document.getElementById('TempLT').innerHTML = cmx_data.monthlyrecs.lowtempT[month];
document.getElementById('DewPointH').innerHTML = cmx_data.monthlyrecs.highDP[month];
document.getElementById('DewPointHT').innerHTML = cmx_data.monthlyrecs.highDPT[month];
document.getElementById('DewPointL').innerHTML = cmx_data.monthlyrecs.lowDP[month];
document.getElementById('DewPointLT').innerHTML = cmx_data.monthlyrecs.lowDPT[month];
document.getElementById('AppTempH').innerHTML = cmx_data.monthlyrecs.highapptemp[month];
document.getElementById('AppTempHT').innerHTML = cmx_data.monthlyrecs.highapptempT[month];
document.getElementById('AppTempL').innerHTML = cmx_data.monthlyrecs.lowapptemp[month];
document.getElementById('AppTempLT').innerHTML = cmx_data.monthlyrecs.lowapptempT[month];
document.getElementById('FeelsLikeH').innerHTML = cmx_data.monthlyrecs.highfeelslike[month];
document.getElementById('FeelsLikeHT').innerHTML = cmx_data.monthlyrecs.highfeelslikeT[month];
document.getElementById('FeelsLikeL').innerHTML = cmx_data.monthlyrecs.lowfeelslike[month];
document.getElementById('FeelsLikeLT').innerHTML = cmx_data.monthlyrecs.lowfeelslikeT[month];
document.getElementById('WChillL').innerHTML = cmx_data.monthlyrecs.lowchill[month];
document.getElementById('WChillLT').innerHTML = cmx_data.monthlyrecs.lowchillT[month];
document.getElementById('HeatIndexH').innerHTML = cmx_data.monthlyrecs.highheatindex[month];
document.getElementById('HeatIndexHT').innerHTML = cmx_data.monthlyrecs.highheatindexT[month];
document.getElementById('MinTempH').innerHTML = cmx_data.monthlyrecs.highmintemp[month];
document.getElementById('MinTempHT').innerHTML = cmx_data.monthlyrecs.highmintempT[month];
document.getElementById('MaxTempL').innerHTML = cmx_data.monthlyrecs.lowmaxtemp[month];
document.getElementById('MaxTempLT').innerHTML = cmx_data.monthlyrecs.lowmaxtempT[month];
document.getElementById('HumH').innerHTML = cmx_data.monthlyrecs.highhum[month];
document.getElementById('HumHT').innerHTML = cmx_data.monthlyrecs.highhumT[month];
document.getElementById('HumL').innerHTML = cmx_data.monthlyrecs.lowhum[month];
document.getElementById('HumLT').innerHTML = cmx_data.monthlyrecs.lowhumT[month];
document.getElementById('HighDailyTempRange').innerHTML = cmx_data.monthlyrecs.hightemprange[month];
document.getElementById('HighDailyTempRangeT').innerHTML = cmx_data.monthlyrecs.hightemprangeT[month];
document.getElementById('LowDailyTempRange').innerHTML = cmx_data.monthlyrecs.lowtemprange[month];
document.getElementById('LowDailyTempRangeT').innerHTML = cmx_data.monthlyrecs.lowtemprangeT[month];
document.getElementById('RainRateH').innerHTML = cmx_data.monthlyrecs.rainrate[month];
document.getElementById('RainRateHT').innerHTML = cmx_data.monthlyrecs.rainrateT[month];
document.getElementById('HourlyRainH').innerHTML = cmx_data.monthlyrecs.hourlyrain[month];
document.getElementById('HourlyRainHT').innerHTML = cmx_data.monthlyrecs.hourlyrainT[month];
document.getElementById('Rain24HourH').innerHTML = cmx_data.monthlyrecs.rain24h[month];
document.getElementById('Rain24HourHT').innerHTML = cmx_data.monthlyrecs.rain24hT[month];
document.getElementById('DailyRainH').innerHTML = cmx_data.monthlyrecs.dailyrain[month];
document.getElementById('DailyRainHT').innerHTML = cmx_data.monthlyrecs.dailyrainT[month];
document.getElementById('MonthlyRainH').innerHTML = cmx_data.monthlyrecs.monthlyrain[month];
document.getElementById('MonthlyRainHT').innerHTML = cmx_data.monthlyrecs.monthlyrainT[month];
document.getElementById('LongestDryPeriod').innerHTML = cmx_data.monthlyrecs.dryperiod[month];
document.getElementById('LongestDryPeriodT').innerHTML = cmx_data.monthlyrecs.dryperiodT[month];
document.getElementById('LongestWetPeriod').innerHTML = cmx_data.monthlyrecs.wetperiod[month];
document.getElementById('LongestWetPeriodT').innerHTML = cmx_data.monthlyrecs.wetperiodT[month];
document.getElementById('GustH').innerHTML = cmx_data.monthlyrecs.highgust[month];
document.getElementById('GustHT').innerHTML = cmx_data.monthlyrecs.highgustT[month];
document.getElementById('WindH').innerHTML = cmx_data.monthlyrecs.highwind[month];
document.getElementById('WindHT').innerHTML = cmx_data.monthlyrecs.highwindT[month];
document.getElementById('WindRunH').innerHTML = cmx_data.monthlyrecs.highwindrun[month];
document.getElementById('WindRunHT').innerHTML = cmx_data.monthlyrecs.highwindrunT[month];
document.getElementById('PressL').innerHTML = cmx_data.monthlyrecs.lowpress[month];
document.getElementById('PressLT').innerHTML = cmx_data.monthlyrecs.lowpressT[month];
document.getElementById('PressH').innerHTML = cmx_data.monthlyrecs.highpress[month];
document.getElementById('PressHT').innerHTML = cmx_data.monthlyrecs.highpressT[month];
$('#btnArray').children('button').attr("aria-pressed", false);
$('#btnMon' + month).attr('aria-pressed', true);
}

142
js/noaarpts.js Normal file
View file

@ -0,0 +1,142 @@
/* ----------------------------------------------------------
* noaarpts.js
* Last modified: 2021/07/10 13:19:42
* Populates the dropdown menus using the records began date
*
* Requires jQuery
* ----------------------------------------------------------*/
let rptPath = 'data/reports/'; // Your path should have a trailing "/", eg. 'Reports/'
let startYear, endYear;
let startMonth, endMonth;
let rptAvail = {};
if (rptPath.length && rptPath.slice(-1) !== '/')
rptPath += '/';
$(document).ready(function () {
dataLoadedPromise.then(function () {
startYear = cmx_data.recordsbegandateISO.split('-')[0] * 1;
startMonth = cmx_data.recordsbegandateISO.split('-')[1] * 1;
endYear = cmx_data.metdateyesterdayISO.split('-')[0] * 1;
endMonth = cmx_data.metdateyesterdayISO.split('-')[1] * 1;
// This does the initial disable of out of range months this year
rptAvail[endYear] = [];
for (let m = 1; m < 13; m++) {
// greater than end month
rptAvail[endYear][m] = m <= endMonth;
// if start year is this year, then less start month
if (startYear == endYear) {
rptAvail[endYear][m] = rptAvail[endYear][m] && m >= startMonth
}
$('#opt-' + m).prop('hidden', !rptAvail[endYear][m]);
}
// get the current year report and display it whilst we sort out the rest in background
getYearRpt(endYear);
// add the year select dropdown values, most recent first
for (let y = endYear; y >= startYear; y--) {
let option = $('<option />');
option.html(y);
option.val(y);
$('#year').append(option);
rptAvail[y] = [];
// The start and end years may be short, so no point in checking months that are out of range
let monSt, monEnd;
if (y == startYear || y == endYear) {
monSt = y == startYear ? startMonth : 1;
monEnd = y == endYear ? endMonth : 12;
} else {
monSt = 1;
monEnd = 12;
}
// we need to process every month though, so we can disbale those out of range as well as MIA
for (let m = 1; m <= 12; m++) {
// assume this month isn't available
rptAvail[y][m] = false;
if (m >= monSt && m <= monEnd) {
// assume it's there, then we only have to check for failure
rptAvail[y][m] = true;
// checking...
$.ajax({
url: rptPath + 'NOAAMO' + pad2(m) + pad2(y - 2000) + '.txt',
type: 'HEAD',
error: function () {
rptAvail[y][m] = false;
// if we are in the year currently being displayed...
if (y == $('#year').val()) {
// ...disable of any months that should be available but aren't
$('#opt-' + m).prop('hidden', true);
}
}
});
}
}
}
});
});
// pad two digit numbers with a leading zero
let pad2 = function (num) {
return (num < 10 ? '0' : '') + num;
}
// Script assumes that reports use the default name format
let getMonRpt = function (month) {
let yr = $('#year').val();
// Is annual selected? If so, show the yearly report
if (month === '0') {
getYearRpt(yr);
return;
}
reqRpt = rptPath + 'NOAAMO' + pad2(month) + pad2(yr - 2000) + '.txt';
$.ajax({
url: reqRpt,
dataType: 'text',
success: function (data) {
$('#noaareport').text(data);
},
error: function () {
alert('Did not find the required report\n\nPlease try another date');
}
});
};
// Script assumes that reports use the default name format
let getYearRpt = function (yr) {
let reqRpt = rptPath + 'NOAAYR' + yr + '.txt';
// set the month buttons for the new year
for (let m = 1; m < 13; m++) {
$('#opt-' + m).prop('hidden', !rptAvail[yr][m]);
}
// Do we have a month selected? If so show the month report for the new year
let mon = $('#month').val();
if (mon != '0') {
getMonRpt(mon);
return;
}
// get the report text
$.ajax({
url: reqRpt,
dataType: 'text',
success: function (data) {
$('#noaareport').text(data);
},
error: function () {
alert('Did not find the required report\n\nPlease try another date');
}
});
};

1469
js/selectachart.js Normal file

File diff suppressed because it is too large Load diff

237
js/setpagedata.js Normal file
View file

@ -0,0 +1,237 @@
/* ----------------------------------------------------------
* setpagedata.js v:0.1.0 d:Mar 2021 a:Neil Thomas
* Last modified: 2022/07/02 17:55:10
* Basic scripts for all new at-xxxx.html template pages.
* Incorporating changes suggested by beteljuice
* Requires jQuery
* ----------------------------------------------------------*/
// Global variables
// Changing these affects every page in the ai-interface
// All numbers are pixels.
let fixedHeader = false; // Use only true or false
let fixedFooter = true; // Use only true or false
let headerMargin = 20; // Gap between the header and the main body
let footerMargin = 10; // Gap between the body and the footer
let load_menu = "js/menu.js"; // menu file to load - path is relative to the page
// Thats the only changes you should make unless you know better!
let cmx_data;
let menu = mobileMenu = "";
let initialLoad = true;
window.onresize = function () {
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');
}
}; // 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';
src.forEach(function (itm) {
if (itm.menu !== 'n') { // wanted in main menu
if (itm.submenu) { // drop down
menu += '<div class="w3-dropdown-hover">\n';
menu += '\t<button id="' + itm.title.replace(/ /g, "_") + '" type="button" class="w3-btn w3-theme-hvr at-slim w3-hide-medium w3-hide-small" onclick="dropDown(this)" aria-expanded="false">' + itm.title + '&#8230;</button>\n';
menu += '\t<div id="sub_' + itm.title.replace(/ /g, "_") + '" class="w3-dropdown-content w3-bar-block w3-theme">\n';
// add the sub-menu items
createMainMenu(itm.items, true);
menu += '\t\n</div></div>\n';
} else {
infill = (itm.new_window ? ' target="_blank"' : '');
if (itm.forum) {
if (cmx_data.forumurl != '') {
menu += '<a href="' + cmx_data.forumurl + '"' + infill + ' class="' + (submenu ? classMainSub : classMain) + '">' + itm.title + '</a>\n';
}
} else if (itm.webcam) {
if (cmx_data.webcamurl != '') {
menu += '<a href="' + cmx_data.webcamurl + '"' + infill + ' class="' + (submenu ? classMainSub : classMain) + '">' + itm.title + '</a>\n';
}
} else {
menu += '<a href="' + itm.url + '"' + infill + ' class="' + (submenu ? classMainSub : classMain) + '">' + itm.title + '</a>\n';
}
}
}
});
// if we are processing a sub menu, return to the main loop
if (submenu)
return;
menu += '<button class="w3-bar-item w3-btn w3-theme-hvr at-slim w3-hide-large w3-right" onClick="toggleMenu(\'Main_Menu_Mobile\')">Menu &#9776;</button>';
// 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;' : '';
src.forEach(function (itm) {
if (itm.menu !== 'w') { // wanted in narrow menu
// mobile menu
if (itm.submenu) {
mobileMenu += '\t<button class="w3-btn at-slim" style="cursor: default;">' + itm.title + '&#8230;</button>\n';
createMobileMenu(itm.items, true);
} else {
infill = (itm.new_window ? " target='_blank'" : "");
if (itm.forum && cmx_data.forumurl != '') {
mobileMenu += '<a href="' + cmx_data.forumurl + '"' + infill + ' class="' + classMobile + '" style= "' + styleMobile + '">' + itm.title + '</a>\n';
} else if (itm.webcam && cmx_data.webcamurl != '') {
mobileMenu += '<a href="' + cmx_data.webcamurl + '"' + infill + ' class="' + classMobile + '" style= "' + styleMobile + '">' + itm.title + '</a>\n';
} else {
mobileMenu += '<a href="' + itm.url + '"' + infill + ' class="' + classMobile + '" style= "' + styleMobile + '">' + itm.title + '</a>\n';
}
}
}
});
// 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);
};
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();
};
let toggleMenu = function (menuid) {
$('#' + 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);
}
};
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);
}
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);
// 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');
}
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
}
// 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');
}
// 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();
}
// 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);
});
});