Created
October 1, 2008 03:15
-
-
Save roskoff/14016 to your computer and use it in GitHub Desktop.
This file contains 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
// ------------------------ | |
// SMS-TIGO | |
// ------------------------ | |
var imageId = ""; | |
CmdUtils.CreateCommand({ | |
name: "sms-tigo", | |
icon: "http://www.tigo.com.py/favicon.ico", | |
author: { name: "Eliseo Ocampos", email: "[email protected]"}, | |
license: "MPL", | |
description: "Envia un SMS a Tigo", | |
help: "Escribir el mensaje a enviar, luego indicar: para 098xnnnnnn codigo xxxx firma remitente. <br/>" + | |
"La firma es opcional. Se debe aguardar un momento para que se muestre el codigo en la imagen.", | |
takes: {mensaje: noun_arb_text}, | |
modifiers: {para: noun_arb_text, codigo: noun_arb_text, firma: noun_arb_text}, | |
previewDelay: 500, | |
preview: function( pblock ){ | |
var mens = ""; | |
var imageIdUrl = "http://www.tigo.com.py/cgi/get_id_sms.php?1222714899111.38"; | |
var getImageUrl = "http://idt.telecel.com.py/brian/sms/sms_img.php?rid="; | |
pblock.innerHTML = "Envia un SMS a Tigo, solicitando codigo..."; | |
if( imageId=="") { | |
displayMessage("Generando idImage..."); // debug message | |
jQuery.get(imageIdUrl, function(data){ | |
imageId = data.substr(3); | |
}); | |
} | |
mens = "En un momento aparecerá el código a completar... <br/>"; | |
mens += "[ <img src='%s' />".replace( /%s/, getImageUrl + imageId) + " ]"; | |
//+ " (" + imageId + ") </div>"; // debug | |
pblock.innerHTML = mens; | |
}, | |
execute: function(mensaje, mods){ | |
var urlEnvio = "http://www.tigo.com.py/cgi/envio_portal.php?"; | |
var params = {hcaracteristica:mods.para.text.substr(0,4), | |
htexto: mensaje.text, | |
hpara: mods.para.text.substr(4), | |
hfirma: mods.firma.text, | |
hpin:'', | |
strRID: mods.codigo.text, | |
intID: imageId.substr(0,8)}; | |
imageId = ""; // Vaciamos para la proxima llamada. | |
jQuery.get(urlEnvio, | |
params, | |
function(data){ | |
// El response será de la forma: <id0>=<valor0>&<id1>=<valor1>, por ejemplo: | |
// blnkOk=false&errorMsg="El codigo es incorrecto" | |
var results = data.split("&"); | |
var okStatus = results[0].split("="); | |
var errorMessage = results[1].split("="); | |
if (okStatus[1] == "true") { | |
displayMessage("[sms-tigo] Mensaje enviado"); | |
} else { | |
displayMessage("[sms-tigo] Error en el envio: " + errorMessage[1]); | |
} | |
} | |
); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment