\
')
timer = setInterval(updateEmailTable, 5000); //check for new mail every 5 seconds
updateEmailTable(); //and check now
}
else
{
changeHash("")
}
}
function updateEmailTable()
{
var email = activeemail;
var index = 1;
console.log("Checking mail for "+email)
$.get("api.php?a=list&email="+email+"&lastid="+lastid,function(data){
if(data.status=="ok")
{
var admin=false;
if(data.type=="admin")
{
clearInterval(timer);
admin = true;
// Do not add the To header if one with the "to" class already exists
if ( $('#tableheader').children(':eq(2)').hasClass("to") === false )
{
$('#tableheader').children(':eq(1)').after('
To
');
}
}
//$("#emailtable tr").remove(); // Empty all
from the table so we don't stack
if(Object.keys(data.emails).length>0)
for(em in data.emails)
{
if($("#nomailyet").length != 0)
$("#nomailyet").remove();
if(admin===true)
{
//dateofemail=em.split("-")[0];
email = em.substring(em.indexOf('-') + 1);
}
else dateofemail = em;
if(em>lastid) lastid = em;
//var date = new Date(parseInt(dateofemail))
//var datestring = date.getDate()+"."+date.getMonth()+"."+date.getFullYear()+" "+date.getHours()+":"+date.getMinutes();
var datestring = moment.unix(parseInt(dateofemail/1000)).format(data.dateformat); // Use moment.js formatting
var ed = data.emails[em]
email = ed.email;
$("#emailtable").append('\