[request] Last status timer - 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: [request] Last status timer (/showthread.php?tid=75981)
[request] Last status timer by gdumitresco on 07-09-2007 at 06:02 PM
Hi
I saw on Mirand IM when you change your status, it will change your personal status message as you define and show how much time you've been on that status, i.e.: I became away/busy and my personal status message becomes like this "I'm away since 2:12pm" or "I'm busy since 11:23am".
I tried starting on my own, but for programmer, I'm good singer. If you catch my drift.
Is it easy to be done?
RE: [request] Last status timer by matty on 07-09-2007 at 07:03 PM
quote: Originally posted by gdumitresco
Hi
I saw on Mirand IM when you change your status, it will change your personal status message as you define and show how much time you've been on that status, i.e.: I became away/busy and my personal status message becomes like this "I'm away since 2:12pm" or "I'm busy since 11:23am".
I tried starting on my own, but for programmer, I'm good singer. If you catch my drift.
Is it easy to be done?
Sure is easy
code: function OnEvent_MyStatusChange(nNewStatus) {
Messenger.MyPersonalMessage = 'I changed my status : '+new Date();
}
Now that is going to print out a really long personal message.
When you use new Date() that way the resulting string is something like this
quote: Mon Jul 09 2007 15:06:39 GMT-0400 (Eastern Daylight Time)
RE: [request] Last status timer by gdumitresco on 07-09-2007 at 07:17 PM
quite easy! but there is a function which brings the current status name?
oh! thanks!
PS.: hmmm I'm trying but I realized it's not my speciality... definitely.
I wonder if anyone could develop something as this:
"A script which will "sense" the last status, and will be able to tell the last time you left it on that status, with possibility of customization for each status (like i.e. online status may show it or not) with custom messages and variables for you to put the time anywhere in the psm."
I dunno if my english left it clear... but I'm crossing my fingers hoping some programmer like the idea
RE: [request] Last status timer by gdumitresco on 07-12-2007 at 07:34 PM
Hi... looking into some scripts and fighting the lazy side of me, I tried to do this:
code: var PreviousToTimerPSM
function OnEvent_Initialize(MessengerStart)
{
}
function OnEvent_Signin(Email)
{
Messenger.MyPersonalMessage = PreviousToTimerPSM; //stores the previous PSM while signing in
}
function OnEvent_Signout(Email)
{
PreviousToTimerPS = Messenger.MyPersonalMessage; //retrieves the previous PSM while signing in?
}
function OnEvent_Uninitialize(MessengerExit)
{
Messenger.MyPersonalMessage = PreviousToTimerPSM;
}
function OnEvent_MyStatusChange(NewStatus)
{
if( NewStatus == 3 )
{
Messenger.MyPersonalMessage = PreviousToTimerPSM; //if it's online, no need to count.
}
else if( NewStatus == 6 )
{
Messenger.MyPersonalMessage = "Estou ausente desde "+GetHours()+":"+GetMinutes();
}
else if( NewStatus == 4 )
{
Messenger.MyPersonalMessage = "Estou ocupado desde "+GetHours()+":"+GetMinutes();
}
else if( NewStatus == 5 )
{
Messenger.MyPersonalMessage = "Saí às "+GetHours()+":"+GetMinutes()+" mas volto logo!";
}
else if( NewStatus == 7 )
{
Messenger.MyPersonalMessage = "Estou ausente desde "+GetHours()+":"+GetMinutes();
}
else if( NewStatus == 8 )
{
Messenger.MyPersonalMessage = "Estou em uma ligação desde "+GetHours()+":"+GetMinutes();
}
else if( NewStatus == 9 )
{
Messenger.MyPersonalMessage = "Estou almoçando desde "+GetHours()+":"+GetMinutes();
}
}
could someone help checking errors or giving ideas? I can't test it from the job
thanks
RE: [request] Last status timer by matty on 07-12-2007 at 08:33 PM
All I did was clean the code up so far, it looks like it should work.
Found an error just as I posted, GetHours() and GetMinutes() are functions of the Date() object in Javascript, you have to declare it before you can use it, hence the var mDate = new Date();
Also you cannot assign the PSM OnEvent_Signin as that is when the user is signing in, it would have to be OnEvent_SigninReady however once you signout the script is stopped until you sign back in so you will loose any variables that have been set.
code: var PreviousToTimerPSM;
var mDate = new Date();
function OnEvent_Signout(Email) {
Messenger.MyPersonalMessage = PreviousToTimerPSM; //restores the original PSM while signing out?
}
function OnEvent_SigninReady(Email) {
PreviousToTimerPSM = Messenger.MyPersonalMessage; //retrieves the previous PSM once the user is signed in?
}
function OnEvent_MyStatusChange(NewStatus) {
if( NewStatus == 3 ) {
Messenger.MyPersonalMessage = PreviousToTimerPSM; //if it's online, no need to count.
} else if( NewStatus == 6 ) {
Messenger.MyPersonalMessage = "Estou ausente desde "+mDate.GetHours()+":"+mDate.GetMinutes();
} else if( NewStatus == 4 ) {
Messenger.MyPersonalMessage = "Estou ocupado desde "+mDate.GetHours()+":"+mDate.GetMinutes();
} else if( NewStatus == 5 ) {
Messenger.MyPersonalMessage = "Saí às "+mDate.GetHours()+":"+mDate.GetMinutes()+" mas volto logo!";
} else if( NewStatus == 7 ) {
Messenger.MyPersonalMessage = "Estou ausente desde "+mDate.GetHours()+":"+mDate.GetMinutes();
} else if( NewStatus == 8 ) {
Messenger.MyPersonalMessage = "Estou em uma ligação desde "+mDate.GetHours()+":"+mDate.GetMinutes();
} else if( NewStatus == 9 ) {
Messenger.MyPersonalMessage = "Estou almoçando desde "+mDate.GetHours()+":"+mDate.GetMinutes();
}
}
RE: [request] Last status timer by pollolibredegrasa on 07-12-2007 at 08:39 PM
Also, you've missed out an M in the signout event
code: function OnEvent_Signout(Email) {
PreviousToTimerPSM = Messenger.MyPersonalMessage; //retrieves the previous PSM while signing in?
}
RE: [request] Last status timer by gdumitresco on 07-12-2007 at 11:24 PM
Hi, I tried... but it brought me the following errors with debug:
code: Function called: OnEvent_MyStatusChange
Error: O objeto não dá suporte para a propriedade ou método (code: -2146827850)
File: Last status timer.js. Line: 18.
Function OnEvent_MyStatusChange returned an error. Code: -2147352567
Function called: OnEvent_MyStatusChange
Error: O objeto não dá suporte para a propriedade ou método (code: -2146827850)
File: Last status timer.js. Line: 20.
Function OnEvent_MyStatusChange returned an error. Code: -2147352567
Function called: OnEvent_MyStatusChange
Function called: OnEvent_MyStatusChange
Error: O objeto não dá suporte para a propriedade ou método (code: -2146827850)
File: Last status timer.js. Line: 26.
Function OnEvent_MyStatusChange returned an error. Code: -2147352567
Function called: OnEvent_MyStatusChange
When I tried to change status... the only one without bugs was the "online" status
RE: [request] Last status timer by matty on 07-12-2007 at 11:52 PM
Change the declaration line to
code: var PreviousToTimerPSM = '';
RE: [request] Last status timer by gdumitresco on 07-12-2007 at 11:57 PM
Before I follow, thanks for the help Matty!
the debug has changed, a bit:
code: Script sendo carregado
Script ativado e pronto
Função denominada: OnEvent_SigninReady
Função denominada: OnEvent_MyStatusChange
Erro: O objeto não dá suporte para a propriedade ou método (código: -2146827850)
Arquivo: Last status timer.js. Linha: 18.
A função OnEvent_MyStatusChange resultou em erro. Código: -2147352567
Função denominada: OnEvent_MyStatusChange
Erro: O objeto não dá suporte para a propriedade ou método (código: -2146827850)
Arquivo: Last status timer.js. Linha: 24.
A função OnEvent_MyStatusChange resultou em erro. Código: -2147352567
I tried to change the error messages to english, but no luck! If you need me to translate them, I'll do it!
RE: [request] Last status timer by matty on 07-13-2007 at 12:07 AM
I can't believe I missed it
code: var PreviousToTimerPSM;
var mDate = new Date();
function OnEvent_Signout(Email) {
Messenger.MyPersonalMessage = PreviousToTimerPSM; //restores the original PSM while signing out?
}
function OnEvent_SigninReady(Email) {
PreviousToTimerPSM = Messenger.MyPersonalMessage; //retrieves the previous PSM once the user is signed in?
}
function OnEvent_MyStatusChange(NewStatus) {
if( NewStatus == 3 ) {
Messenger.MyPersonalMessage = PreviousToTimerPSM; //if it's online, no need to count.
} else if( NewStatus == 6 ) {
Messenger.MyPersonalMessage = "Estou ausente desde "+mDate.getHours()+":"+mDate.getMinutes();
} else if( NewStatus == 4 ) {
Messenger.MyPersonalMessage = "Estou ocupado desde "+mDate.getHours()+":"+mDate.getMinutes();
} else if( NewStatus == 5 ) {
Messenger.MyPersonalMessage = "Saí às "+mDate.getHours()+":"+mDate.getMinutes()+" mas volto logo!";
} else if( NewStatus == 7 ) {
Messenger.MyPersonalMessage = "Estou ausente desde "+mDate.getHours()+":"+mDate.getMinutes();
} else if( NewStatus == 8 ) {
Messenger.MyPersonalMessage = "Estou em uma ligação desde "+mDate.getHours()+":"+mDate.getMinutes();
} else if( NewStatus == 9 ) {
Messenger.MyPersonalMessage = "Estou almoçando desde "+mDate.getHours()+":"+mDate.getMinutes();
}
}
It is getHours() and getMinutes().
RE: [request] Last status timer by gdumitresco on 07-13-2007 at 12:27 AM
Hey Matty! Works like a charm!
I didn't tested about retrieving the previous PSM, but it's working FINE!!!! Well done!!! Many thanks!
RE: [request] Last status timer by CookieRevised on 07-13-2007 at 09:05 AM
Now change the many IF THEN ELSE's to a SWITCH statement to optimize it further.
RE: [request] Last status timer by gdumitresco on 07-13-2007 at 01:09 PM
hmmm do you have the syntax for switch?
I made few changes about handling the PSM... if you have any ideas how to improve it...
code: var PreviousToTimerPSM;
var mDate = new Date();
function OnEvent_Signout(Email) {
Messenger.MyPersonalMessage = PreviousToTimerPSM; //restores the original PSM while signing
out?
}
function OnEvent_SigninReady(Email) {
Messenger.MyPersonalMessage = ""; //retrieves the previous PSM once the user is signed in?
}
function OnEvent_MyStatusChange(NewStatus) {
if( NewStatus == 3 ) {
Messenger.MyPersonalMessage = ""; //if it's online, no need to count.
} else if( NewStatus == 6 ) {
Messenger.MyPersonalMessage = "";
Messenger.MyPersonalMessage = "Estou ausente desde
"+mDate.getHours()+":"+mDate.getMinutes();
} else if( NewStatus == 4 ) {
Messenger.MyPersonalMessage = "";
Messenger.MyPersonalMessage = "Estou ocupado desde
"+mDate.getHours()+":"+mDate.getMinutes();
} else if( NewStatus == 5 ) {
Messenger.MyPersonalMessage = "";
Messenger.MyPersonalMessage = "Saí às "+mDate.getHours()+":"+mDate.getMinutes()+" mas
volto logo!";
} else if( NewStatus == 7 ) {
Messenger.MyPersonalMessage = "";
Messenger.MyPersonalMessage = "Estou ausente desde
"+mDate.getHours()+":"+mDate.getMinutes();
} else if( NewStatus == 8 ) {
Messenger.MyPersonalMessage = "";
Messenger.MyPersonalMessage = "Estou em uma ligação desde
"+mDate.getHours()+":"+mDate.getMinutes();
} else if( NewStatus == 9 ) {
Messenger.MyPersonalMessage = "";
Messenger.MyPersonalMessage = "Estou almoçando desde
"+mDate.getHours()+":"+mDate.getMinutes();
}
}
RE: [request] Last status timer by matty on 07-13-2007 at 01:37 PM
Blah why are you setting the personal message to a blank string then changing it to the PSM that makes no sense...
Look at this: http://www.w3schools.com/js/js_switch.asp
RE: [request] Last status timer by gdumitresco on 07-13-2007 at 01:39 PM
I'm leaving the idea in "blank" until I find out how to work with it...
thanks for the link! ok... call me lazy or whatever, but everytime I start programming I get lazy. LOL, I rather other challenges than knocking my head over the monitor while debugging.
Anyway, it is functional, but with some notes:
1- I removed the retrieval of the original PSM, it would require to store in registry or maybe in a .ini file the preferences for each user, I'm not in the mood of improving it right now, but if anyone knows how to make it, feel free, you'll be my guest and I'll be very thankful as many other users who may enjoy the idea.
2- I found a bug, a silly one, no idea how to fix it, but if minutes starts with zero, the time will be shown as this "12:7", instead of "12:07". Any ideas? I hope it won't need to insert the a.m. or p.m. thing, not used around here.
3- the PSM are in brazilian portuguese, feel free to translate to your language, it would help to spread the idea.
4- Optmizing with the switch statement would require to make my lazy programming cell brains to work again... I would have to study Jscript... oh boy... I'll leave this job to you who love programing.
5- Many thanks to Matty! (I don't have enough reputation to give you more...)
code: var mDate = new Date();
function OnEvent_MyStatusChange(NewStatus) {
if( NewStatus == 3 )
{
Messenger.MyPersonalMessage = ""; //if it's online, no need to change.
}
else if( NewStatus == 6 ) //idle status
{
Messenger.MyPersonalMessage = "";
Messenger.MyPersonalMessage = "Estou ausente desde "+mDate.getHours()+":"+mDate.getMinutes();
}
else if( NewStatus == 4 ) //busy status
{
Messenger.MyPersonalMessage = "";
Messenger.MyPersonalMessage = "Estou ocupado desde "+mDate.getHours()+":"+mDate.getMinutes();
}
else if( NewStatus == 5 ) //brb status
{
Messenger.MyPersonalMessage = "";
Messenger.MyPersonalMessage = "Saí às "+mDate.getHours()+":"+mDate.getMinutes()+" mas volto logo!";
}
else if( NewStatus == 7 ) //away status
{
Messenger.MyPersonalMessage = "";
Messenger.MyPersonalMessage = "Estou ausente desde "+mDate.getHours()+":"+mDate.getMinutes();
}
else if( NewStatus == 8 ) //on a call status
{
Messenger.MyPersonalMessage = "";
Messenger.MyPersonalMessage = "Estou em uma ligação desde "+mDate.getHours()+":"+mDate.getMinutes();
}
else if( NewStatus == 9 ) //out for lunch status
{
Messenger.MyPersonalMessage = "";
Messenger.MyPersonalMessage = "Estou almoçando desde "+mDate.getHours()+":"+mDate.getMinutes();
}
}
RE: [request] Last status timer by Deco on 07-13-2007 at 03:31 PM
Here's with the switch:
code:
var PreviousToTimerPSM;
var mDate = new Date();
function OnEvent_Signout(Email) {
Messenger.MyPersonalMessage = PreviousToTimerPSM; //restores the original PSM while signing out?
}
function OnEvent_SigninReady(Email) {
PreviousToTimerPSM = Messenger.MyPersonalMessage; //retrieves the previous PSM once the user is signed in?
}
function OnEvent_MyStatusChange(NewStatus) {
switch(NewStatus) {
case 3:
Messenger.MyPersonalMessage = PreviousToTimerPSM; //if it's online, no need to count.
break;
case 4:
Messenger.MyPersonalMessage = "Estou ocupado desde "+mDate.getHours()+":"+mDate.getMinutes();
break;
case 5:
Messenger.MyPersonalMessage = "Saí às "+mDate.getHours()+":"+mDate.getMinutes()+" mas volto logo!";
break;
case 6:
Messenger.MyPersonalMessage = "Estou ausente desde "+mDate.getHours()+":"+mDate.getMinutes();
break;
case 7:
Messenger.MyPersonalMessage = "Estou ausente desde "+mDate.getHours()+":"+mDate.getMinutes();
break;
case 8:
Messenger.MyPersonalMessage = "Estou em uma ligação desde "+mDate.getHours()+":"+mDate.getMinutes();
break;
case 9:
Messenger.MyPersonalMessage = "Estou almoçando desde "+mDate.getHours()+":"+mDate.getMinutes();
break;
}
}
Have fun!
RE: [request] Last status timer by matty on 07-13-2007 at 08:03 PM
code: var oPersonalMessage = new String('');
function OnEvent_Signout(Email) {
Messenger.MyPersonalMessage = oPersonalMessage; //restores the original PSM while signing out?
}
function OnEvent_SigninReady(Email) {
oPersonalMessage = Messenger.MyPersonalMessage; //retrieves the previous PSM once the user is signed in?
}
function GetTime() {
var mDate = new Date();
return mDate.getHours()+':'+(mDate.getMinutes() < 10 ? '0':'')+mDate.getMinutes();
}
function OnEvent_MyStatusChange(nNewStatus) {
switch (nNewStatus) {
case 3: Messenger.MyPersonalMessage = oPersonalMessage;
case 6: Messenger.MyPersonalMessage = "Estou ausente desde "+GetTime();
case 4: Messenger.MyPersonalMessage = "Estou ocupado desde "+GetTime();
case 5: Messenger.MyPersonalMessage = "Saí às "+GetTime()+" mas volto logo!";
case 7: Messenger.MyPersonalMessage = "Estou ausente desde "+GetTime();
case 8: Messenger.MyPersonalMessage = "Estou em uma ligação desde "+GetTime();
case 9: Messenger.MyPersonalMessage = "Estou almoçando desde "+GetTime();
}
}
RE: [request] Last status timer by gdumitresco on 07-13-2007 at 08:31 PM
Guys, I'm straight, but I'm starting to love you!
RE: [request] Last status timer by matty on 07-13-2007 at 08:45 PM
quote: Originally posted by gdumitresco
Guys, I'm straight, but I'm starting to love you!
There I updated it, you don't need to store the PSM in the registry, just store it when they sign in, and reset it when they sign out simple as that.
RE: [request] Last status timer by gdumitresco on 07-14-2007 at 01:52 PM
Guys, I'm going to test the "else if" method back, the switch method it's no bringing the right status PSM, even online it brings the wrong message... strange! Does it need the "break" stuff?
RE: [request] Last status timer by CookieRevised on 07-14-2007 at 02:19 PM
quote: Originally posted by gdumitresco
Guys, I'm going to test the "else if" method back, the switch method it's no bringing the right status PSM, even online it brings the wrong message... strange! Does it need the "break" stuff?
Yes, it needs the break stuff. The SWITCH statement is a lot more effecient and shorter than a whole bunch of IF THEN ELSEs.
code: function OnEvent_MyStatusChange(nNewStatus) {
switch (nNewStatus) {
case 3: Messenger.MyPersonalMessage = oPersonalMessage; break;
case 6: Messenger.MyPersonalMessage = "Estou ausente desde "+GetTime(); break;
case 4: Messenger.MyPersonalMessage = "Estou ocupado desde "+GetTime(); break;
case 5: Messenger.MyPersonalMessage = "Saí às "+GetTime()+" mas volto logo!"; break;
case 7: Messenger.MyPersonalMessage = "Estou ausente desde "+GetTime(); break;
case 8: Messenger.MyPersonalMessage = "Estou em uma ligação desde "+GetTime(); break;
case 9: Messenger.MyPersonalMessage = "Estou almoçando desde "+GetTime(); break;
}
}
|