Post by Todge on Mar 2, 2008 10:07:18 GMT -8
This will put a 'thermometer' in the profile of your members showing their recent activity over the past month.. Depending on how long ago they last logged on will depend on how high the thermometer will be, if they haven't logged in for over a month then it will be at the bottom..
Put it in your Main Footer..
You need to save the attached image and host the image yourself..
Then edit this part of the code with the URL of your hosted image...
with the URL of your hosted image..
Updated to work with all date formats
Put it in your Main Footer..
<script type="text/javascript">
<!--
/*
'Activity Thermometer by Todge.
Main Footer
Copyright © 2008
Please keep this header intact
*/
if(location.href.match('action=viewprofile&use'))
{
// Edit below...
var thermoImage = 'URL OF IMAGE';
// Edit above...
// Attempt to work out date format..
function getDateFormat(df)
{
if(df.match(/\s/))
{
if(df.match(/^\d/))
{
return 'ddmonth';
}
else
{
return 'monthdd';
}}
df = df.split(/\D/);
if(df[0]>12)
{
return 'ddmm';
}
if(df[1]>12)
{
return 'mmdd';
}
return 'unknown';
}
var data1 = document.getElementsByTagName('p')[0].innerHTML.split(/br>/i)[1].split(/( at|, \d+:)/)[0];
var format = getDateFormat(data1);
if(format.match(/unknown/))
{
var td = document.getElementsByTagName('td');
for(t=0; t<td.length; t++)
{
if(td[t].width == '25%' && td[t].innerHTML.match(/ate Register/))
{
data1 = td[t+1].firstChild.innerHTML.split(/\s/)[0];
var format = getDateFormat(data1);
if(format != 'unknown')
{
break;
}}
if(td[t].width == '25%' && td[t].innerHTML.match(/st Login D/))
{
data1 = td[t+1].firstChild.innerHTML.split(/\s/)[0];
var format = getDateFormat(data1);
if(format != 'unknown')
{
break;
}}
if(td[t].vAlign == 'top' && td[t].getElementsByTagName('font').length == 1 && td[t].innerHTML.match(/ on \d/))
{
data1 = td[t].firstChild.innerHTML.split(' on ')[1].split(/\s/)[0];
var format = getDateFormat(data1);
if(format != 'unknown')
{
break;
}}}}
if(format != 'unknown')
{
var expireDate = new Date();
expireDate.setMonth(expireDate.getMonth()+36);
document.cookie = 'dateFormat='+format+'; expires='+expireDate.toGMTString()+'; path=/';
}
function getDays(){
var daysAgo;
var today = document.getElementsByTagName('font')[2].innerHTML.split(/br>/i)[1].split(' at')[0].split(/, \d+:/)[0];
today = today.replace(/Jan/,'1').replace(/Feb/,'2').replace(/Mar/,'3').replace(/Apr/,'4');
today = today.replace(/May/,'5').replace(/Jun/,'6').replace(/Jul/,'7').replace(/Aug/,'8');
today = today.replace(/Sep/,'9').replace(/Oct/,'10').replace(/Nov/,'11').replace(/dec/,'12');
today = today.replace(/(st,?|nd,?|th,?|,)? /g,'-');
today = today.split(/\D/);
var lastLogin = document.getElementsByTagName('font');
for(l=0; l<lastLogin.length; l++)
{
if(lastLogin[l].innerHTML == 'Last Login Date:')
{
lastLogin = lastLogin[l+1];
break;
}}
if(lastLogin.innerHTML.match('Today'))
{
daysAgo = 0;
}
else if(lastLogin.innerHTML.match('Yesterday'))
{
daysAgo = 1;
}
else
{
lastLogin = lastLogin.innerHTML.split(' at')[0];
lastLogin = lastLogin.replace(/Jan/,'1').replace(/Feb/,'2').replace(/Mar/,'3').replace(/Apr/,'4');
lastLogin = lastLogin.replace(/May/,'5').replace(/Jun/,'6').replace(/Jul/,'7').replace(/Aug/,'8');
lastLogin = lastLogin.replace(/Sep/,'9').replace(/Oct/,'10').replace(/Nov/,'11').replace(/dec/,'12');
lastLogin = lastLogin.replace(/(st,?|nd,?|th,?|,)? /g,'-');
lastLogin = lastLogin.split(/\D/);
if(document.cookie.match(/dateFormat=d/))
{
var dd = 0;
var mm = 1;
}
else if(document.cookie.match(/dateFormat=m/))
{
var dd = 1;
var mm = 0;
}
// mm=1
if(parseFloat(lastLogin[2]) < parseFloat(today[2])-1)
{
daysAgo = 30;
}
else if(parseFloat(lastLogin[2]) == parseFloat(today[2])-1)
{
if(lastLogin[mm] == 12)
{
lastLogin[mm] = 13;
}
else
{
daysAgo = 30;
}}
if(daysAgo != 0 && daysAgo != 1 && daysAgo != 30)
{
lastLogin = (parseInt(lastLogin[mm])*31)+parseInt(lastLogin[dd]);
today = (parseInt(today[mm])*31)+parseInt(today[dd]);
daysAgo = today-lastLogin;
}}
return daysAgo;
}
function createThermometer(howLong)
{
var space = '&nb'+'sp;';
var thermo = '<br><br><center>Activity<br>Thermometer<br>';
thermo += '<table width="100px"><tbody>';
thermo += '<tr><td width="100%" height="100px" style="background-image: URL('+thermoImage+'); background-position: top center; background-repeat: no-repeat;">';
thermo += '<table width="100%" height="100px" cellspacing="0" cellpadding="0"><tbody>';
thermo += '<tr><td height="6px" width="44px"></td><td width="5px"></td><td></td></tr>';
if(howLong == 0)
{
thermo += '<tr><td></td><td style="background-color: #ff0000;"></td><td style="font-size: 5pt;">'+space+'- Active</td></tr>';
}
else
{
thermo += '<tr><td></td><td></td><td style="font-size: 5pt;">'+space+'- Active</td></tr>';
}
for(t=0; t<29; t++)
{
if(t<howLong)
{
thermo += '<tr><td height="2px"></td><td></td><td></td></tr>';
}
else
{
thermo += '<tr><td height="2px"></td><td style="background-color: #ff0000;"></td><td></td></tr>';
}}
if(howLong == 30)
{
thermo += '<tr><td></td><td></td><td style="font-size: 5pt;">'+space+'- In-active</td></tr>';
}
else
{
thermo += '<tr><td></td><td style="background-color: #ff0000;"></td><td style="font-size: 5pt;">'+space+'- In-active</td></tr>';
}
thermo += '<tr><td height="25px"></td><td></td><td></td></tr>';
thermo += '</tbody></table>';
thermo += '</td></tr>';
thermo += '</tbody></table></center>';
return thermo;
}
var lastTimeHere = getDays();
var thermometer = createThermometer(lastTimeHere);
var profile = document.getElementsByTagName('td');
for(p=0; p<profile.length; p++)
{
if(profile[p].width == '20%' && profile[p].className == 'windowbg' && profile[p].vAlign == 'top')
{
profile[p].innerHTML += thermometer;
break;
}}}
// -->
</script>
You need to save the attached image and host the image yourself..
Then edit this part of the code with the URL of your hosted image...
var thermoImage = 'URL OF IMAGE';
with the URL of your hosted image..
Updated to work with all date formats