Created
September 11, 2009 22:24
-
-
Save BrunoCaimar/185624 to your computer and use it in GitHub Desktop.
UmPortugues.com - Ubiquity Command
This file contains hidden or 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
/* | |
ToDo: Formatar melhor o resultado | |
Refatorar para evitar código duplicado | |
Incluir links para maiores informações (direto para o site) | |
Incluir opção completo | |
*/ | |
CmdUtils.CreateCommand({ | |
names: ["umportugues"], | |
description: "UmPortugues.com - Acordo Ortográfico da Língua Portuguesa v0.0.4.20090915", | |
help: "UmPortugues.com - Verifica se o texto/palavra está de acordo com o Acordo Ortográfico da Língua Portuguesa (http://umportugues.com/)", | |
author: { | |
name: "Bruno Caimar", | |
email: "[email protected]" | |
}, | |
license: "MIT", | |
homepage: "http://ubiquity.brunocaimar.com.br/", | |
arguments: [{ | |
role: 'object', | |
nountype: noun_arb_text | |
}], | |
preview: function preview(pblock, args) { | |
pblock.innerHTML = "UmPortugues.com - Verifica se o texto/palavra está de acordo com o Acordo Ortográfico da Língua Portuguesa <b>"; | |
var urlPreview = "http://umportugues.com/"; | |
var data = { | |
texto: Utils.trim(args.object.text) | |
}; | |
if (Utils.trim(args.object.text) !== "") { | |
CmdUtils.previewPost(pblock, urlPreview, data, function (retorno) { | |
var result = jQuery('#grifado-texto .err', retorno); | |
if (result.length === 0) { | |
var ok = jQuery('#output > table', retorno); | |
pblock.innerHTML += "<br/><br/>" + ok.html(); | |
} else { | |
pblock.innerHTML += "<br/>"; | |
jQuery.each(result, function () { | |
pblock.innerHTML += "<br/><b style='color: red'>" + this.firstChild.nodeValue + '</b>: ' + this.title; | |
}) | |
} | |
}, | |
"html"); | |
} | |
}, | |
execute: function execute(args) { | |
var urlExecute = "http://umportugues.com/"; | |
var data = { | |
texto: Utils.trim(args.object.text) | |
}; | |
Utils.openUrlInBrowser(urlExecute, data); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment