-
-
Save mazexx/25096 to your computer and use it in GitHub Desktop.
Ubiquity Command - Time table for ÖBB
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
/* Code largely reused from Mauro Frigerio's SBB Time table command */ | |
CmdUtils.CreateCommand({ | |
name: "öbb", | |
author: { name: "Matthias Schlaipfer", email: "m.schlaipfer@student.tugraz.at"}, | |
license: "CC", | |
icon: "http://www.öbb.at/favicon.ico", | |
description: "Time table for Austrian Railways", | |
takes: { "Destination":noun_arb_text }, | |
modifiers: { from:noun_arb_text }, | |
execute: function( directObject, info ) { | |
var destination = directObject.text; | |
var currentTime = new Date(); | |
var hours = currentTime.getHours(); | |
var minutes = currentTime.getMinutes(); | |
var month = currentTime.getMonth() + 1; | |
var day = currentTime.getDate(); | |
var year = currentTime.getFullYear(); | |
/* Default departure station vvvv */ | |
var departure = info.from.text || "Graz"; | |
var url = "http://www.oebb.at/pv/de/Servicebox/Fahrplanabfrage/index.jsp?S={DEP}&REQ0JourneyDate={DATE}×el=depart&start=1&ld=oebb&image.x=47&image.y=23&Z={DEST}&time={HOUR}%3A{MINUTE}"; | |
url = url.replace( /{DEST}/g, destination); | |
url = url.replace( /{DEP}/g, departure); | |
url = url.replace( /{DATE}/g, day+"."+month+"."+year); | |
url = url.replace( /{HOUR}/g, hours); | |
url = url.replace( /{MINUTE}/g, minutes); | |
Utils.openUrlInBrowser( url ); | |
}, | |
}); |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment