Dani Webs Code?

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Oct 2005
Posts: 240
Reputation: Inny is an unknown quantity at this point 
Solved Threads: 6
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

Dani Webs Code?

 
0
  #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?
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 16,259
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 540
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator

Re: Dani Webs Code?

 
0
  #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 3:22 am.
If i am helpful, please give me reputation points.
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 240
Reputation: Inny is an unknown quantity at this point 
Solved Threads: 6
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

Re: Dani Webs Code?

 
0
  #3
Jan 16th, 2007
Well thankyou for replying at all, Appreciated!
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 434
Reputation: FC Jamison is on a distinguished road 
Solved Threads: 20
Team Colleague
FC Jamison's Avatar
FC Jamison FC Jamison is offline Offline
Posting Pro in Training

Re: Dani Webs Code?

 
0
  #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 Quick reply to this message  
Join Date: Feb 2002
Posts: 12,054
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 129
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb

Re: Dani Webs Code?

 
0
  #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 4:24 am. Reason: Typo
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/DaniWeb
And if you're interested in Internet marketing there is twitter.com/DaniWebAds
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 240
Reputation: Inny is an unknown quantity at this point 
Solved Threads: 6
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

Re: Dani Webs Code?

 
0
  #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.

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <script type="text/javascript">
  2. <!--
  3. /*
  4. Users Viewing In Main Page
  5. */
  6. var addrequest;
  7. var viewadds = new Array();
  8. var curnum = 0;
  9. var td = document.getElementsByTagName('td');
  10. for(t=0;t<td.length;t++){
  11. if(td[t].getElementsByTagName('a')[0] && td[t].getElementsByTagName('a')[0].href.match(/showforum=\d+/)){
  12. viewadds.push(td[t]);
  13. }}
  14. checkBViews();
  15. function checkBViews(){
  16. if(window.ActiveXObject){
  17. addrequest = new ActiveXObject("Microsoft.XMLHTTP");
  18. } else {
  19. addrequest = new XMLHttpRequest();
  20. }
  21. var opener = viewadds[curnum].getElementsByTagName('a')[0].href;
  22. addrequest.onreadystatechange = function(){
  23. addBViews();
  24. }
  25. addrequest.open("GET",opener,true);
  26. addrequest.send('');
  27. }
  28. function addBViews(){
  29. if(addrequest.readyState == 4 && addrequest.status == 200){
  30. var resptext = addrequest.responseText;
  31. var addiv = document.createElement('div');
  32. addiv.innerHTML = resptext;
  33. var hdiv = addiv.getElementsByTagName('div');
  34. var views = 0;
  35. for(a=0;a<hdiv.length;a++){
  36. if(hdiv[a].className == "darkrow2" && hdiv[a].innerHTML.match(/^(\d+) User\(s\) are browsing this forum/)){
  37. views = parseInt(RegExp.$1) - 1;
  38. }}
  39. if(views < 0){
  40. views = 0;
  41. }
  42. if(views != 0){
  43. var viewstext = document.createTextNode( ' ('+views+' viewing'+')');
  44. viewadds[curnum].insertBefore(viewstext,viewadds[curnum].getElementsByTagName('br')[0]);
  45. }
  46. curnum++;
  47. if(curnum != viewadds.length){
  48. checkBViews();
  49. } else {
  50. termViews();
  51. }}}
  52. function termViews(){
  53. if(window.ActiveXObject){
  54. addrequest = new ActiveXObject("Microsoft.XMLHTTP");
  55. } else {
  56. addrequest = new XMLHttpRequest();
  57. }
  58. addrequest.open("GET",location.href,true);
  59. addrequest.send('');
  60. }
  61. //-->
  62. </script>


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

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1.  
  2. <tr>
  3. <td class="row4" align="center">{$info['img_new_post']}</td>
  4. <td class="row4"><a href="{ibf.script_url}showforum={$info['id'] }"onMouseover="ddrivetip('Open This Forum!','yellow', 150)";
  5. 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)";
  6. onMouseout="hideddrivetip()"><FONT COLOR="#FF0000"><b>New Topic</b></font></a><br /><br><span class='desc'>{$info['description']}<br />
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16. </span></td>
  17.  
  18. <td class="row2" align="center">{$info['topics']}</td>
  19. <td class="row2" align="center">{$info['posts']}</td>
  20.  
  21. <td class="row2" nowrap="nowrap">{$info['last_post']}<br />{ibf.lang.in}:&nbsp;{$info['last_unread']}{$info['last_topic']}
  22.  
  23. <br />{ibf.lang.by}: {$info['last_poster']}
  24.  
  25. </td>
  26. </tr>

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

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



Tag cloud for JavaScript / DHTML / AJAX
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC