Created
September 17, 2008 17:30
-
-
Save codewzrd/11261 to your computer and use it in GitHub Desktop.
Temporary email address from Jetable
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
var noun_type_lifespan = new CmdUtils.NounType("Lifespan", | |
["hour", "day", "week", "month"]); | |
CmdUtils.CreateCommand( | |
{ | |
name: "jetable", | |
description: "Creates a temporary email address from Jetable.org.", | |
icon: "http://www.jetable.org/favicon.ico", | |
homepage: "http://www.makadia.com", | |
author: { name: "Svapan Makadia", email: "codewzrd@hotmail.com"}, | |
help: "Enter email address and a span {hour, day, week, month}.", | |
takes: {"email": noun_arb_text}, | |
modifiers: {span: noun_type_lifespan}, | |
preview: function(pBlock) | |
{ | |
var html = "Inserts a temporary Jetable email address in the current editable text area."; | |
html += "<br/><span style=\"color: yellow;\">Warning, it takes a few seconds to retrieve the email.</span>"; | |
pBlock.innerHTML = html; | |
}, | |
execute: function(directObj, lifespan) | |
{ | |
switch(lifespan.span.text) | |
{ | |
case "hour": | |
span = 3600; | |
break; | |
case "day": | |
span = 86400; | |
break; | |
case "week": | |
span = 604800; | |
break; | |
case "month": | |
span = 2592000; | |
break; | |
default: | |
span = 3600; | |
} | |
var params = {email:directObj.text, | |
time:span}; | |
jQuery.ajax( | |
{ | |
type: "POST", | |
url: "http://www.jetable.org/en/confirm", | |
data: params, | |
error: function() | |
{ | |
displayMessage("Could not get temporary email address."); | |
}, | |
success: function(msg) | |
{ | |
var tempElement = CmdUtils.getHiddenWindow().document.createElementNS("http://www.w3.org/1999/xhtml", "div"); | |
tempElement.innerHTML = msg; | |
//CmdUtils.log(jQuery(tempElement).find("#aliasgenerated").text()); | |
var tempEmail = jQuery(tempElement).find("#aliasgenerated").text(); | |
CmdUtils.setSelection(tempEmail); | |
displayMessage("Temporary Jetable email address is: " + tempEmail); | |
} | |
}) | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment