*

SwingTop

Manipulate Users Online
« on: June 05, 2013, 02:48:31 PM »
Does anyone now how to manipulate the number of total users online?

*

Vink

  • *****
  • 329
    • NedDate.nl
Re: Manipulate Users Online
« Reply #1 on: June 05, 2013, 06:19:12 PM »
Hi

What would you like to do with it?
Regards
Vink
osDate 2.19a | PHP 5.3.8 | MySQL  5.0.91

*

david

  • *
  • 18
Re: Manipulate Users Online
« Reply #2 on: June 05, 2013, 06:35:54 PM »
there is a single line of code that you can change to say any number of users that you want are currently online....

the problem is this:

if you say that you have 500 users online and i login, where are they?  I would like to chat with some of them (perhaps) so show me a pic of each user.

well, you could even fake this, if you wanted to.

but now none of them talk back   :(  .....

but, you could set up an ai interface- and now a robot would talk back to them.....

or- you could hire chatters to chat live to hundreds of users... or....



let me know which one you would like to do and i can help (push, shove, kick) you in the right direction.

*

SwingTop

Re: Manipulate Users Online
« Reply #3 on: June 05, 2013, 06:40:23 PM »
Thanks for the replies. I would like to show a random number "members online" when there are none or only a few members online. It is okay for me if the random number is, lets say, between 10 to 20. If the real number member online is more than 20 I prefer to show the real number.

*

Vink

  • *****
  • 329
    • NedDate.nl
Re: Manipulate Users Online
« Reply #4 on: June 05, 2013, 07:41:13 PM »
Hi

This javascript is doing what u want:
Code: [Select]
<script type="text/javascript">
{literal}
function randomcount()
{
var x=document.getElementById("count")
x.innerHTML=Math.round((20-10) * Math.random() + 10);
}
{/literal}
</script>


<p id="count"></p>

the script is putting a random number between 10 and 20 between the <p></p>
everytime the function randomcount is called.

you can do this with:
Quote
<body onLoad="randomcount()">

or in the function with:
Quote
window.onload=randomcount();
Regards
Vink
osDate 2.19a | PHP 5.3.8 | MySQL  5.0.91

*

david

  • *
  • 18
Re: Manipulate Users Online
« Reply #5 on: June 06, 2013, 01:21:10 AM »
nice.....

you might want to ADD to "count" in case you ever actually get more than 20 real users on at the same time.....


a bettter, and FREE, solution can be found here:

http://www.osdateforum.com/7/onlineuser-by-gender/

this addresses the issue of showing WHO is online too...


*

SwingTop

Re: Manipulate Users Online
« Reply #6 on: June 06, 2013, 07:14:34 AM »
Both great suggestions, thanks. The script from Vink seems to be the most usefull for me, just because I need only the total member message and not by gender specific.

I understand Vink's script allways suggest there are some (10-20) members online, but what if the real number members online is >20? Let's say there are 50 members online, what does the script display in that case?
« Last Edit: June 06, 2013, 01:58:06 PM by SwiTop »

*

Vink

  • *****
  • 329
    • NedDate.nl
Re: Manipulate Users Online
« Reply #7 on: June 06, 2013, 06:30:34 PM »
You can use a if statement. I dont know what shows in 2.6 the online userscount.. in my version (2.19) it is  {$totalrecs} so if you make it:
{if $totalrecs > 20} {$totalrecs} {else} <p id="count"></p> {/if}

shows the real onlineusers if the onlineusers are more than 20.. if less  it shows the random function randomcount()
Regards
Vink
osDate 2.19a | PHP 5.3.8 | MySQL  5.0.91

*

SwingTop

Re: Manipulate Users Online
« Reply #8 on: June 08, 2013, 11:09:41 AM »
Hi. Trying to implement the script I discover problems, I'm not very well known with this kind of work… I did some modifications with the index.tpl file which is in the template map of the template I use.  In index.tpl I have added the code between the first and second line as follows:

{include file="index_header.tpl"}
<script type="text/javascript">
{literal}
function randomcount()
{
var x=document.getElementById("count")
x.innerHTML=Math.round((20-10) * Math.random() + 10);
}
{/literal}
</script>

<body dir="{lang mkey='DIRECTION'}" {if $google_map eq 'Y'}onload="load_map()"{/if}>

To test if this works I have added some code before </body>, also in index.tpl:

<p>Random counter: </p>
<p id="count"></p>

</body>
</html>
{closedb}

Left at the bottom of the home screen the text "Random counter: " is shown, but not the random number. Do you have more specific instructions how (and where) to install the java code?

*

Vink

  • *****
  • 329
    • NedDate.nl
Re: Manipulate Users Online
« Reply #9 on: June 08, 2013, 11:52:02 AM »
Hi
You didn't call the function...
Make it like this:
Code: [Select]
<script type="text/javascript">
{literal}
function randomcount()
{
var x=document.getElementById("count")
x.innerHTML=Math.round((20-10) * Math.random() + 10);
}
window.onload=randomcount();
{/literal}
</script>
Regards
Vink
osDate 2.19a | PHP 5.3.8 | MySQL  5.0.91

*

SwingTop

Re: Manipulate Users Online
« Reply #10 on: June 08, 2013, 12:35:06 PM »
Thanks for your kind support! The first lines of index.tpl (within the /template map I use for my site) now look like:

{include file="index_header.tpl"}
<script type="text/javascript">
{literal}
function randomcount()
{
var x=document.getElementById("count")
x.innerHTML=Math.round((20-10) * Math.random() + 10);
}
window.onload=randomcount();
{/literal}
</script>

<body dir="{lang mkey='DIRECTION'}" {if $google_map eq 'Y'}onload="load_map()"{/if}>
<center>
<!-- Header portion  -->


The last lines of this index.tpl:

{if $smarty.session.UserId <= 0}
   updateOnlineCount();
{/if}
</script>
<p>Random counter: </p>
<p id="count"></p>
</body>
</html>
{closedb}


Unfortunately the random number is still not shown  :-\

*

Vink

  • *****
  • 329
    • NedDate.nl
Re: Manipulate Users Online
« Reply #11 on: June 08, 2013, 03:06:29 PM »
Hi
sorry i made a mistake in window.onload=randomcount();
it must be window.onload=randomcount;
so without the ()
Regards
Vink
osDate 2.19a | PHP 5.3.8 | MySQL  5.0.91

*

SwingTop

Re: Manipulate Users Online
« Reply #12 on: June 08, 2013, 03:28:44 PM »
Hi, this works fine now! As we say in Dutch (and I suppose you can read): "Dat scheelt een slok op een borrel". Thanks for helping me.

*

Vink

  • *****
  • 329
    • NedDate.nl
Re: Manipulate Users Online
« Reply #13 on: June 08, 2013, 03:59:23 PM »
haha ik neem er ook eentje :) leuk hier een landgenoot te treffen en te kunnen helpen ;)
Regards
Vink
osDate 2.19a | PHP 5.3.8 | MySQL  5.0.91

*

SwingTop

Re: Manipulate Users Online
« Reply #14 on: June 08, 2013, 04:02:45 PM »
And we share the same surname too  ;)