Can somebody help me translate this javascript into rules DSL?

A friend did this for me, but I’ve been learning everything else in DSL, and I don’t understand this javascript enough to tweak it and change it for other purposes.

The code is supposed to:

1- Calculate a color temperature based on Sun Elevation (with some offsets for clouds and other weather conditions. Lights change from 2200K to 6000K as the Sun goes between -6Deg to 40 Deg elevation)

2 - Apply the calculated color temperature to any light that is currently on.

```
triggers:
- id: "3"
configuration:
itemName: AstroSunData_Elevation
type: core.ItemStateUpdateTrigger
conditions: []
actions:
- inputs: {}
id: "1"
configuration:
type: application/javascript
script: >+
var logger =
Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' +
ctx.ruleUID);
var SunElevation = (itemRegistry.getItem("AstroSunData_Elevation").getState()) + 6;
var Clouds = itemRegistry
.getItem("Localweatherandforecast_Cloudiness")
.getState();
var weatherCond = itemRegistry.getItem("Localweatherandforecast_WeatherCondition").getState()
var weatherID = itemRegistry.getItem("Localweatherandforecast_Current_Conditionid").getState()
var outputstart = 2200;
var outputend = 6000;
var inputstart = 0;
var inputend = 46;
var output =
Math.floor(
Math.min(Math.max((
outputstart +
((outputend - outputstart) / (inputend - inputstart)) *
(SunElevation - inputstart)
), 2200), 6000)
);
var cloudFactor = "801"
if (weatherID == "801") { // few clouds: 11-25%
cloudFactor = Math.floor(output * 0.05);
} else if (weatherID == "802") { // scattered clouds: 25-50%
cloudFactor = Math.floor(output * 0.1);
} else if (weatherID == "803") { // broken clouds: 51-84%
cloudFactor = Math.floor(output * 0.2);
} else if (weatherID == "804") { // overcast clouds: 85-100%
cloudFactor = Math.floor(output * 0.33);
} else if (weatherID == "800") { // clear sky
cloudFactor = 0
} else if (weatherID == "500") { // light rain
cloudFactor = Math.floor(output * 0.05);
} else if (weatherID == "501") { // moderate rain
cloudFactor = Math.floor(output * 0.25);
} else if (weatherID == "502") { // heavy intensity rain
cloudFactor = Math.floor(output * 0.33);
} else if (weatherID == "503") { // very heavy rain
cloudFactor = Math.floor(output * 0.5);
} else if (weatherID == "504") { // extreme rain
cloudFactor = Math.floor(output * 0.6);
} else if (weatherID == "511") { // freezing rain
cloudFactor = Math.floor(output * 0.6);
} else if (weatherID == "520") { // light intensity shower rain
cloudFactor = Math.floor(output * 0.2);
} else if (weatherID == "521") { // shower rain
cloudFactor = Math.floor(output * 0.3);
} else if (weatherID == "522") { // heavy intensity shower rain
cloudFactor = Math.floor(output * 0.4);
} else if (weatherID == "531") { // ragged shower rain
cloudFactor = Math.floor(output * 0.45);
} else {
cloudFactor = Math.floor(output * Clouds * 0.002);
}
// https://openweathermap.org/weather-conditions adjust for type of cloud/atmosphere/rain
var newColourValue = Math.min(Math.max((output - cloudFactor), 2200), 6000);
events.sendCommand('Calculated_ColorTemperature', newColourValue);
var lightLevelGroup = itemRegistry.getItem("gAll_Lights_Brightness");
lightLevelGroup.members.forEach(function (item) {
if (item.getState() > 0) {
var thingName = item.getName().match(/^(.*)_.*/)[1];
events.sendCommand(
thingName + "_ColorTemperature",
newColourValue
);
}
});
logger.info("Colour Temperature rule is running. Calculated Temp is " + output + "K - Cloud Factor (" + weatherCond + ", " + cloudFactor + "K) = " + (output - cloudFactor) + "K, clamped to " + newColourValue + "K");
type: script.ScriptAction
```

Thanks for any help,