(function() { var MailCatcher; var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; MailCatcher = (function() { function MailCatcher() { $('#messages tr').live('click', __bind(function(e) { e.preventDefault(); return this.loadMessage($(e.currentTarget).attr('data-message-id')); }, this)); $('#message .views .format.tab a').live('click', __bind(function(e) { e.preventDefault(); return this.loadMessageBody(this.selectedMessage(), $($(e.currentTarget).parent('li')).data('message-format')); }, this)); $('#message .views .analysis.tab a').live('click', __bind(function(e) { e.preventDefault(); return this.loadMessageAnalysis(this.selectedMessage()); }, this)); $('#resizer').live({ mousedown: function(e) { var events; e.preventDefault(); return $(window).bind(events = { mouseup: function(e) { e.preventDefault(); return $(window).unbind(events); }, mousemove: function(e) { e.preventDefault(); return $('#messages').css({ height: e.clientY - $('#messages').offset().top }); } }); } }); $('nav.app .clear a').live('click', __bind(function(e) { if (confirm("You will lose all your received messages.\n\nAre you sure you want to clear all messages?")) { return $.ajax({ url: '/messages', type: 'DELETE', success: function() { $('#messages tbody, #message .metadata dd').empty(); $('#message .metadata .attachments').hide(); return $('#message iframe').attr('src', 'about:blank'); }, error: function() { return alert('Error while quitting.'); } }); } }, this)); $('nav.app .quit a').live('click', __bind(function(e) { if (confirm("You will lose all your received messages.\n\nAre you sure you want to quit?")) { return $.ajax({ type: 'DELETE', success: function() { return location.replace($('body > header h1 a').attr('href')); }, error: function() { return alert('Error while quitting.'); } }); } }, this)); this.refresh(); this.subscribe(); } MailCatcher.prototype.parseDateRegexp = /^(\d{4})[-\/\\](\d{2})[-\/\\](\d{2})(?:\s+|T)(\d{2})[:-](\d{2})[:-](\d{2})(?:([ +-]\d{2}:\d{2}|\s*\S+|Z?))?$/; MailCatcher.prototype.parseDate = function(date) { var match; if (match = this.parseDateRegexp.exec(date)) { return new Date(match[1], match[2] - 1, match[3], match[4], match[5], match[6], 0); } }; MailCatcher.prototype.formatDate = function(date) { if (typeof date === "string") { date && (date = this.parseDate(date)); } return date && (date = date.toString("dddd, d MMM yyyy h:mm:ss tt")); }; MailCatcher.prototype.haveMessage = function(message) { if (message.id != null) { message = message.id; } return $("#messages tbody tr[data-message-id=\"" + message + "\"]").length > 0; }; MailCatcher.prototype.selectedMessage = function() { return $('#messages tr.selected').data('message-id'); }; MailCatcher.prototype.addMessage = function(message) { return $('#messages tbody').append($('
Fractal is a really neat service that applies common email design and development knowledge from Email Standards Project to your HTML email and tells you what you've done wrong or what you should do instead.
\nPlease note that this sends your email to the Fractal service for analysis. Read their terms of service if you're paranoid.
\n\n\n"); return $.get("/messages/" + id + ".html", function(html) { return $iframe.find('input[name="html"]').attr('value', html).end().find('.loading').hide().end().find('input[type="submit"]').attr('disabled', null).end().find('form').submit(function() { return $(this).find('input[type="submit"]').attr('disabled', 'disabled').end().find('.loading').text('Analysing...').show(); }); }); } }; MailCatcher.prototype.refresh = function() { return $.getJSON('/messages', __bind(function(messages) { return $.each(messages, __bind(function(i, message) { if (!this.haveMessage(message)) { return this.addMessage(message); } }, this)); }, this)); }; MailCatcher.prototype.subscribe = function() { if (typeof WebSocket !== "undefined" && WebSocket !== null) { return this.subscribeWebSocket(); } else { return this.subscribePoll(); } }; MailCatcher.prototype.subscribeWebSocket = function() { var secure; secure = window.location.scheme === 'https'; this.websocket = new WebSocket("" + (secure ? 'wss' : 'ws') + "://" + window.location.host + "/messages"); return this.websocket.onmessage = __bind(function(event) { return this.addMessage($.parseJSON(event.data)); }, this); }; MailCatcher.prototype.subscribePoll = function() { if (this.refreshInterval == null) { return this.refreshInterval = setInterval((__bind(function() { return this.refresh(); }, this)), 1000); } }; return MailCatcher; })(); $(function() { return window.MailCatcher = new MailCatcher; }); }).call(this);