/*! |
= |
/*! |
* A starter gauges page for Cumulus and Weather Display, based |
|
* A starter gauges page for Cumulus and Weather Display, based |
* on the JavaScript SteelSeries gauges by Gerrit Grunwald. |
|
* on the JavaScript SteelSeries gauges by Gerrit Grunwald. |
* |
|
* |
* Created by Mark Crossley, 02 February 2013 |
|
* Created by Mark Crossley, 02 February 2013 |
* |
|
* |
* File encoding = UTF-8 |
|
* File encoding = UTF-8 |
* |
|
* |
*/ |
|
*/ |
/*globals steelseries, LANG, changeLang, radar*/ |
|
/*globals steelseries, LANG, changeLang, radar*/ |
/*jshint jquery:true */ |
|
/*jshint jquery:true */ |
|
|
|
var gauges = (function () { |
|
var gauges = (function () { |
var strings = LANG.EN, //Set to your default language. Store all the strings in one object |
|
var strings = LANG.EN, //Set to your default language. Store all the strings in one object |
config = { |
|
config = { |
// Script configuration parameters you may want to 'tweak' |
|
// Script configuration parameters you may want to 'tweak' |
scriptVer : '2.1.1 - 2013-02-02', |
|
scriptVer : '2.1.1 - 2013-02-02', |
weatherProgram : 0, //Set 0=Cumulus, 1=Weather Display, 2=VWS |
<> |
weatherProgram : 3, //Set 0=Cumulus, 1=Weather Display, 2=VWS, 3=WeatherCat |
imgPathURL : './images/', //*** Change this to the relative path for your 'Trend' graph images |
|
imgPathURL : '/', //*** Change this to the relative path for your 'Trend' graph images |
oldGauges : 'gauges.htm', //*** Change this to the relative path for your 'old' gauges page. |
= |
oldGauges : 'gauges.htm', //*** Change this to the relative path for your 'old' gauges page. |
forecastWidth : 550, //width of the forecast display (default value 550 pixels) |
|
forecastWidth : 550, //width of the forecast display (default value 550 pixels) |
counter : 60, //download data counter (secs, default 60) |
<> |
counter : 30, //download data counter (secs, default 60) |
gaugeSize : 221, //size of gauges (default 221) - Odd numbers tend to render better than even |
= |
gaugeSize : 221, //size of gauges (default 221) - Odd numbers tend to render better than even |
gaugeSizeMobile : 161, //size of gauges used on mobile devices (default 161) |
|
gaugeSizeMobile : 161, //size of gauges used on mobile devices (default 161) |
graphUpdateTime : 15, //period of popup data graph refesh, in minutes (default 15) |
|
graphUpdateTime : 15, //period of popup data graph refesh, in minutes (default 15) |
stationTimeout : 3, //period of no data change before we declare the station offline, in minutes (default 3) |
|
stationTimeout : 3, //period of no data change before we declare the station offline, in minutes (default 3) |
pageUpdateLimit : 20, //period after which the page stops automatically updating, in minutes (default 20), |
|
pageUpdateLimit : 20, //period after which the page stops automatically updating, in minutes (default 20), |
// - set to 0 (zero) to disable this feature |
|
// - set to 0 (zero) to disable this feature |
pageUpdatePswd : 'its-me', //password to over ride the page updates timeout, do not set to blank even if you do not use a password |
|
pageUpdatePswd : 'its-me', //password to over ride the page updates timeout, do not set to blank even if you do not use a password |
digitalFont : true, //Font control for the gauges & timer |
<> |
digitalFont : false, //Font control for the gauges & timer |
digitalForecast : true, //Font control for the status display, set this to false for languages that use accented characters in the forecasts |
|
digitalForecast : false, //Font control for the status display, set this to false for languages that use accented characters in the forecasts |
showPopupData : true, //Popup data displayed |
= |
showPopupData : true, //Popup data displayed |
showPopupGraphs : true, //If popup data is displayed, show the graphs? |
|
showPopupGraphs : true, //If popup data is displayed, show the graphs? |
showWindVariation : true, //Show variation in wind direction over the last 10 minutes on the direction gauge |
|
showWindVariation : true, //Show variation in wind direction over the last 10 minutes on the direction gauge |
showIndoorTempHum : true, //Show the indoor temperature/humidity options |
|
showIndoorTempHum : true, //Show the indoor temperature/humidity options |
showUvGauge : true, //Display the UV Index gauge |
|
showUvGauge : true, //Display the UV Index gauge |
showSolarGauge : true, //Display the Solar gauge |
|
showSolarGauge : true, //Display the Solar gauge |
solarGaugeScaleMax: 1400, //Max value to be shown on the solar gauge - theoretical max without atmosphere ~ 1374 W/m² |
|
solarGaugeScaleMax: 1400, //Max value to be shown on the solar gauge - theoretical max without atmosphere ~ 1374 W/m² |
// - but Davis stations can read up to 1800 |
|
// - but Davis stations can read up to 1800 |
showRoseGauge : true, //Show the optional Wind Rose gauge |
|
showRoseGauge : true, //Show the optional Wind Rose gauge |
showRoseGaugeOdo : true, //Show the optional Wind Rose gauge Windrun Odometer |
|
showRoseGaugeOdo : true, //Show the optional Wind Rose gauge Windrun Odometer |
showGaugeShadow : true, //Show a drop shadow outside the gauges |
|
showGaugeShadow : true, //Show a drop shadow outside the gauges |
// The realtime files should be absolute paths, "/xxx.txt" refers to the public root of your web server |
|
// The realtime files should be absolute paths, "/xxx.txt" refers to the public root of your web server |
realTimeURL_Cumulus: 'realtimegauges.txt', //*** Cumulus Users: Change to your location of the realtime file *** |
|
realTimeURL_Cumulus: 'realtimegauges.txt', //*** Cumulus Users: Change to your location of the realtime file *** |
realTimeURL_WD : 'customclientraw.txt', //*** WD Users: Change to your location of the ccr file *** |
|
realTimeURL_WD : 'customclientraw.txt', //*** WD Users: Change to your location of the ccr file *** |
|
-+ |
realTimeURL_WC: '/realtimegaugesWC.txt', //*** WeatherCat Users: Change this to your download location if the realtime file is not in the same folder as the gauges-ss.htm *** |
realTimeURL_VWS : 'steelseriesVWSjson.php', //*** VWS Users: Change to your location of the JSON script generator *** |
= |
realTimeURL_VWS : 'steelseriesVWSjson.php', //*** VWS Users: Change to your location of the JSON script generator *** |
useCookies : true, //Persistently store user preferences in a cookie? |
|
useCookies : true, //Persistently store user preferences in a cookie? |
tipImages : [], |
|
tipImages : [], |
dewDisplayType : 'app' //Initial 'scale' to display 'dew' - Dewpoint |
|
dewDisplayType : 'app' //Initial 'scale' to display 'dew' - Dewpoint |
// on the 'dewpoint' gauge. 'app' - Apparent temperature |
|
// on the 'dewpoint' gauge. 'app' - Apparent temperature |
// 'wnd' - Wind Chill |
|
// 'wnd' - Wind Chill |
// 'hea' - Heat Index |
|
// 'hea' - Heat Index |
// 'hum' - Humidex |
|
// 'hum' - Humidex |
}, |
|
}, |
|
|
|
// test for canvas support before we do anything else, especially reference steelseries which will cause the script to abort! |
|
// test for canvas support before we do anything else, especially reference steelseries which will cause the script to abort! |
_canvas = (!!document.createElement("canvas").getContext ? |
|
_canvas = (!!document.createElement("canvas").getContext ? |
true : |
|
true : |
(function () { |
|
(function () { |
$('body').html(strings.canvasnosupport); |
|
$('body').html(strings.canvasnosupport); |
setTimeout(function () { |
|
setTimeout(function () { |
window.location = config.oldGauges; |
|
window.location = config.oldGauges; |
}, 3000); |
|
}, 3000); |
return false; |
|
return false; |
}()) |
|
}()) |
), |
|
), |
|
|
|
//Gauge global look'n'feel settings |
|
//Gauge global look'n'feel settings |
gauge = { |
|
gauge = { |
minMaxArea : 'rgba(212, 132, 134, 0.3)', //area sector for todays max/min. (red, green, blue, transparency) |
|
minMaxArea : 'rgba(212, 132, 134, 0.3)', //area sector for todays max/min. (red, green, blue, transparency) |
windAvgArea : 'rgba(132, 212, 134, 0.3)', |
|
windAvgArea : 'rgba(132, 212, 134, 0.3)', |
frameDesign : steelseries.FrameDesign.TILTED_GRAY, |
<> |
frameDesign : steelseries.FrameDesign.TILTED_BLACK, |
background : steelseries.BackgroundColor.BEIGE, |
|
background : steelseries.BackgroundColor.BRUSHED_METAL, |
foreground : steelseries.ForegroundType.TYPE1, |
= |
foreground : steelseries.ForegroundType.TYPE1, |
pointer : steelseries.PointerType.TYPE8, |
<> |
pointer : steelseries.PointerType.TYPE11, |
pointerColour : steelseries.ColorDef.RED, |
|
pointerColour : steelseries.ColorDef.BLUE, |
gaugeType : steelseries.GaugeType.TYPE4, |
= |
gaugeType : steelseries.GaugeType.TYPE4, |
lcdColour : steelseries.LcdColor.STANDARD, |
|
lcdColour : steelseries.LcdColor.STANDARD, |
knob : steelseries.KnobType.STANDARD_KNOB, |
|
knob : steelseries.KnobType.STANDARD_KNOB, |
knobStyle : steelseries.KnobStyle.SILVER, |
|
knobStyle : steelseries.KnobStyle.SILVER, |
labelFormat : steelseries.LabelNumberFormat.STANDARD, |
|
labelFormat : steelseries.LabelNumberFormat.STANDARD, |
tickLabelOrientation : steelseries.TickLabelOrientation.HORIZONTAL, // was .NORMAL up to v1.6.4 |
|
tickLabelOrientation : steelseries.TickLabelOrientation.HORIZONTAL, // was .NORMAL up to v1.6.4 |
rainUseSectionColours : false, // Only one of these colour options should be true |
|
rainUseSectionColours : false, // Only one of these colour options should be true |
rainUseGradientColours : false, // Set both to false to use the pointer colour |
<> |
rainUseGradientColours : true, // Set both to false to use the pointer colour |
tempTrendVisible : true, |
= |
tempTrendVisible : true, |
pressureTrendVisible : true, |
|
pressureTrendVisible : true, |
uvLcdDecimals : 1, |
|
uvLcdDecimals : 1, |
// default gauge ranges - before auto-scaling/ranging |
|
// default gauge ranges - before auto-scaling/ranging |
tempScaleDefMinC : -20, |
<> |
tempScaleDefMinC : -10, |
tempScaleDefMaxC : 40, |
|
tempScaleDefMaxC : 50, |
tempScaleDefMinF : 0, |
= |
tempScaleDefMinF : 0, |
tempScaleDefMaxF : 100, |
|
tempScaleDefMaxF : 100, |
baroScaleDefMinhPa : 990, |
<> |
baroScaleDefMinhPa : 995, |
baroScaleDefMaxhPa : 1030, |
= |
baroScaleDefMaxhPa : 1030, |
baroScaleDefMinkPa : 99, |
|
baroScaleDefMinkPa : 99, |
baroScaleDefMaxkPa : 103, |
|
baroScaleDefMaxkPa : 103, |
baroScaleDefMininHg : 29.2, |
<> |
baroScaleDefMininHg : 29.38, |
baroScaleDefMaxinHg : 30.4, |
|
baroScaleDefMaxinHg : 30.42, |
windScaleDefMaxMph : 20, |
= |
windScaleDefMaxMph : 20, |
windScaleDefMaxKts : 20, |
|
windScaleDefMaxKts : 20, |
windScaleDefMaxMs : 10, |
|
windScaleDefMaxMs : 10, |
windScaleDefMaxKmh : 30, |
|
windScaleDefMaxKmh : 30, |
uvScaleDefMax : 16 |
|
uvScaleDefMax : 16 |
}, |
|
}, |
|
|
|
commonParams = { |
|
commonParams = { |
// Common parameters for all the SteelSeries gauges |
|
// Common parameters for all the SteelSeries gauges |
size : config.gaugeSize, |
|
size : config.gaugeSize, |
gaugeType : gauge.gaugeType, |
|
gaugeType : gauge.gaugeType, |
minValue : 0, |
|
minValue : 0, |
niceScale : true, |
|
niceScale : true, |
ledVisible : false, |
|
ledVisible : false, |
frameDesign : gauge.frameDesign, |
|
frameDesign : gauge.frameDesign, |
backgroundColor : gauge.background, |
|
backgroundColor : gauge.background, |
foregroundType : gauge.foreground, |
|
foregroundType : gauge.foreground, |
pointerType : gauge.pointer, |
|
pointerType : gauge.pointer, |
pointerColor : gauge.pointerColour, |
|
pointerColor : gauge.pointerColour, |
knobType : gauge.knob, |
|
knobType : gauge.knob, |
knobStyle : gauge.knobStyle, |
|
knobStyle : gauge.knobStyle, |
lcdColor : gauge.lcdColour, |
|
lcdColor : gauge.lcdColour, |
lcdDecimals : 1, |
|
lcdDecimals : 1, |
digitalFont : config.digitalFont, |
|
digitalFont : config.digitalFont, |
tickLabelOrientation : gauge.tickLabelOrientation, |
|
tickLabelOrientation : gauge.tickLabelOrientation, |
labelNumberFormat : gauge.labelFormat |
|
labelNumberFormat : gauge.labelFormat |
}, |
|
}, |
_firstRun = true, //Used to setup units & scales etc |
|
_firstRun = true, //Used to setup units & scales etc |
_userUnitsSet = false, //Tracks if the display units have been set by a user preference |
|
_userUnitsSet = false, //Tracks if the display units have been set by a user preference |
_refreshGraphs = false, //Flag to signal refesh of the pop data graphs |
|
_refreshGraphs = false, //Flag to signal refesh of the pop data graphs |
data = {}, //Stores all the values from realtime.txt |
|
data = {}, //Stores all the values from realtime.txt |
_countDownTimer, |
|
_countDownTimer, |
_count = 11, //countdown tracker, initially set to download timeout value |
|
_count = 11, //countdown tracker, initially set to download timeout value |
_httpError = 0, //global to track download errors |
|
_httpError = 0, //global to track download errors |
_pageUpdateParam, //Stores the password if any from the page URL |
|
_pageUpdateParam, //Stores the password if any from the page URL |
_statusStr = strings.statusStr, |
|
_statusStr = strings.statusStr, |
_cacheDefeat = '?' + (new Date()).getTime().toString(), //used to force reload of popup data graphs, |
|
_cacheDefeat = '?' + (new Date()).getTime().toString(), //used to force reload of popup data graphs, |
_pageLoaded = new Date(), |
|
_pageLoaded = new Date(), |
_displayUnits = null, //Stores the display units cookie settings |
|
_displayUnits = null, //Stores the display units cookie settings |
_displayDewGauge = null, //Stores the dewppoint gauge preferred scale |
|
_displayDewGauge = null, //Stores the dewppoint gauge preferred scale |
_temp = {}, |
|
_temp = {}, |
_dew = {}, |
|
_dew = {}, |
_wind = {}, |
|
_wind = {}, |
_dir = {}, |
|
_dir = {}, |
_rain = {}, |
|
_rain = {}, |
_rrate = {}, |
|
_rrate = {}, |
_baro = {}, |
|
_baro = {}, |
_hum = {}, |
|
_hum = {}, |
_uv = {}, |
|
_uv = {}, |
_solar = {}, |
|
_solar = {}, |
_led = {}, |
|
_led = {}, |
_sampleDate, |
|
_sampleDate, |
_realtimeVer = 9, //minimum version of the realtime JSON file required |
|
_realtimeVer = 9, //minimum version of the realtime JSON file required |
_cumuluslink = '<a href="http://sandaysoft.com/products/cumulus" target="_blank">Cumulus</a>', |
|
_cumuluslink = '<a href="http://sandaysoft.com/products/cumulus" target="_blank">Cumulus</a>', |
_wdisplaylink = '<a href="http://www.weather-display.com/" target="_blank">Weather Display</a>', |
|
_wdisplaylink = '<a href="http://www.weather-display.com/" target="_blank">Weather Display</a>', |
|
-+ |
_wcatlink = '<a href="http://trixology.com/weathercat/" target="_blank">WeatherCat</a>', |
_vwslink = '<a href="http://www.ambientweather.com/virtualstation.html" target="_blank">Virtual Weather Station</a>', |
= |
_vwslink = '<a href="http://www.ambientweather.com/virtualstation.html" target="_blank">Virtual Weather Station</a>', |
_gaugeTemp, _gaugeDew, _gaugeRain, _gaugeRRate, |
|
_gaugeTemp, _gaugeDew, _gaugeRain, _gaugeRRate, |
_gaugeHum, _gaugeBaro, _gaugeWind, _gaugeDir, |
|
_gaugeHum, _gaugeBaro, _gaugeWind, _gaugeDir, |
_gaugeStatus, _gaugeTimer, _gaugeUV, _gaugeSolar, _gaugeLed, |
|
_gaugeStatus, _gaugeTimer, _gaugeUV, _gaugeSolar, _gaugeLed, |
/* _imgBackground, // Uncomment if using a background image on the gauges */ |
|
/* _imgBackground, // Uncomment if using a background image on the gauges */ |
|
|
|
// Nothing below this line needs to be modified for the gauges as supplied |
|
// Nothing below this line needs to be modified for the gauges as supplied |
// - unless you really know what you are doing |
|
// - unless you really know what you are doing |
// - but remember, if you break it, it's up to you to fix it ;) |
|
// - but remember, if you break it, it's up to you to fix it ;) |
// ------------------------------------------------------------ |
|
// ------------------------------------------------------------ |
|
|
|
// |
|
// |
// init() Called when the document is ready, pre-draws the Status Display then calls |
|
// init() Called when the document is ready, pre-draws the Status Display then calls |
// the first Ajax fetch of realtimegauges.txt. First draw of the gauges now defered until |
|
// the first Ajax fetch of realtimegauges.txt. First draw of the gauges now defered until |
// the Ajax data is available as a 'speed up'. |
|
// the Ajax data is available as a 'speed up'. |
// |
|
// |
init = function () { |
|
init = function () { |
|
|
|
// Cumulus, Weather Display, or VWS? |
|
// Cumulus, Weather Display, or VWS? |
if (config.weatherProgram === 0) { |
|
if (config.weatherProgram === 0) { |
config.realTimeURL = config.realTimeURL_Cumulus; |
|
config.realTimeURL = config.realTimeURL_Cumulus; |
} else if (config.weatherProgram === 1) { |
|
} else if (config.weatherProgram === 1) { |
config.realTimeURL = config.realTimeURL_WD; |
|
config.realTimeURL = config.realTimeURL_WD; |
} else if (config.weatherProgram === 2) { |
|
} else if (config.weatherProgram === 2) { |
config.realTimeURL = config.realTimeURL_VWS; |
|
config.realTimeURL = config.realTimeURL_VWS; |
config.showRoseGauge = false; // no windrose data from VWS |
|
config.showRoseGauge = false; // no windrose data from VWS |
|
<> |
} else if (config.weatherProgram === 3) { |
|
|
config.realTimeURL = config.realTimeURL_WC |
} else { |
|
} else { |
config.realtimeURL = null; |
= |
config.realtimeURL = null; |
} |
|
} |
|
|
|
// Set the language |
|
// Set the language |
changeLang(strings); |
|
changeLang(strings); |
|
|
|
// Use smaller gauges when running on phone devices |
|
// Use smaller gauges when running on phone devices |
if (/iphone|ipad|ipod|android|blackberry|mini|webos|windows\sce|palm/i.test(navigator.userAgent.toLowerCase())) { |
|
if (/iphone|ipad|ipod|android|blackberry|mini|webos|windows\sce|palm/i.test(navigator.userAgent.toLowerCase())) { |
commonParams.size = config.gaugeSizeMobile; |
|
commonParams.size = config.gaugeSizeMobile; |
} |
|
} |
|
|
|
// add a shadow to the gauge |
|
// add a shadow to the gauge |
var offset = Math.ceil(commonParams.size * 0.015); |
|
var offset = Math.ceil(commonParams.size * 0.015); |
commonParams.boxShadow = { |
|
commonParams.boxShadow = { |
'box-shadow': '#888 ' + offset + 'px ' + offset + 'px ' + offset + 'px', |
|
'box-shadow': '#888 ' + offset + 'px ' + offset + 'px ' + offset + 'px', |
'border-radius': Math.floor(commonParams.size / 2) + 'px' |
|
'border-radius': Math.floor(commonParams.size / 2) + 'px' |
}; |
|
}; |
|
|
|
// Logo images to 'personalise' the gauge backgrounds |
|
// Logo images to 'personalise' the gauge backgrounds |
// To add a logo to a gauge, add the parameter: |
|
// To add a logo to a gauge, add the parameter: |
// params.customLayer = _imgSmall; |
|
// params.customLayer = _imgSmall; |
// to the corresponding drawXxxx() function below. |
|
// to the corresponding drawXxxx() function below. |
// |
|
// |
// These are for demo only, to add them remove the comments around the following lines, and |
|
// These are for demo only, to add them remove the comments around the following lines, and |
// the _imgBackground definition line above... |
|
// the _imgBackground definition line above... |
/* _imgBackground = document.createElement('img'); // small logo |
|
/* _imgBackground = document.createElement('img'); // small logo |
$(_imgBackground).attr('src', config.imgPathURL + 'logoSmall.png'); |
|
$(_imgBackground).attr('src', config.imgPathURL + 'logoSmall.png'); |
*/ |
|
*/ |
// End of logo images |
|
// End of logo images |
|
|
|
// the trend images to be used for the popup data, used in conjuction with config.imgPathURL |
|
// the trend images to be used for the popup data, used in conjuction with config.imgPathURL |
// by default this is configured for the Cumulus 'standard' web site |
|
// by default this is configured for the Cumulus 'standard' web site |
// ** If you specify one image in a sub-array, then you MUST provide images for all the other sub-elements |
|
// ** If you specify one image in a sub-array, then you MUST provide images for all the other sub-elements |
if (config.weatherProgram === 0) { |
|
if (config.weatherProgram === 0) { |
// config.tipImgs for Cumulus users using the 'default' weather site |
<> |
// config.tipImgs for Cumulus users using the 'default' weather site |
config.tipImgs = [ |
|
config.tipImgs = [ |
['temp.png', 'intemp.png'], // Temperature: outdoor, indoor |
|
['temp.png', 'intemp.png'], // Temperature: outdoor, indoor |
// Temperature: dewpoint, apparent, windChill, heatIndex, humidex |
|
// Temperature: dewpoint, apparent, windChill, heatIndex, humidex |
['temp.png', 'temp.png', 'temp.png', 'temp.png', 'temp.png'], |
|
['temp.png', 'temp.png', 'temp.png', 'temp.png', 'temp.png'], |
'raint.png', // Rainfall |
|
'raint.png', // Rainfall |
'rain.png', // Rainfall rate |
|
'rain.png', // Rainfall rate |
['hum.png', 'hum.png'], // Humidity: outdoor, indoor |
|
['hum.png', 'hum.png'], // Humidity: outdoor, indoor |
'press.png', // Pressure |
|
'press.png', // Pressure |
'wind.png', // Wind speed |
|
'wind.png', // Wind speed |
'windd.png', // Wind direction |
|
'windd.png', // Wind direction |
(config.showUvGauge ? 'uv.png' : null), // UV |
= |
(config.showUvGauge ? 'uv.png' : null), // UV |
(config.showSolarGauge ? 'solar.png' : null), // Solar rad |
|
(config.showSolarGauge ? 'solar.png' : null), // Solar rad |
(config.showRoseGauge ? 'windd.png' : null) // Wind direction for Wind Rose |
|
(config.showRoseGauge ? 'windd.png' : null) // Wind direction for Wind Rose |
]; |
|
]; |
} else if (config.weatherProgram === 1) { |
|
} else if (config.weatherProgram === 1) { |
// config.tipImgs for Weather Display users with wxgraph |
<> |
// config.tipImgs for Weather Display users with wxgraph |
config.tipImgs = [ |
|
config.tipImgs = [ |
['temp+hum_24hr.php', 'indoor_temp_24hr.php'], // Temperature: outdoor, indoor |
|
['temp+hum_24hr.php', 'indoor_temp_24hr.php'], // Temperature: outdoor, indoor |
// Temperature: dewpnt, apparent, windChill, HeatIndx, humidex |
|
// Temperature: dewpnt, apparent, windChill, HeatIndx, humidex |
['temp+dew+hum_1hr.php', 'temp+dew+hum_1hr.php', 'temp+dew+hum_1hr.php', 'temp+dew+hum_1hr.php', 'temp+dew+hum_1hr.php'], |
|
['temp+dew+hum_1hr.php', 'temp+dew+hum_1hr.php', 'temp+dew+hum_1hr.php', 'temp+dew+hum_1hr.php', 'temp+dew+hum_1hr.php'], |
'rain_24hr.php', // Rainfall |
|
'rain_24hr.php', // Rainfall |
'rain_1hr.php', // Rainfall rate |
|
'rain_1hr.php', // Rainfall rate |
['humidity_1hr.php', 'humidity_7days.php'], // Humidity: outdoor, indoor |
|
['humidity_1hr.php', 'humidity_7days.php'], // Humidity: outdoor, indoor |
'baro_24hr.php', // Pressure |
|
'baro_24hr.php', // Pressure |
'windgust_1hr.php', // Wind speed |
|
'windgust_1hr.php', // Wind speed |
'winddir_24hr.php', // Wind direction |
|
'winddir_24hr.php', // Wind direction |
(config.showUvGauge ? 'uv_24hr.php' : null), // UV graph if UV sensor is present | =null if no UV sensor |
|
(config.showUvGauge ? 'uv_24hr.php' : null), // UV graph if UV sensor is present | =null if no UV sensor |
(config.showSolarGauge ? 'solar_24hr.php' : null), // Solar rad graph if Solar sensor is present | Solar =null if no Solar sensor |
|
(config.showSolarGauge ? 'solar_24hr.php' : null), // Solar rad graph if Solar sensor is present | Solar =null if no Solar sensor |
(config.showRoseGauge ? 'winddir_24hr.php' : null) // Wind direction if Radar is enabled | =null if Radar is disabled |
|
(config.showRoseGauge ? 'winddir_24hr.php' : null) // Wind direction if Radar is enabled | =null if Radar is disabled |
]; |
|
]; |
} else if (config.weatherProgram === 2) { |
= |
} else if (config.weatherProgram === 2) { |
// config.tipImgs for VWS users |
|
// config.tipImgs for VWS users |
config.tipImgs = [ |
|
config.tipImgs = [ |
['vws742.jpg', 'vws741.jpg'], // Temperature: outdoor, indoor |
|
['vws742.jpg', 'vws741.jpg'], // Temperature: outdoor, indoor |
// Temperature: dewpnt, apparent, windChill, HeatIndx, humidex |
|
// Temperature: dewpnt, apparent, windChill, HeatIndx, humidex |
['vws757.jpg', 'vws762.jpg', 'vws754.jpg', 'vws756.jpg', null], |
|
['vws757.jpg', 'vws762.jpg', 'vws754.jpg', 'vws756.jpg', null], |
'vws744.jpg', // Rainfall |
|
'vws744.jpg', // Rainfall |
'vws859.jpg', // Rainfall rate |
|
'vws859.jpg', // Rainfall rate |
['vws740.jpg', 'vws739.jpg'], // Humidity: outdoor, indoor |
|
['vws740.jpg', 'vws739.jpg'], // Humidity: outdoor, indoor |
'vws758.jpg', // Pressure |
|
'vws758.jpg', // Pressure |
'vws737.jpg', // Wind speed |
|
'vws737.jpg', // Wind speed |
'vws736.jpg', // Wind direction |
|
'vws736.jpg', // Wind direction |
(config.showUvGauge ? 'vws752.jpg' : null), // UV graph if UV sensor is present | =null if no UV sensor |
|
(config.showUvGauge ? 'vws752.jpg' : null), // UV graph if UV sensor is present | =null if no UV sensor |
(config.showSolarGauge ? 'vws753.jpg' : null), // Solar rad graph if Solar sensor is present | Solar =null if no Solar sensor |
|
(config.showSolarGauge ? 'vws753.jpg' : null), // Solar rad graph if Solar sensor is present | Solar =null if no Solar sensor |
(config.showRoseGauge ? 'vws736.jpg' : null) // Wind direction if Radar is enabled | =null if Radar is disabled |
|
(config.showRoseGauge ? 'vws736.jpg' : null) // Wind direction if Radar is enabled | =null if Radar is disabled |
]; |
|
]; |
|
-+ |
} else if (config.weatherProgram ===3) { |
|
|
// config.tipImgs for WeatherCat users using the 'default' weather site |
|
|
config.tipImgs = [ |
|
|
['temperature1.jpg', 'tempin1.jpg'], // Temperature: outdoor, indoor |
|
|
// Temperature: dewpoint, apparent, windChill, heatIndex, humidex |
|
|
['dewpoint1.jpg', 'temperature1.jpg', 'windchill1.jpg', 'heatindex1.jpg', 'temperature1.jpg'], |
|
|
'precipitationc1.jpg', // Rainfall |
|
|
'precipitation1.jpg', // Rainfall rate |
|
|
['rh1.jpg', 'rhin1.jpg'], // Humidity: outdoor, indoor |
|
|
'pressure1.jpg', // Pressure |
|
|
'windspeed1.jpg', // Wind speed |
|
|
'winddirection1.jpg', // Wind direction |
|
|
(config.showUvGauge ? 'uv1.jpg' : null), // UV |
|
|
(config.showSolarGauge ? 'solarrad1.jpg' : null), // Solar rad |
|
|
(config.showRoseGauge ? 'winddirection1.jpg' : null) // Wind direction for Wind Rose |
|
|
]; |
} else { |
= |
} else { |
// config.tipImgs - unknown |
|
// config.tipImgs - unknown |
config.tipImgs = [ |
|
config.tipImgs = [ |
[null, null], |
|
[null, null], |
[null, null, null, null, null], |
|
[null, null, null, null, null], |
null, null, |
|
null, null, |
[null, null], |
|
[null, null], |
null, null, null, null, null, null |
|
null, null, null, null, null, null |
]; |
|
]; |
} |
|
} |
|
|
|
// define temperature gauge start values |
|
// define temperature gauge start values |
_temp.sections = createTempSections(true); |
|
_temp.sections = createTempSections(true); |
_temp.areas = []; |
|
_temp.areas = []; |
_temp.minValue = gauge.tempScaleDefMinC; |
|
_temp.minValue = gauge.tempScaleDefMinC; |
_temp.maxValue = gauge.tempScaleDefMaxC; |
|
_temp.maxValue = gauge.tempScaleDefMaxC; |
_temp.title = strings.temp_title_out; |
|
_temp.title = strings.temp_title_out; |
_temp.value = gauge.tempScaleDefMinC + 0.0001; |
|
_temp.value = gauge.tempScaleDefMinC + 0.0001; |
_temp.maxMinVisible = false; |
|
_temp.maxMinVisible = false; |
_temp.selected = 'out'; |
|
_temp.selected = 'out'; |
|
|
|
//define dew point gauge start values |
|
//define dew point gauge start values |
_dew.sections = createTempSections(true); |
|
_dew.sections = createTempSections(true); |
_dew.areas = []; |
|
_dew.areas = []; |
_dew.minValue = gauge.tempScaleDefMinC; |
|
_dew.minValue = gauge.tempScaleDefMinC; |
_dew.maxValue = gauge.tempScaleDefMaxC; |
|
_dew.maxValue = gauge.tempScaleDefMaxC; |
_dew.value = gauge.tempScaleDefMinC + 0.0001; |
|
_dew.value = gauge.tempScaleDefMinC + 0.0001; |
// Has the end user selected a prefered 'scale' before |
|
// Has the end user selected a prefered 'scale' before |
_displayDewGauge = getCookie('dewGauge'); |
|
_displayDewGauge = getCookie('dewGauge'); |
// Set 'dewgauge' radio buttons to match prefered units |
|
// Set 'dewgauge' radio buttons to match prefered units |
if (_displayDewGauge !== null) { |
|
if (_displayDewGauge !== null) { |
_dew.selected = _displayDewGauge; |
|
_dew.selected = _displayDewGauge; |
} else { |
|
} else { |
_dew.selected = config.dewDisplayType; |
|
_dew.selected = config.dewDisplayType; |
} |
|
} |
setRadioCheck('rad_dew', _dew.selected); |
|
setRadioCheck('rad_dew', _dew.selected); |
switch (_dew.selected) { |
|
switch (_dew.selected) { |
case 'dew': |
|
case 'dew': |
_dew.title = strings.dew_title; |
|
_dew.title = strings.dew_title; |
_dew.image = 0; |
|
_dew.image = 0; |
break; |
|
break; |
case 'app': |
|
case 'app': |
_dew.title = strings.apptemp_title; |
|
_dew.title = strings.apptemp_title; |
_dew.image = 1; |
|
_dew.image = 1; |
break; |
|
break; |
case 'wnd': |
|
case 'wnd': |
_dew.title = strings.chill_title; |
|
_dew.title = strings.chill_title; |
_dew.image = 2; |
|
_dew.image = 2; |
break; |
|
break; |
case 'hea': |
|
case 'hea': |
_dew.title = strings.heat_title; |
|
_dew.title = strings.heat_title; |
_dew.image = 3; |
|
_dew.image = 3; |
break; |
|
break; |
case 'hum': |
|
case 'hum': |
_dew.title = strings.humdx_title; |
|
_dew.title = strings.humdx_title; |
_dew.image = 4; |
|
_dew.image = 4; |
} |
|
} |
_dew.minMeasuredVisible = false; |
|
_dew.minMeasuredVisible = false; |
_dew.maxMeasuredVisible = false; |
|
_dew.maxMeasuredVisible = false; |
|
|
|
// define rain gauge start values |
|
// define rain gauge start values |
_rain.maxValue = 10; |
|
_rain.maxValue = 10; |
_rain.value = 0.0001; |
|
_rain.value = 0.0001; |
_rain.title = strings.rain_title; |
|
_rain.title = strings.rain_title; |
_rain.lcdDecimals = 1; |
|
_rain.lcdDecimals = 1; |
_rain.scaleDecimals = 1; |
|
_rain.scaleDecimals = 1; |
_rain.labelNumberFormat = gauge.labelFormat; |
|
_rain.labelNumberFormat = gauge.labelFormat; |
_rain.sections = (gauge.rainUseSectionColours ? createRainfallSections(true) : []); |
|
_rain.sections = (gauge.rainUseSectionColours ? createRainfallSections(true) : []); |
_rain.valGrad = (gauge.rainUseGradientColours ? createRainfallGradient(true) : null); |
|
_rain.valGrad = (gauge.rainUseGradientColours ? createRainfallGradient(true) : null); |
|
|
|
// define rain rate gauge start values |
|
// define rain rate gauge start values |
_rrate.maxMeasured = 0; |
|
_rrate.maxMeasured = 0; |
_rrate.maxValue = 10; |
|
_rrate.maxValue = 10; |
_rrate.value = 0.0001; |
|
_rrate.value = 0.0001; |
_rrate.title = strings.rrate_title; |
|
_rrate.title = strings.rrate_title; |
_rrate.lcdDecimals = 1; |
|
_rrate.lcdDecimals = 1; |
_rrate.scaleDecimals = 0; |
|
_rrate.scaleDecimals = 0; |
_rrate.labelNumberFormat = gauge.labelFormat; |
|
_rrate.labelNumberFormat = gauge.labelFormat; |
_rrate.sections = createRainRateSections(true); |
|
_rrate.sections = createRainRateSections(true); |
|
|
|
// define humidity gauge start values |
|
// define humidity gauge start values |
_hum.areas = []; |
|
_hum.areas = []; |
_hum.value = 0.0001; |
|
_hum.value = 0.0001; |
_hum.title = strings.hum_title_out; |
|
_hum.title = strings.hum_title_out; |
_hum.selected = 'out'; |
|
_hum.selected = 'out'; |
|
|
|
// define pressure/barometer gauge start values |
|
// define pressure/barometer gauge start values |
_baro.sections = []; |
|
_baro.sections = []; |
_baro.areas = []; |
|
_baro.areas = []; |
_baro.minValue = gauge.baroScaleDefMinhPa; |
|
_baro.minValue = gauge.baroScaleDefMinhPa; |
_baro.maxValue = gauge.baroScaleDefMaxhPa; |
|
_baro.maxValue = gauge.baroScaleDefMaxhPa; |
_baro.value = _baro.minValue + 0.0001; |
|
_baro.value = _baro.minValue + 0.0001; |
_baro.title = strings.baro_title; |
|
_baro.title = strings.baro_title; |
_baro.lcdDecimals = 1; |
|
_baro.lcdDecimals = 1; |
_baro.scaleDecimals = 0; |
|
_baro.scaleDecimals = 0; |
_baro.labelNumberFormat = gauge.labelFormat; |
|
_baro.labelNumberFormat = gauge.labelFormat; |
|
|
|
// define wind gauge start values |
|
// define wind gauge start values |
_wind.maxValue = gauge.windScaleDefMaxKph; |
|
_wind.maxValue = gauge.windScaleDefMaxKph; |
_wind.areas = []; |
|
_wind.areas = []; |
_wind.maxMeasured = 0; |
|
_wind.maxMeasured = 0; |
_wind.value = 0.0001; |
|
_wind.value = 0.0001; |
_wind.title = strings.wind_title; |
|
_wind.title = strings.wind_title; |
|
|
|
// define wind direction gauge start values |
|
// define wind direction gauge start values |
_dir.valueLatest = 0; |
|
_dir.valueLatest = 0; |
_dir.valueAverage = 0; |
|
_dir.valueAverage = 0; |
_dir.titles = [strings.latest_web, strings.tenminavg_web]; |
|
_dir.titles = [strings.latest_web, strings.tenminavg_web]; |
|
|
|
// define UV start values |
|
// define UV start values |
_uv.value = 0.0001; |
|
_uv.value = 0.0001; |
_uv.title = strings.uv_title; |
|
_uv.title = strings.uv_title; |
_uv.sections = [ |
|
_uv.sections = [ |
steelseries.Section(0, 2.9, '#289500'), |
|
steelseries.Section(0, 2.9, '#289500'), |
steelseries.Section(2.9, 5.8, '#f7e400'), |
|
steelseries.Section(2.9, 5.8, '#f7e400'), |
steelseries.Section(5.8, 7.8, '#f85900'), |
|
steelseries.Section(5.8, 7.8, '#f85900'), |
steelseries.Section(7.8, 10.9, '#d8001d'), |
|
steelseries.Section(7.8, 10.9, '#d8001d'), |
steelseries.Section(10.9, 20, '#6b49c8') |
|
steelseries.Section(10.9, 20, '#6b49c8') |
]; |
|
]; |
_uv.useSections = true; |
|
_uv.useSections = true; |
_uv.maxValue = 16; |
|
_uv.maxValue = 16; |
|
|
|
// define Solar start values |
|
// define Solar start values |
_solar.value = 0.0001; |
|
_solar.value = 0.0001; |
_solar.title = strings.solar_title; |
|
_solar.title = strings.solar_title; |
_solar.units = 'W/m²'; |
|
_solar.units = 'W/m²'; |
_solar.sections = [ |
|
_solar.sections = [ |
steelseries.Section(0, 600, 'rgba(40,149,0,0.3)'), |
|
steelseries.Section(0, 600, 'rgba(40,149,0,0.3)'), |
steelseries.Section(600, 800, 'rgba(248,89,0,0.3)'), |
|
steelseries.Section(600, 800, 'rgba(248,89,0,0.3)'), |
steelseries.Section(800, 1000, 'rgba(216,0,29,0.3)'), |
|
steelseries.Section(800, 1000, 'rgba(216,0,29,0.3)'), |
steelseries.Section(1000, 1800, 'rgba(107,73,200,0.3)') |
|
steelseries.Section(1000, 1800, 'rgba(107,73,200,0.3)') |
]; |
|
]; |
_solar.lcdDecimals = 0; |
|
_solar.lcdDecimals = 0; |
_solar.maxValue = config.solarGaugeScaleMax; |
|
_solar.maxValue = config.solarGaugeScaleMax; |
|
|
|
// define led indicator |
|
// define led indicator |
_led.on = false; |
|
_led.on = false; |
_led.blink = false; |
|
_led.blink = false; |
_led.oldBlink = _led.blink; |
|
_led.oldBlink = _led.blink; |
_led.title = strings.led_title; |
|
_led.title = strings.led_title; |
_led.colour = steelseries.LedColor.GREEN_LED; |
|
_led.colour = steelseries.LedColor.GREEN_LED; |
_led.oldColour = _led.colour; |
|
_led.oldColour = _led.colour; |
|
|
|
// set some default units |
|
// set some default units |
// DO NOT CHANGE THESE - THE SCRIPT DEPENDS ON THESE DEFAULTS |
|
// DO NOT CHANGE THESE - THE SCRIPT DEPENDS ON THESE DEFAULTS |
// the units actually displayed, will be read from the realtime.txt file, or from the users last visit |
|
// the units actually displayed, will be read from the realtime.txt file, or from the users last visit |
|
|
|
// Get the display units the user last used when they visited before - if present |
|
// Get the display units the user last used when they visited before - if present |
_displayUnits = getCookie('units'); |
|
_displayUnits = getCookie('units'); |
// Set 'units' radio buttons to match prefered units |
|
// Set 'units' radio buttons to match prefered units |
if (_displayUnits !== null) { |
|
if (_displayUnits !== null) { |
//User wants specific units |
|
//User wants specific units |
_userUnitsSet = true; |
|
_userUnitsSet = true; |
|
|
|
// temperature |
|
// temperature |
setRadioCheck('rad_unitsTemp', _displayUnits.temp); |
|
setRadioCheck('rad_unitsTemp', _displayUnits.temp); |
data.tempunit = '°' + _displayUnits.temp; |
|
data.tempunit = '°' + _displayUnits.temp; |
// rain |
|
// rain |
setRadioCheck('rad_unitsRain', _displayUnits.rain); |
|
setRadioCheck('rad_unitsRain', _displayUnits.rain); |
data.rainunit = _displayUnits.rain; |
|
data.rainunit = _displayUnits.rain; |
// pressure |
|
// pressure |
setRadioCheck('rad_unitsPress', _displayUnits.press); |
|
setRadioCheck('rad_unitsPress', _displayUnits.press); |
data.pressunit = _displayUnits.press; |
|
data.pressunit = _displayUnits.press; |
// wind |
|
// wind |
setRadioCheck('rad_unitsWind', _displayUnits.wind); |
|
setRadioCheck('rad_unitsWind', _displayUnits.wind); |
data.windunit = _displayUnits.wind; |
|
data.windunit = _displayUnits.wind; |
_displayUnits.windrun = getWindrunUnits(data.windunit); |
|
_displayUnits.windrun = getWindrunUnits(data.windunit); |
} else { |
|
} else { |
// Set the defaults to metric ) |
|
// Set the defaults to metric ) |
_displayUnits = { |
|
_displayUnits = { |
temp: 'C', |
|
temp: 'C', |
rain: 'mm', |
|
rain: 'mm', |
press: 'hPa', |
|
press: 'hPa', |
wind: 'km/h', |
|
wind: 'km/h', |
windrun: 'km' |
|
windrun: 'km' |
}; |
|
}; |
|
|
|
data.tempunit = '°C'; |
|
data.tempunit = '°C'; |
data.rainunit = 'mm'; |
|
data.rainunit = 'mm'; |
data.pressunit = 'hPa'; |
|
data.pressunit = 'hPa'; |
data.windunit = 'km/h'; |
|
data.windunit = 'km/h'; |
} |
|
} |
|
|
|
// remove indoor temperature/humidity options? |
|
// remove indoor temperature/humidity options? |
if (!config.showIndoorTempHum) { |
|
if (!config.showIndoorTempHum) { |
$('#rad_temp1').remove(); |
|
$('#rad_temp1').remove(); |
$('#lab_temp1').remove(); |
|
$('#lab_temp1').remove(); |
$('#rad_temp2').remove(); |
|
$('#rad_temp2').remove(); |
$('#lab_temp2').remove(); |
|
$('#lab_temp2').remove(); |
$('#rad_hum1').remove(); |
|
$('#rad_hum1').remove(); |
$('#lab_hum1').remove(); |
|
$('#lab_hum1').remove(); |
$('#rad_hum2').remove(); |
|
$('#rad_hum2').remove(); |
$('#lab_hum2').remove(); |
|
$('#lab_hum2').remove(); |
} |
|
} |
|
|
|
// remove the UV gauge? |
|
// remove the UV gauge? |
if (!config.showUvGauge) { |
|
if (!config.showUvGauge) { |
$('#canvas_uv').parent().remove(); |
|
$('#canvas_uv').parent().remove(); |
} |
|
} |
|
|
|
// remove the Solar gauge? |
|
// remove the Solar gauge? |
if (!config.showSolarGauge) { |
|
if (!config.showSolarGauge) { |
$('#canvas_solar').parent().remove(); |
|
$('#canvas_solar').parent().remove(); |
} |
|
} |
|
|
|
// remove the Wind Rose? |
|
// remove the Wind Rose? |
if (!config.showRoseGauge) { |
|
if (!config.showRoseGauge) { |
$('#canvas_rose').parent().remove(); |
|
$('#canvas_rose').parent().remove(); |
$('#rgraph_attrib').remove(); |
|
$('#rgraph_attrib').remove(); |
} else if (radar !== "undefined") { |
|
} else if (radar !== "undefined") { |
radar.init(commonParams.size, config.showRoseGaugeOdo); |
|
radar.init(commonParams.size, config.showRoseGaugeOdo); |
radar.setTitle(strings.windrose); |
|
radar.setTitle(strings.windrose); |
radar.setCompassString(strings.compass); |
|
radar.setCompassString(strings.compass); |
} |
|
} |
|
|
|
// enable popup data |
|
// enable popup data |
ddimgtooltip.showTips = config.showPopupData; |
|
ddimgtooltip.showTips = config.showPopupData; |
|
|
|
if (config.showPopupGraphs) { |
|
if (config.showPopupGraphs) { |
// Note the number of array elements must match 'i' in ddimgtooltip.tiparray() |
|
// Note the number of array elements must match 'i' in ddimgtooltip.tiparray() |
ddimgtooltip.tiparray[0][0] = (config.tipImgs[0][0] !== null ? '' : null); |
|
ddimgtooltip.tiparray[0][0] = (config.tipImgs[0][0] !== null ? '' : null); |
ddimgtooltip.tiparray[1][0] = (config.tipImgs[1][0] !== null ? '' : null); |
|
ddimgtooltip.tiparray[1][0] = (config.tipImgs[1][0] !== null ? '' : null); |
ddimgtooltip.tiparray[2][0] = (config.tipImgs[2] !== null ? '' : null); |
|
ddimgtooltip.tiparray[2][0] = (config.tipImgs[2] !== null ? '' : null); |
ddimgtooltip.tiparray[3][0] = (config.tipImgs[3] !== null ? '' : null); |
|
ddimgtooltip.tiparray[3][0] = (config.tipImgs[3] !== null ? '' : null); |
ddimgtooltip.tiparray[4][0] = (config.tipImgs[4][0] !== null ? '' : null); |
|
ddimgtooltip.tiparray[4][0] = (config.tipImgs[4][0] !== null ? '' : null); |
ddimgtooltip.tiparray[5][0] = (config.tipImgs[5] !== null ? '' : null); |
|
ddimgtooltip.tiparray[5][0] = (config.tipImgs[5] !== null ? '' : null); |
ddimgtooltip.tiparray[6][0] = (config.tipImgs[6] !== null ? '' : null); |
|
ddimgtooltip.tiparray[6][0] = (config.tipImgs[6] !== null ? '' : null); |
ddimgtooltip.tiparray[7][0] = (config.tipImgs[7] !== null ? '' : null); |
|
ddimgtooltip.tiparray[7][0] = (config.tipImgs[7] !== null ? '' : null); |
ddimgtooltip.tiparray[8][0] = (config.tipImgs[8] !== null ? '' : null); |
|
ddimgtooltip.tiparray[8][0] = (config.tipImgs[8] !== null ? '' : null); |
ddimgtooltip.tiparray[9][0] = (config.tipImgs[9] !== null ? '' : null); |
|
ddimgtooltip.tiparray[9][0] = (config.tipImgs[9] !== null ? '' : null); |
ddimgtooltip.tiparray[10][0] = (config.tipImgs[10] !== null ? '' : null); |
|
ddimgtooltip.tiparray[10][0] = (config.tipImgs[10] !== null ? '' : null); |
} |
|
} |
|
|
|
// draw the status gadgets first, they will display any errors in the intial setup |
|
// draw the status gadgets first, they will display any errors in the intial setup |
drawLed(); |
|
drawLed(); |
drawStatus(); |
|
drawStatus(); |
drawTimer(); |
|
drawTimer(); |
|
|
|
getRealtime(); |
|
getRealtime(); |
}, |
|
}, |
|
|
|
// |
|
// |
// drawXXXX functions perform the initial construction of the gauges |
|
// drawXXXX functions perform the initial construction of the gauges |
// |
|
// |
drawLed = function () { |
|
drawLed = function () { |
// create led indicator |
|
// create led indicator |
if ($('#canvas_led').length) { |
|
if ($('#canvas_led').length) { |
_gaugeLed = new steelseries.Led( |
|
_gaugeLed = new steelseries.Led( |
'canvas_led', { |
|
'canvas_led', { |
size : 25, |
|
size : 25, |
ledColor : _led.colour |
|
ledColor : _led.colour |
}); |
|
}); |
if (_led.on) { |
|
if (_led.on) { |
_gaugeLed.toggleLed(); |
|
_gaugeLed.toggleLed(); |
} |
|
} |
$('#canvas_led').attr('title', _led.title); |
|
$('#canvas_led').attr('title', _led.title); |
} |
|
} |
}, |
|
}, |
|
|
|
drawStatus = function () { |
|
drawStatus = function () { |
// create forecast display |
|
// create forecast display |
if ($('#canvas_status').length) { |
|
if ($('#canvas_status').length) { |
_gaugeStatus = new steelseries.DisplaySingle( |
|
_gaugeStatus = new steelseries.DisplaySingle( |
'canvas_status', { |
|
'canvas_status', { |
width : config.forecastWidth, |
|
width : config.forecastWidth, |
height : 25, |
|
height : 25, |
lcdColor : gauge.lcdColour, |
|
lcdColor : gauge.lcdColour, |
unitStringVisible : false, |
|
unitStringVisible : false, |
value : _statusStr, |
|
value : _statusStr, |
digitalFont : config.digitalForecast, |
|
digitalFont : config.digitalForecast, |
valuesNumeric : false, |
|
valuesNumeric : false, |
autoScroll : true, |
|
autoScroll : true, |
alwaysScroll : false |
|
alwaysScroll : false |
}); |
|
}); |
} |
|
} |
}, |
|
}, |
|
|
|
drawTimer = function () { |
|
drawTimer = function () { |
// create timer display |
|
// create timer display |
if ($('#canvas_timer').length) { |
|
if ($('#canvas_timer').length) { |
_gaugeTimer = new steelseries.DisplaySingle( |
|
_gaugeTimer = new steelseries.DisplaySingle( |
'canvas_timer', { |
|
'canvas_timer', { |
width : (config.counter.toString().length * 13) + (strings.timer.length * 6), |
|
width : (config.counter.toString().length * 13) + (strings.timer.length * 6), |
height : 25, |
|
height : 25, |
lcdColor : gauge.lcdColour, |
|
lcdColor : gauge.lcdColour, |
lcdDecimals : 0, |
|
lcdDecimals : 0, |
unitString : strings.timer, |
|
unitString : strings.timer, |
unitStringVisible : true, |
|
unitStringVisible : true, |
digitalFont : config.digitalFont, |
|
digitalFont : config.digitalFont, |
value : _count |
|
value : _count |
}); |
|
}); |
} |
|
} |
}, |
|
}, |
|
|
|
drawTemp = function () { |
|
drawTemp = function () { |
var params = extend(commonParams); |
|
var params = extend(commonParams); |
// create temperature radial gauge |
|
// create temperature radial gauge |
if ($('#canvas_temp').length) { |
|
if ($('#canvas_temp').length) { |
params.section = _temp.sections; |
|
params.section = _temp.sections; |
params.area = _temp.areas; |
|
params.area = _temp.areas; |
params.minValue = _temp.minValue; |
|
params.minValue = _temp.minValue; |
params.maxValue = _temp.maxValue; |
|
params.maxValue = _temp.maxValue; |
params.thresholdVisible = false; |
|
params.thresholdVisible = false; |
params.minMeasuredValueVisible = _temp.maxMinVisible; |
|
params.minMeasuredValueVisible = _temp.maxMinVisible; |
params.maxMeasuredValueVisible = _temp.maxMinVisible; |
|
params.maxMeasuredValueVisible = _temp.maxMinVisible; |
params.titleString = _temp.title; |
|
params.titleString = _temp.title; |
params.unitString = data.tempunit; |
|
params.unitString = data.tempunit; |
params.trendVisible = gauge.tempTrendVisible; |
|
params.trendVisible = gauge.tempTrendVisible; |
//params.customLayer = _imgBackground; // uncomment to add a background image - See Logo Images above |
|
//params.customLayer = _imgBackground; // uncomment to add a background image - See Logo Images above |
|
|
|
_gaugeTemp = new steelseries.Radial('canvas_temp', params); |
|
_gaugeTemp = new steelseries.Radial('canvas_temp', params); |
_gaugeTemp.setValue(_temp.value); |
|
_gaugeTemp.setValue(_temp.value); |
} |
|
} |
// add a shadow to the gauge |
|
// add a shadow to the gauge |
if (config.showGaugeShadow) { |
|
if (config.showGaugeShadow) { |
$('#canvas_temp').css(commonParams.boxShadow); |
|
$('#canvas_temp').css(commonParams.boxShadow); |
} |
|
} |
}, |
|
}, |
|
|
|
drawDew = function () { |
|
drawDew = function () { |
var params = extend(commonParams); |
|
var params = extend(commonParams); |
// create dew point radial gauge |
|
// create dew point radial gauge |
if ($('#canvas_dew').length) { |
|
if ($('#canvas_dew').length) { |
params.section = _dew.sections; |
|
params.section = _dew.sections; |
params.area = _dew.areas; |
|
params.area = _dew.areas; |
params.minValue = _dew.minValue; |
|
params.minValue = _dew.minValue; |
params.maxValue = _dew.maxValue; |
|
params.maxValue = _dew.maxValue; |
params.thresholdVisible = false; |
|
params.thresholdVisible = false; |
params.titleString = _dew.title; |
|
params.titleString = _dew.title; |
params.unitString = data.tempunit; |
|
params.unitString = data.tempunit; |
|
|
|
_gaugeDew = new steelseries.Radial('canvas_dew', params); |
|
_gaugeDew = new steelseries.Radial('canvas_dew', params); |
_gaugeDew.setValue(_dew.value); |
|
_gaugeDew.setValue(_dew.value); |
} |
|
} |
// add a shadow to the gauge |
|
// add a shadow to the gauge |
if (config.showGaugeShadow) { |
|
if (config.showGaugeShadow) { |
$('#canvas_dew').css(commonParams.boxShadow); |
|
$('#canvas_dew').css(commonParams.boxShadow); |
} |
|
} |
}, |
|
}, |
|
|
|
drawRain = function () { |
|
drawRain = function () { |
var params = extend(commonParams); |
|
var params = extend(commonParams); |
// create rain radial bargraph gauge |
|
// create rain radial bargraph gauge |
if ($('#canvas_rain').length) { |
|
if ($('#canvas_rain').length) { |
params.maxValue = _rain.maxValue; |
|
params.maxValue = _rain.maxValue; |
params.thresholdVisible = false; |
|
params.thresholdVisible = false; |
params.titleString = _rain.title; |
|
params.titleString = _rain.title; |
params.unitString = data.rainunit; |
|
params.unitString = data.rainunit; |
params.valueColor = gauge.pointerColour; |
|
params.valueColor = gauge.pointerColour; |
params.valueGradient = _rain.valGrad; |
|
params.valueGradient = _rain.valGrad; |
params.useValueGradient = gauge.rainUseGradientColours; |
|
params.useValueGradient = gauge.rainUseGradientColours; |
params.useSectionColors = gauge.rainUseSectionColour; |
|
params.useSectionColors = gauge.rainUseSectionColour; |
params.useSectionColors = gauge.rainUseSectionColours; |
|
params.useSectionColors = gauge.rainUseSectionColours; |
params.labelNumberFormat = _rain.labelNumberFormat; |
|
params.labelNumberFormat = _rain.labelNumberFormat; |
params.fractionalScaleDecimals = _rain.scaleDecimals; |
|
params.fractionalScaleDecimals = _rain.scaleDecimals; |
|
|
|
_gaugeRain = new steelseries.RadialBargraph('canvas_rain', params); |
|
_gaugeRain = new steelseries.RadialBargraph('canvas_rain', params); |
_gaugeRain.setValue(_rain.value); |
|
_gaugeRain.setValue(_rain.value); |
} |
|
} |
// add a shadow to the gauge |
|
// add a shadow to the gauge |
if (config.showGaugeShadow) { |
|
if (config.showGaugeShadow) { |
$('#canvas_rain').css(commonParams.boxShadow); |
|
$('#canvas_rain').css(commonParams.boxShadow); |
} |
|
} |
}, |
|
}, |
|
|
|
drawRRate = function () { |
|
drawRRate = function () { |
var params = extend(commonParams); |
|
var params = extend(commonParams); |
// create rain rate radial gauge |
|
// create rain rate radial gauge |
if ($('#canvas_rrate').length) { |
|
if ($('#canvas_rrate').length) { |
params.section = _rrate.sections; |
|
params.section = _rrate.sections; |
params.maxValue = _rrate.maxValue; |
|
params.maxValue = _rrate.maxValue; |
params.thresholdVisible = false; |
|
params.thresholdVisible = false; |
params.maxMeasuredValueVisible = true; |
|
params.maxMeasuredValueVisible = true; |
params.titleString = _rrate.title; |
|
params.titleString = _rrate.title; |
params.unitString = data.rainunit + '/h'; |
|
params.unitString = data.rainunit + '/h'; |
params.lcdDecimals = _rrate.lcdDecimals; |
|
params.lcdDecimals = _rrate.lcdDecimals; |
params.labelNumberFormat = _rrate.labelNumberFormat; |
|
params.labelNumberFormat = _rrate.labelNumberFormat; |
params.fractionalScaleDecimals = _rrate.scaleDecimals; |
|
params.fractionalScaleDecimals = _rrate.scaleDecimals; |
|
|
|
_gaugeRRate = new steelseries.Radial('canvas_rrate', params); |
|
_gaugeRRate = new steelseries.Radial('canvas_rrate', params); |
_gaugeRRate.setMaxMeasuredValue(_rrate.maxMeasured); |
|
_gaugeRRate.setMaxMeasuredValue(_rrate.maxMeasured); |
_gaugeRRate.setValue(_rrate.value); |
|
_gaugeRRate.setValue(_rrate.value); |
} |
|
} |
// add a shadow to the gauge |
|
// add a shadow to the gauge |
if (config.showGaugeShadow) { |
|
if (config.showGaugeShadow) { |
$('#canvas_rrate').css(commonParams.boxShadow); |
|
$('#canvas_rrate').css(commonParams.boxShadow); |
} |
|
} |
}, |
|
}, |
|
|
|
drawHum = function () { |
|
drawHum = function () { |
var params = extend(commonParams); |
|
var params = extend(commonParams); |
// create humidity radial gauge |
|
// create humidity radial gauge |
if ($('#canvas_hum').length) { |
|
if ($('#canvas_hum').length) { |
params.section = [steelseries.Section(0, 20, 'rgba(255,255,0,0.3)'), |
|
params.section = [steelseries.Section(0, 20, 'rgba(255,255,0,0.3)'), |
steelseries.Section(20, 80, 'rgba(0,255,0,0.3)'), |
|
steelseries.Section(20, 80, 'rgba(0,255,0,0.3)'), |
steelseries.Section(80, 100, 'rgba(255,0,0,0.3)')]; |
|
steelseries.Section(80, 100, 'rgba(255,0,0,0.3)')]; |
params.area = _hum.areas; |
|
params.area = _hum.areas; |
params.maxValue = 100; |
|
params.maxValue = 100; |
params.thresholdVisible = false; |
|
params.thresholdVisible = false; |
params.titleString = _hum.title; |
|
params.titleString = _hum.title; |
params.unitString = '%'; |
|
params.unitString = '%'; |
|
|
|
_gaugeHum = new steelseries.Radial('canvas_hum', params); |
|
_gaugeHum = new steelseries.Radial('canvas_hum', params); |
_gaugeHum.setValue(_hum.value); |
|
_gaugeHum.setValue(_hum.value); |
} |
|
} |
// add a shadow to the gauge |
|
// add a shadow to the gauge |
if (config.showGaugeShadow) { |
|
if (config.showGaugeShadow) { |
$('#canvas_hum').css(commonParams.boxShadow); |
|
$('#canvas_hum').css(commonParams.boxShadow); |
} |
|
} |
}, |
|
}, |
|
|
|
drawBaro = function () { |
|
drawBaro = function () { |
var params = extend(commonParams); |
|
var params = extend(commonParams); |
// create pressure/barometric radial gauge |
|
// create pressure/barometric radial gauge |
if ($('#canvas_baro').length) { |
|
if ($('#canvas_baro').length) { |
params.section = _baro.sections; |
|
params.section = _baro.sections; |
params.area = _baro.areas; |
|
params.area = _baro.areas; |
params.minValue = _baro.minValue; |
|
params.minValue = _baro.minValue; |
params.maxValue = _baro.maxValue; |
|
params.maxValue = _baro.maxValue; |
params.niceScale = false; |
|
params.niceScale = false; |
params.thresholdVisible = false; |
|
params.thresholdVisible = false; |
params.titleString = _baro.title; |
|
params.titleString = _baro.title; |
params.unitString = data.pressunit; |
|
params.unitString = data.pressunit; |
params.lcdDecimals = _baro.lcdDecimals; |
|
params.lcdDecimals = _baro.lcdDecimals; |
params.trendVisible = gauge.pressureTrendVisible; |
|
params.trendVisible = gauge.pressureTrendVisible; |
params.labelNumberFormat = _baro.labelNumberFormat; |
|
params.labelNumberFormat = _baro.labelNumberFormat; |
params.fractionalScaleDecimals = _baro.scaleDecimals; |
|
params.fractionalScaleDecimals = _baro.scaleDecimals; |
|
|
|
_gaugeBaro = new steelseries.Radial('canvas_baro', params); |
|
_gaugeBaro = new steelseries.Radial('canvas_baro', params); |
_gaugeBaro.setValue(_baro.value); |
|
_gaugeBaro.setValue(_baro.value); |
} |
|
} |
// add a shadow to the gauge |
|
// add a shadow to the gauge |
if (config.showGaugeShadow) { |
|
if (config.showGaugeShadow) { |
$('#canvas_baro').css(commonParams.boxShadow); |
|
$('#canvas_baro').css(commonParams.boxShadow); |
} |
|
} |
}, |
|
}, |
|
|
|
drawWind = function () { |
|
drawWind = function () { |
var params = extend(commonParams); |
|
var params = extend(commonParams); |
// create wind speed radial gauge |
|
// create wind speed radial gauge |
if ($('#canvas_wind').length) { |
|
if ($('#canvas_wind').length) { |
params.area = _wind.areas; |
|
params.area = _wind.areas; |
params.maxValue = _wind.maxValue; |
|
params.maxValue = _wind.maxValue; |
params.niceScale = false; |
|
params.niceScale = false; |
params.thresholdVisible = false; |
|
params.thresholdVisible = false; |
params.maxMeasuredValueVisible = true; |
|
params.maxMeasuredValueVisible = true; |
params.titleString = _wind.title; |
|
params.titleString = _wind.title; |
params.unitString = data.windunit; |
|
params.unitString = data.windunit; |
|
|
|
_gaugeWind = new steelseries.Radial('canvas_wind', params); |
|
_gaugeWind = new steelseries.Radial('canvas_wind', params); |
_gaugeWind.setMaxMeasuredValue(_wind.maxMeasured); |
|
_gaugeWind.setMaxMeasuredValue(_wind.maxMeasured); |
_gaugeWind.setValue(_wind.value); |
|
_gaugeWind.setValue(_wind.value); |
} |
|
} |
// add a shadow to the gauge |
|
// add a shadow to the gauge |
if (config.showGaugeShadow) { |
|
if (config.showGaugeShadow) { |
$('#canvas_wind').css(commonParams.boxShadow); |
|
$('#canvas_wind').css(commonParams.boxShadow); |
} |
|
} |
}, |
|
}, |
|
|
|
drawDir = function () { |
|
drawDir = function () { |
var params = extend(commonParams); |
|
var params = extend(commonParams); |
// create wind direction/compass radial gauge |
|
// create wind direction/compass radial gauge |
if ($('#canvas_dir').length) { |
|
if ($('#canvas_dir').length) { |
params.pointerTypeLatest = gauge.pointer; // default TYPE1, |
|
params.pointerTypeLatest = gauge.pointer; // default TYPE1, |
params.pointerTypeAverage = steelseries.PointerType.TYPE8; // default TYPE8 |
<> |
params.pointerTypeAverage = steelseries.PointerType.TYPE1; // default TYPE8 |
params.pointerColorAverage = steelseries.ColorDef.BLUE; |
|
params.pointerColorAverage = steelseries.ColorDef.RED; |
params.degreeScale = true; // Show degree scale rather than ordinal directions |
= |
params.degreeScale = true; // Show degree scale rather than ordinal directions |
params.pointSymbols = strings.compass; |
|
params.pointSymbols = strings.compass; |
params.roseVisible = false; |
|
params.roseVisible = false; |
params.lcdTitleStrings = _dir.titles; |
|
params.lcdTitleStrings = _dir.titles; |
params.useColorLabels = false; |
<> |
params.useColorLabels = true; |
|
= |
|
_gaugeDir = new steelseries.WindDirection('canvas_dir', params); |
|
_gaugeDir = new steelseries.WindDirection('canvas_dir', params); |
_gaugeDir.setValueAverage(+_dir.valueAverage); |
|
_gaugeDir.setValueAverage(+_dir.valueAverage); |
_gaugeDir.setValueLatest(+_dir.valueLatest); |
|
_gaugeDir.setValueLatest(+_dir.valueLatest); |
} |
|
} |
// add a shadow to the gauge |
|
// add a shadow to the gauge |
if (config.showGaugeShadow) { |
|
if (config.showGaugeShadow) { |
$('#canvas_dir').css(commonParams.boxShadow); |
|
$('#canvas_dir').css(commonParams.boxShadow); |
} |
|
} |
}, |
|
}, |
|
|
|
drawUV = function () { |
|
drawUV = function () { |
var params = extend(commonParams); |
|
var params = extend(commonParams); |
// create UV bargraph gauge |
|
// create UV bargraph gauge |
if ($('#canvas_uv').length) { |
|
if ($('#canvas_uv').length) { |
params.gaugeType = steelseries.GaugeType.TYPE3; |
<> |
params.gaugeType = steelseries.GaugeType.TYPE2; |
params.maxValue = gauge.uvScaleDefMax; |
= |
params.maxValue = gauge.uvScaleDefMax; |
params.titleString = _uv.title; |
|
params.titleString = _uv.title; |
params.niceScale = false; |
|
params.niceScale = false; |
params.section = _uv.sections; |
|
params.section = _uv.sections; |
params.useSectionColors = _uv.useSections; |
|
params.useSectionColors = _uv.useSections; |
params.lcdDecimals = gauge.uvLcdDecimals; |
|
params.lcdDecimals = gauge.uvLcdDecimals; |
|
|
|
_gaugeUV = new steelseries.RadialBargraph('canvas_uv', params); |
|
_gaugeUV = new steelseries.RadialBargraph('canvas_uv', params); |
_gaugeUV.setValue(_uv.value); |
|
_gaugeUV.setValue(_uv.value); |
} |
|
} |
// add a shadow to the gauge |
|
// add a shadow to the gauge |
if (config.showGaugeShadow) { |
|
if (config.showGaugeShadow) { |
$('#canvas_uv').css(commonParams.boxShadow); |
|
$('#canvas_uv').css(commonParams.boxShadow); |
} |
|
} |
}, |
|
}, |
|
|
|
drawSolar = function () { |
|
drawSolar = function () { |
var params = extend(commonParams); |
|
var params = extend(commonParams); |
// create Solar gauge |
|
// create Solar gauge |
if ($('#canvas_solar').length) { |
|
if ($('#canvas_solar').length) { |
params.section = _solar.sections; |
|
params.section = _solar.sections; |
params.maxValue = _solar.maxValue; |
|
params.maxValue = _solar.maxValue; |
params.titleString = _solar.title; |
|
params.titleString = _solar.title; |
params.unitString = _solar.units; |
|
params.unitString = _solar.units; |
params.niceScale = false; |
|
params.niceScale = false; |
params.thresholdVisible = false; |
|
params.thresholdVisible = false; |
params.lcdDecimals = _solar.lcdDecimals; |
|
params.lcdDecimals = _solar.lcdDecimals; |
|
|
|
_gaugeSolar = new steelseries.Radial('canvas_solar', params); |
|
_gaugeSolar = new steelseries.Radial('canvas_solar', params); |
_gaugeSolar.setValue(_solar.value); |
|
_gaugeSolar.setValue(_solar.value); |
} |
|
} |
// add a shadow to the gauge |
|
// add a shadow to the gauge |
if (config.showGaugeShadow) { |
|
if (config.showGaugeShadow) { |
$('#canvas_solar').css(commonParams.boxShadow); |
|
$('#canvas_solar').css(commonParams.boxShadow); |
} |
|
} |
}, |
|
}, |
|
|
|
// |
|
// |
// doUpdate() called to update all the gauges with fresh data, then start the timer for the next update |
|
// doUpdate() called to update all the gauges with fresh data, then start the timer for the next update |
// |
|
// |
doUpdate = function () { |
|
doUpdate = function () { |
// first time only, setup units etc |
|
// first time only, setup units etc |
if (_firstRun) { |
|
if (_firstRun) { |
doFirst(); |
|
doFirst(); |
} |
|
} |
|
|
|
if (_refreshGraphs) { |
|
if (_refreshGraphs) { |
_cacheDefeat = '?' + (new Date()).getTime().toString(); |
|
_cacheDefeat = '?' + (new Date()).getTime().toString(); |
} |
|
} |
if (_gaugeTemp) { |
|
if (_gaugeTemp) { |
doTemp(); |
|
doTemp(); |
} |
|
} |
if (_gaugeDew) { |
|
if (_gaugeDew) { |
doDew(); |
|
doDew(); |
} |
|
} |
if (_gaugeBaro) { |
|
if (_gaugeBaro) { |
doBaro(); |
|
doBaro(); |
} |
|
} |
if (_gaugeRain) { |
|
if (_gaugeRain) { |
doRain(); |
|
doRain(); |
} |
|
} |
if (_gaugeRRate) { |
|
if (_gaugeRRate) { |
doRRate(); |
|
doRRate(); |
} |
|
} |
if (_gaugeHum) { |
|
if (_gaugeHum) { |
doHum(); |
|
doHum(); |
} |
|
} |
if (_gaugeWind) { |
|
if (_gaugeWind) { |
doWind(); |
|
doWind(); |
} |
|
} |
if (_gaugeDir) { |
|
if (_gaugeDir) { |
doDir(); |
|
doDir(); |
} |
|
} |
if (_gaugeUV) { |
|
if (_gaugeUV) { |
doUV(); |
|
doUV(); |
} |
|
} |
if (_gaugeSolar) { |
|
if (_gaugeSolar) { |
doSolar(); |
|
doSolar(); |
} |
|
} |
if (config.showRoseGauge && typeof radar !== "undefined") { |
|
if (config.showRoseGauge && typeof radar !== "undefined") { |
doRose(); |
|
doRose(); |
} |
|
} |
if (_refreshGraphs) { |
|
if (_refreshGraphs) { |
_refreshGraphs = false; |
|
_refreshGraphs = false; |
} |
|
} |
|
|
|
if (_firstRun && config.showPopupData && config.showPopupGraphs) { |
|
if (_firstRun && config.showPopupData && config.showPopupGraphs) { |
// now download the trend images |
|
// now download the trend images |
// - has to be done here as doFirst may remove elements from the page |
|
// - has to be done here as doFirst may remove elements from the page |
// - and we delay the download of the images speeding up page display |
|
// - and we delay the download of the images speeding up page display |
// |
|
// |
$('#imgtip0_img').attr('src', config.imgPathURL + config.tipImgs[0][0] + _cacheDefeat); |
|
$('#imgtip0_img').attr('src', config.imgPathURL + config.tipImgs[0][0] + _cacheDefeat); |
$('#imgtip1_img').attr('src', config.imgPathURL + config.tipImgs[1][_dew.image] + _cacheDefeat); |
|
$('#imgtip1_img').attr('src', config.imgPathURL + config.tipImgs[1][_dew.image] + _cacheDefeat); |
$('#imgtip2_img').attr('src', config.imgPathURL + config.tipImgs[2] + _cacheDefeat); |
|
$('#imgtip2_img').attr('src', config.imgPathURL + config.tipImgs[2] + _cacheDefeat); |
$('#imgtip3_img').attr('src', config.imgPathURL + config.tipImgs[3] + _cacheDefeat); |
|
$('#imgtip3_img').attr('src', config.imgPathURL + config.tipImgs[3] + _cacheDefeat); |
$('#imgtip4_img').attr('src', config.imgPathURL + config.tipImgs[4][0] + _cacheDefeat); |
|
$('#imgtip4_img').attr('src', config.imgPathURL + config.tipImgs[4][0] + _cacheDefeat); |
$('#imgtip5_img').attr('src', config.imgPathURL + config.tipImgs[5] + _cacheDefeat); |
|
$('#imgtip5_img').attr('src', config.imgPathURL + config.tipImgs[5] + _cacheDefeat); |
$('#imgtip6_img').attr('src', config.imgPathURL + config.tipImgs[6] + _cacheDefeat); |
|
$('#imgtip6_img').attr('src', config.imgPathURL + config.tipImgs[6] + _cacheDefeat); |
$('#imgtip7_img').attr('src', config.imgPathURL + config.tipImgs[7] + _cacheDefeat); |
|
$('#imgtip7_img').attr('src', config.imgPathURL + config.tipImgs[7] + _cacheDefeat); |
$('#imgtip8_img').attr('src', config.imgPathURL + config.tipImgs[8] + _cacheDefeat); |
|
$('#imgtip8_img').attr('src', config.imgPathURL + config.tipImgs[8] + _cacheDefeat); |
$('#imgtip9_img').attr('src', config.imgPathURL + config.tipImgs[9] + _cacheDefeat); |
|
$('#imgtip9_img').attr('src', config.imgPathURL + config.tipImgs[9] + _cacheDefeat); |
$('#imgtip10_img').attr('src', config.imgPathURL + config.tipImgs[10] + _cacheDefeat); |
|
$('#imgtip10_img').attr('src', config.imgPathURL + config.tipImgs[10] + _cacheDefeat); |
// kick off a timer for popup graphic updates |
|
// kick off a timer for popup graphic updates |
setInterval(function () { |
|
setInterval(function () { |
_refreshGraphs = true; |
|
_refreshGraphs = true; |
}, |
|
}, |
config.graphUpdateTime * 60 * 1000); |
|
config.graphUpdateTime * 60 * 1000); |
|
|
|
} |
|
} |
if (_firstRun) { |
|
if (_firstRun) { |
_firstRun = false; |
|
_firstRun = false; |
} |
|
} |
_count = config.counter; |
|
_count = config.counter; |
countDown(); |
|
countDown(); |
}, |
|
}, |
|
|
|
// |
|
// |
// getRealtime() fetches the realtimegauges.txt file from the server |
|
// getRealtime() fetches the realtimegauges.txt file from the server |
// |
|
// |
getRealtime = function () { |
|
getRealtime = function () { |
setStatus(strings.StatusMsg); |
|
setStatus(strings.StatusMsg); |
_count = 11; // 10 seconds timeout |
|
_count = 11; // 10 seconds timeout |
countDown(); |
|
countDown(); |
$.ajax({url: config.realTimeURL, |
|
$.ajax({url: config.realTimeURL, |
dataType: 'text', |
|
dataType: 'text', |
cache: false, |
|
cache: false, |
success: checkRtResp, |
|
success: checkRtResp, |
error: checkRtError, |
|
error: checkRtError, |
timeout: 10000 |
|
timeout: 10000 |
}); |
|
}); |
}, |
|
}, |
|
|
|
// |
|
// |
// checkRtResp() called by the Ajax fetch once data has been downloaded |
|
// checkRtResp() called by the Ajax fetch once data has been downloaded |
// |
|
// |
checkRtResp = function (response, status, xhr) { |
|
checkRtResp = function (response, status, xhr) { |
countDown(true); |
|
countDown(true); |
response = response.replace(/[\r\n]/g, ''); |
|
response = response.replace(/[\r\n]/g, ''); |
_httpError = 0; |
|
_httpError = 0; |
processData(response); |
|
processData(response); |
}, |
|
}, |
|
|
|
// |
|
// |
// checkRtError() called by the Ajax fetch if an error occurs during the fetching realtimegauges.txt |
|
// checkRtError() called by the Ajax fetch if an error occurs during the fetching realtimegauges.txt |
// |
|
// |
checkRtError = function (xhr, status, error) { |
|
checkRtError = function (xhr, status, error) { |
// Clear any existing download timer |
|
// Clear any existing download timer |
clearTimeout(_countDownTimer); |
|
clearTimeout(_countDownTimer); |
setLed(false, strings.led_title_unknown); |
|
setLed(false, strings.led_title_unknown); |
_httpError = status + ': ' + error; |
|
_httpError = status + ': ' + error; |
_count = 11; // 10 seconds |
|
_count = 11; // 10 seconds |
countDown(); |
|
countDown(); |
}, |
|
}, |
|
|
|
// |
|
// |
// processData() massages the data returned in realtimegauges.txt, and calls doUpdate() to update the page |
|
// processData() massages the data returned in realtimegauges.txt, and calls doUpdate() to update the page |
// |
|
// |
processData = function (dataStr) { |
|
processData = function (dataStr) { |
var str, dt, tm, today, now, then, tmp, elapsedMins; |
<> |
var str, dt, tm, today, now, then, tmp, mytempvar, elapsedMins; |
// get the realtime fields into a handy 'data' object |
= |
// get the realtime fields into a handy 'data' object |
try { |
|
try { |
data = JSON.parse(dataStr); |
|
data = JSON.parse(dataStr); |
} catch (e) { |
|
} catch (e) { |
// JSON parse bombs if the file is zero length, |
|
// JSON parse bombs if the file is zero length, |
// so start a quickish retry... |
|
// so start a quickish retry... |
setStatus(strings.realtimeCorrupt); |
|
setStatus(strings.realtimeCorrupt); |
_count = 3; // 2 seconds |
|
_count = 3; // 2 seconds |
countDown(); |
|
countDown(); |
return; |
|
return; |
} |
|
} |
// and check we have the expected number |
|
// and check we have the expected number |
if (data.ver !== undefined && data.ver >= _realtimeVer) { |
|
if (data.ver !== undefined && data.ver >= _realtimeVer) { |
// OK, we have the expected number of data fields |
|
// OK, we have the expected number of data fields |
|
|
|
// mainpulate the last rain time into something more friendly |
|
// mainpulate the last rain time into something more friendly |
try { |
|
try { |
str = data.LastRainTipISO.split(' '); |
|
str = data.LastRainTipISO.split(' '); |
dt = str[0].replace(/\//g, '-').split('-'); // WD uses dd/mm/yyyy :( |
|
dt = str[0].replace(/\//g, '-').split('-'); // WD uses dd/mm/yyyy :( |
tm = str[1].split(':'); |
|
tm = str[1].split(':'); |
today = new Date(); |
|
today = new Date(); |
today.setHours(0, 0, 0, 0); |
|
today.setHours(0, 0, 0, 0); |
if (data.dateFormat === undefined) { |
|
if (data.dateFormat === undefined) { |
data.dateFormat = 'y/m/d'; |
|
data.dateFormat = 'y/m/d'; |
} else { |
|
} else { |
// frig for WD bug which leaves a trailing % character from the tag |
|
// frig for WD bug which leaves a trailing % character from the tag |
data.dateFormat = data.dateFormat.replace('%', ''); |
|
data.dateFormat = data.dateFormat.replace('%', ''); |
} |
|
} |
if (data.dateFormat === 'y/m/d') { |
|
if (data.dateFormat === 'y/m/d') { |
// ISO/Cumulus format |
|
// ISO/Cumulus format |
then = new Date(dt[0], dt[1] - 1, dt[2], tm[0], tm[1], 0, 0); |
|
then = new Date(dt[0], dt[1] - 1, dt[2], tm[0], tm[1], 0, 0); |
} else if (data.dateFormat === 'd/m/y') { |
|
} else if (data.dateFormat === 'd/m/y') { |
then = new Date(dt[2], dt[1] - 1, dt[0], tm[0], tm[1], 0, 0); |
|
then = new Date(dt[2], dt[1] - 1, dt[0], tm[0], tm[1], 0, 0); |
} else { // m/d/y |
|
} else { // m/d/y |
then = new Date(dt[2], dt[0] - 1, dt[1], tm[0], tm[1], 0, 0); |
|
then = new Date(dt[2], dt[0] - 1, dt[1], tm[0], tm[1], 0, 0); |
} |
|
} |
if (then.getTime() >= today.getTime()) { |
|
if (then.getTime() >= today.getTime()) { |
data.LastRained = strings.LastRainedT_info + ' ' + str[1]; |
|
data.LastRained = strings.LastRainedT_info + ' ' + str[1]; |
} else if (then.getTime() + 86400000 >= today.getTime()) { |
|
} else if (then.getTime() + 86400000 >= today.getTime()) { |
data.LastRained = strings.LastRainedY_info + ' ' + str[1]; |
|
data.LastRained = strings.LastRainedY_info + ' ' + str[1]; |
} else { |
|
} else { |
data.LastRained = then.getDate().toString() + ' ' + strings.months[then.getMonth()] + ' ' + strings.at + ' ' + str[1]; |
|
data.LastRained = then.getDate().toString() + ' ' + strings.months[then.getMonth()] + ' ' + strings.at + ' ' + str[1]; |
} |
|
} |
} catch (e) { |
|
} catch (e) { |
data.LastRained = data.LastRainTipISO; |
|
data.LastRained = data.LastRainTipISO; |
} |
|
} |
// clean up temperature units - remove html encoding |
|
// clean up temperature units - remove html encoding |
if (data.tempunit.length > 1) { |
|
if (data.tempunit.length > 1) { |
// clean up temperature units - remove html encoding |
|
// clean up temperature units - remove html encoding |
// using old format realtimegaugesT.txt |
|
// using old format realtimegaugesT.txt |
data.tempunit.replace('°', '°'); |
<> |
data.tempunit = data.tempunit.replace('°', '°'); |
|
|
if (config.weatherProgram === 3){ |
|
|
data.tempunit = data.tempunit.replace('°', '°'); // This HTML encoding is used by WeatherCat |
|
|
} |
} else { |
= |
} else { |
// using new realtimegaugesT.txt with Cumulus > 1.9.2 |
|
// using new realtimegaugesT.txt with Cumulus > 1.9.2 |
data.tempunit = '°' + data.tempunit; |
|
data.tempunit = '°' + data.tempunit; |
} |
|
} |
|
|
|
// Check for station off-line |
|
// Check for station off-line |
now = new Date(); |
|
now = new Date(); |
|
-+ |
//var nowUtc = new Date( now.getTime() + (now.getTimezoneOffset() * 60000)); |
tmp = data.timeUTC.split(','); |
= |
tmp = data.timeUTC.split(','); |
_sampleDate = Date.UTC(tmp[0], tmp[1] - 1, tmp[2], tmp[3], tmp[4], tmp[5]); |
|
_sampleDate = Date.UTC(tmp[0], tmp[1] - 1, tmp[2], tmp[3], tmp[4], tmp[5]); |
if (now - _sampleDate > config.stationTimeout * 60 * 1000) { |
|
if (now - _sampleDate > config.stationTimeout * 60 * 1000) { |
elapsedMins = Math.floor((now - _sampleDate) / (1000 * 60)); |
|
elapsedMins = Math.floor((now - _sampleDate) / (1000 * 60)); |
// the realtimegauges.txt file isn't being updated |
|
// the realtimegauges.txt file isn't being updated |
_led.colour = steelseries.LedColor.RED_LED; |
|
_led.colour = steelseries.LedColor.RED_LED; |
_led.title = strings.led_title_offline; |
|
_led.title = strings.led_title_offline; |
if (elapsedMins < 120) { |
|
if (elapsedMins < 120) { |
// up to 2 hours ago |
|
// up to 2 hours ago |
tm = elapsedMins.toString() + ' ' + strings.StatusMinsAgo; |
|
tm = elapsedMins.toString() + ' ' + strings.StatusMinsAgo; |
} else if (elapsedMins < 2 * 24 * 60) { |
|
} else if (elapsedMins < 2 * 24 * 60) { |
// up to 48 hours ago |
|
// up to 48 hours ago |
tm = Math.floor(elapsedMins / 60).toString() + ' ' + strings.StatusHoursAgo; |
|
tm = Math.floor(elapsedMins / 60).toString() + ' ' + strings.StatusHoursAgo; |
} else { |
|
} else { |
// days ago! |
|
// days ago! |
tm = Math.floor(elapsedMins / (60 * 24)).toString() + ' ' + strings.StatusDaysAgo; |
|
tm = Math.floor(elapsedMins / (60 * 24)).toString() + ' ' + strings.StatusDaysAgo; |
} |
|
} |
_led.blink = true; |
|
_led.blink = true; |
data.forecast = strings.led_title_offline + ' ' + strings.StatusLastUpdate + ' ' + tm; |
|
data.forecast = strings.led_title_offline + ' ' + strings.StatusLastUpdate + ' ' + tm; |
} else if (+data.SensorContactLost === 1) { |
|
} else if (+data.SensorContactLost === 1) { |
// Fine Offset sensor status |
|
// Fine Offset sensor status |
_led.colour = steelseries.LedColor.RED_LED; |
|
_led.colour = steelseries.LedColor.RED_LED; |
_led.title = strings.led_title_lost; |
|
_led.title = strings.led_title_lost; |
_led.blink = true; |
|
_led.blink = true; |
data.forecast = strings.led_title_lost; |
|
data.forecast = strings.led_title_lost; |
} else { |
|
} else { |
_led.colour = steelseries.LedColor.GREEN_LED; |
|
_led.colour = steelseries.LedColor.GREEN_LED; |
_led.title = strings.led_title_ok + '. ' + strings.StatusLastUpdate + ': ' + data.date; |
|
_led.title = strings.led_title_ok + '. ' + strings.StatusLastUpdate + ': ' + data.date; |
_led.blink = false; |
|
_led.blink = false; |
} |
|
} |
|
|
|
// de-encode the forecast string if required (Cumulus support for extended characters) |
|
// de-encode the forecast string if required (Cumulus support for extended characters) |
data.forecast = $('<div/>').html(data.forecast).text(); |
|
data.forecast = $('<div/>').html(data.forecast).text(); |
data.forecast.trim(); |
|
data.forecast.trim(); |
|
|
|
if (data.pressunit === 'in') { // Cumulus pressunit tag value |
|
if (data.pressunit === 'in') { // Cumulus pressunit tag value |
data.pressunit = 'inHg'; |
|
data.pressunit = 'inHg'; |
} |
|
} |
|
|
|
if (data.windunit === 'kmh') { // WD wind unit omits '/' |
|
if (data.windunit === 'kmh') { // WD wind unit omits '/' |
data.windunit = 'km/h'; |
|
data.windunit = 'km/h'; |
} |
|
} |
|
|
|
// Temperature data conversion for display required? |
|
// Temperature data conversion for display required? |
if (data.tempunit.indexOf(_displayUnits.temp) === -1 && _userUnitsSet) { |
|
if (data.tempunit.indexOf(_displayUnits.temp) === -1 && _userUnitsSet) { |
// temp needs converting |
|
// temp needs converting |
if (data.tempunit.indexOf('C') !== -1) { |
|
if (data.tempunit.indexOf('C') !== -1) { |
convTempData(c2f); |
|
convTempData(c2f); |
} else { |
|
} else { |
convTempData(f2c); |
|
convTempData(f2c); |
} |
|
} |
} else if (_firstRun) { |
|
} else if (_firstRun) { |
_displayUnits.temp = data.tempunit.indexOf('C') === -1 ? 'F' : 'C'; |
|
_displayUnits.temp = data.tempunit.indexOf('C') === -1 ? 'F' : 'C'; |
setRadioCheck('rad_unitsTemp', _displayUnits.temp); |
|
setRadioCheck('rad_unitsTemp', _displayUnits.temp); |
} |
|
} |
|
|
|
// Rain data conversion for display required? |
|
// Rain data conversion for display required? |
if (data.rainunit !== _displayUnits.rain && _userUnitsSet) { |
|
if (data.rainunit !== _displayUnits.rain && _userUnitsSet) { |
// rain needs converting |
|
// rain needs converting |
convRainData(_displayUnits.rain === 'mm' ? in2mm : mm2in); |
|
convRainData(_displayUnits.rain === 'mm' ? in2mm : mm2in); |
} else if (_firstRun) { |
|
} else if (_firstRun) { |
_displayUnits.rain = data.rainunit; |
|
_displayUnits.rain = data.rainunit; |
setRadioCheck('rad_unitsRain', _displayUnits.rain); |
|
setRadioCheck('rad_unitsRain', _displayUnits.rain); |
} |
|
} |
|
|
|
// Wind data conversion for display required? |
|
// Wind data conversion for display required? |
if (data.windunit !== _displayUnits.wind && _userUnitsSet) { |
|
if (data.windunit !== _displayUnits.wind && _userUnitsSet) { |
// rain needs converting |
|
// rain needs converting |
convWindData(data.windunit, _displayUnits.wind); |
|
convWindData(data.windunit, _displayUnits.wind); |
} else if (_firstRun) { |
|
} else if (_firstRun) { |
_displayUnits.wind = data.windunit; |
|
_displayUnits.wind = data.windunit; |
_displayUnits.windrun = getWindrunUnits(data.windunit); |
|
_displayUnits.windrun = getWindrunUnits(data.windunit); |
setRadioCheck('rad_unitsWind', _displayUnits.wind); |
|
setRadioCheck('rad_unitsWind', _displayUnits.wind); |
} |
|
} |
|
|
|
// Pressure data conversion for display required? |
|
// Pressure data conversion for display required? |
if (data.pressunit !== _displayUnits.press && _userUnitsSet) { |
|
if (data.pressunit !== _displayUnits.press && _userUnitsSet) { |
convBaroData(data.pressunit, _displayUnits.press); |
|
convBaroData(data.pressunit, _displayUnits.press); |
} else if (_firstRun) { |
|
} else if (_firstRun) { |
_displayUnits.press = data.pressunit; |
|
_displayUnits.press = data.pressunit; |
setRadioCheck('rad_unitsPress', _displayUnits.press); |
|
setRadioCheck('rad_unitsPress', _displayUnits.press); |
} |
|
} |
|
|
|
setLed(true, _led.title); |
|
setLed(true, _led.title); |
setStatus(data.forecast); |
|
setStatus(data.forecast); |
doUpdate(); |
|
doUpdate(); |
|
|
|
} else { |
|
} else { |
// set an error message |
|
// set an error message |
if (data.ver < _realtimeVer) { |
|
if (data.ver < _realtimeVer) { |
_gaugeTimer.setValue(0); |
|
_gaugeTimer.setValue(0); |
setStatus('Your ' + config.realTimeURL.substr(config.realTimeURL.lastIndexOf('/') + 1) + ' file template needs updating!'); |
|
setStatus('Your ' + config.realTimeURL.substr(config.realTimeURL.lastIndexOf('/') + 1) + ' file template needs updating!'); |
return; |
|
return; |
} else { |
|
} else { |
// oh-oh! The number of data fields isn't what we expected |
|
// oh-oh! The number of data fields isn't what we expected |
setStatus(strings.realtimeCorrupt); |
|
setStatus(strings.realtimeCorrupt); |
} |
|
} |
setLed(false, strings.led_title_unknown); |
|
setLed(false, strings.led_title_unknown); |
_count = 4; // 3 second retry |
|
_count = 4; // 3 second retry |
countDown(); |
|
countDown(); |
} |
|
} |
}, |
|
}, |
|
|
|
// |
|
// |
// setStatus() applies the supplied string to the status LCD display |
|
// setStatus() applies the supplied string to the status LCD display |
// |
|
// |
setStatus = function (str) { |
|
setStatus = function (str) { |
_statusStr = str; |
|
_statusStr = str; |
if (_gaugeStatus) { |
|
if (_gaugeStatus) { |
_gaugeStatus.setValue(str); |
|
_gaugeStatus.setValue(str); |
} |
|
} |
}, |
|
}, |
|
|
|
// |
|
// |
// setLed() sets the warning LED state and popup text |
|
// setLed() sets the warning LED state and popup text |
// |
|
// |
setLed = function (onOff, title) { |
|
setLed = function (onOff, title) { |
_led.title = title || _led.title; |
|
_led.title = title || _led.title; |
if (_gaugeLed) { |
|
if (_gaugeLed) { |
_gaugeLed.setLedOnOff(onOff); |
|
_gaugeLed.setLedOnOff(onOff); |
if ($('#canvas_led').length) { |
|
if ($('#canvas_led').length) { |
$('#canvas_led').attr('title', _led.title); |
|
$('#canvas_led').attr('title', _led.title); |
} |
|
} |
if (_led.colour !== _led.oldColour) { |
|
if (_led.colour !== _led.oldColour) { |
_gaugeLed.setLedColor(_led.colour); |
|
_gaugeLed.setLedColor(_led.colour); |
_led.oldColour = _led.colour; |
|
_led.oldColour = _led.colour; |
} |
|
} |
if (_led.blink !== _led.oldBlink) { |
|
if (_led.blink !== _led.oldBlink) { |
_gaugeLed.blink(_led.blink); |
|
_gaugeLed.blink(_led.blink); |
_led.oldBlink = _led.blink; |
|
_led.oldBlink = _led.blink; |
} |
|
} |
} |
|
} |
}, |
|
}, |
|
|
|
// |
|
// |
// countDown() updates the countdown LCD display, and if the count reaches zero fires off a new Ajax update |
|
// countDown() updates the countdown LCD display, and if the count reaches zero fires off a new Ajax update |
// |
|
// |
countDown = function (stop) { |
|
countDown = function (stop) { |
if (stop !== undefined && stop) { |
|
if (stop !== undefined && stop) { |
clearTimeout(_countDownTimer); |
|
clearTimeout(_countDownTimer); |
_count = 0; |
|
_count = 0; |
_gaugeTimer.setValue(_count); |
|
_gaugeTimer.setValue(_count); |
return; |
|
return; |
} |
|
} |
// has the page update limit been reached - and no password supplied |
|
// has the page update limit been reached - and no password supplied |
var now = new Date(); |
|
var now = new Date(); |
if (stop === false) { |
|
if (stop === false) { |
// we are being called from the LED onClick event, so reset the time the page was loaded |
|
// we are being called from the LED onClick event, so reset the time the page was loaded |
_pageLoaded = now; |
|
_pageLoaded = now; |
} |
|
} |
if (config.pageUpdateLimit > 0 && |
|
if (config.pageUpdateLimit > 0 && |
now > _pageLoaded.getTime() + config.pageUpdateLimit * 60000 && |
|
now > _pageLoaded.getTime() + config.pageUpdateLimit * 60000 && |
_pageUpdateParam !== config.pageUpdatePswd) |
|
_pageUpdateParam !== config.pageUpdatePswd) |
{ |
|
{ |
setStatus(strings.StatusPageLimit); |
|
setStatus(strings.StatusPageLimit); |
_led.colour = steelseries.LedColor.RED_LED; |
|
_led.colour = steelseries.LedColor.RED_LED; |
_led.title = strings.StatusPageLimit; |
|
_led.title = strings.StatusPageLimit; |
_led.blink = true; |
|
_led.blink = true; |
setLed(true); |
|
setLed(true); |
_count = 1; |
|
_count = 1; |
_gaugeTimer.setValue(0); |
|
_gaugeTimer.setValue(0); |
// set an onclick event on the LED to restart |
|
// set an onclick event on the LED to restart |
$('#canvas_led').click(function () { |
|
$('#canvas_led').click(function () { |
// refresh the page data |
|
// refresh the page data |
gauges.countDown(false); |
|
gauges.countDown(false); |
// and disable the onClick event again |
|
// and disable the onClick event again |
$('#canvas_led').off('click'); |
|
$('#canvas_led').off('click'); |
} |
|
} |
); |
|
); |
// and stop |
|
// and stop |
return; |
|
return; |
} |
|
} |
_count -= 1; |
|
_count -= 1; |
if (_gaugeTimer) { |
|
if (_gaugeTimer) { |
_gaugeTimer.setValue(_count); |
|
_gaugeTimer.setValue(_count); |
} |
|
} |
if (_count === 0) { |
|
if (_count === 0) { |
getRealtime(); |
|
getRealtime(); |
_count = config.counter; |
|
_count = config.counter; |
} else { |
|
} else { |
_countDownTimer = setTimeout(countDown, 1000); |
|
_countDownTimer = setTimeout(countDown, 1000); |
if (_httpError !== 0) { |
|
if (_httpError !== 0) { |
setStatus(strings.StatusHttp + ' - ' + _httpError + ' - ' + strings.StatusRetryIn); |
|
setStatus(strings.StatusHttp + ' - ' + _httpError + ' - ' + strings.StatusRetryIn); |
} |
|
} |
} |
|
} |
}, |
|
}, |
|
|
|
// |
|
// |
// doXXXXX() functions update each relevant gauge with the latest information |
|
// doXXXXX() functions update each relevant gauge with the latest information |
// |
|
// |
doTemp = function (radio) { |
|
doTemp = function (radio) { |
// if rad isn't specified, just use existing value |
|
// if rad isn't specified, just use existing value |
var sel = (radio === undefined ? _temp.selected : radio.value), |
|
var sel = (radio === undefined ? _temp.selected : radio.value), |
popupImg, t1, |
|
popupImg, t1, |
scaleStep, tip; |
|
scaleStep, tip; |
|
|
|
if (sel === 'out') { |
|
if (sel === 'out') { |
_temp.minValue = data.tempunit.indexOf('C') !== -1 ? gauge.tempScaleDefMinC : gauge.tempScaleDefMinF; |
|
_temp.minValue = data.tempunit.indexOf('C') !== -1 ? gauge.tempScaleDefMinC : gauge.tempScaleDefMinF; |
_temp.maxValue = data.tempunit.indexOf('C') !== -1 ? gauge.tempScaleDefMaxC : gauge.tempScaleDefMaxF; |
|
_temp.maxValue = data.tempunit.indexOf('C') !== -1 ? gauge.tempScaleDefMaxC : gauge.tempScaleDefMaxF; |
_temp.low = extractDecimal(data.tempTL); |
|
_temp.low = extractDecimal(data.tempTL); |
_temp.lowScale = getMinTemp(); |
|
_temp.lowScale = getMinTemp(); |
_temp.high = extractDecimal(data.tempTH); |
|
_temp.high = extractDecimal(data.tempTH); |
_temp.highScale = getMaxTemp(); |
|
_temp.highScale = getMaxTemp(); |
_temp.value = extractDecimal(data.temp); |
|
_temp.value = extractDecimal(data.temp); |
_temp.title = strings.temp_title_out; |
|
_temp.title = strings.temp_title_out; |
_temp.loc = strings.temp_out_info; |
|
_temp.loc = strings.temp_out_info; |
popupImg = 0; |
|
popupImg = 0; |
_temp.trendVal = extractDecimal(data.temptrend); |
|
_temp.trendVal = extractDecimal(data.temptrend); |
if (gauge.tempTrendVisible) { |
|
if (gauge.tempTrendVisible) { |
t1 = tempTrend(+_temp.trendVal, data.tempunit, false); |
|
t1 = tempTrend(+_temp.trendVal, data.tempunit, false); |
if (t1 > 0) { |
|
if (t1 > 0) { |
_temp.trend = steelseries.TrendState.UP; |
|
_temp.trend = steelseries.TrendState.UP; |
} else if (t1 < 0) { |
|
} else if (t1 < 0) { |
_temp.trend = steelseries.TrendState.DOWN; |
|
_temp.trend = steelseries.TrendState.DOWN; |
} else { |
|
} else { |
_temp.trend = steelseries.TrendState.STEADY; |
|
_temp.trend = steelseries.TrendState.STEADY; |
} |
|
} |
} |
|
} |
} else { |
|
} else { |
_temp.low = extractDecimal(data.intemp); |
|
_temp.low = extractDecimal(data.intemp); |
_temp.lowScale = _temp.low; |
|
_temp.lowScale = _temp.low; |
_temp.high = _temp.low; |
|
_temp.high = _temp.low; |
_temp.highScale = _temp.low; |
|
_temp.highScale = _temp.low; |
_temp.value = _temp.low; |
|
_temp.value = _temp.low; |
_temp.title = strings.temp_title_in; |
|
_temp.title = strings.temp_title_in; |
_temp.loc = strings.temp_in_info; |
|
_temp.loc = strings.temp_in_info; |
popupImg = 1; |
|
popupImg = 1; |
_temp.maxMinVisible = false; |
|
_temp.maxMinVisible = false; |
if (gauge.tempTrendVisible) { |
|
if (gauge.tempTrendVisible) { |
_temp.trend = steelseries.TrendState.OFF; |
|
_temp.trend = steelseries.TrendState.OFF; |
} |
|
} |
} |
|
} |
|
|
|
// has the gauge type changed? |
|
// has the gauge type changed? |
if (_temp.selected !== sel) { |
|
if (_temp.selected !== sel) { |
_temp.selected = sel; |
|
_temp.selected = sel; |
//Change gauge title |
|
//Change gauge title |
_gaugeTemp.setTitleString(_temp.title); |
|
_gaugeTemp.setTitleString(_temp.title); |
_gaugeTemp.setMaxMeasuredValueVisible(_temp.maxMinVisible); |
|
_gaugeTemp.setMaxMeasuredValueVisible(_temp.maxMinVisible); |
_gaugeTemp.setMinMeasuredValueVisible(_temp.maxMinVisible); |
|
_gaugeTemp.setMinMeasuredValueVisible(_temp.maxMinVisible); |
if (config.showPopupGraphs && config.tipImgs[0][0] !== null) { |
|
if (config.showPopupGraphs && config.tipImgs[0][0] !== null) { |
$('#imgtip0_img').attr('src', config.imgPathURL + config.tipImgs[0][popupImg] + _cacheDefeat); |
|
$('#imgtip0_img').attr('src', config.imgPathURL + config.tipImgs[0][popupImg] + _cacheDefeat); |
} |
|
} |
} |
|
} |
|
|
|
//auto scale the ranges |
|
//auto scale the ranges |
if (data.tempunit.indexOf('C') !== -1) { |
|
if (data.tempunit.indexOf('C') !== -1) { |
scaleStep = 10; |
|
scaleStep = 10; |
} else { |
|
} else { |
scaleStep = 20; |
|
scaleStep = 20; |
} |
|
} |
while (_temp.lowScale < _temp.minValue) { |
|
while (_temp.lowScale < _temp.minValue) { |
_temp.minValue -= scaleStep; |
|
_temp.minValue -= scaleStep; |
if (_temp.highScale <= _temp.maxValue - scaleStep) { |
|
if (_temp.highScale <= _temp.maxValue - scaleStep) { |
_temp.maxValue -= scaleStep; |
|
_temp.maxValue -= scaleStep; |
} |
|
} |
} |
|
} |
while (_temp.highScale > _temp.maxValue) { |
|
while (_temp.highScale > _temp.maxValue) { |
_temp.maxValue += scaleStep; |
|
_temp.maxValue += scaleStep; |
if (_temp.minValue >= _temp.minValue + scaleStep) { |
|
if (_temp.minValue >= _temp.minValue + scaleStep) { |
_temp.minValue += scaleStep; |
|
_temp.minValue += scaleStep; |
} |
|
} |
} |
|
} |
|
|
|
if (_temp.minValue !== _gaugeTemp.getMinValue() || _temp.maxValue !== _gaugeTemp.getMaxValue()) { |
|
if (_temp.minValue !== _gaugeTemp.getMinValue() || _temp.maxValue !== _gaugeTemp.getMaxValue()) { |
_gaugeTemp.setMinValue(_temp.minValue); |
|
_gaugeTemp.setMinValue(_temp.minValue); |
_gaugeTemp.setMaxValue(_temp.maxValue); |
|
_gaugeTemp.setMaxValue(_temp.maxValue); |
_gaugeTemp.setValue(_temp.minValue); |
|
_gaugeTemp.setValue(_temp.minValue); |
} |
|
} |
if (_temp.selected === 'out') { |
|
if (_temp.selected === 'out') { |
_temp.areas = [steelseries.Section(+_temp.low, +_temp.high, gauge.minMaxArea)]; |
|
_temp.areas = [steelseries.Section(+_temp.low, +_temp.high, gauge.minMaxArea)]; |
} else { |
|
} else { |
_temp.areas = []; |
|
_temp.areas = []; |
} |
|
} |
|
|
|
if (gauge.tempTrendVisible) { |
|
if (gauge.tempTrendVisible) { |
_gaugeTemp.setTrend(_temp.trend); |
|
_gaugeTemp.setTrend(_temp.trend); |
} |
|
} |
_gaugeTemp.setArea(_temp.areas); |
|
_gaugeTemp.setArea(_temp.areas); |
_gaugeTemp.setValueAnimated(+_temp.value); |
|
_gaugeTemp.setValueAnimated(+_temp.value); |
|
|
|
if (ddimgtooltip.showTips) { |
|
if (ddimgtooltip.showTips) { |
// update tooltip |
|
// update tooltip |
if (_temp.selected === 'out') { |
|
if (_temp.selected === 'out') { |
tip = _temp.loc + ' - ' + strings.lowestF_info + ': ' + _temp.low + data.tempunit + ' ' + strings.at + ' ' + data.TtempTL + |
|
tip = _temp.loc + ' - ' + strings.lowestF_info + ': ' + _temp.low + data.tempunit + ' ' + strings.at + ' ' + data.TtempTL + |
' | ' + |
|
' | ' + |
strings.highestF_info + ': ' + _temp.high + data.tempunit + ' ' + strings.at + ' ' + data.TtempTH + |
|
strings.highestF_info + ': ' + _temp.high + data.tempunit + ' ' + strings.at + ' ' + data.TtempTH + |
'<br>' + |
|
'<br>' + |
strings.temp_trend_info + ': ' + tempTrend(_temp.trendVal, data.tempunit, true) + ' ' + _temp.trendVal + data.tempunit + '/h'; |
|
strings.temp_trend_info + ': ' + tempTrend(_temp.trendVal, data.tempunit, true) + ' ' + _temp.trendVal + data.tempunit + '/h'; |
} else { |
|
} else { |
tip = _temp.loc + ': ' + data.intemp + data.tempunit; |
|
tip = _temp.loc + ': ' + data.intemp + data.tempunit; |
} |
|
} |
$('#imgtip0_txt').html(tip); |
|
$('#imgtip0_txt').html(tip); |
if (_refreshGraphs && config.showPopupGraphs && config.tipImgs[0][0] !== null) { |
|
if (_refreshGraphs && config.showPopupGraphs && config.tipImgs[0][0] !== null) { |
$('#imgtip0_img').attr('src', config.imgPathURL + config.tipImgs[0][_temp.selected === 'out' ? 0 : 1] + _cacheDefeat); |
|
$('#imgtip0_img').attr('src', config.imgPathURL + config.tipImgs[0][_temp.selected === 'out' ? 0 : 1] + _cacheDefeat); |
} |
|
} |
} |
|
} |
}, |
|
}, |
|
|
|
doDew = function (radio) { |
|
doDew = function (radio) { |
var tip, |
|
var tip, |
// if rad isn't specified, just use existing value |
|
// if rad isn't specified, just use existing value |
sel = (radio === undefined ? _dew.selected : radio.value), |
|
sel = (radio === undefined ? _dew.selected : radio.value), |
popupImg, scaleStep; |
|
popupImg, scaleStep; |
|
|
|
_dew.lowScale = getMinTemp(); |
|
_dew.lowScale = getMinTemp(); |
_dew.highScale = getMaxTemp(); |
|
_dew.highScale = getMaxTemp(); |
|
|
|
switch (sel) { |
|
switch (sel) { |
case 'dew': // dew point |
|
case 'dew': // dew point |
_dew.low = extractDecimal(data.dewpointTL); |
|
_dew.low = extractDecimal(data.dewpointTL); |
_dew.high = extractDecimal(data.dewpointTH); |
|
_dew.high = extractDecimal(data.dewpointTH); |
_dew.value = extractDecimal(data.dew); |
|
_dew.value = extractDecimal(data.dew); |
_dew.areas = [steelseries.Section(+_dew.low, +_dew.high, gauge.minMaxArea)]; |
|
_dew.areas = [steelseries.Section(+_dew.low, +_dew.high, gauge.minMaxArea)]; |
_dew.title = strings.dew_title; |
|
_dew.title = strings.dew_title; |
_dew.minMeasuredVisible = false; |
|
_dew.minMeasuredVisible = false; |
_dew.maxMeasuredVisible = false; |
|
_dew.maxMeasuredVisible = false; |
popupImg = 0; |
|
popupImg = 0; |
tip = strings.dew_info + ':' + |
|
tip = strings.dew_info + ':' + |
'<br>' + |
|
'<br>' + |
'- ' + strings.lowest_info + ': ' + _dew.low + data.tempunit + ' ' + strings.at + ' ' + data.TdewpointTL + |
|
'- ' + strings.lowest_info + ': ' + _dew.low + data.tempunit + ' ' + strings.at + ' ' + data.TdewpointTL + |
' | ' + strings.highest_info + ': ' + _dew.high + data.tempunit + ' ' + strings.at + ' ' + data.TdewpointTH; |
|
' | ' + strings.highest_info + ': ' + _dew.high + data.tempunit + ' ' + strings.at + ' ' + data.TdewpointTH; |
break; |
|
break; |
case 'app': // apparent temperature |
|
case 'app': // apparent temperature |
_dew.low = extractDecimal(data.apptempTL); |
|
_dew.low = extractDecimal(data.apptempTL); |
_dew.high = extractDecimal(data.apptempTH); |
|
_dew.high = extractDecimal(data.apptempTH); |
_dew.value = extractDecimal(data.apptemp); |
|
_dew.value = extractDecimal(data.apptemp); |
_dew.areas = [steelseries.Section(+_dew.low, +_dew.high, gauge.minMaxArea)]; |
|
_dew.areas = [steelseries.Section(+_dew.low, +_dew.high, gauge.minMaxArea)]; |
_dew.title = strings.apptemp_title; |
|
_dew.title = strings.apptemp_title; |
_dew.minMeasuredVisible = false; |
|
_dew.minMeasuredVisible = false; |
_dew.maxMeasuredVisible = false; |
|
_dew.maxMeasuredVisible = false; |
popupImg = 1; |
|
popupImg = 1; |
tip = tip = strings.apptemp_info + ':' + |
|
tip = tip = strings.apptemp_info + ':' + |
'<br>' + |
|
'<br>' + |
'- ' + strings.lowestF_info + ': ' + _dew.low + data.tempunit + ' ' + strings.at + ' ' + data.TapptempTL + |
|
'- ' + strings.lowestF_info + ': ' + _dew.low + data.tempunit + ' ' + strings.at + ' ' + data.TapptempTL + |
' | ' + strings.highestF_info + ': ' + _dew.high + data.tempunit + ' ' + strings.at + ' ' + data.TapptempTH; |
|
' | ' + strings.highestF_info + ': ' + _dew.high + data.tempunit + ' ' + strings.at + ' ' + data.TapptempTH; |
break; |
|
break; |
case 'wnd': // wind chill |
|
case 'wnd': // wind chill |
_dew.low = extractDecimal(data.wchillTL); |
|
_dew.low = extractDecimal(data.wchillTL); |
_dew.high = extractDecimal(data.wchill); |
|
_dew.high = extractDecimal(data.wchill); |
_dew.value = extractDecimal(data.wchill); |
|
_dew.value = extractDecimal(data.wchill); |
_dew.areas = []; |
|
_dew.areas = []; |
_dew.title = strings.chill_title; |
|
_dew.title = strings.chill_title; |
_dew.minMeasuredVisible = true; |
|
_dew.minMeasuredVisible = true; |
_dew.maxMeasuredVisible = false; |
|
_dew.maxMeasuredVisible = false; |
popupImg = 2; |
|
popupImg = 2; |
tip = strings.chill_info + ':' + |
|
tip = strings.chill_info + ':' + |
'<br>' + |
|
'<br>' + |
'- ' + strings.lowest_info + ': ' + _dew.low + data.tempunit + ' ' + strings.at + ' ' + data.TwchillTL; |
|
'- ' + strings.lowest_info + ': ' + _dew.low + data.tempunit + ' ' + strings.at + ' ' + data.TwchillTL; |
break; |
|
break; |
case 'hea': // heat index |
|
case 'hea': // heat index |
_dew.low = extractDecimal(data.heatindex); |
|
_dew.low = extractDecimal(data.heatindex); |
_dew.high = extractDecimal(data.heatindexTH); |
|
_dew.high = extractDecimal(data.heatindexTH); |
_dew.value = extractDecimal(data.heatindex); |
|
_dew.value = extractDecimal(data.heatindex); |
_dew.areas = []; |
|
_dew.areas = []; |
_dew.title = strings.heat_title; |
|
_dew.title = strings.heat_title; |
_dew.minMeasuredVisible = false; |
|
_dew.minMeasuredVisible = false; |
_dew.maxMeasuredVisible = true; |
|
_dew.maxMeasuredVisible = true; |
popupImg = 3; |
|
popupImg = 3; |
tip = strings.heat_info + ':' + |
|
tip = strings.heat_info + ':' + |
'<br>' + |
|
'<br>' + |
'- ' + strings.highest_info + ': ' + _dew.high + data.tempunit + ' ' + strings.at + ' ' + data.TheatindexTH; |
|
'- ' + strings.highest_info + ': ' + _dew.high + data.tempunit + ' ' + strings.at + ' ' + data.TheatindexTH; |
break; |
|
break; |
case 'hum': // humidex |
|
case 'hum': // humidex |
_dew.low = extractDecimal(data.humidex); |
|
_dew.low = extractDecimal(data.humidex); |
_dew.high = extractDecimal(data.humidex); |
|
_dew.high = extractDecimal(data.humidex); |
_dew.value = extractDecimal(data.humidex); |
|
_dew.value = extractDecimal(data.humidex); |
_dew.areas = []; |
|
_dew.areas = []; |
_dew.title = strings.humdx_title; |
|
_dew.title = strings.humdx_title; |
_dew.minMeasuredVisible = false; |
|
_dew.minMeasuredVisible = false; |
_dew.maxMeasuredVisible = false; |
|
_dew.maxMeasuredVisible = false; |
popupImg = 4; |
|
popupImg = 4; |
tip = strings.humdx_info + ': ' + _dew.value + data.tempunit; |
|
tip = strings.humdx_info + ': ' + _dew.value + data.tempunit; |
break; |
|
break; |
} |
|
} |
|
|
|
if (_dew.selected !== sel) { |
|
if (_dew.selected !== sel) { |
_dew.selected = sel; |
|
_dew.selected = sel; |
// change gauge title |
|
// change gauge title |
_gaugeDew.setTitleString(_dew.title); |
|
_gaugeDew.setTitleString(_dew.title); |
// and graph image |
|
// and graph image |
if (config.showPopupGraphs && config.tipImgs[1][0] !== null) { |
|
if (config.showPopupGraphs && config.tipImgs[1][0] !== null) { |
$('#imgtip1_img').attr('src', config.imgPathURL + config.tipImgs[1][popupImg] + _cacheDefeat); |
|
$('#imgtip1_img').attr('src', config.imgPathURL + config.tipImgs[1][popupImg] + _cacheDefeat); |
} |
|
} |
// save the choice in a cookie |
|
// save the choice in a cookie |
setCookie('dewGauge', sel); |
|
setCookie('dewGauge', sel); |
} |
|
} |
|
|
|
//auto scale the ranges |
|
//auto scale the ranges |
if (data.tempunit.indexOf('C') !== -1) { |
|
if (data.tempunit.indexOf('C') !== -1) { |
scaleStep = 10; |
|
scaleStep = 10; |
} else { |
|
} else { |
scaleStep = 20; |
|
scaleStep = 20; |
} |
|
} |
while (_dew.lowScale < _dew.minValue) { |
|
while (_dew.lowScale < _dew.minValue) { |
_dew.minValue -= scaleStep; |
|
_dew.minValue -= scaleStep; |
if (_dew.highScale <= _dew.maxValue - scaleStep) { |
|
if (_dew.highScale <= _dew.maxValue - scaleStep) { |
_dew.maxValue -= scaleStep; |
|
_dew.maxValue -= scaleStep; |
} |
|
} |
} |
|
} |
while (_dew.highScale > _dew.maxValue) { |
|
while (_dew.highScale > _dew.maxValue) { |
_dew.maxValue += scaleStep; |
|
_dew.maxValue += scaleStep; |
if (_dew.minValue >= _dew.minValue + scaleStep) { |
|
if (_dew.minValue >= _dew.minValue + scaleStep) { |
_dew.minValue += scaleStep; |
|
_dew.minValue += scaleStep; |
} |
|
} |
} |
|
} |
|
|
|
if (_dew.minValue !== _gaugeDew.getMinValue() || _dew.maxValue !== _gaugeDew.getMaxValue()) { |
|
if (_dew.minValue !== _gaugeDew.getMinValue() || _dew.maxValue !== _gaugeDew.getMaxValue()) { |
_gaugeDew.setMinValue(_dew.minValue); |
|
_gaugeDew.setMinValue(_dew.minValue); |
_gaugeDew.setMaxValue(_dew.maxValue); |
|
_gaugeDew.setMaxValue(_dew.maxValue); |
_gaugeDew.setValue(_dew.minValue); |
|
_gaugeDew.setValue(_dew.minValue); |
} |
|
} |
_gaugeDew.setMinMeasuredValueVisible(_dew.minMeasuredVisible); |
|
_gaugeDew.setMinMeasuredValueVisible(_dew.minMeasuredVisible); |
_gaugeDew.setMaxMeasuredValueVisible(_dew.maxMeasuredVisible); |
|
_gaugeDew.setMaxMeasuredValueVisible(_dew.maxMeasuredVisible); |
_gaugeDew.setMinMeasuredValue(+_dew.low); |
|
_gaugeDew.setMinMeasuredValue(+_dew.low); |
_gaugeDew.setMaxMeasuredValue(+_dew.high); |
|
_gaugeDew.setMaxMeasuredValue(+_dew.high); |
_gaugeDew.setArea(_dew.areas); |
|
_gaugeDew.setArea(_dew.areas); |
_gaugeDew.setValueAnimated(+_dew.value); |
|
_gaugeDew.setValueAnimated(+_dew.value); |
|
|
|
if (ddimgtooltip.showTips) { |
|
if (ddimgtooltip.showTips) { |
// update tooltip |
|
// update tooltip |
$('#imgtip1_txt').html(tip); |
|
$('#imgtip1_txt').html(tip); |
if (_refreshGraphs && config.showPopupGraphs && config.tipImgs[1][popupImg] !== null) { |
|
if (_refreshGraphs && config.showPopupGraphs && config.tipImgs[1][popupImg] !== null) { |
$('#imgtip1_img').attr('src', config.imgPathURL + config.tipImgs[1][popupImg] + _cacheDefeat); |
|
$('#imgtip1_img').attr('src', config.imgPathURL + config.tipImgs[1][popupImg] + _cacheDefeat); |
} |
|
} |
} |
|
} |
}, |
|
}, |
|
|
|
doRain = function () { |
|
doRain = function () { |
_rain.value = extractDecimal(data.rfall); |
|
_rain.value = extractDecimal(data.rfall); |
|
|
|
if (data.rainunit === 'mm') { // 10, 20, 30... |
|
if (data.rainunit === 'mm') { // 10, 20, 30... |
_rain.maxValue = Math.max(Math.ceil(_rain.value / 10) * 10, 10); |
|
_rain.maxValue = Math.max(Math.ceil(_rain.value / 10) * 10, 10); |
} else { |
|
} else { |
// inches 1.0, 2.0, 3.0 ... 10.0, 12.0, 14.0 |
|
// inches 1.0, 2.0, 3.0 ... 10.0, 12.0, 14.0 |
if (_rain.value < 6) { |
|
if (_rain.value < 6) { |
_rain.maxValue = Math.max(Math.ceil(_rain.value), 1.0); |
|
_rain.maxValue = Math.max(Math.ceil(_rain.value), 1.0); |
} else { |
|
} else { |
_rain.maxValue = Math.ceil(_rain.value / 2) * 2; |
|
_rain.maxValue = Math.ceil(_rain.value / 2) * 2; |
} |
|
} |
} |
|
} |
|
|
|
if (_rain.maxValue !== _gaugeRain.getMaxValue()) { |
|
if (_rain.maxValue !== _gaugeRain.getMaxValue()) { |
_gaugeRain.setValue(0); |
|
_gaugeRain.setValue(0); |
_gaugeRain.setMaxValue(_rain.maxValue); |
|
_gaugeRain.setMaxValue(_rain.maxValue); |
} |
|
} |
|
|
|
_gaugeRain.setValueAnimated(_rain.value); |
|
_gaugeRain.setValueAnimated(_rain.value); |
|
|
|
if (ddimgtooltip.showTips) { |
|
if (ddimgtooltip.showTips) { |
// update tooltip |
|
// update tooltip |
$('#imgtip2_txt').html(strings.LastRain_info + ': ' + data.LastRained); |
|
$('#imgtip2_txt').html(strings.LastRain_info + ': ' + data.LastRained); |
if (_refreshGraphs && config.showPopupGraphs && config.tipImgs[2] !== null) { |
|
if (_refreshGraphs && config.showPopupGraphs && config.tipImgs[2] !== null) { |
$('#imgtip2_img').attr('src', config.imgPathURL + config.tipImgs[2] + _cacheDefeat); |
|
$('#imgtip2_img').attr('src', config.imgPathURL + config.tipImgs[2] + _cacheDefeat); |
} |
|
} |
} |
|
} |
}, |
|
}, |
|
|
|
doRRate = function () { |
|
doRRate = function () { |
var tip; |
|
var tip; |
|
|
|
_rrate.value = extractDecimal(data.rrate); |
|
_rrate.value = extractDecimal(data.rrate); |
_rrate.maxMeasured = extractDecimal(data.rrateTM); |
|
_rrate.maxMeasured = extractDecimal(data.rrateTM); |
|
|
|
if (data.rainunit === 'mm') { // 10, 20, 30... |
|
if (data.rainunit === 'mm') { // 10, 20, 30... |
_rrate.maxValue = Math.max(Math.ceil(_rrate.maxMeasured / 10) * 10, 10); |
|
_rrate.maxValue = Math.max(Math.ceil(_rrate.maxMeasured / 10) * 10, 10); |
} else { |
|
} else { |
// inches 0.5, 1.0, 1.5, 2.0 ... |
|
// inches 0.5, 1.0, 1.5, 2.0 ... |
//_rrate.maxValue = Math.max(Math.ceil(_rrate.maxMeasured * 2) * 0.5, 0.5); |
|
//_rrate.maxValue = Math.max(Math.ceil(_rrate.maxMeasured * 2) * 0.5, 0.5); |
// inches 1.0, 2.0, 3.0 ... |
|
// inches 1.0, 2.0, 3.0 ... |
_rrate.maxValue = Math.max(Math.ceil(_rrate.maxMeasured), 1.0); |
|
_rrate.maxValue = Math.max(Math.ceil(_rrate.maxMeasured), 1.0); |
} |
|
} |
|
|
|
if (_rrate.maxValue !== _gaugeRRate.getMaxValue()) { |
|
if (_rrate.maxValue !== _gaugeRRate.getMaxValue()) { |
_gaugeRRate.setValue(0); |
|
_gaugeRRate.setValue(0); |
_gaugeRRate.setMaxValue(_rrate.maxValue); |
|
_gaugeRRate.setMaxValue(_rrate.maxValue); |
} |
|
} |
|
|
|
_gaugeRRate.setValueAnimated(_rrate.value); |
|
_gaugeRRate.setValueAnimated(_rrate.value); |
_gaugeRRate.setMaxMeasuredValue(_rrate.maxMeasured); |
|
_gaugeRRate.setMaxMeasuredValue(_rrate.maxMeasured); |
|
|
|
if (ddimgtooltip.showTips) { |
|
if (ddimgtooltip.showTips) { |
// update tooltip |
|
// update tooltip |
tip = strings.rrate_info + ':<br>' + |
|
tip = strings.rrate_info + ':<br>' + |
'- ' + strings.maximum_info + ': ' + data.rrateTM + ' ' + data.rainunit + '/h ' + strings.at + ' ' + data.TrrateTM + |
|
'- ' + strings.maximum_info + ': ' + data.rrateTM + ' ' + data.rainunit + '/h ' + strings.at + ' ' + data.TrrateTM + |
' | ' + strings.max_hour_info + ': ' + extractDecimal(data.hourlyrainTH) + ' ' + data.rainunit + ' ' + strings.at + ' ' + data.ThourlyrainTH; |
|
' | ' + strings.max_hour_info + ': ' + extractDecimal(data.hourlyrainTH) + ' ' + data.rainunit + ' ' + strings.at + ' ' + data.ThourlyrainTH; |
$('#imgtip3_txt').html(tip); |
|
$('#imgtip3_txt').html(tip); |
if (_refreshGraphs && config.showPopupGraphs && config.tipImgs[3] !== null) { |
|
if (_refreshGraphs && config.showPopupGraphs && config.tipImgs[3] !== null) { |
$('#imgtip3_img').attr('src', config.imgPathURL + config.tipImgs[3] + _cacheDefeat); |
|
$('#imgtip3_img').attr('src', config.imgPathURL + config.tipImgs[3] + _cacheDefeat); |
} |
|
} |
} |
|
} |
}, |
|
}, |
|
|
|
doHum = function (radio) { |
|
doHum = function (radio) { |
//if rad isn't specified, just use existing value |
|
//if rad isn't specified, just use existing value |
var sel = (radio === undefined ? _hum.selected : radio.value), |
|
var sel = (radio === undefined ? _hum.selected : radio.value), |
popupImg, tip; |
|
popupImg, tip; |
|
|
|
if (sel === 'out') { |
|
if (sel === 'out') { |
_hum.value = extractDecimal(data.hum); |
|
_hum.value = extractDecimal(data.hum); |
_hum.areas = [steelseries.Section(+extractDecimal(data.humTL), +extractDecimal(data.humTH), gauge.minMaxArea)]; |
|
_hum.areas = [steelseries.Section(+extractDecimal(data.humTL), +extractDecimal(data.humTH), gauge.minMaxArea)]; |
_hum.title = strings.hum_title_out; |
|
_hum.title = strings.hum_title_out; |
popupImg = 0; |
|
popupImg = 0; |
} else { |
|
} else { |
_hum.value = extractDecimal(data.inhum); |
|
_hum.value = extractDecimal(data.inhum); |
_hum.areas = []; |
|
_hum.areas = []; |
_hum.title = strings.hum_title_in; |
|
_hum.title = strings.hum_title_in; |
popupImg = 1; |
|
popupImg = 1; |
} |
|
} |
|
|
|
if (_hum.selected !== sel) { |
|
if (_hum.selected !== sel) { |
_hum.selected = sel; |
|
_hum.selected = sel; |
//Change gauge title |
|
//Change gauge title |
_gaugeHum.setTitleString(_hum.title); |
|
_gaugeHum.setTitleString(_hum.title); |
if (config.showPopupGraphs) { |
|
if (config.showPopupGraphs) { |
$('#imgtip4_img').attr('src', config.imgPathURL + config.tipImgs[4][popupImg] + _cacheDefeat); |
|
$('#imgtip4_img').attr('src', config.imgPathURL + config.tipImgs[4][popupImg] + _cacheDefeat); |
} |
|
} |
} |
|
} |
|
|
|
_gaugeHum.setArea(_hum.areas); |
|
_gaugeHum.setArea(_hum.areas); |
_gaugeHum.setValueAnimated(_hum.value); |
|
_gaugeHum.setValueAnimated(_hum.value); |
|
|
|
if (ddimgtooltip.showTips) { |
|
if (ddimgtooltip.showTips) { |
//update tooltip |
|
//update tooltip |
if (_hum.selected === 'out') { |
|
if (_hum.selected === 'out') { |
tip = strings.hum_out_info + ':' + |
|
tip = strings.hum_out_info + ':' + |
'<br>' + |
|
'<br>' + |
'- ' + strings.minimum_info + ': ' + extractDecimal(data.humTL) + '% ' + strings.at + ' ' + data.ThumTL + |
|
'- ' + strings.minimum_info + ': ' + extractDecimal(data.humTL) + '% ' + strings.at + ' ' + data.ThumTL + |
' | ' + strings.maximum_info + ': ' + extractDecimal(data.humTH) + '% ' + strings.at + ' ' + data.ThumTH; |
|
' | ' + strings.maximum_info + ': ' + extractDecimal(data.humTH) + '% ' + strings.at + ' ' + data.ThumTH; |
} else { |
|
} else { |
tip = strings.hum_in_info + ': ' + extractDecimal(data.inhum) + '%'; |
|
tip = strings.hum_in_info + ': ' + extractDecimal(data.inhum) + '%'; |
} |
|
} |
$('#imgtip4_txt').html(tip); |
|
$('#imgtip4_txt').html(tip); |
if (_refreshGraphs && config.showPopupGraphs && config.tipImgs[4][0] !== null) { |
|
if (_refreshGraphs && config.showPopupGraphs && config.tipImgs[4][0] !== null) { |
$('i#mgtip4_img').attr('src', config.imgPathURL + config.tipImgs[4][popupImg] + _cacheDefeat); |
|
$('i#mgtip4_img').attr('src', config.imgPathURL + config.tipImgs[4][popupImg] + _cacheDefeat); |
} |
|
} |
} |
|
} |
}, |
|
}, |
|
|
|
doBaro = function () { |
|
doBaro = function () { |
var tip, t1; |
|
var tip, t1; |
|
|
|
_baro.recLow = +extractDecimal(data.pressL); |
|
_baro.recLow = +extractDecimal(data.pressL); |
_baro.recHigh = +extractDecimal(data.pressH); |
|
_baro.recHigh = +extractDecimal(data.pressH); |
_baro.todayLow = +extractDecimal(data.pressTL); |
|
_baro.todayLow = +extractDecimal(data.pressTL); |
_baro.todayHigh = +extractDecimal(data.pressTH); |
|
_baro.todayHigh = +extractDecimal(data.pressTH); |
_baro.value = +extractDecimal(data.press); |
|
_baro.value = +extractDecimal(data.press); |
// Convert the WD change over 3 hours to an hourly rate |
|
// Convert the WD change over 3 hours to an hourly rate |
_baro.trendVal = +extractDecimal(data.presstrendval) / (config.weatherProgram === 0 ? 1 : 3); |
<> |
_baro.trendVal = +extractDecimal(data.presstrendval) / (config.weatherProgram === 1 ? 3 : 1); |
|
= |
|
if (data.pressunit === 'hPa' || data.pressunit === 'mb') { |
|
if (data.pressunit === 'hPa' || data.pressunit === 'mb') { |
// min range 990-1030 - steps of 10 hPa |
|
// min range 990-1030 - steps of 10 hPa |
_baro.minValue = Math.min(Math.floor((_baro.recLow - 2) / 10) * 10, 990); |
|
_baro.minValue = Math.min(Math.floor((_baro.recLow - 2) / 10) * 10, 990); |
_baro.maxValue = Math.max(Math.ceil((_baro.recHigh + 2) / 10) * 10, 1030); |
|
_baro.maxValue = Math.max(Math.ceil((_baro.recHigh + 2) / 10) * 10, 1030); |
_baro.trendValRnd = _baro.trendVal.toFixed(1); // round to 0.1 |
|
_baro.trendValRnd = _baro.trendVal.toFixed(1); // round to 0.1 |
} else if (data.pressunit === 'kPa') { |
|
} else if (data.pressunit === 'kPa') { |
// min range 99-105 - steps of 1 kPa |
|
// min range 99-105 - steps of 1 kPa |
_baro.minValue = Math.min(Math.floor(_baro.recLow - 0.2), 99); |
|
_baro.minValue = Math.min(Math.floor(_baro.recLow - 0.2), 99); |
_baro.maxValue = Math.max(Math.ceil(_baro.recHigh + 0.2), 105); |
|
_baro.maxValue = Math.max(Math.ceil(_baro.recHigh + 0.2), 105); |
_baro.trendValRnd = _baro.trendVal.toFixed(2); // round to 0.01 |
|
_baro.trendValRnd = _baro.trendVal.toFixed(2); // round to 0.01 |
} else { |
|
} else { |
// inHg: min range 29.5-30.5 - steps of 0.5 inHg |
|
// inHg: min range 29.5-30.5 - steps of 0.5 inHg |
_baro.minValue = Math.min(Math.floor((_baro.recLow - 0.1) * 2) / 2, 29.5); |
|
_baro.minValue = Math.min(Math.floor((_baro.recLow - 0.1) * 2) / 2, 29.5); |
_baro.maxValue = Math.max(Math.ceil((_baro.recHigh + 0.1) * 2) / 2, 30.5); |
|
_baro.maxValue = Math.max(Math.ceil((_baro.recHigh + 0.1) * 2) / 2, 30.5); |
_baro.trendValRnd = _baro.trendVal.toFixed(3); // round to 0.001 |
|
_baro.trendValRnd = _baro.trendVal.toFixed(3); // round to 0.001 |
} |
|
} |
if (_baro.minValue !== _gaugeBaro.getMinValue() || _baro.maxValue !== _gaugeBaro.getMaxValue()) { |
|
if (_baro.minValue !== _gaugeBaro.getMinValue() || _baro.maxValue !== _gaugeBaro.getMaxValue()) { |
_gaugeBaro.setMinValue(_baro.minValue); |
|
_gaugeBaro.setMinValue(_baro.minValue); |
_gaugeBaro.setMaxValue(_baro.maxValue); |
|
_gaugeBaro.setMaxValue(_baro.maxValue); |
_gaugeBaro.setValue(_baro.minValue); |
|
_gaugeBaro.setValue(_baro.minValue); |
} |
|
} |
if (_baro.recHigh === _baro.todayHigh && _baro.recLow === _baro.todayLow) { |
|
if (_baro.recHigh === _baro.todayHigh && _baro.recLow === _baro.todayLow) { |
// VWS does not provide record hi/lo values |
|
// VWS does not provide record hi/lo values |
_baro.sections = []; |
|
_baro.sections = []; |
_baro.areas = [steelseries.Section(_baro.todayLow, _baro.todayHigh, gauge.minMaxArea)]; |
|
_baro.areas = [steelseries.Section(_baro.todayLow, _baro.todayHigh, gauge.minMaxArea)]; |
} else { |
|
} else { |
_baro.sections = [ |
|
_baro.sections = [ |
steelseries.Section(_baro.minValue, _baro.recLow, 'rgba(255,0,0,0.5)'), |
|
steelseries.Section(_baro.minValue, _baro.recLow, 'rgba(255,0,0,0.5)'), |
steelseries.Section(_baro.recHigh, _baro.maxValue, 'rgba(255,0,0,0.5)') |
|
steelseries.Section(_baro.recHigh, _baro.maxValue, 'rgba(255,0,0,0.5)') |
]; |
|
]; |
_baro.areas = [ |
|
_baro.areas = [ |
steelseries.Section(_baro.minValue, _baro.recLow, 'rgba(255,0,0,0.5)'), |
|
steelseries.Section(_baro.minValue, _baro.recLow, 'rgba(255,0,0,0.5)'), |
steelseries.Section(_baro.recHigh, _baro.maxValue, 'rgba(255,0,0,0.5)'), |
|
steelseries.Section(_baro.recHigh, _baro.maxValue, 'rgba(255,0,0,0.5)'), |
steelseries.Section(_baro.todayLow, _baro.todayHigh, gauge.minMaxArea) |
|
steelseries.Section(_baro.todayLow, _baro.todayHigh, gauge.minMaxArea) |
]; |
|
]; |
} |
|
} |
|
|
|
if (gauge.pressureTrendVisible) { |
|
if (gauge.pressureTrendVisible) { |
// Use the baroTrend rather than simple arithmetic test - steady is more/less than zero! |
|
// Use the baroTrend rather than simple arithmetic test - steady is more/less than zero! |
t1 = baroTrend(_baro.trendVal, data.pressunit, false); |
|
t1 = baroTrend(_baro.trendVal, data.pressunit, false); |
if (t1 > 0) { |
|
if (t1 > 0) { |
_baro.trend = steelseries.TrendState.UP; |
|
_baro.trend = steelseries.TrendState.UP; |
} else if (t1 < 0) { |
|
} else if (t1 < 0) { |
_baro.trend = steelseries.TrendState.DOWN; |
|
_baro.trend = steelseries.TrendState.DOWN; |
} else { |
|
} else { |
_baro.trend = steelseries.TrendState.STEADY; |
|
_baro.trend = steelseries.TrendState.STEADY; |
} |
|
} |
_gaugeBaro.setTrend(_baro.trend); |
|
_gaugeBaro.setTrend(_baro.trend); |
} |
|
} |
|
|
|
_gaugeBaro.setArea(_baro.areas); |
|
_gaugeBaro.setArea(_baro.areas); |
_gaugeBaro.setSection(_baro.sections); |
|
_gaugeBaro.setSection(_baro.sections); |
_gaugeBaro.setValueAnimated(_baro.value); |
|
_gaugeBaro.setValueAnimated(_baro.value); |
|
|
|
if (ddimgtooltip.showTips) { |
|
if (ddimgtooltip.showTips) { |
// update tooltip |
|
// update tooltip |
tip = strings.baro_info + ':' + |
|
tip = strings.baro_info + ':' + |
'<br>' + |
|
'<br>' + |
'- ' + strings.minimum_info + ': ' + _baro.todayLow + ' ' + data.pressunit + ' ' + strings.at + ' ' + data.TpressTL + |
|
'- ' + strings.minimum_info + ': ' + _baro.todayLow + ' ' + data.pressunit + ' ' + strings.at + ' ' + data.TpressTL + |
' | ' + strings.maximum_info + ': ' + _baro.todayHigh + ' ' + data.pressunit + ' ' + strings.at + ' ' + data.TpressTH + |
|
' | ' + strings.maximum_info + ': ' + _baro.todayHigh + ' ' + data.pressunit + ' ' + strings.at + ' ' + data.TpressTH + |
'<br>' + |
|
'<br>' + |
'- ' + strings.baro_trend_info + ': ' + baroTrend(_baro.trendVal, data.pressunit, true) + ' ' + |
|
'- ' + strings.baro_trend_info + ': ' + baroTrend(_baro.trendVal, data.pressunit, true) + ' ' + |
(_baro.trendValRnd > 0 ? '+' : '') + _baro.trendValRnd + ' ' + data.pressunit + '/h'; |
|
(_baro.trendValRnd > 0 ? '+' : '') + _baro.trendValRnd + ' ' + data.pressunit + '/h'; |
$('#imgtip5_txt').html(tip); |
|
$('#imgtip5_txt').html(tip); |
if (_refreshGraphs && config.showPopupGraphs && config.tipImgs[5] !== null) { |
|
if (_refreshGraphs && config.showPopupGraphs && config.tipImgs[5] !== null) { |
$('#imgtip5_img').attr('src', config.imgPathURL + config.tipImgs[5] + _cacheDefeat); |
|
$('#imgtip5_img').attr('src', config.imgPathURL + config.tipImgs[5] + _cacheDefeat); |
} |
|
} |
} |
|
} |
}, |
|
}, |
|
|
|
doWind = function () { |
|
doWind = function () { |
var tip; |
|
var tip; |
|
|
|
_wind.value = extractDecimal(data.wlatest); |
|
_wind.value = extractDecimal(data.wlatest); |
_wind.average = extractDecimal(data.wspeed); |
|
_wind.average = extractDecimal(data.wspeed); |
_wind.gust = extractDecimal(data.wgust); |
|
_wind.gust = extractDecimal(data.wgust); |
_wind.maxGustToday = extractDecimal(data.wgustTM); |
|
_wind.maxGustToday = extractDecimal(data.wgustTM); |
_wind.maxAvgToday = extractDecimal(data.windTM); |
|
_wind.maxAvgToday = extractDecimal(data.windTM); |
|
|
|
switch (data.windunit) { |
|
switch (data.windunit) { |
case 'mph': |
|
case 'mph': |
case 'kts': |
|
case 'kts': |
_wind.maxValue = Math.max(Math.ceil(_wind.maxGustToday / 10) * 10, gauge.windScaleDefMaxMph); |
|
_wind.maxValue = Math.max(Math.ceil(_wind.maxGustToday / 10) * 10, gauge.windScaleDefMaxMph); |
break; |
|
break; |
case 'm/s': |
|
case 'm/s': |
_wind.maxValue = Math.max(Math.ceil(_wind.maxGustToday / 5) * 5, gauge.windScaleDefMaxMs); |
|
_wind.maxValue = Math.max(Math.ceil(_wind.maxGustToday / 5) * 5, gauge.windScaleDefMaxMs); |
break; |
|
break; |
default: |
|
default: |
_wind.maxValue = Math.max(Math.ceil(_wind.maxGustToday / 20) * 20, gauge.windScaleDefMaxKmh); |
|
_wind.maxValue = Math.max(Math.ceil(_wind.maxGustToday / 20) * 20, gauge.windScaleDefMaxKmh); |
} |
|
} |
_wind.areas = [ |
|
_wind.areas = [ |
steelseries.Section(0, +_wind.average, gauge.windAvgArea), |
|
steelseries.Section(0, +_wind.average, gauge.windAvgArea), |
steelseries.Section(+_wind.average, +_wind.gust, gauge.minMaxArea) |
|
steelseries.Section(+_wind.average, +_wind.gust, gauge.minMaxArea) |
]; |
|
]; |
if (_wind.maxValue !== _gaugeWind.getMaxValue()) { |
|
if (_wind.maxValue !== _gaugeWind.getMaxValue()) { |
_gaugeWind.setMaxValue(_wind.maxValue); |
|
_gaugeWind.setMaxValue(_wind.maxValue); |
} |
|
} |
|
|
|
_gaugeWind.setArea(_wind.areas); |
|
_gaugeWind.setArea(_wind.areas); |
_gaugeWind.setMaxMeasuredValue(_wind.maxGustToday); |
|
_gaugeWind.setMaxMeasuredValue(_wind.maxGustToday); |
_gaugeWind.setValueAnimated(_wind.value); |
|
_gaugeWind.setValueAnimated(_wind.value); |
|
|
|
if (ddimgtooltip.showTips) { |
|
if (ddimgtooltip.showTips) { |
// update tooltip |
|
// update tooltip |
tip = strings.tenminavgwind_info + ': ' + _wind.average + ' ' + data.windunit + ' | ' + |
|
tip = strings.tenminavgwind_info + ': ' + _wind.average + ' ' + data.windunit + ' | ' + |
strings.maxavgwind_info + ': ' + _wind.maxAvgToday + ' ' + data.windunit + '<br>' + |
|
strings.maxavgwind_info + ': ' + _wind.maxAvgToday + ' ' + data.windunit + '<br>' + |
strings.tenmingust_info + ': ' + _wind.gust + ' ' + data.windunit + ' | ' + |
|
strings.tenmingust_info + ': ' + _wind.gust + ' ' + data.windunit + ' | ' + |
strings.maxgust_info + ': ' + _wind.maxGustToday + ' ' + data.windunit + ' ' + |
|
strings.maxgust_info + ': ' + _wind.maxGustToday + ' ' + data.windunit + ' ' + |
strings.at + ' ' + data.TwgustTM + ' ' + strings.bearing_info + ': ' + data.bearingTM + |
|
strings.at + ' ' + data.TwgustTM + ' ' + strings.bearing_info + ': ' + data.bearingTM + |
(isNaN(parseFloat(data.bearingTM)) ? '' : '° (' + getord(+data.bearingTM) + ')'); |
|
(isNaN(parseFloat(data.bearingTM)) ? '' : '° (' + getord(+data.bearingTM) + ')'); |
$('#imgtip6_txt').html(tip); |
|
$('#imgtip6_txt').html(tip); |
if (_refreshGraphs && config.showPopupGraphs && config.tipImgs[6] !== null) { |
|
if (_refreshGraphs && config.showPopupGraphs && config.tipImgs[6] !== null) { |
$('#imgtip6_img').attr('src', config.imgPathURL + config.tipImgs[6] + _cacheDefeat); |
|
$('#imgtip6_img').attr('src', config.imgPathURL + config.tipImgs[6] + _cacheDefeat); |
} |
|
} |
} |
|
} |
}, |
|
}, |
|
|
|
doDir = function () { |
|
doDir = function () { |
var windSpd, range, tip; |
|
var windSpd, range, tip; |
|
|
|
_dir.valueLatest = extractInteger(data.bearing); |
|
_dir.valueLatest = extractInteger(data.bearing); |
_dir.titleLatest = strings.latest_title; |
|
_dir.titleLatest = strings.latest_title; |
_dir.valueAverage = extractInteger(data.avgbearing); |
|
_dir.valueAverage = extractInteger(data.avgbearing); |
_dir.titleAverage = strings.tenminavg_title; |
|
_dir.titleAverage = strings.tenminavg_title; |
_dir.bearingFrom = extractInteger(data.BearingRangeFrom10); |
|
_dir.bearingFrom = extractInteger(data.BearingRangeFrom10); |
_dir.bearingTo = extractInteger(data.BearingRangeTo10); |
|
_dir.bearingTo = extractInteger(data.BearingRangeTo10); |
|
|
|
_gaugeDir.setValueAnimatedAverage(+_dir.valueAverage); |
|
_gaugeDir.setValueAnimatedAverage(+_dir.valueAverage); |
if (_dir.valueAverage === 0) { |
|
if (_dir.valueAverage === 0) { |
_dir.valueLatest = 0; |
|
_dir.valueLatest = 0; |
} |
|
} |
_gaugeDir.setValueAnimatedLatest(+_dir.valueLatest); |
|
_gaugeDir.setValueAnimatedLatest(+_dir.valueLatest); |
|
|
|
windSpd = +extractDecimal(data.wspeed); |
|
windSpd = +extractDecimal(data.wspeed); |
switch (data.windunit.toLowerCase()) { |
|
switch (data.windunit.toLowerCase()) { |
case 'mph': |
|
case 'mph': |
_wind.avgKnots = 0.868976242 * windSpd; |
|
_wind.avgKnots = 0.868976242 * windSpd; |
break; |
|
break; |
case 'kts': |
|
case 'kts': |
_wind.avgKnots = windSpd; |
|
_wind.avgKnots = windSpd; |
break; |
|
break; |
case 'm/s': |
|
case 'm/s': |
_wind.avgKnots = 1.94384449 * windSpd; |
|
_wind.avgKnots = 1.94384449 * windSpd; |
break; |
|
break; |
case 'km/h': |
|
case 'km/h': |
case 'kmh': |
|
case 'kmh': |
_wind.avgKnots = 0.539956803 * windSpd; |
|
_wind.avgKnots = 0.539956803 * windSpd; |
break; |
|
break; |
} |
|
} |
if (config.showWindVariation) { |
|
if (config.showWindVariation) { |
if (windSpd > 0) { |
|
if (windSpd > 0) { |
if (_wind.avgKnots < 6) { |
|
if (_wind.avgKnots < 6) { |
_gaugeDir.setSection([steelseries.Section(_dir.bearingFrom, _dir.bearingTo, gauge.minMaxArea)]); |
|
_gaugeDir.setSection([steelseries.Section(_dir.bearingFrom, _dir.bearingTo, gauge.minMaxArea)]); |
_gaugeDir.setArea([]); |
|
_gaugeDir.setArea([]); |
_gaugeDir.VRB = ' - METAR: VRB'; |
|
_gaugeDir.VRB = ' - METAR: VRB'; |
} else { |
|
} else { |
_gaugeDir.setSection([]); |
|
_gaugeDir.setSection([]); |
_gaugeDir.setArea([steelseries.Section(_dir.bearingFrom, _dir.bearingTo, gauge.minMaxArea)]); |
|
_gaugeDir.setArea([steelseries.Section(_dir.bearingFrom, _dir.bearingTo, gauge.minMaxArea)]); |
_gaugeDir.VRB = ' - METAR: ' + _dir.bearingFrom + 'V' + _dir.bearingTo; |
|
_gaugeDir.VRB = ' - METAR: ' + _dir.bearingFrom + 'V' + _dir.bearingTo; |
} |
|
} |
// If variation less than 60 degrees, then METAR = Steady |
|
// If variation less than 60 degrees, then METAR = Steady |
range = (+_dir.bearingTo < +_dir.bearingFrom ? 360 + (+_dir.bearingTo) : +_dir.bearingTo) - (+_dir.bearingFrom); |
|
range = (+_dir.bearingTo < +_dir.bearingFrom ? 360 + (+_dir.bearingTo) : +_dir.bearingTo) - (+_dir.bearingFrom); |
if (range < 60) { |
|
if (range < 60) { |
_gaugeDir.VRB = ' - METAR: STDY'; |
|
_gaugeDir.VRB = ' - METAR: STDY'; |
} |
|
} |
} else { |
|
} else { |
// Zero wind speed, calm |
|
// Zero wind speed, calm |
_gaugeDir.VRB = ' - METAR: 00000KT'; |
|
_gaugeDir.VRB = ' - METAR: 00000KT'; |
_gaugeDir.setSection([]); |
|
_gaugeDir.setSection([]); |
_gaugeDir.setArea([]); |
|
_gaugeDir.setArea([]); |
} |
|
} |
} else { |
|
} else { |
_gaugeDir.VRB = ''; |
|
_gaugeDir.VRB = ''; |
} |
|
} |
if (ddimgtooltip.showTips) { |
|
if (ddimgtooltip.showTips) { |
// update tooltip |
|
// update tooltip |
tip = strings.latest_title + ' ' + strings.bearing_info + ': ' + _dir.valueLatest + '° (' + getord(+_dir.valueLatest) + ')' + _gaugeDir.VRB + '<br>' + |
|
tip = strings.latest_title + ' ' + strings.bearing_info + ': ' + _dir.valueLatest + '° (' + getord(+_dir.valueLatest) + ')' + _gaugeDir.VRB + '<br>' + |
strings.tenminavg_web + ' ' + strings.bearing_info + ': ' + _dir.valueAverage + '° (' + getord(+_dir.valueAverage) + ')' + ', ' + strings.dominant_bearing + ': ' + data.domwinddir; |
|
strings.tenminavg_web + ' ' + strings.bearing_info + ': ' + _dir.valueAverage + '° (' + getord(+_dir.valueAverage) + ')' + ', ' + strings.dominant_bearing + ': ' + data.domwinddir; |
if (!config.showRoseGauge) { |
|
if (!config.showRoseGauge) { |
// Wind run is shown on the wind rose if it is available |
|
// Wind run is shown on the wind rose if it is available |
tip += '<br>' + strings.windruntoday + ': ' + data.windrun + ' ' + _displayUnits.windrun; |
|
tip += '<br>' + strings.windruntoday + ': ' + data.windrun + ' ' + _displayUnits.windrun; |
} |
|
} |
$('#imgtip7_txt').html(tip); |
|
$('#imgtip7_txt').html(tip); |
if (_refreshGraphs && config.showPopupGraphs && config.tipImgs[7] !== null) { |
|
if (_refreshGraphs && config.showPopupGraphs && config.tipImgs[7] !== null) { |
$('#imgtip7_img').attr('src', config.imgPathURL + config.tipImgs[7] + _cacheDefeat); |
|
$('#imgtip7_img').attr('src', config.imgPathURL + config.tipImgs[7] + _cacheDefeat); |
} |
|
} |
} |
|
} |
}, |
|
}, |
|
|
|
doUV = function () { |
|
doUV = function () { |
var tip; |
|
var tip; |
|
|
|
_uv.value = extractDecimal(data.UV); |
|
_uv.value = extractDecimal(data.UV); |
|
|
|
if (+_uv.value === 0) { |
|
if (+_uv.value === 0) { |
_uv.risk = strings.uv_levels[0]; |
|
_uv.risk = strings.uv_levels[0]; |
_uv.headLine = strings.uv_headlines[0]; |
|
_uv.headLine = strings.uv_headlines[0]; |
_uv.detail = strings.uv_details[0]; |
|
_uv.detail = strings.uv_details[0]; |
} else if (_uv.value < 3) { |
|
} else if (_uv.value < 3) { |
_uv.risk = strings.uv_levels[1]; |
|
_uv.risk = strings.uv_levels[1]; |
_uv.headLine = strings.uv_headlines[1]; |
|
_uv.headLine = strings.uv_headlines[1]; |
_uv.detail = strings.uv_details[1]; |
|
_uv.detail = strings.uv_details[1]; |
} else if (_uv.value < 6) { |
|
} else if (_uv.value < 6) { |
_uv.risk = strings.uv_levels[2]; |
|
_uv.risk = strings.uv_levels[2]; |
_uv.headLine = strings.uv_headlines[2]; |
|
_uv.headLine = strings.uv_headlines[2]; |
_uv.detail = strings.uv_details[2]; |
|
_uv.detail = strings.uv_details[2]; |
} else if (_uv.value < 8) { |
|
} else if (_uv.value < 8) { |
_uv.risk = strings.uv_levels[3]; |
|
_uv.risk = strings.uv_levels[3]; |
_uv.headLine = strings.uv_headlines[3]; |
|
_uv.headLine = strings.uv_headlines[3]; |
_uv.detail = strings.uv_details[3]; |
|
_uv.detail = strings.uv_details[3]; |
} else if (_uv.value < 11) { |
|
} else if (_uv.value < 11) { |
_uv.risk = strings.uv_levels[4]; |
|
_uv.risk = strings.uv_levels[4]; |
_uv.headLine = strings.uv_headlines[4]; |
|
_uv.headLine = strings.uv_headlines[4]; |
_uv.detail = strings.uv_details[4]; |
|
_uv.detail = strings.uv_details[4]; |
} else { |
|
} else { |
_uv.risk = strings.uv_levels[5]; |
|
_uv.risk = strings.uv_levels[5]; |
_uv.headLine = strings.uv_headlines[5]; |
|
_uv.headLine = strings.uv_headlines[5]; |
_uv.detail = strings.uv_details[5]; |
|
_uv.detail = strings.uv_details[5]; |
} |
|
} |
|
|
|
_gaugeUV.setValueAnimated(_uv.value); |
|
_gaugeUV.setValueAnimated(_uv.value); |
_gaugeUV.setUnitString(_uv.risk); |
|
_gaugeUV.setUnitString(_uv.risk); |
|
|
|
if (ddimgtooltip.showTips) { |
|
if (ddimgtooltip.showTips) { |
// update tooltip |
|
// update tooltip |
tip = '<b>' + strings.uv_title + ': ' + _uv.value + '</b><br>'; |
|
tip = '<b>' + strings.uv_title + ': ' + _uv.value + '</b><br>'; |
tip += '<i>' + _uv.headLine + '</i><br>'; |
|
tip += '<i>' + _uv.headLine + '</i><br>'; |
tip += _uv.detail; |
|
tip += _uv.detail; |
$('#imgtip8_txt').html(tip); |
|
$('#imgtip8_txt').html(tip); |
if (_refreshGraphs && config.showPopupGraphs && config.tipImgs[8] !== null) { |
|
if (_refreshGraphs && config.showPopupGraphs && config.tipImgs[8] !== null) { |
$('#imgtip8_img').attr('src', config.imgPathURL + config.tipImgs[8] + _cacheDefeat); |
|
$('#imgtip8_img').attr('src', config.imgPathURL + config.tipImgs[8] + _cacheDefeat); |
} |
|
} |
} |
|
} |
}, |
|
}, |
|
|
|
doSolar = function () { |
|
doSolar = function () { |
var tip, percent; |
|
var tip, percent; |
|
|
|
_solar.value = +extractInteger(data.SolarRad); |
|
_solar.value = +extractInteger(data.SolarRad); |
_solar.currMaxValue = +extractInteger(data.CurrentSolarMax); |
|
_solar.currMaxValue = +extractInteger(data.CurrentSolarMax); |
// Set a section (100 units wide) to show current theoretical max value |
|
// Set a section (100 units wide) to show current theoretical max value |
_gaugeSolar.setArea([steelseries.Section(_solar.currMaxValue, Math.min(_solar.currMaxValue + 100, config.solarGaugeScaleMax), 'rgba(220,0,0,0.5)')]); |
|
_gaugeSolar.setArea([steelseries.Section(_solar.currMaxValue, Math.min(_solar.currMaxValue + 100, config.solarGaugeScaleMax), 'rgba(220,0,0,0.5)')]); |
// Set the value |
|
// Set the value |
_gaugeSolar.setValueAnimated(_solar.value); |
|
_gaugeSolar.setValueAnimated(_solar.value); |
// If we have today's max radiation value (WD only) then show it |
|
// If we have today's max radiation value (WD only) then show it |
if (data.SolarTM !== undefined) { |
|
if (data.SolarTM !== undefined) { |
_solar.maxToday = extractInteger(data.SolarTM); |
|
_solar.maxToday = extractInteger(data.SolarTM); |
_gaugeSolar.setMaxMeasuredValue(_solar.maxToday); |
|
_gaugeSolar.setMaxMeasuredValue(_solar.maxToday); |
} |
|
} |
|
|
|
if (ddimgtooltip.showTips) { |
|
if (ddimgtooltip.showTips) { |
// update tooltip |
|
// update tooltip |
percent = (+_solar.currMaxValue === 0 ? '--' : Math.round(+_solar.value / +_solar.currMaxValue * 100)); |
|
percent = (+_solar.currMaxValue === 0 ? '--' : Math.round(+_solar.value / +_solar.currMaxValue * 100)); |
tip = '<b>' + strings.solar_title + ': ' + _solar.value + ' W/m²</b><br>' + |
|
tip = '<b>' + strings.solar_title + ': ' + _solar.value + ' W/m²</b><br>' + |
'<i>' + percent + '% ' + strings.solar_ofMax + '</i><br>' + |
|
'<i>' + percent + '% ' + strings.solar_ofMax + '</i><br>' + |
strings.solar_currentMax + ': ' + _solar.currMaxValue + ' W/m²'; |
|
strings.solar_currentMax + ': ' + _solar.currMaxValue + ' W/m²'; |
if (data.SolarTM !== undefined) { |
|
if (data.SolarTM !== undefined) { |
tip += '<br>' + strings.solar_maxToday + ': ' + _solar.maxToday + ' W/m²'; |
|
tip += '<br>' + strings.solar_maxToday + ': ' + _solar.maxToday + ' W/m²'; |
} |
|
} |
$('#imgtip9_txt').html(tip); |
|
$('#imgtip9_txt').html(tip); |
} |
|
} |
}, |
|
}, |
|
|
|
doRose = function () { |
|
doRose = function () { |
radar.doWindRose(); |
|
radar.doWindRose(); |
if (ddimgtooltip.showTips) { |
|
if (ddimgtooltip.showTips) { |
// update tooltip |
|
// update tooltip |
$('#imgtip10_txt').html(strings.dominant_bearing + ': ' + data.domwinddir + '<br>' + |
|
$('#imgtip10_txt').html(strings.dominant_bearing + ': ' + data.domwinddir + '<br>' + |
strings.windruntoday + ': ' + data.windrun + ' ' + _displayUnits.windrun); |
|
strings.windruntoday + ': ' + data.windrun + ' ' + _displayUnits.windrun); |
if (_refreshGraphs && config.showPopupGraphs && config.tipImgs[10] !== null) { |
|
if (_refreshGraphs && config.showPopupGraphs && config.tipImgs[10] !== null) { |
$('#imgtip10_img').attr('src', config.imgPathURL + config.tipImgs[10] + _cacheDefeat); |
|
$('#imgtip10_img').attr('src', config.imgPathURL + config.tipImgs[10] + _cacheDefeat); |
} |
|
} |
} |
|
} |
}, |
|
}, |
|
|
|
// |
|
// |
// doFirst() called by doUpdate() the first time the page is updated to setup various things that are |
|
// doFirst() called by doUpdate() the first time the page is updated to setup various things that are |
// only known when the realtimegauges.txt data is available |
|
// only known when the realtimegauges.txt data is available |
// |
|
// |
doFirst = function () { |
|
doFirst = function () { |
|
|
|
drawTemp(); |
|
drawTemp(); |
drawDew(); |
|
drawDew(); |
if (data.tempunit.indexOf('F') !== -1) { |
|
if (data.tempunit.indexOf('F') !== -1) { |
_displayUnits.temp = 'F'; |
|
_displayUnits.temp = 'F'; |
setRadioCheck('rad_unitsTemp', 'F'); |
|
setRadioCheck('rad_unitsTemp', 'F'); |
setTempUnits(false); |
|
setTempUnits(false); |
} |
|
} |
|
|
|
drawHum(); |
|
drawHum(); |
|
|
|
drawBaro(); |
|
drawBaro(); |
if (data.pressunit !== 'hPa') { |
|
if (data.pressunit !== 'hPa') { |
_displayUnits.press = data.pressunit; |
|
_displayUnits.press = data.pressunit; |
setRadioCheck('rad_rad_unitsPress', data.pressunit); |
|
setRadioCheck('rad_rad_unitsPress', data.pressunit); |
setBaroUnits(data.pressunit); |
|
setBaroUnits(data.pressunit); |
} |
|
} |
|
|
|
drawWind(); |
|
drawWind(); |
drawDir(); |
|
drawDir(); |
if (data.windunit !== 'mph') { |
|
if (data.windunit !== 'mph') { |
_displayUnits.wind = data.windunit; |
|
_displayUnits.wind = data.windunit; |
setRadioCheck('rad_rad_unitsPress', data.pressunit); |
|
setRadioCheck('rad_rad_unitsPress', data.pressunit); |
setWindUnits(data.windunit); |
|
setWindUnits(data.windunit); |
} |
|
} |
|
|
|
drawRain(); |
|
drawRain(); |
drawRRate(); |
|
drawRRate(); |
if (data.rainunit === 'in') { |
|
if (data.rainunit === 'in') { |
_displayUnits.rain = data.rainunit; |
|
_displayUnits.rain = data.rainunit; |
setRainUnits(false); |
|
setRainUnits(false); |
} |
|
} |
|
|
|
if (config.showSolarGauge) { |
|
if (config.showSolarGauge) { |
drawSolar(); |
|
drawSolar(); |
if (data.SolarTM !== "undefined") { |
|
if (data.SolarTM !== "undefined") { |
_gaugeSolar.setMaxMeasuredValueVisible(true); |
|
_gaugeSolar.setMaxMeasuredValueVisible(true); |
} |
|
} |
} |
|
} |
|
|
|
if (config.showUvGauge) { |
|
if (config.showUvGauge) { |
drawUV(); |
|
drawUV(); |
} |
|
} |
|
|
|
// set the script version on the page |
|
// set the script version on the page |
if ($('#scriptVer').length) { |
|
if ($('#scriptVer').length) { |
$('#scriptVer').html(config.scriptVer); |
|
$('#scriptVer').html(config.scriptVer); |
} |
|
} |
// set the version information from the station |
|
// set the version information from the station |
$('#programVersion').html(data.version); |
|
$('#programVersion').html(data.version); |
$('#programBuild').html(data.build); |
|
$('#programBuild').html(data.build); |
if (config.weatherProgram === 0) { |
|
if (config.weatherProgram === 0) { |
$('#programName').html(_cumuluslink); |
|
$('#programName').html(_cumuluslink); |
} else if (config.weatherProgram === 1) { |
|
} else if (config.weatherProgram === 1) { |
$('#programName').html(_wdisplaylink); |
|
$('#programName').html(_wdisplaylink); |
} else if (config.weatherProgram === 2) { |
|
} else if (config.weatherProgram === 2) { |
$('#programName').html(_vwslink); |
|
$('#programName').html(_vwslink); |
|
-+ |
} else if (config.weatherProgram === 3) { |
|
|
$('#programName').html(_wcatlink); |
} else { |
= |
} else { |
$('#programName').html('<a href="#">n/a</a>'); |
|
$('#programName').html('<a href="#">n/a</a>'); |
} |
|
} |
|
|
|
// has a page timeout over ride password been supplied? |
|
// has a page timeout over ride password been supplied? |
_pageUpdateParam = gup('pageUpdate'); |
|
_pageUpdateParam = gup('pageUpdate'); |
|
|
|
if (config.showPopupData) { |
|
if (config.showPopupData) { |
// now initialise the pop-up script and download the trend images |
|
// now initialise the pop-up script and download the trend images |
// - has to be done here as doFirst may remove elements from the page |
|
// - has to be done here as doFirst may remove elements from the page |
// - and we delay the download of the images speeding up page display |
|
// - and we delay the download of the images speeding up page display |
ddimgtooltip.init('[id^="tip_"]'); |
|
ddimgtooltip.init('[id^="tip_"]'); |
} |
|
} |
}, |
|
}, |
|
|
|
// |
|
// |
// createTempSections() creates an array of gauge sections appropriate for Celcius or Farenheit scales |
|
// createTempSections() creates an array of gauge sections appropriate for Celcius or Farenheit scales |
// |
|
// |
createTempSections = function (celsius) { |
|
createTempSections = function (celsius) { |
var section; |
|
var section; |
if (celsius) { |
|
if (celsius) { |
section = [ |
|
section = [ |
steelseries.Section(-100, -35, 'rgba(195, 92, 211, 0.4)'), |
|
steelseries.Section(-100, -35, 'rgba(195, 92, 211, 0.4)'), |
steelseries.Section(-35, -30, 'rgba(139, 74, 197, 0.4)'), |
|
steelseries.Section(-35, -30, 'rgba(139, 74, 197, 0.4)'), |
steelseries.Section(-30, -25, 'rgba( 98, 65, 188, 0.4)'), |
|
steelseries.Section(-30, -25, 'rgba( 98, 65, 188, 0.4)'), |
steelseries.Section(-25, -20, 'rgba( 62, 66, 185, 0.4)'), |
|
steelseries.Section(-25, -20, 'rgba( 62, 66, 185, 0.4)'), |
steelseries.Section(-20, -15, 'rgba( 42, 84, 194, 0.4)'), |
|
steelseries.Section(-20, -15, 'rgba( 42, 84, 194, 0.4)'), |
steelseries.Section(-15, -10, 'rgba( 25, 112, 210, 0.4)'), |
|
steelseries.Section(-15, -10, 'rgba( 25, 112, 210, 0.4)'), |
steelseries.Section(-10, -5, 'rgba( 9, 150, 224, 0.4)'), |
|
steelseries.Section(-10, -5, 'rgba( 9, 150, 224, 0.4)'), |
steelseries.Section(-5, 0, 'rgba( 2, 170, 209, 0.4)'), |
|
steelseries.Section(-5, 0, 'rgba( 2, 170, 209, 0.4)'), |
steelseries.Section(0, 5, 'rgba( 0, 162, 145, 0.4)'), |
|
steelseries.Section(0, 5, 'rgba( 0, 162, 145, 0.4)'), |
steelseries.Section(5, 10, 'rgba( 0, 158, 122, 0.4)'), |
|
steelseries.Section(5, 10, 'rgba( 0, 158, 122, 0.4)'), |
steelseries.Section(10, 15, 'rgba( 54, 177, 56, 0.4)'), |
|
steelseries.Section(10, 15, 'rgba( 54, 177, 56, 0.4)'), |
steelseries.Section(15, 20, 'rgba(111, 202, 56, 0.4)'), |
|
steelseries.Section(15, 20, 'rgba(111, 202, 56, 0.4)'), |
steelseries.Section(20, 25, 'rgba(248, 233, 45, 0.4)'), |
|
steelseries.Section(20, 25, 'rgba(248, 233, 45, 0.4)'), |
steelseries.Section(25, 30, 'rgba(253, 142, 42, 0.4)'), |
|
steelseries.Section(25, 30, 'rgba(253, 142, 42, 0.4)'), |
steelseries.Section(30, 40, 'rgba(236, 45, 45, 0.4)'), |
|
steelseries.Section(30, 40, 'rgba(236, 45, 45, 0.4)'), |
steelseries.Section(40, 100, 'rgba(245, 109, 205, 0.4)') |
|
steelseries.Section(40, 100, 'rgba(245, 109, 205, 0.4)') |
]; |
|
]; |
} else { |
|
} else { |
section = [ |
|
section = [ |
steelseries.Section(-200, -30, 'rgba(195, 92, 211, 0.4)'), |
|
steelseries.Section(-200, -30, 'rgba(195, 92, 211, 0.4)'), |
steelseries.Section(-30, -25, 'rgba(139, 74, 197, 0.4)'), |
|
steelseries.Section(-30, -25, 'rgba(139, 74, 197, 0.4)'), |
steelseries.Section(-25, -15, 'rgba( 98, 65, 188, 0.4)'), |
|
steelseries.Section(-25, -15, 'rgba( 98, 65, 188, 0.4)'), |
steelseries.Section(-15, -5, 'rgba( 62, 66, 185, 0.4)'), |
|
steelseries.Section(-15, -5, 'rgba( 62, 66, 185, 0.4)'), |
steelseries.Section(-5, 5, 'rgba( 42, 84, 194, 0.4)'), |
|
steelseries.Section(-5, 5, 'rgba( 42, 84, 194, 0.4)'), |
steelseries.Section(5, 15, 'rgba( 25, 112, 210, 0.4)'), |
|
steelseries.Section(5, 15, 'rgba( 25, 112, 210, 0.4)'), |
steelseries.Section(15, 25, 'rgba( 9, 150, 224, 0.4)'), |
|
steelseries.Section(15, 25, 'rgba( 9, 150, 224, 0.4)'), |
steelseries.Section(25, 32, 'rgba( 2, 170, 209, 0.4)'), |
|
steelseries.Section(25, 32, 'rgba( 2, 170, 209, 0.4)'), |
steelseries.Section(32, 40, 'rgba( 0, 162, 145, 0.4)'), |
|
steelseries.Section(32, 40, 'rgba( 0, 162, 145, 0.4)'), |
steelseries.Section(40, 50, 'rgba( 0, 158, 122, 0.4)'), |
|
steelseries.Section(40, 50, 'rgba( 0, 158, 122, 0.4)'), |
steelseries.Section(50, 60, 'rgba( 54, 177, 56, 0.4)'), |
|
steelseries.Section(50, 60, 'rgba( 54, 177, 56, 0.4)'), |
steelseries.Section(60, 70, 'rgba(111, 202, 56, 0.4)'), |
|
steelseries.Section(60, 70, 'rgba(111, 202, 56, 0.4)'), |
steelseries.Section(70, 80, 'rgba(248, 233, 45, 0.4)'), |
|
steelseries.Section(70, 80, 'rgba(248, 233, 45, 0.4)'), |
steelseries.Section(80, 90, 'rgba(253, 142, 42, 0.4)'), |
|
steelseries.Section(80, 90, 'rgba(253, 142, 42, 0.4)'), |
steelseries.Section(90, 110, 'rgba(236, 45, 45, 0.4)'), |
|
steelseries.Section(90, 110, 'rgba(236, 45, 45, 0.4)'), |
steelseries.Section(110, 200, 'rgba(245, 109, 205, 0.4)') |
|
steelseries.Section(110, 200, 'rgba(245, 109, 205, 0.4)') |
]; |
|
]; |
} |
|
} |
return section; |
|
return section; |
}, |
|
}, |
|
|
|
// |
|
// |
// createRainSections() returns an array of section highlights for the Rain Rate gauge |
|
// createRainSections() returns an array of section highlights for the Rain Rate gauge |
// |
|
// |
/* |
|
/* |
Assumes 'standard' descriptive limits from UK met office: |
|
Assumes 'standard' descriptive limits from UK met office: |
< 0.25 mm/hr - Very light rain |
|
< 0.25 mm/hr - Very light rain |
0.25mm/hr to 1.0mm/hr - Light rain |
|
0.25mm/hr to 1.0mm/hr - Light rain |
1.0 mm/hr to 4.0 mm/hr - Moderate rain |
|
1.0 mm/hr to 4.0 mm/hr - Moderate rain |
4.0 mm/hr to 16.0 mm/hr - Heavy rain |
|
4.0 mm/hr to 16.0 mm/hr - Heavy rain |
16.0 mm/hr to 50 mm/hr - Very heavy rain |
|
16.0 mm/hr to 50 mm/hr - Very heavy rain |
> 50.0 mm/hour - Extreme rain |
|
> 50.0 mm/hour - Extreme rain |
|
|
|
Roughly translated to the corresponding Inch rates |
|
Roughly translated to the corresponding Inch rates |
< 0.001 |
|
< 0.001 |
0.001 to 0.05 |
|
0.001 to 0.05 |
0.05 to 0.20 |
|
0.05 to 0.20 |
0.20 to 0.60 |
|
0.20 to 0.60 |
0.60 to 2.0 |
|
0.60 to 2.0 |
> 2.0 |
|
> 2.0 |
*/ |
|
*/ |
createRainRateSections = function (metric) { |
|
createRainRateSections = function (metric) { |
var section; |
|
var section; |
if (metric) { |
|
if (metric) { |
section = [ steelseries.Section(0, 0.25, 'rgba(0, 140, 0, 0.5)'), |
|
section = [ steelseries.Section(0, 0.25, 'rgba(0, 140, 0, 0.5)'), |
steelseries.Section(0.25, 1, 'rgba(80, 192, 80, 0.5)'), |
|
steelseries.Section(0.25, 1, 'rgba(80, 192, 80, 0.5)'), |
steelseries.Section(1, 4, 'rgba(150, 203, 150, 0.5)'), |
|
steelseries.Section(1, 4, 'rgba(150, 203, 150, 0.5)'), |
steelseries.Section(4, 16, 'rgba(212, 203, 109, 0.5)'), |
|
steelseries.Section(4, 16, 'rgba(212, 203, 109, 0.5)'), |
steelseries.Section(16, 50, 'rgba(225, 155, 105, 0.5)'), |
|
steelseries.Section(16, 50, 'rgba(225, 155, 105, 0.5)'), |
steelseries.Section(50, 1000, 'rgba(245, 86, 59, 0.5)')]; |
|
steelseries.Section(50, 1000, 'rgba(245, 86, 59, 0.5)')]; |
} else { |
|
} else { |
section = [ steelseries.Section(0, 0.05, 'rgba(0, 140, 0, 0.5)'), |
|
section = [ steelseries.Section(0, 0.05, 'rgba(0, 140, 0, 0.5)'), |
steelseries.Section(0.05, 0.1, 'rgba(80, 192, 80, 0.5)'), |
|
steelseries.Section(0.05, 0.1, 'rgba(80, 192, 80, 0.5)'), |
steelseries.Section(0.1, 0.15, 'rgba(150, 203, 150, 0.5)'), |
|
steelseries.Section(0.1, 0.15, 'rgba(150, 203, 150, 0.5)'), |
steelseries.Section(0.15, 0.6, 'rgba(212, 203, 109, 0.5)'), |
|
steelseries.Section(0.15, 0.6, 'rgba(212, 203, 109, 0.5)'), |
steelseries.Section(0.6, 2, 'rgba(225, 155, 105, 0.5)'), |
|
steelseries.Section(0.6, 2, 'rgba(225, 155, 105, 0.5)'), |
steelseries.Section(2, 100, 'rgba(245, 86, 59, 0.5)')]; |
|
steelseries.Section(2, 100, 'rgba(245, 86, 59, 0.5)')]; |
} |
|
} |
return section; |
|
return section; |
}, |
|
}, |
|
|
|
// |
|
// |
// createRainFallSections()returns an array of section highlights for total rainfall in mm or inches |
|
// createRainFallSections()returns an array of section highlights for total rainfall in mm or inches |
// |
|
// |
createRainfallSections = function (metric) { |
|
createRainfallSections = function (metric) { |
var section; |
|
var section; |
if (metric) { |
|
if (metric) { |
section = [ steelseries.Section(0, 5, 'rgba(0, 250, 0, 1)'), |
|
section = [ steelseries.Section(0, 5, 'rgba(0, 250, 0, 1)'), |
steelseries.Section(5, 10, 'rgba(0, 250, 117, 1)'), |
|
steelseries.Section(5, 10, 'rgba(0, 250, 117, 1)'), |
steelseries.Section(10, 25, 'rgba(218, 246, 0, 1)'), |
|
steelseries.Section(10, 25, 'rgba(218, 246, 0, 1)'), |
steelseries.Section(25, 40, 'rgba(250, 186, 0, 1)'), |
|
steelseries.Section(25, 40, 'rgba(250, 186, 0, 1)'), |
steelseries.Section(40, 50, 'rgba(250, 95, 0, 1)'), |
|
steelseries.Section(40, 50, 'rgba(250, 95, 0, 1)'), |
steelseries.Section(50, 65, 'rgba(250, 0, 0, 1)'), |
|
steelseries.Section(50, 65, 'rgba(250, 0, 0, 1)'), |
steelseries.Section(65, 75, 'rgba(250, 6, 80, 1)'), |
|
steelseries.Section(65, 75, 'rgba(250, 6, 80, 1)'), |
steelseries.Section(75, 100, 'rgba(205, 18, 158, 1)'), |
|
steelseries.Section(75, 100, 'rgba(205, 18, 158, 1)'), |
steelseries.Section(100, 125, 'rgba(0, 0, 250, 1)'), |
|
steelseries.Section(100, 125, 'rgba(0, 0, 250, 1)'), |
steelseries.Section(125, 500, 'rgba(0, 219, 212, 1)')]; |
|
steelseries.Section(125, 500, 'rgba(0, 219, 212, 1)')]; |
} else { |
|
} else { |
section = [ steelseries.Section(0, 0.2, 'rgba(0, 250, 0, 1)'), |
|
section = [ steelseries.Section(0, 0.2, 'rgba(0, 250, 0, 1)'), |
steelseries.Section(0.2, 0.5, 'rgba(0, 250, 117, 1)'), |
|
steelseries.Section(0.2, 0.5, 'rgba(0, 250, 117, 1)'), |
steelseries.Section(0.5, 1, 'rgba(218, 246, 0, 1)'), |
|
steelseries.Section(0.5, 1, 'rgba(218, 246, 0, 1)'), |
steelseries.Section(1, 1.5, 'rgba(250, 186, 0, 1)'), |
|
steelseries.Section(1, 1.5, 'rgba(250, 186, 0, 1)'), |
steelseries.Section(1.5, 2, 'rgba(250, 95, 0, 1)'), |
|
steelseries.Section(1.5, 2, 'rgba(250, 95, 0, 1)'), |
steelseries.Section(2, 2.5, 'rgba(250, 0, 0, 1)'), |
|
steelseries.Section(2, 2.5, 'rgba(250, 0, 0, 1)'), |
steelseries.Section(2.5, 3, 'rgba(250, 6, 80, 1)'), |
|
steelseries.Section(2.5, 3, 'rgba(250, 6, 80, 1)'), |
steelseries.Section(3, 4, 'rgba(205, 18, 158, 1)'), |
|
steelseries.Section(3, 4, 'rgba(205, 18, 158, 1)'), |
steelseries.Section(4, 5, 'rgba(0, 0, 250, 1)'), |
|
steelseries.Section(4, 5, 'rgba(0, 0, 250, 1)'), |
steelseries.Section(5, 20, 'rgba(0, 219, 212, 1)')]; |
|
steelseries.Section(5, 20, 'rgba(0, 219, 212, 1)')]; |
} |
|
} |
return section; |
|
return section; |
}, |
|
}, |
|
|
|
// |
|
// |
// createRainfallGradient() returns an array of SS colours for continous gradient colouring of the total rainfall LED gauge |
|
// createRainfallGradient() returns an array of SS colours for continous gradient colouring of the total rainfall LED gauge |
// |
|
// |
createRainfallGradient = function (metric) { |
|
createRainfallGradient = function (metric) { |
var grad = new steelseries.gradientWrapper( |
|
var grad = new steelseries.gradientWrapper( |
0, |
|
0, |
(metric ? 100 : 4), |
|
(metric ? 100 : 4), |
[0, 0.1, 0.62, 1], |
|
[0, 0.1, 0.62, 1], |
[new steelseries.rgbaColor(15, 148, 0, 1), |
|
[new steelseries.rgbaColor(15, 148, 0, 1), |
new steelseries.rgbaColor(213, 213, 0, 1), |
|
new steelseries.rgbaColor(213, 213, 0, 1), |
new steelseries.rgbaColor(213, 0, 25, 1), |
|
new steelseries.rgbaColor(213, 0, 25, 1), |
new steelseries.rgbaColor(250, 0, 0, 1)] |
|
new steelseries.rgbaColor(250, 0, 0, 1)] |
); |
|
); |
return grad; |
|
return grad; |
}, |
|
}, |
|
|
|
// |
|
// |
//--------------- Helper functions ------------------ |
|
//--------------- Helper functions ------------------ |
// |
|
// |
|
|
|
// |
|
// |
// getord() converts a value in degrees (0-360) into a localised compass point (N, ENE, NE, etc) |
|
// getord() converts a value in degrees (0-360) into a localised compass point (N, ENE, NE, etc) |
// |
|
// |
getord = function (deg) { |
|
getord = function (deg) { |
if (deg === 0) { |
|
if (deg === 0) { |
// Special case, 0=No wind, 360=North |
|
// Special case, 0=No wind, 360=North |
return strings.calm; |
|
return strings.calm; |
} else { |
|
} else { |
return (strings.coords[Math.floor((deg + 11.25) / 22.5) % 16]); |
|
return (strings.coords[Math.floor((deg + 11.25) / 22.5) % 16]); |
} |
|
} |
}, |
|
}, |
|
|
|
// |
|
// |
// gup() extracts the named parameter from the current page URL |
|
// gup() extracts the named parameter from the current page URL |
// |
|
// |
gup = function (paramName) { |
|
gup = function (paramName) { |
var regexS, regex, results; |
|
var regexS, regex, results; |
paramName = paramName.replace(/(\[|\])/g, '\\$1'); |
|
paramName = paramName.replace(/(\[|\])/g, '\\$1'); |
regexS = '[\\?&]' + paramName + '=([^&#]*)'; |
|
regexS = '[\\?&]' + paramName + '=([^&#]*)'; |
regex = new RegExp(regexS); |
|
regex = new RegExp(regexS); |
results = regex.exec(window.location.href); |
|
results = regex.exec(window.location.href); |
if (results === null) { |
|
if (results === null) { |
return ''; |
|
return ''; |
} else { |
|
} else { |
return results[1]; |
|
return results[1]; |
} |
|
} |
}, |
|
}, |
|
|
|
// |
|
// |
// extractDecimal() returns a decimal number from a string, the decimal point can be either a dot or a comma |
|
// extractDecimal() returns a decimal number from a string, the decimal point can be either a dot or a comma |
// it ignores any text such as pre/appended units |
|
// it ignores any text such as pre/appended units |
// |
|
// |
extractDecimal = function (str) { |
|
extractDecimal = function (str) { |
return (/[\-+]?[0-9]+\.?[0-9]*/).exec(str.replace(',', '.'))[0]; |
|
return (/[\-+]?[0-9]+\.?[0-9]*/).exec(str.replace(',', '.'))[0]; |
}, |
|
}, |
|
|
|
// |
|
// |
// extractInteger() returns an integer from a string |
|
// extractInteger() returns an integer from a string |
// it ignores any text such as pre/appended units |
|
// it ignores any text such as pre/appended units |
// |
|
// |
extractInteger = function (str) { |
|
extractInteger = function (str) { |
return (/[\-+]?[0-9]+/).exec(str)[0]; |
|
return (/[\-+]?[0-9]+/).exec(str)[0]; |
}, |
|
}, |
|
|
|
// |
|
// |
// tempTrend() converts a temperature trend value into a localised string, or +1, 0, -1 depending on the value of bTxt |
|
// tempTrend() converts a temperature trend value into a localised string, or +1, 0, -1 depending on the value of bTxt |
// |
|
// |
tempTrend = function (trend, units, bTxt) { |
|
tempTrend = function (trend, units, bTxt) { |
// Scale is over 3 hours, in Celcius |
|
// Scale is over 3 hours, in Celcius |
var val = trend * 3 * (units.indexOf('C') !== -1 ? 1 : (5 / 9)), |
|
var val = trend * 3 * (units.indexOf('C') !== -1 ? 1 : (5 / 9)), |
ret; |
|
ret; |
if (val > 5) { |
|
if (val > 5) { |
ret = (bTxt ? strings.RisingVeryRapidly : 1); |
|
ret = (bTxt ? strings.RisingVeryRapidly : 1); |
} else if (val > 3) { |
|
} else if (val > 3) { |
ret = (bTxt ? strings.RisingQuickly : 1); |
|
ret = (bTxt ? strings.RisingQuickly : 1); |
} else if (val > 1) { |
|
} else if (val > 1) { |
ret = (bTxt ? strings.Rising : 1); |
|
ret = (bTxt ? strings.Rising : 1); |
} else if (val > 0.5) { |
|
} else if (val > 0.5) { |
ret = (bTxt ? strings.RisingSlowly : 1); |
|
ret = (bTxt ? strings.RisingSlowly : 1); |
} else if (val >= -0.5) { |
|
} else if (val >= -0.5) { |
ret = (bTxt ? strings.Steady : 0); |
|
ret = (bTxt ? strings.Steady : 0); |
} else if (val >= -1) { |
|
} else if (val >= -1) { |
ret = (bTxt ? strings.FallingSlowly : -1); |
|
ret = (bTxt ? strings.FallingSlowly : -1); |
} else if (val >= -3) { |
|
} else if (val >= -3) { |
ret = (bTxt ? strings.Falling : -1); |
|
ret = (bTxt ? strings.Falling : -1); |
} else if (val >= -5) { |
|
} else if (val >= -5) { |
ret = (bTxt ? strings.FallingQuickly : -1); |
|
ret = (bTxt ? strings.FallingQuickly : -1); |
} else { |
|
} else { |
ret = (bTxt ? strings.FallingVeryRapidly : -1); |
|
ret = (bTxt ? strings.FallingVeryRapidly : -1); |
} |
|
} |
return ret; |
|
return ret; |
}, |
|
}, |
|
|
|
// |
|
// |
// baroTrend() converts a pressure trend value into a localised string, or +1, 0, -1 depending on the value of bTxt |
|
// baroTrend() converts a pressure trend value into a localised string, or +1, 0, -1 depending on the value of bTxt |
// |
|
// |
baroTrend = function (trend, units, bTxt) { |
|
baroTrend = function (trend, units, bTxt) { |
var val = trend * 3, |
|
var val = trend * 3, |
ret; |
|
ret; |
// The terms below are the UK Met Office terms for a 3 hour change in hPa |
|
// The terms below are the UK Met Office terms for a 3 hour change in hPa |
// trend is supplied as an hourly change, so multiply by 3 |
|
// trend is supplied as an hourly change, so multiply by 3 |
if (units === 'in' || units === 'inHg') { |
|
if (units === 'in' || units === 'inHg') { |
val *= 33.8639; |
|
val *= 33.8639; |
} else if (units === 'kPa') { |
|
} else if (units === 'kPa') { |
val *= 10; |
|
val *= 10; |
// assume everything else is hPa or mb, could be dangerous! |
|
// assume everything else is hPa or mb, could be dangerous! |
} |
|
} |
if (val > 6.0) { |
|
if (val > 6.0) { |
ret = (bTxt ? strings.RisingVeryRapidly : 1); |
|
ret = (bTxt ? strings.RisingVeryRapidly : 1); |
} else if (val > 3.5) { |
|
} else if (val > 3.5) { |
ret = (bTxt ? strings.RisingQuickly : 1); |
|
ret = (bTxt ? strings.RisingQuickly : 1); |
} else if (val > 1.5) { |
|
} else if (val > 1.5) { |
ret = (bTxt ? strings.Rising : 1); |
|
ret = (bTxt ? strings.Rising : 1); |
} else if (val > 0.1) { |
|
} else if (val > 0.1) { |
ret = (bTxt ? strings.RisingSlowly : 1); |
|
ret = (bTxt ? strings.RisingSlowly : 1); |
} else if (val >= -0.1) { |
|
} else if (val >= -0.1) { |
ret = (bTxt ? strings.Steady : 0); |
|
ret = (bTxt ? strings.Steady : 0); |
} else if (val >= -1.5) { |
|
} else if (val >= -1.5) { |
ret = (bTxt ? strings.FallingSlowly : -1); |
|
ret = (bTxt ? strings.FallingSlowly : -1); |
} else if (val >= -3.5) { |
|
} else if (val >= -3.5) { |
ret = (bTxt ? strings.Falling : -1); |
|
ret = (bTxt ? strings.Falling : -1); |
} else if (val >= -6.0) { |
|
} else if (val >= -6.0) { |
ret = (bTxt ? strings.FallingQuickly : -1); |
|
ret = (bTxt ? strings.FallingQuickly : -1); |
} else { |
|
} else { |
ret = (bTxt ? strings.FallingVeryRapidly : -1); |
|
ret = (bTxt ? strings.FallingVeryRapidly : -1); |
} |
|
} |
return ret; |
|
return ret; |
}, |
|
}, |
|
|
|
// |
|
// |
// getMinTemp() returns the lowest temperature today for gauge scaling |
|
// getMinTemp() returns the lowest temperature today for gauge scaling |
// |
|
// |
getMinTemp = function () { |
|
getMinTemp = function () { |
return Math.min( |
|
return Math.min( |
extractDecimal(data.tempTL), |
|
extractDecimal(data.tempTL), |
extractDecimal(data.dewpointTL), |
|
extractDecimal(data.dewpointTL), |
extractDecimal(data.apptempTL), |
|
extractDecimal(data.apptempTL), |
extractDecimal(data.wchillTL)); |
|
extractDecimal(data.wchillTL)); |
}, |
|
}, |
|
|
|
// |
|
// |
// getMaxTemp() returns the highest temperature today for gauge scaling |
|
// getMaxTemp() returns the highest temperature today for gauge scaling |
// |
|
// |
getMaxTemp = function () { |
|
getMaxTemp = function () { |
return Math.max( |
|
return Math.max( |
extractDecimal(data.tempTH), |
|
extractDecimal(data.tempTH), |
extractDecimal(data.apptempTH), |
|
extractDecimal(data.apptempTH), |
extractDecimal(data.heatindexTH), |
|
extractDecimal(data.heatindexTH), |
extractDecimal(data.humidex)); |
|
extractDecimal(data.humidex)); |
}, |
|
}, |
|
|
|
// Celcius to Farenheit |
|
// Celcius to Farenheit |
c2f = function (val) { |
|
c2f = function (val) { |
return (extractDecimal(val) * 9 / 5 + 32).toFixed(1); |
|
return (extractDecimal(val) * 9 / 5 + 32).toFixed(1); |
}, |
|
}, |
// Farenheit to Celcius |
|
// Farenheit to Celcius |
f2c = function (val) { |
|
f2c = function (val) { |
return ((extractDecimal(val) - 32) * 5 / 9).toFixed(1); |
|
return ((extractDecimal(val) - 32) * 5 / 9).toFixed(1); |
}, |
|
}, |
// mph to ms |
|
// mph to ms |
mph2ms = function (val) { |
|
mph2ms = function (val) { |
return (extractDecimal(val) * 0.447).toFixed(1); |
|
return (extractDecimal(val) * 0.447).toFixed(1); |
}, |
|
}, |
// knots to ms |
|
// knots to ms |
kts2ms = function (val) { |
|
kts2ms = function (val) { |
return (extractDecimal(val) * 0.515).toFixed(1); |
|
return (extractDecimal(val) * 0.515).toFixed(1); |
}, |
|
}, |
// kph to ms |
|
// kph to ms |
kmh2ms = function (val) { |
|
kmh2ms = function (val) { |
return (extractDecimal(val) * 0.2778).toFixed(1); |
|
return (extractDecimal(val) * 0.2778).toFixed(1); |
}, |
|
}, |
// ms to kts |
|
// ms to kts |
ms2kts = function (val) { |
|
ms2kts = function (val) { |
return (extractDecimal(val) * 1.9426).toFixed(1); |
|
return (extractDecimal(val) * 1.9426).toFixed(1); |
}, |
|
}, |
// ms to mph |
|
// ms to mph |
ms2mph = function (val) { |
|
ms2mph = function (val) { |
return (extractDecimal(val) * 2.237).toFixed(1); |
|
return (extractDecimal(val) * 2.237).toFixed(1); |
}, |
|
}, |
// ms to kph |
|
// ms to kph |
ms2kmh = function (val) { |
|
ms2kmh = function (val) { |
return (extractDecimal(val) * 3.6).toFixed(1); |
|
return (extractDecimal(val) * 3.6).toFixed(1); |
}, |
|
}, |
// mm to inches |
|
// mm to inches |
mm2in = function (val) { |
|
mm2in = function (val) { |
return (extractDecimal(val) / 25.4).toFixed(2); |
|
return (extractDecimal(val) / 25.4).toFixed(2); |
}, |
|
}, |
// inches to mm |
|
// inches to mm |
in2mm = function (val) { |
|
in2mm = function (val) { |
return (extractDecimal(val) * 25.4).toFixed(1); |
|
return (extractDecimal(val) * 25.4).toFixed(1); |
}, |
|
}, |
// miles to km |
|
// miles to km |
miles2km = function (val) { |
|
miles2km = function (val) { |
return (extractDecimal(val) * 1.609344).toFixed(1); |
|
return (extractDecimal(val) * 1.609344).toFixed(1); |
}, |
|
}, |
// nautical miles to km |
|
// nautical miles to km |
nmiles2km = function (val) { |
|
nmiles2km = function (val) { |
return (extractDecimal(val) * 1.85200).toFixed(1); |
|
return (extractDecimal(val) * 1.85200).toFixed(1); |
}, |
|
}, |
// km to miles |
|
// km to miles |
km2miles = function (val) { |
|
km2miles = function (val) { |
return (extractDecimal(val) / 1.609344).toFixed(1); |
|
return (extractDecimal(val) / 1.609344).toFixed(1); |
}, |
|
}, |
// km to nautical miles |
|
// km to nautical miles |
km2nmiles = function (val) { |
|
km2nmiles = function (val) { |
return (extractDecimal(val) / 1.85200).toFixed(1); |
|
return (extractDecimal(val) / 1.85200).toFixed(1); |
}, |
|
}, |
// hPa to inHg (@0°C) |
|
// hPa to inHg (@0°C) |
hpa2inhg = function (val, decimals) { |
|
hpa2inhg = function (val, decimals) { |
decimals = decimals || 2; |
|
decimals = decimals || 2; |
return (extractDecimal(val) * 0.029528744).toFixed(decimals); |
|
return (extractDecimal(val) * 0.029528744).toFixed(decimals); |
}, |
|
}, |
// inHg to hPa (@0°C) |
|
// inHg to hPa (@0°C) |
inhg2hpa = function (val) { |
|
inhg2hpa = function (val) { |
return (extractDecimal(val) / 0.029528744).toFixed(1); |
|
return (extractDecimal(val) / 0.029528744).toFixed(1); |
}, |
|
}, |
// kPa to hPa |
|
// kPa to hPa |
kpa2hpa = function (val) { |
|
kpa2hpa = function (val) { |
return (extractDecimal(val) * 10).toFixed(1); |
|
return (extractDecimal(val) * 10).toFixed(1); |
}, |
|
}, |
// hPa to kPa |
|
// hPa to kPa |
hpa2kpa = function (val, decimals) { |
|
hpa2kpa = function (val, decimals) { |
decimals = decimals || 2; |
|
decimals = decimals || 2; |
return (extractDecimal(val) / 10).toFixed(decimals); |
|
return (extractDecimal(val) / 10).toFixed(decimals); |
}, |
|
}, |
|
|
|
// |
|
// |
// setCookie() writes the 'obj' in cookie 'name' for persistant storage |
|
// setCookie() writes the 'obj' in cookie 'name' for persistant storage |
// |
|
// |
setCookie = function (name, obj) { |
|
setCookie = function (name, obj) { |
var date = new Date(), expires; |
|
var date = new Date(), expires; |
// cookies valid for 1 year |
|
// cookies valid for 1 year |
date.setYear(date.getFullYear() + 1); |
|
date.setYear(date.getFullYear() + 1); |
expires = '; expires=' + date.toGMTString(); |
|
expires = '; expires=' + date.toGMTString(); |
document.cookie = name + '=' + encodeURIComponent(JSON.stringify(obj)) + expires; |
|
document.cookie = name + '=' + encodeURIComponent(JSON.stringify(obj)) + expires; |
}, |
|
}, |
|
|
|
// |
|
// |
// getCookie() reads the value of cookie 'name' from persitent storage |
|
// getCookie() reads the value of cookie 'name' from persitent storage |
// |
|
// |
getCookie = function (name) { |
|
getCookie = function (name) { |
var i, x, y, ret = null, |
|
var i, x, y, ret = null, |
arrCookies = document.cookie.split(';'); |
|
arrCookies = document.cookie.split(';'); |
|
|
|
for (i = arrCookies.length; i--;) { |
|
for (i = arrCookies.length; i--;) { |
x = arrCookies[i].split('='); |
|
x = arrCookies[i].split('='); |
if (x[0].trim() === name) { |
|
if (x[0].trim() === name) { |
try { |
|
try { |
y = decodeURIComponent(x[1]); |
|
y = decodeURIComponent(x[1]); |
} catch (e) { |
|
} catch (e) { |
y = x[1]; |
|
y = x[1]; |
} |
|
} |
ret = JSON.parse(unescape(y)); |
|
ret = JSON.parse(unescape(y)); |
break; |
|
break; |
} |
|
} |
} |
|
} |
return ret; |
|
return ret; |
}, |
|
}, |
|
|
|
// |
|
// |
// setRadioCheck() sets the desired value of the HTML radio buttons to be selected |
|
// setRadioCheck() sets the desired value of the HTML radio buttons to be selected |
// |
|
// |
setRadioCheck = function (obj, val) { |
|
setRadioCheck = function (obj, val) { |
$('input:radio[name="' + obj + '"]').filter('[value="' + val + '"]').attr('checked', true); |
|
$('input:radio[name="' + obj + '"]').filter('[value="' + val + '"]').attr('checked', true); |
}, |
|
}, |
|
|
|
// |
|
// |
// convTempData() converts all the temperature values using the supplied conversion function |
|
// convTempData() converts all the temperature values using the supplied conversion function |
// |
|
// |
convTempData = function (convFunc) { |
|
convTempData = function (convFunc) { |
data.apptemp = convFunc(data.apptemp); |
|
data.apptemp = convFunc(data.apptemp); |
data.apptempTH = convFunc(data.apptempTH); |
|
data.apptempTH = convFunc(data.apptempTH); |
data.apptempTL = convFunc(data.apptempTL); |
|
data.apptempTL = convFunc(data.apptempTL); |
data.dew = convFunc(data.dew); |
|
data.dew = convFunc(data.dew); |
data.dewpointTH = convFunc(data.dewpointTH); |
|
data.dewpointTH = convFunc(data.dewpointTH); |
data.dewpointTL = convFunc(data.dewpointTL); |
|
data.dewpointTL = convFunc(data.dewpointTL); |
data.heatindex = convFunc(data.heatindex); |
|
data.heatindex = convFunc(data.heatindex); |
data.heatindexTH = convFunc(data.heatindexTH); |
|
data.heatindexTH = convFunc(data.heatindexTH); |
data.humidex = convFunc(data.humidex); |
|
data.humidex = convFunc(data.humidex); |
data.intemp = convFunc(data.intemp); |
|
data.intemp = convFunc(data.intemp); |
data.temp = convFunc(data.temp); |
|
data.temp = convFunc(data.temp); |
data.tempTH = convFunc(data.tempTH); |
|
data.tempTH = convFunc(data.tempTH); |
data.tempTL = convFunc(data.tempTL); |
|
data.tempTL = convFunc(data.tempTL); |
data.wchill = convFunc(data.wchill); |
|
data.wchill = convFunc(data.wchill); |
data.wchillTL = convFunc(data.wchillTL); |
|
data.wchillTL = convFunc(data.wchillTL); |
if (convFunc === c2f) { |
|
if (convFunc === c2f) { |
data.temptrend = (+extractDecimal(data.temptrend) * 9 / 5).toFixed(1); |
|
data.temptrend = (+extractDecimal(data.temptrend) * 9 / 5).toFixed(1); |
data.tempunit = '°F'; |
|
data.tempunit = '°F'; |
} else { |
|
} else { |
data.temptrend = (+extractDecimal(data.temptrend) * 5 / 9).toFixed(1); |
|
data.temptrend = (+extractDecimal(data.temptrend) * 5 / 9).toFixed(1); |
data.tempunit = '°C'; |
|
data.tempunit = '°C'; |
} |
|
} |
}, |
|
}, |
|
|
|
// |
|
// |
// convRainData() converts all the rain data units using the supplied conversion function |
|
// convRainData() converts all the rain data units using the supplied conversion function |
// |
|
// |
convRainData = function (convFunc) { |
|
convRainData = function (convFunc) { |
data.rfall = convFunc(data.rfall); |
|
data.rfall = convFunc(data.rfall); |
data.rrate = convFunc(data.rrate); |
|
data.rrate = convFunc(data.rrate); |
data.rrateTM = convFunc(data.rrateTM); |
|
data.rrateTM = convFunc(data.rrateTM); |
data.rainunit = convFunc === mm2in ? 'in' : 'mm'; |
|
data.rainunit = convFunc === mm2in ? 'in' : 'mm'; |
}, |
|
}, |
|
|
|
// |
|
// |
// convWindData() converts all the wind values using the supplied coversion function |
|
// convWindData() converts all the wind values using the supplied coversion function |
// |
|
// |
convWindData = function (from, to) { |
|
convWindData = function (from, to) { |
var fromFunc1, toFunc1, |
|
var fromFunc1, toFunc1, |
fromFunc2, toFunc2, |
|
fromFunc2, toFunc2, |
dummy = function (val) { |
|
dummy = function (val) { |
return val; |
|
return val; |
}; |
|
}; |
|
|
|
// convert to m/s & km |
|
// convert to m/s & km |
switch (from) { |
|
switch (from) { |
case 'mph': |
|
case 'mph': |
fromFunc1 = mph2ms; |
|
fromFunc1 = mph2ms; |
fromFunc2 = miles2km; |
|
fromFunc2 = miles2km; |
break; |
|
break; |
case 'kts': |
|
case 'kts': |
fromFunc1 = kts2ms; |
|
fromFunc1 = kts2ms; |
fromFunc2 = nmiles2km; |
|
fromFunc2 = nmiles2km; |
break; |
|
break; |
case 'km/h': |
|
case 'km/h': |
fromFunc1 = kmh2ms; |
|
fromFunc1 = kmh2ms; |
fromFunc2 = dummy; |
|
fromFunc2 = dummy; |
break; |
|
break; |
case 'm/s': |
|
case 'm/s': |
/* falls through */ |
|
/* falls through */ |
default: |
|
default: |
fromFunc1 = dummy; |
|
fromFunc1 = dummy; |
fromFunc2 = dummy; |
|
fromFunc2 = dummy; |
} |
|
} |
// conversion function from km to required units |
|
// conversion function from km to required units |
switch (to) { |
|
switch (to) { |
case 'mph': |
|
case 'mph': |
toFunc1 = ms2mph; |
|
toFunc1 = ms2mph; |
toFunc2 = km2miles; |
|
toFunc2 = km2miles; |
_displayUnits.windrun = 'miles'; |
|
_displayUnits.windrun = 'miles'; |
break; |
|
break; |
case 'kts': |
|
case 'kts': |
toFunc1 = ms2kts; |
|
toFunc1 = ms2kts; |
toFunc2 = km2nmiles; |
|
toFunc2 = km2nmiles; |
_displayUnits.windrun = 'n.miles'; |
|
_displayUnits.windrun = 'n.miles'; |
break; |
|
break; |
case 'km/h': |
|
case 'km/h': |
toFunc1 = ms2kmh; |
|
toFunc1 = ms2kmh; |
toFunc2 = dummy; |
|
toFunc2 = dummy; |
_displayUnits.windrun = 'km'; |
|
_displayUnits.windrun = 'km'; |
break; |
|
break; |
case 'm/s': |
|
case 'm/s': |
/* falls through */ |
|
/* falls through */ |
default: |
|
default: |
toFunc1 = dummy; |
|
toFunc1 = dummy; |
toFunc2 = dummy; |
|
toFunc2 = dummy; |
_displayUnits.windrun = 'km'; |
|
_displayUnits.windrun = 'km'; |
} |
|
} |
// do the conversions |
|
// do the conversions |
data.wgust = toFunc1(fromFunc1(data.wgust)); |
|
data.wgust = toFunc1(fromFunc1(data.wgust)); |
data.wgustTM = toFunc1(fromFunc1(data.wgustTM)); |
|
data.wgustTM = toFunc1(fromFunc1(data.wgustTM)); |
data.windTM = toFunc1(fromFunc1(data.windTM)); |
|
data.windTM = toFunc1(fromFunc1(data.windTM)); |
data.windrun = toFunc2(fromFunc2(data.windrun)); |
|
data.windrun = toFunc2(fromFunc2(data.windrun)); |
data.wlatest = toFunc1(fromFunc1(data.wlatest)); |
|
data.wlatest = toFunc1(fromFunc1(data.wlatest)); |
data.wspeed = toFunc1(fromFunc1(data.wspeed)); |
|
data.wspeed = toFunc1(fromFunc1(data.wspeed)); |
data.windunit = to; |
|
data.windunit = to; |
}, |
|
}, |
|
|
|
// |
|
// |
// convBaroData() converts all the pressure values using the supplied coversion function |
|
// convBaroData() converts all the pressure values using the supplied coversion function |
// |
|
// |
convBaroData = function (from, to) { |
|
convBaroData = function (from, to) { |
var fromFunc, toFunc, |
|
var fromFunc, toFunc, |
dummy = function (val) { |
|
dummy = function (val) { |
return val; |
|
return val; |
}; |
|
}; |
|
|
|
// convert to hPa |
|
// convert to hPa |
switch (from) { |
|
switch (from) { |
case 'hPa': |
|
case 'hPa': |
/* falls through */ |
|
/* falls through */ |
case 'mb': |
|
case 'mb': |
fromFunc = dummy; |
|
fromFunc = dummy; |
break; |
|
break; |
case 'inHg': |
|
case 'inHg': |
fromFunc = inhg2hpa; |
|
fromFunc = inhg2hpa; |
break; |
|
break; |
case 'kPa': |
|
case 'kPa': |
fromFunc = kpa2hpa; |
|
fromFunc = kpa2hpa; |
break; |
|
break; |
} |
|
} |
// convert to required units |
|
// convert to required units |
switch (to) { |
|
switch (to) { |
case 'hPa': |
|
case 'hPa': |
/* falls through */ |
|
/* falls through */ |
case 'mb': |
|
case 'mb': |
toFunc = dummy; |
|
toFunc = dummy; |
break; |
|
break; |
case 'inHg': |
|
case 'inHg': |
toFunc = hpa2inhg; |
|
toFunc = hpa2inhg; |
break; |
|
break; |
case 'kPa': |
|
case 'kPa': |
toFunc = hpa2kpa; |
|
toFunc = hpa2kpa; |
break; |
|
break; |
} |
|
} |
|
|
|
data.press = toFunc(fromFunc(data.press)); |
|
data.press = toFunc(fromFunc(data.press)); |
data.pressH = toFunc(fromFunc(data.pressH)); |
|
data.pressH = toFunc(fromFunc(data.pressH)); |
data.pressL = toFunc(fromFunc(data.pressL)); |
|
data.pressL = toFunc(fromFunc(data.pressL)); |
data.pressTH = toFunc(fromFunc(data.pressTH)); |
|
data.pressTH = toFunc(fromFunc(data.pressTH)); |
data.pressTL = toFunc(fromFunc(data.pressTL)); |
|
data.pressTL = toFunc(fromFunc(data.pressTL)); |
data.presstrendval = toFunc(fromFunc(data.presstrendval), 3); |
|
data.presstrendval = toFunc(fromFunc(data.presstrendval), 3); |
data.pressunit = to; |
|
data.pressunit = to; |
}, |
|
}, |
|
|
|
// |
|
// |
// setUnits() Main data conversion routine, calls all the sub-routines |
|
// setUnits() Main data conversion routine, calls all the sub-routines |
// |
|
// |
setUnits = function (radio) { |
|
setUnits = function (radio) { |
var sel = radio.value; |
|
var sel = radio.value; |
|
|
|
_userUnitsSet = true; |
|
_userUnitsSet = true; |
|
|
|
switch (sel) { |
|
switch (sel) { |
// == Temperature == |
|
// == Temperature == |
case 'C': |
|
case 'C': |
_displayUnits.temp = sel; |
|
_displayUnits.temp = sel; |
if (data.tempunit.indexOf(sel) === -1) { |
|
if (data.tempunit.indexOf(sel) === -1) { |
setTempUnits(true); |
|
setTempUnits(true); |
convTempData(f2c); |
|
convTempData(f2c); |
doTemp(); |
|
doTemp(); |
doDew(); |
|
doDew(); |
} |
|
} |
break; |
|
break; |
case 'F': |
|
case 'F': |
_displayUnits.temp = sel; |
|
_displayUnits.temp = sel; |
if (data.tempunit.indexOf(sel) === -1) { |
|
if (data.tempunit.indexOf(sel) === -1) { |
setTempUnits(false); |
|
setTempUnits(false); |
convTempData(c2f); |
|
convTempData(c2f); |
doTemp(); |
|
doTemp(); |
doDew(); |
|
doDew(); |
} |
|
} |
break; |
|
break; |
// == Rainfall == |
|
// == Rainfall == |
case 'mm': |
|
case 'mm': |
_displayUnits.rain = sel; |
|
_displayUnits.rain = sel; |
if (data.rainunit !== sel) { |
|
if (data.rainunit !== sel) { |
setRainUnits(true); |
|
setRainUnits(true); |
convRainData(in2mm); |
|
convRainData(in2mm); |
doRain(); |
|
doRain(); |
doRRate(); |
|
doRRate(); |
} |
|
} |
break; |
|
break; |
case 'in': |
|
case 'in': |
_displayUnits.rain = sel; |
|
_displayUnits.rain = sel; |
if (data.rainunit !== sel) { |
|
if (data.rainunit !== sel) { |
setRainUnits(false); |
|
setRainUnits(false); |
convRainData(mm2in); |
|
convRainData(mm2in); |
doRain(); |
|
doRain(); |
doRRate(); |
|
doRRate(); |
} |
|
} |
break; |
|
break; |
// == Pressure == |
|
// == Pressure == |
case 'hPa': |
|
case 'hPa': |
/* falls through */ |
|
/* falls through */ |
case 'inHg': |
|
case 'inHg': |
/* falls through */ |
|
/* falls through */ |
case 'mb': |
|
case 'mb': |
/* falls through */ |
|
/* falls through */ |
case 'kPa': |
|
case 'kPa': |
_displayUnits.press = sel; |
|
_displayUnits.press = sel; |
if (data.pressunit !== sel) { |
|
if (data.pressunit !== sel) { |
convBaroData(data.pressunit, sel); |
|
convBaroData(data.pressunit, sel); |
setBaroUnits(sel); |
|
setBaroUnits(sel); |
doBaro(); |
|
doBaro(); |
} |
|
} |
break; |
|
break; |
// == Wind speed == |
|
// == Wind speed == |
case 'mph': |
|
case 'mph': |
/* falls through */ |
|
/* falls through */ |
case 'kts': |
|
case 'kts': |
/* falls through */ |
|
/* falls through */ |
case 'm/s': |
|
case 'm/s': |
/* falls through */ |
|
/* falls through */ |
case 'km/h': |
|
case 'km/h': |
_displayUnits.wind = sel; |
|
_displayUnits.wind = sel; |
if (data.windunit !== sel) { |
|
if (data.windunit !== sel) { |
convWindData(data.windunit, sel); |
|
convWindData(data.windunit, sel); |
setWindUnits(sel); |
|
setWindUnits(sel); |
doWind(); |
|
doWind(); |
doDir(); |
|
doDir(); |
if (config.showRoseGauge && typeof radar !== "undefined") { |
|
if (config.showRoseGauge && typeof radar !== "undefined") { |
doRose(); |
|
doRose(); |
} |
|
} |
} |
|
} |
break; |
|
break; |
} |
|
} |
if (config.useCookies) { |
|
if (config.useCookies) { |
setCookie('units', _displayUnits); |
|
setCookie('units', _displayUnits); |
} |
|
} |
}, |
|
}, |
|
|
|
setTempUnits = function (celcius) { |
|
setTempUnits = function (celcius) { |
if (celcius) { |
|
if (celcius) { |
data.tempunit = '°C'; |
|
data.tempunit = '°C'; |
_temp.sections = createTempSections(true); |
|
_temp.sections = createTempSections(true); |
_temp.minValue = gauge.tempScaleDefMinC; |
|
_temp.minValue = gauge.tempScaleDefMinC; |
_temp.maxValue = gauge.tempScaleDefMaxC; |
|
_temp.maxValue = gauge.tempScaleDefMaxC; |
_dew.sections = createTempSections(true); |
|
_dew.sections = createTempSections(true); |
_dew.minValue = gauge.tempScaleDefMinC; |
|
_dew.minValue = gauge.tempScaleDefMinC; |
_dew.maxValue = gauge.tempScaleDefMaxC; |
|
_dew.maxValue = gauge.tempScaleDefMaxC; |
} else { |
|
} else { |
data.tempunit = '°F'; |
|
data.tempunit = '°F'; |
_temp.sections = createTempSections(false); |
|
_temp.sections = createTempSections(false); |
_temp.minValue = gauge.tempScaleDefMinF; |
|
_temp.minValue = gauge.tempScaleDefMinF; |
_temp.maxValue = gauge.tempScaleDefMaxF; |
|
_temp.maxValue = gauge.tempScaleDefMaxF; |
_dew.sections = createTempSections(false); |
|
_dew.sections = createTempSections(false); |
_dew.minValue = gauge.tempScaleDefMinF; |
|
_dew.minValue = gauge.tempScaleDefMinF; |
_dew.maxValue = gauge.tempScaleDefMaxF; |
|
_dew.maxValue = gauge.tempScaleDefMaxF; |
} |
|
} |
_gaugeTemp.setUnitString(data.tempunit); |
|
_gaugeTemp.setUnitString(data.tempunit); |
_gaugeTemp.setSection(_temp.sections); |
|
_gaugeTemp.setSection(_temp.sections); |
_gaugeDew.setUnitString(data.tempunit); |
|
_gaugeDew.setUnitString(data.tempunit); |
_gaugeDew.setSection(_temp.sections); |
|
_gaugeDew.setSection(_temp.sections); |
}, |
|
}, |
|
|
|
setRainUnits = function (mm) { |
|
setRainUnits = function (mm) { |
if (mm) { |
|
if (mm) { |
data.rainunit = 'mm'; |
|
data.rainunit = 'mm'; |
_rain.lcdDecimals = 1; |
|
_rain.lcdDecimals = 1; |
_rain.scaleDecimals = 1; |
|
_rain.scaleDecimals = 1; |
_rain.labelNumberFormat = gauge.labelFormat; |
|
_rain.labelNumberFormat = gauge.labelFormat; |
_rain.sections = (gauge.rainUseSectionColours ? createRainfallSections(true) : []); |
|
_rain.sections = (gauge.rainUseSectionColours ? createRainfallSections(true) : []); |
_rain.maxValue = 10; |
|
_rain.maxValue = 10; |
_rain.grad = (gauge.rainUseGradientColours ? createRainfallGradient(true) : null); |
|
_rain.grad = (gauge.rainUseGradientColours ? createRainfallGradient(true) : null); |
_rrate.lcdDecimals = 1; |
|
_rrate.lcdDecimals = 1; |
_rrate.scaleDecimals = 0; |
|
_rrate.scaleDecimals = 0; |
_rrate.labelNumberFormat = gauge.labelFormat; |
|
_rrate.labelNumberFormat = gauge.labelFormat; |
_rrate.sections = createRainRateSections(true); |
|
_rrate.sections = createRainRateSections(true); |
_rrate.maxValue = 10; |
|
_rrate.maxValue = 10; |
} else { |
|
} else { |
data.rainunit = 'in'; |
|
data.rainunit = 'in'; |
_rain.lcdDecimals = 2; |
|
_rain.lcdDecimals = 2; |
_rain.scaleDecimals = 1; |
|
_rain.scaleDecimals = 1; |
_rain.labelNumberFormat = steelseries.LabelNumberFormat.FRACTIONAL; |
|
_rain.labelNumberFormat = steelseries.LabelNumberFormat.FRACTIONAL; |
_rain.sections = (gauge.rainUseSectionColours ? createRainfallSections(false) : []); |
|
_rain.sections = (gauge.rainUseSectionColours ? createRainfallSections(false) : []); |
_rain.maxValue = 1; |
|
_rain.maxValue = 1; |
_rain.grad = (gauge.rainUseGradientColours ? createRainfallGradient(false) : null); |
|
_rain.grad = (gauge.rainUseGradientColours ? createRainfallGradient(false) : null); |
_rrate.lcdDecimals = 2; |
|
_rrate.lcdDecimals = 2; |
_rrate.scaleDecimals = 1; |
|
_rrate.scaleDecimals = 1; |
_rrate.labelNumberFormat = steelseries.LabelNumberFormat.FRACTIONAL; |
|
_rrate.labelNumberFormat = steelseries.LabelNumberFormat.FRACTIONAL; |
_rrate.sections = createRainRateSections(false); |
|
_rrate.sections = createRainRateSections(false); |
_rrate.maxValue = 1; |
|
_rrate.maxValue = 1; |
} |
|
} |
_rain.value = 0; |
|
_rain.value = 0; |
_rrate.value = 0; |
|
_rrate.value = 0; |
_gaugeRain.setUnitString(data.rainunit); |
|
_gaugeRain.setUnitString(data.rainunit); |
_gaugeRain.setSection(_rain.sections); |
|
_gaugeRain.setSection(_rain.sections); |
_gaugeRain.setGradient(_rain.grad); |
|
_gaugeRain.setGradient(_rain.grad); |
_gaugeRain.setFractionalScaleDecimals(_rain.scaleDecimals); |
|
_gaugeRain.setFractionalScaleDecimals(_rain.scaleDecimals); |
_gaugeRain.setLabelNumberFormat(_rain.labelNumberFormat); |
|
_gaugeRain.setLabelNumberFormat(_rain.labelNumberFormat); |
_gaugeRain.setLcdDecimals(_rain.lcdDecimals); |
|
_gaugeRain.setLcdDecimals(_rain.lcdDecimals); |
_gaugeRRate.setUnitString(data.rainunit + '/h'); |
|
_gaugeRRate.setUnitString(data.rainunit + '/h'); |
_gaugeRRate.setSection(_rrate.sections); |
|
_gaugeRRate.setSection(_rrate.sections); |
_gaugeRRate.setFractionalScaleDecimals(_rrate.scaleDecimals); |
|
_gaugeRRate.setFractionalScaleDecimals(_rrate.scaleDecimals); |
_gaugeRRate.setLabelNumberFormat(_rrate.labelNumberFormat); |
|
_gaugeRRate.setLabelNumberFormat(_rrate.labelNumberFormat); |
_gaugeRRate.setLcdDecimals(_rrate.lcdDecimals); |
|
_gaugeRRate.setLcdDecimals(_rrate.lcdDecimals); |
}, |
|
}, |
|
|
|
setWindUnits = function (to) { |
|
setWindUnits = function (to) { |
var maxVal; |
|
var maxVal; |
|
|
|
// conversion function to required units |
|
// conversion function to required units |
switch (to) { |
|
switch (to) { |
case 'mph': |
|
case 'mph': |
maxVal = gauge.windScaleDefMaxMph; |
|
maxVal = gauge.windScaleDefMaxMph; |
break; |
|
break; |
case 'kts': |
|
case 'kts': |
maxVal = gauge.windScaleDefMaxKts; |
|
maxVal = gauge.windScaleDefMaxKts; |
break; |
|
break; |
case 'km/h': |
|
case 'km/h': |
maxVal = gauge.windScaleDefMaxKmh; |
|
maxVal = gauge.windScaleDefMaxKmh; |
break; |
|
break; |
case 'm/s': |
|
case 'm/s': |
maxVal = gauge.windScaleDefMaxMs; |
|
maxVal = gauge.windScaleDefMaxMs; |
} |
|
} |
// set the gauges |
|
// set the gauges |
data.windunit = to; |
|
data.windunit = to; |
_wind.maxValue = maxVal; |
|
_wind.maxValue = maxVal; |
_gaugeWind.setUnitString(data.windunit); |
|
_gaugeWind.setUnitString(data.windunit); |
_gaugeWind.setValue(0); |
|
_gaugeWind.setValue(0); |
}, |
|
}, |
|
|
|
setBaroUnits = function (to) { |
|
setBaroUnits = function (to) { |
var minVal, maxVal; |
|
var minVal, maxVal; |
|
|
|
// set to the required units |
|
// set to the required units |
switch (to) { |
|
switch (to) { |
case 'hPa': |
|
case 'hPa': |
/* falls through */ |
|
/* falls through */ |
case 'mb': |
|
case 'mb': |
minVal = gauge.baroScaleDefMinhPa; |
|
minVal = gauge.baroScaleDefMinhPa; |
maxVal = gauge.baroScaleDefMaxhPa; |
|
maxVal = gauge.baroScaleDefMaxhPa; |
_baro.lcdDecimals = 1; |
|
_baro.lcdDecimals = 1; |
_baro.scaleDecimals = 0; |
|
_baro.scaleDecimals = 0; |
_baro.labelNumberFormat = gauge.labelFormat; |
|
_baro.labelNumberFormat = gauge.labelFormat; |
break; |
|
break; |
case 'inHg': |
|
case 'inHg': |
minVal = gauge.baroScaleDefMininHg; |
|
minVal = gauge.baroScaleDefMininHg; |
maxVal = gauge.baroScaleDefMaxinHg; |
|
maxVal = gauge.baroScaleDefMaxinHg; |
_baro.lcdDecimals = 2; |
|
_baro.lcdDecimals = 2; |
_baro.scaleDecimals = 1; |
|
_baro.scaleDecimals = 1; |
_baro.labelNumberFormat = steelseries.LabelNumberFormat.FRACTIONAL; |
|
_baro.labelNumberFormat = steelseries.LabelNumberFormat.FRACTIONAL; |
break; |
|
break; |
case 'kPa': |
|
case 'kPa': |
minVal = gauge.baroScaleDefMinkPa; |
|
minVal = gauge.baroScaleDefMinkPa; |
maxVal = gauge.baroScaleDefMaxkPa; |
|
maxVal = gauge.baroScaleDefMaxkPa; |
_baro.lcdDecimals = 2; |
|
_baro.lcdDecimals = 2; |
_baro.scaleDecimals = 1; |
|
_baro.scaleDecimals = 1; |
_baro.labelNumberFormat = steelseries.LabelNumberFormat.FRACTIONAL; |
|
_baro.labelNumberFormat = steelseries.LabelNumberFormat.FRACTIONAL; |
break; |
|
break; |
} |
|
} |
|
|
|
data.pressunit = to; |
|
data.pressunit = to; |
_gaugeBaro.setUnitString(to); |
|
_gaugeBaro.setUnitString(to); |
_gaugeBaro.setLcdDecimals(_baro.lcdDecimals); |
|
_gaugeBaro.setLcdDecimals(_baro.lcdDecimals); |
_gaugeBaro.setFractionalScaleDecimals(_baro.scaleDecimals); |
|
_gaugeBaro.setFractionalScaleDecimals(_baro.scaleDecimals); |
_gaugeBaro.setLabelNumberFormat(_baro.labelNumberFormat); |
|
_gaugeBaro.setLabelNumberFormat(_baro.labelNumberFormat); |
_baro.minValue = minVal; |
|
_baro.minValue = minVal; |
_baro.maxValue = maxVal; |
|
_baro.maxValue = maxVal; |
_baro.value = _baro.minValue; |
|
_baro.value = _baro.minValue; |
}, |
|
}, |
|
|
|
// |
|
// |
// setLang() switches the HTML page language set, called by changeLang() in language.js |
|
// setLang() switches the HTML page language set, called by changeLang() in language.js |
// |
|
// |
setLang = function (newLang) { |
|
setLang = function (newLang) { |
// reset to the new language |
|
// reset to the new language |
strings = newLang; |
|
strings = newLang; |
|
|
|
// temperature |
|
// temperature |
if ($('#rad_temp1').is(':checked')) { |
|
if ($('#rad_temp1').is(':checked')) { |
_temp.title = strings.temp_title_out; |
|
_temp.title = strings.temp_title_out; |
} else { |
|
} else { |
_temp.title = strings.temp_title_in; |
|
_temp.title = strings.temp_title_in; |
} |
|
} |
|
|
|
switch ($('input[name="rad_dew"]:checked').val()) { |
|
switch ($('input[name="rad_dew"]:checked').val()) { |
case 'dew': |
|
case 'dew': |
_dew.title = strings.dew_title; |
|
_dew.title = strings.dew_title; |
break; |
|
break; |
case 'app': |
|
case 'app': |
_dew.title = strings.apptemp_title; |
|
_dew.title = strings.apptemp_title; |
break; |
|
break; |
case 'wnd': |
|
case 'wnd': |
_dew.title = strings.chill_title; |
|
_dew.title = strings.chill_title; |
break; |
|
break; |
case 'hea': |
|
case 'hea': |
_dew.title = strings.heat_title; |
|
_dew.title = strings.heat_title; |
break; |
|
break; |
case 'hum': |
|
case 'hum': |
_dew.title = strings.humdx_title; |
|
_dew.title = strings.humdx_title; |
break; |
|
break; |
} |
|
} |
// rain |
|
// rain |
_rain.title = strings.rain_title; |
|
_rain.title = strings.rain_title; |
// rrate |
|
// rrate |
_rrate.title = strings.rrate_title; |
|
_rrate.title = strings.rrate_title; |
// humidty |
|
// humidty |
if ($('#rad_hum1').is(':checked')) { |
|
if ($('#rad_hum1').is(':checked')) { |
_hum.title = strings.hum_title_out; |
|
_hum.title = strings.hum_title_out; |
} else { |
|
} else { |
_hum.title = strings.hum_title_in; |
|
_hum.title = strings.hum_title_in; |
} |
|
} |
// barometer |
|
// barometer |
_baro.title = strings.baro_title; |
|
_baro.title = strings.baro_title; |
// wind |
|
// wind |
_wind.title = strings.wind_title; |
|
_wind.title = strings.wind_title; |
|
|
|
// can't do anything about the LED and status at the moment :( |
|
// can't do anything about the LED and status at the moment :( |
//g_led.title = strings.led_title; |
|
//g_led.title = strings.led_title; |
|
|
|
// Update all the title string and |
|
// Update all the title string and |
// call all the gauge functions to update popup data |
|
// call all the gauge functions to update popup data |
if (_gaugeTemp) { |
|
if (_gaugeTemp) { |
_gaugeTemp.setTitleString(_temp.title); |
|
_gaugeTemp.setTitleString(_temp.title); |
doTemp(); |
|
doTemp(); |
} |
|
} |
if (_gaugeDew) { |
|
if (_gaugeDew) { |
_gaugeDew.setTitleString(_dew.title); |
|
_gaugeDew.setTitleString(_dew.title); |
doDew(); |
|
doDew(); |
} |
|
} |
if (_gaugeBaro) { |
|
if (_gaugeBaro) { |
_gaugeBaro.setTitleString(_baro.title); |
|
_gaugeBaro.setTitleString(_baro.title); |
doBaro(); |
|
doBaro(); |
} |
|
} |
if (_gaugeRain) { |
|
if (_gaugeRain) { |
_gaugeRain.setTitleString(_rain.title); |
|
_gaugeRain.setTitleString(_rain.title); |
doRain(); |
|
doRain(); |
} |
|
} |
if (_gaugeRRate) { |
|
if (_gaugeRRate) { |
_gaugeRRate.setTitleString(_rrate.title); |
|
_gaugeRRate.setTitleString(_rrate.title); |
doRRate(); |
|
doRRate(); |
} |
|
} |
if (_gaugeHum) { |
|
if (_gaugeHum) { |
_gaugeHum.setTitleString(_hum.title); |
|
_gaugeHum.setTitleString(_hum.title); |
doHum(); |
|
doHum(); |
} |
|
} |
if (_gaugeWind) { |
|
if (_gaugeWind) { |
_gaugeWind.setTitleString(_wind.title); |
|
_gaugeWind.setTitleString(_wind.title); |
doWind(); |
|
doWind(); |
} |
|
} |
if (_gaugeDir) { |
|
if (_gaugeDir) { |
_gaugeDir.setPointSymbols(strings.compass); |
|
_gaugeDir.setPointSymbols(strings.compass); |
_dir.titles = [strings.latest_web, strings.tenminavg_web]; |
|
_dir.titles = [strings.latest_web, strings.tenminavg_web]; |
_gaugeDir.setLcdTitleStrings(_dir.titles); |
|
_gaugeDir.setLcdTitleStrings(_dir.titles); |
doDir(); |
|
doDir(); |
} |
|
} |
if (_gaugeUV) { |
|
if (_gaugeUV) { |
_uv.title = strings.uv_title; |
|
_uv.title = strings.uv_title; |
_gaugeUV.setTitleString(_uv.title); |
|
_gaugeUV.setTitleString(_uv.title); |
} |
|
} |
if (_gaugeSolar) { |
|
if (_gaugeSolar) { |
_solar.title = strings.solar_title; |
|
_solar.title = strings.solar_title; |
_gaugeSolar.setTitleString(_solar.title); |
|
_gaugeSolar.setTitleString(_solar.title); |
} |
|
} |
if (typeof radar !== "undefined") { |
|
if (typeof radar !== "undefined") { |
radar.setTitle(strings.windrose); |
|
radar.setTitle(strings.windrose); |
radar.setCompassString(strings.compass); |
|
radar.setCompassString(strings.compass); |
radar.doWindRose(); |
|
radar.doWindRose(); |
} |
|
} |
}, |
|
}, |
|
|
|
getWindrunUnits = function (spdUnits) { |
|
getWindrunUnits = function (spdUnits) { |
var retVal; |
|
var retVal; |
switch (spdUnits) { |
|
switch (spdUnits) { |
case 'mph': |
|
case 'mph': |
retVal = 'miles'; |
|
retVal = 'miles'; |
break; |
|
break; |
case 'kts': |
|
case 'kts': |
retVal = 'n.miles'; |
|
retVal = 'n.miles'; |
break; |
|
break; |
case 'km/h': |
|
case 'km/h': |
/* falls through */ |
|
/* falls through */ |
case 'm/s': |
|
case 'm/s': |
/* falls through */ |
|
/* falls through */ |
default: |
|
default: |
retVal = 'km'; |
|
retVal = 'km'; |
break; |
|
break; |
} |
|
} |
return retVal; |
|
return retVal; |
}, |
|
}, |
|
|
|
// |
|
// |
// extend() used to add a parent object attributes to a child object |
|
// extend() used to add a parent object attributes to a child object |
// |
|
// |
extend = function (parent, child) { |
|
extend = function (parent, child) { |
var i; |
|
var i; |
child = child || {}; |
|
child = child || {}; |
for (i in parent) { |
|
for (i in parent) { |
if (parent.hasOwnProperty(i)) { |
|
if (parent.hasOwnProperty(i)) { |
child[i] = parent[i]; |
|
child[i] = parent[i]; |
} |
|
} |
} |
|
} |
return child; |
|
return child; |
}, |
|
}, |
|
|
|
getWindRoseData = function () { |
|
getWindRoseData = function () { |
return data.WindRoseData; |
|
return data.WindRoseData; |
}, |
|
}, |
|
|
|
getWindRun = function () { |
|
getWindRun = function () { |
return extractDecimal(data.windrun); |
|
return extractDecimal(data.windrun); |
}; |
|
}; |
|
|
|
// |
|
// |
// Called when the document object has loaded |
|
// Called when the document object has loaded |
// This starts the whole script. |
|
// This starts the whole script. |
// |
|
// |
$(document).ready(function () { |
|
$(document).ready(function () { |
// Kick it all off |
|
// Kick it all off |
init(); |
|
init(); |
}); |
|
}); |
|
|
|
return { |
|
return { |
config: config, |
|
config: config, |
gauge: gauge, |
|
gauge: gauge, |
setLang: setLang, |
|
setLang: setLang, |
doTemp: doTemp, |
|
doTemp: doTemp, |
doDew: doDew, |
|
doDew: doDew, |
doHum: doHum, |
|
doHum: doHum, |
setUnits: setUnits, |
|
setUnits: setUnits, |
getWindRoseData: getWindRoseData, |
|
getWindRoseData: getWindRoseData, |
getWindRun: getWindRun, |
|
getWindRun: getWindRun, |
countDown: countDown |
|
countDown: countDown |
}; |
|
}; |
}()), |
|
}()), |
|
|
|
// =============================================================================================================================== |
|
// =============================================================================================================================== |
// =============================================================================================================================== |
|
// =============================================================================================================================== |
// =============================================================================================================================== |
|
// =============================================================================================================================== |
|
|
|
/*! Image w/ description tooltip v2.0 - For FF1+ IE6+ Opr8+ |
|
/*! Image w/ description tooltip v2.0 - For FF1+ IE6+ Opr8+ |
* Created: April 23rd, 2010. This notice must stay intact for usage |
|
* Created: April 23rd, 2010. This notice must stay intact for usage |
* Author: Dynamic Drive at http://www.dynamicdrive.com/ |
|
* Author: Dynamic Drive at http://www.dynamicdrive.com/ |
* Visit http://www.dynamicdrive.com/ for full source code |
|
* Visit http://www.dynamicdrive.com/ for full source code |
* Modified: M Crossley June 2011, January 2012 |
|
* Modified: M Crossley June 2011, January 2012 |
* v2.- |
|
* v2.- |
*/ |
|
*/ |
|
|
|
ddimgtooltip = { |
|
ddimgtooltip = { |
tiparray : (function () { |
|
tiparray : (function () { |
var style = {background: '#FFFFFF', color: 'black', border: '2px ridge darkblue'}, |
|
var style = {background: '#FFFFFF', color: 'black', border: '2px ridge darkblue'}, |
i = 11, // set to number of tooltips required |
|
i = 11, // set to number of tooltips required |
tooltips = []; |
|
tooltips = []; |
for (;i--;) { |
|
for (;i--;) { |
tooltips[i] = [null, ' ', style]; |
|
tooltips[i] = [null, ' ', style]; |
} |
|
} |
return tooltips; |
|
return tooltips; |
}()), |
|
}()), |
|
|
|
tooltipoffsets : [20, -30], //additional x and y offset from mouse cursor for tooltips |
|
tooltipoffsets : [20, -30], //additional x and y offset from mouse cursor for tooltips |
|
|
|
tipDelay : 1000, |
|
tipDelay : 1000, |
|
|
|
_delayTimer : 0, |
|
_delayTimer : 0, |
|
|
|
tipprefix : 'imgtip', //tooltip DOM ID prefixes |
|
tipprefix : 'imgtip', //tooltip DOM ID prefixes |
|
|
|
createtip : function ($, tipid, tipinfo) { |
|
createtip : function ($, tipid, tipinfo) { |
if ($('#' + tipid).length === 0) { //if this tooltip doesn't exist yet |
|
if ($('#' + tipid).length === 0) { //if this tooltip doesn't exist yet |
return $('<div id="' + tipid + '" class="ddimgtooltip" />') |
|
return $('<div id="' + tipid + '" class="ddimgtooltip" />') |
.html( |
|
.html( |
((tipinfo[1]) ? '<div class="tipinfo" id="' + tipid + '_txt">' + tipinfo[1] + '</div>' : '') + |
|
((tipinfo[1]) ? '<div class="tipinfo" id="' + tipid + '_txt">' + tipinfo[1] + '</div>' : '') + |
(tipinfo[0] !== null ? '<div style="text-align:center"><img class="tipimg" id="' + tipid + '_img" src="' + tipinfo[0] + '" /></div>' : '') |
|
(tipinfo[0] !== null ? '<div style="text-align:center"><img class="tipimg" id="' + tipid + '_img" src="' + tipinfo[0] + '" /></div>' : '') |
) |
|
) |
.css(tipinfo[2] || {}) |
|
.css(tipinfo[2] || {}) |
.appendTo(document.body); |
|
.appendTo(document.body); |
} |
|
} |
return null; |
|
return null; |
}, |
|
}, |
|
|
|
positiontooltip : function ($, $tooltip, e) { |
|
positiontooltip : function ($, $tooltip, e) { |
var x = e.pageX + this.tooltipoffsets[0], |
|
var x = e.pageX + this.tooltipoffsets[0], |
y = e.pageY + this.tooltipoffsets[1], |
|
y = e.pageY + this.tooltipoffsets[1], |
tipw = $tooltip.outerWidth(), |
|
tipw = $tooltip.outerWidth(), |
tiph = $tooltip.outerHeight(), |
|
tiph = $tooltip.outerHeight(), |
wHght = $(window).height(), |
|
wHght = $(window).height(), |
dTop = $(document).scrollTop(); |
|
dTop = $(document).scrollTop(); |
|
|
|
x = (x + tipw > $(document).scrollLeft() + $(window).width()) ? x - tipw - (ddimgtooltip.tooltipoffsets[0] * 2) : x; |
|
x = (x + tipw > $(document).scrollLeft() + $(window).width()) ? x - tipw - (ddimgtooltip.tooltipoffsets[0] * 2) : x; |
y = (y + tiph > dTop + wHght) ? dTop + wHght - tiph - 10 : y; |
|
y = (y + tiph > dTop + wHght) ? dTop + wHght - tiph - 10 : y; |
$tooltip.css({left: x, top: y}); |
|
$tooltip.css({left: x, top: y}); |
}, |
|
}, |
|
|
|
delaybox : function ($, $tooltip, e) { |
|
delaybox : function ($, $tooltip, e) { |
if (this.showTips) { |
|
if (this.showTips) { |
ddimgtooltip._delayTimer = setTimeout(function () { |
|
ddimgtooltip._delayTimer = setTimeout(function () { |
ddimgtooltip.showbox($tooltip.selector); |
|
ddimgtooltip.showbox($tooltip.selector); |
}, ddimgtooltip.tipDelay); |
|
}, ddimgtooltip.tipDelay); |
} |
|
} |
}, |
|
}, |
|
|
|
showbox : function (tooltip) { |
|
showbox : function (tooltip) { |
if (this.showTips) { |
|
if (this.showTips) { |
//$(tooltip).show(); |
|
//$(tooltip).show(); |
$(tooltip).fadeIn(); |
|
$(tooltip).fadeIn(); |
} |
|
} |
}, |
|
}, |
|
|
|
hidebox : function ($, $tooltip) { |
|
hidebox : function ($, $tooltip) { |
clearTimeout(ddimgtooltip._delayTimer); |
|
clearTimeout(ddimgtooltip._delayTimer); |
//$tooltip.hide(); |
|
//$tooltip.hide(); |
$tooltip.fadeOut(); |
|
$tooltip.fadeOut(); |
}, |
|
}, |
|
|
|
showTips : false, |
|
showTips : false, |
|
|
|
init : function (targetselector) { |
|
init : function (targetselector) { |
$(document).ready(function ($) { |
|
$(document).ready(function ($) { |
var tiparray = ddimgtooltip.tiparray, |
|
var tiparray = ddimgtooltip.tiparray, |
$targets = $(targetselector); |
|
$targets = $(targetselector); |
|
|
|
if ($targets.length === 0) { |
|
if ($targets.length === 0) { |
return; |
|
return; |
} |
|
} |
$targets.each(function () { |
|
$targets.each(function () { |
var $target = $(this), |
|
var $target = $(this), |
tipsuffix, tipid, |
|
tipsuffix, tipid, |
$tooltip; |
|
$tooltip; |
$target.attr('id').match(/_(\d+)/); //match d of attribute id='tip_d' |
|
$target.attr('id').match(/_(\d+)/); //match d of attribute id='tip_d' |
tipsuffix = parseInt(RegExp.$1, 10); //get d as integer |
|
tipsuffix = parseInt(RegExp.$1, 10); //get d as integer |
tipid = this._tipid = ddimgtooltip.tipprefix + tipsuffix; //construct this tip's ID value and remember it |
|
tipid = this._tipid = ddimgtooltip.tipprefix + tipsuffix; //construct this tip's ID value and remember it |
$tooltip = ddimgtooltip.createtip($, tipid, tiparray[tipsuffix]); |
|
$tooltip = ddimgtooltip.createtip($, tipid, tiparray[tipsuffix]); |
|
|
|
$target.mouseenter(function (e) { |
|
$target.mouseenter(function (e) { |
var $tooltip = $('#' + this._tipid); |
|
var $tooltip = $('#' + this._tipid); |
//ddimgtooltip.showbox($, $tooltip, e); |
|
//ddimgtooltip.showbox($, $tooltip, e); |
ddimgtooltip.delaybox($, $tooltip, e); |
|
ddimgtooltip.delaybox($, $tooltip, e); |
}); |
|
}); |
$target.mouseleave(function (e) { |
|
$target.mouseleave(function (e) { |
var $tooltip = $('#' + this._tipid); |
|
var $tooltip = $('#' + this._tipid); |
ddimgtooltip.hidebox($, $tooltip); |
|
ddimgtooltip.hidebox($, $tooltip); |
}); |
|
}); |
$target.mousemove(function (e) { |
|
$target.mousemove(function (e) { |
var $tooltip = $('#' + this._tipid); |
|
var $tooltip = $('#' + this._tipid); |
ddimgtooltip.positiontooltip($, $tooltip, e); |
|
ddimgtooltip.positiontooltip($, $tooltip, e); |
}); |
|
}); |
if ($tooltip) { //add mouseenter to this tooltip (only if event hasn't already been added) |
|
if ($tooltip) { //add mouseenter to this tooltip (only if event hasn't already been added) |
$tooltip.mouseenter(function () { |
|
$tooltip.mouseenter(function () { |
ddimgtooltip.hidebox($, $(this)); |
|
ddimgtooltip.hidebox($, $(this)); |
}); |
|
}); |
} |
|
} |
}); |
|
}); |
}); //end dom ready |
|
}); //end dom ready |
} |
|
} |
}; |
|
}; |
|
|
|
String.prototype.trim = String.prototype.trim || function trim() { |
|
String.prototype.trim = String.prototype.trim || function trim() { |
return this.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); |
|
return this.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); |
}; |
|
}; |