CmdUtils.CreateCommand({
name: "gt",
takes: {"url": noun_arb_text},
homepage: "http://www.ilovecolors.com.ar",
author: { name: "Elliot},
license: "MPL",
description: "Abre URL",
icon: "http://www.ilovecolors.com.ar/favicon.ico",
preview: function(previewBlock, directObject) {
var searchText = jQuery.trim(directObject.text);
if(searchText.length < 2) {
previewBlock.innerHTML = "Abre la URL ingresada";
return;
}
var previewTemplate = "Abriendo ${url}...";
var previewData = {url: searchText};
previewBlock.innerHTML = CmdUtils.renderTemplate(previewTemplate, previewData);
},
help: "Sólo escribe gt para abrir una URL",
execute: function(urlObj) {
var url = urlObj.text;
if(url.indexOf("://") == -1) {
url = "http://" + url;
}
Utils.openUrlInBrowser(url);
}
});
CmdUtils.CreateCommand({
name: "time",
homepage: "http://www.ilovecolors.com.ar/",
icon: "http://www.ilovecolors.com.ar/favicon.ico",
_date: function(){
var date = new Date();
return date.toLocaleTimeString();
},
preview: function( pblock ) {
var msg = 'La hora actual es ${date}';
pblock.innerHTML = CmdUtils.renderTemplate( msg, {date: this._date()} );
},
});
CmdUtils.CreateCommand({
name: "jquery",
takes: {search: noun_arb_text},
locale: "es-AR",
author: {name: "Elio Rivero"},
license: "MPL",
icon: "http://static.jquery.com/favicon.ico",
description: "Busca el t?rmino en docs.jquery.com",
preview: function(previewBlock, directObject) {
var apiUrl = "http://docs.jquery.com/Special:Search";
var searchText = jQuery.trim(directObject.text);
if(searchText.length < 2) {
previewBlock.innerHTML = "Busca en docs.jquery";
return;
}
var previewTemplate = "Buscando ${query} en docs.jquery...";
var previewData = {query: searchText};
previewBlock.innerHTML = CmdUtils.renderTemplate(previewTemplate, previewData);
jQuery.ajax({
type: "GET",
url: apiUrl,
data: "ns0=1&search=" + searchText,
datatype: "html",
error: function() {
previewBlock.innerHTML = "Error al buscar en docs.jquery";
},
success: function(searchReponse) {
var tempElement = CmdUtils.getHiddenWindow().document.createElementNS("http://www.w3.org/1999/xhtml", "div");
tempElement.innerHTML = searchReponse;
jQuery('.highlight').css({format: bold});
}
});
},
execute: function(directObject) {
var searchUrl = "http://docs.jquery.com/Special:Search";
var searchParams = {search: directObject.text, ns0: 1};
Utils.openUrlInBrowser(searchUrl + Utils.paramsToString(searchParams) + "&go=");
}
});
CmdUtils.CreateCommand({
name: "gl",
homepage: "http://www.ilovecolors.com.ar",
license: "MPL",
description: "Abre una url con I'm feeling lucky",
icon: "http://www.ilovecolors.com.ar/favicon.ico",
takes: {
"url o palabra clave": noun_arb_text
},
preview: function(pblock, theurl){
//create a variable for the entered url
var url = theurl.text;
if (url.length <= 0 || url == undefined) {
pblock.innerHTML = "Entre una URL o palabra clave.";
return;
}
if (this.isUrl(theurl.text)) {
pblock.innerHTML = "abriendo URL directamente";
return;
}
else {
pblock.innerHTML = "usando I'm Feeling Lucky";
return;
}
},
execute: function(theurl){
var url = theurl.text;
if (this.isUrl(theurl.text)) {
Utils.openUrlInBrowser(url);
}
else {
Utils.openUrlInBrowser("http://www.google.com/search?btnI=I%27m+Feeling+Lucky&ie=UTF-8&oe=UTF-8&q=" + url);
}
},
isUrl: function isUrl(s){
var regexp = /(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
return regexp.test(s);
}
});
CmdUtils.CreateCommand({
name: "gr",
homepage: "http://www.ilovecolors.com.ar",
license: "MPL",
description: "Abre Google Reader",
icon: "http://www.ilovecolors.com.ar/favicon.ico",
preview: function(previewBlock) {
previewBlock.innerHTML = "Abre Google Reader";
return;
},
help: "Escribe gr para abrir Google Reader",
execute: function() {
url = "http://www.google.com/reader/view/?tab=my#overview-page";
Utils.openUrlInBrowser(url);
}
});