updated weather-stats.qml script

This commit is contained in:
Patrizio Bekerle 2017-06-08 17:43:19 +02:00
parent e880663c10
commit de6dcdb75e
No known key found for this signature in database
GPG Key ID: 2E9FFD770DABE838
2 changed files with 14 additions and 6 deletions

View File

@ -2,7 +2,7 @@
"name": "Weather stats",
"identifier": "weather-stats",
"script": "weather-stats.qml",
"version": "0.0.1",
"version": "0.0.2",
"minAppVersion": "17.06.4",
"authors": ["@pbek"],
"description" : "This script shows the current weather in the <i>Scripting widget</i>. You can configure the city in the <i>Scripting Settings</i>. The Yahoo weather service is used to fetch the weather. The information is updated every 10min."

View File

@ -3,6 +3,9 @@ import QOwnNotesTypes 1.0
/**
* This script shows current weather statistics in a "scripting label"
*
* The Yahoo weather api is used for fetching the weather data
* https://developer.yahoo.com/weather/
*/
Script {
@ -11,7 +14,6 @@ Script {
property bool useFahrenheit;
// register your settings variables so the user can set them in the script settings
// use this property if you don't need
property variant settingsVariables: [
{
"identifier": "city",
@ -41,17 +43,23 @@ Script {
var weatherInfo = JSON.parse(json);
var temp = weatherInfo.query.results.channel.item.condition.temp
var unit = weatherInfo.query.results.channel.units.temperature;
var tempUnit = weatherInfo.query.results.channel.units.temperature;
var conditionText = weatherInfo.query.results.channel.item.condition.text
var weatherCity = weatherInfo.query.results.channel.location.city
var windSpeed = weatherInfo.query.results.channel.wind.speed
var windUnit = weatherInfo.query.results.channel.units.speed;
if (!useFahrenheit) {
unit = "°" + unit;
tempUnit = "°" + tempUnit;
}
script.setLabelText("weather stats",
"<table align=center width=90%>
"<table align='center' width='90%'>
<tr>
<td align=center>Weather in <b>" + city + "</b>: " + conditionText + " at <b>" + temp + " " + unit + "</b></tb>
<td align='center'>
Weather in <b>" + weatherCity + "</b>: " + conditionText + " at <b>" + temp + " " + tempUnit + "</b>
(" + windSpeed + " " + windUnit + " wind)
</tb>
</tr>
</table>")
}