What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » * Stat Center 1.5* [NEW] [Performance Issues Fixed]

Pages: (20): « First « 1 2 3 [ 4 ] 5 6 7 8 » Last »
1 votes - 5 average   * Stat Center 1.5* [NEW] [Performance Issues Fixed]
Author: Message:
Chestah
Veteran Member
*****

Avatar

Posts: 1658
Reputation: 34
35 / Male / –
Joined: Jun 2004
O.P. RE: [UPDATE v1.0.4] Stat Center - Contact statistics system
Announcing v1.0.4... which should fix all of the bugs everyone has been experiencing, add some small features and bring Stat Center in the loop with Yahoo! contacts!

The full change log is below:

--------------------

Version 1.0.4 (25/12/2006)

Added:

- Yahoo! Contacts support

Improved:

- Statistics center now focuses on the contact selection box on open
- Signed in contact is no longer at the top of the list and is now in the correct alphabetical order to make it easier for users to find their own statistics
- Contact drop down box in statistics has been made longer

Fixed:

- Statistics aren't shown for the currently signed in user (thanks CookieRevised)
- Loading window is loaded and shown too late and does not appear until the loading is finished
- The Auto Update feature was incorrectly setup and did not check for updates
- If the Statistics window is shown and the user clicks to show it again it does not appear
- Viewing statistics using the "view contact's statistics" option in a chat window does not update the currently selected user in the drop down list
- Clicking the "view contact's statistics" option in a chat window when the statistics window is already open does nothing
- Contacts using '{' or '}' in their names save incorrectly and cause loading errors when viewing statistics (Error fixed thanks to dt's update to PrefStore)

--------------------

Download: http://www.msgpluslive.net/scripts/view/245-Stat-Center/

This post was edited on 12-26-2006 at 01:59 AM by Chestah.
Segosa is newb.
12-25-2006 09:22 PM
Profile E-Mail PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: [UPDATE v1.0.4] Stat Center - Contact statistics system
Some stuff handling Yahoo contacts is not correctly or not needed though. eg:

code:
function signinUpdate() {
    (...)
    if(Contact.Network == 1) {
        var sprefs = new PrefStore(Contact.Email);
        sprefs.set('LastSignin', parseInt((new Date().getTime()) / 1000));
        sprefs.save();
               
        if((checkYahoo(Contact.Email, Contacts) == true) && Contacts.GetContact('yahoo:' + Contact.Email).Status != 1) {
            var sprefs = new PrefStore('$YAHOO$' + Contact.Email);
            sprefs.set('LastSignin', parseInt((new Date().getTime()) / 1000));
            sprefs.save();
        }

    } else {
    (...)

The red part isn't needed. The enumeration will already return all contacts, yahoo and msn ones, no matter if they have the same email or not.

You only need to check upon same contact emails if you get the email from a variable or whatever which does not differentiate between yahoo and msn contacts and need to get the contact using GetContact().

Using the enumaration or getting the email from a contact event will always either return all contacts, or return a prefixed email.

Which means that whole function can be reduced to:
code:
function signinUpdate() {
    //Current User
    myprefs.set('LastSignin', parseInt((new Date().getTime()) / 1000));
   
    //Other Users
    for(var e = new Enumerator(Messenger.MyContacts); !e.atEnd(); e.moveNext()) {
        var Contact = e.item();
        if(Contact.Status !== 1 && (Contact.Email !== Messenger.MyEmail || Contact.Network === 2)) {
            var sprefs = new PrefStore((Contact.Network === 2 ? '$YAHOO$' : '') + Contact.Email);
            sprefs.set('LastSignin', parseInt((new Date().getTime()) / 1000));
            sprefs.save();
        }
    }
}
same stuff in OnEvent_Signout(), OnEvent_SigninReady and OnEvent_ChatWndCreated(), OnEvent_ChatWndContactAdded(), OnEvent_ChatWndReceiveMessage(), and maybe other places...



-------------------------------------------------------------

Some other stuff:


* PrefStore.js
- is responsible for the slowness of everything
- do not store email addresses as files if you don't must! use the MSN ID instead for this.


* OnEvent_Signout()
code:
if (Stat_Wnd != null) {
    Stat_Wnd.Close(1);
    Stat_Wnd = null;
}
Since you close the window and in the OnWndStatsEvent_Destroyed function you already set Stat_Wnd to null, you don't need it here. So this can be either:
    if (Stat_Wnd !== null) Stat_Wnd.Close(1);
or
    try{Stat_Wnd.Close(1)}catch( e){}


* OnEvent_ContactSignin()
You perform some same action in the if then else... so you can move to outside and after the if then else. And then you could do with only one replace function instead of the if then else too. And you don't need to change the email to perform action A, and then change it back to what it was to perform action B. Making that whole function just:
code:
function OnEvent_ContactSignin(Email) {
    var sprefs = new PrefStore(Email.replace("yahoo:", "$YAHOO$"));
    Pref_Increase(sprefs, 'Signin');
    sprefs.set('LastSignin', parseInt((new Date().getTime()) / 1000));
    Pref_Increase(sprefs, ('Status_' + Messenger.MyContacts.GetContact(Email).Status));
    Pref_Array(sprefs, 'DisplayNames', Format(Messenger.MyContacts.GetContact(Email).Name));
    Pref_Array(sprefs, 'PsmNames', Format(Messenger.MyContacts.GetContact(Email).PersonalMessage));
    sprefs.save();
}
same in OnEvent_ContactSignout() and maybe other places...


* OnEvent_MyStatusChange() can be reduced to only 1 line:
Pref_Increase(myprefs, "Status_" + NewStatus);
just like you did in OnEvent_ContactStatusChange (though you don't really need the parenthesis)


* OnEvent_SigninReady()
change
    if((Contact.Status != 1)
to
    if((Contact.Status > 1)
since Contact.Status may return 0 too.


* OnEvent_MyMediaChange()
change
    if((NewMedia != '') && (NewMedia != 'undefined') && (NewMedia != undefined))
to
    if(NewMedia !== '')
This goes in general to check upon a valid variable string. But in this particular function you don't even need to consider undefined since Plus! will always return a defined string anyways. Same for OnEvent_ContactMediaChange.


* OnEvent_ContactBlocked()
Yahoo contacts are stored with their email (without prefix) in the same ContactsBlocked counter as msn contacts, is this supposed to do that? A Yahoo mail is a different contact than a MSN contact (with the same email), so...


* OnEvent_ChatWndCreated() can be reduced to just:
code:
function OnEvent_ChatWndCreated(ChatWnd) {
    var i = ChatWnd.Contacts.Count;
    for(var e = new Enumerator(ChatWnd.Contacts); !e.atEnd(); e.moveNext()) {
        var Contact = e.item();
        var sprefs = new PrefStore((Contact.Network === 2 ? '$YAHOO$' : '') + Contact.Email);
        Pref_Increase(sprefs, "Conversations");
        if (i > 1) {
            Pref_Increase(sprefs, "GroupConversations");
        }
        sprefs.save();
    }
    Pref_Increase(myprefs, 'TotalConversations');
}
The same thing (use of ChatWnd.Contacts.Count) goes for OnEvent_ChatWndContactAdded.


* OnEvent_ChatWndReceiveMessage
code:
//Words Received - TOTAL and per-contact
Pref_IncreaseBy(myprefs, "TotalWordsReceived", Message.split(" ").length);
Splitting by a space does not give a proper word count at all. eg: multiple spaces can be used, other bounderies as a space character can be used, etc... To count words in a line you must use a regular expression:
code:
//Words Received - TOTAL and per-contact
var Words = --('A ' + Message).match(/\w+/g).length;
Pref_IncreaseBy(myprefs, "TotalWordsReceived", Words);
Pref_IncreaseBy(sprefs, "WordsReceived", Words);
note that I put 'A ' in front of the message so that the array will never be null, but of course because this counts as a word you do length-1 (is the --)
(same issue in OnEvent_ChatWndSendMessage)



In every switch case statement, you have:
    var sprefs = new PrefStore(Email);
So bring this in front of the switch, and change it too:
    var sprefs = new PrefStore(Email.replace('yahoo:', '$YAHOO$'));
so you don't need:
    if(Contact.Network == 2) {
        Debug.Trace("[External] The Message has been received from a Yahoo! contact");
        Email = "$YAHOO$" + Email;
    }

And remove every
    sprefs.save();
and put it after the switch.



All this also makes that you can put case 6 in front of case 1, but without a break since it mostly requires the same actions:
code:
case 6:               
    //OFFLINE MESSAGE STATISTICS               
    Pref_Increase(myprefs, "TotalOfflineMessagesReceived");
    Pref_Increase(sprefs, "OfflineMessagesReceived");
    //NORMAL CASE 1 STATISTICS FOLLOW
case 1:
    //Total messages Received
    (...)
    break;



code:
for(i=0; i < otherContacts.length; i++) {
    if(Contacts.GetContact(otherContacts[ i]).Network == 1) {
        (....)
        if(checkYahoo(otherContacts[ i], Contacts) == true) {
        }
    } else {
        (....)
    }
}
All this isn't needed and will actually produce wrong results. Not only do the things apply in the first section of this post, the emails in array otherContacts come from an enumeration and thus already contain the proper yahoo prefix in case of a yahoo contact. Which makes that all those checks can be reduced to simply:
code:
for (var i in otherContacts) {
    var sprefs = new PrefStore(otherContacts[ i].replace('yahoo:', '$YAHOO$'));
    Pref_Increase(sprefs, "WinksSent");
    sprefs.save();
}



* OnEvent_ChatWndSendMessage()
change
    if (Message == "/showstats")
to
    if (Message.toLowerCase() === "/showstats")
or even better:
    if (/^\/showstats(?:\s+[\s\S]*|$)/i.exec(Message) !== null)
which also will result in true if the user has added some parameters



Shouldn't this:
    Load_Contact(Contact.Email);
be:
    Load_Contact((Contact.Network === 2 ? '$YAHOO$' : '') + Contact.Email);
? And same issue with:
    Load_WndStats(Contact.Email);
This has further implications for the actual Load_Contact(), Load_WndStats() and possible other similar functions (I've not checked WndStats.js yet).



And this also means that Combo_Contacts[i] === Contact.Email in:
code:
for(var i in Combo_Contacts) {
    if (Combo_Contacts[i] === Contact.Email) {
        Stat_Wnd.Combo_SetCurSel('cboContact', i);
        break;
    }
}
isn't yahoo compatible, since you don't check upon the network



Change:
    Interop.Call('User32', 'BringWindowToTop', Stat_Wnd.Handle);
    Interop.Call('User32', 'ShowWindow', Stat_Wnd.Handle, 1);
to
    Interop.Call('User32', 'SetForegroundWindow', Stat_Wnd.Handle);




* in general, thus in some places, you use:
    if(cContact.Email !== Messenger.MyEmail)
to check if the email isn't the user's email. This should be:
    if(cContact.Email !== Messenger.MyEmail || cContact.Network === 2)
because a Yahoo contact can have the same email address as the user's email, yet is a valid contact and not the user.


* function OnEvent_MessengerLocked()
Messenger.MyEmail isn't always defined when this event is called (eg: one can lock messenger without being singed in)




I didn't checked everything in detail and not all files, so there might be more things like all this in other places. But this is already a lot to fix though, I think  ;)

This post was edited on 12-30-2006 at 01:32 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
12-29-2006 07:46 PM
Profile PM Find Quote Report
Nathan
Veteran Member
*****

Avatar
Yeah, "large dimensions" ;)

Posts: 2984
Reputation: 76
– / Male / Flag
Joined: Apr 2005
RE: [UPDATE v1.0.4] Stat Center - Contact statistics system
I've got a request
- i'd like to be addded in the bout box with this one though as its quite a good on :refuck:

Ok:
If you have chat logs you can order it by size so you could have a feature which is like this:
Most talked to contact this month: email@gmail.com
etc..
Hope you like the idea (y)
Touch Innovation - touch friendly programs/applications for the windows mobile!


12-29-2006 07:53 PM
Profile E-Mail PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: RE: [UPDATE v1.0.4] Stat Center - Contact statistics system
quote:
Originally posted by Nathan
If you have chat logs you can order it by size so you could have a feature which is like this:
Most talked to contact this month: email@gmail.com
etc..
I wouldn't called it "most talked" because size doesn't say everything... I can paste some big text (eg: code) to someone in a few lines, yet talk to another one for a day and still not surpassing the size of the log of the first contact.

It would just be "largest sized log", not "most talked to"...

;)
.-= A 'frrrrrrrituurrr' for Wacky =-.
12-29-2006 07:59 PM
Profile PM Find Quote Report
Nathan
Veteran Member
*****

Avatar
Yeah, "large dimensions" ;)

Posts: 2984
Reputation: 76
– / Male / Flag
Joined: Apr 2005
RE: [UPDATE v1.0.4] Stat Center - Contact statistics system
Yeah like we talked about on wlm :P
Touch Innovation - touch friendly programs/applications for the windows mobile!


12-29-2006 08:06 PM
Profile E-Mail PM Web Find Quote Report
Jimbo
Veteran Member
*****

Avatar

Posts: 1650
Reputation: 18
31 / Male / Flag
Joined: Jul 2006
RE: [UPDATE v1.0.4] Stat Center - Contact statistics system
Request

When you right click on any contact, it has an option that says "View statistics" or something like that.
12-29-2006 08:43 PM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: [UPDATE v1.0.4] Stat Center - Contact statistics system
quote:
Originally posted by Jimbodude
Request
When you right click on any contact, it has an option that says "View statistics" or something like that.
Plus! does not provide a way to add something to the right click context menu in the contactlist window.
.-= A 'frrrrrrrituurrr' for Wacky =-.
12-29-2006 09:05 PM
Profile PM Find Quote Report
Chestah
Veteran Member
*****

Avatar

Posts: 1658
Reputation: 34
35 / Male / –
Joined: Jun 2004
O.P. RE: [UPDATE v1.0.4] Stat Center - Contact statistics system
Thanks for that indepth post Cookie :) - i suspected as much that Yahoo! support wouldn't be 'flawless'/optimised in my first implementation.

I'll look into your suggestions straight away - its always good to have another developer look at your code to find those errors that the main developer has overlooked or simply are not aware of other ways - so thankyou :).

quote:
Originally posted by Jimbodude
Request

When you right click on any contact, it has an option that says "View statistics" or something like that.

Cookie is completely correct - Plus! has no API or method to allow me to easily do this. It would be a great feature though and a suggestion for the Plus! scripting system.
Segosa is newb.
12-29-2006 11:53 PM
Profile E-Mail PM Web Find Quote Report
MattyRid
Veteran Member
*****

Avatar
Red Bull Racing Australia

Posts: 1321
Reputation: 21
– / Male / Flag
Joined: Jan 2006
Status: Away
RE: [UPDATE v1.0.4] Stat Center - Contact statistics system
Chestah....not trying to be so mean or degrading of your script, which I think has been a brilliant idea, but I still don't seem to have the received stats working for any of my contacts. It still seems to do the same thing as the screenshot I posted earlier in the thread. Just maybe checking if it might be something I did wrong in the updating of your script or it might be a problem with the script or something? (You know what I mean :P)

Note: It's for other contacts, not my own

This post was edited on 12-30-2006 at 12:14 AM by MattyRid.
Red Bull Racing Australia - Triple Eight Race Engineering - Holden
12-30-2006 12:14 AM
Profile PM Find Quote Report
Chestah
Veteran Member
*****

Avatar

Posts: 1658
Reputation: 34
35 / Male / –
Joined: Jun 2004
O.P. RE: [UPDATE v1.0.4] Stat Center - Contact statistics system
quote:
Originally posted by MattyRid
Chestah....not trying to be so mean or degrading of your script, which I think has been a brilliant idea, but I still don't seem to have the received stats working for any of my contacts. It still seems to do the same thing as the screenshot I posted earlier in the thread. Just maybe checking if it might be something I did wrong in the updating of your script or it might be a problem with the script or something? (You know what I mean :P)

Note: It's for other contacts, not my own


No its fine :). I had a look before i released 1.0.4 and couldn't see anything wrong. I'll have another look at it today and see if i can fix it, if i can't see anything that could be causing a problem would it be okay if i could get your WLM and we can work through this together?
Segosa is newb.
12-30-2006 12:20 AM
Profile E-Mail PM Web Find Quote Report
Pages: (20): « First « 1 2 3 [ 4 ] 5 6 7 8 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On