User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 401,945 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,359 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1024 | Replies: 5
Reply
Join Date: Oct 2005
Posts: 236
Reputation: Inny is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 5
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

Dani Webs Code?

  #1  
Jan 16th, 2007
This site shows (x) users veiwing each forum on the main index, Id love to know how its done? can it be done with javascript?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2005
Location: Old Hampshire, Old England (LOL)
Posts: 11,937
Reputation: jbennet is a jewel in the rough jbennet is a jewel in the rough jbennet is a jewel in the rough jbennet is a jewel in the rough 
Rep Power: 30
Solved Threads: 268
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Microsoft Fanboy

Re: Dani Webs Code?

  #2  
Jan 16th, 2007
i think its a php script maybe
i know nothing about web design though so take that with a pinch of salt
Last edited by jbennet : Jan 16th, 2007 at 2:22 am.
TRY MY SUGGESTIONS AT YOUR OWN RISK!
james.bennet1@ntlworld.com
Reply With Quote  
Join Date: Oct 2005
Posts: 236
Reputation: Inny is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 5
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

Re: Dani Webs Code?

  #3  
Jan 16th, 2007
Well thankyou for replying at all, Appreciated!
Reply With Quote  
Join Date: Jun 2004
Location: Hemet, CA
Posts: 427
Reputation: FC Jamison is on a distinguished road 
Rep Power: 5
Solved Threads: 17
Colleague
FC Jamison's Avatar
FC Jamison FC Jamison is offline Offline
Posting Pro in Training

Re: Dani Webs Code?

  #4  
Jan 16th, 2007
This forum uses PHP and the code is embedded into the software.

I do not know if it can be done with javascript.
Reply With Quote  
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 10,889
Reputation: cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice 
Rep Power: 32
Solved Threads: 109
Admin
Staff Writer
cscgal's Avatar
cscgal cscgal is online now Online
The Queen of DaniWeb

Re: Dani Webs Code?

  #5  
Jan 16th, 2007
It's not possible to do this with JavaScript because you would need some sort of database to keep track of how many visitors there are, which can only be done with a server-side programming language.

We do it with PHP and MySQL. Each time a page is accessed, a record in a MySQL table is updated with the user's IP address and the timestamp. Records with timestamps older than 20 minutes are deleted. The number of IP addresses is the number of people currently visiting the site.
Last edited by cscgal : Jan 16th, 2007 at 3:24 am. Reason: Typo
Reply With Quote  
Join Date: Oct 2005
Posts: 236
Reputation: Inny is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 5
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

Re: Dani Webs Code?

  #6  
Jan 16th, 2007
ok Thanks again. I found a similar code that may need slight tweaking to work for me. I dont have a 'veiws' cell on my main index though.
could I rewrite this to add to cell 'Forum'? which list the forum name?

P.s Im aware of the advertising ban so I wont link you my site to see.

<script type="text/javascript">
<!--
/*
Users Viewing In Main Page 
*/
var addrequest;
var viewadds = new Array();
var curnum = 0;
var td = document.getElementsByTagName('td');
for(t=0;t<td.length;t++){
if(td[t].getElementsByTagName('a')[0] && td[t].getElementsByTagName('a')[0].href.match(/showforum=\d+/)){
viewadds.push(td[t]);
}}
checkBViews();
function checkBViews(){
if(window.ActiveXObject){
addrequest = new ActiveXObject("Microsoft.XMLHTTP");
} else {
addrequest = new XMLHttpRequest();
}
var opener = viewadds[curnum].getElementsByTagName('a')[0].href;
addrequest.onreadystatechange = function(){
addBViews();
}
addrequest.open("GET",opener,true);
addrequest.send('');
}
function addBViews(){
if(addrequest.readyState == 4 && addrequest.status == 200){
var resptext = addrequest.responseText;
var addiv = document.createElement('div');
addiv.innerHTML = resptext;
var hdiv = addiv.getElementsByTagName('div');
var views = 0;
for(a=0;a<hdiv.length;a++){
if(hdiv[a].className == "darkrow2" && hdiv[a].innerHTML.match(/^(\d+) User\(s\) are browsing this forum/)){
views = parseInt(RegExp.$1) - 1;
}}
if(views < 0){
views = 0;
}
if(views != 0){
var viewstext = document.createTextNode( ' ('+views+' viewing'+')');
viewadds[curnum].insertBefore(viewstext,viewadds[curnum].getElementsByTagName('br')[0]);
}
curnum++;
if(curnum != viewadds.length){
checkBViews();
} else {
termViews();
}}}
function termViews(){
if(window.ActiveXObject){
addrequest = new ActiveXObject("Microsoft.XMLHTTP");
} else {
addrequest = new XMLHttpRequest();
}
addrequest.open("GET",location.href,true);
addrequest.send('');
}
//-->
</script>


p.s My templet for board index forum row. Where I have 'New topic' link is where I want Users Browsing

 <tr> 
          <td class="row4" align="center">{$info['img_new_post']}</td>
          <td class="row4"><a href="{ibf.script_url}showforum={$info['id'] }"onMouseover="ddrivetip('Open This Forum!','yellow', 150)";
onMouseout="hideddrivetip()"><b>{$info['name']}</b></a><br /><br><a href="{ibf.script_url}act=Post&CODE=00&f={$info['id']}"onMouseover="ddrivetip('Start A new Topic In this Forum!','yellow', 150)";
onMouseout="hideddrivetip()"><FONT COLOR="#FF0000"><b>New Topic</b></font></a><br /><br><span class='desc'>{$info['description']}<br />









</span></td>
         
          <td class="row2" align="center">{$info['topics']}</td>
          <td class="row2" align="center">{$info['posts']}</td>

  <td class="row2" nowrap="nowrap">{$info['last_post']}<br />{ibf.lang.in}:&nbsp;{$info['last_unread']}{$info['last_topic']}

<br />{ibf.lang.by}: {$info['last_poster']}

</td>
        </tr>

p.s users browsing [forum/topic] is written in php my board
Last edited by Inny : Jan 16th, 2007 at 3:33 am.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 5:17 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC