/* 2Prong.js Copyright 2006 by Mark Percival - Percival Industries, LLC */ if (window.XMLHttpRequest){ // try to create XMLHttpRequest XMLReq = new XMLHttpRequest(); XMLMail = new XMLHttpRequest(); } if (window.ActiveXObject) { // if ActiveXObject use the Microsoft.XMLHTTP XMLReq = new ActiveXObject("Microsoft.XMLHTTP"); XMLMail = new ActiveXObject("Microsoft.XMLHTTP"); } window.onload=kickStart; var genEmail = ''; var checkMailURL = 'checkemail.php?email='; var getMailURL = 'email.php?id='; var recievedMail = new Array; var emailidArray = new Array; var position = 0; var emailCount = 0; var interval; //var domain = 'iheartspam.org'; var domain = 'reducespam.org';//update this var XMLerror = 0; function kickStart() { setEmail(); startAutoCheck(true); } function setEmail(){ var regex = new RegExp(/\?email=(.+)/); var match = regex.exec(location.href); if(!match){ location.href = '?email='+randomEmail(10); } else genEmail = match[1].substr(0,15); checkMailURL += genEmail; setHTML('emailaddress', '' + genEmail +'@'+ domain + '' + "
"); copy(genEmail+"@"+domain); //updated 150610 setHTML('emailaddressincontent', '' + genEmail +'@'+ domain + ''); applyClickToSelectEvent(); } function startAutoCheck(toggle) { if(toggle) { throbber(true,'Checking Mail'); checkMail(); interval = setInterval("checkMail()", 7000); } else clearInterval(interval); } function checkMail(){ request(checkMailURL + '&c=' + Math.random(), checkMailProc); } function checkMailProc(){ if (XMLReq.readyState==4 && XMLReq.status == 200) { if(XMLReq.responseText) emailidArray = XMLReq.responseText.split(","); if (emailidArray.length > emailCount) { getMail(emailidArray[emailidArray.length - 1]); position = emailidArray.length; if(emailidArray.length>1) multiMail(); } emailCount = emailidArray.length; if(error=1){ throbber(true,'Checking Mail'); error=0; }//reset throbber after error } else if (XMLReq.readyState==4 && XMLReq.status != 200) throbber(true,'Error connecting, retrying...'); } function multiMail() { var navoutput=''; if ((emailidArray.length >= position)&&(position!=1)) navoutput = "Prev "; else navoutput += "Prev "; navoutput += position +' of '+ emailidArray.length; if (emailidArray.length > position)navoutput += " Next"; else navoutput += " Next"; setHTML('emailnav', navoutput); } function prevMail(){ getMail(emailidArray[position-2]); position--; multiMail(); } function nextMail(){ getMail(emailidArray[position]); position++; multiMail(); } function getMail(emailid){ requestMail('email.php?id='+emailid+'&email='+genEmail, getMailProc); } function getMailProc(){ if (XMLMail.readyState==4) { XMLMail.responseText setHTML('content',XMLMail.responseText); startAutoCheck(false); throbber(false, "Check for new mail"); autolink('content'); document.title = "ReduceSpam.org - New Email"; } } function request(url, callfunc) { if (XMLReq.readyState < 1 || XMLReq.readyState > 3) { XMLReq.open("GET", url, true); // Set the onreadystatechange function XMLReq.onreadystatechange = callfunc; // Send XMLReq.send(null); } } function requestMail(url, callfunc) { XMLMail.open("GET", url, true); // Set the onreadystatechange function XMLMail.onreadystatechange = callfunc; // Send XMLMail.send(null); } function setHTML(div, data) { document.getElementById(div).innerHTML = data; } function throbber(toggle, msg) { if(toggle) setHTML('status',msg+"