Skip to content

Instantly share code, notes, and snippets.

@ba3r ba3r/routerank.js
Created Oct 14, 2009

Embed
What would you like to do?
routerank [en|de|fr|es]
const
R = 'http://routerank.com/';
I = 'http://lh5.ggpht.com/_9QZJW2qJEGU/SwNLnkFvRAI/AAAAAAAAAqM/1tB2zfjefYQ/routerank.png';
N = 'Michael Baer';
T = 'https://gist.github.com/synapsos';
L = 'GPL';
S1 = '<span style=\'text-transform:capitalize\'>';
S2 = '</span>';
//v1.65
CmdUtils.CreateCommand({
names: ["routerank", "routerank-en"],
icon: I,
description: "Finds the fastest, cheapest or most CO2-efficient route between 2 places.",
help: "e.g. routerank from london to berlin at december 20 7:30am",
author: {name: N, homepage: T},
license: L,
homepage: R+"en/",
arguments: { source_departure: noun_arb_text,
goal_destination: noun_arb_text,
time_date: noun_type_date,
location_time: noun_type_time,
},
preview: function preview(pblock, args) {
var pStart = args.source.text;
var pEnd = args.goal.text;
var pDate = Date.parse(args.time.data).toString("MMMM d, yyyy \(ddd\)");
var pTime = Date.parse(args.location.data).toString("h:mm tt");
var msg = "from: " + S1 + pStart + S2 + "<br>to: " + S1 + pEnd + S2 + "<br>date: " + pDate + "<br>time: " + pTime + "<br>language: English<br><br><br>";
if (pEnd) {msg += "<img src='http://maps.googleapis.com/maps/api/staticmap?center=" + pEnd + "&zoom=9&size=400x300&sensor=false&key=AIzaSyAV-78Qm1php3pRMWW3vqSL3YqRog1rjIA' /><br><a href='http://maps.google.com/maps?hl=en&f=d&source=s_d&saddr=" + pStart + "&daddr=" + pEnd + "'>Get driving directions from Google Maps</a>™";}
else {msg += "Google Maps™ could not find destination.";}
pblock.innerHTML = msg;
},
execute: function execute(args) {
var lang = "en";
var start = args.source.text;
var end = args.goal.text;
var date = Date.parse(args.time.data).toString("dd-MM-yyyy");
var time = Date.parse(args.location.data).toString("HH-mm");
var url = R + lang + "/search/" + start + "/" + end + "/" + date + "-" + time + "/";
Utils.openUrlInBrowser(url);
}
});
//v1.25
CmdUtils.CreateCommand({
names: ["routerank-de"],
icon: I,
description: "Findet die schnellste, günstigste oder CO2-effizienteste Route zwischen 2 Orten.",
help: "z.B. routerank-de from berlin to basel at 20.12. 7:30",
author: {name: N, homepage: T},
license: L,
homepage: R+"de/",
arguments: { source_departure: noun_arb_text,
goal_destination: noun_arb_text,
time_date: noun_type_date,
location_time: noun_type_time,
},
preview: function preview(pblock, args) {
var pStart = args.source.text;
var pEnd = args.goal.text;
var pDate = Date.parse(args.time.data).toString("dd.MM.yyyy");
var pTime = Date.parse(args.location.data).toString("HH:mm");
var msg = "von: " + S1 + pStart + S2 + "<br>nach: " + S1 + pEnd + S2 + "<br>Datum: " + pDate + "<br>Zeit: " + pTime + "<br>Sprache: Deutsch<br><br><br>";
if (pEnd) {msg += "<img src='http://maps.googleapis.com/maps/api/staticmap?center=" + pEnd + "&zoom=9&size=400x300&sensor=false&key=AIzaSyAV-78Qm1php3pRMWW3vqSL3YqRog1rjIA' /><br><a href='http://maps.google.com/maps?hl=de&f=d&source=s_d&saddr=" + pStart + "&daddr=" + pEnd + "'>Route berechnen mit Google Maps</a>™";}
else {msg += "Google Maps™ konnte den Zielort nicht finden.";}
pblock.innerHTML = msg;
},
execute: function execute(args) {
var lang = "de";
var start = args.source.text;
var end = args.goal.text;
var date = Date.parse(args.time.data).toString("dd-MM-yyyy");
var time = Date.parse(args.location.data).toString("HH-mm");
var url = R + lang + "/search/" + start + "/" + end + "/" + date + "-" + time + "/";
Utils.openUrlInBrowser(url);
}
});
//v1.25
CmdUtils.CreateCommand({
names: ["routerank-fr"],
icon: I,
description: "Trouve l'itinéraire le plus rapide, le moins cher ou le plus CO2 efficace entre 2 endroits.",
help: "p.e. routerank-fr from paris to berlin at 20.12. 7:30",
author: {name: N, homepage: T},
license: L,
homepage: R+"fr/",
arguments: { source_departure: noun_arb_text,
goal_destination: noun_arb_text,
time_date: noun_type_date,
location_time: noun_type_time,
},
preview: function preview(pblock, args) {
var pStart = args.source.text;
var pEnd = args.goal.text;
var pDate = Date.parse(args.time.data).toString("dd.MM.yyyy");
var pTime = Date.parse(args.location.data).toString("HH:mm");
var msg = "de: " + S1 + pStart + S2 + "<br>à: " + S1 + pEnd + S2 + "<br>date: " + pDate + "<br>heure: " + pTime + "<br>langue: français<br><br><br>";
if (pEnd) {msg += "<img src='http://maps.googleapis.com/maps/api/staticmap?center=" + pEnd + "&zoom=9&size=400x300&sensor=false&key=AIzaSyAV-78Qm1php3pRMWW3vqSL3YqRog1rjIA' /><br><a href='http://maps.google.com/maps?hl=fr&f=d&source=s_d&saddr=" + pStart + "&daddr=" + pEnd + "'>Itinéraire en voiture avec Google Maps</a>™";}
else {msg += "Google Maps™ ne pouvait pas trouver la destination.";}
pblock.innerHTML = msg;
},
execute: function execute(args) {
var lang = "fr";
var start = args.source.text;
var end = args.goal.text;
var date = Date.parse(args.time.data).toString("dd-MM-yyyy");
var time = Date.parse(args.location.data).toString("HH-mm");
var url = R + lang + "/search/" + start + "/" + end + "/" + date + "-" + time + "/";
Utils.openUrlInBrowser(url);
}
});
//v1.25
CmdUtils.CreateCommand({
names: ["routerank-es"],
icon: I,
description: "Encontrar la ruta más rápida, más barata o más CO2-eficiente entre 2 lugares.",
help: "p.e. routerank-es from madrid to berlin at 20/12/12 7:30",
author: {name: N, homepage: T},
license: L,
homepage: R+"es/",
arguments: { source_departure: noun_arb_text,
goal_destination: noun_arb_text,
time_date: noun_type_date,
location_time: noun_type_time,
},
preview: function preview(pblock, args) {
var pStart = args.source.text;
var pEnd = args.goal.text;
var pDate = Date.parse(args.time.data).toString("dd/MM/yyyy");
var pTime = Date.parse(args.location.data).toString("HH:mm");
var msg = "de: " + S1 + pStart + S2 + "<br>a: " + S1 + pEnd + S2 + "<br>fecha: " + pDate + "<br>hora: " + pTime + "<br>idioma: Español <br><br><br>";
if (pEnd) {msg += "<img src='http://maps.googleapis.com/maps/api/staticmap?center=" + pEnd + "&zoom=9&size=400x300&sensor=false&key=AIzaSyAV-78Qm1php3pRMWW3vqSL3YqRog1rjIA' /><br><a href='http://maps.google.com/maps?hl=es&f=d&source=s_d&saddr=" + pStart + "&daddr=" + pEnd + "'>Indicaciones de ruta en coche con Google Maps</a>™";}
else {msg += "Google Maps™ no podía encontrar el destino.";}
pblock.innerHTML = msg;
},
execute: function execute(args) {
var lang = "es";
var start = args.source.text;
var end = args.goal.text;
var date = Date.parse(args.time.data).toString("dd-MM-yyyy");
var time = Date.parse(args.location.data).toString("HH-mm");
var url = R + lang + "/search/" + start + "/" + end + "/" + date + "-" + time + "/";
Utils.openUrlInBrowser(url);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.