Skip to content

Instantly share code, notes, and snippets.

@andreadecorte
Created July 26, 2009 17:46
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 andreadecorte/155868 to your computer and use it in GitHub Desktop.
Save andreadecorte/155868 to your computer and use it in GitHub Desktop.
Ubiquity script for Televideo RAI (Italy)
// Source code for televideo Ubiquity command
// requires Ubiquity 0.5 or above
CmdUtils.CreateCommand({
names: ["televideo", "guarda televideo", "telev"],
icon: "http://www.televideo.rai.it/favicon.ico",
description: "Visualizzazione rapida di una pagina del Televideo RAI",
help: "Esempio: televideo 101 of 2 in Friuli<br />Il secondo numero è la sottopagina, se non specificata sarà la prima.<br />Edizione è opzionale, può essere Nazionale (predefinito) o il nome (abbreviato) delle varie regioni. Inserisci la prima lettera per vedere le possibilità.",
author: {name: "Andrea Decorte", email: "adecorte+ubiquity@gmail.com"},
license: "GPL",
homepage: "http://code.google.com/p/telenonvideo/",
arguments: [{role: 'object', nountype: /^([1-8][0-9][0-9])$/, label: 'pagina'}, {role: 'modifier',
nountype: /^\d{1,2}$/,
label: 'sottopagina'}, {role: 'location',
nountype: ["Nazionale", "Abruzzo", "Altoadige", "Aosta",
"Basilicata", "Calabria", "Campania", "Emilia",
"Friuli", "Lazio", "Liguria", "Lombardia",
"Marche", "Molise", "Piemonte", "Puglia", "Sardegna", "Sicilia", "Toscana", "Trentino", "Umbria", "Veneto"],
label: 'edizione'}],
preview: function preview(pblock, args) {
var edizione = "</b> nell'edizione nazionale";
if (args.location.text != "")
edizione = "</b> nell'edizione " + args.location.text;
pblock.innerHTML = "Visualizza la pagina <b>" + args.object.text + edizione;
},
execute: function execute(args) {
if (args.location.text == "")
args.location.text = "Nazionale";
if (args.modifier.text != "") {
if (args.modifier.text == "1")
args.modifier.text = "";
else { args.modifier.text = "." + args.modifier.text; }
}
var baseUrl = "http://www.televideo.rai.it/televideo/pub/tt4web/" + args.location.text + "/page-";
Utils.openUrlInBrowser(baseUrl + args.object.text + args.modifier.text + ".png");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment