From dfe244965cd4d0484f6c47d68fc45da77732cd2b Mon Sep 17 00:00:00 2001 From: Bhabesh <bhabesh.mukhopadhyay@nibio.no> Date: Fri, 10 Jul 2020 11:30:04 +0200 Subject: [PATCH] List of special weather stations as constant Special weather stations maintained in global JSON Objects so that data redundancy can reduce --- .../templates/cydiapomonella/index.html | 38 +++++++++++++------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/cydiapomonella/templates/cydiapomonella/index.html b/cydiapomonella/templates/cydiapomonella/index.html index 2cd2f0ea..2dcc57bb 100644 --- a/cydiapomonella/templates/cydiapomonella/index.html +++ b/cydiapomonella/templates/cydiapomonella/index.html @@ -61,12 +61,35 @@ var dateYesterday = getAdjustDate(dateToday,1); var strEndDate = JSON.stringify(dateToday).substring(1,11); + var CON_idSpecial = { + "Helgøy" : "536" + , "Skiftun" : "537" + } + /* Page onload function */ $(function(){ + /* Calendar will not accept future dates including today */ document.getElementById('idTxtDateInput').setAttribute("max", JSON.stringify(dateYesterday).substring(1,11)); $('#idTxtDateInput').removeClass('hasDatepicker'); }); + /* Function for check whether the choosed weather station is within special category (e.g. devis) */ + function isSpecialWeatherStation(paramStationId) + { + var result = false; + $.each( CON_idSpecial, function( key, value ) { + if (paramStationId === value) + { + result = true; + return false; // exit the each loop + } + }); + return result; + } + + + + /* Function works on date picker onClose event */ function funDtPickerHeatSum() { @@ -92,10 +115,7 @@ var startDate = new Date($('#idTxtDateInput').val()); - if( - varWeatherId === '536' || - varWeatherId === '537' - ) + if(isSpecialWeatherStation(varWeatherId)) { strStartDate = JSON.stringify(getAdjustDate(startDate, 2 )).substring(1,11); jsonParamUrlData = getWeatherDataUrlParam(varWeatherId, strStartDate, strEndDate, varElementMeasurementTypes, varLogInIntervalHourly, CONST_TIMEZONE); @@ -161,10 +181,7 @@ var dateStartDate = getAdjustDate(dateToday,radioDaysValue); var strStartDate = JSON.stringify(dateStartDate).substring(1,11); - if( - varWeatherId === '536' || - varWeatherId === '537' - ) + if(isSpecialWeatherStation(varWeatherId)) { var dateStartDate02 = getAdjustDate(dateToday, (parseInt(radioDaysValue) + 1)); strStartDate = JSON.stringify(dateStartDate02).substring(1,11); @@ -188,10 +205,7 @@ var jsonParamUrlDataHourly = ''; - if( - varWeatherId === '536' || - varWeatherId === '537' - ) + if(isSpecialWeatherStation(varWeatherId)) { jsonParamUrlDataHourly = { logInterval : paramLogInInterval, -- GitLab