Created
December 30, 2008 14:30
-
-
Save codewzrd/41634 to your computer and use it in GitHub Desktop.
Temporary email address from Spambox.us
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_lifetime = new CmdUtils.NounType("Lifespan", | |
["half hour", "hour", "half day", "day", "week", "month", "half year", "year"]); | |
CmdUtils.CreateCommand( | |
{ | |
name: "spambox", | |
description: "Creates a temporary email address from spambox.us.", | |
icon: "http://www.spambox.us/favicon.ico", | |
homepage: "http://www.makadia.com", | |
author: { name: "Svapan Makadia", email: "codewzrd@hotmail.com"}, | |
help: "Enter email address and a lifetime {half hour, hour, half day, day, week, month, half year, year}.", | |
takes: {"email": noun_arb_text}, | |
modifiers: {lifetime: noun_type_lifetime}, | |
preview: function(pBlock) | |
{ | |
var html = "Inserts a temporary spambox.us email address in the current editable text area.<br/>Default lifespan is 1 hour."; | |
html += "<br/><span style=\"color: yellow;\">Warning, it takes a few seconds to retrieve the email.</span>"; | |
pBlock.innerHTML = html; | |
}, | |
execute: function(directObj, lifetime) | |
{ | |
var span = 0; | |
switch(lifetime.text) | |
{ | |
case "half hour": | |
span = 1; | |
break; | |
case "hour": | |
span = 2; | |
break; | |
case "half day": | |
span = 3; | |
break; | |
case "day": | |
span = 4; | |
break; | |
case "week": | |
span = 5; | |
break; | |
case "month": | |
span = 6; | |
break; | |
case "half year": | |
span = 7; | |
break; | |
case "year": | |
span = 8; | |
break; | |
default: | |
span = 2; | |
break; | |
} | |
var params = {email:directObj.text, lifetime:span}; | |
jQuery.ajax( | |
{ | |
type: "POST", | |
url: "http://www.spambox.us/generate", | |
data: params, | |
error: function() | |
{ | |
displayMessage("Could not get temporary email address."); | |
}, | |
success: function(msg) | |
{ | |
//CmdUtils.log(msg); | |
var tempElement = CmdUtils.getHiddenWindow().document.createElementNS("http://www.w3.org/1999/xhtml", "div"); | |
tempElement.innerHTML = msg; | |
//CmdUtils.log(jQuery(tempElement).find("h1:first").text()); | |
var tempEmail = jQuery(tempElement).find("#generated").find("h1:first").text(); | |
if(tempEmail != "") | |
{ | |
CmdUtils.setSelection(tempEmail); | |
displayMessage("Temporary spambox.us email address is: " + tempEmail); | |
} | |
else | |
{ | |
displayMessage(jQuery(tempElement).find("#generated").find("h3:first").text()); | |
} | |
} | |
}) | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment