Skip to content

Instantly share code, notes, and snippets.

@mazexx
Created November 14, 2008 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mazexx/25096 to your computer and use it in GitHub Desktop.
Save mazexx/25096 to your computer and use it in GitHub Desktop.
Ubiquity Command - Time table for ÖBB
/* 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}&timesel=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 );
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment