MOD: Bandwidth Meter

 
Post new topic   Reply to topic    Aprelium Forum Index -> Tutorials
View previous topic :: View next topic  
Author Message
webzn
-


Joined: 01 Apr 2003
Posts: 27
Location: Canada

PostPosted: Thu Aug 05, 2004 4:13 pm    Post subject: MOD: Bandwidth Meter Reply with quote

Here is a little mod I wrote. If you would like to replace that boring Output (KB) with a meter that can display your bandwidth in a nice looking bar, or would you like to turn the kB into MB. Now you can....

Turn KB into MB...

//Abyss Server Control Panel Hack (C) Carl (Neogenisis.net)
// Files to edit: stats.chl

//Open /chl/stats.chl

Find:
Code:
^@StatOutputKb^

Replace with...
Code:

<script>
var stata = parseFloat(^@StatOutputKb^) / parseFloat(1024);
document.write(stata);
</script> MB


Find:
Code:
<TD ALIGN="RIGHT"><b>Output (KB)</b>:

Replace with...
Code:
<TD ALIGN="RIGHT"><b>Output (MB)</b>:


Turn KB into Meter...

//Abyss Server Control Panel Hack (C) Carl (Neogenisis.net)
// Files to edit: stats.chl

//Open chl/stats.chl

Find:
Code:
^@StatOutputKb^

Replace with...
Code:

<table cellpadding=0 cellspacing=0 height=18 width=100 border=1>
<script>
var max = 10; //Change this to your maximum MB
var stata = parseFloat(^@StatOutputKb^) / parseFloat(1024);
statb = parseFloat(parseFloat(stata) / parseFloat(max)) ;
statc = parseFloat(statb) * parseFloat(100);
document.write("<tr><td bgcolor=#000066 width=");
document.write(statc);
</script>
%></td><td></td></tr>
</table>


Find:
Code:
<TD ALIGN="RIGHT"><b>Output (KB)</b>:

Replace with...
Code:
<TD ALIGN="RIGHT"><b>Bandwidth</b>:


Last edited by webzn on Tue Aug 10, 2004 5:40 pm; edited 1 time in total
Back to top View user's profile Send private message Visit poster's website
Nick889
-


Joined: 24 Jul 2004
Posts: 4

PostPosted: Tue Aug 10, 2004 4:27 pm    Post subject: Re: MOD: Bandwidth Meter Reply with quote

webzn wrote:


//Open /chl/stats.chl

Find:
Code:
^@StatOutputKb^

Replace with...
Code:

<script>
var stata = parseFloat(^@StatOutputKb^) / parseFloat(1024);
document.write(statc);
</script> MB




small spelling mistake but it does mean the difference between this working and not...

document.write(statc);

is actually...

document.write(stata);

Just a simple mistype. I knew you ment to put that. Very nice script though, very nice. Using it on my server now! Another small thing.. is it possible to delete the trailing numbers after the megabytes?

I am getting like...

Output (MB): 87.3291015625

that on my server and I would like to get rid of the trailing numbers after the 87.
Back to top View user's profile Send private message AIM Address
webzn
-


Joined: 01 Apr 2003
Posts: 27
Location: Canada

PostPosted: Tue Aug 10, 2004 5:47 pm    Post subject: Reply with quote

Thanks for pointing that out. I guess I hit the wrong button there. Too bad we can't use php in the chl files or else this would be a lot easier

As for the trailing decimals, use this code....

//Open /chl/stats.chl

Find:
Code:
 
^@StatOutputKb^

Replace with...
Code:
 

<script>
var stats = parseFloat(^@StatOutputKb^)  / parseFloat(1024);
//document.write(stats);
var stata = Math.round(stats);
document.write(stata);
</script> MB
 


For my next major project, I want to make a full skin for the console.
Back to top View user's profile Send private message Visit poster's website
Nick889
-


Joined: 24 Jul 2004
Posts: 4

PostPosted: Wed Aug 11, 2004 7:27 am    Post subject: Reply with quote

$20 bucks says this isnt your fault and there isnt much you can do about it... but if you have sent less than 1 meg of data than the bandwidth meter is always 50% full no matter what until you send atleast 1 meg.

I even tried altering the script to read and calculate it by kilobytes instead of megabytes and even with that alteration, the bandwidth meter refuses to show kilobytes for some strange reason.

Thats ok... most of the time users will have sent more than 1 meg of data and who really needs a meter for such low numbers anyway.

Still a great script! 9/10
Back to top View user's profile Send private message AIM Address
blast1102
-


Joined: 27 May 2004
Posts: 6
Location: England

PostPosted: Wed Aug 11, 2004 12:35 pm    Post subject: Reply with quote

Great code, I enjoyed playing with it.

I added
Code:
<TR>
<TD ALIGN="RIGHT"><b>Output (Kb)</b>:
         </TD>
<TD>
            ^@StatOutputKb^
         </TD>
</TR>
<TR>

3 times then left the first as kb and changed the second to MB then the third to a meter.

Ps Nick889 I did not have the 50% bar below 1M problem.
_________________
Tom
Back to top View user's profile Send private message Send e-mail
webzn
-


Joined: 01 Apr 2003
Posts: 27
Location: Canada

PostPosted: Wed Aug 11, 2004 7:27 pm    Post subject: Reply with quote

That problem seems to vary between each browser. Its odd but if you are willing to live with it, it shouldn't be a problem. I'll keep tinkering as well.
Back to top View user's profile Send private message Visit poster's website
Xijar
-


Joined: 10 Nov 2004
Posts: 3

PostPosted: Wed Nov 10, 2004 9:41 am    Post subject: Eh Reply with quote

So this meters a the whole server not just a certain folder, if I can meter a certain folder only. I need it right away C_C
Back to top View user's profile Send private message
webzn
-


Joined: 01 Apr 2003
Posts: 27
Location: Canada

PostPosted: Sat Nov 13, 2004 6:01 pm    Post subject: Reply with quote

Its just a cosmetic change. I can't meter a folder with this script
_________________
Carl (Webzn)
http://Neogenisis.net
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> Tutorials All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group