Revolution X

Coding Community => Coding Snippets => Topic started by: Agent Moose on November 07, 2008, 06:56:15 pm



Title: Activity Code
Post by: Agent Moose on November 07, 2008, 06:56:15 pm
Footers:
Code:
<script>
function Activity(){
$("td.titlebg:contains(Forum Stats)").parent().next().each(function(){
if(this.innerHTML.match(/(\d+) Posts/i)){
var bPosts = RegExp.$1 + RegExp.$2;
$("tr").each(function(){
if(this.innerHTML.match(/(\d+) Posts/i)){
var fPosts = RegExp.$1;
var Activity = Math.round(100 * fPosts / bPosts);
$(this).find("td.windowbg[valign='middle'] span.smalltext").append("<br>" + Activity + "% Activity");
};});};});};
Activity();
</script>

Here is the code alot of people wanted!  The Activity Code, straight from the SMCodes Footers!  There is one problem with it though.  If you look at your board stats, find (number) Posts.

If that number doesn't have a comma for you, it will work perfectly right when you put it on your forums, but, if you do have a comma, you will need to edit a part of the code.

You will need to add ,(\d+) to the code in this line:
Code:
if(this.innerHTML.match(/(\d+) Posts/i)){
Example, if you have 10,000 posts, that line of code would look like this:
Code:
if(this.innerHTML.match(/(\d+),(\d+) Posts/i)){

There ya go, might be alittle comfusion for some of you, but you can try to get it :P

Enjoy :)


Title: Re: Activity Code
Post by: Lyle on June 09, 2009, 07:35:08 am
would this work in Global Headers and Footers?


Title: Re: Activity Code
Post by: Agent Moose on June 09, 2009, 08:46:59 am
Yes it would.


Title: Re: Activity Code
Post by: xboi209 on June 10, 2009, 04:33:23 pm
what does this code do?


Title: Re: Activity Code
Post by: Andrew on June 10, 2009, 05:38:52 pm
It basically tells you how much activity there is for a certain board.


Title: Re: Activity Code
Post by: xboi209 on June 10, 2009, 05:54:13 pm
which board?I dont see any place to edit :-\


Title: Re: Activity Code
Post by: Andrew on June 10, 2009, 06:36:56 pm
It adds it for all boards. Ive used this one before, just got rid of it cause I went code crazy after adding it :P


Title: Re: Activity Code
Post by: Mojobojo82 on June 13, 2009, 09:37:56 am
Lol! Andrew?? Thx for telling me what it does aswell...
Great code Moose but it's useless for me ;)
And my name is Andrew too :P


Title: Re: Activity Code
Post by: Agent Moose on June 13, 2009, 12:04:55 pm
Glad you like the code, even though your not using it :P


Title: Re: Activity Code
Post by: Mojobojo82 on June 14, 2009, 02:01:58 am
Don't take me wrong it's a good code but just no need to use it with my forum O0


Title: Re: Activity Code
Post by: slayer766 on October 18, 2009, 06:33:53 pm
Moose, why don't you just split out the commas in the RegEx?


Title: Re: Activity Code
Post by: Exilis on October 18, 2009, 08:04:39 pm
I wondered that too XD


Title: Re: Activity Code
Post by: Agent Moose on October 18, 2009, 10:00:44 pm
heh, never thought of that.

Back when I wrote this code, I didn't know how to use the split/join functions :P

I haven't messed with a code in awhile, lets hope I can still do it xD

EDIT:
Yep, totally didn't work right:
Code:
<script type="text/javascript">
var bPosts = "", fPosts = "";
$("td.titlebg:contains(Forum Stats)").parent().next().each(function(){
if(this.innerHTML.match(/(\d+) Posts/i)){
if(RegExp.$1.match(/,/i)){
bPosts = RegExp.$1.split(",").join("");
}else{
bPosts = RegExp.$1;
}
$("tr").each(function(){
if(this.innerHTML.match(/(\d+) Posts/i)){
if(RegExp.$1.match(/,/i)){
fPosts = RegExp.$1.split(",").join("");
}else{
fPosts = RegExp.$1;
}
var Activity = Math.round(100 * fPosts / bPosts);
$(this).find("td.windowbg[valign='middle'] span.smalltext").append("<br>" + Activity + "% Activity");
};});};});
</script>