From c15ccb04986cea987a4961ca9202c04078211fc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 15 Sep 2018 22:38:16 +0200 Subject: [PATCH] reduce complexity of showWeather --- htdocs/index.php | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/htdocs/index.php b/htdocs/index.php index 2618d5bc8bc..14f72774d92 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -703,15 +703,27 @@ function showWeather($totallate,$text,$options) $used_conf = !empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'MAIN_METEO_PERCENTAGE_LEVEL' : 'MAIN_METEO_LEVEL'; - $level0=$offset; if (! empty($conf->global->{$used_conf.'0'})) $level0=$conf->global->{$used_conf.'0'}; - $level1=$offset+1*$factor; if (! empty($conf->global->{$used_conf.'1'})) $level1=$conf->global->{$used_conf.'1'}; - $level2=$offset+2*$factor; if (! empty($conf->global->{$used_conf.'2'})) $level2=$conf->global->{$used_conf.'2'}; - $level3=$offset+3*$factor; if (! empty($conf->global->{$used_conf.'3'})) $level3=$conf->global->{$used_conf.'3'}; + $level0=$offset; + if (! empty($conf->global->{$used_conf.'0'})) { + $level0=$conf->global->{$used_conf.'0'}; + } + $level1=$offset+1*$factor; + if (! empty($conf->global->{$used_conf.'1'})) { + $level1=$conf->global->{$used_conf.'1'}; + } + $level2=$offset+2*$factor; + if (! empty($conf->global->{$used_conf.'2'})) { + $level2=$conf->global->{$used_conf.'2'}; + } + $level3=$offset+3*$factor; + if (! empty($conf->global->{$used_conf.'3'})) { + $level3=$conf->global->{$used_conf.'3'}; + } if ($totallate <= $level0) $out.=img_weather($text,'weather-clear.png',$options); - if ($totallate > $level0 && $totallate <= $level1) $out.=img_weather($text,'weather-few-clouds.png',$options); - if ($totallate > $level1 && $totallate <= $level2) $out.=img_weather($text,'weather-clouds.png',$options); - if ($totallate > $level2 && $totallate <= $level3) $out.=img_weather($text,'weather-many-clouds.png',$options); - if ($totallate > $level3) $out.=img_weather($text,'weather-storm.png',$options); + elseif ($totallate > $level0 && $totallate <= $level1) $out.=img_weather($text,'weather-few-clouds.png',$options); + elseif ($totallate > $level1 && $totallate <= $level2) $out.=img_weather($text,'weather-clouds.png',$options); + elseif ($totallate > $level2 && $totallate <= $level3) $out.=img_weather($text,'weather-many-clouds.png',$options); + elseif ($totallate > $level3) $out.=img_weather($text,'weather-storm.png',$options); return $out; }