Shoutbox

online time script - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: online time script (/showthread.php?tid=64828)

online time script by stuartbennett on 08-12-2006 at 03:21 PM

i did run a search for this script's thread but cant find one for it so do excuse me if there is one.

i have a suggestion for a new feature, can you add a way to configure the time format displayed in your PSM so instead of

seconds, minutes, hours, days

it could display as

days, hours, minutes, seconds.

or a variety of other prebuilt formats for the user to choose from.


RE: online time script by Chris4 on 08-12-2006 at 03:32 PM

What do you mean 'instead of seconds, minutes, hours, days'. Where is this? A different script?


RE: online time script by stuartbennett on 08-12-2006 at 05:15 PM

ok heres the script i am talking about, the attached script determines how long you have been signed in to your Windows Live messenger and display the results in your personal message. it presently displays it as

Online Time: 37 Seconds 41 Minutes 6 Hours 0 Days

however i feel that the format is too confusing i would prefer that that information had been displayed as.

Online Time: 0 Days 6 Hours 41 Minutes 37 Seconds

you could event do it like:

Online Time: 00:06:41:37

the point is a variety of variations on format would be offered and the user could make a choice on how that information is displayed to them based on their personal preference.


RE: online time script by matty on 08-12-2006 at 05:20 PM

This is Line 32 of the Online Time.js

code:
var OnlineTime = "Online Time: " + Sec + " Seconds " + Min + " Minutes " + Hrs + " Hours " + Days + " Days";

Why not just change it to what you want?
code:
var OnlineTime = "Online Time: " + Days + " Days " + Hrs + " Hours " + Min + " Minutes " +  Sec + " Seconds";

Wasn't that hard was it?

Or if you want to get fancy

code:
var OnlineTime = 'Online Time:';
if (Days > 1){
    OnlineTime += Days + ' Days';
}else if (Days == 1){
    OnlineTime += Days + ' Day';
}

if (Hrs > 1){
    OnlineTime += Hrs + ' Hours';
}else if (Hrs == 1){
    OnlineTime += Hrs + ' Hour';
}

if (Min > 1){
    OnlineTime += Min + ' Minutes';
}else if (Min == 1){
    OnlineTime += Min + ' Minute';
}

if (Secs > 1){
    OnlineTime += Secs + ' Seconds';
}else if (Secs == 1){
    OnlineTime += Secs + ' Second';
}




[edit]

Beat ya cook ;)

[/edit]
RE: online time script by CookieRevised on 08-12-2006 at 05:29 PM

1) Simply edit the script to show a different line. The script is dead easy (even for those who don't know much about programming). The only line you should change is

code:
var OnlineTime = "Online Time: " + Sec + " Seconds " + Min + " Minutes " + Hrs + " Hours " + Days + " Days";
to
code:
var OnlineTime = "Online Time: " + Days + " Days " + Hrs + " Hours " + Min + " Minutes " + Sec + " Seconds";


2) Note that the script is poorly written. I would actually not suggest to use it in its current form as it doesn't take in account singular values, doesn't take in account flood limits, constantly needs JScript to change the type of variables (string and numbers are mixed), you can't turn it off, etc, etc...


3) The script is very very highly annoying to all your contacts since it changes your personal message every second; be prepared to get banned from your contacts' contactlists when you use it.


EDIT: I need to refresh before I reply
RE: online time script by stuartbennett on 08-12-2006 at 06:31 PM

thanks i did try changing that line earlier this afternoon but for some reason it didnt work, i obvious miss typed the syntax somewhere oh well thanks for the help, so cookie or anyone how would you improve the script, maybe i can make it a little project for me to fix the script as a way to learn more about writing scripts.


RE: online time script by matty on 08-12-2006 at 07:03 PM

Myself I would do something like this:

code:
var time_counter;

function OnEvent_Signin(sEmail){ MsgPlus.AddTimer('uptime',10000); }

function OnEvent_Timer(sTimerId){
    if (sTimerId == 'uptime') {   
        time_counter = time_counter + 10;

        var days = time_counter / (24 * 3600);
        if (days > 0){ timer_counter = timer_counter - (24*3600*days); }
        var hours = timer_counter / 3600;
        if (hours > 0){ timer_counter = timer_counter - (3600*hours); }
        var minutes = timer_counter / 60;
        Messenger.MyPersonalMessage = 'Online Time: ' + days + ':' + hours + ':' + minutes;
        Debug.Trace(Messenger.MyPersonalMessage);
        MsgPlus.AddTimer(sTimerId,10000);
    }
}

Might work now I fixed a small part of the code.
RE: online time script by stuartbennett on 08-12-2006 at 07:42 PM

ok now what difference would that have exactly out of interest.


RE: online time script by matty on 08-12-2006 at 07:58 PM

quote:
Originally posted by stuartbennett
ok now what difference would that have exactly out of interest.
Less processing time because I am not comparing strings to numbers. When you compare a string to a number Javascript has to convert it internally to be able to compare it.
RE: online time script by stuartbennett on 08-12-2006 at 08:18 PM

sorry matty but they way you coded it has bropken the script and it will no longer function at all. from what i can see from testing the code the original code is the only version that works, if you can give me a working code then ill test it.


RE: online time script by matty on 08-12-2006 at 08:42 PM

quote:
Originally posted by stuartbennett
sorry matty but they way you coded it has bropken the script and it will no longer function at all. from what i can see from testing the code the original code is the only version that works, if you can give me a working code then ill test it.
I never said if it worked I said I would do it along those lines. I didn't test it before posting it.

quote:
Originally posted by Matty
Might work now I fixed a small part of the code.

RE: online time script by stuartbennett on 08-12-2006 at 09:01 PM

that didnt fix it but dont worry its not as if we are trying to write a replacement anyway right? thanks for all the help you guys have given me.