December 08, 2024, 09:45:37 am
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Welcome to Revolution X, where Coding meets Graphics.
 
  Home Help Search Arcade Affiliates Staff List Calendar Members Login Register  

Activity Code

Pages: [1]   Go Down
  Print  
Author Topic: Activity Code  (Read 2403 times)
Agent Moose
Administrator
Adminitrator
Offline Offline

Gender: Male
Posts: 1,470



View Profile WWW
Badges: (View All)
« 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 Tongue

Enjoy Smiley
Report Spam   Logged


Share on Facebook Share on Twitter

Lyle
MeTube
Member
Member
Offline Offline

Gender: Male
Posts: 69



View Profile
Badges: (View All)
« Reply #1 on: June 09, 2009, 07:35:08 am »

would this work in Global Headers and Footers?
Report Spam   Logged
Agent Moose
Administrator
Adminitrator
Offline Offline

Gender: Male
Posts: 1,470



View Profile WWW
Badges: (View All)
« Reply #2 on: June 09, 2009, 08:46:59 am »

Yes it would.
Report Spam   Logged


xboi209
Exclusive
Exclusive
Offline Offline

Gender: Male
Posts: 235


View Profile WWW
Badges: (View All)
« Reply #3 on: June 10, 2009, 04:33:23 pm »

what does this code do?
Report Spam   Logged
Andrew
Exclusive
Exclusive
Offline Offline

Gender: Male
Posts: 539



View Profile WWW
Badges: (View All)
« Reply #4 on: June 10, 2009, 05:38:52 pm »

It basically tells you how much activity there is for a certain board.
Report Spam   Logged

xboi209
Exclusive
Exclusive
Offline Offline

Gender: Male
Posts: 235


View Profile WWW
Badges: (View All)
« Reply #5 on: June 10, 2009, 05:54:13 pm »

which board?I dont see any place to edit Undecided
Report Spam   Logged
Andrew
Exclusive
Exclusive
Offline Offline

Gender: Male
Posts: 539



View Profile WWW
Badges: (View All)
« Reply #6 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 Tongue
Report Spam   Logged

Mojobojo82
MVP
MVP
Offline Offline

Gender: Male
Posts: 838


View Profile
Badges: (View All)
« Reply #7 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 Wink
And my name is Andrew too Tongue
Report Spam   Logged






Agent Moose
Administrator
Adminitrator
Offline Offline

Gender: Male
Posts: 1,470



View Profile WWW
Badges: (View All)
« Reply #8 on: June 13, 2009, 12:04:55 pm »

Glad you like the code, even though your not using it Tongue
Report Spam   Logged


Mojobojo82
MVP
MVP
Offline Offline

Gender: Male
Posts: 838


View Profile
Badges: (View All)
« Reply #9 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 Afro
Report Spam   Logged






slayer766
PHP > JS
Member
Member
Offline Offline

Posts: 147



View Profile
Badges: (View All)
« Reply #10 on: October 18, 2009, 06:33:53 pm »

Moose, why don't you just split out the commas in the RegEx?
Report Spam   Logged
Exilis
Optimistic & Creative
Global Moderator
Global Moderator
Offline Offline

Posts: 929


View Profile
Badges: (View All)
« Reply #11 on: October 18, 2009, 08:04:39 pm »

I wondered that too XD
Report Spam   Logged

Global Mod, (sort of) at your service.

http://twitter.com/timothyaveni

Agent Moose
Administrator
Adminitrator
Offline Offline

Gender: Male
Posts: 1,470



View Profile WWW
Badges: (View All)
« Reply #12 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 Tongue

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>
« Last Edit: October 18, 2009, 10:14:50 pm by Agent Moose » Report Spam   Logged


Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum

Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy