-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(): choose if you want to show UI or not and add actions with the…
… text at the end of the request.
- Loading branch information
Showing
3 changed files
with
48 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,46 @@ | ||
// Variables used by Scriptable. | ||
// These must be at the very top of the file. Do not edit. | ||
// icon-color: red; icon-glyph: bus-alt; share-sheet-inputs: plain-text; | ||
var metroTiming = function (station) { | ||
var metroTiming = async function (station, presentUI, callback) { | ||
|
||
let req = new Request("https://serviciosapp.metromadrid.es/servicios/rest/teleindicadores/" + station + "?") | ||
let promiseResponse = req.loadJSON() | ||
promiseResponse.then(json => { | ||
|
||
let array = json["Vtelindicadores"] | ||
let table = new UITable() | ||
|
||
for (item of array) { | ||
|
||
let row = new UITableRow() | ||
let title = item["nombreest"] + " sentido " + item["sentido"] | ||
let subtitle = "" | ||
if (item["proximo"]["@nil"] == "true") { | ||
subtitle = "1 -> " + item["siguiente"] + " minutos" | ||
} else if (item["siguiente"]["@nil"] == "true") { | ||
subtitle = "1 -> " + item["proximo"] + " minutos" | ||
} else { | ||
subtitle = "1 -> " + item["proximo"] + " minutos, 2 -> " + item["siguiente"] + " minutos" | ||
} | ||
|
||
let titleCell = row.addText(title, subtitle) | ||
titleCell.widthWeight = 80 | ||
|
||
row.height = 60 | ||
row.cellSpacing = 10 | ||
table.addRow(row) | ||
let json = await req.loadJSON() | ||
|
||
let array = json["Vtelindicadores"] | ||
let table = new UITable() | ||
let speaksText = "" | ||
|
||
for (item of array) { | ||
|
||
let row = new UITableRow() | ||
let title = item["nombreest"] + " sentido " + item["sentido"] | ||
speaksText = speaksText + "Tren desde " + item["nombreest"] + " sentido " + item["sentido"] + ". " | ||
let subtitle = "" | ||
if (item["proximo"]["@nil"] == "true") { | ||
subtitle = "1 -> " + item["siguiente"] + " minutos" | ||
speaksText = speaksText + "El primero pasará en " + item["siguiente"] + " minutos. " | ||
} else if (item["siguiente"]["@nil"] == "true") { | ||
subtitle = "1 -> " + item["proximo"] + " minutos" | ||
speaksText = speaksText + "El primero pasará en " + item["proximo"] + " minutos. " | ||
} else { | ||
subtitle = "1 -> " + item["proximo"] + " minutos, 2 -> " + item["siguiente"] + " minutos" | ||
speaksText = speaksText + "El primero pasará en " + item["proximo"] + " minutos y el segundo en " + item["siguiente"] + " minutos. " | ||
} | ||
|
||
let titleCell = row.addText(title, subtitle) | ||
titleCell.widthWeight = 80 | ||
|
||
row.height = 60 | ||
row.cellSpacing = 10 | ||
table.addRow(row) | ||
|
||
} | ||
|
||
if (presentUI) { | ||
QuickLook.present(table) | ||
}) | ||
} | ||
|
||
callback(speaksText) | ||
|
||
}; | ||
|