Created
August 9, 2013 07:46
-
-
Save victorb/6191838 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 currentEmails = {}; | |
| var detectedTransport = null; | |
| jQuery(document).ready(function () { | |
| unsub(theinbox); | |
| connectee() | |
| }); | |
| var dataPack; | |
| var connected = false; | |
| function setKaptcha() { | |
| $("#kaptcha3").attr("src", "/kaptcha.jpg?" + new Date); | |
| var ff = $("#fwderror"); | |
| if (ff && ff[0]) ff[0].innerHTML = "" | |
| } | |
| function sendFeedback() { | |
| var msg = $("#styled").val(); | |
| if (!msg || msg.indexOf("ave site feed") > 0 || msg.indexOf("eedback Sub") > 0) return; | |
| var url1 = "/feedback?msg=" + msg + "&time=" + (new Date).getTime(); | |
| $.ajax({ | |
| url: url1 | |
| }); | |
| $("#styled").val("Feedback Submitted! Thanks!") | |
| } | |
| function parseMsg(tospot) { | |
| var tt = tospot; | |
| setTimeout(function () { | |
| window.location.href = tt | |
| }, 8E3) | |
| } | |
| function unsub(inbox) { | |
| theinbox = inbox; | |
| var url1 = "/unsub?box=" + inbox + "&time=" + (new Date).getTime(); | |
| $.getJSON(url1, function (json) { | |
| var app = document.getElementById("InboxNameCtrl"); | |
| var scope = angular.element(app).scope(); | |
| var inbox = json["inbox"]; | |
| if (inbox) { | |
| parseMsg("/inbox.jsp?to=" + theinbox); | |
| return | |
| } | |
| var rate = json["rate"]; | |
| if (rate) { | |
| parseMsg("/ratelimit.jsp"); | |
| return | |
| } | |
| theinbox = json["inboxname"]; | |
| scope.$apply(function () { | |
| scope.setInboxName(json["inboxname"]) | |
| }); | |
| var app = document.getElementById("InboxNameCtrl2"); | |
| var scope = | |
| angular.element(app).scope(); | |
| scope.$apply(function () { | |
| scope.setInboxName(json["inboxname"]) | |
| }); | |
| var app = document.getElementById("InboxNameCtrlq"); | |
| var scope = angular.element(app).scope(); | |
| scope.$apply(function () { | |
| scope.setInboxName(json["inboxname"]) | |
| }); | |
| var app = document.getElementById("InboxNameCtrl1"); | |
| var scope = angular.element(app).scope(); | |
| scope.$apply(function () { | |
| scope.setAlternateName(json["alternatename"]) | |
| }) | |
| }) | |
| } | |
| var latestid = null; | |
| function connectee() { | |
| var url1 = "/pubsub?inbox=" + theinbox + "&time=" + (new Date).getTime(); | |
| if (latestid) url1 += "&after=" + latestid; | |
| $.getJSON(url1, function (data) { | |
| var items = []; | |
| for (var g = 0; g < data.length; ++g) { | |
| var json = data[g]; | |
| var msgid = json["msgid"]; | |
| if (msgid) { | |
| parseMsg("/inbox.jsp?to=" + theinbox); | |
| return | |
| } | |
| var rate = json["rate"]; | |
| if (rate) { | |
| parseMsg("/ratelimit.jsp"); | |
| return | |
| } | |
| var id = json["id"]; | |
| latestid = id; | |
| var state = json["state"]; | |
| var app = document.getElementById("InboxCtrl"); | |
| var scope = angular.element(app).scope(); | |
| if (!currentEmails[id]) { | |
| var thetime = | |
| new Date; | |
| thetime.setSeconds(thetime.getSeconds() - json["seconds_ago"]); | |
| json["arrivetime"] = thetime; | |
| currentEmails[id] = json; | |
| scope.$apply(function () { | |
| scope.addEmail(json) | |
| }) | |
| } | |
| } | |
| }); | |
| setTimeout("connectee()", 1E4) | |
| } | |
| function clearTable() { | |
| var app = document.getElementById("InboxCtrl"); | |
| var scope = angular.element(app).scope(); | |
| scope.$apply(function () { | |
| scope.deleteAllEmails() | |
| }); | |
| currentEmails = {}; | |
| latestid = null | |
| } | |
| function delMsg() { | |
| var url1 = "/api/expunge?time=" + (new Date).getTime(); | |
| $.ajax({ | |
| url: url1 | |
| }).done(function (data) { | |
| clearTable(); | |
| latestid = null; | |
| showInboxPage() | |
| }) | |
| } | |
| function forwardMsg() { | |
| var kap = $("#kaptchafield").val(); | |
| var forwarding = $("#forward3").val(); | |
| var url1 = "/api/remove?kap=" + kap + "&email=" + forwarding + "&time=" + (new Date).getTime(); | |
| $.ajax({ | |
| url: url1 | |
| }).done(function (data) { | |
| var json = JSON.parse(data); | |
| var err = json["error"]; | |
| if (err) { | |
| var ff1 = $("#fwderror"); | |
| if (ff1 && ff1[0]) { | |
| setKaptcha(); | |
| ff1[0].innerHTML = err | |
| } | |
| return | |
| } | |
| var ff = $("#fwderror"); | |
| if (ff && ff[0]) ff[0].innerHTML = "Forwarded! Check your spam folder too"; | |
| setTimeout(function () { | |
| $("#forward-email").toggle() | |
| }, 2E3) | |
| }) | |
| } | |
| var lastIsText = false; | |
| function loadMessage(msgid, text) { | |
| setKaptcha(); | |
| var url1 = "rendermail.jsp?msgid=" + msgid + "&time=" + (new Date).getTime(); | |
| var msgidclose = msgid; | |
| if (text) { | |
| lastIsText = true; | |
| url1 += "&text=true" | |
| } | |
| $.ajax({ | |
| url: url1 | |
| }).done(function (data) { | |
| $("#mailshowdiv")[0].innerHTML = data; | |
| var recv = $("#hidey")[0].innerHTML; | |
| $("#displaytime")[0].innerHTML = new Date(1E3 * ((new Date).getTime() / 1E3 - recv)); | |
| decorateLinks(msgidclose) | |
| }) | |
| } | |
| function ShowMailCtrl($scope) { | |
| $scope.from = ""; | |
| $scope.inboxname = ""; | |
| $scope.subject = ""; | |
| $scope.setInboxName = function (inboxname1) { | |
| $scope.inboxname = inboxname1 | |
| }; | |
| $scope.setFrom = function (from1) { | |
| $scope.from = from1 | |
| }; | |
| $scope.setSubject = function (subject1) { | |
| $scope.subject = subject1 | |
| } | |
| } | |
| function InboxNameCtrl($scope) { | |
| $scope.inboxname = ""; | |
| $scope.setInboxName = function (inboxname1) { | |
| $scope.inboxname = inboxname1 | |
| } | |
| } | |
| function InboxNameCtrl2($scope) { | |
| $scope.inboxname = ""; | |
| $scope.setInboxName = function (inboxname1) { | |
| $scope.inboxname = inboxname1 | |
| } | |
| } | |
| function InboxNameCtrlq($scope) { | |
| $scope.inboxname = ""; | |
| $scope.setInboxName = function (inboxname1) { | |
| $scope.inboxname = inboxname1 | |
| } | |
| } | |
| function InboxNameCtrl1($scope) { | |
| $scope.alternatename = ""; | |
| $scope.setAlternateName = function (inboxname1) { | |
| $scope.alternatename = inboxname1 | |
| } | |
| } | |
| var defaultTitle = "Mailinator - Free. Disposable. Email."; | |
| function InboxCtrl($scope) { | |
| $scope.emails = []; | |
| $scope.addEmail = function (email1) { | |
| email1["humandate"] = jQuery.timeago(email1["arrivetime"]); | |
| $scope.emails.splice(0, 0, email1); | |
| if ($scope.emails.length > 20) $scope.emails.splice(-1, 1); | |
| document.title = "[" + $scope.emails.length + "] " + defaultTitle | |
| }; | |
| $scope.updateHumanTimes = function () { | |
| for (var g = 0; g < $scope.emails.length; ++g) { | |
| var email1 = $scope.emails[g]; | |
| $scope.emails[g]["humandate"] = jQuery.timeago(email1["arrivetime"]) | |
| } | |
| }; | |
| $scope.deleteAllEmails = function () { | |
| $scope.emails = []; | |
| document.title = defaultTitle | |
| }; | |
| $scope.deleteEmail = function (lastemail) { | |
| var idToDelete = lastemail["id"]; | |
| for (var g = 0; g < $scope.emails.length; ++g) | |
| if ($scope.emails[g]["id"] == idToDelete) $scope.emails.splice(g, 1); | |
| var settitle = defaultTitle; | |
| if ($scope.emails.length > 0) settitle = "[" + $scope.emails.length + "] " + settitle; | |
| document.title = settitle | |
| } | |
| } | |
| function updateTimes() { | |
| var app = document.getElementById("InboxCtrl"); | |
| if (app) { | |
| var scope = angular.element(app).scope(); | |
| if (scope) scope.$apply(function () { | |
| scope.updateHumanTimes() | |
| }) | |
| } | |
| setTimeout(updateTimes, 15E3) | |
| } | |
| updateTimes(); | |
| function showmail(emailid) { | |
| $("#maildirpane").hide(); | |
| $("#showmailpane").show(); | |
| loadMessage(emailid) | |
| } | |
| function changeInbox() { | |
| var newinbox = $("#inboxfield").val(); | |
| if (!newinbox) return; | |
| newinbox = newinbox.toLowerCase(); | |
| if (newinbox.indexOf(" ") != -1 || newinbox.indexOf("<") != -1) return; | |
| if (newinbox.indexOf("m8r-") == 0) return; | |
| var at = newinbox.indexOf("@"); | |
| if (at > -1) newinbox = newinbox.substring(0, at - 1); | |
| clearTable(); | |
| $("#inboxfield").val(""); | |
| showInboxPage(); | |
| unsub(newinbox) | |
| } | |
| function showInboxPage() { | |
| $("#showmailpane").hide(); | |
| $("#maildirpane").show(); | |
| $("#mailshowdiv")[0].innerHTML = "" | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment