Shoutbox

Plugin manager - 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: Plugin manager (/showthread.php?tid=72322)

Plugin manager by Yorick on 03-04-2007 at 03:08 PM

Ok I need some advise on this peace of my script. I want to make a plugin manager for my script, as you might know I'm working on a last.fm script. The point is that there are a lot of different feeds available so I want to give people the choice what feeds they want.

But how should I organise this? I was thinking of the following:
[Directory]

- [Last.fm]
- - main files
- - [Plugins]
- - - [TopArtists]
- - - WndTopArtists.xml
- - - JsTopArtists.js
- - - [TopTracks]
- - - WndTopTracks.xml
- - - JsTopTracks.js

But the problem is that Messenger Plus! Live only grabs the Jscript files in the main directory. How can I make it so that it also grabs the Jscript files in my Plugins directory?

Thanks in advance!


RE: Plugin manager by Felu on 03-04-2007 at 03:11 PM

Why not just keep the js files in the main folder? Or make a js file which reads the js files in the Plugins folders and put the data in them itself. You can use FileSystemObject for it. Just ask if you need any help with it ;).


RE: Plugin manager by deAd on 03-04-2007 at 03:15 PM

The best way is just to keep them all in the same folder.


RE: Plugin manager by Yorick on 03-04-2007 at 03:16 PM

quote:
Originally posted by Felu
Why not just keep the js files in the main folder? Or make a js file which reads the js files in the Plugins folders and put the data in them itself. You can use FileSystemObject for it. Just ask if you need any help with it ;).

Ok I'll look into that! Thanks for the help, but I'll try it myself first :D! Is there maybe a script that does something similar like this? Including a other Jascript file in itself?

quote:
Originally posted by deAd
The best way is just to keep them all in the same folder.
Yes that came to my mind later, would it be handy to use some sort of a prefix so I can find them easily? Like:
Plugin_WndTopArtists.xml
Plugin_JsTopArtists.js

Or does anyone has a better idea how to do that?
RE: RE: Plugin manager by deAd on 03-04-2007 at 03:19 PM

quote:
Originally posted by Yorick
quote:
Originally posted by deAd
The best way is just to keep them all in the same folder.
Yes that came to my mind later, would it be handy to use some sort of a prefix so I can find them easily? Like:
Plugin_WndTopArtists.xml
Plugin_JsTopArtists.js
Yes, that's perfectly fine. If you look at the Screenshot Sender script or my Stickynotes script (among others) you'll see that the files are prefixed to help organize them :)

Don't do the file reading, that's a terrible method.
RE: RE: RE: Plugin manager by Yorick on 03-04-2007 at 03:35 PM

I think you're right, don't need it anymore because there all in the main directory now, I'm going to write the manager now. Thanks a lot for your advices!


RE: Plugin manager by Yorick on 03-04-2007 at 07:46 PM

Ok for anyone who's interested this is how I've done it.

Every plugins has 3 files,
- Plugin_TopArtistsInfo.xml, with some information about the plugin: name, descriptiong and id.
- Plugin_TopArtistsWnd.xml with the window(s) for the plugin.
- Plugin_TopArtistsJs.js with the Jscript functions for the plugin.

And last but not least the manager itself (currently only listing of plugins)

[Image: img3.png]


RE: Plugin manager by -dt- on 03-04-2007 at 11:36 PM

Ok heres how i do it in Now Playing

players filenames are formatted as
classname.player.js

so lets say theres a file called "winamp.player.js"

and inside it there is

code:

var winamp = function(){


}

winamp.prototype = {
"helloWorld" : function(){
Debug.Trace('hello world');
}

}



and then we run this code, which loads all files in the /players directory and stores them into the plugins object

code:
    var x;
    var plugins = {};
    var loadedPlugins = [];
    for(var enume = new Enumerator(fso.GetFolder(MsgPlus.ScriptFilesPath + "\\players").Files);!enume.atEnd();enume.moveNext()){
        if(x = new String(enume.item()).match(/([^[\\]*?)\.player\.js$/)){
            loadedPlugins.push(x[1]);
           
            try{
                eval(fso.GetFile(enume.item()).OpenAsTextStream(1, 0).ReadAll());
                plugins [x[1]] = eval(x[1]);
            }catch(e){
                    Debug.Trace("ERROR loading player " + x[1] + ": \nType: " + e['name'] + "\nMessage: " + e['message'] + "\nNumber: " + x['number'] + "\nDescription: " + x['description']);
            }
        } 
    }




and then we can just use

code:
plugins['winamp'].helloWorld();