/* ---------------------------------------------------------- * noaarpts.js * Last modified: 2021/07/10 13:19:42 * Populates the dropdown menus using the records began date * * Requires jQuery * ----------------------------------------------------------*/ let rptPath = '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 = $('