Spider Monkey Panel
All SMP panels are defined with JavaScript, which is:
- Implemented via Mozilla SpiderMonkey engine (ESR68).
- Conformant with ECMAScript 2019 (with the exception of modules and some RegExp features).
- Has built-in ActiveX support (so
Microsoft.XMLHTTP
can be used for network access). - Has various extensions for managing foobar2000 and interacting with WinAPI.
- Has no built-in web browser-specific objects: e.g. XMLHttpRequest, Web Workers API and etc.
Table of Contents
API description
Handling foobar2000 events
Foobar2000 and panel events are translated to callback invocations (see callbacks section for the full list), for example:
new track being played
event from fb2k will invoke on_playback_new_track(new_track_handle) function from user script, if such function was defined.panel's size has changed
> on_size(width, height);mouse moved
> on_mouse_move(x, y, mask)
Note: for performance reasons it's advised to define only those callbacks that you actually need.
Controlling foobar2000 and accessing WinAPI
SMP provides a lot of JavaScript extensions to simplify the work with foobar2000, which are divided in the following namespaces:
fb
: functions for controlling foobar2000 and accessing it's data.gdi
: functions for working with graphics. Most of them are wrappers for Gdi and GdiPlus methods.plman
: functions for managing foobar2000 playlists.console
: has only one methodlog
, which is used for logging messages to foobar2000 console.utils
: various utility functions.window
: functions for working with the current SMP panel and accessing it's properties.
Web and file-system access
Built-in ActiveX
support further expands the range of available features and allows for easy file-system and web access:
Microsoft.XMLHTTP
: this object can be used in place ofXMLHttpRequest
for web access.FileSystemObject
: used for file-system access (see MSDN documentation).
Example:
var xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
Samples
SMP includes some samples which demonstrate it's API usage (see samples sub-folder of your foo_spider_monkey_panel
installation):
- samples/basic: basic short examples.
- samples/complete: feature complete and feature rich samples created by marc2003.
See samples/readme.md for more info.
Links
Homepage
Support thread
Changelog
Detailed list of API Changes
Credits
- marc2003: original foo_jscript_panel, sample scripts and multiple contributions to this project.
- T.P. Wang: original WSH Panel Mod.
- #jsapi IRC channel: wouldn't make it through without them, love you guys!
Especially huge thanks to sfink and jonco, who spent literally tens of hours helping me! - Respective authors of the code being used in this project.