Skip to content

Instantly share code, notes, and snippets.

@ian-plosker
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save ian-plosker/9277167 to your computer and use it in GitHub Desktop.

Select an option

Save ian-plosker/9277167 to your computer and use it in GitHub Desktop.
$(function () {
$("pre.example").each(function(i, ele) {
var example = {"X-cc": "", "From": "[email protected]", "X-Folder": "\\MCASH (Non-Privileged)\\Cash, Michelle\\Inbox", "Content-Transfer-Encoding": "7bit", "X-bcc": "", "X-Origin": "Cash-M", "To": ["[email protected]"], "parts": [{"content": "\r\n=================\r\nMike Baer\r\nAccenture - Legal Group\r\n100 South Wacker Drive, Ste. 515, Chicago, IL 60606-4006\r\nVoice: 312-693-1512, Octel: 69/31512, Fax: 312-652-1512\r\neMail: [email protected]\r\n=================\r\n\r\n\r\n\r\nThis message is for the designated recipient only and may contain\r\nprivileged or confidential information. If you have received it in error,\r\nplease notify the sender immediately and delete the original. Any other\r\nuse of the email by you is prohibited.\r\n - B0033CF1.TIF \r\n\r\n", "contentType": "text/plain"}], "X-FileName": "MCASH (Non-Privileged).pst", "Mime-Version": "1.0", "X-From": "[email protected]@ENRON\r\n <IMCEANOTES-michael+2Ee+2Ebaer+40accenture+2Ecom+40ENRON@ENRON.com>", "Date": {"$date": 993750113000}, "X-To": "Cash, Michelle </O=ENRON/OU=NA/CN=RECIPIENTS/CN=MCASH>", "Message-ID": "<573700.1075853133887.JavaMail.evans@thyme>", "Content-Type": "text/plain; charset=us-ascii", "Subject": "Enron CSA 12/17/97 - Signed"};
$(ele).removeClass("prettyprinted").text(JSON.stringify(example, undefined, 2));
prettyPrint();
});
$("form.enron-form").each(function(i, ele) {
$(ele)
.html('<label for="query">Query:&nbsp;</label><input type="text" value="" class="query" /><br /><label for="limit">Limit:&nbsp;</label><input type="text" value="10" class="limit" /><br /><label for="offset">Offset:&nbsp;</label><input type="text" value="0" class="offset" /><br /><input type="button" value="Execute" class="execute" />&nbsp;<input type="button" value="Clear" class="clear" /><pre class="code json prettyprint"></pre>')
.find("input.query").val($(ele).attr("query")).end()
.find("pre.code").hide()
});
$("form.enron-form .execute").click(function() {
var form = $(this).parent("form");
query = encodeURIComponent($(form).find("input.query").val());
limit = encodeURIComponent($(form).find("input.limit").val());
offset = encodeURIComponent($(form).find("input.offset").val());
if (limit == null) limit = 10;
if (offset == null) offset = 0;
var qs = "?query="+query+"&limit="+limit+"&offset="+offset;
form.find("pre.code").empty().hide();
$.getJSON("http://enron.herokuapp.com/emails"+qs, function(data) {
$(form).find("pre.code").removeClass("prettyprinted").text(JSON.stringify(data, undefined, 2)).show();
prettyPrint();
});
});
$("form.enron-form .clear").click(function() {
$(this).parent("form").find("pre.code").removeClass("prettyprinted").empty().hide();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment