HydrogenAudio

Hosted Forums => foobar2000 => 3rd Party Plugins - (fb2k) => Topic started by: TheQwertiest on 2018-10-01 11:01:15

Title: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2018-10-01 11:01:15
Spider Monkey Panel     (https://img.shields.io/github/release/theqwertiest/foo_spider_monkey_panel.svg) (https://github.com/TheQwertiest/foo_spider_monkey_panel/blob/master/CHANGELOG.md) (https://ci.appveyor.com/api/projects/status/4fg787ijr73u7mxc/branch/master?svg=true) (https://ci.appveyor.com/project/TheQwertiest/foo-spider-monkey-panel/branch/master)

fb2k component that allows for creation of full-fledged CUI/DUI panels using JavaScript! 

Base functionality includes:
 - Graphics functions: drawing (text, images, lines, rectangles and etc), image modification (resize, blur, inversion of colours and etc).
 - Access to font and colour settings from CUI/DUI preferences.
 - Capture of foobar2000 events with callbacks.
 - Capture of keystrokes and mouse movement/clicks.
 - Execution of main menu and context menu commands.
 - Creation of custom buttons and menus.
 - Playlist management: create, destroy, sort, change, rename and do anything that fb2k can do.
 - Media Library access with ability to sort and filter it's content.
 - File tag management.
 - Per panel settings storage.
 - Built-in web and filesystem functionality.
 - foo_acfu (https://acfu.3dyd.com) integration.
 - And more!

Getting started!
 - Use Installation Guide (https://theqwertiest.github.io/foo_spider_monkey_panel/docs/installation).
 - Check out Samples and User scripts (https://theqwertiest.github.io/foo_spider_monkey_panel/docs/script_showcase).
 - Take a look at Documentation (https://theqwertiest.github.io/foo_spider_monkey_panel/docs/script_documentation), if you are craving for more!

Information for JScript Panel users
Spoiler (click to show/hide)

Links
 - Download link (https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/latest)
 - Homepage (https://theqwertiest.github.io/foo_spider_monkey_panel)
 - Changelog (https://github.com/TheQwertiest/foo_spider_monkey_panel/blob/master/CHANGELOG.md)
 - Detailed list of API Changes (https://theqwertiest.github.io/foo_spider_monkey_panel/docs/script_documentation/api_changes)
 - Current tasks and plans (https://github.com/TheQwertiest/foo_spider_monkey_panel/projects/1)
 - Dev build (https://ci.appveyor.com/api/projects/theqwertiest/foo-spider-monkey-panel/artifacts/_result%2FWin32_Release%2Ffoo_spider_monkey_panel.fb2k-component?branch=master&pr=false&job=Configuration%3A%20Release)

Credits
 - marc2003 (https://github.com/marc2k3): original foo_jscript_panel (https://github.com/marc2k3/foo_jscript_panel), sample scripts (https://github.com/TheQwertiest/smp_2003) and multiple contributions to this project.
 - T.P. Wang (https://hydrogenaud.io/index.php?action=profile;u=44175): original WSH Panel Mod (https://code.google.com/archive/p/foo-wsh-panel-mod). 
 - #jsapi IRC channel (https://wiki.mozilla.org/IRC): 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 (https://github.com/TheQwertiest/foo_spider_monkey_panel/blob/master/THIRD_PARTY_NOTICES.md) of the code being used in this project.
Title: Re: Spider Monkey Panel
Post by: TheQwertiest on 2018-10-01 11:15:34
Version: 1.0.0
Link: https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/tag/v1.0.0
Changelog (relative to the latest version of JScript Panel (https://github.com/marc2k3/foo_jscript_panel)):
Spoiler (click to show/hide)
Detailed description of API changes: https://github.com/TheQwertiest/foo_spider_monkey_panel/wiki/API-Changes#v100

Huge thanks to marc2003 (https://github.com/marc2k3) for porting samples and testing the component!
Title: Re: Spider Monkey Panel
Post by: seriousstas on 2018-10-02 21:24:31
Tried to see the cover:
foobar2000 \ user-components \ foo_spider_monkey_panel \ samples \ basic \ GetAlbumArtV2.txt

Code: [Select]
Error: Spider Monkey Panel v1.0.0 (GetAlbumArtV2 by T.P Wang)
g_img.Dispose is not a function

File: <main>
Line: 35, Column: 3

Stack trace:
   on_playback_new_track @ <main>: 35: 3
How to adapt this :
https://hydrogenaud.io/index.php/topic,110938.0.html
Library tree ?
Title: Re: Spider Monkey Panel
Post by: WilB on 2018-10-03 00:51:55
Library Tree is in the process of being ported.
Title: Re: Spider Monkey Panel
Post by: MordredKLB on 2018-10-03 05:01:20
@TheQwertiest , I can't tell you how excited I am for this! Really want to check it out, but I need to finish my themes 1.0 release before I have to redo everything again :)

You said it's fast, but have you done performance benchmarking? What kind of speed increase are you seeing when initializing 10k files in your playlist component?

I saw this bit in the API docs:
Quote
utils.CreateHtmlWindow() method.
This method allows the creation of HTML windows rendered by IE8 engine.
utils.CreateHtmlWindow(html_code, { width: window_w, height: window_h, title: window_title, data: callback_data, fn: callback_fn }).
If that's using ActiveX to create the window, you can bump it up to IE11 using the FEATURE_BROWSER_EMULATION (https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/general-info/ee330730(v=vs.85)) registry key. Not ideal for sharing themes, but probably possible nonetheless.
Title: Re: Spider Monkey Panel
Post by: Black_Over_Bills_Mothers on 2018-10-03 09:32:06
@TheQwertiest , This is great work, at last an engine that has the latest ECMA support. Now I can use string.startsWith and array.findIndex. Heaven knows what I can do with those async functions!

@WilB, You just knew someone would ask 'What about porting your wonderful Biography panel'.....
Title: Re: Spider Monkey Panel
Post by: TheQwertiest on 2018-10-03 09:44:54
Tried to see the cover:
foobar2000 \ user-components \ foo_spider_monkey_panel \ samples \ basic \ GetAlbumArtV2.txt
Oops, forgot to nuke that `Dispose` call (will be fixed in v1.0.1).
For now you can just remove the following lines:
Code: [Select]
if (g_img)
    g_img.Dispose();

How to adapt this :
https://hydrogenaud.io/index.php/topic,110938.0.html
Library tree ?
See @WilB 's reply above: it's being ported =)

Library Tree is in the process of being ported.
Nice! Looking forward to ;)
Title: Re: Spider Monkey Panel
Post by: Black_Over_Bills_Mothers on 2018-10-03 09:56:39
@TheQwertiest

I think I've found a problem. The following line;
    fb.RunContextCommandWithMetadb("ReplayGain/Scan as albums (by folders)",plman.GetPlaylistSelectedItems(plman.ActivePlaylist));

gives this error;
'RunContextCommandWithMetadb' failed:
handle argument is invalid
Title: Re: Spider Monkey Panel
Post by: TheQwertiest on 2018-10-03 09:59:12
You said it's fast, but have you done performance benchmarking? What kind of speed increase are you seeing when initializing 10k files in your playlist component?
I was too lazy to perform any proper benchmarking. AFAIK most(?) operations are faster by at least an order of magnitude. There is one regression I've encountered though (https://bugzilla.mozilla.org/show_bug.cgi?id=1474914), so `Playlist` performance might be further increased by rewriting initialization without `reverse`.

you can bump it up to IE11 using the FEATURE_BROWSER_EMULATION (https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/general-info/ee330730(v=vs.85)) registry key. Not ideal for sharing themes, but probably possible nonetheless.
I'm in progress of total rewrite of `CreateHtmlWindow`, since current implementation has some nasty bugs (like fb2k lockup when user closes html window). As a side effect it should work properly with IE=edge and it will support loading htmls from file.

@TheQwertiest

I think I've found a problem. The following line;
    fb.RunContextCommandWithMetadb("ReplayGain/Scan as albums (by folders)",plman.GetPlaylistSelectedItems(plman.ActivePlaylist));

gives this error;
'RunContextCommandWithMetadb' failed:
handle argument is invalid
See https://github.com/TheQwertiest/foo_spider_monkey_panel/issues/19

Bug will be fixed in v1.0.1
Title: Re: Spider Monkey Panel
Post by: Black_Over_Bills_Mothers on 2018-10-03 10:19:35
@TheQwertiest re issue #19
I've tried 'Build: 21:06:31, Oct  2 2018' patch from github and still get the same problem
Title: Re: Spider Monkey Panel
Post by: WilB on 2018-10-03 10:26:28
@Black_Over_Bills_Mothers
Quote
You just knew someone would ask 'What about porting your wonderful Biography panel'.....

Yes, Biography, Library Tree & YouTube Track Manager are all in the process of being ported... Spider Monkey Panel is a really great advancement that will enable them to be used with the newer ECMA features. To implement these properly may take a little time, but hopefully they are not far away...
Title: Re: Spider Monkey Panel
Post by: loz on 2018-10-03 11:07:47
I'm just going to flat out make a request even before I RTFM...

Please, for the love of all that is, add an album rating method. Something similar to jsp_rating would be nice but I'm not that picky. That is the only feature left that I want in foobar and the one thing I miss about not using custom database. (Having custom notes in custom db was nice too but I can do that with a .txt)

And if not, because marc2003 wouldn't do it either when I asked, I'm still going to use this component because it looks great. Thanks for this.
Title: Re: Spider Monkey Panel
Post by: Black_Over_Bills_Mothers on 2018-10-03 12:16:03
Can we please have a better development environment. Links to an external editor such as Notepad++ or at least add text search and brace matching. I know you can export and import script but it's a pain.
Title: Re: Spider Monkey Panel
Post by: fbuser on 2018-10-03 14:53:11
Can we please have a better development environment. Links to an external editor such as Notepad++ or at least add text search and brace matching.
I'd consider this as a waste of time to implement such functionality. Just place one line like include('path/to/script.js') in the panel code area and do the code editing of this script with an editor of your choice.
Title: Re: Spider Monkey Panel
Post by: Black_Over_Bills_Mothers on 2018-10-03 15:10:25
Can we please have a better development environment. Links to an external editor such as Notepad++ or at least add text search and brace matching.
I'd consider this as a waste of time to implement such functionality. Just place one line like include('path/to/script.js') in the panel code area and do the code editing of this script with an editor of your choice.
Seems interesting but could you explain a little further please.
Title: Re: Spider Monkey Panel
Post by: Sergey77 on 2018-10-03 17:12:35
@Black_Over_Bills_Mothers
Quote
You just knew someone would ask 'What about porting your wonderful Biography panel'.....

Yes, Biography, Library Tree & YouTube Track Manager are all in the process of being ported... Spider Monkey Panel is a really great advancement that will enable them to be used with the newer ECMA features. To implement these properly may take a little time, but hopefully they are not far away...
@WilB, great news!
looking forward to new versions of your cool scripts! (Don't forget JScript's version :) )
And I want to test Spider Monkey Panel
@TheQwertiest, thanks a lot for your great work!
Wish you creative success in the development of this project!
Title: Re: Spider Monkey Panel
Post by: TheQwertiest on 2018-10-03 20:42:39
I've tried 'Build: 21:06:31, Oct  2 2018' patch from github and still get the same problem
That's weird, I'll recheck later.

Wish you creative success in the development of this project!
Haha, thanks!

Please, for the love of all that is, add an album rating method. Something similar to jsp_rating would be nice but I'm not that picky.
Not sure what you mean. Do you want another custom metadb field? Like `smp_album_rating`?
PS: Both JSP and SMP provide a way to edit tags via `UpdateFileInfoFromJSON`.

Seems interesting but could you explain a little further please.
See `docs/js_doc/Interfaces.js` and samples. This method works like `eval`, but accepts path to file and provides better error-reporting.

On another note: JSP and SMP `Configure` window uses the same editor engine as Notepad++ =)
Title: Re: Spider Monkey Panel
Post by: MordredKLB on 2018-10-03 22:19:37
On another note: JSP and SMP `Configure` window uses the same editor engine as Notepad++ =)
Maybe he wants Atom :)
Title: Re: Spider Monkey Panel
Post by: TheQwertiest on 2018-10-04 00:10:53
Maybe he wants Atom :)
Well, to be fair, only internal editor engines are the same, the engine wrappers are different, thus the different experience in Notepad++ compared to `Configure` window in JSP/SMP =)
Title: Re: Spider Monkey Panel
Post by: loz on 2018-10-04 01:04:24
Please, for the love of all that is, add an album rating method. Something similar to jsp_rating would be nice but I'm not that picky.
Not sure what you mean. Do you want another custom metadb field? Like `smp_album_rating`?
PS: Both JSP and SMP provide a way to edit tags via `UpdateFileInfoFromJSON`.
custom metadb field? Like `smp_album_rating`
^ That exactly.  I don't want to be changing the actual tags in the files. I realize I could do this in m-TAGS but that just creates other issues for me personally atm. Custom database was also really good for such things but it just got to the point it crashed so often it was unusable.
Again, Thanks for this component. It looks great.
Title: Re: Spider Monkey Panel
Post by: mjm716 on 2018-10-04 02:59:47
Maybe he wants Atom :)
Well, to be fair, only internal editor engines are the same, the engine wrappers are different, thus the different experience in Notepad++ compared to `Configure` window in JSP/SMP =)

"wordwrap" option would be nice! ;)

great job by the way!
Title: Re: Spider Monkey Panel
Post by: TheQwertiest on 2018-10-04 09:49:13
^ That exactly.  I don't want to be changing the actual tags in the files. I realize I could do this in m-TAGS but that just creates other issues for me personally atm. Custom database was also really good for such things but it just got to the point it crashed so often it was unusable.
Hm... Don't really want to add random tags. I'd rather make a generic method to add custom tags (well, if it's possible), smth like
Code: [Select]
utils.CreateCustomTag('smp_new_tag', 'number') ); // CreateCustomTag(tag_name, tag_type);
...
metadb.SetCustomTag('smp_new_tag', 'this is my tag value'); // SetCustomTag(tag_name, tag_value);

"wordwrap" option would be nice! ;)
Do you mean `linewrap` (when line is too big, part of it will move to the next line)?
If you do, then I can add in v1.0.1.
Title: Re: Spider Monkey Panel
Post by: loz on 2018-10-04 10:29:35
^ That exactly.  I don't want to be changing the actual tags in the files. I realize I could do this in m-TAGS but that just creates other issues for me personally atm. Custom database was also really good for such things but it just got to the point it crashed so often it was unusable.
Hm... Don't really want to add random tags. I'd rather make a generic method to add custom tags (well, if it's possible), smth like
Code: [Select]
utils.CreateCustomTag('smp_new_tag', 'number') ); // CreateCustomTag(tag_name, tag_type);
...
metadb.SetCustomTag('smp_new_tag', 'this is my tag value'); // SetCustomTag(tag_name, tag_value);
That would be fine. Great even. I could actually do more with that.
Title: Re: Spider Monkey Panel
Post by: mjm716 on 2018-10-04 11:08:00
Do you mean `linewrap` (when line is too big, part of it will move to the next line)?
If you do, then I can add in v1.0.1.

Notepad++ actually calls it wordwrap - but yes, linewrap option would be great!
Title: Re: Spider Monkey Panel
Post by: TheQwertiest on 2018-10-04 17:25:12
That would be fine. Great even. I could actually do more with that.
It seems that this is impossible... From fb2k SDK:
Quote
List of fields that you provide is expected to be fixed at run-time. The backend will enumerate your fields only once and refer to them by indexes later.
I.e. all fields must be defined when component loads and can't be added afterwards.
Another way might be to configure custom tags from the component's preferences page, but that would be possible only if component configuration is loaded before fields enumeration (which I doubt is the case).
Title: Re: Spider Monkey Panel
Post by: MordredKLB on 2018-10-04 20:41:39
You could add a customProperties field to the metadb and then expose some methods to store and read arbitrary JSON from it. It's kind of ugly and hacky, but since you're abstracting it away from the end-user it'd hide the ugly implementation details and be pretty seamless.

To be clear, I'm not really advocating this approach, but it's doable.
Title: Re: Spider Monkey Panel
Post by: TheQwertiest on 2018-10-05 11:48:23
Version: 1.0.1
Link: https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/tag/v1.0.1
Changelog
Spoiler (click to show/hide)
Detailed description of API changes: https://github.com/TheQwertiest/foo_spider_monkey_panel/wiki/API-Changes#v101
Title: Re: Spider Monkey Panel
Post by: TheQwertiest on 2018-10-05 12:29:49
Version: 1.0.2
Link: https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/tag/v1.0.2
Changelog
Hotfix for v1.0.1 (see changelog above (https://hydrogenaud.io/index.php/topic,116669.msg963027.html#msg963027))
Title: Re: Spider Monkey Panel
Post by: TheQwertiest on 2018-10-05 13:32:09
You said it's fast, but have you done performance benchmarking? What kind of speed increase are you seeing when initializing 10k files in your playlist component?
I've benchmarked playlist script a bit:
Playlist initialization speed is mostly the same. Profiling showed that bad performance of `Array.reverse()` is the main culprit. So it should greatly improve once I remove it.

But!!! I've noticed that CPU usage is halved during playlist scrolling!
- Normal scrolling: ~3.5% SMP vs ~7.5% JSP.
- Erratic scrolling in huge playlist: ~5% SMP vs ~10% JSP.

Another thing that I've noticed is that erratic scrolling in JSP has small hitches, while SMP does not suffer from it. Most likely caused by differences in GC management policy - JScript immediately destroys any resources that are no longer used, no matter how long it takes, while SpiderMonkey has a `budget` - it can spend only as much time in GC as allowed by budget.

Measured same performance increase during scrolling in @WilB 's Library Tree as well.

PS: I have a 6-core CPU and SMP/JSP are single-threaded, so to get a clearer picture results should be multiplied by six. Thus ~21% SMP vs ~45% JSP in normal scrolling and 30% SMP vs 60% JSP in erratic.
Title: Re: Spider Monkey Panel
Post by: Sergey77 on 2018-10-05 17:50:36
I noticed same interrupt of Shpeck visualization for both panels jsplaylist-mod script in JSP and SMP.
Title: Re: Spider Monkey Panel
Post by: TheQwertiest on 2018-10-06 12:57:54
I noticed same interrupt of Shpeck visualization for both panels jsplaylist-mod script in JSP and SMP.
What do you mean? Shpeck visualization is a separate component/panel and is not a part of SMP nor jsplaylist-mod :\
Title: Re: Spider Monkey Panel
Post by: Sergey77 on 2018-10-06 14:09:15
I noticed same interrupt of Shpeck visualization for both panels jsplaylist-mod script in JSP and SMP.
What do you mean? Shpeck visualization is a separate component/panel and is not a part of SMP nor jsplaylist-mod :\
Yes, but I mean these separate components (Shpeck and jsplaylist-mod) work at the same time in diferent CUI panels.
When together displaying the panel with Shpek and another panel with jsplaylist-mod, the visualization is displaying with jerks during a file playback.
This behavior of visualization when running jsplaylist-mod as in JSP or as in SMP is the same.
But when activated CUI Playlist view panel (jsplaylist-mod panel is not active), Shpeck visualization is displayed smoothly, without jerks.
Title: Re: Spider Monkey Panel
Post by: TheQwertiest on 2018-10-06 16:22:17
When together displaying the panel with Shpek and another panel with jsplaylist-mod, the visualization is displaying with jerks during a file playback.
Can't reproduce: Shpeck visualization(with MilkDrop2) is smooth with both stock CUI playlist and `jsplaylist-mod` script.
Possible cause of hitches you are experiencing: Shpeck is pretty CPU intensive, so, if your CPU is practically used up by Shpeck, then any additional CPU load might cause stuttering.

PS: I've tested `jsplaylist-mod` script a bit, and it does not seem to cause any meaningful CPU load during casual usage. And CPU load is close to nil when idle (i.e. when there is no interaction with playlist panel).
Title: Re: Spider Monkey Panel
Post by: Sergey77 on 2018-10-06 17:19:53
Did you test synchronous work the panels (Shpeck and jsplaylist-mod) during music playback? (triangle cursor of jsplaylist-mod should flashing)
Shpeck (with MilkDrop2) stuttering synchronous with flashing cursor. Shpeck works stable without playback.
Maybe it really depends on my hardware speed. Let's see maybe someone else will report of similar problem.
In any case, thanks for your time!
Title: Re: Spider Monkey Panel
Post by: Black_Over_Bills_Mothers on 2018-10-08 13:52:43
I have a script to automate the addition of new tracks/albums into my collection. This script calls fb.RunContextCommandWithMetadb function to remove all embedded images and then to Optimize and reduce file sizes - both core functionality. These two operations need to be performed sequentially. This has caused me two problems;
1) Firstly the call to fb.RunContextCommandWithMetadb does not block with means that the only way I can detect completeness is to catch the callback - okay but it would be better if the call could block - maybe optionally.
2) Both calls generate a popup window asking the user to click either close or OK button. Can this request be circumvented in some way?
Title: Re: Spider Monkey Panel
Post by: MordredKLB on 2018-10-09 17:36:09
Those are both built in functionality of foobar. There's nothing Spidermonkey or JScript can do to control those operations once it tells foobar to start them.
Title: Re: Spider Monkey Panel
Post by: TheQwertiest on 2018-10-11 10:17:01
Version: 1.0.3
Link: https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/tag/v1.0.3
Changelog
Spoiler (click to show/hide)
Detailed description of API changes: https://github.com/TheQwertiest/foo_spider_monkey_panel/wiki/API-Changes#v103

Note: v1.0.0 API changelog was missing description of on_notify_data callback behaviour change. It is rectified now: see wiki (https://github.com/TheQwertiest/foo_spider_monkey_panel/wiki/API-Changes#v100) or callbacks doc (https://github.com/TheQwertiest/foo_spider_monkey_panel/blob/master/component/docs/Callbacks.js).
Title: Re: Spider Monkey Panel
Post by: Decalicatan_Decalicatan on 2018-10-12 12:31:39
@TheQwertiest , thanks for the component

It seems there is an issue with the on_main_menu() function. As soon as I try to trigger one of the menu items, foobar2000 crashes :-(.
Title: Re: Spider Monkey Panel
Post by: TheQwertiest on 2018-10-12 14:26:03
@TheQwertiest , thanks for the component

It seems there is an issue with the on_main_menu() function. As soon as I try to trigger one of the menu items, foobar2000 crashes :-(.
Thanks for the report!
I'll look into it (#25 (https://github.com/TheQwertiest/foo_spider_monkey_panel/issues/25)).
Title: Re: Spider Monkey Panel
Post by: Decalicatan_Decalicatan on 2018-10-14 21:56:21
@TheQwertiest you're welcome ^^.

I think I may have found another bug  O:) : using Columns UI and the "MainMenuManager All-In-One", as soon as I try to change to another layout --> instant crash...

Title: Re: Spider Monkey Panel
Post by: TheQwertiest on 2018-10-15 10:35:29
@TheQwertiest you're welcome ^^.

I think I may have found another bug  O:) : using Columns UI and the "MainMenuManager All-In-One", as soon as I try to change to another layout --> instant crash...
Could not reproduce the bug (on the latest build at least). Can you try the latest build (https://ci.appveyor.com/api/projects/theqwertiest/foo-spider-monkey-panel/artifacts/_result%2FWin32_Release%2Ffoo_spider_monkey_panel.fb2k-component?branch=master&job=Configuration%3A%20Release)?
Title: Re: Spider Monkey Panel
Post by: Decalicatan_Decalicatan on 2018-10-15 17:26:24
My bad, I tried with a new portable installation and is fine. I think I may have messed up one of the js files in the "docs".

Anyway, on_main_menu() works fine now. Thanks!
Title: Re: Spider Monkey Panel
Post by: TheQwertiest on 2018-10-15 21:36:33
My bad, I tried with a new portable installation and is fine. I think I may have messed up one of the js files in the "docs".

Bug reproduced: see #29 (https://github.com/TheQwertiest/foo_spider_monkey_panel/issues/29)
Title: Re: Spider Monkey Panel
Post by: loz on 2018-10-20 18:18:33
I have the following code in ratings.txt to set ratings using keyboard shortcuts:
Code: [Select]
// RATING HOTKEYS
function on_main_menu(index) {
switch (index) {
case 1: // set rating File>Spider Monkey Panel>1 is run
panel.metadb.SetRating(panel.tf('$if2(%smp_rating%,0)') == 1 ? 0 : 1);
panel.metadb.RefreshStats();
break;
}
 }

This, and every variation I have tried crashes foobar instantly. Now I'm assuming it's either something with my configuration or my code since I pretty much modified what I had in js_panel, but just in case it's something with spider monkey I thought I'd the thread aware this is happening. (Crash reports and full code attached if needed). Thanks.
Title: Re: Spider Monkey Panel
Post by: TheQwertiest on 2018-10-20 22:17:13
I have the following code in ratings.txt to set ratings using keyboard shortcuts:
Code: [Select]
// RATING HOTKEYS
function on_main_menu(index) {
switch (index) {
case 1: // set rating File>Spider Monkey Panel>1 is run
panel.metadb.SetRating(panel.tf('$if2(%smp_rating%,0)') == 1 ? 0 : 1);
panel.metadb.RefreshStats();
break;
}
 }

This, and every variation I have tried crashes foobar instantly. Now I'm assuming it's either something with my configuration or my code since I pretty much modified what I had in js_panel, but just in case it's something with spider monkey I thought I'd the thread aware this is happening. (Crash reports and full code attached if needed). Thanks.
Thanks for the report!
This is a known bug, which will be fixed in v1.0.4, which is expected to be released before the end of the next week.

PS: You can use the `nightly build` from the link in the OP for the time being. It should be noted though, that `nightly build` might be less stable than the `release build` and might have API incompatibilities, which are not documented. So it should be used only if you want to help me by testing it (thus making `release-build` more stable), or if you want to get your bug-fixes as soon as possible by accepting the risk of potential instability.
Title: Re: Spider Monkey Panel
Post by: loz on 2018-10-20 22:53:58
Ok great. Just making sure. I'll wait a few days for the stable as this is a minor issue for me and everything else seems to be working nicely.
Title: Re: Spider Monkey Panel
Post by: TheQwertiest on 2018-10-24 21:40:47
Version: 1.0.4
Link: https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/tag/v1.0.4
Changelog
Spoiler (click to show/hide)
Detailed description of API changes: https://github.com/TheQwertiest/foo_spider_monkey_panel/wiki/API-Changes#v104

Note: reset SMP advanced settings for better performance - Preferences>Advanced>Tools>Right-Click on Spider Monkey Panel>Reset Branch.

Huge thanks to @WilB for all the bug reports!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: loz on 2018-10-25 10:50:11
Fixed
  • Fixed crash when `on_main_menu` callback was invoked.
Can confirm my issues with this have been fixed. Thanks.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: embe on 2018-10-25 14:19:51
I'm having problem with displaying buttons with 'track info + seekbar + buttons' config. All I get are these rectangles. Do I need some special font installed for it?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2018-10-25 22:43:08
I'm having problem with displaying buttons with 'track info + seekbar + buttons' config. All I get are these rectangles. Do I need some special font installed for it?
That's because nobody reads `Readme` nowadays...

Quote from: samples/readme.md
- "complete" scripts: 
         Should work fine on any system.
         Most scripts require the installation of FontAwesome (https://github.com/FortAwesome/Font-Awesome/blob/fa-4/fonts/fontawesome-webfont.ttf?raw=true)."
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2018-11-05 21:04:14
Version: 1.0.5
Link: https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/tag/v1.0.5
Changelog:
Spoiler (click to show/hide)
Detailed description of API changes: https://github.com/TheQwertiest/foo_spider_monkey_panel/wiki/API-Changes#v105
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2018-11-19 19:08:10
Version: 1.1.0
Link: https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/tag/v1.1.0
Changelog:
Spoiler (click to show/hide)
Detailed description of API changes: https://github.com/TheQwertiest/foo_spider_monkey_panel/wiki/API-Changes#v110
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2018-11-20 11:49:00
Version: 1.1.1
Link: https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/tag/v1.1.1
Changelog
Hotfix for v1.1.0 (see changelog above (https://hydrogenaud.io/index.php/topic,116669.msg965016.html#msg965016))
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AlexR on 2018-11-28 07:48:36
Do not work callback on_colours_changed()
version 1.1.1, foobar 1.4.1
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AlexR on 2018-11-28 11:29:39
Do not work callback on_colours_changed()
version 1.1.1, foobar 1.4.1, DUI
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2018-11-29 16:15:24
Do not work callback on_colours_changed()
version 1.1.1, foobar 1.4.1, DUI
Yep, that's a bug, will be fixed in the next version =)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-01-09 11:01:17
Version: 1.1.2
Link: https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/tag/v1.1.2
Changelog:
Spoiler (click to show/hide)
Detailed description of API changes: https://github.com/TheQwertiest/foo_spider_monkey_panel/wiki/API-Changes#v112
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: SUPERCOOLMAN on 2019-01-13 01:33:37
trying to re-create an ancient foo_uie_albumart behaviour where pictures/arts in all user specified sub-directories of currently playing track are collected when track playback starts, then runs slideshow cycling through all the art every X second as specified by user

the component can load jpg, pg, bmp...etc. but not webp or other newer formats. I was wondering if it's possible for SMP to handle webp. maybe through some codec installed on the system?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-01-16 14:17:19
I was wondering if it's possible for SMP to handle webp. maybe through some codec installed on the system?
TLDR: SMP does not have functionality to load images that are not supported by fb2k.

Full answer:
SMP uses foobar2000 API to load album art and `Gdiplus::Bitmap` (https://docs.microsoft.com/en-us/windows/desktop/api/gdiplusheaders/nf-gdiplusheaders-bitmap-bitmap(inconstwchar_inbool)) to load external images. AFAIK neither fb2k nor GDI+ have the ability to work with webp files.
It's probably possible to write a fb2k component that can load webp files as images though (and maybe even work as album art source for fb2k).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-01-17 10:53:43
Version: 1.1.3
Link: https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/tag/v1.1.3
Changelog:
Spoiler (click to show/hide)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Decalicatan_Decalicatan on 2019-01-19 18:21:25
I don't know if the issue is with the latest version (1.1.3) or if it was already there before, but I can't update ratings (foo_playcount) anymore with fb.RunContextCommandWithMetadb. For example with the rating.txt script. It does simple nothings :(

Thanks in advance. And ty for all the work you have already done with the component!
Regards
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: hlhp on 2019-01-20 10:47:39
I am new to Spider Monkey Panel and J script panel.
I want to embed play back statistic information into the file.

Is there a function to edit metadata? (I only found retrieve info from metadata)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Rhand on 2019-01-20 11:28:36
This command doesn't work anymore with new spider panel.
buttons.buttons.albumart = new _button(bs * 6.8, 0, bs, bs, {normal : "Albumart.png", hover: "Albumart_h.png"}, function () { fb.RunContextCommand("Run service/AlbumArt"); },"AlbumArt"); Hope you can solve this
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-01-20 15:11:12
Version: 1.1.4
Link: https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/tag/v1.1.4
Changelog
Hotfix for v1.1.3 (see changelog above (https://hydrogenaud.io/index.php/topic,116669.msg967258.html#msg967258))
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-01-20 15:12:44
@Decalicatan_Decalicatan @Rhand : the issue should be fixed in v1.1.4. Thanks for the bug report!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-01-20 15:19:26
I am new to Spider Monkey Panel and J script panel.
I want to embed play back statistic information into the file.

Is there a function to edit metadata? (I only found retrieve info from metadata)
Depends on what you mean: you can't edit some most stats provided by `foo_playcount` (e.g. %play_count%), but you can write additional custom tags with `FbMetadbHandleList.UpdateFileInfoFromJSON()` (you can read more about the method and it's usage in the documentation included with component: `Configure Panel` dialog > menu > Help > View Help).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Decalicatan_Decalicatan on 2019-01-20 16:25:18
@Decalicatan_Decalicatan @Rhand : the issue should be fixed in v1.1.4. Thanks for the bug report!

ty!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: hlhp on 2019-01-21 02:36:39
Depends on what you mean: you can't edit some most stats provided by `foo_playcount` (e.g. %play_count%), but you can write additional custom tags with `FbMetadbHandleList.UpdateFileInfoFromJSON()` (you can read more about the method and it's usage in the documentation included with component: `Configure Panel` dialog > menu > Help > View Help).
Thank you, adding custom tags is the only thing I want.   ;)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-01-21 14:43:01
Version: 1.1.5
Link: https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/tag/v1.1.5
Changelog
Hotfix II for v1.1.3 (see changelog above (https://hydrogenaud.io/index.php/topic,116669.msg967258.html#msg967258))
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: hlhp on 2019-01-23 03:10:19
I want to find meta value(first value) by name.

According to the documentation.
I need to...
1. Check if there are matched name in the meta. if yes, go to step 2.
2. Find out how many meta in it.
3. Loop through the meta(s) to find the idx numbers for the name
4. Use the idx to get the Value out.

Is there any better way to doing this?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-01-23 09:06:46
I want to find meta value(first value) by name.

According to the documentation.
I need to...
1. Check if there are matched name in the meta. if yes, go to step 2.
2. Find out how many meta in it.
3. Loop through the meta(s) to find the idx numbers for the name
4. Use the idx to get the Value out.

Is there any better way to doing this?

There is also a MetaFind method, which returns the index of the meta field (or -1 if not found) =)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: hlhp on 2019-01-24 14:58:14
There is also a MetaFind method, which returns the index of the meta field (or -1 if not found) =)

Thank you it works.
I thought it only return like Boolean, I should read the documentation more carefully.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-02-06 16:53:34
First of all, a big thank you to @TheQwertiest for this component. I've been away from the forum for sometime and this is really a great surprise. It's good to have a jscript component back with official support and with the developer active in the forum. I'm following the migration instructions from JScript panel 2 and so far no problem. The only issue I found which was not mentioned in the official docs, nor in the forum, is that I can no more include both JScommon and Helpers in the preprocessor because some constants and variables are declared on both scripts.
I solved the problem by copying the few functions I actually needed, from JScommon to a new script, which replaced JScommon in the preprocessors where Helpers is also included. I like it better this way, it is definitely cleaner, but I just wanted to make sure that it is an intended behavior and I did not mess anything up.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-02-07 13:20:50
First of all, a big thank you to @TheQwertiest for this component.
You are very welcome :)

The only issue I found which was not mentioned in the official docs, nor in the forum, is that I can no more include both JScommon and Helpers in the preprocessor because some constants and variables are declared on both scripts.
Well, it was probably intended that way (that is for Br3tt's scripts to be self-sufficient).
I wouldn't know anyway, since I've never actually delved into them - it's only thanks to marc2003 that Br3tt's scripts were even included in SMP =)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: anamorphic on 2019-02-08 05:00:59
I too, would like to heap many thanks upon TheQwertiest one for this component. I do believe it will be quite fun once I figure out how to write scripts. ;)

For now though I just have a minor, issue / question / request. (An issquesest?) If one (me) did not want to see the SMP Playback Statistics in track properties, how could one (I) turn display of them off? Might it please be possible? (We looked for options)

The thing is with 'Selection Properties' (DUI) element, all stats are lumped / jumbled together under 'Other' along with official Playback Statistics (foo_playcount) component. So I guess that is limitation of the element. However the original PS 'Rating' (displayed as stars) is gone altogether, replaced by SMP 'Rating' (with no stars, because not using it) - not very complementary. I'd prefer to see my original ratings.

Not sure what / if you can do anything about this, but mentioning just in case.

(Of course, one could design a far superior 'Selection Properties' element with this very fine component. :D Even so... Edit: and I just found the 'properties.txt' sample after posting, typical!)

Cheers
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-02-08 10:54:29
I just noticed the stats show up twice in the properties tab. I still have JScript panel installed of course. It's not a problem, I just wonder why this happens:

Spoiler (click to show/hide)

Now, in the picture above you will also notice the custom database tags. I don't know how SMP statistics work, but if the values are pinned to primary tags or a combination of primary tags, like the official playback statistics component does, than this is potentially a custom database replacement. I've seen a previous request by @loz for custom tags, but I did not understand if they're planned to be implemented. Anyway I definitely second that request.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-02-08 21:02:31
Eventually I ran into a problem. I use some text files to share layout settings between jscript panels and panel stack splitter. I have a script which deletes a specific file when triggered, using the FileSystemObject DeleteFile method. It's a very simple script and it always worked with JScript Panel, but since migrating to Spider Monkey Panel the delete action is denied because the file is in use by foobar2000. I cannot even delete the file manually.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-02-09 12:19:02
For now though I just have a minor, issue / question / request. (An issquesest?) If one (me) did not want to see the SMP Playback Statistics in track properties, how could one (I) turn display of them off? Might it please be possible? (We looked for options)

The thing is with 'Selection Properties' (DUI) element, all stats are lumped / jumbled together under 'Other' along with official Playback Statistics (foo_playcount) component. So I guess that is limitation of the element. However the original PS 'Rating' (displayed as stars) is gone altogether, replaced by SMP 'Rating' (with no stars, because not using it) - not very complementary. I'd prefer to see my original ratings.
Not sure if I can do anything about it (apart from renaming the metatag, which I won't do :P).
@Peter : could you help us out, please? Is there a way to hide and/or reorder the priority of the metadata provided by components?

I just noticed the stats show up twice in the properties tab. I still have JScript panel installed of course. It's not a problem, I just wonder why this happens:
That is the intended behaviour: SMP and JSP use different (internal) tags to avoid potential compatibility issues.

I've seen a previous request by @loz for custom tags, but I did not understand if they're planned to be implemented. Anyway I definitely second that request.
This is something I'm planning to look into (that is the ability to add customs tags via SMP API), but it's rather low on my priority list.

Eventually I ran into a problem. I use some text files to share layout settings between jscript panels and panel stack splitter. I have a script which deletes a specific file when triggered, using the FileSystemObject DeleteFile method. It's a very simple script and it always worked with JScript Panel, but since migrating to Spider Monkey Panel the delete action is denied because the file is in use by foobar2000. I cannot even delete the file manually.
Could you provide the script (or it's relevant parts)?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-02-09 15:46:45
Eventually I ran into a problem. I use some text files to share layout settings between jscript panels and panel stack splitter. I have a script which deletes a specific file when triggered, using the FileSystemObject DeleteFile method. It's a very simple script and it always worked with JScript Panel, but since migrating to Spider Monkey Panel the delete action is denied because the file is in use by foobar2000. I cannot even delete the file manually.
Could you provide the script (or it's relevant parts)?

Sure, as I said it's a pretty simple one. The panel is resized via PSS (panel stack splitter) and this triggers either a delete or a create file action.
Code: [Select]
function on_size(){
    switch (window.Height){
        case 0:
        if (fso.FileExists(SettingsPath + "PlaylistVisible")) fso.DeleteFile(SettingsPath + "PlaylistVisible");
        RefreshPSS();
        break;
        case 1:
        if (!fso.FileExists(SettingsPath + "PlaylistVisible")) fso.CreateTextFile(SettingsPath + "PlaylistVisible");
        RefreshPSS();
        break;  
        case 2:
        if (fso.FileExists(SettingsPath + "PlaylistVisible")) fso.DeleteFile(SettingsPath + "PlaylistVisible");
        RefreshPSS();
        break;
    }

Here's also the relevant code from another script, included in the preprocessor:
Code: [Select]
var fso = new ActiveXObject("Scripting.FileSystemObject"); 
var SettingsPath = fb.ProfilePath + "settings\\";

function RefreshPSS() {
var Refresh_sys = window.GetProperty("Refresh_sys",true);
 if (Refresh_sys < true) {
if (fb.IsPlaying || fb.IsPaused) { 
fb.RunMainMenuCommand("View/Show status bar");
fb.RunMainMenuCommand("View/Show status bar");
} else {
fb.RunMainMenuCommand("View/Show status bar");
fb.RunMainMenuCommand("View/Show status bar");
}
} else {
if (fb.IsPlaying || fb.IsPaused) { 
fb.RunMainMenuCommand("Playback/Play or Pause");
fb.RunMainMenuCommand("Playback/Play or Pause");
} else {
fb.RunMainMenuCommand("Playback/Play");
fb.RunMainMenuCommand("Playback/Stop");
}
}
}

The script seems to work for a few times right after foobar2000 start up, but eventually something happens which blocks the file, and I can't figure out what it could even be.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-02-09 16:24:28
I just noticed the stats show up twice in the properties tab. I still have JScript panel installed of course. It's not a problem, I just wonder why this happens:
That is the intended behaviour: SMP and JSP use different (internal) tags to avoid potential compatibility issues.

I see, I never noticed before that JScript panel had its own! I though it was reading Spider Monkey Panel statistics.  :))
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-02-09 18:15:50
The script seems to work for a few times right after foobar2000 start up, but eventually something happens which blocks the file, and I can't figure out what it could even be.

TLDR: Use the following code fso.CreateTextFile(path).Close(); or let file = fso.CreateTextFile(path); file.Close();

Full story: the problem is caused by your usage of fso.CreateTextFile: CreateTextFile returns a file object, which contains an open handle to the file, which will be closed only in two cases - when object is destroyed and when it's closed manually. The lifetime of JS objects is variable, i.e. objects might not be immediately destroyed when there are no references to them, so in your case: object is alive & not closed > handle remains open > file remains locked.

PS: Plz, don't over-quote =)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-02-09 20:32:18
TLDR: Use the following code fso.CreateTextFile(path).Close(); or let file = fso.CreateTextFile(path); file.Close();

Full story: the problem is caused by your usage of fso.CreateTextFile: CreateTextFile returns a file object, which contains an open handle to the file, which will be closed only in two cases - when object is destroyed and when it's closed manually. The lifetime of JS objects is variable, i.e. objects might not be immediately destroyed when there are no references to them, so in your case: object is alive & not closed > handle remains open > file remains locked.

Thanks, that was it. So, the real question is: why did it work with JScript panel?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-02-09 21:11:12
Thanks, that was it. So, the real question is: why did it work with JScript panel?
Because GC behaves differently in JScript and SMP (Microsoft's jscript is quite outdated in that way).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: WebSkater on 2019-02-12 13:59:01
Hi,
after installing Spider Monkey Panel in perfect working fb2k v1.3.20 on W7 x64 - and not making any use of it, i only installed it - I can't write rating tags to foo_playcount's database anymore. Modifying already existing rating tags stored in the database isn't possible either. Writing rating tags direct to files is still working. After uninstalling Spider Monkey Panel everything is working as before and writing and modifying rating tags in files or in the database is possible again without any issue !

Seems Spider Monkey Panel and the official Playback Statistics (foo_playcount) can't work together without making trouble.

Any ideas or suggestion?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-02-12 14:34:41
Replied on GitHub.

PS: please, do not duplicate bug reports in the future - posting it in one place (here or on GitHub) is good enough =)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: WebSkater on 2019-02-12 17:28:08
Hi TheQwertiest,
sorry for duplicate posting, but I'm not very experienced in posting + "forum behaviour". Till now reading alone helped me over the years to solve my problems with foobar.

"Replied on GitHub"
means you noticed my post and are aware of the problem, but not that you have answered to it, right ? Stupid question, I know, but after "closing Github post by accident" and reopening and not seeing an answer after that in Github I'm really unsecure about this. Or I'm making something wrong again?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: michtar on 2019-02-13 13:01:46
I'm not sure if it's a system specific, user  :-[ , script or Spider Monkey Panel problem but:
- mouse-on and double click functions of "album art" sample stopped working. They used to work with SMP and work fine with JScript Panel.

- tested on clean portable install, Foobar 1.4.2, default components + Spider Monkey Panel 1.1.5, default path, Windows 7
- as far as I noticed script did not change
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-02-13 13:30:35
I'm not sure if it's a system specific, user  :-[ , script or Spider Monkey Panel problem but:
- mouse-on and double click functions of "album art" sample stopped working. They used to work with SMP and work fine with JScript Panel.

Thanks for the bug report! Will be fixed in the next version (kudos to marc2003).
In the mean time you can apply the fix manually - https://github.com/marc2k3/smp_2003/commit/c12b44f25fb5b810a7c92366e324191a2a0ce5bf
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: michtar on 2019-02-14 09:47:34
In the mean time you can apply the fix manually - https://github.com/marc2k3/smp_2003/commit/c12b44f25fb5b810a7c92366e324191a2a0ce5bf
Works (obviously). Thanks marc2003/TheQwertiest.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: dwmartin0906 on 2019-02-14 12:37:22
I was wondering if anyone else was having this problem with the SMP thumbs panel.  It works fine except when displaying the thumbs in a grid.  They display fine initially, but when clicking on a specific thumb to display it I get the following error.  Any ideas?

Error: Spider Monkey Panel v1.1.5 (Thumbs by marc2003)
_.drawOverlay is not a function

File: thumbs.js
Line: 100, Column: 5

Stack trace:
  _thumbs/this.paint@thumbs.js:100:5
  on_paint@<main>:58:2
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-02-15 09:09:00
I was wondering if anyone else was having this problem with the SMP thumbs panel.  It works fine except when displaying the thumbs in a grid.  They display fine initially, but when clicking on a specific thumb to display it I get the following error.  Any ideas?

Error: Spider Monkey Panel v1.1.5 (Thumbs by marc2003)
_.drawOverlay is not a function

File: thumbs.js
Line: 100, Column: 5

Stack trace:
  _thumbs/this.paint@thumbs.js:100:5
  on_paint@<main>:58:2
Yup, that's a bug =) Will be fixed in the next version (again kudos to marc2003).
In the mean time you can apply the fix manually - https://github.com/marc2k3/smp_2003/commit/a0e578ec06211b1d4b01f529962142bf50a75da5
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: dwmartin0906 on 2019-02-15 10:19:33
Thank you both very much.  That fixed it.  Amazing what one little period can do, isn't it?  I was a COBOL programmer for over 35 years so I understand how much damage one little typo can do.  At least you don't have to deal with hard copies, punch cards and 4 hour compile times like I had to in the beginning.  Debugging was a total nightmare.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-02-15 10:37:46
Yeah, script languages are quite convenient in that way (actually one of the reasons why WSH/JSP/SMP were developed in the first place).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2019-02-15 18:27:11
Hello!
Anybody knows if somebody already did a JS better than the default Album List DUI component?
The default Album List is "too slow" for me and many time starves.
I just need something providing a consolidated by folder structure view (as does Album List DUI) and some capability for searching the dBase by usual search patterns.
If I would be capable of programming in Java I would try myself, but I am not.
Thanks and regards, Andrea
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: always.beta on 2019-02-16 00:31:56
Anybody knows if somebody already did a JS better than the default Album List DUI component?
https://hydrogenaud.io/index.php/topic,111060.0.html
Try it yourself
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2019-02-17 10:45:17
Hi Always.beta, many thanks!
Regards, Andrea
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-02-22 13:31:35
From what I gather, the strict mode defined in the panel does not apply to the scripts processed with the include statement. Is this an intended behaviour?
BTW, is the strict mode kind of mandatory with SMP or is it just a scrpting suggestion by the developers? or is it merely the common practice with the latest ECMA versions?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: philodoxxx on 2019-02-22 16:46:28
 I have been experiencing an error on start up in Foobar related to the JS Smooth Browser sample script  in Spider Monkey Panel v1.1.5. See below:

Error: Spider Monkey Panel v1.1.5 (JS Smooth Browser by Br3tt aka Falstaff)
Resize failed:
Failed to create GdiPlus object (0x0: No error

File: jssb.js
Line: 3500, Column: 24

Stack trace:
  get_images@jssb.js:3500:24
  oBrowser/this.update@jssb.js:1526:3
  oBrowser/this.setSize@jssb.js:1548:3
  on_size@jssb.js:3120:3



If I reload the script it work's fine. The error only occurs at startup.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-02-23 23:41:55
So far I managed to upgrade all my scripts, but I still have a very old one by marc2003 that I can't get working on Spider Monkey Panel. The script is "Last.fm Album Art Downloader" with some little modifications I made over time and it still works perfectly on JScript Panel 2.1.4.

This is the script that works in JScript Panel:
Code: [Select]
// ==PREPROCESSOR==
// @name "Last.fm Album Art Downloader"
// @author "marc2003"
// @import "%fb2k_component_path%samples\complete\js\lodash.min.js"
// @import "%fb2k_component_path%samples\complete\js\helpers.js"
// @import "%fb2k_component_path%samples\complete\js\panel.js"
// ==/PREPROCESSOR==


var SettingsPath = fb.ProfilePath + "settings\\";
var library_tracks_only = false;
var folder_tf = fb.TitleFormat("$puts(folder,$trim($replace($lower($directory(%path%)),disc,,cd,)))$replace($directory_path(%path%),$ifequal($strstr($get(folder),$num($get(folder),$len($get(folder)))),1,\\%directoryname%,),)\\");
var filename_tf = fb.TitleFormat("front.jpg");

var panel = new _.panel("Last.fm Album Art Downloader", ["metadb", "custom_background"]);
var x = new ActiveXObject("Microsoft.XMLHTTP");
var ini = SettingsPath + "album-art.ini";
_.createFolder(SettingsPath);

panel.item_focus_change();

function on_metadb_changed() {
var np = fb.GetNowPlaying();
if (panel.metadb && np && np.Compare(panel.metadb) && np.RawPath.indexOf("file://") == 0 && (!library_tracks_only || fb.IsMetadbInMediaLibrary(np))) {
var ar = panel.tf("%album artist%");
var al = panel.tf("%album%");
var f = folder_tf.EvalWithMetadb(panel.metadb) + _.fbSanitise(filename_tf.EvalWithMetadb(panel.metadb));
var tmp = _.q(_.fbSanitise(ar + al));
var n = _.round(_.now() / 1000);
var t = utils.ReadINI(ini, "Timestamps", tmp, 0);

switch (true) {
case !_.tagged(ar):
case !_.tagged(al):
case _.isFile(f):
case n - t < ONE_DAY:
break;
default:
utils.WriteINI(ini, "Timestamps", tmp, n);
x.open("GET", "https://www.last.fm/music/" + encodeURIComponent(ar) + "/" + encodeURIComponent(al) + "/+images", true);
x.setRequestHeader("If-Modified-Since", "Thu, 01 Jan 1970 00:00:00 GMT");
x.send();
x.onreadystatechange = function () {
if (x.readyState == 4) {
if (x.status == 200) {
var o = _.first(_.filter(_.getElementsByTagName(x.responsetext, "img"), {"className" : "image-list-image"}));
if (o) {
var u = o.src.replace("avatar170s", "ar0");
_.runCmd("cscript //nologo " + _.q(fb.ProfilePath + "scripts\\JSP\\download.vbs") + " " + _.q(u) + " " + _.q(f), false);
window.SetTimeout(function () {
panel.item_focus_change();
}, 3000);
}
} else {
console.log("HTTP error: " + x.status);
}
}
}           
break;
}
}
RefreshPSS();
}

function RefreshPSS() {
var Refresh_sys = window.GetProperty("Refresh_sys",true);
 if (Refresh_sys < true) {
if (fb.IsPlaying || fb.IsPaused) { 
fb.RunMainMenuCommand("View/Show status bar");
fb.RunMainMenuCommand("View/Show status bar");
} else {
fb.RunMainMenuCommand("View/Show status bar");
fb.RunMainMenuCommand("View/Show status bar");
}
} else {
if (fb.IsPlaying || fb.IsPaused) { 
fb.RunMainMenuCommand("Playback/Play or Pause");
fb.RunMainMenuCommand("Playback/Play or Pause");
} else {
fb.RunMainMenuCommand("Playback/Play");
fb.RunMainMenuCommand("Playback/Stop");
}
}

}

...and this is my attempt to upgrade it for Spider Monkey Panel:
Code: [Select]
'use strict';

window.DefinePanel('Last.fm Album Art Downloader', {author:'marc2003'});
include(fb.ComponentPath + 'samples\\complete\\js\\lodash.min.js');
include(fb.ComponentPath + 'samples\\complete\\js\\helpers.js')
include(fb.ComponentPath + 'samples\\complete\\js\\panel.js');


var SettingsPath = fb.ProfilePath + "settings\\";
var library_tracks_only = false;
var folder_tf = fb.TitleFormat("$puts(folder,$trim($replace($lower($directory(%path%)),disc,,cd,)))$replace($directory_path(%path%),$ifequal($strstr($get(folder),$num($get(folder),$len($get(folder)))),1,\\%directoryname%,),)\\");
var filename_tf = fb.TitleFormat("front.jpg");

let panel = new _panel("Last.fm Album Art Downloader", ["metadb", "custom_background"]);
var x = new ActiveXObject("Microsoft.XMLHTTP");
var ini = SettingsPath + "album-art.ini";
_createFolder(SettingsPath);

panel.item_focus_change();

function on_metadb_changed() {
var np = fb.GetNowPlaying();
if (panel.metadb && np && np.Compare(panel.metadb) && np.RawPath.indexOf("file://") == 0 && (!library_tracks_only || fb.IsMetadbInMediaLibrary(np))) {
var ar = panel.tf("%album artist%");
var al = panel.tf("%album%");
var f = folder_tf.EvalWithMetadb(panel.metadb) + _fbSanitise(filename_tf.EvalWithMetadb(panel.metadb));
var tmp = _q(_fbSanitise(ar + al));
var n = _.round(_.now() / 1000);
var t = utils.ReadINI(ini, "Timestamps", tmp, 0);

switch (true) {
case !_tagged(ar):
case !_tagged(al):
case _isFile(f):
case n - t < ONE_DAY:
break;
default:
utils.WriteINI(ini, "Timestamps", tmp, n);
x.open("GET", "https://www.last.fm/music/" + encodeURIComponent(ar) + "/" + encodeURIComponent(al) + "/+images", true);
x.setRequestHeader("If-Modified-Since", "Thu, 01 Jan 1970 00:00:00 GMT");
x.send();
x.onreadystatechange = function () {
if (x.readyState == 4) {
if (x.status == 200) {
var o = _first(_filter(_getElementsByTagName(x.responsetext, "img"), {"className" : "image-list-image"}));
if (o) {
var u = o.src.replace("avatar170s", "ar0");
_runCmd("cscript //nologo " + _q(fb.ProfilePath + "scripts\\SMP\\download.vbs") + " " + _q(u) + " " + _q(f), false);
window.SetTimeout(function () {
panel.item_focus_change();
}, 3000);
}
} else {
console.log("HTTP error: " + x.status);
}
}
}
break;
}
}
RefreshPSS();
}

function RefreshPSS() {
var Refresh_sys = window.GetProperty("Refresh_sys",true);
 if (Refresh_sys < true) {
if (fb.IsPlaying || fb.IsPaused) { 
fb.RunMainMenuCommand("View/Show status bar");
fb.RunMainMenuCommand("View/Show status bar");
} else {
fb.RunMainMenuCommand("View/Show status bar");
fb.RunMainMenuCommand("View/Show status bar");
}
} else {
if (fb.IsPlaying || fb.IsPaused) { 
fb.RunMainMenuCommand("Playback/Play or Pause");
fb.RunMainMenuCommand("Playback/Play or Pause");
} else {
fb.RunMainMenuCommand("Playback/Play");
fb.RunMainMenuCommand("Playback/Stop");
}
}

}

Unfortunately it doesn't crash, therefore I have no idea where the problem is, but it does not download the album cover (doubled checked with the JScript panel version).
Any insight will be much appreciated.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: zeremy on 2019-02-24 15:31:12
@davideleo

Replace line 45 with

Code: [Select]
var o = _.first(_.filter(_getElementsByTagName(x.responseText, "img"), {"className" : "image-list-image"}));

_.first and _.filter are from lodash.js
_getElementsByTagName is from helpers.js

x.responseText is valid (not x.responsetext)



Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-02-24 17:14:42
_.first and _.filter are from lodash.js
_getElementsByTagName is from helpers.js

x.responseText is valid (not x.responsetext)

Thanks so much @zeremy! I was going mad. It works now!
Why wouldn't SMP report an error, though?





Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: zeremy on 2019-02-24 17:26:59
Why wouldn't SMP report an error, though?

It is a known bug.

https://github.com/TheQwertiest/foo_spider_monkey_panel/wiki/Known-bugs
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-02-26 18:06:40
From what I gather, the strict mode defined in the panel does not apply to the scripts processed with the include statement. Is this an intended behaviour?
Not sure, gonna test it out with other JS engines to see how they handle it.

BTW, is the strict mode kind of mandatory with SMP or is it just a scrpting suggestion by the developers? or is it merely the common practice with the latest ECMA versions?
`strict mode` is not mandatory by any means, but it helps avoiding mistakes in the code (via stricter error checking) and might also increase it's performance. So, yes, it is a recommended mode of operation. You can read more about it >>here<< (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode)

I have been experiencing an error on start up in Foobar related to the JS Smooth Browser sample script  in Spider Monkey Panel v1.1.5. See below:
Could you please try the Nightly build (see the link in the first post of this thread) and see if it produces a more intelligible error message?

PS: @zeremy thanks for all the answers in this thread =)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-02-27 21:30:31
Thanks so much @zeremy! I was going mad. It works now!

Seems like I spoke too soon. The script stopped working once again, but I can't tell if I got mistaken when I tested it or if I inadvertently made some changes in foobar2000 that affect SMP's behavior. Whatever is, I fixed it, but I still can't understand why SMP and JSP behave differently.

Here's the script as I'm usinig it now. The patch is marked by a comment:
Code: [Select]
var SettingsPath = fb.ProfilePath + "settings\\";
var library_tracks_only = false;
var folder_tf = fb.TitleFormat("$puts(folder,$trim($replace($lower($directory(%path%)),disc,,cd,)))$replace($directory_path(%path%),$ifequal($strstr($get(folder),$num($get(folder),$len($get(folder)))),1,\\%directoryname%,),)\\");
var filename_tf = fb.TitleFormat("front.jpg");

var panel = new _panel("Last.fm Album Art Downloader", ["metadb", "custom_background"]);
var x = new ActiveXObject("Microsoft.XMLHTTP");
var ini = SettingsPath + "album-art.ini";
_createFolder(SettingsPath);

panel.item_focus_change();

function on_playback_new_track(){   //edit for Spider Monkey Panel
panel.item_focus_change();
}

function on_metadb_changed() {
var np = fb.GetNowPlaying();
console.log("SMP: metadb changed");
console.log("SMP: metadb_func = " + (typeof on_metadb_changed == 'function'));
console.log("SMP: if condition = " + (panel.metadb && np && np.Compare(panel.metadb) && np.RawPath.indexOf("file://") == 0 && (!library_tracks_only || fb.IsMetadbInMediaLibrary(np))));
if (panel.metadb && np && np.Compare(panel.metadb) && np.RawPath.indexOf("file://") == 0 && (!library_tracks_only || fb.IsMetadbInMediaLibrary(np))) {
var ar = panel.tf("$meta_sep(artist,', ',' and ')");
var al = panel.tf("%album%");
var f = folder_tf.EvalWithMetadb(panel.metadb) + _fbSanitise(filename_tf.EvalWithMetadb(panel.metadb));
var tmp = _q(_fbSanitise(ar + al));
var n = _.round(_.now() / 1000);
var t = utils.ReadINI(ini, "Timestamps", tmp, 0);

switch (true) {
case !_tagged(ar):
case !_tagged(al):
case _isFile(f):
case n - t < ONE_DAY:
break;
default:
utils.WriteINI(ini, "Timestamps", tmp, n);
x.open("GET", "https://www.last.fm/music/" + encodeURIComponent(ar) + "/" + encodeURIComponent(al) + "/+images", true);
x.setRequestHeader("If-Modified-Since", "Thu, 01 Jan 1970 00:00:00 GMT");
x.send();
x.onreadystatechange = function () {
if (x.readyState == 4) {
if (x.status == 200) {
var o = _.first(_.filter(_getElementsByTagName(x.responseText, "img"), {"className" : "image-list-image"}));
if (o) {
var u = o.src.replace("avatar170s", "ar0");
_runCmd("cscript //nologo " + _q(fb.ProfilePath + "scripts\\SMP\\download.vbs") + " " + _q(u) + " " + _q(f), false);
window.SetTimeout(function () {
panel.item_focus_change();
}, 3000);
}
} else {
console.log("HTTP error: " + x.status);
}
}
}
break;
}
}
RefreshPSS();
}

function RefreshPSS() {
var Refresh_sys = window.GetProperty("Refresh_sys",true);
 if (Refresh_sys < true) {
if (fb.IsPlaying || fb.IsPaused) { 
fb.RunMainMenuCommand("View/Show status bar");
fb.RunMainMenuCommand("View/Show status bar");
} else {
fb.RunMainMenuCommand("View/Show status bar");
fb.RunMainMenuCommand("View/Show status bar");
}
} else {
if (fb.IsPlaying || fb.IsPaused) { 
fb.RunMainMenuCommand("Playback/Play or Pause");
fb.RunMainMenuCommand("Playback/Play or Pause");
} else {
fb.RunMainMenuCommand("Playback/Play");
fb.RunMainMenuCommand("Playback/Stop");
}
}

}

From what I can understand of marc2003's original script, the code responsible for the download is all in the on_metadb_changed function, but because we want the code to be executed also when a new track is played, the on_metadb_changed function is invoked by the item_focus_change method of the panel object, on line 11. As far as I know this part of the code should be read only on panel start up, but with the console I was able to see that the item_focus_change method is executed on playback of a new track by JSP. So, is this one of those incorrect behaviors tolerated by JSP, but not by SMP? Or is the item_focus_change method triggered by some other event, I thought maybe it could be related to the built-in playcount, which is set differently by default in JSP and SMP?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: zeremy on 2019-02-28 17:20:03
@davideleo

The difference is that JSP panel.js is different from SMP panel.js

Compare the two files and you will see that in JSP panel.js

Code: [Select]
function on_playback_new_track() {
panel.item_focus_change();
}
is defined

In SMP panel.js  it is not defined
Your edit added the missing function.

TIL : When migrating a custom JSP script we should also check its include files.

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-02-28 17:45:08
Compare the two files and you will see that in JSP panel.js

Code: [Select]
function on_playback_new_track() {
panel.item_focus_change();
}
is defined

In SMP panel.js  it is not defined
Your edit added the missing function.

Can you please point me to the relevant code lines? I've been comparing the two panel.js versions for the last two days, but I couldn't find it. I must say the whole panel script is pretty hard for me to read, because of the many cross-references and the use of activex objects that I'm not familiar with.

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: zeremy on 2019-02-28 17:53:58
JSP
https://github.com/marc2k3/foo_jscript_panel/blob/master/foo_jscript_panel/samples/complete/js/panel.js#L15

SMP
https://github.com/marc2k3/smp_2003/blob/a0e578ec06211b1d4b01f529962142bf50a75da5/js/panel.js
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-02-28 18:03:40
JSP
https://github.com/marc2k3/foo_jscript_panel/blob/master/foo_jscript_panel/samples/complete/js/panel.js#L15

SMP
https://github.com/marc2k3/smp_2003/blob/a0e578ec06211b1d4b01f529962142bf50a75da5/js/panel.js


OMG! I can't believe I totally ignored those callabacks  :-[  I was concentrating on the panel object only.
Thanks.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: philodoxxx on 2019-03-05 18:11:15



I have been experiencing an error on start up in Foobar related to the JS Smooth Browser sample script  in Spider Monkey Panel v1.1.5. See below:
Could you please try the Nightly build (see the link in the first post of this thread) and see if it produces a more intelligible error message?

PS: @zeremy thanks for all the answers in this thread =)



 The error is pretty much the same with the nightly build:

Error: Spider Monkey Panel v1.1.6-beta+0191969 (JS Smooth Browser by Br3tt aka Falstaff)
Resize failed:
Failed to create GdiPlus object (0X0): No error

File:
Line: 3500, Column: 24

Stack trace:
  get_images@:3500:24
  oBrowser/this.update@:1526:3
  oBrowser/this.setSize@:1548:3
  on_size@:3120:3
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: zeremy on 2019-03-05 19:28:42
@philodoxxx

Try clearing the Panel Properties
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-03-06 11:13:03
The error is pretty much the same with the nightly build:
Could you try again with the latest Nightly? It should produce a proper error message now.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: zeremy on 2019-03-06 18:20:15
@TheQwertiest

You can reproduce @philodoxxx error if you select Display > Album Art Grid

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-03-06 19:00:19
@TheQwertiest
You can reproduce @philodoxxx error if you select Display > Album Art Grid
Thanks!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-03-09 14:41:24
I noticed on one of my scripts that the on_paint() function always increases memory usage, without releasing it, until eventually foobar2000 has no alternative, but crash. I can't tell if this was happening before switching to SMP, because I never really analysed my scripts in this connection, but the flaw is likely in something I ignore about memory allocation and garbage collection.
I'm posting here the on_paint() code, only, because the complete script is quite long, but if it helps I can post the rest of it. For reference: it's a playlist manager script.

Code: [Select]
function on_paint(gr) {
var PlaylistVisible = (fso.FileExists(SettingsPath + "PlaylistVisible"));
var MenuVisible = fso.FileExists(SettingsPath + "MenuVisible");
VisibleItemsCount = (wh / row_height);
ScrollerHeight = Math.max(wh * VisibleItemsCount / UserPlaylistsCount, 30);
    ScrollerExtension = ScrollerHeight - (wh * VisibleItemsCount / UserPlaylistsCount);
    scrollbar_w = MenuVisible?17:0;
idxStart = Math.max(idxStart, SysPlaylistsCount); 
idxEnd = Math.min(TotalPlaylistsCount, idxStart + Math.ceil(VisibleItemsCount));
var x = gr.CalcTextWidth(" ", font);
    var w = ww - x - scrollbar_w;
var h = row_height;
    for (i = idxStart; i < idxEnd; i++) {       
        var y = row_height*(i - idxStart);
        var MouseHover = (x <= mouse_x) && (mouse_x <= x + w) && (y <= mouse_y) && (mouse_y < y + h);
var ActiveVisible = PlaylistVisible && plman.ActivePlaylist == i;
        var icon = plman.PlayingPlaylist == i && fb.IsPlaying?String.fromCharCode(57369):String.fromCharCode(57368);
        var text = "  " + icon + (MenuVisible?"   " + plman.GetPlaylistName(i):"") + (SHOW_COUNT?" [" + plman.PlaylistItemCount(i) + "]":"");
        var textColor = ActiveVisible?colours.White:offcolour;
        var bgColor = MouseHover?setAlpha(colours.Gray, 60):setAlpha(colours.Black, 0);
        if (!dragging && !scrolling) gr.FillSolidRect(x, y, w, h, bgColor);
        if (ActiveVisible) gr.FillSolidRect(x/2, y, x/2, h, RGBA(255,255,255,255));
gr.GdiDrawText(text, font, textColor, x, y, w, h, IFormat);
        if (dragging && MouseHover) gr.FillSolidRect(x, y + drag_down*row_height, w, 1, offcolour);
        }
       
    scrollbar_y = (idxStart - SysPlaylistsCount) * (wh - ScrollerExtension) / UserPlaylistsCount;   
   
    gr.SetSmoothingMode(1);
    if (MenuVisible && (scrollbar || (SCROLLBAR_MODE == 0))) gr.FillRoundRect(ww - scrollbar_w, scrollbar_y, scrollbar_w, ScrollerHeight, 1, 1, RGBA(255,255,255,100));
    gr.SetSmoothingMode(0);  
}

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-03-11 14:26:45
@philodoxxx Thanks for the bug report! It will be fixed in the next release, in the meantime you can apply the following fix manually - https://github.com/TheQwertiest/foo_spider_monkey_panel/pull/62/files

I noticed on one of my scripts that the on_paint() function always increases memory usage, without releasing it...
Doesn't look like there is anything that could cause a memory leak in your code. To diagnose the issue I need the full (i.e. working) sample. Ideally it should be stripped down as much as possible =)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-03-11 14:29:34
[EDIT] Accidental double-post
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-03-11 18:08:11
To diagnose the issue I need the full (i.e. working) sample. Ideally it should be stripped down as much as possible =)

If you mean the whole script, here it is:
Code: [Select]
'use strict';

window.DefinePanel('YouFy Playlist Manager', {author:'davideleo'});
include(fb.ComponentPath + 'docs\\Flags.js');
include(fb.ComponentPath + 'docs\\Helpers.js');
include(fb.ProfilePath + 'scripts\\SMP\\YouFy common.js');

var i = 0;
var SysPlaylistsCount = 0;
var UserPlaylistsCount = 0;
var TotalPlaylistsCount = 0
var idxStart = 0;
var idxEnd = 0;
var idxFrom = -1;
var idxTo = -1;
var mouse_x = -1;
var mouse_y = -1;
var dragging = false;
var scrollbar = false;
var scrolling = false;
var SCROLLBAR_MODE = window.GetProperty("Scrollbar Mode", 2); //0=always, 1=never, 2=auto hide
var SHOW_COUNT = window.GetProperty("Show TrackCount", true);
var row_height = Number(ReadSettingsValue("RowHeight", 45));
var DPI = ReadSettingsValue("DPI", 96);
var iconfont = ReadSettingsValue("iconfont","youfy mdl2 assets");
var font_size = 16;
var font_height = font_size * DPI / 72;   
var font = gdi.Font(iconfont, font_height, 0);
var IFormat = DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOPREFIX;
count_playlists();


function on_size() {
    ww = window.Width;
    wh = window.Height;
}


function on_paint(gr) {
var PlaylistVisible = (fso.FileExists(SettingsPath + "PlaylistVisible"));
var MenuVisible = fso.FileExists(SettingsPath + "MenuVisible");
VisibleItemsCount = (wh / row_height);
ScrollerHeight = Math.max(wh * VisibleItemsCount / UserPlaylistsCount, 30);
    ScrollerExtension = ScrollerHeight - (wh * VisibleItemsCount / UserPlaylistsCount);
    scrollbar_w = MenuVisible?17:0;
idxStart = Math.max(idxStart, SysPlaylistsCount); 
idxEnd = Math.min(TotalPlaylistsCount, idxStart + Math.ceil(VisibleItemsCount));
var x = gr.CalcTextWidth(" ", font);
    var w = ww - x - scrollbar_w;
var h = row_height;
    for (i = idxStart; i < idxEnd; i++) {       
        var y = row_height*(i - idxStart);
        var MouseHover = (x <= mouse_x) && (mouse_x <= x + w) && (y <= mouse_y) && (mouse_y < y + h);
var ActiveVisible = PlaylistVisible && plman.ActivePlaylist == i;
        var icon = plman.PlayingPlaylist == i && fb.IsPlaying?String.fromCharCode(57369):String.fromCharCode(57368);
        var text = "  " + icon + (MenuVisible?"   " + plman.GetPlaylistName(i):"") + (SHOW_COUNT?" [" + plman.PlaylistItemCount(i) + "]":"");
        var textColor = ActiveVisible?colours.White:offcolour;
        var bgColor = MouseHover?setAlpha(colours.Gray, 60):setAlpha(colours.Black, 0);
        if (!dragging && !scrolling) gr.FillSolidRect(x, y, w, h, bgColor);
        if (ActiveVisible) gr.FillSolidRect(x/2, y, x/2, h, RGBA(255,255,255,255));
gr.GdiDrawText(text, font, textColor, x, y, w, h, IFormat);
        if (dragging && MouseHover) gr.FillSolidRect(x, y + drag_down*row_height, w, 1, offcolour);
        }
       
    scrollbar_y = (idxStart - SysPlaylistsCount) * (wh - ScrollerExtension) / UserPlaylistsCount;   
   
    gr.SetSmoothingMode(1);
    if (MenuVisible && (scrollbar || (SCROLLBAR_MODE == 0))) gr.FillRoundRect(ww - scrollbar_w, scrollbar_y, scrollbar_w, ScrollerHeight, 1, 1, RGBA(255,255,255,100));
    gr.SetSmoothingMode(0);  
}


function on_mouse_move(x, y) {
drag_down = y >= mouse_y;
    mouse_x = x;
    mouse_y = y;
    scrollbar = (UserPlaylistsCount > VisibleItemsCount && SCROLLBAR_MODE != 1);   
    if(scrolling){
        scrollbar_y = Math.max(exScrollbar_y + y - lbtn_down_y, 0);
        if(scrollbar_y + ScrollerHeight > wh) scrollbar_y = wh - ScrollerHeight;
        idxStart = Math.floor(scrollbar_y * UserPlaylistsCount  / (wh - ScrollerExtension)) + SysPlaylistsCount;
        if(idxStart > TotalPlaylistsCount - VisibleItemsCount) idxStart = TotalPlaylistsCount - VisibleItemsCount;
    }
window.Repaint();   
}
 

function on_mouse_lbtn_down(x, y){  
    if(x > ww - scrollbar_w) {
        if(y > scrollbar_y && y < scrollbar_y + ScrollerHeight) {
            exScrollbar_y = scrollbar_y;
            lbtn_down_y = y;
            scrolling = true;
        } else {
            if (y < scrollbar_y) idxStart = Math.max(idxStart - VisibleItemsCount,0);
            if (y > scrollbar_y + ScrollerHeight) idxStart = Math.min(idxStart + VisibleItemsCount, TotalPlaylistsCount - VisibleItemsCount);
        }
    } else {
        idxFrom = GetPlaylistIdx(y);
        plman.ActivePlaylist = idxFrom;
        fso.CreateTextFile(SettingsPath + "PlaylistVisible").Close();
        if (plman.GetPlaylistName(plman.ActivePlaylist)){
            WriteSettingsValue("ActivePlaylist",plman.GetPlaylistName(plman.ActivePlaylist));
            WriteSettingsValue("PlaylistType",plman.IsAutoPlaylist(plman.ActivePlaylist)?"Autoplaylist":"Playlist");
        }
        RefreshPSS();
        dragging = true;
mouse_y = y;
    }
    window.Repaint();
}


function on_mouse_leave() {
    mouse_x = -1;
    mouse_y = -1;
    scrollbar = false;
    window.Repaint();
}


function on_mouse_lbtn_up(x, y){
    idxTo = GetPlaylistIdx(y);
    if (dragging) plman.MovePlaylist(idxFrom,idxTo);
    dragging = false;
    scrolling = false;
    window.Repaint();
    RefreshPSS();
}


function on_mouse_lbtn_dblclk(x, y){
    if(x < ww - scrollbar_w){
plman.PlayingPlaylist = GetPlaylistIdx(y);
fb.Play();
window.Repaint();
    }
}


function on_mouse_rbtn_down(x, y, mask){
    var idx = GetPlaylistIdx(y);
    var ContextMenu = window.CreatePopupMenu();
    var _ScrollbarOption = window.CreatePopupMenu();
    ContextMenu.AppendMenuItem(MF_STRING, 1, "Rename...");
    ContextMenu.AppendMenuItem(MF_STRING, 2, "Remove");
    ContextMenu.AppendMenuItem(MF_STRING, 3, "Save...");
    ContextMenu.AppendMenuItem(MF_STRING, 11, "Move to top");
    ContextMenu.AppendMenuItem(MF_STRING, 12, "Move to bottom");
    ContextMenu.AppendMenuSeparator();
    if (plman.IsAutoPlaylist(idx)){
        ContextMenu.AppendMenuItem(MF_STRING, 4, "AutoPlaylist Format");
        ContextMenu.AppendMenuSeparator();
    }
    ContextMenu.AppendMenuItem(MF_STRING, 5, "Show Track Count");
    ContextMenu.CheckMenuItem(5, SHOW_COUNT?1:0);
    _ScrollbarOption.AppendTo(ContextMenu,0, "Show Scrollbar");
    _ScrollbarOption.AppendMenuItem(MF_STRING, 6, "Always");
    _ScrollbarOption.AppendMenuItem(MF_STRING, 7, "Never");
    _ScrollbarOption.AppendMenuItem(MF_STRING, 8, "Auto Hide");  
    _ScrollbarOption.CheckMenuRadioItem(6,8,SCROLLBAR_MODE + 6);
    if (mask == 6||mask == 14){
        ContextMenu.AppendMenuSeparator();
        ContextMenu.AppendMenuItem(MF_STRING, 9, "Properties");
        ContextMenu.AppendMenuItem(MF_STRING, 10, "Configure...");
    }
   
    if(idx != null){
        switch(ContextMenu.TrackPopupMenu(x, y, 0)){
            case 1:
            plman.ActivePlaylist = idx;
            fb.RunMainMenuCommand("File/Rename Playlist") ;
            break;
           
            case 2:
            plman.RemovePlaylist(idx);
UserPlaylistsCount = TotalPlaylistsCount - SysPlaylistsCount;
            plman.ActivePlaylist = Math.min(idx, UserPlaylistsCount - 1);
            window.Repaint();
            break;
           
            case 3:
            plman.ActivePlaylist = idx;
            fb.SavePlaylist();
            break;
           
            case 4:
            plman.ShowAutoPlaylistUI(idx);
            break;
           
            case 5:
            SHOW_COUNT = !SHOW_COUNT;
            window.SetProperty("Show TrackCount", SHOW_COUNT);
            ContextMenu.CheckMenuItem(5, SHOW_COUNT);
            window.Repaint();
            break;
           
            case 6:
            SCROLLBAR_MODE = 0;
            window.SetProperty("Scrollbar Mode", 0);
            _ScrollbarOption.CheckMenuRadioItem(6,8,6);               
            break;
           
            case 7:
            SCROLLBAR_MODE = 1;
            window.SetProperty("Scrollbar Mode", 1);
            _ScrollbarOption.CheckMenuRadioItem(6,8,7);
            break;
           
            case 8:
            SCROLLBAR_MODE = 2;
            window.SetProperty("Scrollbar Mode", 2);
            _ScrollbarOption.CheckMenuRadioItem(6,8,8);
            break;
           
            case 9:
            window.ShowProperties()
            break;
           
            case 10:
            window.ShowConfigure();
            break;
           
            case 11:
            plman.MovePlaylist(idx, SysPlaylistsCount);
            window.Repaint();
            break;
           
            case 12:
            plman.MovePlaylist(idx, TotalPlaylistsCount - 1);
            window.Repaint();
            break;
           
            default:     
            break;
        }
    }
}


function on_drag_over(action, x, y, mask){
    mouse_x = x;
    mouse_y = y;
window.Repaint(); 
}


function on_drag_drop(action, x, y) {
var idx = GetPlaylistIdx(y);
action.Playlist = idx;
action.ToSelect = false;
plman.ActivePlaylist = idx;
}


function on_playlists_changed() {
count_playlists();
window.Repaint();
}


function on_notify_data(name, info) {
    switch(name) {
        case "refresh":
        window.Repaint();
RefreshPSS();
        break;
        case "row height":
        row_height = info;
        window.Repaint();
        break;
    }
}


function GetPlaylistIdx(y) {
    return Math.floor(y / row_height) + idxStart;
}


function count_playlists(){         //system playlists are prefixed with a "#" and must be hidden from the playlist manager.
TotalPlaylistsCount = plman.PlaylistCount;
SysPlaylistsCount = 0;
for (i = 0; i < TotalPlaylistsCount; i++) {              
if (plman.GetPlaylistName(i).search("#") == 0) {
if (i > SysPlaylistsCount) plman.MovePlaylist(i, SysPlaylistsCount);
SysPlaylistsCount = SysPlaylistsCount + 1;
}
}
UserPlaylistsCount = TotalPlaylistsCount - SysPlaylistsCount;
}

If you really are willing to review my script (in which case I'd be eternally grateful), for completeness here's also the preprocessed "YouFy common" script:
Code: [Select]
// *****************************************************************************************************************************************
// Additional functions & flags for the YouFy skin
// *****************************************************************************************************************************************

var fso = new ActiveXObject("Scripting.FileSystemObject");
var SettingsPath = fb.ProfilePath + "settings\\";
var SkinPath = fb.ProfilePath + "skins\\YouFy\\";
var ImagesPath = fb.TitleFormat("%images_path%").Eval(true) + "\\";
var ThumbsPath = ImagesPath + "thumbs\\";
var BackgroundPath = ImagesPath + "background\\";
var offcolour = RGB(120,120,120);


function ReadSettingsValue(folder,default_value) {
   if (!fso.FolderExists(SettingsPath)) fso.CreateFolder(SettingsPath);
   var FolderPath = SettingsPath + folder +"\\";
   if(!fso.FolderExists(FolderPath)) {
      WriteSettingsValue(folder,default_value);
      return default_value;  
   } else {
      var FolderObj = fso.GetFolder(FolderPath);
      var FolderEnumerator = new Enumerator(FolderObj.Files);
      if(fso.FileExists(FolderEnumerator.item(1))) {
          return FolderEnumerator.item(1).Name;
        } else {
WriteSettingsValue(folder,default_value);
return default_value
        }
   }
}


function WriteSettingsValue(folder,value) {
   if (!fso.FolderExists(SettingsPath)) fso.CreateFolder(SettingsPath);
   var FolderPath = SettingsPath + folder;  
   if(fso.FolderExists(FolderPath)) {
       var FolderObj = fso.GetFolder(FolderPath);
       var FolderEnumerator = new Enumerator(FolderObj.Files);
       for (var i = 1; i < FolderObj.Files.Count + 1; i++) {
           fso.DeleteFile(FolderEnumerator.item(i));
       }
   } else {
       fso.CreateFolder(FolderPath);
   }
   fso.CreateTextFile(FolderPath + "\\" + value).Close();
}


function RefreshPSS() {
var Refresh_sys = window.GetProperty("Refresh_sys",true);
 if (Refresh_sys < true) {
if (fb.IsPlaying || fb.IsPaused) { 
fb.RunMainMenuCommand("View/Show status bar");
fb.RunMainMenuCommand("View/Show status bar");
} else {
fb.RunMainMenuCommand("View/Show status bar");
fb.RunMainMenuCommand("View/Show status bar");
}
} else {
if (fb.IsPlaying || fb.IsPaused) { 
fb.RunMainMenuCommand("Playback/Play or Pause");
fb.RunMainMenuCommand("Playback/Play or Pause");
} else {
fb.RunMainMenuCommand("Playback/Play");
fb.RunMainMenuCommand("Playback/Stop");
}
}

}


function Get_taskbar_colour() {
    var Shell = new ActiveXObject("WScript.Shell");
    if (Shell.RegRead("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize\\ColourPrevalence")) {
        if (Shell.RegRead("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize\\EnableTransparency")) {
            return AccentPalette(7);
            } else {
            return AccentPalette(6);
        }  
        } else {
        if (Shell.RegRead("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize\\EnableTransparency")) {
            return "0-0-0";
            } else {
            return "16-16-16";
        }
    }
}


function AccentPalette(item) {
    var Shell = new ActiveXObject("WScript.Shell");
    item = item -1;
    AccentPaletteArray = Shell.RegRead("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Accent\\AccentPalette");
//  return AccentPaletteArray[4*item] + "-" + AccentPaletteArray[1+4*item] + "-" + AccentPaletteArray[2+4*item];
    return RGB(AccentPaletteArray[4*item], AccentPaletteArray[1+4*item], AccentPaletteArray[2+4*item]);
}


function Get_dpi() {
    var Shell = new ActiveXObject("WScript.Shell");
return Shell.RegRead("HKEY_CURRENT_USER\\Control Panel\\Desktop\\WindowMetrics\\AppliedDPI");
}

var library_items = fb.GetLibraryItems();


function list_values(tag, handle_list = library_items, query = tag + " PRESENT", split = true){
var tags = [];
var items = fb.GetQueryItems(handle_list, query)
for (var i = 0; i < items.Count; i++) {
var handle = items[i];
var meta_num = fb.TitleFormat("$meta_num(" + tag + ")").EvalWithMetadb(handle);
for (var j = 0; j < meta_num; j++) {
tags.push(fb.TitleFormat("$meta(" + tag + "," + j + ")").EvalWithMetadb(handle));
}
}
fb.ShowPopupMessage(_.uniq(tags.sort(), true).join("\n"));
}



All in all the script works fluently and the on_paint routine doesn't actually use much memory. What leaves me perplexed is that it is never released. Why would that even happen, unless something's not working properly with the GC?


P.S.
I also wanted to explain that I realized the issue was with the on_paint function because the on_mouse_move function always triggers a repaint. By simply moving the mouse over the panel, the memory increases. After commenting out the repaint instruction, moving the mouse over the panel doesn't increase memory usage by one byte.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-03-11 19:47:51
I also wanted to explain that I realized the issue was with the on_paint function because the on_mouse_move function always triggers a repaint. By simply moving the mouse over the panel, the memory increases. After commenting out the repaint instruction, moving the mouse over the panel doesn't increase memory usage by one byte.

I uploaded a short video (https://www.dropbox.com/s/p1yrvbnytaq5b66/2019-03-11%2020-30-51.mp4?dl=0) to show what I mean (and maybe it is also of help to who is willing to take a look at my script).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: philodoxxx on 2019-03-11 20:39:49
@philodoxxx Thanks for the bug report! It will be fixed in the next release, in the meantime you can apply the following fix manually - https://github.com/TheQwertiest/foo_spider_monkey_panel/pull/62/files

Thank you. Switching out those few lines in the script did indeed fix the issue. Regards.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-03-12 10:24:50
@davideleo your script looks like this for me
Spoiler (click to show/hide)
And there were no apparent memory leaks :\
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-03-12 13:41:22
@davideleo your script looks like this for me
Yes, that's because you are missing the "Youfy MDL2 assets" font, which is a collage-font I put together for this skin. Actually there are also a few variables which take their value from text files created by another script.


And there were no apparent memory leaks :\
So, that's a clue, isn't it? Doesn't it close in on the interaction with other scripts or components? I actually already tested it without the black sheep of foobar2000's plug-ins, foo_customdb, but nothing changed.
What about the GC settings in the advanced preferences? Should I  mess around with them?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-03-12 16:02:38
I tested all of my scripts and it turned out it's a general problem. Every on_paint() function seems to increase memory and never release it. Even worse is that there is likely an on_playback_newtrack() function with the same problem, but I still didn't find out which one. That means my foobar2000 is bound to crash sooner or later at every session, even if I don't touch it.
What really put me down is that I also tested the only script I have by another author (marc2003's Last.fm Bio) and guess what? No memory leak at all. This is the proof that the problem is in my scripting.

@TheQwertiest when you write that there were no apparent memory leaks, do you mean that triggering the on_mouse_move() doesn't increase memory usage or that the memory increase is then released? BTW thanks a lot for taking a look.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: juniiflow on 2019-03-13 10:14:47
Anyone knows a quick way to remove or move the now playing arrow on j smooth?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Strigoy on 2019-03-13 12:58:06
Uh, this 'Edit' menu problem drives me nuts )) I don't get it, why this happens (this only affects 'Edit' submenu, others work just fine):

(https://i.imgur.com/7NQBTxp.png)

but if I use default Menu everything works just fine =>

(https://i.imgur.com/fnDOzg7.png)

I'm using snippet from MainMenuManager All-In-One.js

Speaking of which: I got couple of questions:
1)
Code: [Select]
contextman.InitNowPlaying(); 
this is getting called twice for some reason

2)
Am I MisSinG SoMetHing wItH thE CasE herE?
Code: [Select]
    menuman1.Init('file');
    menuman2.Init('edit');
    menuman3.Init('View');
    menuman4.Init('playback');
    menuman5.Init('library');
    menuman6.Init('help');
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Strigoy on 2019-03-13 21:54:14
Nevermind, guh... I've spent so much time trying to figure it out, but the problem was with panel settings... just unchecked 'grab focus' and it's working as intended.

My god, that's so silly...
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-03-14 12:25:39
Uh, this 'Edit' menu problem drives me nuts )) I don't get it, why this happens (this only affects 'Edit' submenu, others work just fine):
Not sure what's going on here - it works fine for me (both with `Grab Focus` enabled and disabled).

1) this is getting called twice for some reason
2) Am I MisSinG SoMetHing wItH thE CasE herE?
Because reasons :D
Those are just typos.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-03-14 16:40:17
@davideleo your script looks like this for me
Spoiler (click to show/hide)
And there were no apparent memory leaks :\

I tested my script on a clean installation with no other plug-in, but spider monkey panel. The memory leak was more than apparent. How did you test it?
I really need to get to the bottom of this problem, because it is making spider monkey panel unusable for me.


P.S.
BTW, on a clean installation I realized that the reason for that appearance is that the script does not find the "MenuVisible" file (without extension) in the "settings" folder inside the foobar2000 configuration folder. It is normally created by another script.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-03-14 18:12:21
P.P.S.
I tested some of the sample scripts to see if I could find at least one with a similar behaviour. Eventually I found that the "track info + seekbar + buttons" by marc2003 increases memory usage by 0,8-9 MB at every button click without releasing it, but it looks like marc2003 managed the issue, because it is released when (and apparently only if) the total memory delta is around 20MB.

EDIT
I made a mistake: it's not the button click that increases memory, but the playback state change, triggered by the button click.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-03-14 23:58:52
I made some steps forward in my inquiry on the memory-greedy script.

First of all I realized that memory usage increases only when several repaint actions are executed sequentially at close intervals, therefore I managed to lessen its impact by limiting the repaint action to when it is actually required, rather than on any on_mouse_move event.

That didn't solve the issue, though, and if I move the mouse very quickly, over the panel, I can still reproduce it, even if it takes longer to reach dangerous levels.

Anyway, I finally tested the same script on a JScript panel, on the same clean installation of the Spider Monkey panel. Here (https://www.dropbox.com/s/0yci9nfctu70cx6/2019-03-14%2023-38-45.mp4?dl=0)'s what happened (yes, I know I look like a weirdo). I moved the mouse up and down on the JScript panel for about one minute and - as you can see in the task manager - the memory level is stuck on 677,2 MB. There is only a slight increase towards the end, released right after. The same action on the Spider Monkey panel immediately starts raising the memory in use and after one minute it's well over 680 MB.

Sorry if I sound obsessed, but since I'm still learning javascript, it's very important for me to understand what I didn't get right, before I move on to more advanced scripting.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-03-15 09:08:25
but it looks like marc2003 managed the issue, because it is released when (and apparently only if) the total memory delta is around 20MB.
That's just GC kicking in - it has several triggers, one of which is the amount of allocated memory. I.e. you don't have to `Dispose` anything manually in 99.9% cases in SMP.

What about the GC settings in the advanced preferences? Should I  mess around with them?
You should not =)

when you write that there were no apparent memory leaks, do you mean that triggering the on_mouse_move() doesn't increase memory usage or that the memory increase is then released? BTW thanks a lot for taking a look.
The memory increase is minuscule and it's not permanent - it's  cleaned up properly after sometime with GC (i.e. it's not a leak).

[EDIT] Can you download the debug version of SMP and enable GC zeal and check if memory is still leaking for you?
Debug version: https://ci.appveyor.com/api/buildjobs/rylakh87w1kuotm2/artifacts/_result%2FWin32_Debug%2Ffoo_spider_monkey_panel.fb2k-component_debug
GC Zeal: Preferences > Advanced > Display > Spider Monkey Panel > GC > Zeal > Enable
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-03-15 12:59:12
@davideleo you can also try the latest Nightly build (which is available via link in OP) - I might have fixed the leak there.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-03-15 14:11:18
With the nightly build (1.1.6-beta+80ac164) the behavior is unchanged and when I try installing the debug version I get this message:
Quote
Failed to load DLL: foo_spider_monkey_panel.dll
Reason: This component is missing a required dependency, or was made for different version of foobar2000.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-03-15 15:53:14
With the nightly build (1.1.6-beta+80ac164) the behavior is unchanged...

I think it was not the latest version. Anyway I just tried  1.1.6-beta+f3d6584 and it behaves in the same way.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-03-15 15:54:10
With the nightly build (1.1.6-beta+80ac164) the behavior is unchanged
Are you sure? Note that GC does not kick in immediately, that is 10mb of allocated memory is not enough to trigger GC. Try reaching 100mb of allocations.

This component is missing a required dependency, or was made for different version of foobar2000
I will send you a PM with missing dlls later this evening or tomorrow.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-03-15 20:25:07
Are you sure? Note that GC does not kick in immediately, that is 10mb of allocated memory is not enough to trigger GC. Try reaching 100mb of allocations.

You are right! I gave the job to a timer, set to execute the repaint action once every millisecond. Right after startup, foobar2000 was using 677MB. After about 7 minutes the GC kicked in and memory usage dropped from 825MB to 690MB. I didn't clear the timer the first time and watched it repeat the cycle with the exact same values.
Just to make sure I tested the release version, too, and to my surprise it performed even better, dropping from 820MB to 687MB.
That's quite encouraging, even though I don't really understand why a script like mine would use so much memory for what to me looks basically like reassigning already allocated variables.



I will send you a PM with missing dlls later this evening or tomorrow.

Thanks a lot, I really appreciate your attention.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-03-16 12:06:53
I don't really understand why a script like mine would use so much memory for what to me looks basically like reassigning already allocated variables

GC is tuned for the best performance with multiple active SMP panels and heavy-allocating scripts, so it might be not aggressive enough for simple (that is light-allocating) scripts. That said, your case helped me to discover a bug, which made GC to be more lenient with memory allocation than it should've been. You can check out the fix with the latest Nightly build =)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-03-16 17:10:51
You can check out the fix with the latest Nightly build =)

I just tested the script with beta version 2fdc8be and it behaves similarly, perhaps slightly worst: GC kicked in at 835MB (higher threshold than beta f3d6584) and dropped to 694MB (higher residual than beta f3d6584).
The fact remains that with JScript panel the same script does not raise memory usage at all. I recorded one more video (https://www.dropbox.com/s/p6fn2aj9odp7bcb/2019-03-16%2017-04-44.mp4?dl=0) which shows the task manager while two identical foobar2000 installations run the same script, one with JScript panel and one with Spider Monkey panel. The timer is set on start-up, and the two installations are launched simultaneously. Mind that no dispose() method was added in the JScript panel version.



GC is tuned for the best performance with multiple active SMP panels and heavy-allocating scripts, so it might be not aggressive enough for simple (that is light-allocating) scripts.

I'm a bit puzzled now: is JScript panel better tuned for light-allocating scripts? Is it more advisable for simple ones like mine?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-03-17 22:39:09
I just tested the script with beta version 2fdc8be and it behaves similarly
Hm... That's weird... I'm currently reworking GC a bit, so hopefully the memory usage will go down with next builds.

The fact remains that with JScript panel the same script does not raise memory usage at all.
Because JSP does not have GC at all, which has it advantages like never using more memory than currently needed, but at the cost of the performance. See the following post for a bit more info and performance trade-off example: https://hydrogenaud.io/index.php/topic,116669.msg963036.html#msg963036

I'm a bit puzzled now: is JScript panel better tuned for light-allocating scripts? Is it more advisable for simple ones like mine?
I've never said anything like that. SMP and JSP are different beasts with different memory allocation policies. SMP uses (generally) more memory than JSP, but provides enhanced performance and smoother UX instead.
What I did say, is that I tuned SMP GC policies for more heavy scripts. So, while it uses more memory with light scripts than it could've (i.e. it would accumulate more memory before purging it), it consumes CPU time drastically less with heavy scripts than it would've otherwise (which results in smoother UX and etc and etc).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-03-18 20:59:57
I've never said anything like that. SMP and JSP are different beasts with different memory allocation policies. SMP uses (generally) more memory than JSP, but provides enhanced performance and smoother UX instead.
What I did say, is that I tuned SMP GC policies for more heavy scripts. So, while it uses more memory with light scripts than it could've (i.e. it would accumulate more memory before purging it), it costumes CPU time drastically less with heavy scripts than it would've otherwise (which results in smoother UX and etc and etc).

I see, that makes sense, thanks for the explanation. I couldn't quite relate it to what I's experiencing because other heavy-looking scripts by professional coders didn't increase memory usage as much and my fear was that I was ignoring some basic good practice in my scripts. Eventually I found at least one professional script with a much bigger impact on memory and that reassured me a bit.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-03-19 15:01:43
@davideleo Please try the latest build again.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-03-20 14:34:04
I'm testing beta 6cc1cbd. The memory increases at a similar pace than the previous ones, but apparently GC comes round more often and with a smaller truck.
With foobar2000 starting up at 670-680 MB, beta 2fdc8be and the stable release both need at least 825-835 MB (but today it was 850-860 MB, just to make things more random!) before dropping to more or less 700 MB. Beta 6cc1cbd drops from 800-810 MB to 760 MB.
My two cents: by looking at the first cycle only, it would seem a lot better. I wonder, though, whether a higher garbage residual means that, on the long run, the average memory usage is bound to increase more rapidly. What is also hard to tell is how multiple panels, working together in a real usage set up, would actually perform: analytically speaking the single panel is better off with a lower peak, but a higher residual means that the overall uncollected garbage level is generally higher. So, except for the very rare case of all scripts approaching their memory cap at the same time, I can't tell really which one is more advisable.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-03-20 15:53:02
With foobar2000 starting up at 670-680 MB, beta 2fdc8be and the stable release both need at least 825-835 MB (but today it was 850-860 MB, just to make things more random!) before dropping to more or less 700 MB. Beta 6cc1cbd drops from 800-810 MB to 760 MB.
Mind though, that you should differentiate between total memory usage (i.e. via task manager) and SMP memory usage (via `window.TotalMemoryUsage`).

What is also hard to tell is how multiple panels, working together in a real usage set up, would actually perform: analytically speaking the single panel is better off with a lower peak, but a higher residual means that the overall uncollected garbage level is generally higher
Whatever the case it should not `leak` anymore. That is, SMP average memory usage should stay mostly the same.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-03-20 20:37:40
Whatever the case it should not `leak` anymore. That is, SMP average memory usage should stay mostly the same.

I monitored the memory values for over 2 hours (not literally, I recorded 2 hours of task manager and then scrolled the frames through) because I was curious of the GC behavior on the long run, so now I have a bigger picture. The new beta stabilizes already after the first GC action, whereas the previous beta and the stable release keep on raising the baseline - and to a lesser extent the peak level - for over one hour! That's a long time and if you don't know it will come to an end, it really looks like a bad memory leak. The comparison I made above did not take this into account: I compared the stabilized memory baseline of the new beta with the still growing baseline of the other two. Once the values are stable, the winner is the new beta by all means.


Mind though, that you should differentiate between total memory usage (i.e. via task manager) and SMP memory usage (via `window.TotalMemoryUsage`).
You shouldn't have told me. Now I know what I'll do in the next days.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-03-20 20:46:39
And now for something completely different: is it possible to read and edit the search pattern of an autoplaylist via JScript?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Ottodix on 2019-03-21 09:17:26
And now for something completely different: is it possible to read and edit the search pattern of an autoplaylist via JScript?

Yep :) plman.ShowAutoPlaylistUI(pl_idx);
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-03-21 14:57:29
Yep :) plman.ShowAutoPlaylistUI(pl_idx);

As far as I know that opens the autoplaylist properties dialog window. I want to read (and possibly edit) the query pattern by code.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-03-21 15:26:19
And now for something completely different: is it possible to read and edit the search pattern of an autoplaylist via JScript?
fb2k does not provide such API, so neither SMP nor JSP have this feature.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-04-03 17:12:29
I apologize for the lack of updates (and the promised fixes), so here is a bit info to those who care(^^):
Recently my motivation suffered a huge blow from Mozilla and it's shenanigans, which (coupled with my usual lack of free time) mostly stalled any progress on the next SMP release. Hopefully, the motivation will restore itself (at least partially) soon enough, but it may take some time...
Regardless, the current SMP version (and the nightly build as well) should be stable enough to last till the new release =)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-04-03 18:20:19
No need to apologize: as far as I remember, hardly any component has had the support you've been providing so far.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: WilB on 2019-04-03 18:47:50
@TheQwertiest
Code: [Select]
huge blow from Mozilla and it's shenanigans

That's disappointing news & hopefully not too restrictive in the future. All your excellent hard work & effort is much appreciated on this marvellous plug-in.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: wcs13 on 2019-04-20 17:51:41
Hi everybody,
So this may be the successor of the excellent JScript Panel ! Great news !
Is there an updated list of the already-compatible scripts, with the corresponding codes ? That would help a lot.
I'm thinking about marc2003 scripts... Plus WilB's Biography View... etc..
Thanks.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-04-20 22:28:38
Is there an updated list of the already-compatible scripts, with the corresponding codes ?
There is no such list (yet?).
All WilB's script are SMP compatible though.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-04-20 22:33:47
@davideleo , @WilB , thanks for your kind words and support, really appreciated =)

That's disappointing news & hopefully not too restrictive in the future.
It was not anything really huge (like DMCA), but rather the state of the current and the future support of Mozilla SpiderMonkey embeddings...
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-04-22 17:15:22
Version: 1.2.0
Link: https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/tag/v1.2.0
Changelog:
Spoiler (click to show/hide)
Detailed description of API changes: https://github.com/TheQwertiest/foo_spider_monkey_panel/wiki/API-Changes#v120
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kutuzof on 2019-04-23 15:03:23
https://drive.google.com/open?id=1Me4EUu65bn9vCJ4E1ZUgubPx48DaHXqK
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-04-23 19:16:46
@kutuzof , can you try the latest Nightly build and see if it fixes the freeze?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: louiscoim on 2019-04-23 20:41:28
Hello TheQwertiest, and everybody else, off course..

I have very simple question:

Is there a way to port WSH Coverflow  to an SMP Script?

I mean, I know Chronial's Coverflow or even Bubble Coverflow are more advanced components, but my PC doesn't support them as
I get the pixelformat error because of my old Intel HD graphics chip.. I tried everything possible to fix this issue (from drivers to installing open EL/GL solutions)..
If it isn't possible, no need to tell me why, I don't know much about scripting and I must say that: I admire a lot Your work and think it's awesome!!

Anyway, Thanks in Advance.

Peace
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kutuzof on 2019-04-24 07:39:49
@kutuzof , can you try the latest Nightly build and see if it fixes the freeze?

Thanks, I tried the nightly build, while it seems to work well.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-04-24 16:35:15
Version: 1.2.1
Link: https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/tag/v1.2.1
Changelog
Hotfix for v1.2.0 (see changelog above (https://hydrogenaud.io/index.php/topic,116669.msg970630.html#msg970630))
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-04-24 17:09:04
How safe is it to add custom methods and properties to default SMP objects?

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-04-24 18:53:04
Never tried, but should be probably safe (if it works :D), since all SMP objects are proper JS objects. Obviously there are some limitations - e.g. you can't make a deep copy of (most) SMP objects (unless it's stated explicitly otherwise in docs).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: acmodeu on 2019-04-24 21:05:30
Tried to migrate to Spider Monkey. Added volume bar from https://github.com/timonwong/foo_uie_wsh_panel_mod/blob/master/samples/Volbar%20with%20GdiDrawText.txt
Got this on gr.FillGradRect(  0, 0, pos , wh, 90, RGB(240,240,240), RGB(46,48,63));

Code: [Select]
Error: Spider Monkey Panel v1.2.1 (MyScript v1.2.3 by Me)
FillGradRect failed:
GdiPlus error: SetBlendTriangularShape failed with error (0X2): InvalidParameter

File: <main>
Line: 45, Column: 2

Stack trace:
  on_paint@<main>:45:2
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-04-24 21:42:10
Tried to migrate to Spider Monkey. Added volume bar from https://github.com/timonwong/foo_uie_wsh_panel_mod/blob/master/samples/Volbar%20with%20GdiDrawText.txt
Got this on gr.FillGradRect(  0, 0, pos , wh, 90, RGB(240,240,240), RGB(46,48,63));


I think the error is generated when the width argument is equal to 0, that is when "pos" is equal to "ww". I guess you have to manage that eventuality with something like:
Code: [Select]
line 51         if (pos != ww) gr.FillGradRect(pos, 0, ww - pos, wh, 90, RGB(240, 240, 240), RGB(190, 190, 190));


P.S.
I just realized you got the error on the previous FillGradRect function, on line 50. Obviously the same applies to both:

Code: [Select]
    if (pos != 0) gr.FillGradRect(0, 0, pos, wh, 90, RGB(240, 240, 240), RGB(100, 230, 100));
    if (pos != ww) gr.FillGradRect(pos, 0, ww - pos, wh, 90, RGB(240, 240, 240), RGB(190, 190, 190));

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-04-24 22:37:02
@acmodeu, there is no need to update this sample manually - it's available as part of SMP package (samples/basic/Volbar with GdiDrawText.js).

PS: @davideleo, your reasoning is correct =)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-04-24 22:43:23
Is there a way to port WSH Coverflow  to an SMP Script?
You can try using the following guide: https://github.com/TheQwertiest/foo_spider_monkey_panel/wiki/JScript-to-SpiderMonkey-migration-guide
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: acmodeu on 2019-04-25 14:59:16
@davideleo, @TheQwertiest thank you guys!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Ottodix on 2019-04-25 17:35:14
Big thanks TheQuertiest for your work on this component!

I released a theme based on this, you can get it there if you want to try it:
(https://i.ibb.co/4Tmh9TB/preview-tn.jpg)   https://github.com/Ottodix/Eole-foobar-theme

Most of this theme is made possible by SMP
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-04-25 17:53:56
Looks awesome! Guess it's time to make that script showcase page :D
It might be a good idea to create a separate thread for your theme though, otherwise it might get lost in this thread and not get the attention it deserves...
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-05-01 18:56:47
Conceptual question: what is the use of setting to null the variable that holds the graphics object, after using the GetGraphics() and thereon the ReleaseGraphics() methods?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Ottodix on 2019-05-02 14:03:59
Conceptual question: what is the use of setting to null the variable that holds the graphics object, after using the GetGraphics() and thereon the ReleaseGraphics() methods?
Making sure that the GC collect and free up the allocated memory for this graphic object, if you declared it as a global variable ? That's my guess
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-05-02 14:58:03
...if you declared it as a global variable...

In the sample scripts I've seen, it is always declared locally and nevertheless set to null at closure. But isn't it redundant after the ReleaseGraphics() method, given how spider monkey GC works?

P.S.
I noticed the StackBlur (text).js sample script does not bother to set the graphics object variable to null, after running the ReleaseGraphics() method. It's the only exception, though. What is the difference, for example, with the thumbs.js sample script? Why is setting the graphics object variable to null required in the latter and not in the first?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Joulupukki on 2019-05-02 20:52:09
@TheQwertiest: many thanks for your Spider Monkey Panel!

@TheQwertiest and other other developers:

Would it be possible to have a simple code for a simple volume control with 2 images: a dot and a knob with your panel?

(I've both images)

Thanks in advance.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Joulupukki on 2019-05-04 19:00:16
Well,, I swtched to WSH panel mod and the "DarkOne Volume Knob Panel  v3.1" vworks fine now  with my Foobar v1.4.3 (DUI).  :)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-05-13 15:20:15
I'm working on a one-panel theme and so I turned some of my stand-alone scripts to objects. With stand-alone scripts, though, we are able to draw portions of graphic elements by placing the drawing coordinates virtually outside of the window, relying on the fact that only the pixels inside the window will be painted. This is especially helpful (at least it helped me) in animating a scrolling motion.
Obviously this trick is not available in a one-panel script, where coordinates outside of the target area (the area I actually want to paint) are nevertheless inside the main window, and will be painted anyway.
So, is there a general way to mask or clip the portion of a graphic element that falls outside of a given area?
Let's say I have an object with x, y, width and height properties which define a region of the window, and than a draw() method which executes a few GdiGraphics methods. I want to make sure that when the draw() method is called, only the region defined by the object x, y, width and height properties is painted. How can I achieve that?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-05-13 19:19:54
For the record, I actually managed to get the above mentioned effect, but I cannot stress enough how much I dislike my solution:

Code: [Select]
var repainting = false;
var repaint_done = false;
var myObj = new PaintRegion(700, 400, 500, 300)


function on_paint(gr){
    myObj.paint(gr);
}


function PaintRegion(x, y, w, h){
    this.x = x;
    this.y = y;
    this.w = w;
    this.h = h;
    this.paint = (gr) => {
        if (repainting) // some GdiGraphics method...
        repainting = !repainting ;
        if (!repaint_done) window.RepaintRect(this.x, this.y, this.w, this.h);
        repaint_done = true
    }
}

I'm not comfortable triggering a RepaintRect method with the on_paint() callback and I have to pay attention that whenever the on_paint event is called, the repainting and repaint_done global variables are set to the proper value. If this is the right direction I can work on it to make it safe, but I reckon there must be a better way.


P.S.
After some tests with multiple objects I settled on the following version which seems to be pretty fluent:
Code: [Select]
function PaintRegion(x, y, w, h){
    this.x = x;
    this.y = y;
    this.w = w;
    this.h = h;
    this.repainting = false;
    this.repaint_done = false;
    this.paint = (gr) => {
        if (this.repainting) //draw something...;
        this.repainting = !this.repainting;
        if (!this.repaint_done) window.RepaintRect(this.x, this.y, this.w, this.h);
        this.repaint_done = !this.repaint_done
    }
}

Still looking forward to insights from skilled coders.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-05-13 23:44:11
Update: the above solution is okay if the objects are separate, but it gets buggy when they overlap.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2019-05-14 18:38:02
Unless I'm missing something, RepaintRect just clips the area that is currently drawn to the screen. So if I draw a rectangle from 0,0,100,100 to the gr buffer, and I'm only painting the region from (50,50 -> 100,100), the next time a full repaint is done, the rectangle will be completely drawn from 0,0 -> 100,100.

Also, it's my understanding that RepaintRect isn't something that causes a draw to happen immediately. It just specifies the region which will be drawn to the screen and that region is the union of the outermost extants of the region on the next draw cycle. So if I do RepaintRect(10,10,20,20) and then another RepaintRect(1000,1000,20,20) before the contents are actually drawn, when the drawcycle occurs it'll actually draw (10,10) -> (1020,1020). I'm assuming the underlying gdi stuff hasn't changed for Spidermonkey.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-05-14 20:27:04
Unless I'm missing something, RepaintRect just clips the area that is currently drawn to the screen. So if I draw a rectangle from 0,0,100,100 to the gr buffer, and I'm only painting the region from (50,50 -> 100,100), the next time a full repaint is done, the rectangle will be completely drawn from 0,0 -> 100,100.

Yes, unless you do this:
Code: [Select]
var myRegion = new PaintRegion(50, 50, 100, 100)


function on_paint(gr){
    myRegion.paint(gr);
}


function PaintRegion(x, y, w, h){
    this.x = x;
    this.y = y;
    this.w = w;
    this.h = h;
    this.repainting = false;
    this.repaint_done = false;
    this.paint = (gr) => {
        if (this.repainting) {
            gr.FillSolidRect(0,0, window.Width, window.Height,0xFF000000);  // these are just examples,any other
            gr.DrawEllipse(80, 30, 200, 200, 2, 0xFFFFFFFF)                 // GdiGraphics method goes here.
            this.repaint_done = true;
            this.repainting = false;
        };
        if (!this.repaint_done) {
            this.repainting = true;
            window.RepaintRect(this.x, this.y, this.w, this.h);
            this.repaint_done = false;           
        };
    }
}

The full paint is done only if the repainting property is true, but this is set to false by default and it is not touched when a full paint is called. It is turned to true only for the RepaintRect method to reference it, and than back to false right after its execution. The repaint_done property works the other way round, in order to prevent a RepaintRect loop.
The above code works, but in my new project I built a system of nested objects, that pass the paint action (any action actually) on to their content, and that's where it gets tricky, but it's a very specific problem for that script.

Anyway, I'd prefer, and I'm still looking for (I still did not look into the Catrox scripts!  :-[ ), an alternative method that doesn't use the on_paint() callback to trigger the RepaintRect() method, for obvious safety reasons, but also because it would probably work in my nested objects chain.



Also, it's my understanding that RepaintRect isn't something that causes a draw to happen immediately.

I'm not sure about that. From what I read in the docs, it behaves like the Repaint() method. Doesn't that call an immediate window repaint?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-05-14 23:10:11
Sorry, I just realized the last line of code which resets the repaint_done property to false, must not be in the conditional section, but right after:
Code: [Select]
var myRegion = new PaintRegion(50, 50, 100, 100)


function on_paint(gr){
    myRegion.paint(gr);
}


function PaintRegion(x, y, w, h){
    this.x = x;
    this.y = y;
    this.w = w;
    this.h = h;
    this.repainting = false;
    this.repaint_done = false;
    this.paint = (gr) => {
        if (this.repainting) {
            gr.FillSolidRect(0,0, window.Width, window.Height,0xFF000000);  // these are just examples,any other
            gr.DrawEllipse(80, 30, 200, 200, 2, 0xFFFFFFFF)                 // GdiGraphics method goes here.
            this.repaint_done = true;
            this.repainting = false;
        };
        if (!this.repaint_done) {
            this.repainting = true;
            window.RepaintRect(this.x, this.y, this.w, this.h);    
        };
       this.repaint_done = false;  // <---------
    }
}

I don't really understand why, though. It seems that the RepaintRect method aborts the execution of the previously called on_paint() function that triggered it. Is that correct?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-05-15 00:11:46
I don't really understand why, though. It seems that the RepaintRect method aborts the execution of the previously called on_paint() function that triggered it. Is that correct?

Alright, I think I understand now what @MordredKLB was telling me in his previous reply (https://hydrogenaud.io/index.php/topic,116669.msg971412.html#msg971412): the new paint event called by the RepaintRect() method is queued and executed only when the first paint event that triggered it is popped off the stack. Right?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2019-05-15 01:23:49
Alright, I think I understand now what @MordredKLB was telling me in his previous reply (https://hydrogenaud.io/index.php/topic,116669.msg971412.html#msg971412): the new paint event called by the RepaintRect() method is queued and executed only when the first paint event that triggered it is popped off the stack. Right?
Not exactly. Say you have a function that calls window.RepaintRect() twice in a row so that two buttons are repainted. It's my understanding that your on_paint method will only be called once the next time a WM_PAINT message is received by the foobar window, and that the cliprect for the area drawn will be the union of the exterior bounds (although that I'm less sure on).

Basically the Javascript is single-threaded, but the operating system isn't, and it queues up the areas that will be drawn.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-05-18 16:19:43
I finally found out how @TheQwertiest managed to solve the above issue in his CatRox theme. It's pretty straightforward actually, but it took me a few days because it was buried in thousands of code lines. So, for who's interested, here is a proper and more reasonable way than the one I came up with:

Code: [Select]
var myRegion = new PaintRegion(100, 100, 200, 200)


function on_paint(gr){
    myRegion.paint(gr);
}


function PaintRegion(x, y, w, h){
    this.x = x;
    this.y = y;
    this.w = w;
    this.h = h;
    this.paint = (gr) => {
        var clipImg = gdi.CreateImage(this.w, this.h)
        var grClip = clipImg.GetGraphics();
        grClip.DrawEllipse(100, 50, 200, 200, 2, 0xFF000000)
        clipImg.ReleaseGraphics(grClip);
        gr.DrawImage(clipImg, this.x, this.y, this.w, this.h, 0, 0, this.w, this.h)
    }
}
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: cerbaire on 2019-06-05 11:43:45
Hello,

I have a question about on_size event. It has two parameters and documentation indicates that it corresponds to panel size.
I have tested that and saw that it correspond to window size.
I did not do the test with JScript panel, but I would like to know if it the same with the JScript Panel ?

Kind regards,
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-06-05 13:44:42
I have a question about on_size event. It has two parameters and documentation indicates that it corresponds to panel size.
I have tested that and saw that it correspond to window size.
That is impossible - SMP currently does not have a way to find the size of fb2k window. on_size arguments ARE panel width and height respectively.
You can easily verify this by creating a layout with two resizeable SMP panels (e.g. in DUI) and replacing the following line in the default script:
Code: [Select]
gr.GdiDrawText(g_text, g_font, g_hot ? g_textcolour_hl : g_textcolour, 0, 0, ww, wh, DT_VCENTER | DT_CENTER | DT_WORDBREAK | DT_CALCRECT | DT_NOPREFIX);
with
Code: [Select]
gr.GdiDrawText(`width: ${ww}, height ${wh}`, g_font, g_hot ? g_textcolour_hl : g_textcolour, 0, 0, ww, wh, DT_VCENTER | DT_CENTER | DT_WORDBREAK | DT_CALCRECT | DT_NOPREFIX);
Each panel will display it's size, which will change when they are resized.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: cerbaire on 2019-06-05 18:30:31
Thanks for you response.
I was already displaying width and height but is was the same for my for 4 panels.
After more testing, I decided to add a MinWidth and MaxWidth, idem with height. And it is not respected. I use CUI with horizontal and vertical splitter.
The thing is that a panel stretch to the size of the largest panel inside a column, even if larger than MaxWidth.
When you say 'resizeable SMP panel', do you mean that we can have them not resizeable?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-06-17 11:50:40
After more testing, I decided to add a MinWidth and MaxWidth, idem with height. And it is not respected. I use CUI with horizontal and vertical splitter.
MinWidth and MaxWidth properties (and window dimensions adjustment functionality) are not provided by SMP component, but rather by foo_ui_hacks =)
You can use the following code though from my CaTRoX theme though: https://github.com/TheQwertiest/CaTRoX_QWR/blob/61eecfa4159e3714d58f53ae942d5f1861e83fb2/theme/Scripts/Panel_Menu.js#L1018
Note, that you have to change assignments like MinWidth=True to MinWidth.Enabled=True.


When you say 'resizeable SMP panel', do you mean that we can have them not resizeable
I mean smth like parent vertical/horizontal splitter in DUI/CUI that allows for panel size adjustment. There are components that provide panels for CUI/DUI, which allow having other panels inside, but don't allow their resizing.

[EDIT] Disregard this, I can't read...
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Ottodix on 2019-06-26 10:11:57
Hi,

Does someone knows a trick to trigger a new evaluation of panel stack splitter scripts, from a SMP panel ?
There is the play/pause way, using the function below, because the PerTrack scripts of a PSS panel are evaluate on playback changes, but this creates some sound glitches, especially while playing live streams (because foobar can't buffer the stream when this is a live stream, it need to synchronize with the stream after a pause command)

Code: [Select]
function RefreshPSS() {
if (fb.IsPlaying || fb.IsPaused) {
fb.PlayOrPause();
fb.PlayOrPause();
}
else {
fb.Play();fb.Stop();
}
}
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: zeremy on 2019-06-26 19:38:11
Hi,

Does someone knows a trick to trigger a new evaluation of panel stack splitter scripts, from a SMP panel ?
There is the play/pause way, using the function below, because the PerTrack scripts of a PSS panel are evaluate on playback changes, but this creates some sound glitches, especially while playing live streams (because foobar can't buffer the stream when this is a live stream, it need to synchronize with the stream after a pause command)

Code: [Select]
function RefreshPSS() {
if (fb.IsPlaying || fb.IsPaused) {
fb.PlayOrPause();
fb.PlayOrPause();
}
else {
fb.Play();fb.Stop();
}
}

There is a trick you can try.

You will need to enable is the PSS panels "Evaluate scripts when track info is modified"

Change your function to
Code: [Select]

function RefreshPSS() {
let handle_list = plman.GetPlaylistItems(plman.ActivePlaylist);
handle_list.RefreshStats();
}

There is a limitation:  Your handle list cannot be empty.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Ottodix on 2019-06-26 21:28:21
Ah yes, thanks! By combining both methods, you end up with something which work all the time:
Code: [Select]
function RefreshPSS() {
if (fb.IsPlaying || fb.IsPaused) {
let handle_list = new FbMetadbHandleList(fb.GetNowPlaying());
handle_list.RefreshStats();
}
else {
fb.Play();fb.Stop();
}
}

Important point:
 "Evaluate scripts when track info is modified" needs to be enabled AND on the script tab of the PSS panel, "Titleformat mode on startup" needs to be on "now playing"
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-06-27 13:44:23
@cerbaire , I have to apologize: my last answer was answering the wrong question, since I've misread `MinWidth` (present in SMP/JSP) as `MinSize.Width` (foo_ui_hacks)... But you've probably read the (correct) answer by marc2003 by now, so I won't repeat it here... :shame_on_me:
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: cerbaire on 2019-06-27 19:17:17
@cerbaire , I have to apologize: my last answer was answering the wrong question, since I've misread `MinWidth` (present in SMP/JSP) as `MinSize.Width` (foo_ui_hacks)... But you've probably read the (correct) answer by marc2003 by now, so I won't repeat it here... :shame_on_me:
Thanks TheQwertiest, yes I saw marc2k3 response on GitHub.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: spuuunit on 2019-06-27 20:56:20
How can I use foobar2000 code with Spider Monkey Panel code?

This is what I want to do:
Code: [Select]
$if(%ispaused%,❚❚,▶)‌‌
%title%
%playback_time% / %length%

This is my Spider Monkey Panel code so far:
Code: [Select]
var font = gdi.Font("Segoe UI", 12, 0);

function Color(r, g, b) {
return 0xFF000000 | r << 16 | g << 8 | b;
}

function on_paint(gr) {
    gr.FillSolidRect(0, 0, 1000, 1000, Color(240,240,240));
    gr.GdiDrawText("Playing/Paused - Track Title", font, Color(0,0,0), 5, 1, 226, 1000);
    gr.GdiDrawText("00:00 / 00:00", font, Color(0,0,0), 237, 1, 1000, 1000);
}
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Decalicatan_Decalicatan on 2019-06-28 14:12:54
Hi everyone,

Does anyone ever hear of a SMP (or marc2003's jscript) code for an library search toolbar (like the Quicksearch toobar component for example?)
There used to be a WSH toolbar in one of Br3tt's theme (xchange I think) but it's kind of old and I'm not sure I will be able to port it to SMP.

Thanks in advance
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-06-29 00:27:57
Hi everyone,

Does anyone ever hear of a SMP (or marc2003's jscript) code for an library search toolbar (like the Quicksearch toobar component for example?)
There used to be a WSH toolbar in one of Br3tt's theme (xchange I think) but it's kind of old and I'm not sure I will be able to port it to SMP.


Not sure it helps, but here is an adaptation of the script I wrote for my config. It was not meant to work in a component-like fashion, so you might have to edit the code here and there (no window properties, sorry). My coding is much more naive than marc2003's or Br3tt's, but perhaps this makes it easier to grasp and modify.
For reasons I don't understand, it only works with columns ui, maybe some more advanced coder can figure out why,
I still didn't find the time to handle the typing animation when the text's length exceeds that of the width of the panel, so make sure the panel is wide enough for your average search strings.
Search results are displayed in a playlist called "Search results [your search string]", which is overwritten at every new search.

Code: [Select]
"use strict";

include(fb.ComponentPath + "docs\\flags.js");
include(fb.ComponentPath + "docs\\helpers.js");
include(fb.ComponentPath + "samples\\complete\\js\\lodash.min.js");


var font_height = 18;
var fontcolor = colours.White;
var text = "";
var cursor = 0;
var set_cursor = false;
var selection_lx = 0;
var selection_rx = 0;
var selection = "";
var mouse_lbtn_down = false;
var count = 0;
var timerID;
var timer = false;
var edit = false;
var writing = false;
var ctrla = false;
var dblclk = false;
var dblclk_lx = 0;
var dblclk_rx = 0;
var mouse_lbtn_down_x = 0;
var mouse_move_x = 0;
var obj = new ActiveXObject("htmlfile");
var autocomplete = new Array();
var history = new Array();
history.push(text);
var currentState = 0;
var ww = 0;
var wh = 0;
var text_x = 0;


function on_size(){
    ww = window.Width;
    wh = window.Height; 
}


function on_paint(gr){   
    var iconfont = "Segoe mdl2 assets";   
    var font = gdi.Font(iconfont, font_height, 0);
    var selection_color = colours.Black;
    var icon = String.fromCharCode(57492);
    var textheigth = gr.CalcTextHeight(icon, font); 
    text_x = wh + gr.CalcTextWidth(" ", font);
   
    dblclk_lx = Math.max(text.slice(0, getPos(mouse_lbtn_down_x, text, font, gr)).toString().lastIndexOf(" ") + 1, 0);
    dblclk_rx = getPos(mouse_lbtn_down_x, text, font, gr) + (text + " ").slice(getPos(mouse_lbtn_down_x, text, font, gr)).toString().indexOf(" ") + 1;
    selection_lx = getPos(Math.min(mouse_lbtn_down_x, mouse_move_x), text, font, gr);
    selection_rx = getPos(Math.max(mouse_lbtn_down_x, mouse_move_x), text, font, gr);
    if (dblclk) selection_lx = Math.min(selection_lx, dblclk_lx);
    if (dblclk) selection_rx = Math.max(selection_rx, dblclk_rx);
    if (ctrla) selection_lx = 0;
    if (ctrla) selection_rx = text.length;
       
    var selection_x = text_x + (gr.CalcTextWidth(text.slice(0, selection_lx), font));
    var selection_w = gr.CalcTextWidth(text.slice(selection_lx, selection_rx), font);
    var text1 = text.slice(0, selection_lx);
    var text2 = text.slice(selection_lx, selection_rx);
    var text3 = text.slice(selection_rx);
    if (set_cursor) {
        cursor = getPos(mouse_lbtn_down_x, text, font, gr);
        set_cursor = false;
    }
    selection = text2;
    var cursor_x = text_x + gr.CalcTextWidth(text.slice(0, cursor), font);
   

    gr.DrawRect(0, 0, ww - 1, wh - 1, 1, fontcolor);
    gr.GdiDrawText(icon, font, fontcolor, 0, 0, wh, wh, DT_CENTER | DT_VCENTER | DT_SINGLELINE); 
    gr.FillSolidRect(selection_x, (wh - textheigth)/2, selection_w, textheigth, colours.Gray);      
    gr.GdiDrawText(text1, font, fontcolor, text_x, 0, gr.CalcTextWidth(text1, font), wh, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);
    gr.GdiDrawText(text2, font, selection_color, text_x + gr.CalcTextWidth(text1, font), 0, gr.CalcTextWidth(text2, font), wh, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);
    gr.GdiDrawText(text3, font, fontcolor, text_x + gr.CalcTextWidth(text1, font) + gr.CalcTextWidth(text2, font), 0, gr.CalcTextWidth(text3, font), wh, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);
    if (selection_w == 0 && edit && count%2 == 1) gr.DrawLine(cursor_x, (wh - textheigth)/2, cursor_x, (wh + textheigth)/2, 1, fontcolor);
    if (text == "" && !edit) gr.GdiDrawText("Search", font, fontcolor, text_x, 0, ww - text_x, wh, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
    writing = false;
}


function on_mouse_move(x, y){
    window.SetCursor(IDC_IBEAM);
    if (mouse_lbtn_down){
        mouse_move_x = x;
        window.Repaint();
}
}


function on_mouse_lbtn_down(x, y){
    edit = true;
    mouse_lbtn_down = true;
    mouse_lbtn_down_x = x;
    set_cursor = true;
    unselect();
    window.Repaint();
}


function on_mouse_lbtn_up(x, y){
    mouse_lbtn_down = false;
}


function on_mouse_lbtn_dblclk(x, y){
    mouse_lbtn_down = true;
    mouse_lbtn_down_x = x;
    dblclk = true;   
    window.Repaint();
}
   
   
function on_mouse_leave(){
    mouse_lbtn_down = false;
    edit = writing;
}


function on_focus(is_focused){
    if (is_focused){
        timerID = window.SetInterval(function() {
            count++;
            window.Repaint();
            }, 500);   
        timer = true
    } else {
        window.ClearInterval(timerID);
        timer = false;
        count = 0;
        window.Repaint();
    }
}


function on_char(code){
    if (code > 31) {
        if (selection_lx < selection_rx){
            text = text.slice(0, selection_lx) + String.fromCharCode(code) + text.slice(selection_rx);
            cursor = selection_lx + 1;
            unselect();
        } else {           
            text = text.slice(0, cursor) + String.fromCharCode(code) + text.slice(cursor);
            cursor = cursor + 1;
        }
        newState(text);
        var autocompleteMenu = window.CreatePopupMenu();
        var filtered_list = _.uniq(autocomplete, true).filter(filterAutocomplete);
        for (var i = 0; i < filtered_list.length; i++){
            autocompleteMenu.AppendMenuItem(MF_STRING, i + 1, filtered_list[i]);
        }
        var ret = autocompleteMenu.TrackPopupMenu(text_x, wh, 0);
        if (ret > 0){
            text = filtered_list[ret - 1];
            cursor = text.length;
        }
        writing = true;
        window.Repaint();
    }
}
       

function on_key_down(vkey){
    var ShiftKeyPressed = utils.IsKeyPressed(VK_SHIFT);
    var ControlKeyPressed = utils.IsKeyPressed(VK_CONTROL);
    if (!ControlKeyPressed){      
        switch (vkey){           
            case 8: //backspace           
            if (selection_lx < selection_rx){
                text = text.slice(0, selection_lx) + text.slice(selection_rx);
                cursor = selection_lx;
                unselect();
            } else {
                text = text.slice(0, Math.max(cursor - 1, 0)) + text.slice(cursor);
                cursor = Math.max(cursor - 1, 0);
            }
            newState(text);
            break;
           
            case 13: //enter
            search();
            text = "";
            cursor = 0;
            history = [];
            newState(text);
            break;
           
            case 37: //left arrow
            cursor = Math.max(cursor - 1, 0);
            break;
           
            case 39: //right arrow
            cursor = Math.min(cursor + 1, text.length);
            break;
           
            case 46: //delete
            if (selection_lx < selection_rx){
                text = text.slice(0, selection_lx) + text.slice(selection_rx);
                cursor = selection_lx;
                unselect();
            } else {
                text = text.slice(0, cursor) + text.slice(cursor).slice(1);
            }
            newState(text);
            break;
        }
    } else {
        switch (vkey){
            case 65: //ctrl + A
            ctrla = true;
            break;
           
            case 67: //ctrl + C
            obj.parentWindow.clipboardData.setData("Text", selection);
            break;
           
            case 86: //ctrl + V
            var clipboard = obj.parentWindow.clipboardData.getData("Text") + "";
            if (selection_lx < selection_rx){
                text = text.slice(0, selection_lx) + clipboard + text.slice(selection_rx);
            } else {
                text = text.slice(0, cursor) + clipboard + text.slice(cursor);
            }
            cursor = selection_lx + clipboard.length;
            unselect();
            newState(text);           
            break;
           
            case 88: //ctrl + X
            obj.parentWindow.clipboardData.setData("Text", selection);
            text = text.slice(0, selection_lx) + text.slice(selection_rx);
            cursor = selection_lx;
            unselect();
            newState(text);
            break;
           
            case 89: //ctrl + Y
            currentState = Math.max(currentState - 1, 0);
            text = history[currentState];
            cursor = text.length;
            break;
           
            case 90: //ctrl + Z
            currentState = Math.min(currentState + 1, history.length - 1);
            text = history[currentState];
            cursor = text.length;
            break;        
        }
    }
    window.Repaint();
}
           

function getPos(x, text, font, gr){
    var pos;
    for (var i = 0; i <= text.length; i++){
        if (x < text_x + gr.CalcTextWidth(text.slice(0, i + 1), font)){
            pos = i;
            i = text.length + 1;

        } else {
            pos = text.length;
        }
    }
    return pos;
}

   
function unselect(){
    mouse_move_x = mouse_lbtn_down_x;
    dblclk = false;
    ctrla = false;
}


function newState(text){
    history.slice(currentState);
    history.unshift(text);
    currentState = 0;
}


function search(){
    autocomplete.push(text);
    autocomplete.sort();
   
    var SortOrder = "%album artist%|%release date%|%album%|%discnumber%|%set subtitle%|%tracknumber%|%path%";
    try {
        var queryItems = fb.GetQueryItems(fb.GetLibraryItems(), text);
    }
    catch(Error){
        var queryItems = fb.CreateHandleList();
    }
   
    var index = -1;    
    for (var i = 0; i < plman.PlaylistCount; i++) {
       if (plman.GetPlaylistName(i).indexOf("Search results [") == 0) index = i;
    }
    if (index > -1){
        plman.RemovePlaylist(index);
    } else {
        index = plman.PlaylistCount;
    }
    plman.CreatePlaylist(index,"Search results [" + text + "]");
    plman.InsertPlaylistItems(index, 0, queryItems);
    plman.SortByFormat(index, SortOrder); 
    plman.ActivePlaylist = index;
}


function filterAutocomplete(value){
    return value.indexOf(text) == 0;
}
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: CrowRabbit on 2019-06-29 14:40:24
Hi,

I wrote to able use Spider Monkey Panel in TypeScript.
https://github.com/FuCrowRabbit/SpiderMonkeyPanelForTypeScript

Thanks.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: spuuunit on 2019-06-29 14:46:23
Oh god I just figured out how to write my panel! Kind of like a short status bar:

Code: [Select]
var font = gdi.Font("Segoe UI", 12, 0);
var play_pause = fb.TitleFormat('$if(%ispaused%,❚❚,▶)');
var title = fb.TitleFormat('%title%');
var time1 = fb.TitleFormat('%playback_time%');
var time2 = fb.TitleFormat('%length%');


function on_playback_pause() {  // + play
    window.Repaint();
}
function on_playback_new_track() {
    window.Repaint();
}
function on_playback_seek() {
window.Repaint();
}
function on_playback_time() {
window.Repaint();
}


function Color(r, g, b) {
return 0xFF000000 | r << 16 | g << 8 | b;
}
function on_paint(gr) {
    gr.FillSolidRect(0, 0, 1000, 1000, Color(240,240,240));
    gr.GdiDrawText(play_pause.Eval() + " " + title.Eval(), font, Color(0,0,0), 5, 1, 226, 1000);
    gr.GdiDrawText(time1.Eval() + " / " + time2.Eval(), font, Color(0,0,0), 237, 1, 1000, 1000);
}

But does anyone know if there's a way to update just one string, and not the whole panel like window.Repaint(); does?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-06-29 15:05:48
@spuuunit , you can use `RepaintRect(w,h)` instead of `Repaint()` if you want to redraw only part of the panel.

@CrowRabbit , TS typings would be nice, but I'm wary of the duplicated documentation: there is already a JSDoc version https://github.com/TheQwertiest/foo_spider_monkey_panel/blob/master/component/docs/js/foo_spider_monkey_panel.js , and it would be a pain to have to maintain the same docs in TS typings as well... (I mean method descriptions and stuff, I'm fine with maintaining the interface itself)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: spuuunit on 2019-06-29 15:34:06
@spuuunit , you can use `RepaintRect(w,h)` instead of `Repaint()` if you want to redraw only part of the panel.

@CrowRabbit , TS typings would be nice, but I'm wary of the duplicated documentation: there is already a JSDoc version https://github.com/TheQwertiest/foo_spider_monkey_panel/blob/master/component/docs/js/foo_spider_monkey_panel.js , and it would be a pain to have to maintain the same docs in TS typings as well... (I mean method descriptions and stuff, I'm fine with maintaining the interface itself)

Thanks! But how exactly does that look like, is it like this: window.RepaintRect(0, 1000, 0, 1000); Does that cover the whole area? Because nothing is updating for me.

And another thing: The playback time that increases every second is what I want to update. Is it worth updating just that area all the time, rather than the whole panel, to save resources? Or does panel update affect resources so little that I shouldn't bother?

EDIT: This is my panel by the way. 4 tags and a background color: https://imgur.com/Pds7rqY
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-06-29 16:17:26
That's cause you are using it wrong =)
The method prototype is `window.RepaintRect(x,y,w,h)` and you calling it like `window.RepaintRect(x,w,y,h)`. So, in your case, the correct call would be `window.RepaintRect(0, 0, 1000, 1000)`.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: spuuunit on 2019-06-29 16:32:34
Oh shit thanks! =) But does RepaintRect require less computer power than only Repaint? If so I'll go with that.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-06-29 16:37:26
RepaintRect will use less CPU only if the area it's redrawing is smaller then your whole panel. Otherwise there will be no difference.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: spuuunit on 2019-06-29 16:47:28
Ok thanks!

I have 2 more questions, sorry to be a nuicense.  O:)
1. Is it possible to draw text right aligned?
2. Is it possible to draw an external image, a PNG for example.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Decalicatan_Decalicatan on 2019-06-29 18:43:04

Not sure it helps, but here is an adaptation of the script I wrote for my config. It was not meant to work in a component-like fashion, so you might have to edit the code here and there (no window properties, sorry). My coding is much more naive than marc2003's or Br3tt's, but perhaps this makes it easier to grasp and modify.
For reasons I don't understand, it only works with columns ui, maybe some more advanced coder can figure out why,
I still didn't find the time to handle the typing animation when the text's length exceeds that of the width of the panel, so make sure the panel is wide enough for your average search strings.
Search results are displayed in a playlist called "Search results [your search string]", which is overwritten at every new search.

Thank you! Very much appreciated :)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-06-30 11:45:56
Thank you! Very much appreciated :)

Don't bother ask if you need help understanding the script or indications on which variables must be edited to change the appearance.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Decalicatan_Decalicatan on 2019-07-01 10:26:53
Don't bother ask if you need help understanding the script or indications on which variables must be edited to change the appearance.

Thanks for the offer ^^ ....

Maybe you can help me for a more generic question then:
Where can I find character codes if I wanted to change the search icon in the line "var icon = String.fromCharCode(57492);").
(I already managed to change the font / color / other stuffs)

Thanks in advance.. and thanks once again to profide me the script,, even I you prefer not to answer, which I can undersand.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-07-01 11:33:48

Maybe you can help me for a more generic question then:
Where can I find character codes if I wanted to change the search icon in the line "var icon = String.fromCharCode(57492);").
(I already managed to change the font / color / other stuffs)

Well, I guess it depends on the new font you chose. You can look it up in the windows character map application where it is shown as UTF-8 code, you than have to convert it to decimal in order to use it in the fromCharCode method (I use online converters for this purpose).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-07-01 11:37:10
1. Is it possible to draw text right aligned?
See documentation for `GdiDrawText` method, specifically `format` argument.

2. Is it possible to draw an external image, a PNG for example.
See docs for `LoadImageAsync`/`LoadImageAsyncV2`, `DrawImage`/`GdiDrawBitmap` methods and basic `LoadImageAsync.js`/`LoadImageAsyncV2.js` samples.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Decalicatan_Decalicatan on 2019-07-01 13:27:16
Well, I guess it depends on the new font you chose. You can look it up in the windows character map application where it is shown as UTF-8 code, you than have to convert it to decimal in order to use it in the fromCharCode method (I use online converters for this purpose).

Thank you. The hex to decimal conversion part was what I missed. Now it's working.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: spuuunit on 2019-07-01 23:17:03
1. Is it possible to draw text right aligned?
See documentation for `GdiDrawText` method, specifically `format` argument.

2. Is it possible to draw an external image, a PNG for example.
See docs for `LoadImageAsync`/`LoadImageAsyncV2`, `DrawImage`/`GdiDrawBitmap` methods and basic `LoadImageAsync.js`/`LoadImageAsyncV2.js` samples.

God thank you! I found those documentation files, didn't even know they were there. Finally I put together my panel and it's perfect. =)

Thank you TheQwertiest for an awesome plugin and all the support! This plugin must give endless possibilities for you guys who really know how to script. Keep up the good work!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-07-02 15:01:36
I found those documentation files, didn't even know they were there. Finally I put together my panel and it's perfect.

FYI, there is a JS version and HTML version of the docs. You want the HTML version, which is accessible via `Context Menu`>`Configure Panel`>`Help`>`View Help`.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: cerbaire on 2019-07-12 14:12:14
1. Is it possible to draw text right aligned?
See documentation for `GdiDrawText` method, specifically `format` argument.

2. Is it possible to draw an external image, a PNG for example.
See docs for `LoadImageAsync`/`LoadImageAsyncV2`, `DrawImage`/`GdiDrawBitmap` methods and basic `LoadImageAsync.js`/`LoadImageAsyncV2.js` samples.

Is it possible to load an image directly from an url ?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-07-12 16:00:03
Is it possible to load an image directly from an url ?
Nope, you'll have to download it manually: SMP does not provide any direct means to work with the Web, you have to use a suitable COM object via `ActiveObjectX` interface (e.g. `ActiveObjectX("MSXML2.XMLHTTP")`.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: cerbaire on 2019-07-16 15:46:01
Is it possible to load an image directly from an url ?
Nope, you'll have to download it manually: SMP does not provide any direct means to work with the Web, you have to use a suitable COM object via `ActiveObjectX` interface (e.g. `ActiveObjectX("MSXML2.XMLHTTP")`.
I have created a code using XMLHttpRequest that can download binary stream of file under Chrome, but it does not work inside a SMP panel (using a the ActiveX component instead of XMLHttpRequest object), and then I don't find anyway to save the stream to filesystem.
Any clue appreciated.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Ottodix on 2019-07-17 18:48:47
It's not an easy problem. You can try to look at the code of the Biography script by Wilb, there (https://hydrogenaud.io/index.php/topic,112913.msg929674.html#new), it calls a VBScript in order to download images (well his VBScript can actually download any kind of file).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: whyonearth on 2019-07-22 03:20:00
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-07-22 11:24:06
With foobar2000 v 1.5 beta 6 and foo_spider_monkey_panel nightly build v1.2.2-beta+8a02533a I observe constant memory usage growing in following scenario

It's not really leaking: garbage collector in SMP has several triggers, two of them are `allocated memory trigger` and `allocation count trigger`. The problem is that I can't know the size of a loaded ActiveXObject, so it doesn't trigger GC as much as it should. But, if you are actively using your script (instead of just reloading it =)), it should encounter one of the GC triggers sooner or later and will free all the memory occupied by ActiveXObject's.

Regarding your suggestions: noted, but I don't think I'll work on these any times soon - I have a few major features that I really want to implement and it will take quite a lot of time... COM objects being a major PITA (and the lack of documentation) also doesn't help.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-07-22 11:48:06
@Awesomeo : moved SMP specific discussion here, as to not clutter @WilB 's thread.

And vice versa, I could have any PSS element that would react to changes in a particular SMP. So maybe something like $set_smp(smp_id,property,value) and $get_smp(smp_id,property).
This is not possible - PSS does not provide any way to extend it's API. What I will (probably) do is add an additional panel option, which would allow to define panel `events` that could be used by fb2k shortcuts.

Hm, not sure if I fully understand this, because both things happen at once for me: playback pauses and the library tree search field receives a space.
Playback pause/play shortcut uses 'on_key_down' event (which is not passed to script in this case), library tree uses 'on_key_up' event (which is passed).

However I've already checked other CUI panels with typing option, like 'Typefind' or 'Youtube Source Search' and keystrokes work locally in them, they don't execute foobar's global hotkeys
Dunno about Youtube Source, but it seems that 'Typefind' uses quite a hacky method to workaround this problem. I'm not quite ready to make such hacks (might change my mind though).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: whyonearth on 2019-07-22 15:31:19
With foobar2000 v 1.5 beta 6 and foo_spider_monkey_panel nightly build v1.2.2-beta+8a02533a I observe constant memory usage growing in following scenario

It's not really leaking: garbage collector in SMP has several triggers, two of them are `allocated memory trigger` and `allocation count trigger`. The problem is that I can't know the size of a loaded ActiveXObject, so it doesn't trigger GC as much as it should. But, if you are actively using your script (instead of just reloading it =)), it should encounter one of the GC triggers sooner or later and will free all the memory occupied by ActiveXObject's.
OK, I think I understand this. SMP garbage collector had been tuned to kick-in based on reasonable criterias. And instantiation of ActiveX object doesn't produce any meaningful information that can contribute to this criteria, so garbage collector just have no reasons to react to growing memory usage.

Problem is, even though multiple saving/reloading is a laughable use-case (not in bad sense), I really did it on valid purpose, when I iteratively developed SMP script. Change script a little, save, try it out. Repeat.

With instantiation of AutoHotkey COM object (as I described in list item 4), memory usage grows in about 1-2 MB chunks on every save/reload event. I think, I have not so modern computer, with just 2GB RAM, and Windows 10 is memory-hungry too, so I hit OOM. I really did. Foobar2000 process just was killed. That's a bad experience.

So maybe, if tuning GC kick-in criteria now requires changes to C++ code and recompilation of SMP, the solution to my problem would be a possibility for user to contribute to criteria with JavaScript API.

Something like
Code: [Select]
window.TriggerSmpGcAsap()

Calling such function will trigger SMP garbage collector as soon as possible even though criterias defined in C++ code aren't fulfilled yet.

With this function I can do something like
Code: [Select]
const gc_memory_criteria = 20 * (1024 * 1024 * 1024); // 20 MB

function on_script_unload() {
  if (window.PanelMemoryUsage > gc_memory_criteria) {
    window.TriggerSmpGcAsap()
  }
}

Also, even though you don't know the size of a loaded ActiveXObject, but I (as user) can observe memory usage growing and make an assumption about this size. So maybe there could be a way to pass this information from JavaScript to component, like
Code: [Select]
const obj = newActiveXObject('Some.MemoryHungry.COM.Object')
window.AssumeObjectSizeInGcCriteria(obj, 2*1024*1024*1024 /*2 MB*/);

Regarding your suggestions: noted, but I don't think I'll work on these any times soon - I have a few major features that I really want to implement and it will take quite a lot of time... COM objects being a major PITA (and the lack of documentation) also doesn't help.
I totally agree about COM technology being PITA  :'(  and I didn't even interact with it in C++, so I can only imagine how it is (but I don't want to, sorry  ;D).

However, all of my suggestions for new SMP features don't directly touch COM.

I implemented Tab key focusing by setting WS_TABSTOP (https://docs.microsoft.com/en-us/windows/win32/winmsg/window-styles) window style for SMP control from AutoHotkey script. So I suggested adding of JavaScript API for enabling/disabling this style from SMP panel script.

And suggestion about extending JavaScript API for manipulating activation contexts also don't need COM programming at all. Just introducing thin wrapper for instantiating ACTCTX (https://docs.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-tagactctxa) structure and calling CreateActCtx (https://docs.microsoft.com/ru-ru/windows/win32/api/winbase/nf-winbase-createactctxa), ActivateActCtx (https://docs.microsoft.com/ru-ru/windows/win32/api/winbase/nf-winbase-activateactctx) and DeactivateActCtx (https://docs.microsoft.com/ru-ru/windows/win32/api/winbase/nf-winbase-deactivateactctx).

There are also other function in Activation Context API (https://docs.microsoft.com/en-us/windows/win32/sbscs/activation-context-reference), but they are possibly not so important for simple use-cases like mine.

But anyway, it's just a clarification. I understand that SMP development is driven by your motivation and motivation can be substantially lowered by unwanted distractions. I'm the only one who asked for this features, and I can live without them for long time or even forever, as I've found workarounds. So it's totally OK for me to know that these features wouldn't be implemented soon or wouldn't be implemented at all.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-07-22 17:08:18
Something like
Code: [Select]
window.TriggerSmpGcAsap()
I will not implement such method if I can avoid. Reason is simple: users ALWAYS try to shoot themselves in the foot, e.g. call `ForceGC` in every `on_paint` event and then complain that the performance is bad.
I'll try to think of a better way to solve your problem (hoping there is one).

window.AssumeObjectSizeInGcCriteria(obj, 2*1024*1024*1024 /*2 MB*/);
Same with exposing such internals. API should be kept as concise as possible (I would remove/reorganize quite a few methods from the current SMP if I could do so without breaking compatibility).

PS: `2*1024*1024*1024` is 2GB =)

And suggestion about extending JavaScript API for manipulating activation contexts also don't need COM programming at all. Just introducing thin wrapper for instantiating ACTCTX (https://docs.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-tagactctxa) structure and calling CreateActCtx (https://docs.microsoft.com/ru-ru/windows/win32/api/winbase/nf-winbase-createactctxa), ActivateActCtx (https://docs.microsoft.com/ru-ru/windows/win32/api/winbase/nf-winbase-activateactctx) and DeactivateActCtx (https://docs.microsoft.com/ru-ru/windows/win32/api/winbase/nf-winbase-deactivateactctx).
These are not general-purpose methods so they would never be placed in the core namespaces, maybe they could be added as static methods of ActiveXObject... (or perhaps a candidate for a SMP plugin, once/if such plugin API is implemented).

About tabbing: I'll take a look, but no ETA =)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: whyonearth on 2019-07-22 18:33:33
PS: `2*1024*1024*1024` is 2GB =)
Yep, you are right, the code was wrong, the code comment is correct. Don't know how it happened. Thanks for noticing.

It's good to know that you've took a closer look at suggested features. I'll patiently wait.

If you don't want to give user any access to GC control knobs, it might be enough to force GC in C++ code just after invoking JS on_script_unload() callback (https://github.com/TheQwertiest/foo_spider_monkey_panel/blob/3467e78e0266a7e03c8c08a0cf1fc1acdd6305d6/foo_spider_monkey_panel/js_panel_window.cpp#L944) (maybe force conditionally, based on state of checkbox added in Panel Features menu). As far as I can deduce from looking at code, it should cover cases of saving script in panel configuration window and script reload. After all, on reload most (all?) references in unloaded script should be unreachable and targeted for garbage collection anyway.



As I'm using AutoHotkey, I'm looking for ways to push information from AutoHotkey script to SMP script (pulling information from AutoHotkey script and pushing information to AutoHotkey script could be done with COM object methods).

AutoHotkey can send (or post) windows messages (https://hotkeyit.github.io/v2/docs/commands/PostMessage.htm) to windows and controls with given parameters. As my limited understanding of SMP component code allows me to suppose, SMP's on_main_menu() callback is invoked based on specific window message number and argument passed to on_main_menu() callback is parameter of window message. So it could be used for my purposes.

However, window message number (https://github.com/TheQwertiest/foo_spider_monkey_panel/blob/5589fb60982f066b24f44f0315b0ce8fefd1444d/foo_spider_monkey_panel/user_message.h#L64) for invoking on_main_menu() callback can change between releases of SMP, because of possible changing of related enums where this number is defined. This makes relying on concrete number a bit reckless.

Can you provide separate callback (like on_wm_user_message()), which would be called on receving windows message with stable number? Or maybe you can expose main_menu_item message number in property accessible from JS script (like window.MAIN_MENU_ITEM_WM_NUMBER), so that I can push it to AutoHotkey script?

(Concrete names of functions and properties are not important.)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Ottodix on 2019-07-24 15:47:11
HI,

Is there a way to get a playlist track metadb without retrieving the whole content of the target playlist?
I'm trying to get the focused track of a playlist (any playlist, not the active one).
So i've got that
Code: [Select]
var focus_index = plman.GetPlaylistFocusItemIndex(playlistIndex);		
var metadbs = plman.GetPlaylistItems(playlistIndex);
metadb = metadbs[focus_index];

But in term of performance, it means that i will temporary create a object containing the whole playlist, isn't it an issue on very large playlist? I would prefer something like
Code: [Select]
plman.GetPlaylistItemByIndex(playlistIndex, item_index);
Or eventually, something like that, in order to get the FbMetadbHandle instead of just the index
Code: [Select]
plman.GetPlaylistFocusItem(playlistIndex);
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-07-24 16:45:45
I have created a code using XMLHttpRequest that can download binary stream of file under Chrome, but it does not work inside a SMP panel (using a the ActiveX component instead of XMLHttpRequest object), and then I don't find anyway to save the stream to filesystem.
Sorry, forgot to answer your post:
`xhr` in chrome/mozilla/edge is not the same as `*legacy* xhr` which is XMLHttpRequest activexobject.
It's possible to manually invoke it in JavaScript in SMP, but the problem is that it's impossible to save the file asynchronously, meaning that it will block the main thread until the operation is finished. The solution to this is to invoke the `download&save` operation in a separate process. One such example is the one @Ottodix mentioned: invoke the download with a separate VBScript via `cscript,exe`: VBScript file - `samples\complete\vbs\download.vbs`; example usage - `samples\complete\js\thumbs.js` (https://github.com/marc2k3/smp_2003/blob/98fb2425975dcd8d3e999a7f25282392403d60dd/js/thumbs.js#L525)

it might be enough to force GC in C++ code just after invoking JS on_script_unload() callback
Actually I was thinking about it when I was tuning GC, but decided against it exactly due to the scenario when user reloads script a lot to test his changes. I should try to trigger a minimal GC though, since minimal GC has minimal impact on UX.

Can you provide separate callback (like on_wm_user_message())
I can't, since it will tank the performance - crossing JS <> native boundary is not free and message loop is one of the most often called places.

Or eventually, something like that, in order to get the FbMetadbHandle instead of just the index
Uhm, you could just call `fb.GetFocusItem()` though? =)
But yea, there is currently no way to get a single track (except for the focused track) from the playlist without fetching the array containing the whole playlist.

[EDIT]: I can't currently think of a proper scenario when you would have a track index, but wouldn't have the whole playlist or means to access the corresponding track: you are either working with the whole playlist or you need a specific track because of it's status (that is selected, focused, queued and etc) which means that you can access them via corresponding methods.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Ottodix on 2019-07-25 10:29:40
Uhm, you could just call `fb.GetFocusItem()` though? =)

fb.GetFocusItem() works only on the active playlist. This is inside a on_item_focus_change(playlistIndex, from, to) callback.
In this callback, I would like to get the focused track handle, and this status is effectively focused, but ! Not in the active playlist unfortunately
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-07-25 10:44:58
Hm... Just wondering, why would you need a focused track from non-active playlist? =)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Ottodix on 2019-07-25 16:23:53
Hm... Just wondering, why would you need a focused track from non-active playlist? =)

this is a little bit complex, i'm building a side panel which show infos about the focused track, it needs to interact with others panels showing tracks from a playlist which is not necessary the active one (and i can't make it the active one without triggering on_playlist_switch everywhere, and it would be a major performance drawback on my layout).

I think i will try to trigger a refresh of this "info panel" without on_item_focus_change but instead with on_notify_data() and a custom on_focus_change function, all my panels are SMP panels anyway, it will allow me a better control

EDIT: Yes, it's much easier to control with with on_notify_data(), less foobar-logic-compliant, but it doesn't matter
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: thisbanisnotsettoexpire on 2019-07-26 02:15:20
Something like
Code: [Select]
window.TriggerSmpGcAsap()
I'll try to think of a better way to solve your problem (hoping there is one).
I (whyonearth) was banned for not really considering forum rules. I hope now I'm complying with them. Sorry for breaking the rules and for confusion with replying from new account.

Anyway, that OOM-on-repeated-script-reload error I was talking about was not an OOM error at all. Nevertheless, it's still error of resource exhaustion type.

So, I noted that there was some free memory at the time of crash. This is when I thought I might be wrong in my conclusions. Then I somehow did look more thoroughly at foobar2000 crash report and accidentally 93MB of .rar files extracted meaningful information (crash report is trimmed here):
Spoiler (click to show/hide)

So, code tried to access address zero, when last win32 error was error with code 1114 (ERROR_DLL_INIT_FAILED (https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--1000-1299-): A dynamic link library (DLL) initialization routine failed).

I examined AutoHotkey_H sources, then downloaded OllyDbg and tried to trace AutoHotkey DLL execution. Starting point was in DllGetClassObject (https://github.com/HotKeyIt/ahkdll/blob/eec985c16ff284ec77bde2423bb584c3a7fb1463/source/dllmain.cpp#L1199). Here's what I found.
Spoiler (click to show/hide)

Relevant links:Spoiler (click to show/hide)

So, when I naively chose Win32w_MT variant of AutoHotkey.dll from release distribution, I chose statically linked library (which I didn't know at the time) and this brought some fixed limits.

Good news, in recent version of Windows 10 this limit is raised: read here (https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/3546c3c4-1b36-4552-85c5-1b3ba860ee84/how-many-dlls-can-be-loaded-in-a-process-using-loadlibrary-?forum=windowssdk#2e017194-025e-4521-bee0-aad21fd1f805) and here (https://www.gearslutz.com/board/showpost.php?p=13729254&postcount=62&s=b7f43881db1fa1a81da3cc76ceba2e51). Bad news (for me), I'm not using the recent version of Windows 10.

So, while I can instead use dynamically linked AutoHotkey.dll (from Win32w directory), which is linked with vcruntime140.dll, just as foobar2000, and this replacement seems to fix crashes, I thought, maybe if SMP component would just unload COM DLL on unloading (i.e. reloading) SMP script, this also should fix my problem?

While, looking at the SMP code, I can find CoFreeUnusedLibraries (https://github.com/TheQwertiest/foo_spider_monkey_panel/blob/9252b68ba8caca8cecc0a9a9f64b76c8bacd314a/foo_spider_monkey_panel/js_objects/active_x_object.cpp#L420), I believe, in real usage component doesn't always work as expected.

Trying to prove that normally used CoFreeUnusedLibraries certainly should free FLS indexes allocated by COM DLL (at least, by AutoHotkey.dll), I did some experiments:
Spoiler (click to show/hide)

So, I think this is where SMP can be improved.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-07-26 15:15:44
@thisbanisnotsettoexpire : that's quite a research you did there =)
I'm not sure if this is SMP bug, since it seems that AHK reserves new FLS on every execution, but as I said I will add some GC on panel unload.

Not sure when will it happen though, since MS released a broken Visual Studio update, which made it impossible to compile SMP (and I just can't find enough motivation to go through the whole VS reinstallation process to get the working VS back).
<rant>This f***ing s***-show makes me wonder if they even go through QA before making a release...</rant>
<rant intensifies>And don't even get me started on this f***ing disgusting compact title-bar...</rant>
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2019-07-26 20:44:01
@thisbanisnotsettoexpire : that's quite a research you did there =)
I'm not sure if this is SMP bug, since it seems that AHK reserves new FLS on every execution, but as I said I will add some GC on panel unload.

Not sure when will it happen though, since MS released a broken Visual Studio update, which made it impossible to compile SMP (and I just can't find enough motivation to go through the whole VS reinstallation process to get the working VS back).
<rant>This f***ing s***-show makes me wonder if they even go through QA before making a release...</rant>
<rant intensifies>And don't even get me started on this f***ing disgusting compact title-bar...</rant>
Is this VS2019 - 16.2.0 you're talking about?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: thisbanisnotsettoexpire on 2019-07-27 04:07:27
As far as I can understand from sources, SMP allows to pass JS function as argument to COM object method. Passed function is wrapped in IDispatch-able gateway and this function could be invoked from COM object side by using gateway's ExecuteValue() (https://github.com/TheQwertiest/foo_spider_monkey_panel/blob/8a02533ad58ced877ace97dae7d482e5da5c17de/foo_spider_monkey_panel/convert/com.cpp#L79) method.

AutoHotkey_H COM object can assign value to variable in AutoHotkey script with ahkassign (https://hotkeyit.github.io/v2/docs/commands/ahkassign.htm) method. Though documentation says that only string value can be passed to that method and assigned to variable, in fact, as AutoHotkey_H sources show, CoCOMServer::ahkassign (https://github.com/HotKeyIt/ahkdll/blob/af0541bcb57240bcfbf29884cf358367be27962b/source/dllmain.cpp#L803) recognizes different COM types (calling AssignVariant (https://github.com/HotKeyIt/ahkdll/blob/af0541bcb57240bcfbf29884cf358367be27962b/source/script_com.cpp#L757), then VariantToToken (https://github.com/HotKeyIt/ahkdll/blob/af0541bcb57240bcfbf29884cf358367be27962b/source/script_com.cpp#L620)). By passing VT_DISPATCH COM value to ahkassign, it's possible to assign AutoHotkey object to AutoHotkey script variable and then invoke IDispatch methods from AutoHotkey side by using same-named object methods.

I successfully tested this functionality of AutoHotkey_H COM object with Python script:
Spoiler (click to show/hide)

But when I used AutoHotkey_H COM object in SMP JS script in the same way as in Python script, trying to call JS function from AutoHotkey script side, it produced access violation error on ExecuteValue() call from AutoHotkey script.

JS script code:Spoiler (click to show/hide)

In tests I used following versions: Spoiler (click to show/hide)

I tried to trace SMP code with OllyDbg, found that ExecuteValue() is really called on SMP component side and (if my understanding is right) in this line (https://github.com/TheQwertiest/foo_spider_monkey_panel/blob/8a02533ad58ced877ace97dae7d482e5da5c17de/foo_spider_monkey_panel/convert/com.cpp#L97)
Code: [Select]
JS::RootedObject jsGlobal( pJsCtx_, heapMgr.Get( globalId_ ).toObjectOrNull() );
heapMgr.Get( globalId_ ) returned 0.

If I'm right, can it be fixed? (Just asking about possibility, not pushing to do it ASAP.)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: thisbanisnotsettoexpire on 2019-07-28 15:29:04
While, looking at the SMP code, I can find CoFreeUnusedLibraries (https://github.com/TheQwertiest/foo_spider_monkey_panel/blob/9252b68ba8caca8cecc0a9a9f64b76c8bacd314a/foo_spider_monkey_panel/js_objects/active_x_object.cpp#L420), I believe, in real usage component doesn't always work as expected.

Trying to prove that normally used CoFreeUnusedLibraries certainly should free FLS indexes allocated by COM DLL (at least, by AutoHotkey.dll), I did some experiments:

So, I think this is where SMP can be improved.
In that experiments I used CoUninitialize and it was critical for successful results, but, while it's OK to use this function in the end of execution of standalone script, now I believe (basing on CoUninitialize documentation (https://docs.microsoft.com/en-us/windows/win32/api/combaseapi/nf-combaseapi-couninitialize)), that using it in SMP is either not allowed at all, or at least would require cooperation between author of foobar2000, authors of all other components and author of SMP (i.e. it's impractical).

Turns out, just using CoFreeUnusedLibraries wasn't enough to produce noticable releasing of FLS indexes, because
Quote
CoFreeUnusedLibraries does not immediately release DLLs that have no active object. There is a 10-minute delay for multithreaded apartments (MTAs) and neutral apartments (NAs). For single-threaded apartments (STAs), there is no delay.

No, it's not a quote from CoFreeUnusedLibraries documentation (https://docs.microsoft.com/ru-ru/windows/win32/api/combaseapi/nf-combaseapi-cofreeunusedlibraries), it's a quote from CoFreeUnusedLibrariesEx documentation (https://docs.microsoft.com/en-us/windows/win32/api/combaseapi/nf-combaseapi-cofreeunusedlibrariesex). Thanks a lot, Microsoft.

CoFreeUnusedLibrariesEx is specifically provided to set explicit delay for unloading DLLs with a way to force the unloading of DLLs without any delay, though remarks in CoFreeUnusedLibrariesEx documentation warn against forcing immediate unloading of DLLs.

With using CoFreeUnusedLibrariesEx I can consistently release FLS indexes in test script without CoUninitialize:
Spoiler (click to show/hide)

The problem is, with any reasonable delay (even reasonably small delay), there probably would still be no useful change in my original SMP's usage scenario (in the concrete case of using statically linked AutoHotkey DLL), because in reloading script new AutoHotkey COM object would be created by reloaded script in a time smaller than that delay and then AutoHotkey DLL wouldn't be unloaded and allocated FLS indexes wouldn't be released and foobar2000 will still crash after repeated script reloading.

But anyway, it looks like this particular mysterious mystery of strange mystery is resolved and, with this information, maybe TheQwertiest will come up with some heuristic to use the possibility of setting COM DLLs unload delay.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-07-29 13:17:50
Is this VS2019 - 16.2.0 you're talking about?
Yup

I tried to trace SMP code with OllyDbg, found that ExecuteValue() is really called on SMP component side and (if my understanding is right) in this line (https://github.com/TheQwertiest/foo_spider_monkey_panel/blob/8a02533ad58ced877ace97dae7d482e5da5c17de/foo_spider_monkey_panel/convert/com.cpp#L97)
Code: [Select]
JS::RootedObject jsGlobal( pJsCtx_, heapMgr.Get( globalId_ ).toObjectOrNull() );
heapMgr.Get( globalId_ ) returned 0.

If I'm right, can it be fixed? (Just asking about possibility, not pushing to do it ASAP.)
This should not ever happen - it's a bug.
Can you try the nightly build (see OP for the link) and check if the bug persists?

PS: Thanks for the detailed repro steps!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: thisbanisnotsettoexpire on 2019-08-08 14:58:49
I tried to trace SMP code with OllyDbg, found that ExecuteValue() is really called on SMP component side and (if my understanding is right) in this line (https://github.com/TheQwertiest/foo_spider_monkey_panel/blob/8a02533ad58ced877ace97dae7d482e5da5c17de/foo_spider_monkey_panel/convert/com.cpp#L97)
Code: [Select]
JS::RootedObject jsGlobal( pJsCtx_, heapMgr.Get( globalId_ ).toObjectOrNull() );
heapMgr.Get( globalId_ ) returned 0.
I changed debugger from OllyDbg to x64dbg (https://x64dbg.com/) (it has 32-bit version and can debug 32-bit code, despite the name) and, coincidentally, place of error also changed. I didn't try to debug with OllyDbg again, so I can't say whether I was just plainly wrong in quoted bug report, or there was some misunderstanding on my side. However, after several attempts at debugging with x64dbg, I successfully found bugfix.

I patched foo_spider_monkey_panel v1.2.1 (https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/tag/v1.2.1) DLL at following offsets (from the beginning of file):
OffsetOriginal valuePatched value
0x3F7790xFF0x90
0x3F77A0xD70x90
Originally I used runtime patching ability of x64dbg and exported patch in .1337 format. It looks like offsets in this patch are not from the beginning of the file, so it wasn't useful for me per se, but for completeness I paste it here:Spoiler (click to show/hide)

Original values are assembled as CALL EDI instruction and patch replaces it with NOPs.

In terms of C++ sources, patch removes this line (https://github.com/TheQwertiest/foo_spider_monkey_panel/blob/667bfffec3df96a8e8b36b70240739d728eddeac/foo_spider_monkey_panel/js_objects/active_x_object.cpp#L812) in ActiveXObject::Invoke method:
Code: [Select]
VariantClear( &args[i] );

After patching, I can execute JS script from quoted post without any errors, but with producing expected result of appending an entry to foobar2000 console. As ExecuteValue method is the default member of SMP's COM object (i.e. it is identified by DISPID_VALUE (https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-oaut/cb9d0131-c6bd-463d-9c40-7264856a10c5)), it can also be invoked from AutoHotkey side by using following syntax: Spoiler (click to show/hide)

If I'm right, can it be fixed? (Just asking about possibility, not pushing to do it ASAP.)
This should not ever happen - it's a bug.
Can you try the nightly build (see OP for the link) and check if the bug persists?
After replacing foo_spider_monkey_panel v1.2.1 to v1.2.2-beta+8a02533a I observe Access Violation error on the ahk.ahkExec('f.ExecuteValue()'); line. Though I can't say that it's the same bug. In absence of .pdb for nightly and having working stable DLL, I didn't try to debug nightly to find the cause of error.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-08-08 15:56:04
@thisbanisnotsettoexpire : that's some extensive debugging!
It's really weird though that `VariantClear` causes errors: it just cleans up arguments that were generated for function call (and it should be safe for well-formed COM types). Not doing this will cause memory leaks.

Nevertheless, I can't test nor debug this (nor continue the component development) since I still don't have a working Visual Studio installation: current version (16.2) is broken and I couldn't find a way to download the previous release...

PS: Corresponding .pdb symbols (as well as a debug build) are available on the appveyor agent - https://ci.appveyor.com/project/TheQwertiest/foo-spider-monkey-panel/builds/26070987/job/nxn00otulu6tyrl7/artifacts
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: thisbanisnotsettoexpire on 2019-08-09 14:06:02
It's really weird though that `VariantClear` causes errors: it just cleans up arguments that were generated for function call (and it should be safe for well-formed COM types). Not doing this will cause memory leaks.
Thanks for hint. I guess then it's working, but wrong solution. VariantClear (https://docs.microsoft.com/en-us/windows/win32/api/oleauto/nf-oleauto-variantclear):
Quote
clears a VARIANTARG by setting the vt field to VT_EMPTY. The current contents of the VARIANTARG are released first. [...] If the vtfield is VT_DISPATCH, the object is released.

So I've took an attempt to come up with solution from other side and patched AutoHotkey_H DLL v2.0-a100-H104:
Spoiler (click to show/hide)

It changes 0x6A 0x00 to 0x6A 0x01, i.e. PUSH 0 to PUSH 1.

In terms of original source, it modifies function CoCOMServer::ahkassign (https://github.com/HotKeyIt/ahkdll/blob/af0541bcb57240bcfbf29884cf358367be27962b/source/dllmain.cpp#L803) by changing argument false in function call (https://github.com/HotKeyIt/ahkdll/blob/af0541bcb57240bcfbf29884cf358367be27962b/source/dllmain.cpp#L812) to true:
Code: [Select]
AssignVariant(*var, value, false);

It means that AssignVariant (https://github.com/HotKeyIt/ahkdll/blob/af0541bcb57240bcfbf29884cf358367be27962b/source/script_com.cpp#L757) is called with argument aRetainVar = true, then VariantToToken (https://github.com/HotKeyIt/ahkdll/blob/af0541bcb57240bcfbf29884cf358367be27962b/source/script_com.cpp#L620) is called with argument aRetainVar = true, then reference count for an interface pointer to a COM object is incremented (https://github.com/HotKeyIt/ahkdll/blob/af0541bcb57240bcfbf29884cf358367be27962b/source/script_com.cpp#L718).

I'm not sure that it's correct bugfix (is AutoHotkey_H really must be responsible for incrementing reference counter?), but it also works with Spider Monkey Panel v1.2.2-beta+8a02533a.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-08-09 16:22:13
After some incredible shenanigans I've managed to get myself a working VS2019 16.1 installation (no thanks to Microsoft)!
Anyways...

@thisbanisnotsettoexpire : I've managed to reproduce your crash - it seems that the COM object passed to `ahkassign` does not have it's counter incremented.
Code: [Select]
...
function f();
...
ahk.assign('f', f);
...
SMP wraps function `f` in a COM object and passes it to `ahk.assign`.
So, we have the following scenario:
- COM object is created from JS object. It has a usage counter equal to 1.
- COM object is passed to ahk.assign. Usage counter was not incremented in ahk.assign.
- Local (to SMP) COM object is destroyed. Usage counter is decremented to zero thus the VARIANT is destroyed as well.
- If ahk tries to use said (destroyed) COM object it will invoke UB and most likely crash.

Quote
    is AutoHotkey_H really must be responsible for incrementing reference counter?
Yes, because the caller does not how the passed object will be utilized. COM object handling is the same as shared_ptr.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-08-09 17:06:29
@thisbanisnotsettoexpire : I've tested with the debug build of AHK and my guess was proven true - AHK assign does not increase ref count. This is the code which assigns my COM object to internal ASH variable: https://github.com/HotKeyIt/ahkdll/blob/7e6d355db20d6faf59d8a15fcc908b52ff7b5d80/source/script_com.cpp#L731
There is no reference increments going on unless aRetainVar was set to true (which is not the case for `ahkassign`).

[EDIT] Moreover, it seems that `ahkassign` will actually DECREASE refcount of the incoming object WITHOUT incrementing it in some cases (invoking UB if the caller didn't increase refcount) : e.g. https://github.com/HotKeyIt/ahkdll/blob/7e6d355db20d6faf59d8a15fcc908b52ff7b5d80/source/script_com.cpp#L698
This code is flawed and I can't find any sensible scenario when it would be a correct approach. Your AHK patch *is* the correct fix.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-08-12 12:02:11
Well f**k... VS 2019 was updated to 16.2 on the build agent, so now SMP can't be built there... And there is still no answer from Microsoft on this issue...
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: cerbaire on 2019-08-19 16:24:01
It's not an easy problem. You can try to look at the code of the Biography script by Wilb, there (https://hydrogenaud.io/index.php/topic,112913.msg929674.html#new), it calls a VBScript in order to download images (well his VBScript can actually download any kind of file).

Thank you Ottidix and TheQwertiest. It works great. It was finally quite simple but I did no get the idea by myself !
Another question ; I have an error 'can't access dead object' !
Any suggestion on why this error is raised ?
I will check the livecycle of my object, but if you have any clue (I reset SMP parameters in 'Advanced / Tools / SMP settings, but not sufficient)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Ottodix on 2019-08-19 16:43:30
Another question ; I have an error 'can't access dead object' !
Any suggestion on why this error is raised ?

It completely depend of your code, there is a lot of possible scenarios. One common mistake : if you send a object from another panel using window.NotifyOthers(name,info), you need to clone the object inside the corresponding callback on_notify_data(name,info) of the receiver panel, you can't just assign by reference to another variable. Because the "info" object is destructed at the end of this function.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-08-20 12:09:20
@cerbaire , Ottodix's suggestion is entirely correct. You can find more info about it in the documentation of `on_notify_data` callback (you can access HTML documentation via 'Configure...'>'Help'>'View Help').
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: cerbaire on 2019-08-20 17:05:13
@cerbaire , Ottodix's suggestion is entirely correct. You can find more info about it in the documentation of `on_notify_data` callback (you can access HTML documentation via 'Configure...'>'Help'>'View Help').

Thanks for your responses. I understand the problem, and I think I am not in the scenario of a on_notify_data call.
My object is a FbMetadbHandle stored in a list. I will check on which event I am binded, but I think I instantiate my object directly in the panel script so it is not binded to any documented SMP event. I check that tonight and let you know.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Ottodix on 2019-08-21 09:58:05
Then it's really impossible to help without the code, you can debug it yourself though. You can use a function like:

Code: [Select]
function debug_dead_item(metadb_list,index){
    console.log("desired index: "+index+", list length: "+metadb_list.length);
    console.log(metadb_list[index].RawPath);
}

Put checkpoints in your code with this function in order to trace when/where this object was available and when/where it's not anymore, and then you'll probably understand what's going on. This function will crash if the list or if the specified index doesn't exist, but it doesn't matter, the crash message will be as good an information than the console messages.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-08-21 10:28:32
Thanks for your responses. I understand the problem, and I think I am not in the scenario of a on_notify_data call.
My object is a FbMetadbHandle stored in a list. I will check on which event I am binded, but I think I instantiate my object directly in the panel script so it is not binded to any documented SMP event. I check that tonight and let you know.
The problem might be delayed: e.g.
Code: [Select]
// Pseudo code

let arr = []
on_notify_data(data) {
  // no error
  arr.push_back(data);
}

on_mouse_click() {
  // error
  console.log(arr[0].Path);
}
On another note: what SMP version are you using?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: cerbaire on 2019-08-21 12:18:14
Thanks for your responses. I understand the problem, and I think I am not in the scenario of a on_notify_data call.
My object is a FbMetadbHandle stored in a list. I will check on which event I am binded, but I think I instantiate my object directly in the panel script so it is not binded to any documented SMP event. I check that tonight and let you know.
The problem might be delayed: e.g.
Code: [Select]
// Pseudo code

let arr = []
on_notify_data(data) {
  // no error
  arr.push_back(data);
}

on_mouse_click() {
  // error
  console.log(arr[0].Path);
}
On another note: what SMP version are you using?

I am using last nightly build available.
In the panel code, I call GetPlaylistItems(-1) in a setTimeout() and store index and FbMetadbHandle returned by GetPlaylistItems. Later, in a on_mouse_lbtn_up, I use the previous stored FbMetadbHandle, and it fail.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-08-21 14:22:02
I am using last nightly build available.
In the panel code, I call GetPlaylistItems(-1) in a setTimeout() and store index and FbMetadbHandle returned by GetPlaylistItems. Later, in a on_mouse_lbtn_up, I use the previous stored FbMetadbHandle, and it fail.
That's really weird. Can you provide a minimal repro scenario? So that I could reproduce it locally.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: cerbaire on 2019-08-22 00:14:50
I am using last nightly build available.
In the panel code, I call GetPlaylistItems(-1) in a setTimeout() and store index and FbMetadbHandle returned by GetPlaylistItems. Later, in a on_mouse_lbtn_up, I use the previous stored FbMetadbHandle, and it fail.
That's really weird. Can you provide a minimal repro scenario? So that I could reproduce it locally.
You're right ! I was storing FbMetadbHandle in a function called from on_notify_data, and using that handle after the callback end.
I replace the handle by the RawPath property and it works better!
Thank you for putting me in the right direction.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-08-22 11:16:49
You're right ! I was storing FbMetadbHandle in a function called from on_notify_data, and using that handle after the callback end.
I replace the handle by the RawPath property and it works better!
Thank you for putting me in the right direction.
No! You are using it wrong! Please, read documentation for the `on_notify_data`...
Your usage (for both FbMetadbHandle and FbMetadbHandle.RawPath) is covered explicitly in the method description.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: cerbaire on 2019-08-22 13:51:56
You're right ! I was storing FbMetadbHandle in a function called from on_notify_data, and using that handle after the callback end.
I replace the handle by the RawPath property and it works better!
Thank you for putting me in the right direction.
No! You are using it wrong! Please, read documentation for the `on_notify_data`...
Your usage (for both FbMetadbHandle and FbMetadbHandle.RawPath) is covered explicitly in the method description.
Right! I now use JSON.parse(JSON.stringify(metadb)) to store a copy of my handle and it works lke a charm. Thanks.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-08-22 15:17:06
Right! I now use JSON.parse(JSON.stringify(metadb)) to store a copy of my handle and it works lke a charm. Thanks.
Uhm... no...

Code: [Select]
...
 If you want to store the data from `info` you have to perform a deep copy:
- `String(info)` for strings.
...
So if you want to store `metadb.RawPath`, you store it like this:
Code: [Select]
// Pseudo code
g_storage = []
on_notify_data(metadb)
{
  // `String` performs a deep copy
  g_storage.push_back(String(metadb.RawPath))
}

You can't serialize `metadb` since it's not a serializable object (i.e. it will be restored into a simple struct instead after deserialization).
To clone metadb you'll have to clone metadbhandlelist instead (metadb does not have a copy constructor):
Code: [Select]
// Pseudo code
g_storage = []
on_notify_data(metadb)
{
  // FbMetadbHandleList constructor always performs a deep copy
  let tmpHandleList = new FbMetadbHandleList(metadb);
  g_storage.push_back(tmpHandleList[0]);
}
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2019-08-29 07:24:11
Is there a way to get an arbitrary URL to open in a browser from FSM (or jscript)? I was thinking this was simple, then when I tried to implement it, I realized that all the times I'd seen it done required foo_run, along with pre-defined URLs.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: thisbanisnotsettoexpire on 2019-08-29 10:11:42
Is there a way to get an arbitrary URL to open in a browser from FSM (or jscript)? I was thinking this was simple, then when I tried to implement it, I realized that all the times I'd seen it done required foo_run, along with pre-defined URLs.
Maybe Shell.ShellExecute (https://docs.microsoft.com/en-us/windows/win32/shell/shell-shellexecute) will work?
Code: [Select]
const objShell = new ActiveXObject("Shell.Application");
objShell.ShellExecute("https://hydrogenaud.io");
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: zeremy on 2019-08-29 12:53:42
Is there a way to get an arbitrary URL to open in a browser from FSM (or jscript)? I was thinking this was simple, then when I tried to implement it, I realized that all the times I'd seen it done required foo_run, along with pre-defined URLs.

Use Wshshell.Run with WScript.Shell

Sample function
https://github.com/marc2k3/smp_2003/blob/ed613ee3875cc914ea102a763758457431cdfc25/js/helpers.js#L516
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-08-29 15:42:35
Back from my holidays, the lastfm album art downloader is not working anymore. It is an old script by marc2003 that I modified now and then. It is quite obvious that the reason is a change in the lastfm web page HTML code. It is likely a silly problem, but I'm not familiar with HTML, so maybe someone here can help me out.

The following is - as far as I understand - the relevant code which needs some change:
Code: [Select]
include(fb.ComponentPath + 'samples\\complete\\js\\lodash.min.js');
include(fb.ComponentPath + 'samples\\complete\\js\\helpers.js')
include(fb.ComponentPath + 'samples\\complete\\js\\panel.js');

var x = new ActiveXObject("Microsoft.XMLHTTP");
var ar = panel.tf("$meta_sep(artist,', ',' and ')");
var al = panel.tf("%album%");

x.open("GET", "https://www.last.fm/music/" + encodeURIComponent(ar) + "/" + encodeURIComponent(al) + "/+images", true);
x.setRequestHeader("If-Modified-Since", "Thu, 01 Jan 1970 00:00:00 GMT");
x.send();

var o = _.first(_.filter(_getElementsByTagName(x.responseText, "img"), {"className" : "image-list-image"}));


The issue is in the last line of the above code. It used to fetch the first of the album covers on the album lastfm page, such as this one (https://www.last.fm/music/Alessandro+Alessandroni/Prisma+Sonoro/+images). I've been looking at this part of the HTML code (from line 1077 in the aforementioned example page):
Code: [Select]
    <ul class="image-list">
       
            <li class="image-list-item-wrapper">
                <a href="/music/Alessandro+Alessandroni/Prisma+Sonoro/+images/829db16b90ed471cbbfe248ef08ada39" class="image-list-item">
                    <img
                        src="https://lastfm-img2.akamaized.net/i/u/avatar170s/829db16b90ed471cbbfe248ef08ada39.webp"
                        alt="None"
                    >
                </a>
            </li>
       
            <li class="image-list-item-wrapper">
                <a href="/music/Alessandro+Alessandroni/Prisma+Sonoro/+images/72cd2e7b55604336b9003de58bf58d24" class="image-list-item">
                    <img
                        src="https://lastfm-img2.akamaized.net/i/u/avatar170s/72cd2e7b55604336b9003de58bf58d24.webp"
                        alt="None"
                    >
                </a>
            </li>
       
            <li class="image-list-item-wrapper">
                <a href="/music/Alessandro+Alessandroni/Prisma+Sonoro/+images/d002704049d844f4ba5dcc647614a483" class="image-list-item">
                    <img
                        src="https://lastfm-img2.akamaized.net/i/u/avatar170s/d002704049d844f4ba5dcc647614a483.webp"
                        alt="None"
                    >
                </a>
            </li>
       
    </ul>


I guess the parameters in the _getElementsByTagName function do not match the page HTML code anymore, but I cannot reference it properly.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2019-08-29 17:31:23
Maybe Shell.ShellExecute (https://docs.microsoft.com/en-us/windows/win32/shell/shell-shellexecute) will work?
Code: [Select]
const objShell = new ActiveXObject("Shell.Application");
objShell.ShellExecute("https://hydrogenaud.io");

Use Wshshell.Run with WScript.Shell

Sample function
https://github.com/marc2k3/smp_2003/blob/ed613ee3875cc914ea102a763758457431cdfc25/js/helpers.js#L516
Thanks, guys. thisban's code worked great, but I already had Marc's helper script in my theme so I saved a line of code :)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2019-08-29 17:37:42
Back from my holidays, the lastfm album art downloader is not working anymore. It is an old script by marc2003 that I modified now and then. It is quite obvious that the reason is a change in the lastfm web page HTML code. It is likely a silly problem, but I'm not familiar with HTML, so maybe someone here can help me out.

The following is - as far as I understand - the relevant code which needs some change:
...

I guess the parameters in the _getElementsByTagName function do not match the page HTML code anymore, but I cannot reference it properly.
A few things:
1) The img's don't have "image-list-image" class attached to them anymore, so all images are being filtered out. You'd have to completely remove the _.filter section, or first get all "a" tags and filter by class="image-list-item" and then get all images from inside those. I haven't used those methods enough to know how to write that relevant code though.
2) Those are .webp images. Can SMP even handle those, presuming they can be scraped correctly?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-08-29 19:18:44
A few things:
1) The img's don't have "image-list-image" class attached to them anymore, so all images are being filtered out. You'd have to completely remove the _.filter section, or first get all "a" tags and filter by class="image-list-item" and then get all images from inside those. I haven't used those methods enough to know how to write that relevant code though.
2) Those are .webp images. Can SMP even handle those, presuming they can be scraped correctly?

Thanks, I'll try your suggested fixes. I don't know about the webp format yet. I wanted to fix the file download anyway, as a mean to better understand how to use the xmlhttp object. I found instructions on how to manually download the webp file as a jpg, so maybe it's possible to edit the code in order to emulate such method. Perhaps a better alternative would be to get the jpg url from the meta tag (line 65 of the HTML code in the above example page). This might be my next question.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-08-30 10:25:02
@davideleo , I think it should be fixed with the latest marc2003 scripts (https://github.com/marc2k3/smp_2003). Download them and put them in samples/complete.

@MordredKLB , SMP doesn't support .webp images.
[EDIT] MSDN indicates that there's some built-in support for .webp images, but there is no information on when and where such support is available (https://docs.microsoft.com/en-us/windows/win32/gdiplus/-gdiplus-constant-image-file-format-constants)

PS: I might have found a workaround that might allow me to work around MSVS issues.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-08-31 18:01:22
@davideleo , I think it should be fixed with the latest marc2003 scripts (https://github.com/marc2k3/smp_2003). Download them and put them in samples/complete.

Thanks for the link, but I cannot find the "Last.fm Album Art Downloader" script. As far as I know marc2003 stopped updating it since a few years, at least publicly.

However I tried fetching the jpg URL in the page metadata with this code:
Code: [Select]
let doc = new ActiveXObject('htmlfile');
doc.open();
doc.write(x.responseText);                       
var o = doc.querySelector("meta[property='og:image']").getAttribute("content");
doc.close();

The code correctly assigns the url, such as this one (https://lastfm-img2.akamaized.net/i/u/ar0/829db16b90ed471cbbfe248ef08ada39.jpg), to the variable "o", but the "download" visual basic script doesn't seem to like it as an argument. The code that runs the visual basic script is the following:
Code: [Select]
_runCmd("cscript //nologo " + _q(fb.ComponentPath + "samples\\complete\\vbs\\download.vbs") + " " + _q(o) + " " + _q(f), false);
where the variable "f" is the destination filename.

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-09-03 17:11:18
The code correctly assigns the url, such as this one (https://lastfm-img2.akamaized.net/i/u/ar0/829db16b90ed471cbbfe248ef08ada39.jpg), to the variable "o", but the "download" visual basic script doesn't seem to like it as an argument.

Problem solved. The issue was a leftover line of the previous code (commented out in the script below) which I naively thought to be harmless.


Code: [Select]
                        let doc = new ActiveXObject('htmlfile');
                        doc.open();
                        doc.write(x.responseText);                       
                        var o = doc.querySelector("meta[property='og:image']").getAttribute("content");
                        doc.close();                     
// var u = o.src.replace("avatar170s", "ar0");
     _runCmd("cscript //nologo " + _q(fb.ComponentPath + "samples\\complete\\vbs\\download.vbs") + " " + _q(o) + " " + _q(f), false);
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: cerbaire on 2019-09-06 18:53:33
Hello,

When I use image in my panels, for example with gdi.Image('path.to.img'), I can't delete the file from filesystem without closing foobar2000. Is there a best practice to release image handle?
Kind regards,
Nicolas
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: spuuunit on 2019-09-14 09:45:27
Hi, I just noticed that when I print out the track title for example ( fb.TitleFormat('%title%'); ) the character & does not display correctly. This is what it looks like (https://imgur.com/WZFkRYk). It's not a huge deal, but it would be nice if I could fix it. And ideas?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-09-14 13:44:39
Hi, I just noticed that when I print out the track title for example ( fb.TitleFormat('%title%'); ) the character & does not display correctly. This is what it looks like (https://imgur.com/WZFkRYk). It's not a huge deal, but it would be nice if I could fix it. And ideas?
What method are you calling to print the text? Which font are you using?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-09-15 17:26:00
I'm a little confused about the encodeURIComponent() function.
The lastfm album art downloader script uses the function to get the right URL of the lastfm album page, like this:
Code: [Select]
include(fb.ComponentPath + 'samples\\complete\\js\\panel.js');

var x = new ActiveXObject("Microsoft.XMLHTTP");
var ar = panel.tf("$meta_sep(album artist,', ',' and ')");
var al = panel.tf("%album%");
x.open("GET", "https://www.last.fm/music/" + encodeURIComponent(ar) + "/" + encodeURIComponent(al), true);

This usually worked fine, but with the Damned's "The MCA Singles A's + B's" I got
https://www.last.fm/music/The%20Damned/The%20MCA%20Singles%20A's%20%2B%20B's (https://www.last.fm/music/The%20Damned/The%20MCA%20Singles%20A's%20%2B%20B's)
whereas the URL of the lastfm album page is
https://www.last.fm/music/The%20Damned/The%20MCA%20Singles%20A's%20%252B%20B's (https://www.last.fm/music/The%20Damned/The%20MCA%20Singles%20A's%20%252B%20B's)

The encodeURIComponent() function properly converts the "+" character to "%2B", but the lastfm URL shows a sort of double encoding converting the "%" character to "%25" in turn, and thus the "+" character becomes "%252B".
Therefore I changed the code applying the function twce, like this:
Code: [Select]
"https://www.last.fm/music/" + encodeURIComponent(encodeURIComponent(ar)) + "/" + encodeURIComponent(encodeURIComponent(al))
getting a weird
https://www.last.fm/music/The%2520Damned/The%2520MCA%2520Singles%2520A's%2520%252B%2520B's (https://www.last.fm/music/The%2520Damned/The%2520MCA%2520Singles%2520A's%2520%252B%2520B's)
which surprisingly (at least for me) works as well.

Can anybody explain me the logic of this double encoding?


Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-09-16 14:43:18
Can anybody explain me the logic of this double encoding?
It seem that's just a bug in lastfm url generation.
`encodeURIComponent` seems to perform exactly as it's described in JavaScript docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-09-16 14:48:13
Version: 1.2.2-preview
Link: https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/tag/v1.2.2-preview
Changelog:
Spoiler (click to show/hide)
Detailed description of API changes: https://github.com/TheQwertiest/foo_spider_monkey_panel/wiki/API-Changes#v122

PS: the version is called "preview", because it was built manually on my PC (instead of appveyor CI as before). Because of Microsoft shenanigans this is the only way right now. It will be republished as a proper non-preview version once MS fixes the bug (mind you, it's already been two months since the bug was reported). It will be the same though functionality-wise (unless there are bugs discovered, of course)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-09-16 15:32:52
It seem that's just a bug in lastfm url generation.
`encodeURIComponent` seems to perform exactly as it's described in JavaScript docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent

Yes, sorry my question was not clear enough. How come the double encoding works? Unlike my code, lastfm's bug generates a double encoding of only one percentage character in the URL. In other words, why does
https://www.last.fm/music/The%2520Damned/The%2520MCA%2520Singles%2520A's%2520%252B%2520B's (https://www.last.fm/music/The%2520Damned/The%2520MCA%2520Singles%2520A's%2520%252B%2520B's)
lead me to
https://www.last.fm/music/The%20Damned/The%20MCA%20Singles%20A's%20%252B%20B's (https://www.last.fm/music/The%20Damned/The%20MCA%20Singles%20A's%20%252B%20B's)?
It is as if all "%25" were interpreted as "%", but one.
Mind that triple encoding doesn't work.

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: spuuunit on 2019-09-16 20:55:00
What method are you calling to print the text? Which font are you using?

gr.GdiDrawText. Segoe UI, and that font has the '&' character.

Here's my code for clarity:
Code: [Select]
var font = gdi.Font("Segoe UI", 12, 0);
var play_pause = fb.TitleFormat('$if(%ispaused%,❚❚,▶)');
var title = fb.TitleFormat('%title%');
var time1 = fb.TitleFormat('%playback_time%');
var time2 = fb.TitleFormat(' / %length%');


function on_playback_pause() {
    window.Repaint();
}
function on_playback_new_track() {
    window.Repaint();
}
function on_playback_seek() {
window.Repaint();
}
function on_library_items_changed() {
window.Repaint();
}
function on_playback_time() {
window.RepaintRect(213, 3, 85, 12);
}


function Color(r, g, b) {
return 0xFF000000 | r << 16 | g << 8 | b;
}
function on_paint(gr) {
    var time_width = gr.CalcTextWidth(time1.Eval() + time2.Eval(), font);
    gr.FillSolidRect(0, 0, 1000, 1000, Color(240,240,240));
    gr.GdiDrawText(play_pause.Eval() + " " + title.Eval(), font, Color(0,0,0), 5, 1, 287 - time_width, 1000);
    gr.GdiDrawText(time1.Eval() + time2.Eval(), font, Color(0,0,0), 297 - time_width, 1, 1000, 1000);
}
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-09-16 21:45:13
@spuuunit : `GdiDrawText` (which uses `::DrawText` internally) uses `&` for some formatting rules (e.g. adding underscore to the following character). In your case you can just add `DT_NOPREFIX` flag (0x00000800) to the method. For more info about flags of `GdiDrawText` see corresponding section in docs/flags.js.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: spuuunit on 2019-09-17 17:39:55
@spuuunit : `GdiDrawText` (which uses `::DrawText` internally) uses `&` for some formatting rules (e.g. adding underscore to the following character). In your case you can just add `DT_NOPREFIX` flag (0x00000800) to the method. For more info about flags of `GdiDrawText` see corresponding section in docs/flags.js.

Oooh, I see. That makes sense. And thanks, I added that now. :)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Madthunder on 2019-09-18 19:31:05
I had a problem moving from 1.2.1 to 1.2.2 when using the updated jsplaylist-mod.

I seems like g_font_wd2 and g_font_wd3 were undefined in WSHplaylistmanager.js and WSHtopbar.js and so I had to add the following in both files (specifically, in the functions oPlaylistManager and oTopBar):

Code: [Select]
var g_font_wd2 = {
name: "Wingdings 2",
Size: 24
};

var g_font_wd3 = {
name: "Wingdings 3"
};

This fixes the problem for me.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-09-20 21:54:38
@Madthunder , nice catch! Will be fixed in the next release.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-09-30 16:09:52
@AndreaT , most likely you are using up all the memory =)

Quote
At least I can have it running for a while
Do you mean that the script doesn't fail immediately?

I will try to whip up a debug build that has a more detailed error message.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2019-10-02 16:27:44
@AndreaT , most likely you are using up all the memory =)

Quote
At least I can have it running for a while
Do you mean that the script doesn't fail immediately?

I will try to whip up a debug build that has a more detailed error message.

@TheQwertiest : Yes, exactly so, the script runs for a while, even for minutes, then it crashes randomly (but quite often when making a search or browsing/scrolling through the search's results).
Regards, Andrea
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-10-02 17:30:47
@AndreaT, does it fail always in the same place (i.e. OrderByRelativePath)? If not, does it produce the same error message ("allocation overflow") ?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Lasternom on 2019-10-04 16:40:59
Hi all,

I've got an questions. I'm trying to make a theme selector that would changes the whole colour scheme of foobar.
I was wondering if it's possible to change the default colours in Columns UI, as shown in the attached picture, this ofcourse with the SpiderMonkeyPanel.

My apologies If I'm asking this question in the wrong place.






Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-10-05 15:29:13
I've got an questions. I'm trying to make a theme selector that would changes the whole colour scheme of foobar.
I was wondering if it's possible to change the default colours in Columns UI, as shown in the attached picture, this ofcourse with the SpiderMonkeyPanel.

My apologies If I'm asking this question in the wrong place.
AFAIK, CUI/DUI does not provide such API, so SMP can't do much about it :\
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2019-10-07 17:47:56
@AndreaT, does it fail always in the same place (i.e. OrderByRelativePath)? If not, does it produce the same error message ("allocation overflow") ?

@TheQwertiest : I am sorry, I cannot be of help about, I didn't take care of that.
As soon as a new version with improved debugging will be available, I will reinstall the component and I will take care to update you more precisely.
Many thanks.
Kind regards, Andrea
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-10-10 00:19:53
PS: Nightly builds are up again! (thanks to Appveyor team!) (no thanks to Microsoft...)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2019-10-10 17:08:02
@TheQwertiest

SMP crash on Windows 10 Pro 32bit. But working perfectly on Windows 7 Ultimate 32bit

Hello, I don't know if this is a SMP problem or a problem of Biography 1.1.1, but this happens with FB 1.5 beta 17 and 18 on Windows 10 Pro 32bit ITA version.

To be noted that I am running exactly the same configuration also on Windows 7 Ultimate 32bit ITA without any significant problems.

Thanks and regards,
Andrea
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-10-11 10:36:29
@TheQwertiest

SMP crash on Windows 10 Pro 32bit. But working perfectly on Windows 7 Ultimate 32bit

Hello, I don't know if this is a SMP problem or a problem of Biography 1.1.1, but this happens with FB 1.5 beta 17 and 18 on Windows 10 Pro 32bit ITA version.

To be noted that I am running exactly the same configuration also on Windows 7 Ultimate 32bit ITA without any significant problems.

Well, you are out of memory =)
This error usually happens when there are too many images loaded (or the images are too big).
The difference between Win7 and Win10 might be caused by the difference in RAM/VRAM consumption by OS (i.e. Win10 consumes more memory than Win7).
PS: How much RAM and VRAM do you have?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2019-10-11 13:01:42
@TheQwertiest

I was not out of memory, I had over 1GB available.
I have 4GB total (the max for a 32bit OS).

And also I do not agree on Windows 10 consuming more memory of Win7, it is the contrary.

Foobar (exactly the same configuration) uses 1100MB on Win7 and only 950MB on Win10.

And, question, why you point to the memory while the error is speaking about an "image/window resize error"?

Regarding the image size and the like, Biography 1.1.1 is fetching images from internet. Usually are small, a matter of kB.

Regards,
Andrea
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-10-11 15:59:38
why you point to the memory while the error is speaking about an "image/window resize error"?
Because `Resize` does not modify the current image, but creates a new resized image from the old one.

It might be something else though: it seems that GdiPlus might return `OutOfMemory` error even if the error has nothing to do with memory...
Another thing you could check is the amount of GDI handles used: open Task Manager (CTRL-SHIFT-ESC) > Details > Right-Mouse-Button on column header > Select columns > Check `GDI objects`. This will display the current number of GDI objects used by process.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2019-10-13 08:20:20
@TheQwertiest

Hi, I checked the system and everything was within the normal limits.
So, I decided to remove the Biography script, delete all the sub-folders related to Biography, but not its install where the config files are.
Then I run Foobar again and reloaded the Biography script.
Doing so, it is finally working fine.
Probably there was something corrupted in the subfolders structure or in the ACL.
I think the real error was related to some disk write error / access denied in writing.
Regards, Andrea
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2019-10-19 08:13:18
@TheQwertiest
Hello TheQwertiest, I am just reminding you that I am still having this blocking error with Library Tree:

Error: Spider Monkey Panel v1.2.2-preview+0db3c6a4 (Library Tree v2.1.2 by WilB)
OrderByRelativePath failed:
allocation size overflow

File: <main>
Line: 542, Column: 61

Stack trace:
  Panel/this.sort@<main>:542:61
  rootNames@<main>:1205:48
  Library/this.getLibrary@<main>:1190:119
  Timers/this.lib/<@<main>:2911:115



I contacted WilB once more and he gave me this reply:

Reply #255 – 2019-10-17 18:54:23
As far as I am aware this seems to be a bug in spider monkey panel and outside of my control, but I am open to suggestions. I just tried again with a 642K test library & all was OK here. That particular error seems to be occurring on panel initialisation and is explicitly related to view by folder structure. So you could try a different view (if the error is locking you out you could open panel properties and find SYSTEM.View By [it's probably the last entry] and change it to 1 to set a different view).

I thought you were debugging the issue with @TheQwertiest? It sounds as though the issue is reproducible and so it ought to be possible to resolve the cause.

HTH
Last Edit: 2019-10-17 19:08:22 by WilB


Can you help me solving this issue?
Many thanks and kind regards, Andrea
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-10-24 21:02:27
@AndreaT , regretfully, I couldn't make the debug SMP build work (yet).
... The lack of free time doesn't help either ...
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2019-10-25 07:48:19
@TheQwertiest, no problem and thanks for having let me know.
If/when you will make it, kindly let me know and I will test it.
Many thanks and kind regards, Andrea.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-10-31 15:52:39
@AndreaT , here is the debug build for diagnosing `OrderByRelativePath` issue:
https://ci.appveyor.com/api/buildjobs/4fnfte0b2r6h8906/artifacts/_result%2FWin32_Release%2Ffoo_spider_monkey_panel.fb2k-component
https://ci.appveyor.com/api/buildjobs/4fnfte0b2r6h8906/artifacts/_result%2FWin32_Release%2Ffoo_spider_monkey_panel_pdb.zip

To turn on diagnostics you need:
1. Install *.fb2k-component as usual.
2. Unpack *_pdb.zip into the SMP component folder (e.g. `user-components/foo_spider_monkey_panel`).
3. Launch fb2k.
4. Preferences > Advanced > Tools > Spider Monkey Panel > C++ exception stack trace > Enable (tick).
5. Load WilB's Library Tree and reproduce the error.
6. Check fb2k console output for the stack trace.
7. Post console output here.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2019-10-31 15:59:05
@TheQwertiest : Many thanks! I will update you as soon as possible. Kind regards, Andrea
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2019-10-31 16:29:53
@TheQwertiest :
Hello TheQwerties, herein attached the log collected.
It should contains 3 or 4 "runs" in attempt to have the script running, but it always failed just at the initialization.
Looking forward
Kind regards, Andrea
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-10-31 17:49:43
Welp, I was right - you were out of memory =)
Good news though, I have an idea how to reduce memory usage here, which might fix your issue.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2019-10-31 17:55:03
Hi @TheQwertiest : I do not have the knowledge to question you, but I have to kindly notify you that I am having 1.5GB of physical free memory plus other 2 or 3GB of virtual memory available...
I do not understand how I can be out-of-memory...
Thanks and warm regards, Andrea
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kode54 on 2019-11-01 00:26:06
Virtual memory does not let you allocate more memory to a single process than can fit in its own memory space. For 32 bit applications, this is 2GB of user address space*. Even then, allocating more memory than is available can only force so much to page out to disk, and if those background processes are actively running, they cannot really be paged out so easily, without incurring a heavy load as they continue to access their own memory.

* Even with Large Address Aware, the limit is only 3GB.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: lvqcl on 2019-11-01 12:02:02
There's also such thing as memory fragmentation: https://stackoverflow.com/questions/3770457/what-is-memory-fragmentation
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: tuxman on 2019-11-01 12:11:59
Memory limits are exactly why I hesitate to try this. JavaScript virtual machines - like SpiderMonkey - have been proven to be not really low on resource usage. You pay a high price for having a non-native user interface.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-11-01 15:04:47
@tuxman , well each programming language has it's niche. I mean, SMP itself was written in C++, because performance and memory consumption matters for it's intended usage. But making a program in a compiled language requires much more effort than making it in a scripting language (especially for a casual user).

Regarding SMP: creating a panel component for fb2k in C++ requires quite a bit of code and a machine with configured IDE, but when using SMP (or JSP/WSH) you get that panel handling code for free and you don't need any IDE nor even a Notepad. SMP/JSP/WSH can be considered a higher level API wrapper around fb2k API, i.e. it might be not as flexible and performant, but it's much easier to use and requires much less insight in fb2k and/or Windows internals.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: tuxman on 2019-11-01 15:11:56
I don't think that a casual user should be able to write code. It is a profession for a good reason.
If resource usage would not matter, I'd dive deeper into Dopamine and similar players.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-11-01 15:28:25
@AndreaT , I've made a test SMP version, which has a revamped `OrderByRelativePath` implementation called `OrderByRelativePathV2`. To test it, you need to replace OrderByRelativePath with OrderByRelativePathV2 in WilB LibraryTree script.
Link to test version: https://ci.appveyor.com/api/buildjobs/pegl4h5tg2ms6noh/artifacts/_result%2FWin32_Release%2Ffoo_spider_monkey_panel.fb2k-component
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-11-01 15:36:44
@tuxman , I don't agree with you, but I don't think we can have a productive discussion on this topic, so I'll just drop it.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2019-11-01 17:59:15
@AndreaT , I've made a test SMP version, which has a revamped `OrderByRelativePath` implementation called `OrderByRelativePathV2`. To test it, you need to replace OrderByRelativePath with OrderByRelativePathV2 in WilB LibraryTree script.
Link to test version: https://ci.appveyor.com/api/buildjobs/pegl4h5tg2ms6noh/artifacts/_result%2FWin32_Release%2Ffoo_spider_monkey_panel.fb2k-component

@TheQwertiest : Many Thanks! I am going to do that. I will update you asap. Kind regards, Andrea
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kode54 on 2019-11-02 02:18:06
I don't think that a casual user should be able to write code. It is a profession for a good reason.
If resource usage would not matter, I'd dive deeper into Dopamine and similar players.
Thanks for being the gatekeeper to all things known as creative expression. Casual users should also stay away from composing music and crafting artwork as well. If it isn't a paying job, it isn't worth doing, right?

Oh, how could I be so stupid! Some kind soul has alerted me to my mistake. I have forgotten to include the fine profession of word craft. Lest we forget that you have not been paid for writing the above quoted post, so I should assume that it is not of your best quality. Do be sure to share something more akin to the writings of a professional author next time!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2019-11-02 11:14:46
@TheQwertiest :
Hello TheQwerties,

I installed your new SMP ver 1.2.3-beta (kindly note that I did NOT removed the debug library from the user-component directory and did not disabled the Advanced settings I set for the debug of the ver 1.2.3-test). I was supposed to keep all this as-is not having had different instruction.

Then I edited the Library Tree ver 2.1.2 JS as instructed (replacing all the occurances). Attached is the modified JS in case you would check if I did all right.

And this is the outcome:
1) What's good is that not Library Tree can start-up with the default view, there are no crash.
2) What's bad is that as soon as I select the View by Folder Structure, Foobar UI freezes and it doesn't came back to live even waiting 1+ hour. So, I have to kill the process Foobar.
To be noted that after the kill, I can restart Foobar and the Library Tree JS results not loaded in the target SMP panel (that panel configuration is lost or deleted by the system).

I tried this 5 times and all runs went exactly the same.
Unfortunately I could not collect any console log because of Foobar freeze.

Kindly let me know if you need me to execute some other tests or collect debug info.
Thanks and regards, Andrea
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-11-02 16:00:36
@AndreaT, could you create a memory dump during freeze? Instructions: https://github.com/TheQwertiest/foo_spider_monkey_panel/issues/61#issuecomment-470036761
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2019-11-02 16:09:47
@TheQwertiest : I will try right away. I will let you know asap.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Black_Over_Bills_Mothers on 2019-11-06 10:08:04
@Qwertyiest
Tidying my script to process new tracks. In this script I get a list of handles to be processed and then I used to call
fb.RunContextCommandWithMetadb("Tagging/Remove all pictures",myHandles,8);
to delete all embedded images. I've replaced this with the RemoveAttachedImages method of the handles list and it works great.

I also want to optimise my files so I currently use a context menu command;
fb.RunContextCommandWithMetadb("Utilities/Optimize file layout + minimize file size",myHandles,8);
However this generates a popup information box that I have to close every time. Would it be possible to create another method such as myHandles.OptimizeAndMinimize on the list of handles to avoid the popup message?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Black_Over_Bills_Mothers on 2019-11-09 08:56:34
Looks like our friend marc2k3 has implemented IMetadbHandleList OptimiseFileLayout in his foo_jscript_panel to address my request. Thanks marc2k3. Hopefully this will find it's way into the next foo_spider_monkey_panel.....please.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-11-09 18:01:02
@Black_Over_Bills_Mothers, sorry, I have quite a few things that I want (and need) to do in SMP, so it will have to wait for a bit. It is noted though, and I'll come back to it after I finish at least some of planned features.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-11-11 10:57:17
@AndreaT , latest nightly has OrderByRelativePath with integrated fix.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2019-11-11 12:05:59
Hello @TheQwertiest, many thanks for promptly notifing me.
I immediately tested the new Spider Monkey Panel v1.2.3-beta+61085bf2.
It is working well and in my case it saves approximately 75MB or RAM (compared with the special build you gave me dated 6 of November).
Great job!
Kind regards, Andrea
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-11-11 12:26:50
Quote
saves approximately 75MB or RAM (compared with the special build you gave me dated 6 of November)
It's probably caused by the new SpiderMonkey (JavaScript engine), which was updated in the nightly builds =)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2019-11-11 13:41:04
Quote
saves approximately 75MB or RAM (compared with the special build you gave me dated 6 of November)
It's probably caused by the new SpiderMonkey (JavaScript engine), which was updated in the nightly builds =)

@TheQwertiest : But I was not using V2 method. So, I think the 75MB savings is due to the new V2 method merged into the legacy V1.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-11-14 20:01:42
* double post removed *
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-11-14 20:02:50
First time I ever see this kind of error:
Quote
Error: Spider Monkey Panel v1.2.2-preview+0db3c6a4 (test by davideleo)
Font failed:
WinAPI error: CreateFont failed with error (0x0): The operation completed successfully.

The code which generates the error is as simple as this:
Code: [Select]
this.font = gdi.Font("Segoe UI", 12);

The crash occurs only once every two times.


Any clue?



P.S.
As a test, I replaced the error generating line with the following:
Code: [Select]
this.font =  window.GetFontCUI(0);

The script still crashes once every two times, but for a different reason:
Quote
Error: Spider Monkey Panel v1.2.2-preview+0db3c6a4 (test by davideleo)
FillSolidRect failed:
GdiPlus error: FillRectangle failed with error (0x2): InvalidParameter

Once again, the error-generatng line is as innocent as it can get:
Code: [Select]
gr.FillSolidRect(this.x, this.y, this.width, this.height, colours.LightGray);
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-11-15 10:42:48
@davideleo , can you try the latest nightly version and check if it has the same error?

As for `gr.FillSolidRect(this.x, this.y, this.width, this.height, colours.LightGray);` error, this usually happens when you supply invalid dimensions. E.g. zero height or width.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-11-15 14:21:15
Hi @TheQwertiest , I tested the script with the nightly build and it behaves in the exact same way, notifying the same errors.
Switching from one version to the other, I watched the behavior on startup, though, which I did not consider previously. The original script (the one with gdi.Font()) always crashes on startup and at the first attempt to reload it. Subsequent attempts alternate success and failure.
The "control" script (the one with window.GetFontCUI()) totally freezes foobar2000 on startup. I can hear the sound of the crash notification, but all I see is a blank window preview when I move the mouse over the taskbar icon (see the attached picture). I can start foobar2000 (albeit with a crash) only with the original script and replace it with the control script only once foobar2000 is running. The control script will than work and crash every other time.

Something I did not mention before is that it is not a proper crash: the code stops working, but the last painted window is not replaced by the "Aw, crashed :(" orange window (I have to manually resize the window to trigger that).


As for `gr.FillSolidRect(this.x, this.y, this.width, this.height, colours.LightGray);` error, this usually happens when you supply invalid dimensions. E.g. zero height or width.
For doubt's sake I outputted the FillSolidRect() arguments to the console and they are the same the one time it crashes and the one it works. 


P.S.
Maybe it's a clue, maybe not: I tried reverting to SMP v1.2.1 and found out that with this older version both scripts freeze foobar2000 on startup.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2019-11-16 12:28:26
Hello @TheQwertiest, I do not know why but yesterday I had again Out-of-memory errors (3 or 4 in a couple of hours) running Library Tree and the beta of SMP 1.2.3 dated (build 11 of November).
I do not remember to have done something different or unusual than the previous days...
The only big change in between is Windows 10 update from 1903 to 1909.
Kindly let me know if you need me collecting specific data/logs.
Regards, Andrea
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2019-11-16 20:21:07
Unresponsive script - Don't ask me again - Option NOT working

Hello @TheQwertiest, I noticed that even if I select the option "Don't ask me again", it doesn't work and every time I restart Foorbar I get the notifying window herein attached.

Kind regards, Andrea
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-11-17 14:34:11
Unresponsive script - Don't ask me again - Option NOT working
It's not supposed to persist between fb2k restarts, i.e. it's intentional. It only suppresses the warning in the current panel for the current fb2k instance.

Regarding OOM errors: not sure what I can do to help you. As I've said before, your library *is* huge and WilB's script is not designed for minimal memory usage (the performance of the script would have been likely worse if it was though - time-memory trade-off and all that). Maybe playing around with GC settings might help you (i.e. in preferences > advanced), but I have no specific suggestions :\

@davideleo , can you provide the script that reproduces the problem?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2019-11-18 07:21:29
@TheQwertiest, many thanks for your kind reply.
All the best, Andrea
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-11-19 19:18:42
@davideleo , can you provide the script that reproduces the problem?

I tried reverting to the error-generating version of the script, but I made too many edits since my last post. However, I was able to move on when I found out that the error was generated by too many repeated gdi.Font methods (the crash would occur after around 2000 iterations),

The following is a very simplified script with the same logic, which reproduces the same error:
Code: [Select]
include(fb.ComponentPath + "samples\\complete\\js\\lodash.min.js");


var artists = list("artist");
var grid = new Grid(artists, 12);


function Cell(fontSize){
this.font = gdi.Font("Segoe UI", fontSize);
}


function Grid(list, fontSize){
this.cells = list.map(() => {
return new Cell(fontSize);
})
}


function list(tag, handle_list = fb.GetLibraryItems()){
var tags = [];
var items = fb.GetQueryItems(handle_list, tag + " PRESENT");
for (var i = 0; i < items.Count; i++) {
var handle = items[i];
var values = fb.TitleFormat("$meta_num(" + tag + ")").EvalWithMetadb(handle);
for (var j = 0; j < values; j++) {
tags.push(fb.TitleFormat("$meta(" + tag + "," + j + ")").EvalWithMetadb(handle));
}
}
    return _.uniq(tags.sort(), true);
}

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-11-20 10:01:28
@davideleo , it seems that you've exhausted GDI handles. System can provide only so much GDI handles (the limit depends on the OS version and it's configuration). Since all GdiFont objects are being stored in the Grid/Cell, they can't be GC'd, thus GDI handles can't be freed. The resulting error report is weird though and I'll try to look into it.

That aside, you should reuse GdiFont objects whenever possible (instead of recreating them every time) for memory and performance sakes (and to avoid hitting GDI handle limit).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-11-25 20:31:07
I need the width of the playing playlist name on start up. According to the console log, I only have one on_paint event to exploit after the playing playlist is resumed, but I'd rather not overload the on_paint() callback if not strictly needed. So, is there another way to trigger the code when the playback state has been resumed, or alternatively a good reason not to?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-11-26 10:01:26
I need the width of the playing playlist name on start up. According to the console log, I only have one on_paint event to exploit after the playing playlist is resumed, but I'd rather not overload the on_paint() callback if not strictly needed. So, is there another way to trigger the code when the playback state has been resumed, or alternatively a good reason not to?
Not sure I understand your scenario. For playback state tracking you can use `on_playback*` callbacks (e.g. `on_playback_pause`). If you want to reduce workload in `on_paint`, you can always cache results (i.e. calculate width only if the playlist name changed).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-11-26 13:37:43
Not sure I understand your scenario.

The problem is only at startup. I use foobar2000 with the option to resume playback state checked and I never stop the player, I just  pause it. Therefore, foobar2000 starts with a playing playlist on. I have a drawtext function that takes the playing playlist name and the width of the playlist name, but the playing playlist name is not available until the very end of the startup process, when the only event left to use is the on_paint. So, is this the only option? I have no need to recalculate the width of the text at every on_paint, on_size would make more sense, but the last of the three on_size events at startup is before playlist initialization.
There is actually other stuff going on between the last on_size and the on_paint at startup, such as foo_enhanced_playcount being loaded, which makes me guess that I'd have the same issue if I were to retrieve scrobbling information at startup.
I kind of miss an on_startup_done() callback.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-11-26 19:57:04
Is there a way to temporary disable keyboard shortcuts?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-11-29 11:08:26
The problem is only at startup. I use foobar2000 with the option to resume playback state checked and I never stop the player, I just  pause it. Therefore, foobar2000 starts with a playing playlist on. I have a drawtext function that takes the playing playlist name and the width of the playlist name, but the playing playlist name is not available until the very end of the startup process, when the only event left to use is the on_paint. So, is this the only option? I have no need to recalculate the width of the text at every on_paint, on_size would make more sense, but the last of the three on_size events at startup is before playlist initialization.
There is actually other stuff going on between the last on_size and the on_paint at startup, such as foo_enhanced_playcount being loaded, which makes me guess that I'd have the same issue if I were to retrieve scrobbling information at startup.
I kind of miss an on_startup_done() callback.

Regretfully, fb2k does not provide `on_startup_done` callback and I can't implement it myself.

I have no need to recalculate the width of the text at every on_paint
As I've said, you can *cache* the value. Or just use a simple boolean guard
Code: [Select]
var isInitialized = false;
function on_paint()
{
  if (!isInitialized )
  {
    CalculateSmth();
    isInitialized =true;
  }
}

Quote
Is there a way to temporary disable keyboard shortcuts?
fb2k API does not provide such functionality.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-11-29 12:56:07
Regretfully, fb2k does not provide `on_startup_done` callback and I can't implement it myself.

I have no need to recalculate the width of the text at every on_paint
As I've said, you can *cache* the value. Or just use a simple boolean guard
Code: [Select]
var isInitialized = false;
function on_paint()
{
  if (!isInitialized )
  {
    CalculateSmth();
    isInitialized =true;
  }
}

I see. Thanks, I actually needed to be reassured that a workaround is needed here. I guess I'll just save the playing playlist name to a file, Talking of workarounds, I found out that you can trigger a few playlist events before the initial on_paint by adding and removing items to a playlist on start up. It's probably the closest you can get to an on_start_up_done.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-11-29 13:11:28
@davideleo , I've got some info from Peter (https://hydrogenaud.io/index.php?topic=117208.msg977811#msg977811), which clarified some things:
- It *might* be possible to create on_start_up_done callback. No promises or ETA though.
- on_paint and on_size callbacks *might* (and often will) be called before the fb2k is fully initialized.
[Edit]:
- It *is* possible to suppress shortcuts. But no promises or ETA on that either.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-11-29 13:16:45
 8)  You are my favorite foobar2000 component developer ♥
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-11-29 13:30:38
Haha, thanks =)
Though I don't think I deserve this title. There are far more qualified developers (e.g. musicmusic, CUI dev).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-11-29 13:51:49
- on_paint and on_size callbacks *might* (and often will) be called before the fb2k is fully initialized.

What I refer to as "start up" is probably autoplaylist initialization really. The console log shows the start up time right after all autoplaylists are set, therefore I gathered that was the last stand of the start up process. This is my usual start up log:


Quote from:  console.log
components loaded
configuration read
on_size
Spider Monkey panel initialized
on_size (3 times)
UI initialized
foo_custom_database initialized
autoplaylist initialized
foo_enhanced_playcount loaded
start up done (at least start up time is written here in the console log) <-----------------
possible playlist events
on_paint


Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2019-12-01 13:56:03
Hello @TheQwertiest, hoping to find you well, I am getting to you just to have an idea of when you would release the new SMP with the v1 and v2 methods merged together.
I am waiting for it in order to use Library Tree (I have then to remove because of the too frequent out-of-memory crashes).
Kind regards, Andrea
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-12-01 14:55:08
@AndreaT, it's still quite far from release, but you can use Nightly version in the meantime (Nightly/beta doesn't mean "not stable" ), it has v2 sorting method integrated.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2019-12-01 17:57:11
@AndreaT, it's still quite far from release, but you can use Nightly version in the meantime (Nightly/beta doesn't mean "not stable" ), it has v2 sorting method integrated.

Hello @TheQwertiest, ... thanks ... but your last Nightly build I downloaded few hours ago cannot be installed.
I am getting an installation error. I tried 3 times.
If you need the error code, let me know and I will try to reinstall again.
Thanks and regards, Andrea
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-12-02 10:19:52
I am getting an installation error. I tried 3 times.
If you need the error code, let me know and I will try to reinstall again.
That's really weird. Is there a error message or smth like that?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2019-12-02 13:16:09
Hello @TheQwertiest, this is the error I get during the installation process:
"Could not load component "foo_spider_monkey_panel.fb2k-component": bad allocation"

I downloaded right now the Nightly buid from your GitHub project page: https://github.com/TheQwertiest/foo_spider_monkey_panel
using the link you provided for the nightly build:
link https://ci.appveyor.com/api/projects/theqwertiest/foo-spider-monkey-panel/artifacts/_result%2FWin32_Release%2Ffoo_spider_monkey_panel.fb2k-component?branch=master&job=Configuration%3A%20Release

Regards, Andrea
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-12-02 15:03:22
@AndreaT, Hmm... can you try installing debug version and see if it works?
Link: https://ci.appveyor.com/api/buildjobs/iyyt6dttpmkuf98y/artifacts/_result%2FWin32_Debug%2Ffoo_spider_monkey_panel.fb2k-component_debug
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-12-02 16:36:08
I need some clarification about memory usage. I'm monitoring the panel and the total memory usage of a one SMP only configuration and I was expecting the two values to coincide. Instead, panel memory usage reaches 52 MB before GC kicks in, while total memory usage is more or less stuck on 2 MB. How is that? Why is total memory usage lower than panel memory usage?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2019-12-02 17:51:11
Hello @TheQwertiest , I am getting the same error: Could not load component "foo_spider_monkey_panel.fb2k-component": bad allocation.

By the way, is it correct that this package is 57MB in size and that I had to rename the file removing the ending "_debug"?

Regards, Andrea
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-12-02 18:15:50
I need some clarification about memory usage. I'm monitoring the panel and the total memory usage of a one SMP only configuration and I was expecting the two values to coincide. Instead, panel memory usage reaches 52 MB before GC kicks in, while total memory usage is more or less stuck on 2 MB. How is that? Why is total memory usage lower than panel memory usage?
What smp version are you using?

Hello @TheQwertiest , I am getting the same error: Could not load component "foo_spider_monkey_panel.fb2k-component": bad allocation.
Hm... That's really weird. Can you check if installation of the latest release version (v1.2.2) works? I'm not even sure if it's a SMP error anymore...
Oh and what's your fb2k version?

By the way, is it correct that this package is 57MB in size and that I had to rename the file removing the ending "_debug"?
Yes, that's correct. Another user has informed me that I forgot to include some files though, so it wouldn't have worked even if your installation succeeded.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-12-02 18:25:32
What smp version are you using?

v1.2.2-preview+0db3c6a4
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-12-02 18:31:14
v1.2.2-preview+0db3c6a4
Calculating total memory usage is actually not a `free` operation in terms of performance (compared to panel memory usage), so to minimize performance impact it uses cached value, which is updated every GC cycle. In some cases (e.g. yours) this might result in incorrect values. I'll see if smth can be done to make reported values more accurate.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-12-02 18:35:50
Thanks for the answer. Since it's a one-panel configuration, can I presume the total memory consumption to be that of the only panel, or does the component use more memory besides the panel shares?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-12-02 18:41:26
Thanks for the answer. Since it's a one-panel configuration, can I presume the total memory consumption to be that of the only panel, or does the component use more memory besides the panel shares?
SMP needs additional memory for JS engine and for internal usage, but it's safe to assume that panel is the one that contributes the most to memory usage (unless it contains nothing :P).
The memory impact of SMP will be close to zero (citation needed), if there are no SMP panels active.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2019-12-02 20:52:31
Hello @TheQwertiest, I am sorry, I have bad news: no way for me to install ever the v1.2.2-preview.
I am getting the same error.
I would like to try to remove the current version I have running:

Spider Monkey Panel v1.2.3-beta+61085bf2 by TheQwertiest
Based on JScript Panel by marc2003
Based on WSH Panel Mod by T.P. Wang

Build: 10:49:05, Nov 11 2019
Columns UI SDK Version: 6.5


But what about if then I cannot reinstall any?

Regards, Andrea
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-12-09 15:04:37
Created a basic website for SMP documentation - https://theqwertiest.github.io/foo_spider_monkey_panel
Notable features:
- Built-in script documentation (the one that is currently supplied with the component): https://theqwertiest.github.io/foo_spider_monkey_panel/docs/script_documentation/javascript_api
- Script showcase (more like `script list` currently, but I will work on that): https://theqwertiest.github.io/foo_spider_monkey_panel/docs/script_showcase
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-12-09 15:33:24
👍👍👍
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-12-09 17:14:04
Quote from:  console.log
components loaded
configuration read
on_size
Spider Monkey panel initialized
on_size (3 times)       <=======
UI initialized
foo_custom_database initialized
autoplaylist initialized
foo_enhanced_playcount loaded
start up done (at least start up time is written here in the console log) <-----------------
possible playlist events
on_paint

One way or another, I always stumble on this multiple on_size() fire at start up. I never read other users having problems with it, so I wonder if I'm simply ignoring some document or some common good practice.
Some time ago I learnt that the full window width and height are not available until the last of the three events and consequently instructed my scripts to check the window size before making calculations on it. I relied on the assumption that the window size is either full or 0. But today I found out that the second on_size() sets the window to an intermediate measure, which my code was not expecting. Did the start up procedure change with one of the last updates? Or is it just me, finding out in dribs and drabs how things work ?
Working around such issues is quite easy, as long as I understand correctly what is going on under the hood. Clearly analyzing the console log and making guesses is not enough. Can anybody explain me once and for all how the panel initialization works and why? What is the safe way to initialize objects and variables with values relative to the window size?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: seongbin on 2019-12-09 18:33:00
Maybe a stupid question (non-programmer btw)....
Is there any difference between SMP and JScript or WSH while rendering text with GdiDrawText? Feels like it is slightly different in details especially for CJK characters, actually SMP has much better effect.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-12-09 23:19:51
Here's a javascript puzzle not strictly related to SMP, I hope it is not too off topic.

I'm working on a nested objects system, where each object is an item in an array property of a container object. The methods of the container object execute the method with the same name in the nested objects. This is done by calling another method - the forward() method in the code below - so the container constructor function has the following structure:
Code: [Select]
function Container(){
this.items = [obj1, obj2, obj3...];
this.method1 = (...args) => {this.forward('method1', ...args)};
this.method2 = (...args) => {this.forward('method2', ...args)};
this.method3 = (...args) => {this.forward('method3', ...args)};
...
this.methodN = (...args) => {this.forward('methodN', ...args)};
this.forward = (method, ...args) => {
this.items.forEach((item) => {if (method in item) item[method](...args)});
}
}

Since the methods from 1 to N have the same pattern I thought I could make them perfectly alike and thus simply reference the forward() method for all. What I need is to ditch the "method" argument in the forward() method and retrieve it by code from the caller method's name. But it turns out it is harder than I thought. Ideally I would like to write something like:
Code: [Select]
function Container(){
this.items = [obj1, obj2, obj3...];
this.method1 = this.forward;
this.method2 = this.forward;
this.method3 = this.forward;
...
this.methodN = this.forward;
this.forward = ( ...args) => {
this.items.forEach((item) => {
let method = //...code to retrieve the caller*** method's name
if (method in item) item[method](...args)});
}
}

//***if this kind of code did work like I mean, the container's method would not be a caller anymore, just a reference.

It looks like such a typical scenario for javascript that I'm confident there must be a way, but everything I tried failed. Do you have any suggestion?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-12-10 10:28:54
It looks like such a typical scenario for javascript that I'm confident there must be a way, but everything I tried failed. Do you have any suggestion?
Retrieving caller information was deemed a problematic feature for multiple reasons:
- Makes some optimizations impossible.
- Easy to abuse to make code unreadable.
- (Web-specific) potential security vulnerabilities.

There is `Function.caller` (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/caller), which can be abused to get the name of the function. But this will not be performance friendly (constant regexp parsing) and this method is unavailable in strict mode anyway.

Maybe a stupid question (non-programmer btw)....
Is there any difference between SMP and JScript or WSH while rendering text with GdiDrawText? Feels like it is slightly different in details especially for CJK characters, actually SMP has much better effect.

No intentional changes on my side =)
The only thing I can think of, is that I target Windows 7 as a minimum supported OS, while WSH and JSP target Windows XP, so that could've affected the way GdiDrawText is called, theoretically.

Did the start up procedure change with one of the last updates?
Nope.

Working around such issues is quite easy, as long as I understand correctly what is going on under the hood. Clearly analyzing the console log and making guesses is not enough. Can anybody explain me once and for all how the panel initialization works and why?
Are you using SMP panel as a standalone CUI/DUI panel? Or is it a part of smth like PSS?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-12-10 16:22:37
There is `Function.caller` (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/caller), which can be abused to get the name of the function. But this will not be performance friendly (constant regexp parsing) and this method is unavailable in strict mode anyway.

Yes, I tried that and it actually crashed the panel, because indeed I am using strict mode. But then, why does this function I use for debugging purposes work in strict mode?
Spoiler (click to show/hide)


Retrieving caller information was deemed a problematic feature for multiple reasons:
- Makes some optimizations impossible.
- Easy to abuse to make code unreadable.
- (Web-specific) potential security vulnerabilities.

I read a bit about this topic in the last days, in search for a solution, and I understand that these caller methods are vestiges of a pre-named-functions era in javascript, but it is exactly the name of the function that I need to have, not the function itself, which is probably the only case when a caller method makes sense. I also understand how uncertain it is to rely on a "function name", which is actually not a property of the function, just one of many possible references to it. But when that reference is an object property, it is definitely more reliable.

Whatever. All in all it seems that the ECMA guys know what they are doing. The thesis that if you think you need the caller method, there is likely a better way to do what you are trying to do, turned out to be true, at least for me. As is often the case, posting the problem on the forum cleared my mind and I realized I actually don't need the method's name, I actually don't need all those methods at all, but just the forward method with an argument, from the head of the chain, so my container constructor is now something like this:
Spoiler (click to show/hide)

It might be a little meaningless out of context, but I got rid of several lines of code and the final result is a lot more concise than it would have been with a caller-like workaround. Sorry if this was a waste of time, but I just wanted to witness the wisdom of javascript constraints, which I was cursing until yesterday night, and blessing today for pushing me into better coding.


Are you using SMP panel as a standalone CUI/DUI panel? Or is it a part of smth like PSS?

I was using PSS, but since I don't need it (thanks for reminding me!), I removed it and tested it again, with CUI and with DUI. The on_size() callback is always triggered three times in a row, and the window size is always 0x0 on the first, full width x full height on the third and intermediate values in the second, but these are different with DUI, CUI and PSS.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-12-11 00:40:44
For reasons I don't understand, it only works with columns ui, maybe some more advanced coder can figure out why,

I still don't understand the reason, but at least now I know that to make it work in DUI I need to set the window dialog code to 4 (DLGC_WANTALLKEYS). At first I thought the reason was the default dlgcode in CUI, but I checked and with both UI, SMP has a default dlgcode set to 0. Can anybody explain me why DUI needs a different dlg code to take key events?

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: zoumbro on 2019-12-13 06:14:31
dear developer(s)

I am facing the following message after installing the latest fsmp version.
I am using latest foobar 1.5 and I have attached a report of installed components.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-12-16 10:35:29
But today I found out that the second on_size() sets the window to an intermediate measure, which my code was not expecting.
I could not reproduce this behaviour, do you have a reproducible scenario?

Regarding repeated on_size calls: these are only invoked when the panel receives WM_SIZE message (except for one extra invocation which will be removed in the next version. These messages might be triggered by fb2k, by DUI, by CUI or by system itself. SMP just translates this native system message to JS callback.

I am facing the following message after installing the latest fsmp version.
I am using latest foobar 1.5 and I have attached a report of installed components.

You probably didn't install all the required fonts (which are listed in readme.md in samples folder).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-12-16 16:09:49
I could not reproduce this behaviour, do you have a reproducible scenario?

Yes, a very simple one: clean portable installation (v1.5.1 beta 2) with only two extra components: spider monkey panel and columns ui. No library, no playlists.
The columns ui layout is just one spider monkey panel, as a base, with this script:
Code: [Select]
function on_size(){
    console.log("width: " + window.Width, "height: " + window.Height);
}

And here's the console output on startup:
nk=msg=978394 date=1576492529]
Regarding repeated on_size calls: these are only invoked when the panel receives WM_SIZE message (except for one extra invocation which will be removed in the next version. These messages might be triggered by fb2k, by DUI, by CUI or by system itself. SMP just translates this native system message to JS callback.

I get it. After reading your explanation I recreated the above scenario without CUI and here's the console log:
Quote from: the console log
width: 0 height: 0
width: 1364 height: 653

The height is lower than CUI in the final size because of the toolbars.
So, it looks like the intermediate sizing is triggered by CUI. Problem solved. I don't need CUI actually, but for removing toolbars. BTW, replacing a whole interface only to get rid of the toolbars is kind of ridiculous, isn't it?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2019-12-16 20:33:21
Hello @TheQwertiest, I have a big problem with Foobar 1.5 beta 2 crashing at start while loading SMP.

I also tried the last nightly build having the same crash on start.
Probably the case to notify also Peter. I didn't do yet.

Attached the crash report files

Kind regards, Andrea
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: zoumbro on 2019-12-17 08:29:29
But today I found out that the second on_size() sets the window to an intermediate measure, which my code was not expecting.
I could not reproduce this behaviour, do you have a reproducible scenario?

Regarding repeated on_size calls: these are only invoked when the panel receives WM_SIZE message (except for one extra invocation which will be removed in the next version. These messages might be triggered by fb2k, by DUI, by CUI or by system itself. SMP just translates this native system message to JS callback.

I am facing the following message after installing the latest fsmp version.
I am using latest foobar 1.5 and I have attached a report of installed components.

You probably didn't install all the required fonts (which are listed in readme.md in samples folder).

I have all fonts installed (Guifx v2 Transports, fontawesome-webfont,wingdings2.ttf and wingdings3.ttf).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-12-17 10:17:05
@AndreaT , a known issue that I've actually fixed already, but forgot to merge into master branch >_<
Will be up shortly (in a nightly build).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2019-12-17 10:39:13
Hello @TheQwertiest, thanks for the prompt reply.
Please, if you don't mind, kindly drop me a message (here or private) when the new Nightly Build is ready for testing.
Many thanks and kind regards, Andrea
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-12-17 11:11:01
@AndreaT, nightly build with the fix is up.

@zoumbro , I was reminded by @marc2k3 (https://github.com/marc2k3) that it's a known (and fixed) problem in the script. Regrettably, there is no release build yet which has the fix. So, you can either download the nightly build (see OP for the link), or download and replace all the scripts manually (https://github.com/TheQwertiest/foo_spider_monkey_panel/tree/master/component/samples)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2019-12-17 21:45:56
Hello @TheQwertiest, well done! Now it works fine again. Many thanks. Regards, Andrea
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-12-19 19:18:06
I'd like to get back to this (https://hydrogenaud.io/index.php?msg=971543) clipping procedure, which as far as I understand is the SMP translation of this (https://docs.microsoft.com/en-us/dotnet/framework/winforms/advanced/restricting-the-drawing-surface-in-gdi#see-also) windows GDI+ clipping technique. As far as clipping i concerned, it works as it should, but the text rendering sucks. I didn't realize this at first because I was working with white text on black background. In the code below, I added some text in the clipped region and changed the colours to make the problem visible.

Code: [Select]
include(fb.ComponentPath + "docs\\helpers.js");

let font = gdi.Font("segoe UI", 16);
let myRegion = new PaintRegion(100, 100, 200, 200)


function on_paint(gr){
gr.FillSolidRect(0, 0, window.Width, window.Height, colours.DarkGray);
gr.GdiDrawText("TEST", font, colours.White,110, 70, 100, 20)
    myRegion.paint(gr);
}


function PaintRegion(x, y, w, h){
    this.x = x;
    this.y = y;
    this.w = w;
    this.h = h;
    this.paint = (gr) => {
gr.FillSolidRect(this.x, this.y, this.w, this.h, colours.Pink);
        var clipImg = gdi.CreateImage(this.w, this.h)
        var grClip = clipImg.GetGraphics();

grClip.GdiDrawText("TEST", font, colours.White, 10, 10, 100, 20)
grClip.DrawEllipse(100, 50, 200, 200, 2, colours.White);

        clipImg.ReleaseGraphics(grClip);
        gr.DrawImage(clipImg, this.x, this.y, this.w, this.h, 0, 0, this.w, this.h)
    }
}

In the attached picture you can see the outcome. The first line of text on gray background is drawn with the regular graphics object passed by the on_paint callback, the one below, in the pink clipped region is drawn with the clipped graphics object. SetTextRenderingHint and SetSmoothingMode didn't help.

How can I avoid this blurred effect?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-12-20 00:36:44
How can I avoid this blurred effect?

So, apparently the problem is the DrawText function. Once more posting to the forum helped me find the answer. I finally found a case where you actually need the DrawString method.

P. S.
Upon reading some window .NET docs on GDI+ and TextRender, I have the impression that the use of DrawString is strongly encouraged, whereas I get the opposite idea from the SMP docs. Are the two methods actually the same? And what are the drawbacks of replacing DrawText with DrawString, anyway?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-12-20 10:01:32
Upon reading some window .NET docs on GDI+ and TextRender, I have the impression that the use of DrawString is strongly encouraged, whereas I get the opposite idea from the SMP docs. Are the two methods actually the same? And what are the drawbacks of replacing DrawText with DrawString, anyway?
DrawString is worse than DrawText in most cases. DrawText has better performance and better rendering unless used on a transparent surface (as mentioned in SMP docs).
One of the sources: https://stackoverflow.com/questions/1203087/why-is-graphics-measurestring-returning-a-higher-than-expected-number/6404811#6404811

Regarding your problem. Quote from docs (https://theqwertiest.github.io/foo_spider_monkey_panel/assets/generated_files/docs/html/GdiGraphics.html#GdiDrawText):
Quote
GdiDrawText
    Provides faster and better rendering than GdiGraphics#DrawString.

    Do not use this to draw text on transparent background or with GdiGraphics other than the one passed in on_paint callback: this will result in visual artifacts caused by ClearType hinting.
    Use GdiGraphics#DrawString instead in such cases.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2019-12-20 14:01:12
DrawString is worse than DrawText in most cases. DrawText has better performance and better rendering unless used on a transparent surface (as mentioned in SMP docs).
One of the sources: https://stackoverflow.com/questions/1203087/why-is-graphics-measurestring-returning-a-higher-than-expected-number/6404811#6404811

Thanks, this was very, very useful.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: seongbin on 2019-12-28 00:51:02
Firstly, MERRY X MAS! and thx for the great component.
It looks like DrawImage() in SMP is generating left and top border by default. How can I avoid this?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2019-12-28 10:25:44
Firstly, MERRY X MAS! and thx for the great component.
It looks like DrawImage() in SMP is generating left and top border by default. How can I avoid this?
o/
What version of SMP are you using?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: seongbin on 2019-12-28 20:43:58
o/
What version of SMP are you using?
I am using v1.2.2-preview+0db3c6a4. I tried simply comment out the relevant line in JScommon.js as below, but the borders are still there in jssb.
Code: [Select]
function drawImage(gr, img, src_x, src_y, src_w, src_h, auto_fill, border, alpha) {

if (border) {
// gr.DrawRect(src_x, src_y, src_w - 1, src_h - 1, 1, border);
}
}

-eidt-
I digged google a little bit, it looks like borders are generated during resizing images
https://mariusschulz.com/blog/preventing-ghost-borders-when-resizing-images-with-system-drawing
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kowal24 on 2020-01-02 21:21:06
Hi
Today my AV shows info about virus in file foo_lastfm_img.vbs. Anyone have the same problem?

(https://i.imgur.com/KiD3xEp.jpg)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: seongbin on 2020-01-05 12:12:10
-eidt-
I digged google a little bit, it looks like borders are generated during resizing images
https://mariusschulz.com/blog/preventing-ghost-borders-when-resizing-images-with-system-drawing


NVM, simply resolved by setting interpolation mode as "0" in relevant functions.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-01-10 15:54:50
@seongbin , glad to hear that your problem was resolved. Sorry for the lack of answers - was on a vacation and (mostly) away from the internet...

@kowal24 , false-positive (you can view the code of the script to manually verify that).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Ottodix on 2020-01-23 09:21:35
Hi,

I've got an issue related to search query and multi values tags.
I'm searching in my whole library the tracks by an artist simply named "bob".
I could do
fb.GetQueryItems(fb.GetLibraryItems(), "%artist% IS bob");
but then it won't return the tracks tagged with multi values, like "bob; nirvana".

In order to include the tracks tagged with multiple artists, I could do
fb.GetQueryItems(fb.GetLibraryItems(), "%artist% HAS bob");
but then it will return all tracks with bob inside their artist name, like bob dylan, and not all tracks by the artist simply named "bob".

Does someone there have an idea? Thanks!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-01-27 10:50:16
Does someone there have an idea? Thanks!
fb.GetQueryItems uses fb2k query rules. I.e. you can use and test this query in default CUI playlist_view search. So I think you are more likely to get a proper answer if you create a separate thread in General forum section.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-02-04 14:56:04
Version: 1.2.3
Link: https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/tag/v1.2.3
Changelog:
Spoiler (click to show/hide)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-02-04 14:58:51
Note: I've decided to make this Maintenance release, because a full Feature release is still far away from being ready...
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-02-04 18:55:19
Reuploaded v1.2.3. It shouldn't crash anymore now =)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: wcs13 on 2020-02-08 00:41:35
Hi :) Some time ago with WSH Panel component, I was using the "Thumbs" script by marc2003.
It's a nice script that displays not only a main pic, but several thumbs of other pics that you can select by clicking on them, etc.. Plus it's really customizable (e.g. I could edit lines 10 & 11 to change data folder and subfolders format).
So of course my question is : is there some port or equivalent script that I could use with Spider Monkey ? Thanks !
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MojoBass on 2020-02-08 04:18:42
Isn't this (https://github.com/marc2k3/smp_2003/blob/master/js/thumbs.js) Marcs smp version of his thumb.js? (not using it myself)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: mjm716 on 2020-02-08 05:47:47

So of course my question is : is there some port or equivalent script that I could use with Spider Monkey ? Thanks !

Yes Marc's old scripts are all ported to SMP and found in the default SMP install folder: foobar2000\user-components\foo_spider_monkey_panel\samples\complete
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: wcs13 on 2020-02-08 11:42:04
Got it :) Thanks MojoBass & mjm716 !

There is however one thing I can't get to work :
- With the old WSH script I could set a custom data folder, and then automatically download pics to that folder and subfolders. It worked perfectly.
- With the new SMP script I can set a custom folder structure (in my case it would be "D:\AUDIO\BIOS\artists\$meta(artist,0)"), and then the script displays the already existing pics... but there is no automatic download of new pics (e.g. when there are no pics yet, or where the number of existing pics is lower than the set limit).

If I change "Custom folder" to "Last.fm artist art" I see a "Download now" menu option, but :
- The download is manual, so I'd have to select "Download now" for every new song, which is painful for thousands of artists,
- The pics then get downloaded to %foobar folder%\js_data\artists\ , not to my custom folder.

Can I change this behaviour ? How ?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-02-08 13:40:12
@wcs13 ,  marc2003 removed automatic download option (AFAIK people abused it by settings download limit too high, thus violating LastFM rules, which prompted LastFm to block marc's API key), you can probably restore it by comparing the old script with the new one and copying all the relevant changes.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: wcs13 on 2020-02-12 16:20:00
I've been thinking about this. Rather than removing auto-download, maybe this would have been more useful  in marc's script ?

Idea 1 :
- Define two api_key variables : m_api_key = marc's one (somewhere in the middle of the script), and user_api_key = empty (to be filled by the user at the beginning of the script)
- "Download now" would use m_api_key, but "Auto download" would use user_api_key, so it would result in an error until user enters a valid user_api_key
Sure, an evil user could always try to tweak the script into using m_api_key for autoDL, but very few users would go through the hassle. Easier to just get a personal API Key and copy it in the very first lines of the script.

Idea 2 :
An even stricter solution : just define a single user_api_key variable (empty), so no DLs at all until user enters a valid key. But once he does, autoDL would work too.

My point being : if you're a developer, please don't break script's functionality just because of some (ab)users. Stop giving the API Key if needed, but never break functionality.
It harms the good guys, while at the same time any abuser with JS knowledge could restore function using marc's previous WSH script and keep abusing it.

Anyway, I'll wait until somehow this function can be restored : I already have a personal API Key, but I know little about JS so I can't do all those changes on my own. :(
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: mjm716 on 2020-02-13 02:54:24
Anyway, I'll wait until somehow this function can be restored : I already have a personal API Key, but I know little about JS so I can't do all those changes on my own. :(

It could be a loooong wait. WilB's absolutely amazing SMP/Biography script has better downloading capabilities and customization than Marc's script. I use them both myself.
https://hydrogenaud.io/index.php?topic=112914.0
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2020-02-13 08:40:43
Last update of complete samples should be attached. Includes automatic download options for Thumbs script.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-02-13 10:24:37
@wcs13 , @mjm716 , actually marc2003 re-added automatic download to the `Thumbs` script yesterday (he also corrected my misinformation about LFM API key requirement: the script actually parses LFM site manually without using LFM API). But, regretfully, he deleted his GitHub account shortly afterwards =(

@mjm716, I would say that one should use WilB's Bio script if they need everything in a single panel, and use marc2003's scripts if they want to separate various functionality in multiple different panels (e.g. `thumbs` and `last.fm bio` scripts).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-02-13 10:55:23
Last update of complete samples should be attached. Includes automatic download options for Thumbs script.
Thanks! (esp. for providing `.git` as well)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Smurth on 2020-02-13 18:42:31
Hello,

Is there a way to disable the default context menu (and NOT replacing it with another) ?

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: wcs13 on 2020-02-14 00:45:07
Quote from: mjm716
It could be a loooong wait
Quote from: snotlicker
Last update of complete samples should be attached. Includes automatic download options for Thumbs script.
Quote from: TheQwertiest
actually marc2003 re-added automatic download to the `Thumbs` script yesterday
Wow guys, that was faster than I expected !  :))
I have indeed updated the SMP samples and now autoDL seems to work again. Thank you !  :)

One question though :
- In "last.fm artist art" mode, art is downloaded to %foobar folder%\js_data\artists
- In "custom folder" mode, art isn't downloaded to the defined custom folder (ex : "D:\AUDIO\BIOS\artists\$meta(artist,0)" ). It just doesn't seem to be downloaded anywhere.
Am I doing something wrong ?

I'd really like the art to be downloaded to my big storage D: drive, and not to my small system C: drive.
Besides, I have several portable foobar installs, and I'd like them all to share the same art folder in order not to download art multiple times.
As a last resort, maybe I could edit the script and change the the default %foobar folder%\js_data\artists. Any hints on what line(s) I should edit ?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-02-14 12:17:25
Is there a way to disable the default context menu (and NOT replacing it with another) ?
Implement an empty `on_mouse_rbtn_up` callback that returns `true`. Corresponding docs: https://theqwertiest.github.io/foo_spider_monkey_panel/assets/generated_files/docs/html/module-callbacks.html#~on_mouse_rbtn_up
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Smurth on 2020-02-14 16:15:56
Implement an empty `on_mouse_rbtn_up` callback that returns `true`. (...)

Thank you very, very much ;)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kutuzof on 2020-02-21 18:58:15
Greetings!
I am not good at scripting. I want to create a menu for switching DSP presets. There is a switching code for the output device, but when I replace with "fb.GetDSPPresets()" the menu remains the same.
Code: [Select]
function getDSPPresetsMenu(x, y) {
x = Buttons.top_l.left;
y = Buttons.top_l.top;

    var menu = window.CreatePopupMenu();
    var str = fb.GetDSPPresets();
    var arr = JSON.parse(str);
    var active = -1;
    for (var i = 0; i < arr.length; i++) {
        menu.AppendMenuItem(0, i + 1, arr[i].name);
        if (arr[i].active) active = i;
    }

    if (active > -1) menu.CheckMenuRadioItem(1, arr.length + 1, active + 1);

    var idx = menu.TrackPopupMenu(x, y);
    menu;

    if (idx > 0) fb.RunMainMenuCommand("Playback/DSP settings/" + arr[idx - 1].name);
}
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Smurth on 2020-02-26 16:26:36
Hello,

I'm having an issue with fb.IsMainMenuCommandChecked()

The code below allow me to successfuly change the settings - all the defined settings - but it fail to retrieve the state of the "Playback/order/..." stuff. II can't understand why. Foobar's bug or SMP's bug ?
Or me ?

Code: [Select]
		let menu = window.CreatePopupMenu();
let ent = ['Order/Default','Order/Repeat (playlist)','Order/Repeat (track)','Order/Random','Stop after current','Playback follows cursor','Cursor follows playback'];
for (var i = 0; i < ent.length; i++) {
menu.AppendMenuItem(MF_STRING, i+1, ent[i].replace('Order/',''));
if (fb.IsMainMenuCommandChecked('Playback/' + ent[i])) {
menu.CheckMenuItem(i+1, true);
}
if (i == 3){
menu.AppendMenuSeparator();
}
}
const idx = menu.TrackPopupMenu(x, y);
if (idx>0) {
fb.RunMainMenuCommand('Playback/' + ent[idx-1]);
}
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Smurth on 2020-02-26 19:03:34
I'm having an issue with fb.IsMainMenuCommandChecked()
...

Sorry, I've missed plman.PlaybackOrder.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: wcs13 on 2020-02-27 23:51:04
Could somebody please answer this past question? Thank you  :)
- In "last.fm artist art" mode, art is downloaded to %foobar folder%\js_data\artists
- In "custom folder" mode, art isn't downloaded to the defined custom folder (ex : "D:\AUDIO\BIOS\artists\$meta(artist,0)" ). It just doesn't seem to be downloaded anywhere.
Am I doing something wrong ?

I'd really like the art to be downloaded to my big storage D: drive, and not to my small system C: drive.
Besides, I have several portable foobar installs, and I'd like them all to share the same art folder in order not to download art multiple times.
As a last resort, maybe I could edit the script and change the the default %foobar folder%\js_data\artists. Any hints on what line(s) I should edit ?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-02-28 12:46:31
@kutuzof , regarding `GetDSPPresets()`: yep, that's a bug. Fixed in the nightly build.

@Smurth , regarding `IsMainMenuCommandChecked()`: yep, that's a bug as well - this command didn't work properly for menu items that are hidden by default. Fixed in the nightly build.

@wcs13 , in `custom folder mode` images are loaded from the folder provided by user, so it doesn't download anything.
Folders for all marc's scripts are defined in `js\helpers.js` (search for `let folders = {};`). Beware that changing these paths will affect all scripts that are using said paths.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2020-02-28 16:28:19
@kutuzof , regarding `GetDSPPresets()`: yep, that's a bug. Fixed in the nightly build.

Hi @TheQwertiest , concerning this GetDSPPresets() function, I can see that it is listed in the autocomplete entries, but I cannot find any reference in the docs.  If it wasn't for @kutuzof 's post, I wouldn't know about it. Am I missing some source of information?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-02-28 18:15:48
Am I missing some source of information?
Yep, you should've read it from my mind :D
Anyways, it's indeed missing from docs. I'll add it soonish.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2020-02-28 19:24:28
Yep, you should've read it from my mind :D

 :)  I see, so that's @kutuzof 's secret superpower.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2020-02-28 20:43:11
No super powers required.  :-X

https://github.com/kbuffington/foo_jscript_panel/blob/54fc020f09f3a9fb54bdbed8f3c1e6755e4ff8a6/component/docs/Interfaces.txt#L282
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: wcs13 on 2020-02-28 23:14:48
@wcs13 , in `custom folder mode` images are loaded from the folder provided by user, so it doesn't download anything.
Folders for all marc's scripts are defined in `js\helpers.js` (search for `let folders = {};`). Beware that changing these paths will affect all scripts that are using said paths.
It all works perfectly now. You made my day ! :D
I'll remember that other scripts may use those paths, but so far I'm only using Marc's Thumbs and WilB's bio.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: wcs13 on 2020-02-29 01:45:23
BTW I have noticed what could be a glitch on marc's Thumbs script. It's easy to reproduce.
Let's say %artist% = "Bryan Lee & The Jump Street Five"
WilB's bio nicely creates a folder called "Bryan Lee & The Jump Street Five" and downloads relevant album art.
However, marc's Thumbs creates a folder called "Bryan Lee & The Jump Street" and of course can't download any album art so the folder remains empty.
Can somebody confirm this ?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2020-02-29 05:09:13
Bug reproduced. Those scripts used a 3rd party Javascript library called lodash and the way you supply arguments to one of the functions got changed when upgrading from the old version 3 used with JSP and the newer version 4 bundled with SMP

js\helpers.js line 197 replace

Code: [Select]
folder = folders.artists + _.truncate(a, 64);

with

Code: [Select]
folder = folders.artists + _.truncate(a, { length : 64 });


Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: anamorphic on 2020-02-29 05:32:08
I'll remember that other scripts may use those paths, but so far I'm only using Marc's Thumbs and WilB's bio.
Also, I imagine that when we update SMP, all edited sample scripts will get overwritten to defaults? So perhaps copy the edited samples folder elsewhere for use, or make note of the changes you made, I guess.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: wcs13 on 2020-02-29 09:30:02
@snotlicker : thanks, it worked indeed :)

@anamorphic : yes, I have already copied the edited samples AND made note of changes on separate txt files, just in case ;)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: wcs13 on 2020-02-29 12:11:19
I think I found another glitch :
If %artist% is empty but %composer% is filled, WilB's bio creates a %composer% folder and downloads info, but marc's Thumbs does nothing.
Any hints ?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-03-02 10:20:16
@snotlicker , thanks!
https://github.com/TheQwertiest/smp_2003/commit/c7d62119559fb1c46f4dcd43f74390b58f8f028e
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Anakunda on 2020-03-03 13:38:32
Hi,
would be SpiderMonkey able to capture metadata from online source, apply them to audio tags, and eventually transfer the cover to album folder? The similar task what Discogs plugin does, just for custom source. If that's possible, could I get a hint what functions to use for it. Also I'd appreciate an existing script previously made for the same purpose as a template, if some.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Miltiades on 2020-03-14 21:15:09
Hallo there,
I'm using (latest) foobar v.1.5.2. I have also SpiderMonkeyPanel, Biography and JScript Panel on latest version.
It was working properly, as it should since yesterday at the afternoon: I can't see either artist pictures nor pictures from covers.  I see only text (biography) but no pictures.
Any suggestions please?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: wcs13 on 2020-04-01 14:14:00
I'm bumping this because it's been a month :
If %artist% is empty but %composer% is filled, WilB's bio creates a %composer% folder and downloads info, but marc's Thumbs does nothing. Any hints ?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2020-04-01 18:31:41
https://github.com/TheQwertiest/smp_2003/blob/master/js/helpers.js#L628

If all your tags are single value, you could replace it with %artist% as that has automatic fallbacks built in...

https://wiki.hydrogenaud.io/index.php?title=Foobar2000:Title_Formatting_Reference#.25artist.25

If your tags are multi-value, you should use $meta to access the first value only...

Code: [Select]
$if2($meta(artist,0),$meta(composer,0))
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: wcs13 on 2020-04-03 03:09:45
Thank you. That worked indeed! My happiness is complete now :)

Yes, I totally get your code. I'm quite OK at Titleformat but I suck at JS. I only needed to find the right line(s) in the right file(s), so thank you for pointing this one out! I really appreciate.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: wcs13 on 2020-04-03 14:10:31
New bug report, in helpers.js, line 511 :

Code: [Select]
		app.Namespace(10).MoveHere(file);

Code: [Select]
Error: Spider Monkey Panel v1.2.3 (Thumbs by marc2003)
app.Namespace is not a function

File: helpers.js
Line: 511, Column: 3

Stack trace:
  _recycleFile@helpers.js:511:3
  _thumbs/this.rbtn_up_done@thumbs.js:461:4
  _panel/this.rbtn_up@panel.js:142:5
  on_mouse_rbtn_up@<main>:49:9
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2020-04-04 05:32:56
That would be a component bug. For now you can replace that line of code with

Code: [Select]
_deleteFile(file)

This bypasses the recycle bin though - files get deleted for good.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: mjm716 on 2020-04-04 16:37:01
I recently updated to 1.5.3 and have had a steady stream of crashes since. I can't really understand the reports, other than they seem to indicate SMP (and probably Marc's Thumb script)? (using v1.2.3)
Can anyone help me decipher these?

Code: [Select]
CRASH:
Error: Spider Monkey Panel v1.2.3 (Thumbs by marc2003)
CheckMenuRadioItem failed:
Index is out of bounds
File: thumbs.js
Line: 323, Column: 4
Stack trace:
  _thumbs/this.rbtn_up@thumbs.js:323:4
  _panel/this.rbtn_up@panel.js:85:4
  on_mouse_rbtn_up@<main>:49:9

Different CRASH
Error: Spider Monkey Panel v1.2.3 (Thumbs by marc2003)
DrawImage failed:
GdiPlus error: DrawImage failed with error (0x7): Win32Error
File: helpers.js
Line: 265, Column: 3
Stack trace:
  _drawImage@helpers.js:265:3
  _thumbs/this.paint@thumbs.js:92:23
  on_paint@<main>:58:2

different CRASH:
Error: Spider Monkey Panel v1.2.3 (Thumbs by marc2003)
DrawImage failed:
GdiPlus error: DrawImage failed with error (0x7): Win32Error
File: helpers.js
Line: 280, Column: 3
Stack trace:
  _drawImage@helpers.js:280:3
  _thumbs/this.paint@thumbs.js:136:23
  on_paint@<main>:58:2


Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2020-04-04 17:14:27
Code: [Select]
CheckMenuRadioItem failed:
Index is out of bounds

Pretty sure that's your fault for bypassing the available menu options and entering your own thumbnail size via the Properties dialog???
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: mjm716 on 2020-04-05 04:33:07
good lead - I do have one panel with custom thumb size. thank you, I'll see if that helps.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-04-06 12:15:23
New bug report, in helpers.js, line 511 :
Code: [Select]
		app.Namespace(10).MoveHere(file);
It might be a casing error, try replacing `Namespace` with `NameSpace`.

PS: component development is still on-going, if anyone was wondering =) The new (major) feature is just too non-trivial and it gets me frustrated all the time >_<
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: wcs13 on 2020-04-07 02:38:32
@TheQwertiest : casing error indeed! 'NameSpace' worked perfectly. Thanks, and please note the correction for future releases. Thanks again.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: cerbaire on 2020-04-09 22:45:07
PS: component development is still on-going, if anyone was wondering =) The new (major) feature is just too non-trivial and it gets me frustrated all the time >_<
I love your PS. Take care.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: SUPERCOOLMAN on 2020-04-10 07:42:33
hit a crash. I think it's having issue with some high res large png images. foo_uie_albumart allows user to pick resolution resizing quality, not sure if it's this problem or just not happy with the type of png file(s)
Code: [Select]
File: helpers.js
Line: 287, Column: 1

Stack trace:
  _drawImage@helpers.js:287:1
  _thumbs/this.size/<@thumbs.js:55:6
  r@lodash.min.js:5:356
  Xe@lodash.min.js:67:63
  _thumbs/this.size@thumbs.js:54:5
  _thumbs/this.update@thumbs.js:483:3
  _thumbs/this.metadb_changed@thumbs.js:167:3
  on_metadb_changed@<main>:33:2
  _panel/this.item_focus_change@panel.js:11:4
  on_item_focus_change@<main>:25:2
Spider Monkey Panel v1.2.3 (Thumbs by marc2003): initialized in 698 ms
Opening track for playback: "D:\ISU\OST_CD.cue" / index: 11
Error: Spider Monkey Panel v1.2.3 (Thumbs by marc2003)
Out of memory: 1754042880/1073741824 bytes


overall I'm just looking for something that allows folder name with wildcard searching and allows multiple folders with cycling through all supported arts
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Fabio258 on 2020-04-10 16:26:14
I'm searching a playlist viewer that can be linked to a specific playlist like EsPlaylist. Is it possible with jsplaylist? I've tried but It seems auto-linked to the active playlist  :(
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Air KEN on 2020-04-11 07:51:24
Hi.
Picture cannot be displayed with Microsoft Store foobar2000 (not foobar2000 mobile).
https://www.microsoft.com/store/apps/9PDJ8X9SPF2K
Text only.Biography, thumbs ...
Spider Monkey Panel and JScript Panel.

Thanks for the help.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: wcs13 on 2020-04-11 14:46:31
Hi, another question about Thumbs script :
I have noticed that downloaded images are often low-res, even when there are lots of hi-res images for the same artist on last.fm.
For some artists there are hundreds of images available, but the component just seems to pick the first ones.
Is there an option to either favor hi-res images, or the most upvoted ones, or to set a minimum res ?
If not, it would be a nice add-on. Thanks !
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2020-04-12 08:53:51
Look at this HTML and tell me which images are low/hi res. Thanks.

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: wcs13 on 2020-04-12 15:12:18
Hi @snotlicker , I just asked if there was an option that I wouldn't know about, because there are tons of things I don't know about.
If it's not possible, then it's not possible, but there's no need to be ironic.

Also, since I'm not a dev, I don't know if SMP scripts can check downloaded files.
Maybe we could download an unknown pic, then once downloaded check its dimensions, and if it's too small, just trash it and download the next one. I don't know!
https://www.tutorialrepublic.com/faq/how-to-get-current-image-size-in-javascript.php

Thanks :)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Falstaff on 2020-04-12 17:30:12
I'm searching a playlist viewer that can be linked to a specific playlist like EsPlaylist. Is it possible with jsplaylist? I've tried but It seems auto-linked to the active playlist  :(


HI,

as it is a script, you can modify jssplaylist to replace active playlist to a specific one, but it needs some changes to do that like replacing in script "plman.ActivePlaylist" with a variable that you have to set on init, by scanning existing playlists to find the index of the playlist you want to link to the playlist view (by playlist name testing imho ...)

HTH  ;)


Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-04-13 09:44:58
@SUPERCOOLMAN, it's an out of memory error. The script preloads all images from the folder without resizing them (so as to support dynamic size, e.g. when resizing player), so if there are a lot of big images, it might eat all of the available memory. It might be possible to avoid this issue by resizing images immediately after loading them, but this way there won't be a higher resolution image for dynamic resizing.

@Air KEN , MS Store sandboxes their apps (by disabling some operations), in this case it might have disabled some internet related API used by SMP. Nothing I can do to fix that, aside from rewriting the whole networking stack (which I won't be doing any time soon).

@wcs13 , it might be possible to implement such logic in the script (ignoring low-res images that is), but I'm currently prioritizing component development over script improvement. In other words it won't be fixed anytime soon, sorry.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2020-04-13 10:00:47
People getting out of memory errors with samples from the complete folder can open samples\complete\js\helpers.js and replace this function...

Code: [Select]
function _img(value) {
if (_isFile(value)) {
return gdi.Image(value);
} else {
return gdi.Image(folders.images + value);
}
}

with

Code: [Select]
function _img(value) {
let img;
if (_isFile(value)) {
img = gdi.Image(value);
} else {
img = gdi.Image(folders.images + value);
}

if (!img) return null;

const MAX_SIZE = 1000;
if (img.Width < MAX_SIZE && img.Height < MAX_SIZE) return img;

const s = Math.min(MAX_SIZE / img.Width, MAX_SIZE / img.Height);
const w = Math.floor(img.Width * s);
const h = Math.floor(img.Height * s);
return img.Resize(w, h);
}

Using the old function, I tested it with 8 large 5000px + images that take 40MB on disk but caused SMP to use nearly 900MB of ram according to window.PanelMemoryUsage

After this change, the reported value was 22MB.

edit: resizing doesn't come for free - there might be an apparent freeze for a second or 2 while it hogs the CPU!! YMMV.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-04-13 10:23:11
images that take 40MB on disk but caused SMP to use nearly 900MB of ram according to window.PanelMemoryUsage
That's because images are loaded in memory as uncompressed BMP, so it takes much more memory than it could've (or should've).

edit: resizing doesn't come for free - there is a performance penalty to be paid which might be noticeable?? YMMV.
This is caused by resize operation being performed on the main thread. I was thinking of making it async or maybe incorporating it `LoadImageAsync` (i.e. load *and* resize), but thought that such functionality was not that needed...

In long-term I'm planning to implement a new graphics back-end based on Direct2D (the support for current GDI/GDI+ back-end will remain), which should help with RAM utilization (amongst many other things).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Fabio258 on 2020-04-13 11:14:03
I'm searching a playlist viewer that can be linked to a specific playlist like EsPlaylist. Is it possible with jsplaylist? I've tried but It seems auto-linked to the active playlist  :(


HI,

as it is a script, you can modify jssplaylist to replace active playlist to a specific one, but it needs some changes to do that like replacing in script "plman.ActivePlaylist" with a variable that you have to set on init, by scanning existing playlists to find the index of the playlist you want to link to the playlist view (by playlist name testing imho ...)

HTH  ;)


Hi Falstaff, nice to see you here again  :)
Yes, if I was a programmer this can help me a lot, but sadly my programmer skills are slightly above 0  :'(
And I don't want anyone to do the job for me for free.
In jsplaylist there is already a menu with a list of existing foobar playlists. I'm sure that can be modified to lock the view to the selected playlist but I've no idea on how to do this and how long it takes. So, if there is someone who wants to do it for me, please send me a PM.

Many thanks to all for this beautiful player and plugins

Fabio
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: SUPERCOOLMAN on 2020-04-13 11:32:53
Using the old function, I tested it with 8 large 5000px + images that take 40MB on disk but caused SMP to use nearly 900MB of ram according to window.PanelMemoryUsage

After this change, the reported value was 22MB.

edit: resizing doesn't come for free - there might be an apparent freeze for a second or 2 while it hogs the CPU!! YMMV.

ideally, script should generate only the small thumbnails when thumbnails is enabled. for main image, it should just keep a list of images file path found when current track's playback starts. script only need to load an image when being shown/drawn during current track's playback. there is already refresh/reload option when user want to refresh list of available images

another way to do this would be detecting screen resolution at the beginning and just down scale all images larger than that to screen resolution or smaller before loading since screen resolution is your display upper limit

This is caused by resize operation being performed on the main thread. I was thinking of making it async or maybe incorporating it `LoadImageAsync` (i.e. load *and* resize), but thought that such functionality was not that needed...

In long-term I'm planning to implementing a new graphics back-end based on Direct2D (the support for current GDI/GDI+ back-end will remain), which should help with RAM utilization (amongst many other things).

that would be a great improvement

one of the problem with the old albumart is that it doesn't pre-load or cache images during current track's playback, so it causes fb2k to freeze for 1-3 seconds every time it cycles to a high resolution image
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2020-04-13 11:34:56
For just one script (thumbs), use JScript Panel. It has none of these issues.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: SUPERCOOLMAN on 2020-04-13 11:39:20
unfortunately, for another complex script, I had to freeze JSP at pretty old version due to newer JSP causing breakage. marc2003 has also completely removed his repositories, so this is the only current repository for the thumbs
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2020-04-13 12:07:04
What version? Just checked and anything newer than v1.1.6.1 should have thumbs included.

Last.fm functionality will be broken in every version except the latest but since you're have issues with hi-res images, I'm assuming you're using custom folder mode which hasn't changed in years.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-04-13 12:11:56
another way to do this would be detecting screen resolution at the beginning and just down scale all images larger than that to screen resolution or smaller before loading since screen resolution is your display upper limit
I think this is the easiest solution\workaround to your problem (coupled with the snippet @snotlicker posted above). But async resize would be needed to avoid fb2k freeze. I think I'll just add resizing to LoadAsync, coz I have a few huge album arts as well that I'm too lazy to resize, which cause fb2k to stutter every time they load...
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Falstaff on 2020-04-13 17:09:53
Bug report:

in panel script editor, "Replace all" makes freezing/looping the program when searched string is a word in lowercase and the new string is the same word in uppercase

i.e: Replace "text" by "TEXT"

i've just lost 50 minutes of works :(

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-04-13 17:34:44
That... should not happen =)
I'll take a look tomorrow.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Falstaff on 2020-04-13 18:06:28
Thanks!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: wcs13 on 2020-04-14 03:57:35
@wcs13 , it might be possible to implement such logic in the script (ignoring low-res images that is), but I'm currently prioritizing component development over script improvement. In other words it won't be fixed anytime soon, sorry.
Sounds great for me. Nobody's in a hurry. :)
I'd love it if it can be achieved someday, so please put it in your to-do list and you'll get to it eventually.
Many thanks for your work and your expertise!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: mjm716 on 2020-04-14 12:47:34
coz I have a few huge album arts as well that I'm too lazy to resize, which cause fb2k to stutter every time they load...

I clean my images up (over 10GB of artists alone) in minutes using Agent Ransack (https://www.mythicsoft.com/agentransack/) and Image Resizer (https://www.bricelam.net/ImageResizer/).
e.g. AR can search for image files of size> or dimensions> and the sortable results list can easily be batch resized by ctrl-click & IR
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-04-16 15:41:45
@Falstaff , `Replace All` is not working at all in the current version, REGEXP is borked as well. I'll fix it today\tomorrow.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: wcs13 on 2020-04-16 17:22:44
I clean my images up (over 10GB of artists alone) in minutes using Agent Ransack (https://www.mythicsoft.com/agentransack/) and Image Resizer (https://www.bricelam.net/ImageResizer/).
e.g. AR can search for image files of size> or dimensions> and the sortable results list can easily be batch resized by ctrl-click & IR
XnViewMP (https://www.xnview.com/fr/xnviewmp/) can do it too on its own, no need for two pieces of software :
1. Tools > Search (Add > File Size > Is greater than or equal to > 1000 > KiB)
2. Select all results
3. Right Click > Batch Convert (Add action > Image > Resize, then set all relevant options, everything is possible)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Bollerkopp on 2020-04-23 08:44:50
Hello,

if I use some of the samples of the "complete" folder (e.g. "last.fm bio.js"), the panel crashes and I get the following error message:

Quote
Error: Spider Monkey Panel v1.2.3 (Last.fm Bio by marc2003)
include failed:
ActiveXObject_Constructor failed:
WinAPI error: GetTypeInfo failed with error (0x80029c4a): Unknown error

File: helpers.js
Line: 588, Column: 11

Stack trace:
  @helpers.js:588:11
  @<main>:5:1

I'm on Windows 10 64bit with foobar2000 v1.5.3.0.

What could be the problem? Thank you very much in advance.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: hexenszene on 2020-04-26 09:24:26
Hope this is the right place to ask, but has the Spectrogram Seekbar that used to run on WSH Panel been upated for SM Panel?
This is the old one: https://pastebin.com/6n0ZmTtB
I know SoX is or would be required...

Thanks!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: hexenszene on 2020-04-27 18:03:38
Another question...   My SM Panels seem to be missing a font, so the down arrow isn't displaying properly. 
See here:  https://imgur.com/a/FHia3X7   Does anyone know how  to resolve this?

And last but not least, Marc2003 used to have a Last.fm script for WSH Panel that allowed you to see "top tracks" and "top albums" for an artist.  Has this been updated for SM Panels yet?

Thanks all.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-04-28 10:12:34
@Bollerkopp , not sure, why you are getting this error. The library in question (`Mshtml.dll`) should be available on all supported Windows systems. Are you using a norrmal fb2k or a fb2k from Windows Store? There were reports about issues in Windows Store version.

@hexenszene ,
Quote
has the Spectrogram Seekbar that used to run on WSH Panel been upated for SM Panel?
AFAIK, no.

Quote
My SM Panels seem to be missing a font
have you installed `Font Awesome` as per `readme`?

Quote
And last but not least, Marc2003 used to have a Last.fm script for WSH Panel that allowed you to see "top tracks" and "top albums" for an artist.  Has this been updated for SM Panels yet?
`complete/last.fm similar artists + user charts + recent tracks.js`

@Falstaff , regretfully, the fix is still not ready. Hopefully I'll have enough free time and energy to complete the fix soon (it's 95% ready).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: hexenszene on 2020-04-28 13:36:50
@Bollerkopp , not sure, why you are getting this error. The library in question (`Mshtml.dll`) should be available on all supported Windows systems. Are you using a norrmal fb2k or a fb2k from Windows Store? There were reports about issues in Windows Store version.

@hexenszene ,
Quote
has the Spectrogram Seekbar that used to run on WSH Panel been upated for SM Panel?
AFAIK, no.

Quote
My SM Panels seem to be missing a font
have you installed `Font Awesome` as per `readme`?

Quote
And last but not least, Marc2003 used to have a Last.fm script for WSH Panel that allowed you to see "top tracks" and "top albums" for an artist.  Has this been updated for SM Panels yet?
`complete/last.fm similar artists + user charts + recent tracks.js`

@Falstaff , regretfully, the fix is still not ready. Hopefully I'll have enough free time and energy to complete the fix soon (it's 95% ready).

Thanks for the help.  I had looked for a readme in the folder but somehow missed it.  Issue solved.
Regarding the script "complete/last.fm similar artists + user charts + recent tracks.js" -- this doesn't seem to have "top albums" or "top tracks" in it.  The only choices seem to be "last.fm user charts", "recent tracks", and "similar artists".  Am I missing something?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MojoBass on 2020-04-28 20:00:00
Regarding the script "complete/last.fm similar artists + user charts + recent tracks.js" -- this doesn't seem to have "top albums" or "top tracks" in it.  The only choices seem to be "last.fm user charts", "recent tracks", and "similar artists".  Am I missing something?
The Youtube Track Manager (YTTM, see here (https://hydrogenaud.io/index.php?topic=105522.100)) is listing top albums and top tracks out of the box. Runs as well on SMP.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: hexenszene on 2020-04-30 13:44:47
Regarding the script "complete/last.fm similar artists + user charts + recent tracks.js" -- this doesn't seem to have "top albums" or "top tracks" in it.  The only choices seem to be "last.fm user charts", "recent tracks", and "similar artists".  Am I missing something?
The Youtube Track Manager (YTTM, see here (https://hydrogenaud.io/index.php?topic=105522.100)) is listing top albums and top tracks out of the box. Runs as well on SMP.
This is awesome!  Thank you!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Falstaff on 2020-04-30 17:15:45
@Falstaff , regretfully, the fix is still not ready. Hopefully I'll have enough free time and energy to complete the fix soon (it's 95% ready).

*waits* ;)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-05-06 15:46:21
@Falstaff , should be fixed (hopefully) in the latest nightly build. What a PITA it was...
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Falstaff on 2020-05-10 11:14:19
thanks, i'll test asap
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2020-05-29 04:46:45
@TheQwertiest
I was building foo_spider_monkey_panel just fine and then I upgraded to VS2019 - 16.6, and the kmeans code throws errors wherever ranges::... is used. I think this is probably fixed by bumping up the range submodule dependency, but it looked like you were purposefully using an older version. Am I out of luck here?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-05-29 19:45:53
@MordredKLB , haha, well I've updated my VS as well and it indeed fails to build, but not in `range-v3` part :P
What is the commit that your range submodule is on? (`cd submodules/range` & `git status` ).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2020-05-30 18:31:42
@MordredKLB , haha, well I've updated my VS as well and it indeed fails to build, but not in `range-v3` part :P
What is the commit that your range submodule is on? (`cd submodules/range` & `git status` ).
Well, After rebasing last night to get your 16.6 changes, everything is good again, and DEBUG builds just fine. I still can't build release versions though.

I'm getting dozens of these 3 errors which shows me they're all related, but I can't figure out where the mismatch is coming from:
Code: [Select]
LNK2038	mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in abort_callback.obj
LNK2038 mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MT_StaticRelease' in abort_callback.obj
LNK2001 unresolved external symbol __CrtDbgReport
Also, when I try and use the debug build I made, foobar tells me I have missing dependencies.

This is why I should stick to JavaScript :D

Edit: I'm realizing now that I can probably use your "pack_component.bat --debug" script to build the debug component, which I guess is really all I need to be able to do.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2020-05-30 19:03:04
Seems like your solution has a mix of statically linked and dynamically linked projects. They all need to be the same.

edit: and debug/release mixed up too??
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2020-05-30 19:17:59
Seems like your solution has a mix of statically linked and dynamically linked projects. They all need to be the same.

edit: and debug/release mixed up too??
Yeah, it's weird. I haven't touched any of that stuff either. Fresh pull, run setup.py, open the .sln file and attempt to build release. All the components are set to RELEASE as well. Either way, I can now build a debug component and that's what matters.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-05-30 19:44:31
You have to "Rebuild" the project when you change configuration. This is caused by some *make based dependencies (scintilla, lexilla), which output binaries to the same path in Release and Debug configuration (and they do not detect automatically the change in configuration to trigger the rebuild).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2020-05-30 19:53:05
The current version of Scintilla now includes a VS project file for lexilla which makes it easier.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-05-30 19:57:15
Thanks! I'll look into it.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-05-30 20:01:47
@snotlicker , it seems that these projects can only produce dynamic libraries, so it's not really suitable for SMP =(
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2020-05-30 20:22:13
I normally use dynamic but did a quick test with static and it compiles and works just fine??

Perhaps you need to update your linker settings to remove the .lib file previously generated by nmake??

edit: here's a screenshot of my own project - note the increased file size on the right!

https://i.imgur.com/5CX6MTc.png
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-05-30 20:34:10
I normally use dynamic but did a quick test with static and it compiles and works just fine??
`*.lib` file that is produced by `Scintilla.vcxproj` is an export library. So if you link against it, it will actually link you against corresponding `*.dll`. You can test this by removing said `*.dll` file (the program should crash or disable the component once it tries to load the component library)).

[edit]: https://i.imgur.com/JT8l35w.png
As you can see *.lib has the size of only 2KB vs 2MB of *.dll.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2020-05-30 21:05:23
You have to "Rebuild" the project when you change configuration. This is caused by some *make based dependencies (scintilla, lexilla), which output binaries to the same path in Release and Debug configuration (and they do not detect automatically the change in configuration to trigger the rebuild).
Ugh, should have thought to try that since it was clearly a release/debug mismatch. It's getting close to a decade since I worked professionally in VS/C-development so I've forgotten a few tricks.
Thanks for merging that PR!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2020-06-02 07:20:59
@snotlicker , it seems that these projects can only produce dynamic libraries, so it's not really suitable for SMP =(

Since I was locked on version 4.3.3, I didn't understand this issue but I guess you were on latest commit when you tried. Since a new version was released yesterday, I encountered the same issue and reported it here...

https://groups.google.com/forum/#!topic/scintilla-interest/vnegGNO6nKw

 It has now been fixed in version 4.4.2.

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: APECR on 2020-06-06 00:35:45
Code: [Select]
image_cache = function () {
    this._cachelist = {};
    this.hit = function (metadb) {
        var img = this._cachelist[metadb.Path];
        if (list.drag_stop && typeof img == "undefined") {
            if(!cover.load_timer) {
                cover.load_timer = window.SetTimeout(function() {
                    utils.GetAlbumArtAsync(window.ID, metadb, 0, true, false, false);
                    cover.load_timer && window.ClearTimeout(cover.load_timer);
                    cover.load_timer = false;
                }, 20);
            };
        };
        return img;
    };
    this.getit = function (metadb, track_type, image) {
        var img;
        var quotient = (panel.flat_mode) ? 2 : 12;
        if(cover.keepaspectratio) {
            if(!image) {
                var pw = (cover.w+cover.margin*quotient);
                var ph = (cover.h+cover.margin*quotient);
            } else {
                if(image.Height>=image.Width) {
                    var ratio = image.Width / image.Height;
                    var pw = (cover.w+cover.margin*quotient)*ratio;
                    var ph = (cover.h+cover.margin*quotient);
                } else {
                    var ratio = image.Height / image.Width;
                    var pw = (cover.w+cover.margin*quotient);
                    var ph = (cover.h+cover.margin*quotient)*ratio;
                };
            };
        } else {
            var pw = (cover.w+cover.margin*quotient);
            var ph = (cover.h+cover.margin*quotient);
        };
        // item.cover_type : 0 = nocover, 1 = external cover, 2 = embedded cover, 3 = stream
        if(track_type!=3) {
            if(metadb) {
                img = FormatCover(image, pw, ph);
                if(!img) {
                    img = nocover_img;
                    //item.cover_type = 0;
                } else {
                    //item.cover_type = 1;
                };
            };
        } else {
            img = streamcover_img;
            //item.cover_type = 3;
        };   
        this._cachelist[metadb.Path] = img;
        return img;
    };
};
Help convert
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-07-10 17:39:14
Version: 1.3.0
Link: https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/tag/v1.3.0
Changelog:
Spoiler (click to show/hide)
Detailed description of API changes: https://theqwertiest.github.io/foo_spider_monkey_panel/docs/script_documentation/api_changes/#v130
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2020-07-10 18:46:00
SetFont doesn't work.

Code: [Select]
tooltip.SetFont is not a function

Pre-existing methods like SetMaxWidth still work.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2020-07-12 00:05:34
I'm seeing phantom tooltips that keep coming back after a script crashes and you reload it. I maxed out at 5 visible on top of each other at the same time. No real rhyme or reason I can tell to why they show up (or what values they have), but switching to foobar from another tab causes them to show again.

Seems like on a script crash Tooltip.Deactivate() might need to be called internally?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2020-07-12 07:04:47
I discovered this evening that gdi.LoadImageAsync can return the same task ID at certain times which was a serious problem when I was attempting to load two large images somewhat simultaneously and then check then check the IDs in the callback. Was pretty simple to migrate over to LoadImageAsyncV2 (which is much cleaner as well!) but still kind of a confusing problem.

I'm also running into a memory leak when doing window.Reload(). I tried some pedantic stuff to reproduce but it seems garbage collection works fine, except in my theme.

My foobar starts at around 250MB, and adds 10-20MB (seems somewhat dependent on size of the active playlist) each time I do a window.Reload(). Eventually foobar is using 1.3TBs and I get error messages like this immediately after my theme loads and I have to restart foobar:
Code: [Select]
Error: Spider Monkey Panel v1.3.0 (Georgia v2.0.0 by Mordred)
Out of memory: 4057804/1073741824 bytes

Still trying to figure out if there's something I can do to minimize things, or not.

Edit: Seems I can mitigate things somewhat by setting playlist = null; and all of WillB's library objects to null before doing window.Reload(). Somehow it seems objects in the global namespace get orphaned references on a window.Reload... and I have a lot of stuff in the global namespace.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-07-12 12:10:15
SetFont doesn't work.
Haha, welp, that's what I get for being lazy and not testing things properly =)
Thanks for reporting.

I'm seeing phantom tooltips that keep coming back after a script crashes and you reload it.
Strange, that should not happen. I'll take a look if I can reproduce it.

I discovered this evening that gdi.LoadImageAsync can return the same task ID at certain times
Do you mean that that `LoadImageAsync()` returns the same ID when ran serially? E.g.
Code: [Select]
ids = []
for (path in paths)
{
  ids.push[gdi.LoadImageAsync(path)];
}
// ids not unique

Task ID is just an object's memory address. The only way they could have the same id (in theory) is when the memory is reused (which is possible only if the previous task was finished and handled in the callback).

I'm also running into a memory leak when doing window.Reload().
Still trying to figure out if there's something I can do to minimize things, or not.
Regretfully, it's nearly impossible to fix such leaks without at least somewhat minimal repro scenario.
Try downloading debug version of SMP, enable GC zeal (https://theqwertiest.github.io/foo_spider_monkey_panel/docs/for_developers/component_development_tips/#test-with-gczeal) and see if the memory leak is still there.
Note: GC zeal will tank the performance, so it might take some time for the script to load.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-07-12 12:48:00
@snotlicker , fixed in the Nightly build.

@MordredKLB , I've fixed the `ghost tooltip` in the Nightly build. Can you check if it fixes your memory leak as well?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2020-07-12 17:18:53
@snotlicker , fixed in the Nightly build.

@MordredKLB , I've fixed the `ghost tooltip` in the Nightly build. Can you check if it fixes your memory leak as well?
JFC, it was the god damned tooltip! Now I can spam the Reload() button on my theme, get memory up to 500MB, and it drops back down to 225-230ish within a few seconds. Also easy to verify since if I cause an error in the theme, memory usage drops back to a flat 207MB every time.

I can't believe it. Ghost tooltip issue is also fixed. Thanks so much. :)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2020-07-12 20:41:58
Not to be one of those people, but I noticed that ESR 78.x was released a few days ago. How difficult is the jump from 68 to 78? I wouldn't have even noticed, but I was rewriting some of my stuff using the class syntax and found out that I got a "fields are not currently supported" crash when trying to use class field notation. No big deal at all, I was just surprised to discover that the ESRs only release once a year or so.

One other question I've got, I've added the foo_spider_monkey_panel.js to my VSCode project, and it picks up types correctly for everything except window which gives me the following type error for every method: "Property 'RepaintRect' does not exist on type 'Window & typeof globalThis'." Any way around that?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-07-13 10:53:52
How difficult is the jump from 68 to 78?
Dunno. SM devs do not care much for API stability (or MSVC compatibility), so it might be anything between a simple SM recompile or a full-blown SMP rewrite.
Anyway, I won't start migrating to ESR78 before I finish the ConfigureV2 rewrite (which will take a loooong time).

Any way around that?
The problem is that `window` object is a built-in JS object, which causes conflicts with SMP definitions.
There *is* probably a way to work around that, but I don't have any ideas =)
PS: If you *do* find a workaround, plz message me, so I could add it to the docs.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-07-13 12:13:40
@MordredKLB , try smth like this:
Code: [Select]
{
    "compilerOptions": {
        // this is needed to suppress built-in browser objects (`window`, various DOM objects and etc)
        "lib": ["es2019"]
     },
    "include": [
        // project files
        "**/*.js",
        // docs
        "../../user-components/foo_spider_monkey_panel/docs/js/*.js"
    ],
}
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2020-07-13 16:04:58
@MordredKLB , try smth like this:
Code: [Select]
{
    "compilerOptions": {
        // this is needed to suppress built-in browser objects (`window`, various DOM objects and etc)
        "lib": ["es2019"]
     },
    "include": [
        // project files
        "**/*.js",
        // docs
        "../../user-components/foo_spider_monkey_panel/docs/js/*.js"
    ],
}
Yup, that's what worked for me. BTW, I've made a ton of changes to the JSDoc stuff to fix VSCode false positives. Should I submit a PR for that? Not sure if everything currently works okay in intelliJ.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-07-13 16:57:11
Yup, that's what worked for me. BTW, I've made a ton of changes to the JSDoc stuff to fix VSCode false positives. Should I submit a PR for that? Not sure if everything currently works okay in intelliJ.
Sure, I will take a look.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-07-14 15:53:18
I discovered this evening that gdi.LoadImageAsync can return the same task ID at certain times which was a serious problem

I've tried to load 1000 images multiple times and didn't manage to reproduce the problem. Are you sure that the task id collision happened before it was utilized in `on_load_image_done()`? I.e. reuse of task id can only happen after the task_id is consumed by `on_load_image_done()` (which makes said task_id unused and available for further usage).

[edit]: Nvm, reproduced and fixed.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-07-14 22:47:11
Remade `script showcase` page. Now it has screenshots and stuff!
Link: https://theqwertiest.github.io/foo_spider_monkey_panel/docs/script_showcase
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2020-07-14 23:12:18
Thanks to your screenshot, just spotted a bug in the Properties script where subsong index is undefined. This is because of case sensitivity again...

https://github.com/TheQwertiest/smp_2003/blob/7fc1d75cd73081e3a83cb16e6af0ef2405342150/js/list.js#L983

panel.metadb.Subsong should be panel.metadb.SubSong
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-07-15 10:49:07
Thanks to your screenshot, just spotted a bug in the Properties script where subsong index is undefined.
Haha, nice catch =)

Btw, could you help with the `Last.fm Loved Tracks Manager` script screenshot (I can crop it myself if needed) and/or description, please? I've never used Last.Fm for anything other than scrobbling...

PS: It also appears that `track info + seekbar + buttons` script is borked, both on SMP and JSP. Hopefully, I have enough JS knowledge left to fix it :D
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2020-07-15 11:24:22
How is the track info+seekbar+buttons borked? I'm sure you know about the font requirements for the buttons. Perhaps your panel is far too big? Ideal height is around 60-80px

The behaviour of the seekbar where if you move your mouse too far away while dragging and the grip is released... that's by design.

(https://i.imgur.com/zaarAf5.png)

edit: the last.fm lover script has this description inside it...

Code: [Select]
/*
This script makes use of the Spider Monkey "Playback Stats" database to import
and store loved tracks from Last.fm. Each loved track will have the value of
%smp_loved% set to 1. You can access this through all other components/search -
it works in the same way as "foo_playcount" - all values are stored in a database
file and no files are tagged. Each record is bound to "%artist% - %title%" so
common tracks across different albums will share the same loved status. Right click
the heart iocn to set your Last.fm username and authorise the script through your
browser. You can then import all your loved tracks and then use the heart icon
to love/unlove tracks.
*/

edit2: Of course the glaring error in that text is that you won't see a heart icon until AFTER you've configured your username and authorised through your browser. Until, then you'll see a little red exclamation mark.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: VlaKor on 2020-07-15 14:47:40
Btw, could you help with the `Last.fm Loved Tracks Manager` script screenshot (I can crop it myself if needed) and/or description, please? I've never used Last.Fm for anything other than scrobbling...

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-07-16 13:53:40
Perhaps your panel is far too big? Ideal height is around 60-80px
Yep, that was it =)

edit: the last.fm lover script has this description inside it...
Thanks!

@VlaKor , thank you as well =)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: jazzthieve on 2020-07-16 18:40:53
Speaking of Last.fm Loved Tracks Manager, is there a way to indicate in playlist with a value which tracks are loved? The only way to see is to go to the lastfm website or when a track is playing.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-07-16 19:05:25
@jazzthieve , if your playlist supports the display of custom tags, you can use `%smp_loved%` to get the value for the track (1 - loved, 0 - not really...).

E.g. `$ifequal(%smp_loved%,1,♥,)`.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: jazzthieve on 2020-07-16 19:43:54
Great, thanks.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-07-18 13:14:52
Version: 1.3.1
Link: https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/tag/v1.3.1
Changelog
Hotfix for v1.3.0 (see changelog above (https://hydrogenaud.io/index.php?topic=116669.msg985305#msg985305))
Spoiler (click to show/hide)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2020-07-21 06:32:04
Haven't noticed any issues with 1.3.1. Thanks for being so responsive.

In my playlist, I've got hyperlinks that will create/replace the current playlist with a new search based on what you clicked on. I.e. you click on the artists name and the playlist just shows all songs by that artist. It bugged me that if I was playing a song by Tool for instance, and clicked on the artist name, calling plman.ClearPlaylist(pl) would also lose the playing status of the current playing song (i.e. it wouldn't show as being played anymore even though it's metadb was in the contents of the playlist).

So I devised this workaround to remove everything from the playlist except what was being played, then add the contents of the search back in:

Code: [Select]
const pl = plman.FindOrCreatePlaylist('Search', true);
if (pl === plman.PlayingPlaylist && plman.GetPlayingItemLocation().PlaylistIndex === pl) {
plman.ClearPlaylistSelection(pl);
plman.SetPlaylistSelection(pl, [plman.GetPlayingItemLocation().PlaylistItemIndex], true);
plman.RemovePlaylistSelection(pl, true);

const playing = new FbMetadbHandleList(fb.GetNowPlaying());
handle_list.Sort();
const handle_copy = new FbMetadbHandleList(handle_list);
handle_copy.MakeIntersection(playing);
if (handle_copy.Count === 0) {
plman.ClearPlaylist(pl);
} else {
handle_list.MakeDifference(playing);
}
plman.InsertPlaylistItems(pl, 0, handle_list);
} else {
// nothing playing or Search playlist is not active
plman.ClearPlaylist(pl);
plman.InsertPlaylistItems(pl, 0, handle_list);
}

This works, but it seems incredibly hacky to me, and is hard to read. Is there a better/another way to remove items from a playlist than using RemovePlaylistSelection, or otherwise do this?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2020-07-21 08:02:49
Not sure modifying the contents of any existing playlist is the way to go if other people are using this?? To be safe, I'd be sending the contents of the query to a new playlist every time.

But if you really want to remove the playing track from the handle list of results, use BSearch to find its index and remove it.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-07-21 10:45:25
@MordredKLB , it's just the way fb2k works - played item is bound to the playlist it's playing on. If you clear a playlist then it's no longer bound to it (from fb2k point of view). So, yeah. The only way you can preserve this connection is by removing all other items like you currently do (but you can simplify it a bit via BSearch as suggested by @snotlicker ).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2020-07-21 16:34:10
Not sure modifying the contents of any existing playlist is the way to go if other people are using this?? To be safe, I'd be sending the contents of the query to a new playlist every time.

But if you really want to remove the playing track from the handle list of results, use BSearch to find its index and remove it.
It uses a specific playlist each time. Think of it like the CUI "Filter" playlist, or WillB's "Library Playlist". When you make a new selection the contents of that specific playlist are always replaced.

I want to do the opposite of removing the playing song. :) I want to see if the currently playing song is in the results of the search, and if so, remove everything else and then add the results of the search.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2020-07-21 16:35:35
@MordredKLB , it's just the way fb2k works - played item is bound to the playlist it's playing on. If you clear a playlist then it's no longer bound to it (from fb2k point of view). So, yeah. The only way you can preserve this connection is by removing all other items like you currently do (but you can simplify it a bit via BSearch as suggested by @snotlicker ).
I'm not sure how BSearch helps since I've already got the index from plman.GetPlayingItemLocation().PlaylistItemIndex.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2020-07-21 17:00:10
I was talking about this....

Code: [Select]
	const playing = new FbMetadbHandleList(fb.GetNowPlaying());
handle_list.Sort();
const handle_copy = new FbMetadbHandleList(handle_list);
handle_copy.MakeIntersection(playing);
if (handle_copy.Count === 0) {
plman.ClearPlaylist(pl);
} else {
handle_list.MakeDifference(playing);
}

...but maybe I have no idea what you're doing at all. If whatever it's supposed to do works, just leave it and forget I said anything. :D
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2020-07-21 17:28:28
I was talking about this....

...but maybe I have no idea what you're doing at all. If whatever it's supposed to do works, just leave it and forget I said anything. :D
I gotcha. Sorry I misread what you were saying earlier. This is much cleaner now:

Code: [Select]
handle_list.Sort();
const index = handle_list.BSearch(fb.GetNowPlaying());
if (pl === plman.PlayingPlaylist && plman.GetPlayingItemLocation().PlaylistIndex === pl && index !== -1) {
// remove everything in playlist except currently playing song
plman.ClearPlaylistSelection(pl);
plman.SetPlaylistSelection(pl, [plman.GetPlayingItemLocation().PlaylistItemIndex], true);
plman.RemovePlaylistSelection(pl, true);
plman.ClearPlaylistSelection(pl);

handle_list.RemoveById(index);
} else {
// nothing playing or Search playlist is not active
plman.ClearPlaylist(pl);
}
plman.InsertPlaylistItems(pl, 0, handle_list);
Thanks!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2020-07-24 06:12:21
So I've noticed something kind of annoying with Georgia in FSM. When I start up foobar, everything has to spin up as my library loads and FB checks for changes. At the same time FSM is trying to parse my theme, and it's not uncommon to get a "this script is taking too long would you like to kill it" message. It appears that when the dialog is up, FSM freezes the scripts so even though they'd become responsive by the time you have a chance to click continue/kill it doesn't happen. Is there some way to increase the timeout before this warning when foobar is starting up... or not pause the scripts and clear the dialog if they do become responsive again?

Alternatively, is there something I can do in my scripts at startup to prevent this from happening?

BTW, don't know if it matters but my configuration is just a single include of a georgia-theme.js file, and that georgia-theme.js file is what actually includes all the js files for the theme. Figured that would give me more flexibility when updating the theme to add/remove files at will, but maybe the nested includes cause issues?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-07-24 11:14:40
Is there some way to increase the timeout before this warning when foobar is starting up...
Nope, won't be changed.

Quote
or not pause the scripts and clear the dialog if they do become responsive again?
That would be neat. I'll see if it's possible to do this.

Alternatively, is there something I can do in my scripts at startup to prevent this from happening?

The proper way to avoid holding stuff for long time would be to make initialization segmented, which would yield the control after each segment is completed (with smth like a progress bar). E.g.
Code: [Select]
// This is pseudo-code

is_initializing = true;

function on_paint() {
  if (is_initializing) {
    print_loading_in_progress();
  }
  else {
    print_normal_stuff();
  }
}

function init_short()
{
  // basic init that doesn't hold for long
}

async function init_long() {
  while (has_stuff_to_do) {
     let promise = new Promise((resolve) => {
       stuff_to_do = get_current_init_part();
       stuff_to_do.do();
       resolve(stuff_to_do.id)
     });
     stuff_id = await promise; // this will yield the execution
     console.log(`$(stuff_id) done`);
  }
  is_initializing = false;
}

init_short();
init_long();

Figured that would give me more flexibility when updating the theme to add/remove files at will, but maybe the nested includes cause issues?
The panel is considered a single script. I.e. it doesn't matter if it uses `include()` or just has everything inlined.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2020-07-24 17:39:49
I might try some tests with async/await wrapping includes. The warning seems to be entirely dependent on whether my hard drives need to spin up first... something I haven't been able to get to happen today. If the HDD is spinning, FSM loads my theme in <300ms at startup. Refreshing the panel after foobar has started takes about 20ms, so it's not that the script is actually slow.

BTW, I stupidly had clicked the "don't show me this again" checkbox. Is deleting the foo_spider_monkey.dll.cfg good enough to reset that? It didn't reset the panel configuration so some data is being stored elsewhere at least.

Edit: Rebooted my computer and got this to happen again. Async processing of files won't help the situation. I verified the file it had hung on last time, and it's the very second file I include, and it died at line 70, where I define the RGB helper function. Not exactly a tight loop.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Black_Over_Bills_Mothers on 2020-07-26 12:39:47
Using;
handle_list.AttachImage(img_path, 0)
If img_path contains ( or ) then image file is not found.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2020-07-26 12:58:18
You sure? Just tested and it works exactly as expected with () in the filename.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Black_Over_Bills_Mothers on 2020-07-26 13:45:52
Hi snotlicker
Thanks for the quick response. You are correct and I'm guilty of such a stupid js school-boy error. Too embarrassed to tell what I'd done wrong. All working now. Thanks.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-07-26 14:06:52
BTW, I stupidly had clicked the "don't show me this again" checkbox. Is deleting the foo_spider_monkey.dll.cfg good enough to reset that? It didn't reset the panel configuration so some data is being stored elsewhere at least.

"don't show me this again" options is fb2k-instance-local. Meaning that it only affects the current process of fb2k and it does not persist across different fb2k launches.

@ your "hanging" problem: I'm trying to make "Slow script" dialog async, so that it would not halt the script execution. But I don't think I can do anything other than that.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2020-07-26 17:10:23
Does that mean you could also hide the dialog again, once things become responsive again, or no? Even if not it'd be a big improvement since users would be able to see the theme load behind the dialog.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-07-27 09:53:00
Does that mean you could also hide the dialog again, once things become responsive again, or no?
Yes.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Black_Over_Bills_Mothers on 2020-07-27 14:15:35
I'm trying  to process selected files from a playlist. Firstly I want to convert them and I'm using:
fb.RunContextCommandWithMetadb("Convert/mp3 tablet",handle_list);
then I want to embed the album cover. My problem is the the RunContextCommand doesn't block so I need an event that is raised when all the files have been converted. Any ideas?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-07-27 14:28:46
@Black_Over_Bills_Mothers , that's just the way fb2k API works. Hence can't do much if the invoked command is non-blocking :\
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: fbuser on 2020-07-27 16:44:51
I'm trying  to process selected files from a playlist. Firstly I want to convert them and I'm using:
fb.RunContextCommandWithMetadb("Convert/mp3 tablet",handle_list);
then I want to embed the album cover. My problem is the the RunContextCommand doesn't block so I need an event that is raised when all the files have been converted. Any ideas?
In general you could use something like the code below. You need to replace <get handleList> and <do the processing for metaDb> with valid code and you might need to play a little bit with the timings.
Code: [Select]
const handleList= <get handleList>;                                         

fb.RunContextCommandWithMetadb("Convert/mp3 tablet",handleList);
 
const processItem=() => {
  if(!handleList.Count) return false;
     
  const metaDb=handleList[0];

  <do the processing for metaDb>

  handleList.RemoveById(0);

  return Boolean(handleList.Count);
};

() => {
   if(!processItem()) return;
   
   setTimeout(arguments.callee,20);
}();
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2020-07-27 16:48:31
That seems dangerous to me. You're essentially just guessing that each file will be written in 20ms. If HDDs need to spin back up, or a file is huge, this will fail just like B_O_B_M's original case.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: fbuser on 2020-07-27 16:55:58
That seems dangerous to me. You're essentially just guessing that each file will be written in 20ms. If HDDs need to spin back up, or a file is huge, this will fail just like B_O_B_M's original case.
No, it's not dangerous. You just need to make additional tests during the processing and return false return true, if the file, which needs to be processed is not ready. Additionally a guard should be implemented to avoid endless processing.

Edit: Corrected and extended the answer.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Black_Over_Bills_Mothers on 2020-07-27 19:36:24
@All. Thanks for your replies. My best effort was to create an autoplaylist targeted at the destination for the converted files. I made a note of the file total and tested the playlist index of the autoplaylist and file count in the 'on_playlist_items_added(playlistIndex)' event. When I had all the files in the destination folder, I continued and embedded the album image in them all. Seems to work so far.

Thanks for your valuable time spent in helping me on this.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-07-31 15:05:14
@MordredKLB , I've tinkered around a bit . Regretfully, it seems that it's impossible to make `slow script` dialog asynchronyous (without writing/using a new GUI stack): the problem is that GUI handling/processing is performed on the main thread, so if the main thread is stuck (e.g. in the infinite loop in JS), then no GUI messages can be processed making it impossible to interact with any dialogs (including `slow script` dialog).

While I understand your problem, I just don't know what can be done without removing the `slow script` check. I will try to extend the time limit a bit for the script on fb2k startup (in case there's some async stuff that hogging up the CPU), but it's still won't be a universal solution and it might not help much in your case.

[EDIT] Welp, no idea how to check that fb2k has loaded everything. Hence decided to make `slow script` time limit configurable (Advanced > SMP > Performance > Execution time limit).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2020-07-31 21:22:08
@MordredKLB , I've tinkered around a bit . Regretfully, it seems that it's impossible to make `slow script` dialog asynchronyous (without writing/using a new GUI stack): the problem is that GUI handling/processing is performed on the main thread, so if the main thread is stuck (e.g. in the infinite loop in JS), then no GUI messages can be processed making it impossible to interact with any dialogs (including `slow script` dialog).

While I understand your problem, I just don't know what can be done without removing the `slow script` check. I will try to extend the time limit a bit for the script on fb2k startup (in case there's some async stuff that hogging up the CPU), but it's still won't be a universal solution and it might not help much in your case.

[EDIT] Welp, no idea how to check that fb2k has loaded everything. Hence decided to make `slow script` time limit configurable (Advanced > SMP > Performance > Execution time limit).
Thanks for investigating and I was afraid that might be the issue.

In further thinking, I might play around with async loading, just to see if maybe that can help. It all depends on what's actually happening behind the scenes with FB freezes trying to read from the HDD. i.e. do the other threads completely get locked out while that's happening, or are they just processing very slowly. If it's the first (which seems likely) then there's nothing to be done, but if it's the second, it might make this issue harder to encounter. It's weird though that SMP can still display the dialog.

Honestly this seems like a FB issue, and I'm wondering if we should report to @Peter .
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-07-31 21:45:14
It's weird though that SMP can still display the dialog.
SMP can display a modal `slow script` dialog during JS execution, because this dialog is invoked during JS interruption callback (i.e. it actually stops JS execution, thus it no longer stalls the main thread). The dialog could not have been displayed if the main thread was stalled by smth not JS related (this `not JS related` stuff might slow-down JS execution enough to trigger the `slow script` though).

If you have a debugger (e.g. visual studio), you may try to diagnose the issue by attaching to fb2k and breaking during the freeze. It will at least show the `.dll` on which fb2k is stuck.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2020-07-31 21:57:42
Well this is my confusion. Are you saying SMP executes the JS in the main thread then? In that case I would have thought that the interruption handler wouldn't have been able to work since it's also on the main thread, unless I'm misunderstanding how that even works.

I might try the debugger trick, or maybe just wait and see if I'm the only one actually running into the issue. It's a pain in the ass to get conditions right to even occur naturally (although I haven't messed with HDD spin-down times yet...)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-07-31 22:14:35
Are you saying SMP executes the JS in the main thread then?
Yep. Most of the JS stuff is executed on the main thread. A lot (most?) of GC is performed on worker threads though (memory deallocation is not cheap, so it gives a good performance boost).

In that case I would have thought that the interruption handler wouldn't have been able to work since it's also on the main thread, unless I'm misunderstanding how that even works.
I didn't look in the Spider Monkey internals too much, but it probably looks smth like this:

Code: [Select]
// SM internals
// Everything here is executed on the main thread

void JSMachineRunner()
{
  while (hasStuffToDo)
  {
    auto currentPart = GetNewPart();
    ExecuteJSMaybe(currentPart);
  }
}

void ExecuteJSMaybe(JSPart part)
{
  if (interruptRequested)
  {
    InvokeInterruptCallback();
  }
  ExecuteJS(part);
}

I.e. in JS engine itself the JS code is not monolithic, but split in parts that are fed in a JS runner (even an infinite loop like `while(true){}`). Thus making the interruption (and `slow script` dialog) possible.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2020-08-01 05:32:06
Got it. Well, i'll give the async script loading a shot. Wrap every file in a await promise with setTimeout(() => {}, 1) and see if that improves the situation.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Mrakobes on 2020-08-01 16:43:58
problem 1: Artist Images (thumbs.js)

help to configure the paths for displaying the covers in the "covers" folder, the problem is that sometimes I place this folder in the album, it is one level higher (in the case of a two-disc edition) - I just can't configure the second option. I want the code to look for the "covers" folder first in the lower directory, then, not finding it there, went up one level, and so on

problem 2: last.fm similar artists + user charts + recent tracks

similar unicode characters are not displayed correctly (bands in German, French)

problem 3: last.fm

I can not configure the folder for uploading photos from last.fm to the same directory as the artist

problem 4: musicbrainz

the discography is sorted by year in reverse order and I want to increase
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2020-09-24 21:26:00
I might try some tests with async/await wrapping includes.
Wanted to follow up that loading scripts async made the issue go away. I haven't seen the slow-script warning popup in the last 2 months.

My code for anyone who has this same problem (probably nobody else):

Code: [Select]
function loadAsyncFile(filePath) {
    return new Promise(resolve => {
        setTimeout(() => {
            include(filePath);
            resolve();
        }, 1);
    })
}

const basePath = fb.ProfilePath + 'georgia\\';

async function includeFiles(fileList) {
    for (let i = 0; i < fileList.length; i++) {
        await loadAsyncFile(basePath + fileList[i]);
    }
}

includeFiles([
    'js\\CaTRoX_QWR\\lodash.min.js',
    . . . // all other files
]);
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-09-25 21:06:51
@Mrakobes , regretfully my free time is very limited currently (even more than before, because of the new job I've landed). Because of that I won't be focusing on script development, but rather on component itself (I will steal some script fixes\improvements from @marc though :P)

@MordredKLB , glad to hear that it's working out for you =)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: wcs13 on 2020-09-25 23:16:54
Hi :) This is obviously not the best moment judging from your last post. I just wanted to remind you this one from about 6 months ago, so you can keep it in mind when the moment comes. Many thanks in advance !

@wcs13 , it might be possible to implement such logic in the script (ignoring low-res images that is), but I'm currently prioritizing component development over script improvement. In other words it won't be fixed anytime soon, sorry.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2020-09-26 03:40:42
Quick hack, complete\js\thumbs.js, line 492, replace the existing function with this..
Code: [Select]
	this.update = () => {
this.image = 0;
this.files = [];
this.images = [];

let tmp = _getFiles(this.folder, this.exts, this.properties.sort.value == 1);
tmp.forEach((item) => {
let img = gdi.Image(item);
if (img && img.Width >= 500 && img.Height >= 500) {
this.files.push(item);
this.images.push(img);
}
});

this.size(true);
window.Repaint();
}

Change the dimensions as required.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2020-09-26 11:27:18
^Forget I posted that. It will lead to undesirable/buggy behaviour. It could be done properly but I'm far too lazy for that.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2020-10-25 11:18:01
fb.GetNowPlaying() method returns the actually playing (or paused) track, and returns a null value when the player is stopped, but it seems that foobar2000 stores a reference to the track even once it is stopped, because it is resumed when pressing the "play" button subsequently. Panel Stack Splitter also seems to access that reference when titleformat mode on start up is set to "Now playing".
So, given my assumption is not wrong, is there a SMP method that returns that same reference?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2020-10-25 11:36:38
That's why callbacks like on_playback_stop exist.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2020-10-25 14:16:11
That's why callbacks like on_playback_stop exist.
Yes, but this does not answer my question. or does it?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2020-10-25 16:48:55
That's why callbacks like on_playback_stop exist.
Yes, but this does not answer my question. or does it?

I believe Marc is saying that in the on_playback_stop you could record a reference to the track.

From what I can tell, I think you're actually confusing having a reference to the last song played with the active playlist item. If I stop a song, and then press play, it isn't that foobar is remembering what the song is, it's just playing from the current position of the active playlist. When I play an entire playlist and then playback stops, when I hit play again, it doesn't play the last song, it plays the first song in the playlist.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2020-10-25 18:17:08
If I stop a song, and then press play, it isn't that foobar is remembering what the song is, it's just playing from the current position of the active playlist.

But if I stop a song and then select another item in the active playlist, when I press play the playback does not start from the selected item, but from where the playback stopped. Furthermore, it does so even if I move the selected item above the previously playing song, so that its index is changed, which apparently means foobar is remembering the song and not the position.

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2020-10-26 08:50:15
EDIT: Sorry, I posted in the wrong thread!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2020-10-26 19:10:13
It seems I have no idea what anyone is on about. I thought the original issue was something like this.

Code: [Select]
var g_metadb = fb.GetNowPlaying() // could be a valid handle or null

function on_playback_new_track(metadb) {
    g_metadb = metadb; // always a valid handle
}

function on_mouse_lbtn_up(x, y) {
    if (g_metadb) {
        //code here would run even if playback has stopped so long as g_metadb was valid at some point previously
    }
}

I would "fix" like this...

Code: [Select]
function on_playback_stop(reason) {
   g_metadb = null;
}

g_metadb would always be a valid handle when playing and null when not.

Now it seems the issue has nothing to do with scripts/components at all and is simply not having main menu->"Playback/Playback follows cursor" enabled??
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2020-10-26 21:35:31
My issue arises from the need to make a SMP script consistent with that of a PSS panel where titleformatting mode on startup is set to "now playing". Indeed it looks as if PSS is keeping record of the last played track, but I was wondering if this is what's actually going on under the hood or if PSS is referencing some value provided by foobar2000. My question was not how to keep record of the last playing track, which is not a big deal, but whether this supposed foobar2000 internal reference exists and if I'm missing a SMP method the retrieves it.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Emerelle on 2020-10-27 17:19:42
Hi,

thank you very much for this awesome panel!
I updated almost all of my very outdated WSH panels and Im very happy.

One question - and a request for coding help :/
I am using the sample script of the menu button. I would love to add an onHover image to the menu image though.
Can someone give me pointers into the right direction?

Here is the script I use:
Code: [Select]
'use strict';

window.DefinePanel('Menu Button', {author:'marc2003'});
include(fb.ComponentPath + 'samples\\complete\\js\\lodash.min.js');
include(fb.ComponentPath + 'samples\\complete\\js\\helpers.js');
include(fb.ComponentPath + 'samples\\complete\\js\\panel.js');

let panel = new _panel(true);
let buttons = new _buttons();
buttons.buttons.menu = new _button(0, 0, 36, 36, {normal : 'misc\\foobar2000.png'}, (x, y, mask) => { _menu(0, 36); }, 'Menu');

function on_focus(is_focused) {
if (is_focused) {
plman.SetActivePlaylistContext();
}
}

function on_colours_changed() {
panel.colours_changed();
window.Repaint();
}

function on_mouse_lbtn_up(x, y, mask) {
buttons.lbtn_up(x, y, mask);
}

function on_mouse_leave() {
buttons.leave();
}

function on_mouse_move(x, y) {
buttons.move(x, y);
}

function on_mouse_rbtn_up(x, y) {
if (buttons.buttons.menu.trace(x, y)) {
_help(0, 36);
return true;
} else {
return panel.rbtn_up(x, y);
}
}

function on_paint(gr) {
panel.paint(gr);
buttons.paint(gr);
}

function on_size() {
panel.size();
}
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2020-10-28 19:35:43
I am using the sample script of the menu button. I would love to add an onHover image to the menu image though.
Can someone give me pointers into the right direction?

From what I gather, you can add the hover image as a property of the fifth argument of the _button() function, which is an object.
If you look at line 10, you will see the img_src argument which is
Code: [Select]
{normal : 'misc\\foobar2000.png'}
Just add another property with key "hover" and value either an image (GdiBitmap), or if you place the image in the  "samples\complete\images" directory, a string with the last part of the image path.
For example
Code: [Select]
{normal : 'misc\\foobar2000.png', hover : 'buttons\\menu_hover.png'}

The _button() function code where you can learn all this is in the "samples\complete\js\helpers.js" script.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Emerelle on 2020-10-29 05:22:37
Thank you so much, davideleo!

It is hard for me since I am not a programmer at all; I will try out your suggestion today :)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: JOSHSKORN on 2020-10-30 18:06:15
Hi.  I'm I've been racking my brain, trying to create a custom list of my library and I just can't seem to figure it out.  Basically, I want to list all of my artists and then albums.  See table example:

List(Artist, Album, Genre, Total Album Length, Total Number of Tracks, Date, Front, Back, CD)

The fields Front/Back/CD are to test the immediate folder for the contents of Front.jpg, Back. jpg and CD. jpg.

Can this be accomplished using Spider Monkey Panel?  If so, is there sample coding I can work off of?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2020-10-31 12:18:17
Hi.  I'm I've been racking my brain, trying to create a custom list of my library and I just can't seem to figure it out.  Basically, I want to list all of my artists and then albums.

I'm very sympathetic to your issue because after some months of studying javascript I was still lost applying it to foobar2000 and the answer marc2003, alias @snotlicker , gave me to a similar question was enlightening and a turning point for me (I still have to thank him for this). You can read the exchange here (https://hydrogenaud.io/index.php?topic=110516.msg941771#msg941771).

Since that was a jscript panel discussion, here is a spider monkey version of the code, which is also lodash-free.
Code: [Select]
fb.ShowPopupMessage(listByTag("artist").join("\n"));


function listByTag(tag){
    let tags = [];
    let items = fb.GetQueryItems(fb.GetLibraryItems(), tag + " PRESENT");
    for (let i = 0; i < items.Count; i++) {
        let num = fb.TitleFormat("$meta_num(" + tag + ")").EvalWithMetadb(items[i]);
        for (let j = 0; j < num; j++) {
            tags.push(fb.TitleFormat("$meta(" + tag + "," + j + ")").EvalWithMetadb(items[i]));
        }
    }
    return [...new Set(tags)].sort();
}
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Emerelle on 2020-11-01 10:07:08
I had been using one of the one-panel examples, the text reader script. It crashed my foobar ever so often that I had to take the panel out of my layout.

I didnt add any modifications of the code at all, so I was wondering if there is a known issue with the loading time of this script? I get a "one script on this page is not responding" message when I add it to my layout up to the point foobar2000 will not come up anymore at all.

Its a real shame since I store the contents of audiobooks in a info.txt file.

Any hint very welcome!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: zeremy on 2020-11-03 17:07:37
@TheQwertiest

Regarding the callback on_script_unload()

The docs say:

Called when:
- Panel script is reloaded via context menu > Reload.
- Panel script is changed via panel menu > Configure.
- fb2k is exiting normally.
Not called when:
- Script fails with error.
- fb2k closed externally (e.g. killed with process manager).
- fb2k fails with exception.

Do the same restrictions apply as the jscript component that the callback is not guaranteed to be called during unloading.?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-11-03 19:53:59
@zeremy , AFAIK, JSP has mostly the same behaviour as SMP regarding `on_script_unload`. It's just not listed explicitly.

@Emerelle , does it fail for every track? Or does it fail only on specific file? If the latler, please send me an example, so I can reproduce the problem.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2020-11-04 08:06:32
not guaranteed to be called during unloading.?

I think that was inherited from WSH panel mod and I've never given it a moments thought. I guess I should test/update the docs. I'm pretty sure it's always called but the original dev was just being extra cautious.

In addition to the SMP docs you quoted, it should also be called when removing/replacing a panel in layout editing mode.

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Emerelle on 2020-11-04 12:11:03
@TheQwertiest It fails on load, when I start foobar. I get a notification that a script takes too long to load and if I want to stop it or wait for it to load. Sometimes even foobar does not load at all anymore and I have to kill the process.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Mrakobes on 2020-11-05 10:12:12
Recently (after updating the player), the script started to crash, this is observed on some audio.
(https://i114.fastpic.ru/thumb/2020/1105/80/_137c398386c40388a1238df355d9cd80.jpeg) (https://i114.fastpic.ru/big/2020/1105/80/_137c398386c40388a1238df355d9cd80.png)
I understand that the code was developed in collaboration with marc2k3, can here take the files
https://github.com/marc2k3/foo_jscript_panel
only problem is that samples are there in TXT no JS
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: VERDAE on 2020-11-05 17:26:15
Hey, I downloaded the SMP debug and now I'm getting this error whenever I try to open Foobar. What can I do to fix this? I'm also somewhat new to foobar so I apologize if this is a stupid question lol:

Error: Spider Monkey Panel v1.3.2-beta+f0830b60 ({269F9404-C9AD-4BFA-957D-26628B44C199})
include failed:
ActiveXObject_Constructor failed:
Invalid CLSID: UIHacks

File: JStheme_common.js
Line: 863, Column: 26

Stack trace:
  oUIHacks@JStheme_common.js:863:26
  @JStheme_common.js:1023:17
  @<main>:1:1
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: zeremy on 2020-11-05 21:13:09
not guaranteed to be called during unloading.?

I think that was inherited from WSH panel mod and I've never given it a moments thought. I guess I should test/update the docs. I'm pretty sure it's always called but the original dev was just being extra cautious.

In addition to the SMP docs you quoted, it should also be called when removing/replacing a panel in layout editing mode.


@snotlicker
I found that the culprit not letting me run the callback in a script was your helpers.js that was an include.
It has the function
Code: [Select]
function on_script_unload() {
_tt('');
}
in it 
and the second on_script_unload() in my script didn't get executed.

Maybe some sanity checks are needed as to define the same function only once.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2020-11-05 21:31:43
The normal convention in javascript is that if a function with the same name is defined more than once, the last version always takes precedence. For example...

Code: [Select]
function message(name) {
    console.log("hello", name);
}

function message(name) {
    console.log("bye", name);
}

message("zeremy"); // always outputs "bye zeremy"

But the include function built in to SMP breaks this convention so if the first definition is inside an include file, that will take precedence instead.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: wcs13 on 2020-11-18 16:07:17
Quick hack, complete\js\thumbs.js, line 492
^Forget I posted that. It will lead to undesirable/buggy behaviour. It could be done properly but I'm far too lazy for that.
Thanks for trying though  :)
I hope it can be done properly by TheQwertiest or you at some point, because low-res art tends to ruin the whole Thumbs experience.

In my case I have a nice bio on the left half of the screen... and quite often I have a low-res art on the right half, even though I know that many hi-res pics exist for the same artist/album.
Hi-res art should definitely be prioritized IMHO (when available). It's not about completely avoiding low-res, but rather about preferring hi-res when possible. Fingers crossed.  :)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2020-11-19 09:16:39
This might work instead...

Code: [Select]
	this.update = () => {
this.image = 0;
this.files = [];
this.images = [];
_(_getFiles(this.folder, this.exts, false))
.map((item) => {
var img = gdi.Image(item);
return {
path : item,
image : img,
area : img.Width * img.Height
};
})
.orderBy((item) => {
return item.area;
}, 'desc')
.forEach((item) => {
this.files.push(item.path);
this.images.push(item.image);
});
this.size(true);
window.Repaint();
}
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: wcs13 on 2020-11-19 19:44:12
This might work instead...
Thanks, trying to make it work :)

EDIT - doesn't seem to work.
I have tried it on Beyoncé. It seemed like a good example, since her last.fm page has 5000+ pictures, some low-res, some hi-res.
The modified Thumbs.js just appears to download the first n pictures in her page (in my case the first 10 pictures), regardless of their size.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2020-11-19 20:44:54
That code is simply for re-arranging files that are inside the folder. Don't like it? Don't use it.

Do I really need to tell you that asking about thousands of images online is ****ing insane.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: wcs13 on 2020-11-20 01:06:51
I may have missed something, but I don't think I was rude at all in my message. So why are you ?  :o

Do I need to remind you what was kindly requested months ago in the first place ?
@wcs13 , it might be possible to implement such logic in the script (ignoring low-res images that is), but I'm currently prioritizing component development over script improvement. In other words it won't be fixed anytime soon, sorry.

You just posted a bit of code, with no indications of what it's supposed to do.
I'm not a dev. So of course I didn't examine the code, because I thought you were answering to what was requested.
Now you say that your code was only for re-arranging images (from hi-res to low-res in foobar I guess), which has little to do with what was requested (ignoring, not re-arranging).

Now don't get me wrong : I'm grateful for your bit of code and I'm grateful for you wanting to help.
It's of course better than nothing, but it's hardly a solution, because if Thumbs.js downloaded a majority of low-res images in the first place, then sorting them will not be very useful, unless we're only interested in the first or second image.

BTW, did I ever ask about parsing thousands of images online ? No !  :o  I'm not that stupid.
Ignoring low-res images can be much simpler. I assume you know lots of ways to do it. Here's one :
If we are reasonable with the enough-res resolution (e.g. 360.000 pixels min, that's 600x600), we won't need to ignore lots of images. So for n saved images, I guess we may need to parse 1.5n images, maybe 2n images, but hardly more.

I guess that's what @TheQwertiest suggested that he'd do when he'd have some time. If somebody is willing to do it, I'm sure I won't be the only one to be grateful. If not, then I'll just keep waiting. There's nothing else I can do.

BTW here's how my 32" 1440p display looks with a low-res image (see attached file). Like I said, it ruins the whole experience a bit.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2020-12-10 19:44:43
Is it possible to rename the main menu entries? (I was expecting it would be available on the preferences panel)
XX

Why? Because adding those menu commands to standard foobar buttons give the menu name as tool-tip texts.
X

Renaming the menu entries would give a clue of what they do without having to use text buttons.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: cooldude on 2020-12-12 21:02:43
I've been trying to find a convenient way to view, select and automatically cycle through all the images which are in the same folder as a song, and also a subdirectory below. The "Artist Images"/"thumbs.js" script which is included is nearly perfect.

But currently, it only shows images from the same directory as the music file - using this:
Code: [Select]
$directory_path(%path%)
How do I set it up so that it also shows images from a directory below the file (for example, if there's a folder filled with covers)?
In addition, is it possible to also have it show embedded album art? Currently it can't.

So in summary, I'd like it to show the images in the same folder, the images in any folder which is directly below, and embedded images.

The last and smallest thing that would be nice to have, is to somehow change this background color (currently black):

(https://i.imgur.com/T46BJ6F.png)
The included setting doesn't change it.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2020-12-13 21:03:09
Probably not exactly what you needed, since I'm using other script. But sure you can take the path part to suit your needs.

Code: [Select]
window.DefinePanel("LoadImageAsync", { author: "XXX" });

let sel = ""
let path = ""

if (fb.IsPlaying) {
    sel = fb.GetNowPlaying();
    path = fb.TitleFormat("$directory_path(%path%)").EvalWithMetadb(sel);
}

// Get a list of jpg files from a folder
var pathart = ""

if (utils.FileTest(path + '\\art', "e"))
    pathart = '\\art\\';
else if (utils.FileTest(path + '\\artwork', "e"))
    pathart = '\\artwork\\';
else if (utils.FileTest(path + '\\_artwork', "e"))
    pathart = '\\_artwork\\';

const g_image_list = utils.Glob(path + pathart + '*.jpg');
let ww = 0, wh = 0;
let g_img = null;
let g_valid_tid = 0;

// Trigger every 5 seconds.
let g_timer = setInterval(function () {
    load_random_image_async();
}, 5000);

load_random_image_async();

function on_playback_new_track() {
    let g_timer = setTimeout(function () {
        window.Reload();
    }, 1000);
}

function on_playback_starting() {
    let g_timer = setTimeout(function () {
        window.Reload();
    }, 1000);
}

function load_random_image_async() {
    // Load a random image from the list
    let path = g_image_list[Math.floor(Math.random() * g_image_list.length)];
    // on_load_image_done will be triggered when the image has been loaded
    g_valid_tid = gdi.LoadImageAsync(window.ID, path);
}

function on_size() {
    ww = window.Width;
    wh = window.Height;
}

function on_paint(gr) {
    if (!g_img) {
        return;
    }

    let scale_w = ww / g_img.Width;
    let scale_h = wh / g_img.Height;
    let scale = Math.min(scale_w, scale_h);
    let pos_x = 0, pos_y = 0;
    if (scale_w < scale_h) {
        pos_y = (wh - g_img.Height * scale) / 2;
    }
    else if (scale_w > scale_h) {
        pos_x = (ww - g_img.Width * scale) / 2;
    }
    gr.DrawImage(g_img, pos_x, pos_y, g_img.Width * scale, g_img.Height * scale, 0, 0, g_img.Width, g_img.Height);
}

// After loading image is done in the background, this callback will be invoked
function on_load_image_done(tid, image, image_path) {
    if (g_valid_tid === tid) {
        g_img = image;
        window.Repaint();
    }
}

"Pathart" is the subfolder part you want. Ex:
ACDC/Black in black/Artwork/front.jpg
ACDC/Black in black/Artwork/...
ACDC/Black in black/track1
....
ACDC/Black in black/cover.jpg

I only have 3 possible artwork sub-folder names, so that's the 3 "if sentences" part.

Then const g_image_list = utils.Glob(path + pathart + '*.jpg') just merges the file path (track folder) with the subfolder path and takes all jpg files. It should work with any other extension, but beware I have no idea if js displays png or other image files right. I just note you can put whatever you want on that list.

So the first part of this script should work for you in your script in some way. It just displays 1 image at a time and cycle it.

About adding the embedded artwork, I have a "cover.jpg" file present on the base folder, so that's what I would check. Adding that file to the image list too. If you talk about the cover within the track, then you can check "GetAlbumArtAsync.js" on samples folder.


EDIT: After re-reading.. btw if it's just a matter of config editing and you can put whatever tittle-formatting you want then:

$directory_path(%path%) --> $directory_path(%path%)\artwork

That should do. Or your desired subfolder name. (Note, anyway, that would restrict the images to just the subfolder).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: cooldude on 2020-12-14 23:03:03
EDIT: After re-reading.. btw if it's just a matter of config editing and you can put whatever tittle-formatting you want then:

$directory_path(%path%) --> $directory_path(%path%)\artwork

That should do. Or your desired subfolder name. (Note, anyway, that would restrict the images to just the subfolder).

Thanks. However, I can't find any "GetAlbumArtAsync.js" file anywhere, and probably wouldn't know what to do with it.

The way I can select particular images with the "thumbs.js" script is quite slick and practical, and something similar would be a must if I'm going to bother with this. But it seems it may not be possible to simultaneously view images from folders, subfolders and embedded images while using it.

I also don't mind using other scripts if there's ones which would work for all this. It's just that without being able to view all three sources simultaneously (images in folders, subfolders, and embedded), most of the album art in my different collections would end up missing.

There's an older WSH artwork script which might work and I want to try, hopefully someone can reupload it:
https://hydrogenaud.io/index.php?topic=77883.msg991453#msg991453
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: dwmartin0906 on 2020-12-20 01:03:50
Hi.  I have a strange issue using the on_mouse_mbtn_up function.  When my script is in an embedded panel, I have to double click to get the desired result.  A single click is ignored.  But when the same script is in a foo_flowin pop-up panel, it works just fine.   I also use on_mouse_lbtn_up and it works fine either way.  Does any one have an idea what might be causing this? 
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2020-12-25 16:19:07
Ignoring low-res images can be much simpler. I assume you know lots of ways to do it. Here's one :

    Check image 1. If enough-res, save it, or else ignore it. Go to the next image.
    Repeat until you have n enough-res saved images.
That's actually the problem. To get image dimensions you need to download it. So, if there are only low-res images, you'll have to download all those images first.

Is it possible to rename the main menu entries? (I was expecting it would be available on the preferences panel)
I have plans to totally rework `main menu buttons` feature (and make it possible to generate buttons dynamically), but I don't think it will be done any time soon.

Hi.  I have a strange issue using the on_mouse_mbtn_up function.
What do you mean by "embedded panel"? Also can you attach an example script that has such problem?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: dwmartin0906 on 2020-12-26 02:56:36
Thank you for responding.  I used the term "embedded panel" to refer to a normal Foobar panel as defined with splitters, as opposed to pop-up panels created with foo_flowin.  And I found the problem.  Another component was set up to use the middle mouse button, even though I had never used it.  I redefined the keys used by that component and on_mouse_mbtn_up now works as expected with a single click.  I've just started learning Spider Monkey scripting and am amazed at the power and flexibility it offers.  Thank you very much for this amazing component and the excellent documentation you provide.

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2020-12-26 17:59:46
9483]
Is it possible to rename the main menu entries? (I was expecting it would be available on the preferences panel)
I have plans to totally rework `main menu buttons` feature (and make it possible to generate buttons dynamically), but I don't think it will be done any time soon.
[/quote]

That would be much appreciated.

Also, would it be possible to add a Find(handle) → {number} function with configurable order (inverted too)? Or one which outputs all coincidences?

I'm working on a remove duplicates" function (more advanced than 'same raw path'), while maintaining playlist order by duplicating handles and working on sorted lists on parallel to the original one (A).
For 17K tracks that means 1.5 seconds (A). 327 seconds working without cloned sorted list. And 369 ms if I don't care about original order at all.

The problem I got for (A) is that remove(handle) removes all coincidences (but I one to maintain one!), so I use Find(handle) to  then remove by ID at the original unsorted list. But... it obviously outputs just one match, instead of all. And it always search from the start of the list, so the removed position is not configurable.

I'm currently doing this within some loops and other code (for tags):
Code: [Select]
									let handleAidx =[];
let idx = handle_list.Find(handleA); //Needed. Or it would remove all instances of the same handle!
let idxcache = idx;
while (idxcache != -1) {
handle_list.RemoveById(idxcache);
idxcache = handle_list.Find(handleA);
}
handle_list.Insert(idx,handleA); //It was last copy. Revert once to first place.
break;
With oriented search it would convert to:
Code: [Select]
									let idxA = handle_list.Find(handleA); 
let idxB = handle_list.Find(handleA,-1); //Inverse
while (idxA != idxB) {
handle_list.RemoveById(idxB);
idxB = handle_list.Find(handleA,-1);
}
break;

Or find array result:
Code: [Select]
									let findArray= handle_list.Find(handleA);
let i = findArray.length;
while (i--) {
handle_list.RemoveById(findArray[i]);
}
break;
Which would be so much better and faster.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: sndsAU on 2021-01-08 02:25:07
Hi, I am using the Spider Monkey panel and the included sample file "js smooth browser" for a cover art browser.
My question is, is there a way to actually cache the artwork to local disk? My music is stored on a NAS and the artwork is embedded in the flac files.

There is a setting that can be selected in the popup menu "Enable Disk Image Cache" but this seems broken/has no effect. Everytime foobar is restarted, the panel has to reread the art from remote files.

Thanks.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-01-14 08:34:41
Utils.Version returns the version of SMP, but I was wondering if there a way to get the version of foobar currently running?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: zeremy on 2021-01-14 09:56:43
Utils.Version returns the version of SMP, but I was wondering if there a way to get the version of foobar currently running?

Code: [Select]
fb.TitleFormat("%_foobar2000_version%").Eval(true);
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-01-14 16:22:43
Brilliant. Should have known there'd be a title_format field. Thank man!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-01-15 10:37:07
How do I load a playlist by path?
LoadPlaylist() doesn't accept any argument according to the documentation
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-01-15 10:53:14
plman.AddLocations. It expects an existing playlistIndex as one of the args so you might want to create a new one with plman.CreatePlaylist first.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-01-15 11:15:13
plman.AddLocations. It expects an existing playlistIndex as one of the args so you might want to create a new one with plman.CreatePlaylist first.
Yep, got it working. The idea is to have a playlist manager with {names/paths} and load playlists on foobar only on demand (instead of cluttering the playlist tab with all playlist loaded at the same time). So the name (and thus new ID needed) will be already given by the object. Thanks!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-01-15 17:14:07
@TheQwertiest FYI, the latest nightly causes foobar to crash on startup.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-01-15 17:16:52
@TheQwertiest FYI, the latest nightly causes foobar to crash on startup.
Are you using DUI? (https://github.com/TheQwertiest/foo_spider_monkey_panel/issues/129)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-01-15 20:08:47
@TheQwertiest FYI, the latest nightly causes foobar to crash on startup.
Are you using DUI? (https://github.com/TheQwertiest/foo_spider_monkey_panel/issues/129)
Yup. I'll give the new nightly a look.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Black_Over_Bills_Mothers on 2021-01-16 15:53:37
Using nightly build (v1.3.2-beta+9a1b2b36).

Exploring the changed features. panel properties/ configuration (one with three tabs). Can you please make this re-sizeable. Also on the properties tab (same as old version), can you please increase the width of the horizontal splitter as it's very difficult to grab with the mouse and move.

On a more general note, I hope all your great ideas for v2 have been included into the single project git project.

Looking forward to the next official version.

Thanks for your efforts. They are very much appreciated.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-01-16 16:43:46
Can you please make this re-sizeable.
I'd like to, but, TBH, my UI programming skills are close to non-existent >_<
But I will try...
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-01-16 17:37:05
Speaking about the properties panel (I'm using the stable release btw), could the keys be sorted following natural number order?

X
As is, it's currently broken for anything over 9. 10 appears after 1. Or should I force it adding zeros? (most times I don't know how many properties will be created with my buttons framework so it's not trivial)

Btw, are you open to any other suggestion for the panel?
- I'm thinking about predefined values: if you set true to a property, the panel already shows a dropdown with true/false. Allowed values could be set with the current set function as a third argument (not breaking current scripts).
-Could a property panel be created according to an ID? Right now I just add properties sequentially to the current SMP panel whenever I merge/add buttons... I assign different IDs and prefixes to the properties so every button has it's own set. But obviously that add a ton of variables to the properties panel. Creating panels on demand with an ID would solve that, I would simply assign every panel to its own button. Then overriding the menu on right click to show button properties instead of panel properties.
X
As you see, I'm currently doing it with prefixes + numbers at script loading, so at least the sorting part would be a lifesaver.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-01-16 18:19:49
Speaking about the properties panel (I'm using the stable release btw), could the keys be sorted following natural number order?
Not sure, I need to check if there's any built-in sorting function that allows to do that, since I don't want to drag a big chunk of code in component just for that.

For now you can just append three zeroes, I mean I doubt that there'll be more than 1k buttons :D

- I'm thinking about predefined values: if you set true to a property, the panel already shows a dropdown with true/false. Allowed values could be set with the current set function as a third argument (not breaking current scripts).

I was entertaining this idea, actually. This is one of the big features that I want to work on:
- additional display mode for Properties dialog: properties are displayed as a tree view, where `.` character is used as a separator.
- support for arrays (yet to figure how it will work though).
- ability to set property type explicitly (in dialog and via JS).
- support for enum values (the feature that you are requesting).
- ability to manipulate properties as a json (where objects are generated the same way as the tree view).

Not sure when I'll come around to implementing all that though.

-Could a property panel be created according to an ID? Right now I just add properties sequentially to the current SMP panel whenever I merge/add buttons... I assign different IDs and prefixes to the properties so every button has it's own set. But obviously that add a ton of variables to the properties panel. Creating panels on demand with an ID would solve that, I would simply assign every panel to its own button. Then overriding the menu on right click to show button properties instead of panel properties.
As you see, I'm currently doing it with prefixes + numbers at script loading, so at least the sorting part would be a lifesaver.
The `panels` you are talking about are virtual panels, but there is no such concept in SMP right now and I don't think I want to introduce it and there several reasons for that:
- This is quite a big feature. The proper concept introduction will require quite a lot of new API (and component code to support it).
- It's use-case is quite niche. In 99,999% cases buttons don't need any additional properties and usually work just as a dumb callback-invoker.

So, while idea itself is pretty cool, I just don't have any spare capacity to work on it (being the sole maintainer of this project and all that)...

However, I do think you'll be able to work around your problems with the Properties rework, that I've mention above (without having to resort to implementing `virtual panel`s in SMP).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-01-16 18:37:34
I just don't have any spare capacity to work on it

To give you some idea on the workload: just a small overview of all the currently planned features for next releases: https://github.com/TheQwertiest/foo_spider_monkey_panel/projects/1#column-3416309

And that's not counting all other projects that I want to work on... >_<
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-01-18 02:05:55
And that's not counting all other projects that I want to work on... >_<
The pain is real. It's why I seem to never succeed in finishing anything :D

Thanks for all the amazing work on SMP though!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Black_Over_Bills_Mothers on 2021-01-18 09:11:55
@Qwertiest
Not wishing to add to your workload too much... any chance of changing the file name sent to an external editor. At the moment it is smpxxxx.tmp. To help get the most out of MS Code for example, it would be good if the file name used was smpxxxx.js.

ps Thanks for the easier-to-grip properties splitter
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2021-01-18 09:38:12
To give you some idea on the workload: just a small overview of all the currently planned features for next releases: https://github.com/TheQwertiest/foo_spider_monkey_panel/projects/1#column-3416309

Delighted to see these ❤
(https://lh3.googleusercontent.com/W5eF1c9v54jxQTOrMVZXIdzV4aS4y-FpNvWOQKunIxKC9Tz-tmpcrs75W_R28eIojMkcCjEVAoLGyYGNDD1GIuMj_EKSoxljbJ0WeFuCFqZzotoasPdkJ46tKqBOPRruKcP1b0rlDHZ_UMErRRuqJTKD45HDmyyLZfL_0uDEDSgAn0VuWXR4DBW-JbyxlvIrfTKeloDXJaOc3Hhf_YLSGwiQf8zfsg6h0eyYxDhtn6pCwsS-SnF-sVGhS4byBe_H-jFD714ykZTAiIKaFnCVYCDHZXtjN4v4NF-hiuywghaBxWU25G0C1CTCA4jLkt_51G-U2faZkZE0H0FNOchzCILV2ELx9sItX2RtBweOdoLnUWkAUgfmswP4LG2-cqe0cO_e13ZfRVg5q2Ha6gXODXQkftiah4nzcC0RaLNy1SkPdkTbIyAXUWjYLK24a3iqgYMDntyi2vKwLU1q8XYNloD-R19dUCbcOCVVijlIZ8LUo6hU5EpgLOh4YcOt7A2wfljSvmvt3bwvHFFsn3FfJUyjSTuPsSxXJIcX1SmlO26InEMvg0noI9M2xKB8Puk1SDYL-3fXznXtmC_3YeKpW1UrWt58YTKJTs3_kv8lJEo-CPC1QHKBR1YsLioG1tGZXdV2RwHVfdVTVOT5IRkB-8g79vrO0KrpDs9Hx3im3nHDxnOADsc2xMzlnKiK=w366-h347-no?authuser=0)
Keep it up, this component makes foobar2000 so much fun!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-01-18 10:41:42
Not sure, I need to check if there's any built-in sorting function that allows to do that, since I don't want to drag a big chunk of code in component just for that.

For now you can just append three zeroes, I mean I doubt that there'll be more than 1k buttons :D
Yep, did that and works great. Most things have <30 options, and as you said I don't plan to have more than 10 buttons on the same bar.

Quote
- additional display mode for Properties dialog: properties are displayed as a tree view, where `.` character is used as a separator.
- support for arrays (yet to figure how it will work though).
- ability to set property type explicitly (in dialog and via JS).
- support for enum values (the feature that you are requesting).
- ability to manipulate properties as a json (where objects are generated the same way as the tree view).
That would be great!
I support arrays and objects separating keys/values by commas and then converting it to arrays/objects with my own helper hahahaha not pretty but works. I needed it to allow setting arbitrary tags on filters (remapping X tags to be treated as 'genre'). Or pairs {tag: value}. Obviously the downside is that you have to manually follow the convention needed for that property and warn about it on the description (one "solution" is use the value for that: PUT HERE AN OBJECT {...}).
For simplicity I just use x,value,y,value... but I see no reason to allow "{}" or "[]" notation.

Btw, I manipulate properties as objects. I simply create one with default properties (the main function), then I add new properties on buttons if required. Use [...old, ...new] and have my own set of functions to set, get all values at once. Since I use prefixes and unique IDs, I can pass the object to functions and load the associated properties by merging the default keys with the ID. That works good enough for me, and I even use properties to set tooltips dynamically for every button. Prefixes can be set to name different categories within the properties. Also using  [...old, ...new], you can simply create 4 different properties objects on the js file (if that makes easier the readability or you need conditional settings) and then merging them. Not a tree like view but works.

About that, the only thing I could not make to work are paths. Property values seem to be converted to strings when using the "get..."), so paths with "/" get broken. I was expecting to be able to use raw on output and then change "/" to "//" before converting the path to a string, but no way. Also that string implicit conversion gave me some headaches, since numbers were sometimes treated as strings until I found I had to explicitly add Number() when getting properties (and tags too! -like date-)

Quote
The `panels` you are talking about are virtual panels, but there is no such concept in SMP right now and I don't think I want to introduce it and there several reasons for that:
- This is quite a big feature. The proper concept introduction will require quite a lot of new API (and component code to support it).
- It's use-case is quite niche. In 99,999% cases buttons don't need any additional properties and usually work just as a dumb callback-invoker.
Well that's exactly the use-case for all the things I have developed for playlist creation hahaha But it's working using my framework, so it's not a needed thing at all. Got it right with the padding and creating unique IDs. I also managed to show the IDs within the tooltips, so it's pretty easy to know which button is associated to which ID. That's good enough for me and once I share it on github, could be used by anyone as a workaround.

Oh, and other thing I noticed these days. Just a question. Why the getMeta... way is slower than ussing TF? Let's say you have 30k tracks and I need to get all the values of genre, mood, style, etc. and then loop through them to check some things. I have noticed it's faster to use evalwithmetadbs(), setting a TF expression like "tagX | tagY ..." and then splitting things on multidimensional arrays using "|" per tag, and ", " per value than looping through files and getting tags... that was weird. I mean... the method to get tags is slower than the method expected to be the slowest one. What's the use of the getMeta... then? Am I missing something?

And could you confirm this?
Quote
Thanks! Well the html rendering part is done outside foobar with a browser, so it's just using standard js code. I'm not sure if it could be integrated in any way within foobar as a html popup though (?) On github, you told me IE is used for html rendering, so I could try that path once I install it. I don't use fancy things, just standard js, SVG rendering and jquery as a library. It would be awesome: I could do things like showing tracks from the library matching the node selected, playlists by node and "radius", etc.

I still have to check the iso subsong bug, I will update the issue on github as soon as I can. Thanks for this great component and all your work!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-01-18 11:31:00
@Qwertiest
Not wishing to add to your workload too much... any chance of changing the file name sent to an external editor. At the moment it is smpxxxx.tmp. To help get the most out of MS Code for example, it would be good if the file name used was smpxxxx.js.
Sure =)

About that, the only thing I could not make to work are paths. Property values seem to be converted to strings when using the "get..."), so paths with "/" get broken. I was expecting to be able to use raw on output and then change "/" to "//" before converting the path to a string, but no way. Also that string implicit conversion gave me some headaches, since numbers were sometimes treated as strings until I found I had to explicitly add Number() when getting properties (and tags too! -like date-)
Not sure I understand your problem with paths, could you elaborate, plz?
Regarding strings and types - this is the only way I can find out the property type, i.e. I can't convert string to int myself, since it might've been intended to be a string by user, but just happened to contain numbers inside.

Oh, and other thing I noticed these days. Just a question. Why the getMeta... way is slower than ussing TF? Let's say you have 30k tracks and I need to get all the values of genre, mood, style, etc. and then loop through them to check some things. I have noticed it's faster to use evalwithmetadbs(), setting a TF expression like "tagX | tagY ..." and then splitting things on multidimensional arrays using "|" per tag, and ", " per value than looping through files and getting tags... that was weird. I mean... the method to get tags is slower than the method expected to be the slowest one. What's the use of the getMeta... then? Am I missing something?
What do you mean by getmeta?

And could you confirm this?
https://theqwertiest.github.io/foo_spider_monkey_panel/assets/generated_files/docs/html/utils.html#.ShowHtmlDialog


@davideleo , no ETA though :P (as usual)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-01-18 16:10:48
What's the use of the getMeta... then? Am I missing something?

The point of using GetFileInfo() is that you can access all tags within a file without knowing what they are. Using title formatting, you have to know in advance what tags you want to access. Load up the samples\properties sample. It doesn't know or care about your tags but displays them all regardless. If that script was based on title formatting, you'd have to tell it about each and every tag your files might contain.

edit: some sections of that properties sample are based on title formatting but the main meta and tech info sections use GetFileInfo and loop through the available fields without knowing the names.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-01-18 21:59:06
Quote
Not sure I understand your problem with paths, could you elaborate, plz?
Regarding strings and types - this is the only way I can find out the property type, i.e. I can't convert string to int myself, since it might've been intended to be a string by user, but just happened to contain numbers inside.
Let's say I create a property.
window.GetProperty(blabla, 'C:\path\gbqaws');
For sure, that path it's wrong if you use it as is within js. You know it, I know it. Ok. But what about users?
window.GetProperty(blabla, 'PUT HERE YOUR PATH');
Then the user just copy/paste paths from explorer and...
99.99% programs within windows give you paths with single "\" when copying them.

Maybe that's easily solved with other method (I'm totally novice on js) but as far as I know the only way to manage that usage is using String.raw'whatever' . But that workaround does nothing in this case since the getProperty value has been already converted to string where escapes have been processed. So...
window.GetProperty(blabla, 'PUT HERE YOUR PATH').replace('\','\\'); for sure doesn't work.
neither
String.raw'${window.GetProperty(blabla, 'PUT HERE YOUR PATH')}'.replace('\','\\');
nor
String.raw'${window.GetProperty(blabla, String.raw'C:\path\gbqaws')}'.replace('\','\\');
As far as I tested, you are forced to put double \ on the panel (?) because the returned value has been already converted to string. Similar behavior can be found with other escapes.

Quote
What do you mean by getmeta?

This
Code: [Select]
function getTagsValues(handle, tagsArray, bMerged = false) {
if (!isArrayStrings (tagsArray)) {return null;}
if (!handle) {return null;}

const sel_info = sel.GetFileInfo();
const tagArray_length = tagsArray.length;
let outputArray = [];
let i = 0;

while (i < tagArray_length) {
let tagValues = [];
const tagIdx = sel_info.MetaFind(tagsArray[i]);
        const tagNumber = (tagIdx != -1) ? sel_info.MetaValueCount(tagIdx) : 0;
if (tagNumber != 0) {
let j = 0;
while (j < tagNumber) {
tagValues[j] = sel_info.MetaValue(tagIdx,j);
j++;
}
}
outputArray.push(tagValues);
i++;
}

if (bMerged) {outputArray = outputArray.flat();}
return outputArray;
};

Is slower than this;
Code: [Select]
]function getTagsValuesV3(handle, tagsArray, bMerged = false) {
if (!isArrayStrings (tagsArray)) {return null;}
if (!handle) {return null;}

const tagArray_length = tagsArray.length;
let outputArray = [];
let i = 0;
let tagString = "";
const outputArray_length = handle.Count;
while (i < tagArray_length) {
if (bMerged) {tagString += i == 0 ? "[%" + tagsArray[i] + "%]" : "[, " + "%" + tagsArray[i] + "%]";} // We have all values separated by comma
else {tagString += i == 0 ? "[%" + tagsArray[i] + "%]" : "| " + "[%" + tagsArray[i] + "%]";} // We have tag values separated by comma and different tags by |
i++;
}
let tfo = fb.TitleFormat(tagString);
outputArray = tfo.EvalWithMetadbs(handle);
if (bMerged) { // Just an array of values per track: n x 1
for (let i = 0; i < outputArray_length; i++) {
outputArray[i] = outputArray[i].split(', ')
}
} else { // Array of values tag and per track; n x tagNumber
let tfo = fb.TitleFormat(tagString);
outputArray = tfo.EvalWithMetadbs(handle);
for (let i = 0; i < outputArray_length; i++) {
outputArray[i] = outputArray[i].split('| ');
for (let j = 0; j < tagArray_length; j++) {
outputArray[i][j] = outputArray[i][j].split(', ');
}
}
}
return outputArray;
}

Try it iterating on 30k tracks. I didn't understand how a TF approach is faster than using the methods to get tags. I mean... take a look at how many things I have to do to get usable output with TF...
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-01-18 22:02:51
What's the use of the getMeta... then? Am I missing something?

The point of using GetFileInfo() is that you can access all tags within a file without knowing what they are. Using title formatting, you have to know in advance what tags you want to access. Load up the samples\properties sample. It doesn't know or care about your tags but displays them all regardless. If that script was based on title formatting, you'd have to tell it about each and every tag your files might contain.

edit: some sections of that properties sample are based on title formatting but the main meta and tech info sections use GetFileInfo and loop through the available fields without knowing the names.
Ok that makes sense now... all my use-cases use already known tags names to compare things. So then those methods are only useful when iterating all tags. At least performance wise. I was slowing my scripts using the first approach without needing.

Quote
https://theqwertiest.github.io/foo_spider_monkey_panel/assets/generated_files/docs/html/utils.html#.ShowHtmlDialog
Well If I understand the w3s web... looks bad,
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-01-18 22:25:42
For sure, that path it's wrong if you use it as is within js. You know it, I know it. Ok. But what about users?

This is how the language works and there is nothing you can do about it. You have to do the same thing in C++ too.

https://github.com/marc2k3/foo_jscript_panel/blob/c2cf47859536c1bfffc956cf3996ae5e9df7d70d/src/Helpers/Component.h#L10

If you're intending to share your scripts then you should be building menus/buttons that use utils.InputBox or the Properties dialog for entering strings.

Editing scripts directly is obviously very error prone and is highly discouraged.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-01-18 23:12:34
For sure, that path it's wrong if you use it as is within js. You know it, I know it. Ok. But what about users?

This is how the language works and there is nothing you can do about it. You have to do the same thing in C++ too.

https://github.com/marc2k3/foo_jscript_panel/blob/c2cf47859536c1bfffc956cf3996ae5e9df7d70d/src/Helpers/Component.h#L10

If you're intending to share your scripts then you should be building menus/buttons that use utils.InputBox or the Properties dialog for entering strings.

Editing scripts directly is obviously very error prone and is highly discouraged.

That's what I already do. That's the point, I don't expect users to know \ should be doubled. It's also pretty inconvenient.
I mean, the UI panel is exposed to the user... so I expect usage according to the user mentality (copy/paste). Using panels solves nothing if they put paths with single \ there, I was not talking about editing scripts directly. That's why string.raw exists, for arbitrary user input.

But if nothing can be done about it, then I will just warn about it.

EDIT:
window.GetProperty(description, defaultval, function)

wouldn't that solve the problem with types?
Instead of Number(window.GetProperty(description, defaultval))
just window.GetProperty(description, defaultval, function(value) {return Number(value); })
Instead of strings processed
just window.GetProperty(description, defaultval, function(value) {return string.raw'${value}'.replace('/','//'; })
function should be applied as first step when loading the user value, not later.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-01-18 23:25:55
You don't have to double the \ when using the Properties window. It really is that simple.

As an example, load up samples\thumbs. Do not use the Custom folder menu option that I've nicely added. Instead, hold down Shift+Winkey and right click to open the Properties (I always hide easy access).

Now edit the value for 2K3.THUMBS.CUSTOM.FOLDER.TF to any folder that contains images using single slashes and click OK. Do the images display? I should hope so...
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-01-18 23:32:26
You don't have to double the \ when using the Properties window. It really is that simple.
I'm lost... and how do you convert that string to something usable within your code then?
let path = window.GetProperty(blabla);

becomes an unusable string (?) and replace('\','\\'); wiill not work.

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-01-18 23:39:41
I don't do anything and at this point, I'm out. :/
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-01-19 00:04:48
Quote
Now edit the value for 2K3.THUMBS.CUSTOM.FOLDER.TF to any folder that contains images using single slashes and click OK. Do the images display? I should hope so...
Quote
Now edit the value for 2K3.THUMBS.CUSTOM.FOLDER.TF to any folder that contains images using single slashes and click OK. Do the images display? I should hope so...
Nope. Strings with single \ definitely don't work on the panel for me, that's why I reported it... because I have tested it. With your samples, I got this on console...

c:\Users\xxx\AppData\Roaming\foobar2000\scripts\SMP\samples\js-smooth\images\default.png (panel)
->
c:UsersxxxAppDataRoamingfoobar2000scriptsSMPsamplesjs-smoothimagesdefault.png (console)

If you assure the properties should work that way, I will check on a new foobar profile since there is definitely something wrong here.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-01-19 02:05:39
I should have made it clear that the script expects a path to a folder - not a filename.

Check the attachment to see my previous post illustrated.



Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-01-19 04:39:44
If you assure the properties should work that way, I will check on a new foobar profile since there is definitely something wrong here.
Yeah, I'm not sure what you're doing. As marc showed, it works just fine. I also tested this out just to make sure. If you're doing SetProperty in a script you have to escape the slashes, but you certainly don't when editing in the properties panel, because again, those are already strings.

A simple console.log(window.GetProperty('FOLDER_PATH')) will demonstrate that it's correct (once you've defined a property called FOLDER_PATH). Are you doing anything to those strings after calling GetProperty to retrieve them?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-01-19 10:55:30
I feel that you are talking past each other =)
So, I'll try to sum up all the things that @snotlicker said.

@regor , as it was mentioned above, in quite a few programming languages (and even in RegExp and windows command line) `\` character is used as an escape character or to form a control character. For example, `\n` is a control character for a new line, `\"` - escape the quote character.
Values that can be seen in property dialog have all the escape chars and control chars parsed.

So, in JS (and SMP) it will work like this:
Code: [Select]
window.SetProperty("escape_1", "\"");
console.log(window.GetProperty("escape_1"));  // Logged and displayed in Property dialog as `"`

window.SetProperty("escape_2", "\\");
console.log(window.GetProperty("escape_2"));  // Logged and displayed as `\`

window.SetProperty("path_1", "path\\to\\file.ext");
console.log(window.GetProperty("path_1")); // Logged and displayed as `path\to\file.ext`

window.SetProperty("path_2", "path/to/file.ext");
console.log(window.GetProperty("path_2")); // Logged and displayed as `path/to/file.ext`

window.SetProperty("control_1", "line_1\nline_2");
console.log(window.GetProperty("control_1"));
// Logged as:
// `line_1
// line_2`
// displayed as:
// `line_1line_2`

Thus, path strings in JS code should be either like this `path/to/file.ext` or like this `path\\to\\file.ext` .
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Black_Over_Bills_Mothers on 2021-01-19 12:19:33
Hi
I'm trying to get an indication if the single track selected is an individual flac file or part of a multi-track flac file. Any ideas?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-01-19 17:21:29
Hi
I'm trying to get an indication if the single track selected is an individual flac file or part of a multi-track flac file. Any ideas?


Check if the path ends with .cue or use title formatting for embedded cuesheets %__cue_embedded% equals yes
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-01-19 17:44:49
Check if the path ends with .cue or use title formatting for embedded cuesheets %__cue_embedded% equals yes
If cue is external (i.e. not embedded), you may also try checking FbMetadbHandle.SubSong, it seems to be above zero only when it's a multi-track file.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-01-19 17:53:47
I always thought SubSong begain with zero for the first track which is why I didn't mention it. My mistake!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-01-19 18:24:23
I always thought SubSong begain with zero for the first track which is why I didn't mention it. My mistake!
So did I =)
Just happened to have a cue file in my library to actually verify it >_<
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Black_Over_Bills_Mothers on 2021-01-19 19:15:10
Well done and thanks.
Most of my examples are a single flac file without a .cue companion. And low-and-behold the .SubSong method yields 1 upwards for each track. It is always 0 for non multi-track flacs.

Great.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Black_Over_Bills_Mothers on 2021-01-20 10:18:36
Just found out that if you use the internal editor to export a script and the name has spaces in it then the external editor (MS Code in my case) doesn't like it. Eg export as "prep new music" then use the external editior, MS Code opens two text files (prep and new) and one js file (music.js). Not sure if it's worth a code change but it's worth noting.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-01-20 14:02:04
Just found out that if you use the internal editor to export a script and the name has spaces in it then the external editor (MS Code in my case) doesn't like it. Eg export as "prep new music" then use the external editior, MS Code opens two text files (prep and new) and one js file (music.js). Not sure if it's worth a code change but it's worth noting.
That's a bug =)
Will be fixed.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: LeVvE on 2021-01-20 18:03:58
I've tried looking through the documentation but I'm not getting any wiser so I thought I'd ask here.

I want to make a button that switches between shuffle track and default playback that works like how the play/pause button in the sample "playback buttons", anyone have any suggestions on how to make it work?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2021-01-20 20:13:46
I've tried looking through the documentation but I'm not getting any wiser so I thought I'd ask here.

I want to make a button that switches between shuffle track and default playback that works like how the play/pause button in the sample "playback buttons", anyone have any suggestions on how to make it work?

Code: [Select]
			if (plman.PlaybackOrder === 4){
fb.RunMainMenuCommand("Playback/Order/Default");
} else {
fb.RunMainMenuCommand("Playback/Order/Shuffle (tracks)");
}
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-01-20 21:37:05
I feel that you are talking past each other =)
So, I'll try to sum up all the things that @snotlicker said.

@regor , as it was mentioned above, in quite a few programming languages (and even in RegExp and windows command line) `\` character is used as an escape character or to form a control character. For example, `\n` is a control character for a new line, `\"` - escape the quote character.
Values that can be seen in property dialog have all the escape chars and control chars parsed.

So, in JS (and SMP) it will work like this:
Code: [Select]
window.SetProperty("escape_1", "\"");
console.log(window.GetProperty("escape_1"));  // Logged and displayed in Property dialog as `"`

window.SetProperty("escape_2", "\\");
console.log(window.GetProperty("escape_2"));  // Logged and displayed as `\`

window.SetProperty("path_1", "path\\to\\file.ext");
console.log(window.GetProperty("path_1")); // Logged and displayed as `path\to\file.ext`

window.SetProperty("path_2", "path/to/file.ext");
console.log(window.GetProperty("path_2")); // Logged and displayed as `path/to/file.ext`

window.SetProperty("control_1", "line_1\nline_2");
console.log(window.GetProperty("control_1"));
// Logged as:
// `line_1
// line_2`
// displayed as:
// `line_1line_2`

Thus, path strings in JS code should be either like this `path/to/file.ext` or like this `path\\to\\file.ext` .
Was a bug on my installation. New foobar profile worked right, I reinstalled everything and now works as expected. Have no idea what was going on.. since same lines of code behaved differently on different profiles.

Btw, I have one more doubt. I'm trying to create a playlist manager, like the autoplaylist list on samples but for standard playlists.
Right now I got it like this: There is a monitored folder, the UI loads all files within that folder (playlists), I can open them and they are loaded within foobar, update the file (i.e. save foobar playlist to binded file), rebind playlist and rename (renaming playlist on manager, renames the file itself and the playlist on foobar). All that is working. I only have a problem, I can delete the files using this function from helpers .
Code: [Select]
let app = new ActiveXObject('Shell.Application');
function _recycleFile(file) {
if (_isFile(file)) {
app.NameSpace(10).MoveHere(file);
}
}
But restoring the file becomes a problem. I can not find a way to move files from the bin to the original folder.  I use the Move method with this, something like this
Code: [Select]
let fso = new ActiveXObject('Scripting.FileSystemObject');
let recyclePath = "c:\\$RECYCLE.BIN\\" + app.NameSpace(10) + "\\" + file.FILENAME;
let restorePath = file.PATH;
fso.MoveFile(recyclePath , restorePath );
But files are never moved from the bin. I have tried with that recyclePath which does indeed work on explorer, but not using the move function. So as far as I understand, the path should be right since it works on explorer (?)
"c:\$RECYCLE.BIN\" points to the physical folder, and  "c:\$RECYCLE.BIN\" + app.NameSpace(10) to the virtual one containing all files from any HDD
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: LeVvE on 2021-01-21 14:33:00
I've tried looking through the documentation but I'm not getting any wiser so I thought I'd ask here.

I want to make a button that switches between shuffle track and default playback that works like how the play/pause button in the sample "playback buttons", anyone have any suggestions on how to make it work?

Code: [Select]
			if (plman.PlaybackOrder === 4){
fb.RunMainMenuCommand("Playback/Order/Default");
} else {
fb.RunMainMenuCommand("Playback/Order/Shuffle (tracks)");
}
That code worked to switch, thanks a lot.
I have to ask for more help though, sadly. I want to swap icon based on which order is active, how do I add that?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2021-01-21 18:38:57
That code worked to switch, thanks a lot.
I have to ask for more help though, sadly. I want to swap icon based on which order is active, how do I add that?

Well, you can use the plman.PlaybackOrder (https://theqwertiest.github.io/foo_spider_monkey_panel/assets/generated_files/docs/html/plman.html#.PlaybackOrder) property to write a conditional statement for that, too, much in the same way as above. To keep it simple, if you are using actual images:
Code: [Select]
function on_paint(gr){
let img_path;
if (plman.PlaybackOrder === 4){
img_path = //path to the default icon image
} else {
img_path = //path to the shuffle icon image
}
let img = gdi.Image(img_path)
gr.GdiDrawBitmap(img.CreateRawBitmap(), dstX, dstY, dstW, dstH, srcX, srcY, srcW, srcH)
}

If you are using font icon characters the principle is the same.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: LeVvE on 2021-01-21 18:55:40
That code worked to switch, thanks a lot.
I have to ask for more help though, sadly. I want to swap icon based on which order is active, how do I add that?

Well, you can use the plman.PlaybackOrder (https://theqwertiest.github.io/foo_spider_monkey_panel/assets/generated_files/docs/html/plman.html#.PlaybackOrder) property to write a conditional statement for that, too, much in the same way as above. To keep it simple, if you are using actual images:
Code: [Select]
function on_paint(gr){
let img_path;
if (plman.PlaybackOrder === 4){
img_path = //path to the default icon image
} else {
img_path = //path to the shuffle icon image
}
let img = gdi.Image(img_path)
gr.GdiDrawBitmap(img.CreateRawBitmap(), dstX, dstY, dstW, dstH, srcX, srcY, srcW, srcH)
}

If you are using font icon characters the principle is the same.

I think I'm too dumb for this, the current thing I use is this:
Code: [Select]
buttons.buttons.shuffle = new _button(2, 2, 32, 32, {normal : 'buttons\\Menu.png'}, (x, y) => { if (plman.PlaybackOrder === 4){ fb.RunMainMenuCommand("Playback/Order/Default"); } else { fb.RunMainMenuCommand("Playback/Order/Shuffle (tracks)"); } }, 'Shuffle');

Maybe I should just look for another skin that has this function and see how they did it because I can't figure this out. When I add the function I get image is null.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2021-01-21 20:07:04
I think I'm too dumb for this, the current thing I use is this:
Code: [Select]
buttons.buttons.shuffle = new _button(2, 2, 32, 32, {normal : 'buttons\\Menu.png'}, (x, y) => { if (plman.PlaybackOrder === 4){ fb.RunMainMenuCommand("Playback/Order/Default"); } else { fb.RunMainMenuCommand("Playback/Order/Shuffle (tracks)"); } }, 'Shuffle');

Maybe I should just look for another skin that has this function and see how they did it because I can't figure this out. When I add the function I get image is null.

I see, you're editing marc's script! I thought you were writing your own code. That makes it a little more complicated because you need to look at the code of at least three different scripts to understand where and how to edit (playback buttons, helpers and panel I think). I don't use it and I'm not familiar with it, but in that line of code you posted, the button image is likely passed by the fith argument of the _button() function, which is an object:
Code: [Select]
{normal : 'buttons\\Menu.png'}
So first of all you need to have the required image files in the buttons folder and than you could try replacing "menu" with a variable and assign that variable the appropriate value with the conditional statement I suggested in the previous post. You could write the conditional statement in the on_playback_order_changed() callback, for example. But really, I would need to have a better look at the scripts before suggesting anything.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: LeVvE on 2021-01-21 20:32:51
I think I'm too dumb for this, the current thing I use is this:
Code: [Select]
buttons.buttons.shuffle = new _button(2, 2, 32, 32, {normal : 'buttons\\Menu.png'}, (x, y) => { if (plman.PlaybackOrder === 4){ fb.RunMainMenuCommand("Playback/Order/Default"); } else { fb.RunMainMenuCommand("Playback/Order/Shuffle (tracks)"); } }, 'Shuffle');

Maybe I should just look for another skin that has this function and see how they did it because I can't figure this out. When I add the function I get image is null.

I see, you're editing marc's script! I thought you were writing your own code. That makes it a little more complicated because you need to look at the code of at least three different scripts to understand where and how to edit (playback buttons, helpers and panel I think). I don't use it and I'm not familiar with it, but in that line of code you posted, the button image is likely passed by the fith argument of the _button() function, which is an object:
Code: [Select]
{normal : 'buttons\\Menu.png'}
So first of all you need to have the required image files in the buttons folder and than you could try replacing "menu" with a variable and assign that variable the appropriate value with the conditional statement I suggested in the previous post. You could write the conditional statement in the on_playback_order_changed() callback, for example. But really, I would need to have a better look at the scripts before suggesting anything.
So you recommend I start from scratch instead?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2021-01-21 20:43:23
So you recommend I start from scratch instead?

I encourage anyone to write their own rather than hacking other people's scripts, unless they are fairly simple and straightforward standalone scripts. But good coders usually don't have standalone scripts, but more complex systems which are hard to edit without breaking something. Nevertheless, meanwhile I had a look at the scripts and something easy you could try is editing the line of code you posted as follows:

Code: [Select]
buttons.buttons.shuffle = new _button(2, 2, 32, 32, {normal : plman.PlaybackOrder === 4 ? 'buttons\\deafult.png' : 'buttons\\shuffle.png'}, (x, y) => { if (plman.PlaybackOrder === 4){ fb.RunMainMenuCommand("Playback/Order/Default"); } else { fb.RunMainMenuCommand("Playback/Order/Shuffle (tracks)"); } }, 'Shuffle');

Than add the following:
Code: [Select]
function on_playback_order_changed(){
buttons.update();
window.Repaint();
}

Of course this works if you have a "shuffle.png" and "default.png" file in the buttons folder.

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2021-01-21 21:06:12
P.S.
While we are at it, you can use the ternary operator ('?' and ':') for the conditional statement of the command as well:

Code: [Select]
buttons.buttons.shuffle = new _button(2, 2, 32, 32, {normal : plman.PlaybackOrder === 4 ? 'buttons\\deafult.png' : 'buttons\\shuffle.png'}, (x, y) => plman.PlaybackOrder === 4 ? fb.RunMainMenuCommand("Playback/Order/Default") : fb.RunMainMenuCommand("Playback/Order/Shuffle (tracks)"), 'shuffle');
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: LeVvE on 2021-01-22 00:37:57
P.S.
While we are at it, you can use the ternary operator ('?' and ':') for the conditional statement of the command as well:

Code: [Select]
buttons.buttons.shuffle = new _button(2, 2, 32, 32, {normal : plman.PlaybackOrder === 4 ? 'buttons\\deafult.png' : 'buttons\\shuffle.png'}, (x, y) => plman.PlaybackOrder === 4 ? fb.RunMainMenuCommand("Playback/Order/Default") : fb.RunMainMenuCommand("Playback/Order/Shuffle (tracks)"), 'shuffle');

Works just the way I want it, thanks for your help :)

This is how I made it look, top right corner, greyed out when not enabled: (https://i.imgur.com/z0yNpwn.png)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Black_Over_Bills_Mothers on 2021-01-24 11:43:49
@Qwertiest
I've added some info. on issue 'ActiveXObject error when dealing with exotic filename encodings #54' on github. Hope this helped. If you need further info. please let me know.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: fbuser on 2021-01-24 12:04:34
Check if the path ends with .cue or use title formatting for embedded cuesheets %__cue_embedded% equals yes
If cue is external (i.e. not embedded), you may also try checking FbMetadbHandle.SubSong, it seems to be above zero only when it's a multi-track file.
Not necessarily. If you are using mtags with one file for each track, the subsong index is always 1.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-01-24 19:31:23
How do you save a playlist to a path? I found nothing about that on the documentation only SavePlaylist() and using a main menu command I can not add the path.

Quote
But restoring the file becomes a problem. I can not find a way to move files from the bin to the original folder.  I use the Move method with this, something like this
Any help there would be appreciated too.

Thanks!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-01-26 12:19:54
How do you save a playlist to a path? I found nothing about that on the documentation only SavePlaylist() and using a main menu command I can not add the path.
marc2k3 just aded that functionality btw.

Quote
But restoring the file becomes a problem. I can not find a way to move files from the bin to the original folder.  I use the Move method with this, something like this
Any help there would be appreciated too.

Thanks!
Well just found the problem is the (physical) name gets changed by the SO after sending a file to the Recycle Bin, so "a.txt" is changed to "$K4354A.txt" or things like that, while the explorer displays the original (virtual) name. I have now to list all files on the bin and identify the one I deleted, will report if that works for restoring purposes.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-01-26 13:35:06
Also, is there some method to create a simple yes/no popupBox without using HTML?

popupBox(window_id, prompt, okString, cancelString)  -> return true/false

Obviously InputBox() could be used along try/catch to emulate that functionality but it looks weird (since the window expects a text input).

X
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-01-26 14:25:12
Well just found the problem is the (physical) name gets changed by the SO after sending a file to the Recycle Bin, so "a.txt" is changed to "$K4354A.txt" or things like that, while the explorer displays the original (virtual) name. I have now to list all files on the bin and identify the one I deleted, will report if that works for restoring purposes.
You can get original filename by using the following code:
Code: [Select]
let dir = app.NameSpace(10);
let items = dir.Items();

// Regretfully, `dir.Items()` is not enumerable, so it must be traversed manually
for (let i = 0; i < items.Count; ++i) {
   console.log(items.Item(i).Name); // original name
   console.log(items.Item(i).Path); // full path in recycle bin
}

How do you save a playlist to a path? I found nothing about that on the documentation only SavePlaylist() and using a main menu command I can not add the path.
Not sure I want to add this method, but I will put it on the maybe list in case I change my mind (it does happen =)).

Also, is there some method to create a simple yes/no popupBox without using HTML?
Not currently, but I'll see if it can be done.

@Qwertiest
I've added some info. on issue 'ActiveXObject error when dealing with exotic filename encodings #54' on github. Hope this helped. If you need further info. please let me know.
Thanks, I'll take a look.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-01-26 14:40:11
Simple popups are already possible and have been in my samples for years.

Code: [Select]
let WshShell = new ActiveXObject('WScript.Shell');

let popup = {
ok : 0,
yes_no : 4,
yes : 6,
no : 7,
stop : 16,
question : 32,
info : 64
};

let prompt = ...
let caption = ...

if (WshShell.Popup(prompt, 0, caption, popup.question + popup.yes_no) == popup.yes) {
//do something
}

edit: see here for other button combos I've not included

https://www.devguru.com/content/technologies/wsh/wshshell-popup.html
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-01-26 15:04:20
Yep I did the same and finally got it working.  Thanks :) For reference, if anyone needs to do the same (it's just an improvement to marc's helpers):

Code: [Select]
const fso = new ActiveXObject('Scripting.FileSystemObject');
const app = new ActiveXObject('Shell.Application');

function _isFile(file) {
return _.isString(file) ? fso.FileExists(file) : false;
}

function _isFolder(folder) {
return _.isString(folder) ? fso.FolderExists(folder) : false;
}

function _createFolder(folder) {
if (!_isFolder(folder)) {
try {
fso.CreateFolder(folder);
} catch (e) {
return false;
}
return _isFolder(folder);
}
return false;
}

function _deleteFile(file) {
if (_isFile(file)) {
try {
fso.DeleteFile(file);
} catch (e) {
return false;
}
return !(_isFile(file));
}
return false;
}

function _renameFile(file, newFilePath) {
if (!_isFile(newFilePath) {
if (_isFile(file)) {
try {
fso.MoveFile(file, newFilePath);
} catch (e) {
return false;
}
return _isFile(newFilePath);
}
return false;
}
return false;
}

function _recycleFile(file) {
if (_isFile(file)) {
try {
app.NameSpace(10).MoveHere(file);
} catch (e) {
return false;
}
return !(_isFile(file));
}
return false;
}

function _restoreFile(file) {
if (!_isFile(file)) {
const arr = utils.FileTest(file, "split");
const OriginalFileName = arr[1];
const items = app.NameSpace(10).Items();
const numItems = items.Count;
for (let i = 0; i < numItems; i++) {
if (items.Item(i).Name == OriginalFileName) {
_renameFile(items.Item(i).Path, file);
break;
}
}
let bFound = _isFile(file);
if (!bFound){console.log('_restoreFile(): Can not restore file, "' + OriginalFileName + '" was not found at the bin.');}
return bFound;
} else {
console.log('_restoreFile(): Can not restore file to "' + file + '" since there is already another file at the same path.');
return false;
}
}



Btw utils.FileTest() seems to have a bug.

Code: [Select]
let arr = utils.FileTest("D:\\Somedir\\Somefile.txt", "split")
// arr[1] <= "Somefile.txt" extension included (?)

Not sure if that's intended, but the documentation says otherwise:

Code: [Select]
let arr = utils.FileTest("D:\\Somedir\\Somefile.txt", "split");
// arr[0] <= "D:\\Somedir\\" (always includes backslash at the end)
// arr[1] <= "Somefile"
// arr[2] <= ".txt"

PD: For reference, if that behaviour get's fixed, then the scripts at top should reflect that change too.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-01-26 15:06:43
Simple popups are already possible and have been in my samples for years.

Code: [Select]
let WshShell = new ActiveXObject('WScript.Shell');

let popup = {
ok : 0,
yes_no : 4,
yes : 6,
no : 7,
stop : 16,
question : 32,
info : 64
};

let prompt = ...
let caption = ...

if (WshShell.Popup(prompt, 0, caption, popup.question + popup.yes_no) == popup.yes) {
//do something
}

edit: see here for other button combos I've not included

https://www.devguru.com/content/technologies/wsh/wshshell-popup.html

Oh that... yes. That's why I asked, I was sure I have been seeing them somewhere! I would prefer to not use ActiveXobjects but it's good enough. Thanks!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-01-26 15:20:01
I can see the bug with utils.FileTest here...

https://github.com/TheQwertiest/foo_spider_monkey_panel/blob/150e49cdc072762b1a6b6a90d7e5be1158bbba50/foo_spider_monkey_panel/js_objects/utils.cpp#L298

It should use stem(), not filename().
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-01-27 09:58:33
Finally got all working on the playlist manager, and managed to get playlist size (#tracks) by using m3u directives and/or counting lines if they are missing. But I have a limitation, I can easily read/write m3u, m3u8 files and create schemes for them but I have no way to read fpl files.

If I want to know the number of tracks from a fpl playlist, is there any other way other than loading the playlist within foobar, and using plman.PlaylistItemCount(index)t?
I mean, is there a way to bypass playlist loading into the UI? fpl -> Handle list

EDIT: since addLocations(playlistIndex, paths, selectopt)  is async and there is no other method to load a playlist, the mentioned method doesn't work since PlaylistItemCount returns 0 because the playlist loading is not done yet when called. And having in mind all this involves playlist being temporarily shown on the UI, I think I should avoid using promises for creating/count/deleting temp playlists.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-01-27 10:34:18
No.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-01-27 14:13:19
Another bug:

I have folder with these files:
Code: [Select]
c:\Users\XXX\AppData\Roaming\foobar2000\playlist_manager\Lucia Emotivas.fpl
c:\Users\XXX\AppData\Roaming\foobar2000\playlist_manager\Post-Britpop.m3u8
c:\Users\XXX\AppData\Roaming\foobar2000\playlist_manager\World.m3u

Code: [Select]
utils.Glob(folderPath + '*.m3u').concat(utils.Glob(folderPath + '*.m3u8')).concat(utils.Glob(folderPath + '*.fpl')).concat(utils.Glob(folderPath + '*.pls'));

On console, win 7, there are 4 files:
[15:11:36] ["C:\Users\XXX\AppData\Roaming\foobar2000\playlist_manager\Post-Britpop.m3u8", "C:\Users\XXX\AppData\Roaming\foobar2000\playlist_manager\World.m3u", "C:\Users\XXX\AppData\Roaming\foobar2000\playlist_manager\Post-Britpop.m3u8", "C:\Users\XXX\AppData\Roaming\foobar2000\playlist_manager\Lucia Emotivas.fpl"]

Same script on win 10: 3 files
Code: [Select]
[15:11:36] ["C:\Users\XXX\AppData\Roaming\foobar2000\playlist_manager\World.m3u", "C:\Users\XXX\AppData\Roaming\foobar2000\playlist_manager\Post-Britpop.m3u8", "C:\Users\XXX\AppData\Roaming\foobar2000\playlist_manager\Lucia Emotivas.fpl"]

utils.Glob(folderPath + '*.m3u') matches '*.m3u8' too on win 7.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-01-27 14:45:16
Seems like its not a component bug but a windows API issue.

But you can just use *.* and filter by extension yourself.

Code: [Select]
const allowed = ["m3u", "m3u8", "pls", "fpl"];
let files = utils.Glob("z:\\*.*").filter((item) => {
return allowed.includes(item.split('.').pop().toLowerCase());
});
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-01-27 15:45:29
Yep, I did something similar.
@TheQwertiest  Also check PathWildcardMatch(), since being a bug with the API it probably has the same behavior. If you need testing on win 7 just let me know, I use both.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MachineHead on 2021-01-27 18:50:55
Not sure if this has been brought up, but can very old WSH scripts be updated to work in SMP? This one in particular has probably never been updated from its original release there. (https://www.deviantart.com/br3tt/art/WSH-CoverFlow-290788027) Happened to stumble across it in an old config I had tucked away and thought I'd ask.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel) - Knops
Post by: 2tec on 2021-01-30 20:10:44
There's some knobs, some with javascript, hosted on this site ~ https://codepen.io/tag/knob/

implementing one's a little beyond me at this point, perhaps someone with more know how will find this useful
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MojoBass on 2021-01-31 05:48:23
Not sure if this has been brought up, but can very old WSH scripts be updated to work in SMP? This one in particular has probably never been updated from its original release there. (https://www.deviantart.com/br3tt/art/WSH-CoverFlow-290788027) Happened to stumble across it in an old config I had tucked away and thought I'd ask.
Guess your linked WSH Coverflow is the basis for this (https://hydrogenaud.io/index.php?topic=110516.msg985835#msg985835) script running well in my config within JScript Panel 2.5.2 from marc2k3/ @snotlicker . Not really maintained by anybody, but there is still some helping hand from @snotlicker or @MordredKLB (Thanks!!)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-01-31 08:05:49
No one ever reads anything do they?

https://theqwertiest.github.io/foo_spider_monkey_panel/docs/guides/jsp_to_smp_migration_guide/
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MachineHead on 2021-01-31 19:03:26
*snip*
Thanks for that. Works great.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-02-01 12:20:24
Code: [Select]
			// Doesn't work
arr.push({
'REPLAYGAIN_ALBUM_GAIN' : '',
'REPLAYGAIN_ALBUM_PEAK' : '',
'REPLAYGAIN_TRACK_GAIN' : '',
'REPLAYGAIN_TRACK_PEAK' : ''
});
sel_items.UpdateFileInfoFromJSON(JSON.stringify(arr));
// Works
fb.RunContextCommandWithMetadb("ReplayGain/Remove ReplayGain information from files", sel_items, 8);

Why UpdateFileInfoFromJSON is not able to clear ReplayGain tags?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-02-01 13:43:33
Can you edit replaygain values from the Metadata tab of the Properties dialog? There's your answer.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-02-01 16:50:42
So it's a foobar's limit. Yep masstagger has the same limit too.
Had no idea it was so hardcoded, I thought it was just a soft limit to force users to use the proper UI. Makes no sense to me to block it on scripts/components too, but thanks! Will use the component menu.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-02-01 17:51:09
I'm pretty sure the SDK exposes other ways to manipulate RG values, just not the method used for updating normal tags.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Emerelle on 2021-02-02 08:37:34
I am using the script Album Art. I wonder if it is possible to set it to autorefresh on folder change?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-02 13:14:02
Simple popups are already possible and have been in my samples for years.
I knew I've seen it somewhere!
it's being too long since I've last coded anything non-trivial on SMP/JSP...

I can see the bug with utils.FileTest here...

https://github.com/TheQwertiest/foo_spider_monkey_panel/blob/150e49cdc072762b1a6b6a90d7e5be1158bbba50/foo_spider_monkey_panel/js_objects/utils.cpp#L298

It should use stem(), not filename().
Thanks!

utils.Glob(folderPath + '*.m3u') matches '*.m3u8' too on win 7.
Yep, as Marc have said, it's a WinAPI bug (*sigh*): https://stackoverflow.com/a/44933735
That said, I'll see if I can reimplement this method to avoid this.

Also check PathWildcardMatch()
PathWildcardMatch (reportedly) does not have such a bug.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-02-03 15:38:26
One more question, maybe I'm missing something. Is there some way to have a "on_mouse_lbtn_dblclk(x, y)"  and "on_mouse_lbtn_up(x, y)"  at the same time for the same item?
For ex: I have this UI, if I click lbtn then it shows a contextual menu. If I try to double click, I want it to load the playlist.
As workaround, I have used a modifier key and it's good enough for me. But wanted to know anyway.

EDIT: nevermind. I see I can use setTimeout() to delay the contextual menu and then it works. But double clicking will not cancel its the execution of the delayed function so...
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-03 16:09:18
One more question, maybe I'm missing something. Is there some way to have a "on_mouse_lbtn_dblclk(x, y)"  and "on_mouse_lbtn_up(x, y)"  at the same time for the same item?
For ex: I have this UI, if I click lbtn then it shows a contextual menu. If I try to double click, I want it to load the playlist.
As workaround, I have used a modifier key and it's good enough for me. But wanted to know anyway.

EDIT: nevermind. I see I can use setTimeout() to delay the contextual menu and then it works. But double clicking will not cancel its the execution of the delayed function so...
That's just the way SMP/JSP/WSH work: double click produces the following events:
Code: [Select]
on_mouse_lbtn_down
on_mouse_lbtn_up
on_mouse_lbtn_dblclk
on_mouse_lbtn_up

So yeah, you have to take in account all the possible scenarios (if you want to handle both click and double click) . For example, you can store `is_mouse_down` and `was_double_clicked` states (e.g. https://github.com/TheQwertiest/CaTRoX_QWR/blob/61eecfa4159e3714d58f53ae942d5f1861e83fb2/theme/Scripts/Control_List.js#L230).
[EDIT]: See the post below.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-03 16:25:27
Oh, I think I've misunderstood what you are trying to achieve.
Your scenario is impossible to implement properly (i.e. without delays), since to know if the event is click or a double-click one must know the future =)
That's why 99% of the time single-click invokes an action that is a part of a double-click action or at the very least does not contradict a double-click action. E.g. click - `Select`, dblclick - `Execute the selected item`; click - `Select the whole string`, dblclick - `Select only one word from the string`.

IMO, you should rework your scenario and remove the context menu from the click action.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-02-03 17:23:26
Oh, I think I've misunderstood what you are trying to achieve.
Your scenario is impossible to implement properly (i.e. without delays), since to know if the event is click or a double-click one must know the future =)
That's why 99% of the time single-click invokes an action that is a part of a double-click action or at the very least does not contradict a double-click action. E.g. click - `Select`, dblclick - `Execute the selected item`; click - `Select the whole string`, dblclick - `Select only one word from the string`.

IMO, you should rework your scenario and remove the context menu from the click action.
Yep, was that.
I have managed to do it though, with delays...
Code: [Select]
	this.lbtn_up = (x, y) => { // on_mouse_lbtn_up(x, y)
...
if (!this.bDoubleclick) { // it's not a second lbtn click
this.timeOut = this.delayedEdit(x,y, undefined, this.index);
} else {this.bDoubleclick = false;}
...
}
this.lbtn_dblclk = (x, y) => { // Called by on_mouse_lbtn_dblclk(x, y)
clearTimeout(this.timeOut);
this.timeOut = null;
this.bDoubleclick = true;
...doyourthing
}
this.edit = (x, y, menuIdx = null, forcedIndex = null) => { // use index from on_mouse_move(x, y), so you have to forceIndex from first call
...doyourthing
}
this.delayedEdit = delayFn(this.edit, 100);
this.timeOut = null;
this.bDoubleclick = false;

on helpers
Code: [Select]
const delayFn = (func, ms) => {
return (...args) => {return setTimeout(func.bind(this, ...args), ms);}
}

I have to pass the index to this.edit() because the mouse may move after clicking once and select another thing different to the original one which fired the contextual menu, but it works flawless now.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Black_Over_Bills_Mothers on 2021-02-04 22:35:29
Just downloaded the nightly build (@22:30 GMT). On restart of foobar I see the following a stack of many popup windows all with the same message:
WinAPI error:
  IIDFromString failed with error (0x80070057):
    The parameter is incorrect.

This also appears in the console. Unable to use foobar at this point. I have resorted to a previous nightly build and all is okay. I have lost WilB's library tree and biography panel contents, properties but I've managed to recover 90%.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-02-04 22:49:37
More questions. I got a panel like this, with drag n drop enabled.
X

I have 2 use cases:
- "Moving" tracks to a playlist item at the panel.
Quote
(Spider Monkey Panel specific) All mouse callbacks are suppressed during drag operation (including on_mouse_lbtn_up, but excluding on_mouse_mbtn_up and on_mouse_rbtn_up).
But according to the documentation, I can not track the mouse movement within the panel (?) to check the index the mouse is over. So judging the dragndrop sample  I should use on_drag_enter() , etc. with the same functions I already have at on_mouse_move(x, y) to check the index I'm over, and then link that index to the handles I drop. Right?

--  "Moving" files to the panel (which is linked to a folder). I'm talking about the physical playlist file here.
As far as I have seen, all the drag n drop functions expect at some point handles... and moving a file within foobar treats it automatically as a track, or a collection of tracks if it's a playlist. Is there some way to get the actual playlist file path (and not its tracks) when using drag n drop? i.e. make no assumption about what the files are, and just get their path.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: zeremy on 2021-02-05 09:49:32
This script works in JSP , but not in SMP.

Code: [Select]
var xml = '<person><name>John Doe</name></person>';

var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.loadXML(xml);

var data = xmlDoc.getElementsByTagName('name');
console.log(data[0].childNodes[0].nodeValue);


Any ideas why ??
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-05 12:19:28
Just downloaded the nightly build (@22:30 GMT). On restart of foobar I see the following a stack of many popup windows all with the same message:
WinAPI error:
  IIDFromString failed with error (0x80070057):
    The parameter is incorrect.

This also appears in the console. Unable to use foobar at this point. I have resorted to a previous nightly build and all is okay. I have lost WilB's library tree and biography panel contents, properties but I've managed to recover 90%.
Darn, I'm sorry for these problems. I'll fix it ASAP.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-05 13:10:21
@Black_Over_Bills_Mothers , could you paste the version of the working nightly?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Black_Over_Bills_Mothers on 2021-02-05 13:50:44
This the latest working version:
Spider Monkey Panel v1.3.2-beta+5e1f7be3 by TheQwertiest
Based on JScript Panel by marc2003
Based on WSH Panel Mod by T.P. Wang

Build: 00:22:51, Feb  4 2021
Columns UI SDK Version: 6.5
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-05 14:41:47
<snip>
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-05 19:15:47
- "Moving" tracks to a playlist item at the panel.
Quote
(Spider Monkey Panel specific) All mouse callbacks are suppressed during drag operation (including on_mouse_lbtn_up, but excluding on_mouse_mbtn_up and on_mouse_rbtn_up).
But according to the documentation, I can not track the mouse movement within the panel (?) to check the index the mouse is over. So judging the dragndrop sample  I should use on_drag_enter() , etc. with the same functions I already have at on_mouse_move(x, y) to check the index I'm over, and then link that index to the handles I drop. Right?
Yes, on_mouse_move is replaced with on_drag_over.

--  "Moving" files to the panel (which is linked to a folder). I'm talking about the physical playlist file here.
As far as I have seen, all the drag n drop functions expect at some point handles... and moving a file within foobar treats it automatically as a track, or a collection of tracks if it's a playlist. Is there some way to get the actual playlist file path (and not its tracks) when using drag n drop? i.e. make no assumption about what the files are, and just get their path.
Noted, but I don't think this will be implemented in this release.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Black_Over_Bills_Mothers on 2021-02-05 20:14:03
@Qwertiest
Not sure if this helps you but I've tried the nightly build:
Spider Monkey Panel v1.3.2-beta+dd28ed6b by TheQwertiest
Based on JScript Panel by marc2003
Based on WSH Panel Mod by T.P. Wang

Build: 19:12:53, Feb  5 2021
Columns UI SDK Version: 6.5

And all working fine.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-05 20:20:01
This the latest working version:
Spider Monkey Panel v1.3.2-beta+5e1f7be3 by TheQwertiest
Based on JScript Panel by marc2003
Based on WSH Panel Mod by T.P. Wang

Build: 00:22:51, Feb  4 2021
Columns UI SDK Version: 6.5
Should be fixed in the latest nightly.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Black_Over_Bills_Mothers on 2021-02-05 20:25:51
Thank you so much.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-06 14:00:33
This script works in JSP , but not in SMP.

Any ideas why ??
Because of the subpar subscript handling =)
Almost every interaction with COM objects (aka `ActiveXObject` in JS interface) has to be implemented in SMP manually... This is not a problem for JSP and WSH, since their implementation is actually based on COM objects.
Should be fixed in nightly.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-02-06 19:21:26
- "Moving" tracks to a playlist item at the panel.
Quote
(Spider Monkey Panel specific) All mouse callbacks are suppressed during drag operation (including on_mouse_lbtn_up, but excluding on_mouse_mbtn_up and on_mouse_rbtn_up).
But according to the documentation, I can not track the mouse movement within the panel (?) to check the index the mouse is over. So judging the dragndrop sample  I should use on_drag_enter() , etc. with the same functions I already have at on_mouse_move(x, y) to check the index I'm over, and then link that index to the handles I drop. Right?
Yes, on_mouse_move is replaced with on_drag_over.
Well I looked at it again and maybe I miss something but that part can not be done too. The drag n drop sample just redirects the action to another playlist by Id.
I can drop tracks to a playlist already loaded since I can assign its Id to the action (b), but I can not simply get the handle list of the drag n drop action without sending it to a playlist (a).

a) My workflow is: drop -> handle list -> get paths of tracks -> save paths into .m3u8 file
b) For a playlist already loaded:   drop -> playlist -> autosave paths to linked  .m3u8 playlist file
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-06 19:40:07
The drag n drop sample just redirects the action to another playlist by Id.
Yes, it does (unless you block it by changing `Effect` to `DROPEFFECT_NONE`).

can not simply get the handle list of the drag n drop action without sending it to a playlist
Yes, you can't.

As I've said in the previous post, your feature request is acknowledged and will be implemented sometime in the future (i.e. it's a totally valid use-case and not a niche feature).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Black_Over_Bills_Mothers on 2021-02-06 23:16:53
@The Qwertiest
Using nightly build:
Spider Monkey Panel v1.3.2-beta+01dd8c13 by TheQwertiest
Based on JScript Panel by marc2003
Based on WSH Panel Mod by T.P. Wang
Build: 22:04:47, Feb  6 2021
Columns UI SDK Version: 6.5

I get popup windows and WilB's Biography script script (v1.1.3) crashes. The error given is:
WinAPI error:
  GetTypeInfo failed with error (0x80070005):
    Access is denied.

File: <main>
Line: 29, Column: 42
Stack trace:
  htmlParse@<main>:29:42
  Lfm_top_albums/this.Analyse@<main>:1158:5
  Lfm_top_albums/this.on_state_change@<main>:1148:154
  Panel/this.get_multi/getTopAlb<@<main>:888:83
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Black_Over_Bills_Mothers on 2021-02-07 08:36:31
@TheQwertiest
Just updated to foobar2000 1.6.4 (from early beta) and all working with SMP latest nightly.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Black_Over_Bills_Mothers on 2021-02-07 09:01:11
@TheQwertyiest
Oops! Spoke too soon. Script  still crashing but a lot less often. Previously it was always at startup. Now it can be several minutes usage - but always after a band/artist change and always the Biography script.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-02-07 09:08:43
It happens when parsing the html for a webpage it doesn't already have a cached file for. I've not looked at that bio script but I can reproduce with this...

Code: [Select]
var doc = new ActiveXObject('htmlfile');

function _getElementsByTagName(value, tag) {
doc.open();
var div = doc.createElement('div');
div.innerHTML = value;
var data = div.getElementsByTagName(tag);
doc.close();
return data;
}

var html = "<html><div class=\"text\"><p>blah</p></div></html>";
var divs = _getElementsByTagName(html, "div");
console.log(divs.length) // 1, OK


While the above function seems to create an array as expected, any attempt to access any element fails...

Code: [Select]
if (divs[0].className == "text") console.log(divs[0].innerText);

//or

console.log(typeof divs[0]);


Code: [Select]
WinAPI error:
  GetTypeInfo failed with error (0x80070005):
    Access is denied.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kode54 on 2021-02-07 09:17:43
This component supports ActiveX?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-02-07 09:31:10
Yep. Currently there is no other way to manage files/folders, access the internet etc. I guess it could all be implemented via SDK helpers/WinAPI but it would be even more effort than mangling ActiveX support in. Obviously it's all way over my head.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-07 11:25:10
I get popup windows and WilB's Biography script script (v1.1.3) crashes. The error given is:
Thankfully it's not a new bug =)
It was actually failing even in previous SMP builds, but it was failing silently (which I've finally managed to fix in the latest nightly).
The core problem is the one reported by marc.

While the above function seems to create an array as expected
Thanks for the minimal repro sample!
It should be noted though, that it's not an array, but an ActiveXObject that tries to behave as an array =)
E.g. `console.log(divs)` will print `ActiveXObject`.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-07 14:04:10
It also means that html parsing in SMP version of Biography script is not working at all.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: tomaasz on 2021-02-07 14:05:38
Hi, I'm noob ...
Could you send me any link where I could see how to implement JS in foobar ?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-07 14:55:32
It also means that html parsing in SMP version of Biography script is not working at all.
Okay, I was totally wrong :D
`ActiveXObject` subscript handling is just WAAAAAAAAAAAAAAY weirder than I've imagined.
Everything should be working now (once the new build is done).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Black_Over_Bills_Mothers on 2021-02-07 16:03:06
Confirmed. All working without errors using:

Spider Monkey Panel v1.3.2-beta+718c0702 by TheQwertiest
Based on JScript Panel by marc2003
Based on WSH Panel Mod by T.P. Wang

Build: 15:12:55, Feb  7 2021
Columns UI SDK Version: 6.5
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2021-02-08 19:11:50
There is an inconsistency between the GdiGraphics DrawLine() and FillSolidRect() methods, or at least it looks like an inconsistency to me.  If I write the following code, the line looks 1 pixel longer than the rectangle:
Code: [Select]
include(fb.ComponentPath + "docs\\helpers.js");

function on_paint(gr){
    let x = 50;
    let y = 100;
    let w = 300;
    let h = 100;
    gr.FillSolidRect(x, y, w, h, colours.LightGray);
    gr.DrawLine(x, y, x + w, y, 1, colours.Black)
}

This only happens when the line is 1 pixel thick. Thicker lines perfectly patch the rectangle side of the same nominal length.
Does this have a purpose? or am I overlooking something?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-02-08 20:14:46
xywh are passed along untouched so any issues you have with the component would be apparent in pure C++ too. Address any complaints to Microsoft.

Just draw 2 rectangles to ensure consistency.

Code: [Select]
gr.FillSolidRect(x, y, w, h, colours.LightGray);
gr.FillSolidRect(x, y, w, 1, colours.Black)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-02-09 01:33:39
The drag n drop sample just redirects the action to another playlist by Id.
Yes, it does (unless you block it by changing `Effect` to `DROPEFFECT_NONE`).

can not simply get the handle list of the drag n drop action without sending it to a playlist
Yes, you can't.

As I've said in the previous post, your feature request is acknowledged and will be implemented sometime in the future (i.e. it's a totally valid use-case and not a niche feature).
My first request was about getting paths of arbitrary objects (path of a playlist file for ex.), not getting the handle list of the tracks (I thought this was already possible). But good to know. Thanks!

By the way,
Quote
How do you save a playlist to a path? I found nothing about that on the documentation only SavePlaylist() and using a main menu command I can not add the path.

Quote
Not sure I want to add this method, but I will put it on the maybe list in case I change my mind (it does happen =)).
And hope you reconsider this one. Along getting the handle of an fpl playlist without loading it first.

Have noticed playlist are really slow to load as m3u8 files while working on the playlist manager, which means it loses its use for big playlists. It can easily take a minute for +1000 tracks when loading them, while loading the same fpl playlist it's a matter of seconds. There is no workaround for fpl playlists for auto-saving except forcing the user to manually save the playlist to fpl every time. Or converting the playlist to m3u8 (what I did) and then taking the speed penalty. It really seems strange to me to create a playlist manager which greatly simplifies management of offline playlist within foobar but having no full support for its native format.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-02-10 08:57:17
Latest nightly seems to have changed the behavior of utils.FileTest for folders. Before I could check for the existence of a folder by doing utils.FileTest(path, 'd') and it would return false if the path did not exist. Now it crashes if path does not exist with "Path does not point to a valid location". Had to alter all my checks for folder existence need to be utils.FileTest(path, 'e') && utils.FileTest(path, 'd'). Not a huge deal, but might trip some people up.

Unfortunately for me I was redoing some of my folder paths at the exact same time I upgraded so I spent an hour banging my head against the wall thinking I'd screwed up the new paths somehow haha.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-02-10 09:10:31
Latest nightly seems to have changed the behavior of utils.FileTest for folders. Before I could check for the existence of a folder by doing utils.FileTest(path, 'd') and it would return false if the path did not exist. Now it crashes if path does not exist with "Path does not point to a valid location". Had to alter all my checks for folder existence need to be utils.FileTest(path, 'e') && utils.FileTest(path, 'd'). Not a huge deal, but might trip some people up.

Unfortunately for me I was redoing some of my folder paths at the exact same time I upgraded so I spent an hour banging my head against the wall thinking I'd screwed up the new paths somehow haha.
Yep, this:
https://github.com/TheQwertiest/foo_spider_monkey_panel/commit/718c07024a842ef137eef2b1d91976805944c3a5
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-02-10 09:11:14
On a related note, I'm trying to find a way to get all the subfolders of a folder. Seems like fso is the way to go.

fso.GetFolder(path) works fine, and .SubFolders appears to be a valid property (and should be a collection of Folders objects) but once I've got that, I can't figure out how to parse those into names/paths. fso.GetFolder(path).SubFolders doesn't work with any array methods, and fso.GetFolder(path).SubFolders.toString()  gives me an invalid number of parameters error. Anyone know how this can work?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: zeremy on 2021-02-10 09:27:43
On a related note, I'm trying to find a way to get all the subfolders of a folder. Seems like fso is the way to go.

fso.GetFolder(path) works fine, and .SubFolders appears to be a valid property (and should be a collection of Folders objects) but once I've got that, I can't figure out how to parse those into names/paths. fso.GetFolder(path).SubFolders doesn't work with any array methods, and fso.GetFolder(path).SubFolders.toString()  gives me an invalid number of parameters error. Anyone know how this can work?

Relative implementation
https://github.com/smoralis/footuner/blob/af0026910091e77f3e18e59a25411054936760aa/profile/themes/footuner/js/recorder.js#L211


Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-02-10 15:33:26
Relative implementation
https://github.com/smoralis/footuner/blob/af0026910091e77f3e18e59a25411054936760aa/profile/themes/footuner/js/recorder.js#L211
That worked. Thanks so much! I would have never figured that out on my own.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-10 21:57:46
Latest nightly seems to have changed the behavior of utils.FileTest for folders.
Should be fixed in the latest nightly.

On a related note, I'm trying to find a way to get all the subfolders of a folder. Seems like fso is the way to go.
Relative implementation
https://github.com/smoralis/footuner/blob/af0026910091e77f3e18e59a25411054936760aa/profile/themes/footuner/js/recorder.js#L211

I've added `iterator` support to iterable ActiveXObjects. Now you can write it like this:
Code: [Select]
for (let f of p.SubFolders) {
  DoSmth(f);
}
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-02-10 22:01:48
On a related note, I'm trying to find a way to get all the subfolders of a folder. Seems like fso is the way to go.

fso.GetFolder(path) works fine, and .SubFolders appears to be a valid property (and should be a collection of Folders objects) but once I've got that, I can't figure out how to parse those into names/paths. fso.GetFolder(path).SubFolders doesn't work with any array methods, and fso.GetFolder(path).SubFolders.toString()  gives me an invalid number of parameters error. Anyone know how this can work?

And there you got another way:

https://docs.microsoft.com/en-us/windows/win32/shell/folderitem-isfolder
Code: [Select]
const app = new ActiveXObject('Shell.Application');
const items = app.NameSpace(path).Items();
const numItems = items.Count;
for (let i = 0; i < numItems; i++) {
    if (items.Item(i).IsFolder){
        console.log(items.Item(i).Path);
    }
}

You can also filter the items with flags
https://docs.microsoft.com/en-us/windows/win32/shell/folderitems3-filter
https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_shcontf
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-10 23:50:21
Code: [Select]
const app = new ActiveXObject('Shell.Application');
const items = app.NameSpace(path).Items();
const numItems = items.Count;
for (let i = 0; i < numItems; i++) {
    if (items.Item(i).IsFolder){
        console.log(items.Item(i).Path);
    }
}

Funnily enough, `app.NameSpace(path).Items()` is not iterable, even though it's subscriptable... Gotta love those WinAPI interfaces...
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-02-11 04:28:52
Should be fixed in the latest nightly.
Verified. Wasn't a big deal for me since I was always using a IsFolder() helper method so it was a one line fix, but this is still simpler.

Quote
I've added `iterator` support to iterable ActiveXObjects. Now you can write it like this:
Code: [Select]
for (let f of p.SubFolders) {
  DoSmth(f);
}
Much cleaner. Thanks so much!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Black_Over_Bills_Mothers on 2021-02-11 13:23:54
I'm experimenting with getters and setters in classes. The following code crashes foobar (crash reports submitted). What am I doing wrong?
class _procNewFiles{
    constructor() {
        this.state = -1;
        this.myHandles;
        this.folders = [];
    }
    get state() {
        return this.state;
    }
    set state(v) {
        this.state = v;
    }
}
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-11 13:48:09
I'm experimenting with getters and setters in classes. The following code crashes foobar (crash reports submitted). What am I doing wrong?
What version of SMP are you using?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Black_Over_Bills_Mothers on 2021-02-11 14:00:54
Spider Monkey Panel v1.3.2-beta+718c0702 by TheQwertiest
Based on JScript Panel by marc2003
Based on WSH Panel Mod by T.P. Wang

Build: 15:12:55, Feb  7 2021
Columns UI SDK Version: 6.5
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-11 14:04:32
Spider Monkey Panel v1.3.2-beta+718c0702 by TheQwertiest
Based on JScript Panel by marc2003
Based on WSH Panel Mod by T.P. Wang

Build: 15:12:55, Feb  7 2021
Columns UI SDK Version: 6.5
Can you pm me a crash dump? (latest .dmp file from `foobar2000/crash reports`)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-11 14:23:24
I'm experimenting with getters and setters in classes. The following code crashes foobar (crash reports submitted). What am I doing wrong?
class _procNewFiles{
    constructor() {
        this.state = -1;
        this.myHandles;
        this.folders = [];
    }
    get state() {
        return this.state;
    }
    set state(v) {
        this.state = v;
    }
}
Also, are you sure that this is the whole script that you are executing? And not just a part of it?
I need the full script if I want to repro the crash.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Black_Over_Bills_Mothers on 2021-02-11 14:43:35
Also, are you sure that this is the whole script that you are executing? And not just a part of it?
I need the full script if I want to repro the crash.

I've PMed you a link.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2021-02-11 14:59:58
I'm experimenting with getters and setters in classes. The following code crashes foobar (crash reports submitted). What am I doing wrong?
class _procNewFiles{
    constructor() {
        this.state = -1;
        this.myHandles;
        this.folders = [];
    }
    get state() {
        return this.state;
    }
    set state(v) {
        this.state = v;
    }
}

Not an expert here, but I think the problem is that the getter and setter can not have the same name as the property they read and write.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Black_Over_Bills_Mothers on 2021-02-11 15:16:40
I'm experimenting with getters and setters in classes. The following code crashes foobar (crash reports submitted). What am I doing wrong?
class _procNewFiles{
    constructor() {
        this.state = -1;
        this.myHandles;
        this.folders = [];
    }
    get state() {
        return this.state;
    }
    set state(v) {
        this.state = v;
    }
}

Not an expert here, but I think the problem is that the getter and setter can not have the same name as the property they read and write.

Hey. That fixed it. Many thanks. I'm sure TheQwertiest will fix the crash though. I would have thought MS Code would flag it as an error but it didn't.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-02-11 16:22:00
I'm experimenting with getters and setters in classes. The following code crashes foobar (crash reports submitted). What am I doing wrong?
class _procNewFiles{
    constructor() {
        this.state = -1;
        this.myHandles;
        this.folders = [];
    }
    get state() {
        return this.state;
    }
    set state(v) {
        this.state = v;
    }
}

Not an expert here, but I think the problem is that the getter and setter can not have the same name as the property they read and write.
There's nothing illegal about having the getter/setter return the same property... it's just almost always not what you intend to do unless you're doing something fancy and intentional like lazy getters, etc.

As written, his getter would return the function (or possibly the constructor has overwritten the getter? I probably should know this), and his setter would overwrite the getter if it still exists.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-02-11 16:59:33
Just a question, I have not checked your latest changes on the properties panel so I don't know if it's relevant.

Quote
-Properties descriptions change according to things set on the panel, not just the values. i.e. if you change the sort method using the contextual menu, then the description on the panel reflects the associated states dynamically.
[attach type=image]18981[/attach] IMAGE HERE -> https://hydrogenaud.io/index.php?topic=120394.msg993688#msg993688
What about an on_properties_panel_change(name) callback? That way we could recreate the descriptions (and add allowed values) on the fly.

Right now I have managed 2 use-cases:
-User sets property A using contextual menu. -> old Property B gets removed. -> Property B gets rewritten and set according to A. Example:
A: Sorting method: by Size -> B: Asc or Desc: Asc
=> A: Sorting method: by Name -> B: Az or Za: Az

-Main script has property A with empty value -> On init, checks if A is empty. -> old Property A gets removed.  -> A secondary file loads a list of values and sets the default one to property A. Description changed accordingly too. - > Property B set according to A, ...
Example:
A: Sorting method. (Allowed by): ''  -> A: Sorting method. (Allowed by Name, by Size): size  ->  B: Asc or Desc


Both require removing old properties and setting new ones. But that only works because I previously know all values.

If the user edits the properties panel directly, on first use case this is what happens:
-User sets property A using contextual menu. -> Nothing is removed because it was not empty -> Property B gets automatically rewritten according to A and set.

So I get 2 times the "same" property B but with different descriptions.
X

Since I don't know the description of the old property B because A has already changed, I can not do anything about it. A callback with the description of the property changed would solve that. I would get A description and then get the associated B description and remove it. And I'm sure the callback would be useful for other uses.

Another possibilities/solutions would be:
- Function to clear all properties. That way, if the panel changes, I can simply recreate all new properties at once (not having to care about what's old and what's new.
-Being able to iterate all properties of a window.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2021-02-11 17:01:20
There's nothing illegal about having the getter/setter return the same property...

That's not what I wrote, though. The getter and the setter can return the same property, of course, but they cannot return themselves.


EDIT: I just googled "lazy getters", didn't know about this pattern.  I see what you mean now.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-11 17:25:33
I'm experimenting with getters and setters in classes. The following code crashes foobar (crash reports submitted). What am I doing wrong?
Fixed component crash in the nightly (once it's built), now it will crash JS instead =)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-11 17:30:45
What about an on_properties_panel_change(name) callback?
This one won't be implemented: panel properties can only be changed by the SMP user and can't be changed by the SMP itself, so it makes no sense to make such callback.

- Function to clear all properties. That way, if the panel changes, I can simply recreate all new properties at once (not having to care about what's old and what's new.
-Being able to iterate all properties of a window.
These could be implemented via properties_v2 that I've mention before (when it's done).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-11 19:21:11
Version: 1.4.0
Link: https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/tag/v1.4.0
Changelog:
Spoiler (click to show/hide)
Detailed description of API changes: https://theqwertiest.github.io/foo_spider_monkey_panel/docs/script_documentation/api_changes/#v140
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-02-12 05:36:31
Been playing around with 1.4 and it seems pretty solid. No issues on my end. Great work!

In looking at the new packages feature, and it's very interesting, but I'm wondering whether it's worth it to switch over to this distribution method. Right now users of my theme just download my repo and extract it to a specific folder (which occasionally causes issues because people can't find the profile folder). When they want to upgrade they just do the same thing and overwrite the existing files which seems to be working pretty well. At initial install they have to copy a 1-liner include command which includes a loader.js file which then does all the including of all the other .js files, etc., but then they never have to touch the config screen again.

Presumably creating a package will essentially just perform the same function? It would just change where the files would need to be extracted, right? My only external assets that aren't created by the theme itself are in an /images folder so they're already segregated from the rest of the code.

Are there other benefits that I'm missing?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-02-12 11:01:45
First "bug": Properties tab, clicking clear and then apply does not refresh the list as it always did. The same for deleting.

Also, changing the panel name when already using DefinePanel() inside the script does nothing.  DefinePanel() takes priority and change gets reverted.
But using DefineScript() at the same place, the panel name set at configure takes priority. Is that intended?

Looks good so far! Thanks! Specially love the in memory/ from file setting. I was so tired of having to re-import the main script to load the last changes if they were on the main file.

Quote
Are there other benefits that I'm missing?
As far as I have seen, the paths are relative. So you can include tons of files without overwriting others. Your theme for example is a single modification intended to be use standalone, but if you use different scripts it's easy to see file conflicts.

For ex. when I release the graph scripts, buttons framework and the playlist manager, all of them use the same helpers. Whenever I update one of them I will have to update the entire list of files for every other release, otherwise I will have "graph scripts" expecting a version of X helper different to "playlist manager scripts". Note your users just have scrip Theme v x or Theme v Y, so upgrading means replacing X with Y and done. Other use cases involve people having script A vx and Script B vy.... and upgrading Script B should not mean replacing files from A too. But that happens right now if you use the same filenames in both releases.

In a package, I would simply put my new changes in the new package and other packages would work with its own version of the 'same' files. It can be done changing manually names on include() but this greatly speeds up  the thing. Most game mods work similar, they are added using relative files path.

It seems that in the same spirit than "mods", the package has a description, etc. So you can explain a bit what the thing does without expecting the user will read a comment in the js file or a readme.txt.

X

Have no idea if there are more benefits.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kutuzof on 2021-02-12 11:17:40
If the "foo_wave_seekbar" component is installed, then when editing scripts directly in the panels themselves, the player crashes. This has been the case in recent JS releases
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-02-12 11:52:20
Assuming it's the same bug as I had, ListBoxX_ClassName needs updating to something unique.

https://github.com/TheQwertiest/scintilla/blob/f8817063200055b8b9f7b9a7a83c30100f64c903/win32/PlatWin.cxx#L2533
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-12 12:17:11
Are there other benefits that I'm missing?
Well, off the top of my head:
- Package is installed and unpacked automatically either via `Import` button or just by drug-n-dropping. So users don't need to know the "correct" location (or the correct folder structure).
- Packages has persistent id, meaning that the path to package content is always persistent and can be relied upon (e.g. by other packages).
- User can easily switch between packages in a single panel without needing to copy-paste script content anywhere.
- Same package can be reused in multiple panels (again, without needing to copy-paste script content).

First "bug": Properties tab, clicking clear and then apply does not refresh the list as it always did. The same for deleting.
I'll look into it, thanks.

Also, changing the panel name when already using DefinePanel() inside the script does nothing.  DefinePanel() takes priority and change gets reverted.
But using DefineScript() at the same place, the panel name set at configure takes priority. Is that intended?
Yes, that is intended.
As per docs (https://theqwertiest.github.io/foo_spider_monkey_panel/assets/generated_files/docs/html/window.html#.DefinePanel and https://theqwertiest.github.io/foo_spider_monkey_panel/docs/script_documentation/api_changes/#v140): "Note: to retain backward compatibility this method sets both script name and panel name."
That's why it was marked as deprecated =)

Looks good so far! Thanks! Specially love the in memory/ from file setting. I was so tired of having to re-import the main script to load the last changes if they were on the main file.
Glad that you liked it :)

As far as I have seen, the paths are relative.
Relative path support was there even in the previous SMP versions =)
The only difference is that package scripts dir is included in the search path now.

Assuming it's the same bug as I had, ListBoxX_ClassName needs updating to something unique.

https://github.com/TheQwertiest/scintilla/blob/f8817063200055b8b9f7b9a7a83c30100f64c903/win32/PlatWin.cxx#L2533
Thanks for the tip!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-02-12 12:31:01
Quote
Relative path support was there even in the previous SMP versions =)
The only difference is that package scripts dir is included in the search path now.
I meant relative to the package yep. That changes many things.

Quote
Yes, that is intended.
As per docs (https://theqwertiest.github.io/foo_spider_monkey_panel/assets/generated_files/docs/html/window.html#.DefinePanel and https://theqwertiest.github.io/foo_spider_monkey_panel/docs/script_documentation/api_changes/#v140): "Note: to retain backward compatibility this method sets both script name and panel name."
That's why it was marked as deprecated =)
I was not talking about the funcs, but the UI behavior. The option should be greyed out if the script contains a call to DefinePanel(), or some UI warning in the panel: NAME + (non configurable: set by script). It's counterintuitive for users to change something and be reverted without notice, since your main aim was to ease things for final users.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: cerbaire on 2021-02-12 15:57:20
Hi everyone,

I have a small problem using XMLHTTP object. It generates the following error:
ActiveXObject:
source: msxml3.dll
description: Error not specified

This is an extract of the code I use to get this error (I'm using Typescript)

let xhttp = new ActiveXObject("Microsoft.XMLHTTP");
return new Promise((resolve, reject) => {
   xhttp.onreadystatechange = function () {
      if (xhttp.status === 200) {
         if (xhttp.readyState === 4) {
            resolve(xhttp.responseText);
         } else {
            reject("Error");
         }
      } else {
         reject("Error");
      }
   };

   const album_url = `http://localhost/api/v1/album/get?album_id=${album_id}`;
   xhttp.open("GET", album_url, true);
   xhttp.send();
}
I use foo_spider_monkey_panel 1.4.0
Any idea where this error could come from ?
Thx for your support.

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-12 19:52:00
Any idea where this error could come from ?
Thx for your support.
It seems that it's not allowed to access `status` before `readyState` is 'Done' (i.e. equal to 4). And yes, MS should've done a much better job with the error message in such case :D
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-12 19:54:11
@regor , @kutuzof , all reported issues should be fixed in the dev build.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: cerbaire on 2021-02-12 21:26:01
Any idea where this error could come from ?
Thx for your support.
It seems that it's not allowed to access `status` before `readyState` is 'Done' (i.e. equal to 4). And yes, MS should've done a much better job with the error message in such case :D
Thanks @TheQwertiest, it works great now.
One question: I wonder if it is possible to package a multiple panel theme with the last release of your plug-in. It seems we can easily package a single panel theme. What if I have 5 panels ?
Many thanks for all the job you've done.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-02-12 22:19:12
Well, off the top of my head:
- Package is installed and unpacked automatically either via `Import` button or just by drug-n-dropping. So users don't need to know the "correct" location (or the correct folder structure).
- Packages has persistent id, meaning that the path to package content is always persistent and can be relied upon (e.g. by other packages).
- User can easily switch between packages in a single panel without needing to copy-paste script content anywhere.
- Same package can be reused in multiple panels (again, without needing to copy-paste script content).
Okay, so drag-n-drop is a neat feature. For that should it be a .zip file that has the package.json at the root level, or does it need to include the GUID folder as well? For upgrades, dropping/installing an updated package will overwrite the original contents I assume?

Edit: I did a bunch of tests and I can't figure out how to create a zip file package that can be installed correctly. I copied your package to a new location, changed the GUID and then zipped it up and attempted to import. Getting this error whatever basically whatever I do:
copy: The system cannot find the path specified.: "D:\Source\foobar2000_portable\foo_spider_monkey_panel\tmp\unpacked_package", "D:\Source\foobar2000_portable\foo_spider_monkey_panel\packages\{AAAAFFEF-C88A-4849-94D5-F33C71649927}"
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-12 23:41:38
Okay, so drag-n-drop is a neat feature. For that should it be a .zip file that has the package.json at the root level, or does it need to include the GUID folder as well? For upgrades, dropping/installing an updated package will overwrite the original contents I assume?
To create a package click "New Package" in package manager: this will create all the necessary files for the package (and this is the only proper way to create one).
To pack a package into an archive of importable format click "Export" in package manager.
Package id is used to identify a package, so importing a package with the same id will replace the current package.

What if I have 5 panels ?
You'll have to split it in at least 5 packages =)
Drag-n-drop package import support batch import as well.
Thus the whole theme could be reduced to N script packages and a .fcl file. And it's installation might be done as follows:
- User installs all the required packages (via drag-n-drop).
- User imports theme's .fcl (via fb2k preferences).

Note: common theme stuff can be extracted to a separate `utility` package, the one that does nothing, but is accessed via `utils.GetPackagePath()` from other packages.

Any file can be drag-n-dropped to the `Package files` control on package tab and it will automatically copied in a proper place. Note though, that folders are always put in `assets` folder (even if they contain only scripts), thus they have to be moved to the `scripts` folder manually.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-02-13 01:45:08
Thanks, that makes sense. So from my tests, when I update a package the entire contents of the package folder are wiped, and then the new package is extracted there.

I've been creating a config.json file with my theme so that users can non-destructively make changes for title-formatting strings without having to touch the actual code so that updates don't overwrite their changes. Seems like for me to make this work I'd need to store these config files in a different location outside the package itself. fb.ProfilePath maybe? I've also got some other assets that users tend to add their own things to so either I need to continue to use a centralized Georgia folder outside the package or maybe just continue doing things the way I've been doing them. Need to think about this a bit more.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-13 23:02:49
Version: 1.4.1
Link: https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/tag/v1.4.1
Changelog:
Hotfix for v1.4.0 (see changelog above (https://hydrogenaud.io/index.php?topic=116669.msg993706#msg993706))
Spoiler (click to show/hide)
Detailed description of API changes: https://theqwertiest.github.io/foo_spider_monkey_panel/docs/script_documentation/api_changes/#v141
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: JoeSyr on 2021-02-14 20:23:59
Hello, I'm experiencing a conflict between assorted SMP scripts and a setup that uses a high DPI scaling override(to make fb2k usable on large/high res screens). I'm not sure if this is more an issue with SMP or with windows, but as far as I've seen so far, SMP elements are the only ones so specifically affected so I thought to mention it here. It's not new to 1.4/1.4.1.

In a nutshell if you have:

-Win10 display settings set to use a scaling factor of >100%

-Foobar2000.exe set to override that scaling factor using "System (enhanced)" (foobar2000.exe ->properties->compatibility->change high DPI settings->High DPI scaling override)

Then a number of elements are prone to getting white box artifacts, for example the bottom bar in the StrigUI2.0 theme looks like this (https://imgur.com/9XgnLjz) after any of the buttons have been moused over (or things like the timer and the non-waveform seekbar incur it passively), and the white boxes persist until something is clicked. Similar white boxing happens to the biography panel by WilB, and the scrollbars in JS Playlist.

By comparison, using "System" instead of "system (enhanced)" does not cause these issues, but it does leave all the text in fb2k in an undesirable blurry state (as of yet I've found no other combination of windows settings that fixes this without otherwise distorted the UI to an unusable state). On my current setup (using a 4k tv as a monitor) it is necessary to use one of these or the UI will be severely distorted (and the global scaling factor is subjectively necessary to use the setup at all). This also seems to not be a driver related issue a the same thing happens on an Nvidia 2070 Super as an Intel integrated graphics build.

Somewhat related, the sample script at samples/complete/last.fm bio.js is badly rendered in such setups because the font size comes out giant even at the smallest settings.

Unrelated to these scaling related issues, I also just thought to report that 1.4 and 1.4.1 seem to break the Last.fm panel included in StrigUI2.0 with the following error message (I am not personally using/signed into this panel but I noticed it crashing while loading themes investigating the scaling issues):

this.xmlhttp is undefined

File: _LastFM.js
Line: 504, Column: 6
Stack trace:
  lfm_parse_data@_LastFM.js:504:6
  _lastfm/this.get/lastfm_xmlhttp[id].onreadystatechange@_LastFM.js:690:5
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-15 11:29:23
@JoeSyr , SMP does not handle DPI scaling in any way, i.e. everything is implemented (or not) by script authors. Since I don't have a high-DPI display, I don't even try to implement it in any of the scripts.
PS: Some `sample` panels do have DPI scaling code though, all thanks to marc2003 =)

Regarding StrigUI2.0 errors: this script was made by SMP user and is not a part of SMP installation, so you'll have to either request the author of the script for the fix or to fix it yourself. But it seems like a site parsing error, so perhaps last.fm changed the site structure at one point of time, which made the corresponding parsing code incompatible.

PS: It was working in previous SMP versions, because these kind of errors were suppressed before, because of the JS engine limitations (which was rectified in 1.4.0).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: JoeSyr on 2021-02-15 20:21:56
I see, thanks for the insights. I'll give things a spin to see if I can possibly adapt some of marc2003's scripts for my own usage.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-02-15 21:11:35
Somewhat related, the sample script at samples/complete/last.fm bio.js is badly rendered in such setups because the font size comes out giant even at the smallest settings.

Well this is supposed to one of the scripts with DPI support!!

All I can is that it works fine here but there are caveats:

-because the DPI is read from the registry, any desktop DPI changes means you have to log out and log back in again. It's not enough to restart the application.
-only the primary monitor can be queried. multi-monitor setups with differing DPI settings per monitor are not going to play nice.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2021-02-15 23:21:39
Whereas the GdiDrawText() method uses "segoe ui" as a fallback font for missing "segoe mdl2 assets" characters, DrawString() replaces them with empty squares. Is this a limitation of DrawString(), or am I missing something?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Black_Over_Bills_Mothers on 2021-02-16 09:13:53
I think there is an error in the documentation for IDE integration (https://theqwertiest.github.io/foo_spider_monkey_panel/docs/script_documentation/ide_integration/)

The entry under Visual Studio Code:
/// <reference path="./../../user-components/foo_spider_monkey_panel/docs/js/foo_spider_monkey_panel.js">

Should have a forward slash towards the end as below:
/// <reference path="./../../user-components/foo_spider_monkey_panel/docs/js/foo_spider_monkey_panel.js"/>
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-02-16 13:04:49
Whereas the GdiDrawText() method uses "segoe ui" as a fallback font for missing "segoe mdl2 assets" characters, DrawString() replaces them with empty squares. Is this a limitation of DrawString(), or am I missing something?

I can't be bothered to trawl the source code so I'm going to assume SMP hasn't deviated from the original WSH/JSP code where font objects have to store 2 different types of WinAPI fonts internally. Those are HFONT and Gdiplus::Font.

GdiDrawText uses HFONT and IIRC you get Arial if the font you ask for is missing
DrawString uses Gdiplus::Font and you get Microsoft Sans Serif if the font you ask for is missing

When you check the properties of any font object in JS (.Name, .Size, .Style), the internal Gdiplus::Font is queried, not the HFONT.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2021-02-16 16:34:40
...I'm going to assume SMP hasn't deviated from the original WSH/JSP code where font objects have to store 2 different types of WinAPI fonts internally. Those are HFONT and Gdiplus::Font.

JSP behaves in the same way, so I guess your assumption is correct.


DrawString uses Gdiplus::Font and you get Microsoft Sans Serif if the font you ask for is missing

Yes, if the whole font is missing, it is replaced with the fallback font, but if the font exists, missing glyphs are replaced with a □. GdiDrawText replaces them with the corresponding fallback font glyph, instead.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-02-16 20:05:52
Since that font is for symbols only, why don't you limit yourself to what is actually there? I presume you're using charmap to get what you want?

Maybe a practical example will help me understand??
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: davideleo on 2021-02-16 21:31:46
Since that font is for symbols only, why don't you limit yourself to what is actually there?

Yes, I suppose that's the proper way to go. The idea of relying on the fallback font arises from the need to simplify a few graphical issues when drawing captions (buttons, headers, etc.) with both an icon and a text label. Since I set their dimensions with relative values, based on MeasureStringInfo properties, dealing with just one font makes things easier. With "segoe ui symbol" this was not a problem, because the font provides all the regular "segoe ui" characters. When I moved to "segoe mdl2 assets", which I like better and has many more fonticons, I didn't even realize this was an issue because I was always using GdiDrawText (I actually did mistake the "arial" fallback font for "segoe ui"). Now I made some changes in the scripts, which require using DrawString, though, and here I am.

It's not really a coding problem in a strict sense, I just wanted to make sure I was not overlooking some options available to make DrawString behave like GdiDrawText in this regard, but the more I think about it and the less I like the idea of relying on a fallback font anyway.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-02-20 06:42:14
In 1.4.1 if I set Script source as file, and then select a file everything works. But when I restart foobar my file selection has lost everything except for what appears to be fb.profilePath. So no file is selected and I get an error and am forced to reselect the file (https://i.imgur.com/LLx0F70.png). Interestingly when I go back into the file selection dialog it does remember the full path to the file I had last selected.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-20 09:46:13
In 1.4.1 if I set Script source as file, and then select a file everything works. But when I restart foobar my file selection has lost everything except for what appears to be fb.profilePath. So no file is selected and I get an error and am forced to reselect the file (https://i.imgur.com/LLx0F70.png). Interestingly when I go back into the file selection dialog it does remember the full path to the file I had last selected.
Can you provide the full path to file you are trying to use?

And can you try the latest dev build and see if it has the same error?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-02-20 17:55:54
Can you provide the full path to file you are trying to use?

And can you try the latest dev build and see if it has the same error?
Full path is: D:\Source\foobar2000_portable\georgia\georgia-theme.js

Still seeing the same thing in 1.4.2-dev
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-21 13:12:40
Full path is: D:\Source\foobar2000_portable\georgia\georgia-theme.js

Still seeing the same thing in 1.4.2-dev
Hm... Still can't reproduce...
Can you try the following custom build?
https://ci.appveyor.com/api/buildjobs/dmess6a7ifkhdl12/artifacts/_result%2FWin32_Release%2Ffoo_spider_monkey_panel.fb2k-component
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-02-21 16:04:47
Hm... Still can't reproduce...
Can you try the following custom build?
https://ci.appveyor.com/api/buildjobs/dmess6a7ifkhdl12/artifacts/_result%2FWin32_Release%2Ffoo_spider_monkey_panel.fb2k-component
No joy. I tried this on a non-portable installation and everything worked fine. Can't tell if that's the issue, if it's another component (UIHacks?) or if something just got in a bad state when I was experimenting with packages and now it can't get out.

Edit: I completely removed FSM including the packages folders, then reinstalled and the path seems to survive through restarts now. I guess that's good enough for me.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-02-21 16:28:29
Okay, I figured out what the issue is. I have a single georgia folder which I use for development and then I drop junction links (https://superuser.com/questions/343074/directory-junction-vs-directory-symbolic-link) in my foobar folders so they all always have the same content. Paths inside the junctions are not saved, but if i point directly to the folder not using a link, things work.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-02-21 20:06:39
I'm having one last issue regarding relative paths and include. From the documentation it seems that if my Script source is a file, then passing a relative path to include should load files correctly, but this does not seem to be the case. I just get "Path does not point to a valid file: js\CaTRoX_QWR\lodash.min.js" when I pass a relative path from where the theme file is loaded.

i.e. I'm loading georgia-theme.js from georgia\ and that folder also contains a js\CaTRoX_QWR sub folders as well but it doesn't seem to be looking in that location.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Mikko_H on 2021-02-22 13:27:08
Hi, could you make the SMP playback stats feature optional as I feel like it's needlessly cluttering the properties window if not in use.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-02-24 10:33:24
Does someone know if there is a foobar controller (via Web or app) which does interact in some way with custom buttons, menus, etc?
The idea is to run smp scripts while using the controller, for example to create smart playlists. I know I could create a dummy playlist, and sending things to that playlist I could check with callbacks and run scripts but... is there any other way? (somewhat built in, obviously I know I could run menu entries using cmd commands on a local network)

Have tried these but they are limited to library management, playback or streaming
https://play.google.com/store/apps/details?id=com.cav.foobar2000controller&hl=es_GT
https://play.google.com/store/apps/details?id=com.foobar2000.foobar2000
https://hyperblast.org/beefweb/api/#/
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: zeremy on 2021-02-24 12:25:59
Does someone know if there is a foobar controller (via Web or app) which does interact in some way with custom buttons, menus, etc?
The idea is to run smp scripts while using the controller, for example to create smart playlists. I know I could create a dummy playlist, and sending things to that playlist I could check with callbacks and run scripts but... is there any other way? (somewhat built in, obviously I know I could run menu entries using cmd commands on a local network)

Have tried these but they are limited to library management, playback or streaming
https://play.google.com/store/apps/details?id=com.cav.foobar2000controller&hl=es_GT
https://play.google.com/store/apps/details?id=com.foobar2000.foobar2000
https://hyperblast.org/beefweb/api/#/

There is no such app that I am aware of with such ready made interaction.
My only suggestion is using foo_httpcontrol (https://bitbucket.org/oblikoamorale/foo_httpcontrol/downloads/) and an app such as HTTP Request Shortcuts (https://play.google.com/store/apps/details?id=ch.rmy.android.http_shortcuts&hl=en&gl=US) to send the request.

With foo_httpcontrol you can send a command line parameter to execute SMP main menu entries
https://bitbucket.org/oblikoamorale/foo_httpcontrol/wiki/Commands#markdown-header-cmdline

e.g "File / Spider Monkey Panel / 1"
http://localhost:8888/default?cmd=CmdLine&param1=/command:%221%22

In a SMP script create the code to be executed:
Code: [Select]
function on_main_menu(index) {
    switch (index) {
    case 1: // triggered when File>Spider Monkey Panel>1 is run
        fb.ShowPopupMessage("success");
        console.log("success");
        break;
    }
}
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-02-24 13:09:36
Thanks :) Yep, I was wondering if there was another way of doing it instead of http requests via another app.

That method is good enough for me, but not for the general public... I still find the dummy playlist route better for some use-cases though.
For example creating new playlists using a track as reference: using foobar web/app controllers involves only sending the desired track to that tracked playlist and then I can create a new playlist, change focus via script and automatically start playback as soon as anything is added. Using Http requests I can not point to a track previously selected on the controller app, but it works perfect for 'hardcoded' menu entries as you point.

I will consider a mix of both methods for my use-cases and the scripts I release then.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-02-26 19:20:29
I'm having one last issue regarding relative paths and include. From the documentation it seems that if my Script source is a file, then passing a relative path to include should load files correctly, but this does not seem to be the case. I just get "Path does not point to a valid file: js\CaTRoX_QWR\lodash.min.js" when I pass a relative path from where the theme file is loaded.

i.e. I'm loading georgia-theme.js from georgia\ and that folder also contains a js\CaTRoX_QWR sub folders as well but it doesn't seem to be looking in that location.
Could not reproduce your problem - I've tested with the following file structure:
Code: [Select]
fb2k_dir/
  folder/
    one.js
    sub1/
      sub2/
        two.js

one.js content:
Code: [Select]
include('sub1/sub2/two.js')

Are you sure you are not using junctions again? =)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-02-27 09:30:12
Are you sure you are not using junctions again? =)
I am (and don't knock junctions, they're awesome  :)) )

Okay, set this as the content of one.js and let's see if this is minimally reproducible for you:
Code: [Select]
function loadAsyncFile(filePath) {
    return new Promise(resolve => {
        setTimeout(() => {
            include(filePath);
            resolve();
        }, 1);
    })
}

const loadAsync = true; // works if false
async function includeFiles(fileList) {
    if (loadAsync) {
        for (let i = 0; i < fileList.length; i++) {
            await loadAsyncFile(fileList[i]);
        }
    } else {
        // this works
        fileList.forEach(filePath => include(filePath));
    }
}

includeFiles(['sub1/sub2/two.js']);

If I don't load with promises inside an await, everything is fine. Unfortunately as discussed months ago, if I don't load my theme using Promises, I get the "script is taking too long" popup when starting up foobar when my HDD isn't spinning.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: hexenszene on 2021-02-28 19:39:46
Not sure if this is the right thread so forgive me if that's the case.

I'm using Spider Monkey Panel and the Muzicbrainz discography script that comes with it.  It's great, but of course it requires the MUSICBRAINZ_ARTISTID tag to pull the info from Musicbrainz.  I've been diligently populating my files with that tag for the last few weeks until I realized I should probably be using Picard to do so instead.   However, apparently Picard populates the files with the tag "MUSICBRAINZ ARTISTID" (no underscore) instead of "MUSICBRAINZ_ARTISTID" that the script looks for.

Is there a way to have the script look for both versions of the tag, and use whichever is present?  (Or perhaps there's a way to change Picard's behavior?  Of  course this is the wrong thread for this latter solution...)  I'm open to any suggestions.

Thanks all.  Great work you've done with these features. <3

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-02-28 20:02:00
Are you assuming things without looking at the script itself??

https://github.com/TheQwertiest/smp_2003/blob/master/musicbrainz.js#L9



Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-02-28 22:38:57
Hope you reconsider the support for native playlists methods: (saving to given path without UI windows & loading directly to handle and not requiring an intermediate playlist being created on the UI)
https://hydrogenaud.io/index.php?topic=120394.msg994362#msg994362

For playlist manager:
Playlists with tons of tracks become totally unmanageable in m3u format (loading time), thus making the playlist manager functional only for auto-playlists and small standard playlist. Forcing to load them as read-only locked playlists, to rewrite them as m3u (loading time problem) or manually saving them via user intervention (making auto-updates useless). Also fpl playlist are the only one I can not check their size without loading them first on UI...

For Graph scripts:
A set of reference tracks could be saved to fpl playlists to be loaded later (via handles) as 'moods (https://www.spicefly.com/article.php?page=musicip-moods)'. It seems natural to use native foobar format for that... and they could be integrated in the manager too (to allow direct user updating). Yep I could save 'tags' to json, but then they lose the point of being user configurable.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-03-01 03:42:58
Hope you reconsider the support for native playlists methods: (saving to given path without UI windows & loading directly to handle and not requiring an intermediate playlist being created on the UI)
https://hydrogenaud.io/index.php?topic=120394.msg994362#msg994362
So I've been only sorta paying attention to this discussion, but I don't really get what you're trying to accomplish with m3u/fpl playlists. You seem to be developing a script which generates playlists of songs with a similar "mood" and then what exactly are you trying to do with them? Why are you even trying to save them to arbitrary locations? Also, does foo-jesus not handle your auto-saving issues?

Maybe I'm wrong, but you seem to be trying to force foobar/SMP to behave in a way that is kind of outside its design.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-03-01 09:18:21
Obviously you have not understand it (?) I really feel like I have to explain my motivations to someone who has not spent any time reading the thread... with all due respect. And that's weird... Specially when my request are 2 basic things. Saving fpl playlists without an annoying UI window to give a path, and loading a fpl playlist without loading it into the playlists tabs first.

First, I have created a playlist manager. SMP allows to write/read files directly so I can create and load m3u, pls or m3u8 playlists via scripts. That means I can track a folder with playlists, load them on demand (instead of having them always loaded within foobar), autoupdate them, etc. Foobar currently only supports loading a playlist, and then playlists are saved to internal format to its profile folder, not to their original folder... They also get cryptic filenames, etc.  You can not filter playlists by name, by user-set tags/categories, sort them, lock them, show only autoplaylists, create autoplaylists and save them without having them on the UI (marc's script did that and it was clearly within SMP/foobar's scope), regenerate their size, assign playlists files to playlists within foobar and autosave changes, etc. My manager is just a generalization of that design.

Foo-jesus has nothing to do with a playlist manager. You have a library manager, which does the same things (searching, sorting, etc.), without needing to send tracks first to a playlist. A playlist manager does the same without needing to send playlist to the playlist tab (just using physical files). That's the main point. Many people have created library managers with SMP, was that outside SMP design?

The manager is fully functional right now. There is only 1 thing missing, foobar ironically doesn't have open fpl playlist support and SMP doesn't have any method to work with fpl playlist. You can not load a playlist to a handle list without loading it on the UI first, and you can not save a playlist to a path directly (like any other file).  Also, not having fpl support means all autosaving/updating features are disabled for them. Or they have to be rewritten to m3u8 format... but then when you load a playlists with 1K tracks as m3u8, it takes a full min. instead of seconds (when using fpl).

That means... a playlist manager thought to manage foobar playlists can manage anything but native playlists, a bit ironic.

(https://hydrogenaud.io/index.php?action=dlattach;attach=19010;image)

Is like saying creating a theme is forcing SMP/foobar to behave in a way that is kind of outside its design. I don't really get your point, if you know what I mean ;) Specially when a playlist manager is something basic in a music player, and it has been done a dozen of times as plugin (but without all these features).

Second, the graph scripts... Again, it's fully functional and it has been since weeks XD I still don't get the point of trying SMP to behave in a way that is kind of outside its design. I'm not going to explain again what these scripts do since it's all in the thread, but essentially I have managed to create intelligent playlists the same than spotify/genius or any other online player does. Using open source offline data. And it can be configurable by artist, genre, style, moods, in key mixing, etc. What you do with those playlists is your problem XD I don't understand your questions.

Having SMP methods to load/write fpl playlists without UI intervention (which is clearly within design, since you already manage handle lists via scripts, and can load fpl playlists to UI) would allow the user to select 4 tracks, call them 'Happy mood' and then use that playlist or 'mood' as a set of references to create dynamic playlists similar to them.

It's my impression that makes more sense than selecting 4 tracks, saving their tags to a json file and doing all in a non transparent way. I mean... since 'moods' or these playlists are meant to be user configurable, It's obviously more easy for anyone to just load a playlist file, add/remove tracks and save it again. Instead of regenerating json  files, creating new menus, a new UI window to show the tracks currently on the 'mood' or virtual file, specific logic to add/remove tracks, etc. If the fpl is clearly a container for tracks, I don't see why using it as a container of tracks is outside its design. It's just a feature I would like to add (https://www.spicefly.com/article.php?page=musicip-moods) and being a thing which clearly needs things already implemented, needing just a native method to do it without UI intervention, would be much simpler than the json way...

Btw... since I have already create a playlist manager... If we had native methods to read/save fpl playlists, then I could track the folder with 'moods' and autosave any change done within foobar to those playlists. Therefore having the files always updated, apart from foobar's internal folder. Which again... serves another purpose. Since moods are playlist not meant to be always loaded on the UI, but just containers.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-03-01 18:18:00
With all due respect, I've read every single post in this thread. Yesterday I also went and reread all of your posts through the last 4 pages of this thread and every post in your linked thread. You are extremely verbose (and that's saying something coming from me!) and it can be very difficult to understand exactly what you're trying to do and what your issues are. I think what you're trying to do with the mood/similar playlists is really cool and interesting, but despite everything you wrote to me, I still don't understand why you need what you think you need.

From what I can tell you are:
Generating new playlists. Obviously no issues there.
You want to be able to save these playlists as .fpl's, but that's already the native format that SMP/fb2k saves playlists.
You want to be able to save these playlists on demand. I mentioned foo_jesus because it will force writing .fpls to disk.
You want to be able to save these playlists in arbitrary locations with arbitrary names. Why? Why does having them automatically saved in the Playlists-1.4 folder not work for you? The playlist already has an internal name that you give it.
You want to be able to read playlists from arbitrary locations without actually loading the playlist. This part I also don't think you've adequately explained.

Is the issue that you're wanting to generate hundreds/thousands of playlists and not incur a hit at startup? Is there even much of a performance hit with non-autoplaylists? I added 10 playlist with 7800 files each (all different since the playlist manager is smart about duplicate playlists) and my startup time was essentially exactly the same as the 2 seconds it was before I added them.

Is the issue that don't want the playlists to show up in foobar's playlist manager? In that case yeah, you're probably out of luck, but since you're creating your own playlist manager you could you easily use smart naming to filter out what you don't want to see, right? Again, maybe scale makes that impossible to do well. Only you know that.

What I see you asking for is the ability to write .fpls to a different location using a new SMP method, and then read from those locations without foobar itself loading the playlists (for reasons?) which I'd be surprised if the fb2k API even supports. Some of this you should probably make a pull-request for if you can figure out how to do it, or even develop your own playlist reading/writing component which you could then control through SMP. It seems pretty niche to me, and whenever I come to that realization I end up having to code it myself  ;D
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-03-01 19:34:30
Don't really get the point of discussing with you when TheQwertiest knows exactly which are the 'limitations' with  fb.SavePlaylist() and fb.AddLocations.... really, reread what you are writing...

Quote
You want to be able to save these playlists as .fpl's, but that's already the native format that SMP/fb2k saves playlists.
No. That's your interpretation.

Quote
You want to be able to save these playlists in arbitrary locations with arbitrary names. Why? Why does having them automatically saved in the Playlists-1.4 folder not work for you? The playlist already has an internal name that you give it.
That's the freakin point of a playlist manager lol. Instead of discussing the point, just create yourself 40 playlist within foobar. Now what, you have 40 playlist loaded always in the playlist tab? Why? Are you using the 40 playlist at the same time?

What was the point of marc's autoplaylist manager then?
https://github.com/TheQwertiest/smp_2003/blob/master/autoplaylists.js (https://github.com/TheQwertiest/smp_2003/blob/master/autoplaylists.js)

Obviously you are clearly missing some people have tons of playlists and having them loaded for no reason, when they can be loaded on demand makes no sense. They clutter the UI and make searching for something really slow.

But please, do it. Create your 40 playlists and 40 autoplaylists and then tell me how they are being saved in foobar 1.4 like you said. And then tell me which file is linked to which playlist. And then tell me what happens when you have many autoplaylists at startup. Then close those playlists and tell me where they go on the next session ;)

It's not so hard to understand foobar treats playlist as virtual files, not something linked to physical files. Yep, they are saved periodically IF you have another component AND WHILE you have them loaded within foobar. That clearly doesn't cover the usage of a playlist manager, which manages playlist not loaded too.

And again, you are clearly missing having a window with a tracked folder which shows all the playlist files, with sorting, filtering and many more features. But hey... if you like having criptic names, and all the limits with current playlist management.. go with it. I will not discuss your use-case nor your theme aim, since that's ridiculous. Obviously everyone does what he likes. We could eveny say having a library manager is stupid. Just use the explorer.. hahahaha Why not?... wow.

Quote
You want to be able to read playlists from arbitrary locations without actually loading the playlist. This part I also don't think you've adequately explained.
Again, why do I have to explain it to you to justify its use? I don't see you justifying me why you have created a theme or you want X or Y Really, this makes no sense. You have just come here judging what I do without a reason. What's the point or value of this discussion? I have made a request, have given reasons, they are not directed to you and I CLEARLY KNOW there is no other method to do what I want.

Quote
Is the issue that you're wanting to generate hundreds/thousands of playlists and not incur a hit at startup? Is there even much of a performance hit with non-autoplaylists? I added 10 playlist with 7800 files each (all different since the playlist manager is smart about duplicate playlists) and my startup time was essentially exactly the same as the 2 seconds it was before I added them.
The playlist manager manages both, standard playlists and autoplaylists. Thanks for telling me what I already know anyway...

Quote
Is the issue that don't want the playlists to show up in foobar's playlist manager? In that case yeah, you're probably out of luck, but since you're creating your own playlist manager you could you easily use smart naming to filter out what you don't want to see, right? Again, maybe scale makes that impossible to do well. Only you know that.
.... that's why I'm requesting a NATIVE METHOD to save fpl playlist to a path, and loading FPL playlist to handle list. But again thanks for telling me what I need.

Quote
What I see you asking for is the ability to write .fpls to a different location using a new SMP method, and then read from those locations without foobar itself loading the playlists (for reasons?) which I'd be surprised if the fb2k API even supports.
... so, according to you, you have queries which can create handle-lists without involving UI or virtual playlist. You have handle-lists, which are equivalent to a playlist and you can work with them in any way you want without involving a playlist.
A playlist is just a handle-list... but the problem is the API magically always converts a handle-list to a playlist. And it's impossible to just skip the creation of an UI object to work with that file list. Aha, it makes so much sense.

Some of this you should probably make a pull-request for if you can figure out how to do it, or even develop your own playlist reading/writing component which you could then control through SMP. It seems pretty niche to me, and whenever I come to that realization I end up having to code it myself  ;D
I have already written a script to read/write playlist through SMP. For m3u8, m3u and pls formats. Again, you are just speaking what if's and telling me what to do without a reason. But thanks.
And it works perfectly fine for fpl playlists, except those are treated as read-only.

But since fpl format is NOT PUBLIC, the only way to ask for it is here at the forums. And being SMP already interacts with the SDK, the proper way to do it would be giving fb.savePlaylist a path, and having a fb.loadPlaylist method to load handle-lists.

Quote
It seems pretty niche to me
And that was the point of all the discussion, since you find no utility on what I do, you feel the need to discuss it. Great. Thanks.
Well, considering there have been 4 playlist manager plugins and one Jscript/SMP script plugin to to partially what I have done, I would say it is not niche. But hey... I will simply stop my verbose answers, since it doesn't matter how much I write you already have your opinion even without ever having seen the scripts or their usage.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-03-01 21:49:29
@regor You're kind of being... let's go with rude. There's really no need to be so combative.

I'm not asking to justify your use case, I'm trying to get you to concisely explain the problem you're trying to solve, and what shortcomings you feel SMP has to see if there's potentially an alternative you've overlooked, or something that could actually be done. I'm a professional JS developer, and have developed an 8k+ line theme, and, unlike you, I've actually contributed to the SMP codebase so it's not like I'm just some ass on a forum saying your idea is dumb (and I'm clearly not saying that -- again it's a neat idea).

I did also want to point out that you were correct that given the ephemeral nature of fpl's you're either stuck with a million playlists loaded which is not ideal (even if your component could effectively emulate hierarchical style viewing which was my thought), and that closing a playlist is identical to deletion. So I fully understand the limitation there and you're right, it's a big one.

Don't really get the point of discussing with you when TheQwertiest knows exactly which are the 'limitations' with  fb.SavePlaylist() and fb.AddLocations.... really, reread what you are writing...
So what exactly are you wanting him to do? All SavePlaylist and LoadPlaylist do is make a call to the SDK (https://github.com/TheQwertiest/foo_spider_monkey_panel/blob/244522674b0f0b756502ab0cf01ac7cb588372dc/foo_spider_monkey_panel/js_objects/fb_utils.cpp#L701), just like if you selected the entry from the FileMenu. If Peter doesn't expose the functionality you want, what do you think @TheQwertiest is gonna be able to do?  ;D Marc has pointed out that this functionality does exist in the SDK. Mea culpa.

In the original post I responded to, you asked him to "reconsider adding support for native playlists". Now you freely admit that the FPL format is not public. Again, what magic do you think TheQwertiest can work with a non-public format that the fb2k SDK only exposes by manually loading them. Why aren't you asking @Peter for this?

Part of the disconnect is that you keep saying Playlist Manager, when typically in the context of foobar that refers to playlists that are already loaded. What you're hoping to be able to build is a File Manager operating only on playlist formats (because you want some meta information about them, but clearly don't want to load them into memory) that allows you to open and close playlists at will. Linking to scripts that list loaded auto-playlists as proof of... *something* isn't quite the same thing.

Anyway, I wish you the best of luck, and hope someday you can build exactly what you want.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-03-01 22:42:40
Again, what magic do you think TheQwertiest can work with a non-public format that the fb2k SDK only exposes by manually loading them. Why aren't you asking @Peter for this?

What are you dribbling on about? regor asked for this in SMP AFTER I had the used the SDK to implement the same feature in JSP. I didn't point to the source code at the time but it's here.... all one line of it.

https://github.com/marc2k3/foo_jscript_panel/blob/b99537003e0d3b6787931cc4b1f2dad70eb0f5d7/src/ScriptInterface/MetadbHandleList.cpp#L379
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-03-01 23:11:42
What are you dribbling on about? regor asked for this in SMP AFTER I had the used the SDK to implement the same feature in JSP. I didn't point to the source code at the time but it's here.... all one line of it.

https://github.com/marc2k3/foo_jscript_panel/blob/b99537003e0d3b6787931cc4b1f2dad70eb0f5d7/src/ScriptInterface/MetadbHandleList.cpp#L379
My bad. Seems pretty straightforward, and regor could easily create a pull request to utilize that and g_save_playlist it seems, although maybe TQ has nixed that idea completely.

However, Regor also apparently wants to be able to read playlists without actually loading them in foobar, which is what I was referencing in the part you quoted.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-03-02 09:07:02
Again, what magic do you think TheQwertiest can work with a non-public format that the fb2k SDK only exposes by manually loading them. Why aren't you asking @Peter for this?

What are you dribbling on about? regor asked for this in SMP AFTER I had the used the SDK to implement the same feature in JSP. I didn't point to the source code at the time but it's here.... all one line of it.

https://github.com/marc2k3/foo_jscript_panel/blob/b99537003e0d3b6787931cc4b1f2dad70eb0f5d7/src/ScriptInterface/MetadbHandleList.cpp#L379
Thanks...

In fact the saving part is the most important piece of code, since that would make the manager fully functional for fpl (autosaving, autoupdating, notable speed improvements over m3u8). I would not be able to get the playlist size for fpl playlists (until it's loaded on the UI)... but that's a minor thing compared to the other features.

Quote
@regor You're kind of being... let's go with rude. There's really no need to be so combative.
Really, it is not my intention to be combative. Sorry.  But please reread your comments, you have simply prejudged I didn't know what I wanted, why I wanted it or  how I wanted to do it. It's fine, I understand everyone may miss an obvious alternative of doing things, but you crossed the line multiple times even when I gave you clear answers and asked you to stop it. This discussion has been totally pointless, for many reasons. Will not answer to the rest, since it's a dead end road (who has more lines of code, really?) I'm waiting for those fpl functions and a bit of testing before releasing the code publicly too ;) Anyway, if you want to see what I have done, just drop me a line. It is not like it's secret code, I simply have no time -now- for updating a github with beta code and documentation everyday .

Anyway, 'native fpl support' just meant using the already existing functions on the SDK to manage playlists without involving UI, via scripts. I don't ask for hocus pocus or TQ giving us the format of FPL when that's clearly outside his reach. I thought that was pretty obvious, given the context and that you are a developer...

Let's forget this and continue with our work.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-03-02 17:19:29
Anyway, 'native fpl support' just meant using the already existing functions on the SDK to manage playlists without involving UI, via scripts. I don't ask for hocus pocus or TQ giving us the format of FPL when that's clearly outside his reach. I thought that was pretty obvious, given the context and that you are a developer...
Sorry, I had seen you request this: "loading directly to handle and not requiring an intermediate playlist being created on the UI)" multiple times now which is what I thought you were referring to with native support. That's also what I meant when I originally said you seemed to be violating foobar's design.

Quote
Let's forget this and continue with our work.
Agreed. Let's chalk it up to language differences and I apologize for the poor behavior on my part.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Lucidae on 2021-03-10 07:17:28
I like "JS Smooth Playlist" from the samples in this plugin, but it doesn't let you change the default displayed fields. Has anyone tried modifying this script to add more customization options?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-03-10 09:50:01
Edit: In the course of writing this post I verified it was an FSM problem, and so I just created a ticket and moved the original contents of this post here: https://github.com/TheQwertiest/foo_spider_monkey_panel/issues/135
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MojoBass on 2021-03-11 05:44:31
I like "JS Smooth Playlist" from the samples in this plugin, but it doesn't let you change the default displayed fields. Has anyone tried modifying this script to add more customization options?
Changing over to 'JS Playlist' (or as well called 'jsplaylist-mod') gives full ability to modification, see here (https://theqwertiest.github.io/foo_spider_monkey_panel/docs/script_showcase/single_panel_scripts/#js-playlist). Runs as well in SMP, is activated in SMP by
Code: [Select]
include('samples/jsplaylist-mod/jsplaylist main script.js');
or of course by selecting the script source 'Sample' and then ' jsplaylist-mod\jsplaylist main script.js' in the SMP Configuration.

@TheQwertiest by the way: in your (great!) SMP component homepage (https://theqwertiest.github.io/foo_spider_monkey_panel/), the pics and path of JS Smooth Playlist and JS Smooth Playlist Manager seem to be reversed.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: IP974 on 2021-03-11 11:42:16
Hi all
foobar 1.6.4 crash when I want to add smp 1.4.1.
Do you have a solution . thank you

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-03-16 14:33:31
https://hydrogenaud.io/index.php?topic=120394.msg994849#msg994849

Created the first package for SMP and have some questions about the way it works.
Code: [Select]
try { //May be loaded along other buttons
window.DefinePanel('Top Tracks Button', {author:'xxx'});
include(fb.ProfilePath + 'scripts\\SMP\\xxx-scripts\\helpers\\buttons_xxx.js');
var g_font = gdi.Font('Segoe UI', 12);
var buttonCoordinates = {x: 0, y: 0, w: 98, h: 22};
var buttonOrientation = 'x';
} catch (e) {
buttonCoordinates = {x: 0, y: 0, w: buttonOrientation == 'x' ? 98 : buttonCoordinates.w , h: buttonOrientation == 'y' ? 22 : buttonCoordinates.h}; // Reset
console.log('Top Tracks Button loaded.');
}

I use that code to check if the button file is being loaded within a button bar or as standalone. The idea is the button bar is loaded first so window.DefinePanel has been already called and therefore "try" thows an error. Works great using standard scripts, but in packages window.DefinePanel and window.DefineScript always throw an error... rendering that method obsolete.

A button bar would simply follow the same structure and include the buttons files.

Code: [Select]
try { //May be loaded along other buttons
window.DefinePanel('Merged Buttons bar', {author:'xxx'});
include(fb.ProfilePath + 'scripts\\SMP\\xxx-scripts\\helpers\\buttons_xxx.js');
var g_font = gdi.Font('Segoe UI', 12);
var buttonCoordinates = {x: 0, y: 0, w: 98, h: 22};
var buttonOrientation = 'x';
} catch (e) {
buttonCoordinates = {x: 0, y: 0, w: buttonOrientation == 'x' ? 98 : buttonCoordinates.w , h: buttonOrientation == 'y' ? 22 : buttonCoordinates.h}; // Reset
console.log('Merged Buttons loaded.');
}

// Global width - Height overrides
buttonCoordinates.w += 40; // Only works for 'y' orientation
buttonCoordinates.h += 0; //For 'x' orientation

// Global toolbar color
bToolbar = true; // Change this on buttons bars files to set the background color
toolbarColor = RGB(211,218,237);


{ // Buttons
let buttonsPath = [ // Add here your buttons path
fb.ProfilePath + 'scripts\\SMP\\xxx-scripts\\buttons\\buttons_search_same_style.js',
fb.ProfilePath + 'scripts\\SMP\\xxx-scripts\\buttons\\buttons_search_same_style_moods.js',
fb.ProfilePath + 'scripts\\SMP\\xxx-scripts\\buttons\\buttons_search_similar_by.js',  //+15 w
fb.ProfilePath + 'scripts\\SMP\\xxx-scripts\\buttons\\buttons_search_top_tracks.js',
fb.ProfilePath + 'scripts\\SMP\\xxx-scripts\\buttons\\buttons_remove_duplicates.js',  //+25 w
fb.ProfilePath + 'scripts\\SMP\\xxx-scripts\\buttons\\buttons_search_bydistance.js',
fb.ProfilePath + 'scripts\\SMP\\xxx-scripts\\buttons\\buttons_tags_automation.js',
];

for (let i = 0; i < buttonsPath.length; i++) {
if ((isCompatible('1.4.0') ? utils.IsFile(buttonsPath[i]) : utils.FileTest(buttonsPath[i], "e"))) {
include(buttonsPath[i], {always_evaluate: true});
} else {
console.log(buttonsPath[i] +' not loaded');
}
}

/*
OR just add them manually:
include(fb.ProfilePath + 'scripts\\SMP\\xxx-scripts\\buttons\\buttons_search_same_style.js', {always_evaluate: true});
...
*/
}

This way merging buttons becames a matter of editing 1 line. And anyone can create their own bars easily.

How could I do the same within packages?
Is there a universal way to do it? I would prefer to not have 2 versions of the same script, one for packages and other for standard scripts...
Is there a way to check if the script is being loaded within a package?
Could window.DefinePanel or window.DefineScript work within a package?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-03-16 20:09:09
And have another suggestion related to the SMP menu and executing arbitrary scripts on demand. While trying to link a standard foobar button to a script, obviously I found the only way was to link the button to main menu SMP entry. Then adding a script at some panel to populate that menu entry with my desired function... but what about dynamic main/contextual menus? I now we talked about it some time ago and I think I have a pretty good concept of how it could work.


For example masstagger creates menus dynamically according to the "presets" you create.


Now back to SMP, a panel within foobar preferences could be created (the same than jScript) with a simple UI.


Solves complex logic to create dynamic menus. Does not require a dummy script to add on menu callbacks and functions there..  and is user configurable without limits. Just the same than adding scripts to the panels.


Creating buttons with SMP functionality would be pretty easy since they would be integrated in foobar the same than any other button... and without X entries limit. It would not require extra js files to draw buttons or menus for panels. Also my reasoning to create both, menu and context menus is simple. For buttons it may not change anything, but for mouse menus it does. It would show some menus when right clicking on tracks, and others on file menu, allowing some fine tuning.



This simple change would change drastically script integration. For ex. anyone could add scripts to any theme using menus/buttons without touching the panels at all (pretty useful for playlist generation scripts, etc.) This would further differentiate utility scripts (meant to be used only on demand) and UI/panel scripts (meant to draw items dynamically or always loaded). Utility scripts would be much more useful and simpler to use.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kgena_ua on 2021-03-23 16:05:36
Is it possible to check for compatibility Spider Monkey Panel v.1.4.1 and foo dockable panels (foo_dockable_panels).
foobar 1.5 crash when I want to add Spider Monkey Panel v.1.4.1. using foo dockable panels.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kgena_ua on 2021-04-02 06:56:43
foo_spider_monkey_panel v 1.4.1
foobar2000_v1.5
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Dawidsu on 2021-04-09 11:56:48
I'm having problems using on_playback_queue_changed(origin). I can use it without the parameter, but that works with every queue change and I have no use for that. ;) I need to set it to "playback advance", but when I try to execute on_playback_queue_changed(2) I'm getting an error message:
Code: [Select]
missing formal parameter

File: track info scroll.js
Line: 209, Column: 35
Source: function on_playback_queue_changed(2) {
Any ideas what can be wrong with this?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-04-09 13:49:09
If I don't load with promises inside an await, everything is fine. Unfortunately as discussed months ago, if I don't load my theme using Promises, I get the "script is taking too long" popup when starting up foobar when my HDD isn't spinning.
Okay, I see what the problem is, I'll take a look.

@TheQwertiest by the way: in your (great!) SMP component homepage (https://theqwertiest.github.io/foo_spider_monkey_panel/), the pics and path of JS Smooth Playlist and JS Smooth Playlist Manager seem to be reversed.
Thanks, I'll fix that =)

in packages window.DefinePanel and window.DefineScript always throw an error... rendering that method obsolete.
Yes, that's intentional. Package contains all the necessary info about the included scripts, so there is no need to define it in the script itself.

The primary (and the only) purpose of `DefinePanel`/`DefineScript` is to provide the user with the information about the script in case it fails. I.e. it's for troubleshooting only.

In your case, there is zero need for `DefineScript` and it can be easily substituted with smth like
Code: [Select]
if (typeof loaded_scripts === 'undefined') {
    loaded_scripts = {}
}
if (!(script_id in loaded_scripts)) {
   load_script(script_id);
  loaded_scripts[script_id] = true;
}

PS: `window.DefinePanel` is marked as deprecated

Is it possible to check for compatibility Spider Monkey Panel v.1.4.1 and foo dockable panels (foo_dockable_panels).
foobar 1.5 crash when I want to add Spider Monkey Panel v.1.4.1. using foo dockable panels.
Does foobar2000 crash or is it the script that is crashing?
If it's the latter and your next post contains the corresponding error text, then it might be the same problem as the one that @MordredKLB has.

I'm having problems using on_playback_queue_changed(origin). I can use it without the parameter, but that works with every queue change and I have no use for that. ;) I need to set it to "playback advance", but when I try to execute on_playback_queue_changed(2) I'm getting an error message:
`on_playback_queue_changed` is a callback that's invoked by SMP, so I'm not sure what you are trying to do here.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Dawidsu on 2021-04-09 14:02:51
Quote
I'm having problems using on_playback_queue_changed(origin). I can use it without the parameter, but that works with every queue change and I have no use for that. ;) I need to set it to "playback advance", but when I try to execute on_playback_queue_changed(2) I'm getting an error message:
`on_playback_queue_changed` is a callback that's invoked by SMP, so I'm not sure what you are trying to do here.

I'll admit that I'm a complete noob and I don't know first thing about java script (I have no idea what SMP is). I'm trying to use whatever basic knowledge I have in php and guess what I need to do. So maybe that's why my question seems unclear. Anyway, I'm trying to monitor for when the queue runs out and then play a specified track from a playlist. So far what I managed to do is play the specified track whenever the queue changes, but that's not gonna work for my purpose. I need to use on_playback_queue_changed(2) for that and I can't. How shall I use it?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-04-09 19:22:11
Quote
Yes, that's intentional. Package contains all the necessary info about the included scripts, so there is no need to define it in the script itself.

The primary (and the only) purpose of `DefinePanel`/`DefineScript` is to provide the user with the information about the script in case it fails. I.e. it's for troubleshooting only.

In your case, there is zero need for `DefineScript` and it can be easily substituted with smth like
Code: [Select]

if (typeof loaded_scripts === 'undefined') {
    loaded_scripts = {}
}
if (!(script_id in loaded_scripts)) {
   load_script(script_id);
  loaded_scripts[script_id] = true;
}


PS: `window.DefinePanel` is marked as deprecated
That doesn't solve the problem entirely. DefinePanel/defineScript marks the current script as the main one, thus marking the rest (independently of the order they get loaded or the number) as secondary ones and merging them (since consecutive calls throw an error). While your approach has nothing to do with that (or requires a lot more of coding to do the same), but loading multiple known scripts (which can not be duplicated).
I don't need the script_ids at all. I don't even need to know what the main script is at any given point.

I just load:
button bar 1, button 3, button 3, button 6, ... button bar calls define panel once, thus telling the other buttons to be loaded as merged buttons.
But that works the same if I simply add to any panel:
button bar 1, button 5
Or:
button 3

And I don't have to touch the code at all, just include them. Every time DefinePanel/defineScript is called exactly once on the first file. And the same files can be reused as independent buttons scripts, merged as bars or inside other panels. Obviously I could just create a shared var bool bMainLoaded (instead of storing all IDs like you do), but I find DefinePanel/defineScript much cleaner, since it also gives the panel a name (both things done in one step). I guess is your design choice, but that choice clearly creates differences on how the same code works on packages and standalone scripts (definePanel may be deprecated but DefineScript is not and has the same problem).

Code: [Select]
'use strict';

/*
Just a bar of the same search by distance buttons customizable! So every instance can have its own name and do its own different thing.
*/

try { //May be loaded along other buttons
window.DefinePanel('Merged SBD Custom Buttons bar', {author:'xxx'});
include(fb.ProfilePath + 'scripts\\SMP\\xxx-scripts\\helpers\\buttons_xxx.js');
var g_font = gdi.Font('Segoe UI', 12);
var buttonCoordinates = {x: 0, y: 0, w: 98, h: 22};
var buttonOrientation = 'x';
} catch (e) {
buttonCoordinates = {x: 0, y: 0, w: buttonOrientation == 'x' ? 98 : buttonCoordinates.w , h: buttonOrientation == 'y' ? 22 : buttonCoordinates.h}; // Reset
console.log('Merged SBD Custom Buttons bar loaded.');
}

// Global width - Height overrides
buttonCoordinates.w += 0; // Only works for 'y' orientation
buttonCoordinates.h += 0; //For 'x' orientation

// Global toolbar color
bToolbar = false; // Change this on buttons bars files to set the background color
toolbarColor = RGB(211,218,237);


{ // Buttons
let buttonsPath = [ // Add here your buttons path
fb.ProfilePath + 'scripts\\SMP\\xxx-scripts\\buttons\\buttons_search_bydistance_customizable.js',
fb.ProfilePath + 'scripts\\SMP\\xxx-scripts\\buttons\\buttons_search_bydistance_customizable.js',
fb.ProfilePath + 'scripts\\SMP\\xxx-scripts\\buttons\\buttons_search_bydistance_customizable.js',
fb.ProfilePath + 'scripts\\SMP\\xxx-scripts\\buttons\\buttons_search_bydistance_customizable.js',
fb.ProfilePath + 'scripts\\SMP\\xxx-scripts\\buttons\\buttons_search_bydistance_customizable.js',
fb.ProfilePath + 'scripts\\SMP\\xxx-scripts\\buttons\\buttons_search_bydistance_customizable.js',
];

for (let i = 0; i < buttonsPath.length; i++) {
if ((isCompatible('1.4.0') ? utils.IsFile(buttonsPath[i]) : utils.FileTest(buttonsPath[i], "e"))) {
include(buttonsPath[i], {always_evaluate: true});
} else {
console.log(buttonsPath[i] +' not loaded');
}
}

/*
OR just add them manually:
include(fb.ProfilePath + 'scripts\\SMP\\xxx-scripts\\buttons\\buttons_search_same_style.js', {always_evaluate: true});
...
*/
}

Code: [Select]
'use strict';

try { //May be loaded along other buttons
window.DefinePanel('Search by Distance Customizable Button', {author:'xxx'});
include(fb.ProfilePath + 'scripts\\SMP\\xxx-scripts\\helpers\\buttons_xxx.js');
var g_font = gdi.Font('Segoe UI', 12);
var buttonCoordinates = {x: 0, y: 0, w: 98, h: 22};
var buttonOrientation = 'x';
} catch (e) {
buttonCoordinates = {x: 0, y: 0, w: buttonOrientation == 'x' ? 98 : buttonCoordinates.w , h: buttonOrientation == 'y' ? 22 : buttonCoordinates.h}; // Reset
console.log('Search by Distance Buttons loaded.');
}
include(fb.ProfilePath + 'scripts\\SMP\\xxx-scripts\\search_bydistance.js'); // Load after buttons_xxx.js so properties are only set once
var prefix = "sbd_";
prefix = getUniquePrefix(prefix, "_"); // Puts new ID before "_"

var newButtonsProperties = { //You can simply add new properties here
customName: ['Name for the custom UI button', 'Customize!']
};
newButtonsProperties = {...SearchByDistance_properties, ...newButtonsProperties}; // Add default properties at the beginning to be sure they work
setProperties(newButtonsProperties, prefix); //This sets all the panel properties at once

// we change the default coordinates here to accommodate text
if (buttonOrientation == 'x') {buttonCoordinates.w -= 5;}

/*
Some button examples for "search_bydistance.js". Look at that file to see what they do.
*/

var newButtons = {
    SimilarUserSet: new SimpleButton(calcNextButtonCoordinates(buttonCoordinates, buttonOrientation, buttonOrientation == 'x' ? true : false).x, calcNextButtonCoordinates(buttonCoordinates, buttonOrientation, buttonOrientation == 'x' ? false : true).y, buttonCoordinates.w, buttonCoordinates.h, getProperties(newButtonsProperties, prefix)['customName'], function () {
let t0 = Date.now();
let t1 = 0;
const properties = getPropertiesPairs(this.buttonsProperties, this.prefix);
if (properties['customName'][1] == 'Customize!') {
const new_name = utils.InputBox(window.ID, 'Enter button name. Then configure properties according to your liking (look for "' + this.prefix + '...").', window.Name + ': Search by Distance Customizable Button');
            if (!new_name.length) {
                return;
            } else {
this.buttonsProperties['customName'][1] = new_name;
setProperties(this.buttonsProperties, this.prefix, undefined, undefined, true); // Force overwriting
window.ShowProperties(); // This also forces a reload if you press ok/apply, but pressing cancel doesn't! That would leave the button with the old name... even if the property is already set
window.Reload(); // Forces redraw with new name
}
} else {
do_searchby_distance({properties: properties}); // All set according to properties panel!
}
t1 = Date.now();
console.log("Call to do_searchby_distance " + getProperties(this.buttonsProperties, this.prefix)['customName'] + " took " + (t1 - t0) + " milliseconds.");
}, null, g_font,'Search according to user set variables at properties panel', prefix, newButtonsProperties)
};
// Check if the button list already has the same button ID
for (var buttonName in newButtons) {
if (buttons.hasOwnProperty(buttonName)) {
// fb.ShowPopupMessage('Duplicated button ID (' + buttonName + ') on ' + window.Name);
console.log('Duplicated button ID (' + buttonName + ') on ' + window.Name);
Object.defineProperty(newButtons, buttonName + Object.keys(buttons).length, Object.getOwnPropertyDescriptor(newButtons, buttonName));
delete newButtons[buttonName];
}
}
buttons = {...buttons, ...newButtons};
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-04-10 18:15:59
Bug:

Try copying this into any property:
Code: [Select]
style,Psychedelic Folk;style,Latin Rock;style,Electropop;style,Jam;style,Modal Jazz;style,Chicano Rock;style,Soul Blues;style,Thrash Metal;style,Contemporary Jazz;style,British Blues;style,Italian Prog. Rock;style,Jazz-Rock;style,Southern Soul;style,Raga Rock;style,Doom Metal;style,Shoegaze;style,Contemporary Blues;style,Tulsa Sound;style,Jazz-Rap;style,Chanson;style,Guitar Jazz;style,Power Pop;style,Aussie Rock;style,Britpop;style,Eclectic Prog;style,Arena Rock;style,Glam Rock;style,Romantic;style,Classic Grunge;style,Boogie Rock;style,Noise Rock;style,Post-Grunge;style,Desert Blues;style,New Wave;style,Cantautor;style,Freak Folk;style,Heartland Rock;style,Post-Punk Revival;style,Space Rock;style,Post-Bop;style,Ambiental;style,Alt. Country;style,Bebop;style,Conscious;style,Spanish Folk;style,Fusion;style,Outlaw Country;style,Pop Metal;style,Classic Metal;style,Neo Soul;style,Beat Music;style,Alt. Rap;style,British Metal;style,Chicago Blues;style,Jam Band;style,British Folk-Rock;style,Roots Rock;style,Folk Pop;style,Rockabilly;style,Lo-Fi;style,Soft Rock;style,Baroque Pop;style,R&B;style,Heavy Prog;style,Country Folk;style,Garage Rock Revival;style,Acoustic;style,Garage Rock;style,Symphonic Prog;style,Experimental;style,Hard-Bop;style,Country Rock;style,Neo-Psychedelia;style,Stoner Rock;style,Traditional Pop;style,Crossover Prog;style,Piano Jazz;style,Southern Rock;style,Spanish Rock;style,Swing;style,Songwriter;style,Hi-Fi;style,Pop Rock;style,Indie;style,Acid Rock;style,Americana;style,Electric Blues;style,Blues Rock;style,Live;style,Classic Rock;style,Female Vocal;style,Garage Pop;style,Honky Tonk;style,Hip-Hop Soul;style,Easy Listening;style,Chill-Out Downtempo;style,Nu Jazz;style,Jazz-Pop;style,Old-School;style,Jump Blues;style,Punk Pop;style,Hindustani;style,German Rock;style,Son;style,Jazz-Funk;style,Future Bass;style,House;style,Traditional Country;style,Isicathamiya;style,Comedy;style,Celtic Punk;style,Lounge;style,Proto-Punk;style,Niger Folk;style,Traditional American Folk;style,Psychedelic Grunge;style,Nashville Sound;style,Mexican Rock;style,Dub;style,Renaissance;style,Proto-Prog;style,Folk Metal;style,Uruguayan Rock;style,Folk Punk;style,Modernist;style,Israeli Rock;style,Underground Rap;style,Hair Metal;style,Contemporary Classical;style,Jazz Drumming;style,Folktronica;style,Nubian Folk;style,Melodic Hardcore;style,Funk Metal;style,Reggae Fusion;style,Philadelphia Soul;style,Rap Metal;style,Close Harmony;style,Gypsy-Jazz;style,New Acoustic;style,Flamenco Rock;style,Deep Funk Revival;style,Canterbury Scene;style,Disco;style,Trap;style,Brill Building Sound;style,Spanish Hip-Hop;style,Classic Funk;style,Detroit Blues;style,Gothic Metal;style,Black Metal;style,Electro;style,British Folk-Jazz;style,P-Funk;style,Sludge Metal;style,Contemporary Country;style,Pop Rap;style,Pop Folk;style,Vaudeville Blues;style,New Orleans R&B;style,Synth-Pop;style,Post-Rock;style,Proto-Stoner Rock;style,Baroque;style,Hardcore Punk;style,Tex-Mex;style,Avant-Garde Jazz;style,Horrorcore;style,South Coast;style,Motown Sound;style,Instrumental Country;style,Smooth Jazz;style,Riot Grrrl;style,Cowpunk;style,Glam Metal;style,Memphis Blues;style,Big Band;style,Irish;style,Rockabilly Revival;style,Midwest;style,Torch Songs;style,Free Jazz;style,Medieval;style,Roots Reggae;style,Piano Blues;style,Soul-Jazz;style,Vocal Pop;style,Symphonic Metal;style,Bossa Nova;style,Cool Jazz;style,Psychedelic Soul;style,Latin-Jazz;style,Afro-Cuban;style,Grunge Metal;style,Celtic New Age;style,Surf Rock;style,Hardcore;style,Gangsta;style,Country Pop;style,Delta Blues;style,Pop Punk;style,Grunge Punk;style,American Primitive Guitar;style,Modern Electric Blues;style,East Coast;style,Texas Blues;style,Dixieland;style,Country Boogie;style,Free Improvisation;style,Hill Country Blues;style,Retro Rock;style,Post-Punk;style,Grunge Rock;style,Bluegrass;style,Sadcore;style,Progressive Metal;style,Ska Punk;style,Rock Opera;style,Alt. Metal;style,Mainstream Jazz;style,Pub Rock;style,Sunshine Pop;style,Garage Punk;style,Instrumental Rock;style,Speed Metal;style,Malian Folk;style,Flamenco;style,Trip Hop;style,Bal Folk;style,Detroit Rock;style,Geek Rock;style,Folk Baroque;style,Tishoumaren;style,Smooth Soul;style,Proto-Metal;style,Pagan Folk;style,Traditional European Folk;style,Nu Metal;style,Country Blues;style,Celtic;style,Krautrock;style,West Coast;style,Dream Pop;style,Harmonica Blues;style,Psychedelic Funk;style,Contemporary Funk;style,Psychedelic Rap;style,Argentinian Folk;style,Funk Rock;style,Punk Rock;style,Psychedelic Pop;style,British Psychedelia;style,Contemporary Folk;style,Progressive Folk;style,Argentinian Rock;style,Contemporary Rock;style,90s Rock;style,80s Rock;genre,Música Popular Brasileira;genre,Musical;genre,Indian;genre,Gospel;genre,Japanese;genre,Greek;genre,Nubian;genre,Christmas;genre,New Age;genre,Reggae;genre,Soundtrack;genre,Electronic;genre,Funk;genre,African;genre,Classical;genre,Grunge;genre,Latin;genre,Rock & Roll;genre,Punk;genre,Hip-Hop;genre,World;genre,Pop;genre,Soul;genre,Country;genre,Jazz Vocal;genre,Heavy Metal;genre,Instrumental;genre,Jazz;genre,Folk;genre,Blues;genre,Hard Rock;genre,Alt. Rock;genre,Folk-Rock;genre,Rock;genre,Progressive Rock;genre,Psychedelic Rock;style,Venezuelan Folk;style,Neo-Prog;style,Rond;style,Andro;style,Ska Revival;style,Third Stream;style,Kabuki;style,Japanese Classical;style,Christian Rock;style,Tuareg Music;style,Deep Funk;style,Israeli;style,Afghan Folk;style,Tuvan;style,Asian Folk;style,Jazz-Blues;style,Post-Metal;style,Spoken Word;style,Cumbia;style,Gnawa;style,Candombe Beat;style,Future Jazz;style,Avant-Garde Classical;style,Gothic Rock;style,Sahrawi Folk;style,Dance-Rock;style,Calypso;style,Italian Rock;style,Old-Timey;style,Reggaeton;style,Chillwave;style,Stoner Doom;style,Psychedelic Blues;style,Funk Blues;style,Ragga Hip-Hop;style,Contemporary R&B;style,Choral;style,Polka;style,Afrobeat;style,Radio Program;style,Hang Music;style,Groove Metal;style,Europop;style,Japanese Prog. Rock;style,Jig;style,Circle;style,Traditional Folk;style,Bakersfield Sound;style,Scottish;style,Golden Age;style,Stoner Sludge;style,Bourree;style,Healing Music;style,Doo Wop;style,Zydeco;style,Mauritanian Folk;style,Rumba Fusión;style,Progressive Bluegrass;style,Industrial Metal;style,Exotica;style,Power Metal;style,British Hip-Hop;style,Vals;style,Israeli Folk;style,German Folk;style,Mazurka;style,Afro-Rock;style,Children's Music;style,Griot;style,Acid Jazz;style,Classical Period;style,Mexican Folk;style,Éntekhno;style,Instrumental Hip-Hop;style,Avant-Prog;artist,Trobar de Morte;artist,A Tribe Called Quest;artist,Bob Dylan & The Band;artist,Nancy Sinatra;artist,Ben Harper & The Innocent Criminals;artist,HIM;artist,Nneka;artist,Alice In Chains;artist,Beethoven;artist,Comus;artist,Itoiz;artist,Jamiroquai;artist,The Siegel-Schwall Band;artist,Link Wray;artist,The Kooks;artist,Uncle Tupelo;artist,Blondie;artist,Molly Hatchet;artist,Nilsson;artist,Anacrusa;artist,Buena Vista Social Club;artist,Focus;artist,Muse;artist,The Darkness;artist,Procol Harum;artist,Awon & Phoniks;artist,Poco;artist,Radio Moscow;artist,Rival Sons;artist,The Moody Blues;artist,Lauryn Hill;artist,Stills & Nash;artist,P.O.D.;artist,The Dave Brubeck Quartet;artist,The Troggs;artist,Motorpsycho;artist,Slayer;artist,The Tragically Hip;artist,Traffic;artist,Almendra;artist,Blackalicious;artist,Tito & Tarantula;artist,Fairport Convention;artist,La Raíz;artist,T. Rex;artist,Stills;artist,Nash & Young;artist,Veruca Salt;artist,Vivaldi;artist,Love;artist,Candlebox;artist,Stevie Ray Vaughan & Double Trouble;artist,The Blasters;artist,The Steve Miller Band;artist,The Allman Brothers Band;artist,Elephant Revival;artist,Vox Dei;artist,The Cranberries;artist,Miles Davis Quintet;artist,Cheap Trick;artist,Renaissance;artist,Dover;artist,The Jeff Healey Band;artist,Monster Magnet;artist,Steeleye Span;artist,Journey;artist,Pappo's Blues;artist,Nick Cave & The Bad Seeds;artist,Linkin Park;artist,Bill Evans Trio;artist,Quicksilver Messenger Service;artist,Uriah Heep;artist,Frank Sinatra & The Count Basie Orchestra;artist,The Ozark Mountain Daredevils;artist,Wagner;artist,Joss Stone;artist,Bob Seger & The Silver Bullet Band;artist,Mott The Hoople;artist,The Black Crowes;artist,Blackmore's Night;artist,Bon Jovi;artist,The Pretty Things;artist,Steely Dan;artist,Coldplay;artist,Jimi Hendrix & Curtis Knight;artist,Curtis Knight & The Squires;artist,Magna Carta;artist,Rainbow;artist,The Yardbirds;artist,La Oreja de Van Gogh;artist,Queens Of The Stone Age;artist,Van Halen;artist,Big Brother and The Holding Company;artist,Paul McCartney & Wings;artist,Cypress Hill;artist,Buffalo Springfield;artist,Mark Lanegan Band;artist,Savoy Brown;artist,Son Volt;artist,Them;artist,Mountain;artist,Les Menestriers;artist,The Guess Who;artist,Planxty;artist,John Mayall's Bluesbreakers;artist,Grant Green;artist,Eva Cassidy;artist,Mighty Sam McClain;artist,The West Coast Pop Art Experimental Band;artist,Oasis;artist,Blue Öyster Cult;artist,Heron;artist,Ten Years After;artist,Van Der Graaf Generator;artist,America;artist,Cold Chisel;artist,The Black Keys;artist,Grand Funk Railroad;artist,Mazzy Star;artist,Pixies;artist,The Smashing Pumpkins;artist,The Band;artist,Awon;artist,Pescado Rabioso;artist,The Flamin' Groovies;artist,The 13th Floor Elevators;artist,Heart;artist,Lady Gaga;artist,Small Faces;artist,The Mothers of Invention;artist,The Velvet Underground;artist,Faun;artist,Black Flag;artist,Free;artist,UFO;artist,Derek and The Dominos;artist,Scorpions;artist,R.E.M.;artist,Soundgarden;artist,The Shadows of Knight;artist,Whitesnake;artist,La Pegatina;artist,Platero y Tú;artist,King Crimson;artist,The Robert Cray Band;artist,38 Special;artist,Spirit;artist,Big Star;artist,OutKast;artist,Bob Marley & The Wailers;artist,Nirvana;artist,The Jayhawks;artist,Omnia;artist,Yes;artist,Elvis Costello & The Attractions;artist,Kula Shaker;artist,Red Hot Chili Peppers;artist,Wigwam;artist,Nightwish;artist,The Incredible String Band;artist,Megadeth;artist,Dinosaur Jr.;artist,Phoniks;artist,PJ Harvey;artist,Queen;artist,Passenger;artist,Guns N' Roses;artist,Extremoduro;artist,Tom Petty & The Heartbreakers;artist,Diana Krall;artist,Hawkwind;artist,Captain Beefheart and The Magic Band;artist,Jefferson Airplane;artist,Rush;artist,Eagles;artist,Pearl Jam;artist,Cream;artist,Neil Young & Crazy Horse;artist,Simon & Garfunkel;artist,Creedence Clearwater Revival;artist,The Mamas and The Papas;artist,Barclay James Harvest;artist,Eels;artist,Deep Purple;artist,Aerosmith;artist,Supertramp;artist,Thin Lizzy;artist,Black Sabbath;artist,The Oscar Peterson Trio;artist,Dire Straits;artist,Nat King Cole;artist,The Who;artist,Chet Atkins;artist,Chopin;artist,The Beach Boys;artist,Fleetwood Mac;artist,Iron Maiden;artist,Jethro Tull;artist,Donovan;artist,Santana;artist,The Beatles;artist,The Kinks;artist,The Jimi Hendrix Experience;artist,Led Zeppelin;artist,The Rolling Stones

The string is not displayed. The same on a popup, although the string exists and can be copied/pasted into notepad without problems.

X

X
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: 2tec on 2021-04-11 12:41:56
I'm getting:

Error: Spider Monkey Panel v1.4.1 ({0F768A08-0736-4D01-A78B-C76F049A4A65})
unexpected token: identifier

File: <main>
Line: 1, Column: 21
Source: samples/js-smooth/JS Smooth Playlist Manager.js

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kgena_ua on 2021-04-14 07:39:41
Question.
Simple script
Code: [Select]
    var arr = [0, 1, , 2, 3, 4, , 5, 6, 7, , 8, 9];
    for (var i = 0; i < arr.length; i++) {
        gr.GdiDrawText( arr[i], font, RGB(255, 255, 100), 20, 10 + i * 15, ww, wh, DT_LEFT );
    }
lines "undefined" with SMP.
Is it a mistake or it should be.
Thank you.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-04-14 08:35:38
Question.
Simple script
Code: [Select]
    var arr = [0, 1, , 2, 3, 4, , 5, 6, 7, , 8, 9];
    for (var i = 0; i < arr.length; i++) {
        gr.GdiDrawText( arr[i], font, RGB(255, 255, 100), 20, 10 + i * 15, ww, wh, DT_LEFT );
    }
lines "undefined" with SMP.
Is it a mistake or it should be.
Thank you.

"0, 1, , 2"

There is a hole on the array, so it outputs undefined (as it should be). Remove the hole, or use array.filter(...)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kgena_ua on 2021-04-14 08:52:50
Quote
"0, 1, , 2"
There is a hole on the array...........
regor.
This i know.
I compared the WSH panel and the SM panel. There is no such thing in the WSH panel.
It is clear, it should be on the SM panel.
No problems. Thank you.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-04-14 08:59:54
Quote
"0, 1, , 2"
There is a hole on the array, so it outputs undefined (as it should be). Remove the hole, or use array.filter(...)
regor.
This i know.
I compared the WSH panel and the SM panel. There is no such thing in the WSH panel.
It is clear, it should be on the SM panel.
No problems. Thank you.

Have no idea why it works different in WSH, but the thing you see in SMP is how standard javascript works yep.  WSH may haved extra code to treat undefined strings as empty strings for that func, or it's just a side effect of not using standard js, that's all (which is a problem, since then you can not identify there is a problem and someone may think undefined and '' should be the same, like you).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kgena_ua on 2021-04-14 09:06:27
Quote
but the thing you see in SMP is how standard javascript works
I have not dreamed of this.
Thank you, regor.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-04-15 12:07:59
It should be noted that WSHP and JSP components use JScript, which is actually a separate dialect of ECMAScript and is not the same as JavaScript that's used in all modern browsers (and SMP), hence all the differences like case-sensitivity, different treatment of empty elements in array and etc.
So, even though the names of these languages are (very) similar and they both are based on ECMAScript specifications, they are *not* the same language.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kgena_ua on 2021-04-15 19:03:28
I can't find EnableMenuItem(...).
Or this function is not present in SMP.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-04-16 08:53:57
I can't find EnableMenuItem(...).
Or this function is not present in SMP.
Use search:
https://theqwertiest.github.io/foo_spider_monkey_panel/assets/generated_files/docs/html/

Then on jsp... you are told to use flags
https://github.com/marc2k3/foo_jscript_panel/wiki/Breaking-Changes#v203
Quote
Consider using flags like MF_GRAYED/MF_DISABLED on AppendMenuItem instead. Also, the optional bypos arguments for CheckMenuItem and CheckMenuRadioItem have both been removed. See the updated docs for full details.

Which is how SMP works too
https://theqwertiest.github.io/foo_spider_monkey_panel/assets/generated_files/docs/html/MenuObject.html#AppendMenuItem
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kgena_ua on 2021-04-16 10:38:53
Quote
Consider using flags like MF_GRAYED/MF_DISABLED on AppendMenuItem instead
It's clear.
I mean, one function of EnableMenuItem can replace "ten" lines of code like MF_GRAYED / MF_DISABLED on AppendMenuItem.
If not, then no.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-04-16 19:55:08
It should be noted that WSHP and JSP components use JScript, which is actually a separate dialect of ECMAScript and is not the same as JavaScript that's used in all modern browsers (and SMP), hence all the differences like case-sensitivity, different treatment of empty elements in array and etc.
So, even though the names of these languages are (very) similar and they both are based on ECMAScript specifications, they are *not* the same language.
Thanks Microsoft!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-04-16 19:58:46
I have created an entire framework to create menus on demand. Should be useful for more people at some point. (have edited and added many things  since that post, but until I share it on github, send me a PM and I will share all scripts)
https://hydrogenaud.io/index.php?topic=120394.msg994919#msg994919
I agree it can be simplified, and creating menus with it is just a matter of a few lines. Instead of duplicating codes on callbacks (for ID matching) and checking conditions.
For ex. I have used it to create this menu button (with multiple checks and even custom entries addition/deletion by user): https://hydrogenaud.io/index.php?topic=120394.msg995845#msg995845

But not really sure why you have to write ten lines to disable menus, could you share an example of your code? Maybe I can help.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kgena_ua on 2021-04-18 10:34:24
v 1.4.1
Very rare crashes when just typing a code.
Like crash when passing objects to console.log().
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-04-18 16:32:10
v 1.4.1
Very rare crashes when just typing a code.
Like crash when passing objects to console.log().
What kind of objects are you trying to pass?

Paste some code that's causing crashes.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kgena_ua on 2021-04-20 17:39:46
Crashes.
I didn't get it. I wrote the code ...
Next time I'll try to be more attentive.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-04-21 10:57:39
Crashes.
I didn't get it. I wrote the code ...
Next time I'll try to be more attentive.
Without the code can not help.

Is there any way to access properties from other panels (read only) without on_notify callbacks?
i.e. if you know the window name (something set on the script which doesn't change), instead of forcing other script's authors to add some code for script interaction, you could simply get the properties from its panel and work with that.

For ex. my map script (https://hydrogenaud.io/index.php?topic=120394.msg996483#msg996483) has a selection mode which should match the selection mode of WilB's Biography script if you use them together. I can warn about it with a popup, ask the author to expose that property with NotifyOthers() or offer a modified version by myself... but being able to read properties from any panel would solve that issue, while still rendering NotifyOthers useful for other use cases and be much cleaner.

It would greatly expand and simplify script interoperability for sure.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Mrakobes on 2021-04-22 16:05:34
Please write a script to search for images in the "Covers" folder, which is located in two versions

1. In the same folder with the album
2. One level above the album being played, when listening to a two-disc edition, it is located in the album folder

--

And I also want to set up the viewing of the artist's photo, which has the name of the "Images" and is located in the artist's folder, along with other folders containing albums
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Graes on 2021-04-22 22:22:20
Is it possible to change column ui colors with spider monkey panel? I was trying to change the global selection color, but I'm not really sure how.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-04-23 10:32:05
gdi.Font crashes when size is set to 0.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: anamorphic on 2021-04-23 12:53:06
Please write a script to search for images in the "Covers" folder, which is located in two versions
1. In the same folder with the album
2. One level above the album being played, when listening to a two-disc edition, it is located in the album folder
Most scripts are going to look in the art locations entered in Preferences > Display > Front Cover tab -

Code: [Select]
$if(%discnumber%,..\)Covers\Front.jpg

^ If tracks are tagged with DISCNUMBER, it goes up one level ..\
(Ideally DISCNUMBER field should not be tagged for one-disc releases)

Quote
And I also want to set up the viewing of the artist's photo, which has the name of the "Images" and is located in the artist's folder, along with other folders containing albums
If you mean the folder is named "Images"? Preferences > Display > Artist tab -

Code: [Select]
$if(%discnumber%,..\)..\Images\Artist.jpg

Cheers
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kgena_ua on 2021-04-23 18:39:57
Help.
example:
bg_color = window.GetColourCUI(ColorTypeCUI.background);   
color = bg_color
color  - is Ok.

But if:
bg_color = window.GetColourCUI(ColorTypeCUI.background);   
arr = [bg_color, ... , ...];
color = arr[0]
color  - is nothing.



Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-04-24 11:38:11
Help.
example:
bg_color = window.GetColourCUI(ColorTypeCUI.background);   
color = bg_color
color  - is Ok.

But if:
bg_color = window.GetColourCUI(ColorTypeCUI.background);   
arr = [bg_color, ... , ...];
color = arr[0]
color  - is nothing.

In flags...
Code: [Select]
/ Used in window.GetColourCUI()
var ColourTypeCUI = {
text: 0,
selection_text: 1,
inactive_selection_text: 2,
background: 3,
selection_background: 4,
inactive_selection_background: 5,
active_item_frame: 6
};

I don't see at all how your code can work unless you are using other flags. ColorTypeCUI -> ColourTypeCUI

Code: [Select]
let bg_color = window.GetColourCUI(ColourTypeCUI.background);
let arr = [bg_color];
let color = arr[0] ;
console.log(color);
It's ok
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kgena_ua on 2021-04-25 08:16:30
regor.
Thanks, found a bug
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Mrakobes on 2021-04-25 15:33:33
Please write a script to search for images in the "Covers" folder, which is located in two versions
1. In the same folder with the album
2. One level above the album being played, when listening to a two-disc edition, it is located in the album folder
Most scripts are going to look in the art locations entered in Preferences > Display > Front Cover tab -

Code: [Select]
$if(%discnumber%,..\)Covers\Front.jpg

^ If tracks are tagged with DISCNUMBER, it goes up one level ..\
(Ideally DISCNUMBER field should not be tagged for one-disc releases)

Quote
And I also want to set up the viewing of the artist's photo, which has the name of the "Images" and is located in the artist's folder, along with other folders containing albums
If you mean the folder is named "Images"? Preferences > Display > Artist tab -

Code: [Select]
$if(%discnumber%,..\)..\Images\Artist.jpg

Cheers

I'm sorry, maybe I didn't ask the question fully enough, I'm setting up the in "thumbs" folder

(https://i114.fastpic.ru/thumb/2021/0425/d4/68371846e88cdeb7d1d1b9e3bd7145d4.jpeg) (https://i114.fastpic.ru/big/2021/0425/d4/68371846e88cdeb7d1d1b9e3bd7145d4.png)

My file structure looks like this

(https://i114.fastpic.ru/thumb/2021/0425/47/a6b56bfe0082d04c0c29a6d91eaa2447.jpeg) (https://i114.fastpic.ru/big/2021/0425/47/a6b56bfe0082d04c0c29a6d91eaa2447.png)

Accordingly, the script should display ALL image files, regardless of the name and extension, located in the "Covers" folder, which is sometimes one level higher than the album being played

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-04-27 09:26:02
Another bug.
An infinite loop on the edit script panel (in memory) freezes foobar.
While loading an script file with the same code shows the popup about the script taking too much time, thus letting you abort execution. The behavior should be the same in both.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-04-27 10:00:13
So you've been bitten by your own stupidity? Learn from it.

edit: I know I've made the same mistake more than once but at least I blame myself each time.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-04-27 10:06:57
So you've been bitten by your own stupidity? Learn from it.

edit: I know I've made the same mistake more than once but at least I blame myself each time.
?? That's not the point. The point is the script should be halted the same than it does when called outside the edit script panel. What has blaming to do with that?
Quote
The behavior should be the same in both.

Either you always halt infinite loops with a popup, or you don't. But it makes no sense to do one thing in one window and another thing in the main window.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: anamorphic on 2021-04-27 13:11:11
I'm sorry, maybe I didn't ask the question fully enough, I'm setting up the in "thumbs" folder
I see. The "Thumbs.js" script just wants an absolute path to the image folder. So you could try something like -

D:\Music\%album artist%\%date% - %album%\Covers

^ Change drive letter and music folder to your setup. You might have to experiment, depends on your tags.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-04-27 17:51:36
Quote
The behavior should be the same in both.

Either you always halt infinite loops with a popup, or you don't. But it makes no sense to do one thing in one window and another thing in the main window.
Except for the fact that it's probably very easy for the component to check if your script is taking too long to load, and it's not necessarily easy at all to tell if user interaction has caused a script to enter into an infinite loop.

We've all done it. Just kill foobar and restart after fixing the issue.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-04-27 19:16:53
Quote
The behavior should be the same in both.

Either you always halt infinite loops with a popup, or you don't. But it makes no sense to do one thing in one window and another thing in the main window.
Except for the fact that it's probably very easy for the component to check if your script is taking too long to load, and it's not necessarily easy at all to tell if user interaction has caused a script to enter into an infinite loop.

We've all done it. Just kill foobar and restart after fixing the issue.
Obviously I knew there was something wrong on the code, was checking exactly that.  Not sure why both are trying to convince me about anything though XD

https://github.com/TheQwertiest/foo_spider_monkey_panel/compare/v1.1.5...v1.2.0
Quote
Added slow script handling: script can be aborted now if it's unresponsive for some time.

SMP halts execution for scripts taking too much time and it doesn't work when pressing apply on the edit script panel, even if it's tied to an external script; but works in any other case. TheQwertiest may want to check it or not, but that's seems to be a bug since it does not work as it was supposed to work. That's all. lol.

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-04-28 05:04:34
SMP halts execution for scripts taking too much time and it doesn't work when pressing apply on the edit script panel, even if it's tied to an external script; but works in any other case. TheQwertiest may want to check it or not, but that's seems to be a bug since it does not work as it was supposed to work. That's all. lol.
Actually you're probably right here. Can you share a minimally reproducible code sample?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-04-28 09:02:10
My guess is that it's modal dialog related. Since the config window is modal, it blocks any other modals spawned from scripts while its open.

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kgena_ua on 2021-05-02 05:12:53
Please, help.
I have never encountered such an error. What is the problem ?
When can this message appear?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-05-02 05:18:00
Please, help.
I have never encountered such an error. What is the problem ?
When can this message appear?

The problem is explained in the error message. Something in the script is taking a long time (a tight loop/infinite loop, blocking waiting for an API response, etc.) and the component is making sure you want to continue waiting as your scripts are currently unable to process callbacks. If this is a common occurrence you might need to refactor your code to use promises or something similar so that you don't block script execution.

This was what regor was complaining wasn't working for him above.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kgena_ua on 2021-05-02 05:27:27
MordredKLB,
thank you.
The problem is that I have not personally encountered such an error. And so I don’t understand where to look for it.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-05-02 10:38:12
SMP halts execution for scripts taking too much time and it doesn't work when pressing apply on the edit script panel, even if it's tied to an external script; but works in any other case. TheQwertiest may want to check it or not, but that's seems to be a bug since it does not work as it was supposed to work. That's all. lol.
Actually you're probably right here. Can you share a minimally reproducible code sample?

Quote
My guess is that it's modal dialog related. Since the config window is modal, it blocks any other modals spawned from scripts while its open.

Any code. It's a problem with the window as said.

Code: [Select]
let i = 1;
while (i) {
 console.log('h');
}
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-05-02 10:42:42
MordredKLB,
thank you.
The problem is that I have not personally encountered such an error. And so I don’t understand where to look for it.

Press stop, and take a look at the console where the script was stuck. The console will show you the lines and function.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-05-03 18:26:30
I added a new debugging function to my Georgia theme, and I'm sharing it here because I thought some other people might find it useful. What it does is highlights the areas which are marked for repainting through RepaintRect. I kind of did it as a whim when doing some performance testing in my draw code, but it's helped me track down several other bugs that I wasn't aware I even had.

Code: [Select]
let repaintRects = [];
let drawRepaintRects = true;
window.oldRepaintRect = window.RepaintRect;
window.RepaintRect = (x, y, w, h, force = undefined) => {
if (drawRepaintRects) {
repaintRects.push({ x, y, w, h });
window.Repaint(); // must do a full repaint otherwise old outlines won't clear
} else {
window.oldRepaintRect(x, y, w, h, force);
}
}

// then in your on_paint
on_paint(gr) {
// ... all your other draw code first...
if (repaintRects.length) {
repaintRects.forEach(rect => gr.DrawRect(rect.x, rect.y, rect.w, rect.h, 1, rgba(255,0,0,175)));
repaintRects = [];
}
}
I added it to a menu option so I can toggle it on and off as needed.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: paregistrase on 2021-05-04 03:29:31
Hi people!

Sorry to bother you all but maybe one of you can help me.

I'm running foobar with wine in ubuntu, with the lastest versions of wine the spider monkey scripts works without instaling ie8 (that need a 32 prefix and mess a lot of things).

But I have a little problem with some script (biography and Library Tree) when i used the right button the panel crahed and give this:

Code: [Select]
Error: Spider Monkey Panel v1.4.1 (Biography: Biography v1.1.3 by WilB)
WinAPI error:
  ActiveXObject failed with error (0x80004001):
    No implementado.

File: <main>
Line: 1947, Column: 24
Stack trace:
  MenuItems/this.rbtn_up@<main>:1947:24
  on_mouse_rbtn_up@<main>:3629:94

and in the Library Tree with right button in the search field:

Code: [Select]
Error: Spider Monkey Panel v1.4.1 (Library Tree: Library Tree v2.1.3 by WilB)
WinAPI error:
  ActiveXObject failed with error (0x80004001):
    No implementado.

File: Library Tree 2.1.3.js
Line: 2234, Column: 31
Stack trace:
  SearchLibrary/this.rbtn_up@Library Tree 2.1.3.js:2234:31
  on_mouse_rbtn_up@Library Tree 2.1.3.js:2894:108


Have any of you some clue how can i workaround this?

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: WilB on 2021-05-04 10:51:56
It's seems it's the ActiveXObject('htmlfile') it doesn't like. I don't know if there's an alternative that could be used.

In the meantime the errors may be fixed by:

Biography: change line 1947 to the following:

Code: [Select]
const docTxt = ''/*s.doc.parentWindow.clipboardData.getData('text')*/; let idx, Index = 1;

Library tree: change line 2234 to:

Code: [Select]
this.rbtn_up = (x, y) => {men.search_menu(x, y, b, f, false)/*doc.parentWindow.clipboardData.getData('text') ? true : false)*/;}

This will disable a couple of minor paste from clipboard events, i.e. pasting custom bios & reviews in biography, and pasting in the search bar of library tree.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-05-04 12:59:20
Is there any way to retrieve the query from an autoplaylist already created? Can retrieve the name, the index, even the handle list, but I see no way to get the query which created it.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: paregistrase on 2021-05-04 14:56:23
It's seems it's the ActiveXObject('htmlfile') it doesn't like. I don't know if there's an alternative that could be used.

In the meantime the errors may be fixed by:

Biography: change line 1947 to the following:

Code: [Select]
const docTxt = ''/*s.doc.parentWindow.clipboardData.getData('text')*/; let idx, Index = 1;

Library tree: change line 2234 to:

Code: [Select]
this.rbtn_up = (x, y) => {men.search_menu(x, y, b, f, false)/*doc.parentWindow.clipboardData.getData('text') ? true : false)*/;}

This will disable a couple of minor paste from clipboard events, i.e. pasting custom bios & reviews in biography, and pasting in the search bar of library tree.


That do the trick. No more crash in right button click.

I can live without the copy and paste in bio (I never used it anyway) and the search bar is a little inconvenient but better than crash  :))

Thanks you very much
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Sue Dunham on 2021-05-04 19:23:01
I'm trying to make a toolbar button that will open a locally-stored web page, and I've gotten most of the way there with foo_run, as follows:

This works as long as there is a track selected in the playlist, but not otherwise: the handle is null and the panel crashes. Running the command inside a try statement avoids the crash, but the fact is that the command itself doesn't actually use the handle in this case; the handle simply has to be there to use Run service for anything. I have tried using fb.RunContextCommand instead of fb.RunContextCommandWithMetadb, but that didn't do anything.

Is there another way to open a local file in the default browser? I gather that javascript itself intentionally does not do that sort of thing, but is there an alternative foobar command that can do that? Alternately, is there a way I can fashion a valid dummy handle to give to foo_run?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-05-04 20:45:14
I'm trying to make a toolbar button that will open a locally-stored web page, and I've gotten most of the way there with foo_run, as follows:
  • I've created the command Run service/Button image sources that opens the path to the html file.
  • I've modified the playback buttons.js sample script to include the button. A handle variable is set equal to fb.GetFocusItem(), and the command is called with fb.RunContextCommandWithMetadb('Run service/Button image sources', handle)

This works as long as there is a track selected in the playlist, but not otherwise: the handle is null and the panel crashes. Running the command inside a try statement avoids the crash, but the fact is that the command itself doesn't actually use the handle in this case; the handle simply has to be there to use Run service for anything. I have tried using fb.RunContextCommand instead of fb.RunContextCommandWithMetadb, but that didn't do anything.

Is there another way to open a local file in the default browser? I gather that javascript itself intentionally does not do that sort of thing, but is there an alternative foobar command that can do that? Alternately, is there a way I can fashion a valid dummy handle to give to foo_run?

It's simple. run services is only found on contextual menus. And those always require a handle, even if your command does nothing with it. It's a limitation of the component (run services, which could have a main menu command).
Therefore, you must check if handle is null.
Code: [Select]
const handle = fb.GetLibraryItems()[0];
if (handle) {
    fb.RunContextCommandWithMetadb('Run service/cdrtfe', handle);
}
That should always work if your library is not empty, since handle will never be null.

I have tried passing an empty handle list but it failed (maybe due to my code), anyway you can try yourself with this:
Code: [Select]
const handle =new FbMetadbHandleList();
...
The first approach should always work. Not sure if SMP should allow a dummy handle though for these cases.

Code: [Select]
Is there another way to open a local file in the default browser? I gather that javascript itself intentionally does not do that sort of thing, but is there an alternative foobar command that can do that? Alternately, is there a way I can fashion a valid dummy handle to give to foo_run?

There are multiple ways to do that with ActiveXObject (http://file:///C:/Users/XXX/AppData/Roaming/foobar2000/user-components/foo_spider_monkey_panel/docs/html/ActiveXObject.html), and then using the SO methods to run a file, an executable, load an html, etc.

Code: [Select]
let WshShell = new ActiveXObject('WScript.Shell');
WshShell.Run('https://hydrogenaud.io/');
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Sue Dunham on 2021-05-05 00:13:18
Ah, that ActiveXObject approach is just what I was looking for, thanks. ;D In this case, it seems that WshShell was already declared by one of the included scripts, so I just needed the Run command.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-05-05 23:24:33
@TheQwertiest you may want to add the scripts to your list (https://theqwertiest.github.io/foo_spider_monkey_panel/docs/script_showcase/) now that they are public:
There are 4 scripts ready to use on panels. And 2 helpers for other people's projects (+2 more on the future).
https://github.com/regorxxx
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-05-07 17:57:14
I had a "brilliant" idea that we could drastically speed up drawing rotated images by using RotateFlip for multiples of 90 degrees instead of the pGdi_->SetTransform and DrawImage combo that FSM currently uses in all cases. Took a little while to get working correctly, but it works! Drawing speed to rotate an image 180 degrees was 50-75% faster (for an ~800x800 image 20-30ms -> 5-8ms). Hooray!

Of course then I realized that despite perfectly symmetrical images, the rotated result with RotateFlip is somehow moved slightly? More probably it's that the DrawImage in conjunction with a matrix transform output is altered from the original a pixel or so in the x/y/w/h. Either way, they give different results and rotating an image through 89.9, 90, and 90.1 degrees causes a noticeable jump in the perceived image location, then a jump back.

Ended up reverting all my FSM changes. This is how you lose half a day :)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-05-12 20:32:32
Would it be possible to set lock states of playlists? It would be immediately added to Playlist tools (https://github.com/regorxxx/Playlist-Tools-SMP), since it's naturally related.
plman.setLockPlaylist(playlistIndex, state)

foo_playlist_attributes or foo_utils could be replaced with methods by SMP (thus freeing dll (https://hydrogenaud.io/index.php?topic=84947.msg991336#msg991336) slots and startup), while still allowing to replicate at least some of their use-cases.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Sue Dunham on 2021-05-13 17:06:30
I hope that this is a good place for a general js question. I've modified the samples/complete/playback buttons.js file to create a toolbar, and there are two toggling buttons on it that are related to one another. I would like to enable or disable the second of them depending on the state of the first.

The buttons themselves are defined thusly:
Code: [Select]
buttons.update = () => {
    // other buttons omitted
    buttons.buttons.editor = new _button(bs * 8, 0, bs, bs,
        {normal : window.GetProperty('editorshown', fso.FileExists(filepath))
        ? bp + 'player_cool.png' : bp + 'editor_cool.png',
        hover : window.GetProperty('editorshown') ? bp + 'player_hot.png'
        : bp + 'editor_hot.png'},
        (x, y) => { toggle_editor(); }, 'Editor/player');
    buttons.buttons.showgroups = new _button(bs * 9, 0, bs, bs,
        {normal : window.GetProperty('groupsshown')
        ? bp + 'grouphide_cool.png' : bp + 'groupshow_cool.png',
        hover : window.GetProperty('groupsshown')
        ? bp + 'grouphide_hot.png' : bp + 'groupshow_hot.png'},
        (x, y) => { toggle_groups(); }, 'Show/hide groups (editor)');

That toggle_editor function is as follows and is where I'd like to put the enabling/disabling of the showgroups button. At the moment, it toggles a window property to set the editor button's images and creates/deletes an empty file in order to tell a panel stack splitter to hide some elements and show others.

Code: [Select]
function toggle_editor() {
    if (window.GetProperty('editorshown')) {
        window.SetProperty('editorshown', false);
        fso.DeleteFile(filepath);
    } else {
        window.SetProperty('editorshown', true);
        fso.CreateTextFile(filepath).Close();
    }
    buttons.update();
    window.Repaint();
}

So how can a javascript neophyte enable or disable a button like this? My searches turn up various ways of using javascript to interact with HTML buttons or what have you, but I can't tell if I've found anything dealing with a pure js setting. Would graphic actions like producing the "grayed out" effect happen automatically, or would I need to make another png for that?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-05-13 17:24:18
There are multiple ways, but adding a simple boolean would do.

Code: [Select]
let bEnable = true;  // note this is outside the function, global var
function toggle_editor() {
   bEnable = !bEnable; // Just changes true -> false, false -> true
    if (window.GetProperty('editorshown')) {
        window.SetProperty('editorshown', false);
        fso.DeleteFile(filepath);
    } else {
        window.SetProperty('editorshown', true);
        fso.CreateTextFile(filepath).Close();
    }
    buttons.update();
    window.Repaint();
}

Then you add that check on the button you want to change. I'm not really sure if you want to delete the button, left it there but doing nothing, changing its appearance to reflect the change, but...

Code: [Select]
    buttons.buttons.showgroups = new _button(bs * 9, 0, bs, bs,
        {normal : window.GetProperty('groupsshown')
        ? bp + 'grouphide_cool.png' : bp + 'groupshow_cool.png',
        hover : window.GetProperty('groupsshown')
        ? bp + 'grouphide_hot.png' : bp + 'groupshow_hot.png'},
        (x, y) => {
                if (!bEnable) {return;} // Don't do anything if it's false
                toggle_groups();
        }, 'Show/hide groups (editor)');

Finally, adjust the initial state of bEnable according to how you want it to work.  You should be able to expand the idea to change the other parts (like using a different png according to the boolean, etc.)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2021-05-13 18:26:18
Hello,

does anyone know how to fix the ActiveX htmlfile error?:

ActiveXObject_Constructor failed:
Failed to create ActiveXObject object via CLSID: htmlfile
const doc = new ActiveXObject('htmlfile');

Is there a fix or workaround?
I am using the latest Spider Monkey Panel v1.4.1 with foobar 1.6.5...

Thank you

- TT
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-05-14 06:36:11
There was a long discussion in another thread (https://hydrogenaud.io/index.php?topic=114686.175) about slow performance of FSM scripts at startup. Seems that some of us, in certain conditions, have very poor performance (15-30sec startup times). This was immediately apparent to me when switching Georgia from jscript_panel, but I thought I was the only one. That wasn't the case, and an argument about the root cause and what happens at startup got me thinking.

I forked the current FSM codebase and made some changes to how FSM itself starts up, essentially delaying initialization of several required services to the component's on_init() which is when foobar says "it's okay" to start loading stuff. In most instances this has improved my foobar startup time 3-5x. Results may vary and if you weren't experiencing slow startup with FSM scripts, then this may not do anything for you.

This is a dev (unreleased) build from Feb so it was has a few things in it post the last 1.4.1 release, plus my code of course. Should be safe to use. Hopefully we can get a few more eyes on this to see if others see improvements on startup time and make sure there are no unintended consequences.

Pull request can be found here (https://github.com/TheQwertiest/foo_spider_monkey_panel/pull/138).

Edit: Dev component removed due to crashes.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-05-14 10:27:27
Fails with Gdiplus errors in default UI. More detail on github.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2021-05-14 16:02:52
Hello,

does anyone know how to fix the ActiveX htmlfile error?:

ActiveXObject_Constructor failed:
Failed to create ActiveXObject object via CLSID: htmlfile
const doc = new ActiveXObject('htmlfile');

Is there a fix or workaround?
I am using the latest Spider Monkey Panel v1.4.1 with foobar 1.6.5...

Thank you

- TT

You need to install the Gecko support in Wine to have basic HTML controls, and even then, it's not guaranteed to be compatible with Windows.

For anyone else that has the same problem running foobar in Wine, installing Gecko solved the problem.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2021-05-14 22:43:17
Does anyone know if utils.CheckFont and gdi.Font are working correctly under Wine?

I've put custom ttf fonts in /usr/share/wine/fonts and ~/.wine/drive_c/Windows/fonts
and it seems are not initialized with utils.CheckFont and loaded via gdi.Font in SMP...

If I change for example the font in Preferences -> Columns UI -> Colors and fonts, the font to the custom font changes and is displayed correctly!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-05-14 22:56:46
Try a .fonts folder inside your linux HOME folder.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-05-14 23:23:18
@snotlicker can you try with the following version and see if you still get crashes?

This test did not show any improvements. Removing custom build.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2021-05-14 23:29:06
Try a .fonts folder inside your linux HOME folder.

Didn't work :( ,

I also tried from etc/fonts/fonts.conf
/usr/share/fonts and /usr/local/share/fonts

without luck...

@TheQwertiest Do you know what's up with https://hydrogenaud.io/index.php?topic=116669.msg997682#msg997682 ?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-05-15 00:23:08
@snotlicker can you try with the following version and see if you still get crashes?

This build works. Tested CUI and DUI.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-05-15 01:34:09
Try a .fonts folder inside your linux HOME folder.

Didn't work :( ,

I also tried from etc/fonts/fonts.conf
/usr/share/fonts and /usr/local/share/fonts

without luck...

@TheQwertiest Do you know what's up with https://hydrogenaud.io/index.php?topic=116669.msg997682#msg997682 ?

What I said was the right folder. You probably need to install gdiplus via winetricks.

In this screenshot, the buttons on the bottom right require FontAwesome....

(https://i.imgur.com/zbDWuWZ.png)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: tyronatyson756 on 2021-05-15 13:53:28
Reporting an issue (a skin used, I don't know if this matters): https://hydrogenaud.io/index.php?topic=117595.msg997731#msg997731
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-05-18 23:14:03
FYI: I will try to make some time this month (as in next 30 days), though I don't think there will be a lot of new features in SMP (if any), but it should contain some API and package handling fixes.

My current plan is the following:
- SMP: fix reported bugs. Focus on package support.
- foo_spotify: fix all the reported bugs.
- CaTRoX theme: release SMP version.
- foo_discord_rich: implement the `last` feature (it will be probably the last feature release, since Discord doesn't develop their API much).
- SMP: work on new features.
- foo_spotify: work on new features.

It should be said, that even if I'm not answering here, it doesn't mean that your messages are being ignored or forgotten (or not appreciated), most of them were stored in my `to_do.txt` (that I'm too lazy to transfer to GH properly)...
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Black_Over_Bills_Mothers on 2021-05-19 06:37:02
@TheQwertiest
Great to know you still intend to develop SMP. With all the new stuff going into JScript panel I was wondering about changing back.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-05-19 22:31:18
Have found a weird behaviour while working on the playlist manager, because I have just set the shift key as a shorcut to delete files and it was not working...

Lets say I have this recycle function
Code: [Select]
function _recycleFile(file) {
if (_isFile(file)) {
try {
app.NameSpace(10).MoveHere(file);
} catch (e) {
return false;
}
return !(_isFile(file));
}
return false;
}

If I'm pressing SHIFT while the panel run this part, then the file is deleted without being sent to the recycle bin. Which is pretty weird since I'm using a moveHere function on the end... (I suppose's it's related to the shift+delete behaviour of win, but this is not a "delete" operation)
Code: [Select]
_recycleFile(newPath);

But this is even worse:
Code: [Select]
if (utils.IsKeyPressed(VK_SHIFT)) {
const debouncedRecycle = debounce(() => {
if (utils.IsKeyPressed(VK_SHIFT)) {
debouncedRecycle(newPath);
return;
} else {_recycleFile(newPath);}  // It "magically" works after some ms even if the key is still pressed
}, 100);
debouncedRecycle();
} else {_recycleFile(newPath);}

// Where debounce is:
const debounce = (func, delay, immediate) => {
let timerId;
return (...args) => {
const boundFunc = func.bind(this, ...args);
clearTimeout(timerId);
if (immediate && !timerId) {
boundFunc();
}
const calleeFunc = immediate ? () => {timerId = null;} : boundFunc;
timerId = setTimeout(calleeFunc, delay);
};
};

So the last code sends the file to the recycle bin even if I'm pressing shift indefinitely (?). Which is good since that's what I want in the end, but not what I expected at all hahaha

utils.IsKeyPressed(VK_SHIFT) returns false at the third or fourth try. even if I'm pressing the key. Am I missing something? (like a timer for pressed keys)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-05-20 00:42:26
Instead of using a debounce, what if you just do a simple busy wait?

Code: [Select]
while(utils.IsKeyPressed(0x10)) {}
_recycleFunc(file);
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-05-20 01:51:10
If isKeyPressed worked as it was supposed to do, that would hang execution of the rest of the code indefinitely while you maintain the key pressed.  I don't care when the file is deleted, so I don't need at all to do it in a synchronous way. I can tolerate deletion being post-poned, not the other code.
Anyway, that's not the point (?).  It seems it's a tradition of this forum to give answers not related to the questions hahaha

The question: Why "isKeyPressed" returns false at some point while pressing the key without releasing it?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-05-20 02:04:30
If you want to do something when the key is released, use on_key_up. I would have thought that was obvious.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-05-20 02:05:45
If you want to do something when the key is released, use on_key_up. I would have thought that was obvious.
That's obvious, but that doesn't explain why isKeyPressed returns false when the key is still pressed.

Or we should name that function "maybeIsKeyPressedOrMaybeNot"? Cmon...
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-05-20 02:22:47
IsKeyPressed is provided by the foobar2000 SDK.

Code: [Select]
bool IsKeyPressed(unsigned vk) {
return (GetKeyState(vk) & 0x8000) ? true : false;
}

GetKeyState is a Windows API method and you can read more about it here.

https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getkeystate

Don't like it? Don't use it.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-05-20 07:55:32
If isKeyPressed worked as it was supposed to do, that would hang execution of the rest of the code indefinitely while you maintain the key pressed.  I don't care when the file is deleted, so I don't need at all to do it in a synchronous way. I can tolerate deletion being post-poned, not the other code.
Anyway, that's not the point (?).  It seems it's a tradition of this forum to give answers not related to the questions hahaha

The question: Why "isKeyPressed" returns false at some point while pressing the key without releasing it?
It was related to your question, as I was wondering if your debounce implementation was doing something weird, especially because you have your debounce just implementing a set timeout essentially (maybe it makes sense in broader context). Regardless, it seems like it's doing something funny because I can't replicate your issue (the busy wait hangs foobar interestingly). This works perfectly fine:
Code: [Select]
function on_key_down(vkey) {
let count = 0;
const test = setInterval(() => {
if (!utils.IsKeyPressed(VK_SHIFT)) {
console.log('shift is not down');
clearInterval(test);
}
count++;
if (count > 100) {
console.log('stopped waiting')
clearInterval(test);
}
},25);
}
It also works perfectly fine in on_key_up it will wait forever until I let go of shift if I increase the max count... which it certainly sounds like what you want.

Could be an issue with your keyboard or something in the OS (stickykeys/filterkeys maybe? I know those are related to holding shift)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-05-20 09:18:22
Well I tested it on win 10 and the same code does what it's supposed to do. i.e. it always returns true while the key is pressed, and as result my file is never deleted (while pressing shift). Also tried with multiple variants... loops, intervals, etc. All are fine.

Yesterday I was working on win 7. So I think that we got another function (like utils.FileTest() ) behaving different in win 7 and win 10.
Will check all tests again on the other PC asap, but if it's another SO behavior mismatch the func is totally broken on win 7.

Quote
Could be an issue with your keyboard or something in the OS (stickykeys/filterkeys maybe? I know those are related to holding shift)

I don't use any of that. But I will check it since I have access to multiple PCs with win 7.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-05-22 00:16:20
So this is gonna be an odd question and I fully realize off the bat that I am probably not using FSM as intended. That said, let's talk about complex animations!

In Georgia 2.0.2 I added spinning cdArt. Uses a ton of memory and some CPU but looks pretty cool. For 2.0.3 that's about to release I added a bunch of different options to control # of images cached and how quickly those images refresh. I've done a TON of optimization on this front to ensure that my on_paint's happen as quickly as possible. My screen refresh rate is 60Hz, but obviously 16.6ms is too fast to do anything complex and for rotation the max speed I even attempt is 75ms or roughly 13fps. Because I'm caching the cdArt (drawing rotated images is way too slow) each on_paint for the cd image takes around 7-10ms on a 4k monitor at full screen -- 1080p monitor we're talking 3-6ms. This should be really easy to do smoothly. However, it appears that FSM is somehow dropping frames at times. Rotation of the image jerks and skips every 4-5 images as images are skipped.

Now you might think this is just judder related to refreshes happening every 4 or 5 frames (sometimes 6 if things slow down), but frames are actually being dropped. If you open this youtube video (https://youtu.be/DraOh5CEVm0) and slow it down to .25x it's easy to see that some numbers are skipped meaning that even though the on_paint is happening (console logs show every image being drawn) the screen never gets updated.

@TheQwertiest is there any possible solution for this?

Nevermind. Seems nVidia has changed my desktop refresh rate back to 23Hz after watching a movie. Setting it back to 60Hz and animation is smooth like butter. I feel dumb.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kgena_ua on 2021-05-22 19:41:10
Quote
utils.WriteTextFile(fn, text, bom)
"bum" - Help. I can't understand what it means.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-05-22 22:49:20
Quote
utils.WriteTextFile(fn, text, bom)
"bum" - Help. I can't understand what it means.
BOM is Byte-Order Mark. It's used by programs reading the file to determining the endian-ness of a file. If that sentence means nothing to you, don't worry about it. You don't need to include it when calling WriteTextFile (it defaults to true) so you can just do:
Code: [Select]
utils.WriteTextFile(filename, text);

You only need to worry about that setting if you're writing files that another program that isn't foobar is reading.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MojoBass on 2021-05-23 05:37:28
@MordredKLB , SMP doesn't support .webp images.
Are there any news on WebP on SMP? This format is used quite often in YT thumbnails, I miss them e.g. at SMP-based Georgia from @MordredKLB or Biography from @WilB. In Marcs JSP scripts such as 'Album Art' or 'Track Info + Seekbar + Buttons', WebP-based YT thumbnails are shown without any problems.
Would be great to be available as well for SMP-based scripts.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-05-23 21:54:29
Well I tested it on win 10 and the same code does what it's supposed to do. i.e. it always returns true while the key is pressed, and as result my file is never deleted (while pressing shift). Also tried with multiple variants... loops, intervals, etc. All are fine.

Yesterday I was working on win 7. So I think that we got another function (like utils.FileTest() ) behaving different in win 7 and win 10.
Will check all tests again on the other PC asap, but if it's another SO behavior mismatch the func is totally broken on win 7.

Quote
Could be an issue with your keyboard or something in the OS (stickykeys/filterkeys maybe? I know those are related to holding shift)

I don't use any of that. But I will check it since I have access to multiple PCs with win 7.

Have tested it again and ... the same code did not work as expected on win 7. Tried multiple things without luck (specially following MordredKLB thoughts about some keyboard filter on background) and finally after reinstalling SMP component it worked. So have no idea what was going on but now there is no bug. Consider it solved (?).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-05-25 20:16:20
Are there any news on WebP on SMP? This format is used quite often in YT thumbnails, I miss them e.g. at SMP-based Georgia from @MordredKLB or Biography from @WilB. In Marcs JSP scripts such as 'Album Art' or 'Track Info + Seekbar + Buttons', WebP-based YT thumbnails are shown without any problems.
Would be great to be available as well for SMP-based scripts.
@MojoBass see discussion here:
https://github.com/TheQwertiest/foo_spider_monkey_panel/issues/111

Seems marc did some work to get this to work well in JSP, but currently SMP just can't handle webp.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: paregistrase on 2021-05-26 04:05:35
In the details tab of properties and "selection properties" panel.there is a SMP section with playcount values, always empty.

Which script do they belong to? are they necessary to SMP proper operation?

If not....Is there a way to disabled?

It's weird to have repeated values in the "selection properties" panel.


Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MojoBass on 2021-05-26 05:11:04
see discussion here:
https://github.com/TheQwertiest/foo_spider_monkey_panel/issues/111
Seems marc did some work to get this to work well in JSP, but currently SMP just can't handle webp.
@MordredKLB : thanks for the info!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-05-26 08:33:07
In the details tab of properties and "selection properties" panel.there is a SMP section with playcount values, always empty.

Which script do they belong to? are they necessary to SMP proper operation?

If not....Is there a way to disabled?

It's weird to have repeated values in the "selection properties" panel.

I've submitted a pull request on github that fixes this. You'll have to wait and see if it gets accepted or not.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: paregistrase on 2021-05-26 16:29:27
In the details tab of properties and "selection properties" panel.there is a SMP section with playcount values, always empty.

Which script do they belong to? are they necessary to SMP proper operation?

If not....Is there a way to disabled?

It's weird to have repeated values in the "selection properties" panel.

I've submitted a pull request on github that fixes this. You'll have to wait and see if it gets accepted or not.

Cool  8)



Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-05-31 16:58:54
Is there some way to replicate the shortcut tip of foobar menus on SMP?

X

Note they are aligned to the right and don't make the menu to be bigger! If you simply add that string to the menu text, it just increases the width, so you could make it "centered" leaving blank spaces but never like the image.

It would be a wonderful addition to add shortcuts in a clear way.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-05-31 18:00:59
Just use \t like this:

Code: [Select]
menu.AppendMenuItem(MF_STRING, 1, "Search\tCtrl+F");
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-05-31 19:17:51
Just use \t like this:

Code: [Select]
menu.AppendMenuItem(MF_STRING, 1, "Search\tCtrl+F");
Works perfectly. Thanks! Thought it was somehow hard-coded.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-05-31 20:03:12
Now I think I found some weird behavior.

On_key_up(vkey) needs as requirement "Grab focus" enabled in the Configuration window.

But there is no such thing for external scripts, only for packages (!).

So I thought.. hey lets use DefinePanel(). I know it's deprecated but thats why I had on all my scripts yet.
grab_focus is not supported there according to the documentation, have not tried it though.
So I replaced DefinePanel with DefineScript, put the option and bingo it works.

The thing is... I reverted the changes and used again DefinePanel(). And that option remained active. i.e. I can still use key callbacks. Reloading the panel or restarting foobar obviously doesn't change anything.

Not necessarily a bug, since it makes sense that the option remains active until you directly change it. But since there is no UI to change it in standard scripts, it's really weird...

Scripts:
X

Packages
X
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-06-01 12:29:54
Another 2 questions.

Does on_char(code) require panel focus? I have not been able to use it for global shortcuts without the mouse clicking on the panel first, but the documentation does not say anything about it. (while it does on on_key_down/...)

And then.. is there some way to add global shortcuts without panel focus? (without using intervals)

Code: [Select]
var keyCallbackDate = Date.now();
function keyCallback() {
if (Date.now() - keyCallbackDate <= 500) {return;} // Limit rate to 500 ms
let bDone = false;
Object.keys(shortcuts).forEach((key) => {
if (bDone) {return;}
const shortcut = shortcuts[key];
if (utils.IsKeyPressed(shortcut.val) && (shortcut.mod === -1 || utils.IsKeyPressed(shortcut.mod))) {shortcut.func(shortcut.menu); bDone = true;}
});
if (bDone) {keyCallbackDate = Date.now();}
}
repeatFn(keyCallback, 100)();

Well that doesn't work as expected since it's really "global", and works even with the main foobar window not being in focus.

Adding if (!window.IsVisible) {return;} does not work as intended if using alt-tab. Since the panel window is considered to be visible even if the main program is not on focus (nor in the screen at all). When it's minimized it seems to work though.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-06-01 14:23:21
To make shortcuts global, components have to expose main menu or context commands that can be bound in the main preferences dialog. This is why on_main_menu exists but take care to understand the notes I included when I implemented it.

Quote
On the main menu>File>Spider Monkey Panel, there are 10 menu items and whichever number is selected is sent as the "index" to this callback.
Being main menu items now means you can bind them to global keyboard shortcuts, standard toolbar buttons, panel stack splitter buttons, etc.
Remember to think carefully about where you use this code as you probably only want it to run once and so don't include it in common files and scripts where you might have multiple instances.
Important: you should avoid sharing scripts containing this code so as not to conflict with what other users may already be using.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-06-01 15:41:49
I knew that option, but that's not what I would want to do at all since it involves -as you noted- replacing the main menu entries. Also it's limited to 10 entries, etc. That part requires a rework to be really usable by multiple scripts.
And also it doesn't work as I would want, since it would still require user input to bind shortcuts to those associated entries (which have no names but only 1,2,3..). Too many loops to assign a shortcut to a menu entry in a script (and I have no way to retrieve which keys are set).

Anyway, apart from that. I don't really understand why utils.IsKeyPressed() works even when foobar is not on focus. That doesn't seem to be right if there is no option to limit key checking only when foobar is on focus. Or a "fb.IsVisible" check could simply solve it too. Where it checks if the main window is visible.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-06-01 15:59:43
Let's say there was no limitation on the number of commands and you could customise the name of each one. That doesn't make them any easier to bind via main preferences and you can't really dictate which shortcuts people must use to match the text on your menu commands (assuming that is your intent). This functionality simply is not meant for shared scripts and nothing can be done to make it any easier.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-06-01 16:10:29
Let's say there was no limitation on the number of commands and you could customise the name of each one. That doesn't make them any easier to bind via main preferences and you can't really dictate which shortcuts people must use to match the text on your menu commands (assuming that is your intent). This functionality simply is not meant for shared scripts and nothing can be done to make it any easier.
Well my suggestion some months ago about the main menu entries was precisely to change that. Letting users to add arbitrary entries to the SMP config panel and setting shortcuts there. Then, since it's done by SMP, keys could be "suggested", instead of forced (the only way that can be done right now as you note).
https://hydrogenaud.io/index.php?topic=116669.msg994865#msg994865

That's why I say it needs a rework.

Lets say we have something like...

fb.addShortcut(name, func, key). Then it would populate the list on the link, at config, with a new entry. Automatically at script loading! No need for user input. Key would be a suggested key, and foobar already has some capability to check for duplicates keys so... if there was a duplicate, we could simply show a popup to ask the user to change it. Leaving it blank until then.

Quote
This functionality simply is not meant for shared scripts and nothing can be done to make it any easier.

That solves all problems. Scripts could add arbitrary menu entries. They would not be limited to X entries. Keys could be arbitrarily linked to them, and keys could be retrieved by the scripts (to add that info to the menu entries).

Obviously the problem is the menu thing right now,  ::) Not that it can not be changed to an usable thing between different panels.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-06-01 16:27:46
I look forward to your implementation.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-06-01 16:44:32
Sorry for pointing to a thing which even TheQwertiest admitted was really limited 'as is' and discussing an alternative idea which obviously it's not in my list to do.

Would love to also see such ironic answers when someone appraises other developer's works.
- Hey really good plugin man. Love it as is.
- Do it yourself if you like it so much. I look forward to your implementation.
::) 
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-06-01 18:34:39
regor, you've got a very specific use-case for your scripts, specifically because you're writing what amounts to add-ons to other scripts/themes that you don't maintain. That's not something that anybody else is doing as far as I'm aware. I understand *why* you're doing it, but it seems to be making things more complicated for you as well.

When you've got a highly specialized use case with limited demand among the user base and it would require substantial dev-effort you can either figure out how to do it yourself and raise a PR, or you can just realize that it's probably not going to happen. Qwertiest has limited time and he's most likely going to allocate it to functionality and bug fixes that affect the most people.

I know you're going to ignore this but I think you're better off just putting the onus on any script writer who wants to include your stuff. If people really want the functionality you're providing, they'll do the heavy lifting themselves.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: SUPERCOOLMAN on 2021-06-06 10:17:16
anyone know if it's possible to request feature (improvement) on the scripts (by marc2003) included with Spider Monkey Panel?

for Artist Images@samples/complete/thumbs.js

1. currently, there is no way to bring up panel configuration (not script editor) unless I bring up fb2k's Preference and go for "configure panel" in the UI setting. would be good to be able to right click on the panel and bring that up so things like panel properties can be configure with ease. I actually didn't know such configuration exists until accidentally found it while configuring UI

2. not able to specify multiple custom folders and completely disable downloading arts

3. currently, custom folder path doesn't take any wild card, so it's not possible to specify some thing like "*scan*" to match folders like "hi-res scans [artist's name]", "scans [artist's name]", "scans booklet"...etc in addition to the regular "scan" folder to look for the arts. perhaps it's due to feature similar to Python's glob is missing

4. can Spider Monkey Panel support webp, tif...etc other popular art formats for thumbs.js to display the arts? tried a bit but couldn't get it to work

5. retain current thumbs (instead of reload and rebuild) when playing the next song in the same album/folder as current song such that there is no change to the available arts
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-06-06 11:16:18
1) There is nothing in the Properties dialog that cannot be set via the MENU.

2) If in Custom folder mode, no art is downloaded. If in Last.fm Artist mode, right click and uncheck Automatic Downloads. There is no support for multiple folders.

3) It's hardcoded to a single folder. I guess support for multiple folders is possible but I have no idea how to support wildcards in folder names.

4) Spider Monkey Panel does not support webp currently, It's on a to-do list.

5) This already happens. There is no refresh unless the title formatting evaluated for the current folder/artist changes.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: fbuser on 2021-06-06 11:31:09
1. currently, there is no way to bring up panel configuration (not script editor) unless I bring up fb2k's Preference and go for "configure panel" in the UI setting. would be good to be able to right click on the panel and bring that up so things like panel properties can be configure with ease. I actually didn't know such configuration exists until accidentally found it while configuring UI
This is always possible with <WIN>+<SHIFT>+<RCLICK> -> Properties/Configure
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: SUPERCOOLMAN on 2021-06-06 11:44:59
1. currently, there is no way to bring up panel configuration (not script editor) unless I bring up fb2k's Preference and go for "configure panel" in the UI setting. would be good to be able to right click on the panel and bring that up so things like panel properties can be configure with ease. I actually didn't know such configuration exists until accidentally found it while configuring UI
This is always possible with <WIN>+<SHIFT>+<RCLICK> -> Properties/Configure
thanks. interesting enough that brings up the same menu as when Spider Monkey Panel crashes, which has the option to go panel config
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: SUPERCOOLMAN on 2021-06-06 12:26:16
1) There is nothing in the Properties dialog that cannot be set via the MENU.

2) If in Custom folder mode, no art is downloaded. If in Last.fm Artist mode, right click and uncheck Automatic Downloads. There is no support for multiple folders.

3) It's hardcoded to a single folder. I guess support for multiple folders is possible but I have no idea how to support wildcards in folder names.

4) Spider Monkey Panel does not support webp currently, It's on a to-do list.

5) This already happens. There is no refresh unless the title formatting evaluated for the current folder/artist changes.
1. fbuser provided a way to do it, so I'm good on this one

2. was cleaning up a bunch of unexpected downloaded arts due to trying to recover from weird crashes requiring delete panel from UI and re-add. wanted to directly configure property to custom folder since default is download mode and it looks like it does the download when any song is selected while nothing is playing

3. was looking to make folder a list separated by invalid path character (ex. colon) and iteratively do something similar to https://stackoverflow.com/questions/23809897/node-js-glob-pattern-for-excluding-multiple-files to recursively traverse all levels of each directory and grab all valid files

4. this is good to know

5. I kept hitting out of memory errors like below randomly. now I realize even when Selection mode is prefer now playing, script will react to the current selection when I stopped the playback. this causes crash and fk2k freeze for some time during start up if the resolved customer folder of the select song has high resolution scans (15000 x 9600) on 1080p monitor. note that at this point, if I start playback again either using hotkey or fb2k's menu, fb2k will play the last played song, not current selection. hence playback had never changed album/directory, but script will refresh thumbs/cache due to its context switch when I transition between playback and stopped playback states
Code: [Select]
Error: Spider Monkey Panel v1.4.1 ({2951B685-A759-4726-BC76-AE22F64A5607})
Out of memory: 288/1073741824 bytes

6. a new one. for displaying art, "center" would always leave spaces all around (top, bottom, left and right) while the other 3 modes would not leave space. would be good for center mode to at least fill up 2 of the 4 sides


Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-06-06 13:10:21
You could avoid all out of memory errors and get webp support by using the JScript Panel version instead.

As for automatic downloads. fb2k must be playing, the selected item must match what is now playing and 2 seconds must have passed since the track was started before it even checks and there must be no existing images already.

https://github.com/TheQwertiest/smp_2003/blob/4a35bfe34a1190e5b321042fcecec9c9a5086fcb/js/thumbs.js#L175L184

It is quite literally impossible for anything to happen by selection change when not playing.




Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: SUPERCOOLMAN on 2021-06-06 19:21:43
You could avoid all out of memory errors and get webp support by using the JScript Panel version instead.

As for automatic downloads. fb2k must be playing, the selected item must match what is now playing and 2 seconds must have passed since the track was started before it even checks and there must be no existing images already.

https://github.com/TheQwertiest/smp_2003/blob/4a35bfe34a1190e5b321042fcecec9c9a5086fcb/js/thumbs.js#L175L184

It is quite literally impossible for anything to happen by selection change when not playing.
this was sometime ago, so I haven't been playing with the download part for a while. will report back if I get to the exact reproducing steps the next time I encounter this (similar to #5)

I'm stuck with the very old JScript Panel because the newer versions of JScript Panel break compatibility for scripts like Modoki Lyrics. I'm holding onto the old version of JScript Panel because of these scripts
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: SUPERCOOLMAN on 2021-06-07 06:47:56
my first attempt/edit on samples\complete\js\thumbs.js to add multiple folders support. probably breaks download and something I didn't notice
example customer folder now take multiple folder separated by newline (line feed character) $directory_path(%path%)\Scans$char(10)$directory_path(%path%)\Scans Hi-Res

Code: [Select]
include(fb.ComponentPath + 'samples\\complete\\js\\lodash.min.js');
Code: [Select]
    this.update = () => {
        this.image = 0;
        function iter_folder_get_files_curry(exts, newest_first){
            return function(folder){
                return _getFiles(folder, exts, newest_first);
            }
        } // end iter_folder_get_files_curry
        this.files = _.filter(_.spread(_.union)(_.map(_.union(_.split(this.folders,"\n")),iter_folder_get_files_curry(this.exts, this.properties.sort.value == 1))), _.size);
        if (this.properties.source.value == 1 && this.files.length > 1) {
            this.default_file = this.folders + utils.ReadINI(this.ini_file, 'Defaults', _fbSanitise(this.artist));
            const tmp = _.indexOf(this.files, this.default_file);
            if (tmp > -1) {
                this.files.splice(tmp, 1);
                this.files.unshift(this.default_file);
            }
        }


glob and out of memory crashes are to be explored as Spider Monkey Panel seemed to be missing the JavaScript functionalities for node-glob (https://github.com/isaacs/node-glob) to work
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: SUPERCOOLMAN on 2021-06-08 04:46:29
problems with Spider Monkey Panel's utils.Glob are

1. unable to handle paths with non-English (Unicode?) character. it returns empty array if the input path pattern is not purely English ASCII
2. does not recursively go into sub-directory. doesn't support the /**/* syntax
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-06-08 05:37:20
problems with Spider Monkey Panel's utils.Glob are

1. unable to handle paths with non-English (Unicode?) character. it returns empty array if the input path pattern is not purely English ASCII
2. does not recursively go into sub-directory. doesn't support the /**/* syntax
utils.Glob is implemented using fb2k's implementation of FindFirstFile/FindNextFile. It's not a unix glob and you shoudn't expect it to behave like one.  You should also assume that any code written for node-js will not function in FSM; they're two completely different things.

If unicode paths aren't working then that appears to be a limitation of the foobar SDK. The FSM code seems to handle unicode files inside a directory, but I didn't verify. Just saw that it's checking unicode strings in the returned filePaths.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-06-08 08:02:07
I tested it and it works exactly as expected.

(https://i.imgur.com/x1WzDtG.png)

It exclusively lists files with Björk in the filename and omits the others.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-06-08 08:47:21
problems with Spider Monkey Panel's utils.Glob are
2. does not recursively go into sub-directory. doesn't support the /**/* syntax

That's right, there you got recursive search. That's what I use to inject a mod into another script, looking for all js files first.

Code: [Select]
let fileArr = findRecursivefile('*.js', [fb.ProfilePath, fb.ComponentPath]); // All possible paths for the scripts

Code: [Select]
function findRecursivePaths(path = fb.ProfilePath){
let arr = [], pathArr = [];
arr = utils.Glob(path + '*.*', 0x00000020); // Directory
arr.forEach( (subPath) => {
if (subPath.indexOf('\\..') !== -1 || subPath.indexOf('\\.') !== -1) {return;}
if (subPath === path) {return;}
pathArr.push(subPath);
pathArr = pathArr.concat(findRecursivePaths(subPath + '\\'));
});
return pathArr;
}

function findRecursivefile(fileMask, inPaths = [fb.ProfilePath, fb.ComponentPath]){
let fileArr = [];
if (isArrayStrings(inPaths)) {
let pathArr = [];
inPaths.forEach( (path) => {pathArr = pathArr.concat(findRecursivePaths(path));});
pathArr.forEach( (path) => {fileArr = fileArr.concat(utils.Glob(path + '\\' +  fileMask));});
}
return fileArr;
}

function isArrayStrings(checkKeys, bAllowEmpty = false) {
if ( checkKeys === null || Object.prototype.toString.call(checkKeys) !== '[object Array]' || checkKeys.length === null || checkKeys.length === 0) {
return false; //Array was null or not an array
} else {
let i = checkKeys.length;
while (i--){
if (Object.prototype.toString.call(checkKeys[i]) !== '[object String]') {
return false; //values were null or not strings
}
if (!bAllowEmpty && checkKeys[i] === '') {
return false; //values were empty
}
}
}
return true;
}
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: SUPERCOOLMAN on 2021-06-08 10:45:41
I tested it and it works exactly as expected.
Spoiler (click to show/hide)

It exclusively lists files with Björk in the filename and omits the others.
below screenshot should illustrate the problem. you can see the contradiction between utils.IsDirectory and utils.Glob. even utils.Glob itself is not very consistent. I'm not sure if this is fb2k problem or Spider Monkey Panel's own implementation bug
(https://i.imgur.com/ISB7lFb.png)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: SUPERCOOLMAN on 2021-06-08 11:36:37
problems with Spider Monkey Panel's utils.Glob are
2. does not recursively go into sub-directory. doesn't support the /**/* syntax

That's right, there you got recursive search. That's what I use to inject a mod into another script, looking for all js files first.
Spoiler (click to show/hide)

thanks. I was hoping to be able to do something like glob.sync(path + '**/*.+('+this.exts+')') to grab all files in all sub-directory recursively with the targeted extension in one shot using the regular glob
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-06-08 16:53:17
It exclusively lists files with Björk in the filename and omits the others.
ö isn't unicode -- It's ASCII value 148.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-06-08 17:34:50
Whatever...

Code: [Select]
var files = utils.Glob("z:\\近藤奈々\\近藤奈々*.*");
console.log(files);

(https://i.imgur.com/fwFQdRC.png)



Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-06-08 17:56:47
Yeah, confirmed that it works just fine. @SUPERCOOLMAN is doing something wrong. Doing a console.log on utils.Glob will always return at least a "[]" even if it doesn't match anything but his console screenshot shows it returning an empty string, which tells me that somehow his code is not using the FSM utils.Glob. Maybe one of the includes is overwriting it?

(https://user-images.githubusercontent.com/2282004/121227187-e9c6f080-c850-11eb-9dcd-9a20f6f03068.png)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: SUPERCOOLMAN on 2021-06-08 18:13:25
Yeah, confirmed that it works just fine. @SUPERCOOLMAN is doing something wrong. Doing a console.log on utils.Glob will always return at least a "[]" even if it doesn't match anything but his console screenshot shows it returning an empty string, which tells me that somehow his code is not using the FSM utils.Glob. Maybe one of the includes is overwriting it?

Spoiler (click to show/hide)
I think your problem is that you are not doing string concat (in console.log) like I had shown in my screenshot... you should try to concat something to utils.Glob's result
here is the code I used
Code: [Select]
"use strict";
include(fb.ComponentPath + 'samples\\complete\\js\\lodash.min.js');
include(fb.ComponentPath + 'samples\\complete\\js\\helpers.js');
include(fb.ComponentPath + 'samples\\complete\\js\\panel.js');

let panel = new _panel(true);

console.log("utils.IsDirectory=" + utils.IsDirectory("C:\\エデン\\画像"));
console.log("utils.Glob=" + utils.Glob( "C:\\エデン", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( "C:\\エデ*", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( "C:\\エ*", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( "C:\\エデ*\\*", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( "C:\\エデ*\\画像*", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( "C:\\エデ*\\画像", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( panel.tf("$directory_path(%path%)"), 0x0, 0x10 ));
console.log("directory_path=" + panel.tf( "$directory_path(%path%)" ));
console.log("utils.Glob+=" + utils.Glob( panel.tf("$directory_path(%path%)\\画像"), 0x0, 0x10 ));
console.log("directory_path+=" + panel.tf( "$directory_path(%path%)\\画像" ));
console.log("utils.Glob+=" + utils.Glob( panel.tf("$directory_path(%path%)"+"\\画像"), 0x0, 0x10 ));
console.log("directory_path+=" + panel.tf( "$directory_path(%path%)"+"\\画像" ));
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-06-08 18:21:28
Heh, you're right. Still it's you (your computer, directory name, etc.), not FSM:

Code: [Select]
"use strict"

console.log("utils.IsDirectory=" + utils.IsDirectory("C:\\エデン\\画像"));
console.log("utils.Glob=" + utils.Glob( "C:\\エデン", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( "C:\\エデ*", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( "C:\\エ*", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( "C:\\エデ*\\*", 0x0, 0x10 )); // you can't have wildcard and then more path -- not a unix glob
console.log("utils.Glob=" + utils.Glob( "C:\\エデ*\\画像*", 0x0, 0x10 ));// you can't have wildcard and then more path -- not a unix glob
console.log("utils.Glob=" + utils.Glob( "C:\\エデ*\\画像", 0x0, 0x10 ));// you can't have wildcard and then more path -- not a unix glob

console.log("utils.Glob=" + utils.Glob( "C:\\エデン\\画像*", 0x0, 0x10 ));
(https://user-images.githubusercontent.com/2282004/121229716-eda84200-c853-11eb-8423-3dd8f2300349.png)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: SUPERCOOLMAN on 2021-06-08 19:21:07
Heh, you're right. Still it's you (your computer, directory name, etc.), not FSM:

Spoiler (click to show/hide)
right now, I can only think of either SMP version differences (you have dev build) or my OS's native language/encoding being CJK causes some other transformation resulting the issue

for me, I get below result with the following code
Code: [Select]
"use strict"

console.log("utils.IsDirectory=" + utils.IsDirectory("C:\\エデン\\画像"));
console.log("utils.Glob=" + utils.Glob( "C:\\エデン", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( "C:\\エデ*", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( "C:\\エ*", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( "C:\\エデン\\*", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( "C:\\エデン\\画像*", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( "C:\\エデン\\画像", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( "C:\\エデン\\画像*", 0x0, 0x10 ));
Code: [Select]
utils.IsDirectory=true
utils.Glob=
utils.Glob=C:\エデン
utils.Glob=
utils.Glob=C:\エデン\.,C:\エデン\..,C:\エデン\画像
utils.Glob=
utils.Glob=
utils.Glob=
Spider Monkey Panel v1.4.1 ({E02200A8-2D15-40A2-878C-EEEE123C71D1}): initialized in 2 ms
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-06-08 23:00:50
right now, I can only think of either SMP version differences (you have dev build) or my OS's native language/encoding being CJK causes some other transformation resulting the issue
Shouldn't be anything different in my dev build (and snotlicker already showed it works in 1.4.1). Just to be clear, you're on a Windows flavor, and not trying to run this in WINE, right?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: SUPERCOOLMAN on 2021-06-09 03:05:17
right now, I can only think of either SMP version differences (you have dev build) or my OS's native language/encoding being CJK causes some other transformation resulting the issue
Shouldn't be anything different in my dev build (and snotlicker already showed it works in 1.4.1). Just to be clear, you're on a Windows flavor, and not trying to run this in WINE, right?
I'm running this on native WIn10 20H2, not wine or any VM. also, some patterns are working for me as you can see from my results, just not all. that's why I'm not able to figure out what's wrong
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: SUPERCOOLMAN on 2021-06-09 03:22:25
is it normal that if 1 SMP crash, all SMP would crash together despite each running different script?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-06-09 04:16:01
No idea what you're trying to do but there is nothing wrong with the component. My previous examples were file based, this is just folders...

(https://i.imgur.com/mc7Ydqy.png)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: SUPERCOOLMAN on 2021-06-09 07:13:15
No idea what you're trying to do but there is nothing wrong with the component. My previous examples were file based, this is just folders...

Spoiler (click to show/hide)
MordredKLB had already pointed out that I'm trying to achieve unix glob.

anyways, I minimized and modified tiny-glob to had achieve what I want in SMP. next step is to see how to make it faster
Code: [Select]
Glob Pattern=C:/エデン/*画像*/**/*.{jpg,jpeg,png,gif}
Glob Pattern=C:/エデン/*圖片*/**/*.{jpg,jpeg,png,gif}
Glob Found=C:\エデン\画像\001.png
C:\エデン\画像\002.png
C:\エデン\画像\003.png
C:\エデン\画像\004.png
C:\エデン\画像\005.png
C:\エデン\画像\l2\001.png
C:\エデン\画像\l2\002.png
C:\エデン\画像\l2\003.png
C:\エデン\画像\l2\004.png
C:\エデン\画像\l2\005.png
C:\エデン\画像\l2\l3\001.png
C:\エデン\画像\l2\l3\002.png
C:\エデン\画像\l2\l3\003.png
C:\エデン\画像\l2\l3\004.png
C:\エデン\画像\l2\l3\005.png
C:\エデン\画像\l2 - 2\001.png
C:\エデン\画像\l2 - 2\002.png
C:\エデン\画像\l2 - 2\003.png
C:\エデン\画像\l2 - 2\004.png
C:\エデン\画像\l2 - 2\005.png
Spider Monkey Panel v1.4.1 (Thumbs: Thumbs by marc2003): initialized in 376 ms
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: SUPERCOOLMAN on 2021-06-10 06:11:03
encountered another weird issue. when I added code to re-size images based on panel size, which takes a hell long time (200+ms → 10+sec), I notice _img (which calls gdi.Image) failed to load some of the images hence the resulting GdiBitmap are null. however, both utils.IsFile and _isFile confirmed these files do exists. there is no out of memory error or any error msg, so I'm not sure how to determine why images would fail to load. if I handle returning GdiBitmap being null properly with a check to let it continue, then many other images after the failing images loaded just fine

multiple other files in the same directory and similar name loaded just fine. for example, A********10.png loads just fine, but A********11.png would fail to load. A********12.png and  A********13.png load without issue as well. array is sorted order, so images would get loaded in order
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-06-10 07:07:31
Just because a file definitely exists, doesn't mean it's guaranteed to be read successfully by the gdi.Image function.

The component uses the Gdiplus library from the windows SDK and what you must do after most operations is check the status in C++.

https://docs.microsoft.com/en-us/windows/win32/api/gdiplustypes/ne-gdiplustypes-status

If the status of the operation is not OK, you get a null return value.

Reporting the internal error in this case is largely useless. See the remarks section on the web page above...

Quote
If you construct a GDI+ object and then immediately call the GetLastStatus method of that object, you can determine whether the constructor succeeded or failed. In such cases, GetLastStatus might return OutOfMemory even though there was plenty of memory available to create the object. Several GDI+ constructors set the status to OutOfMemory when they fail regardless of the reason for failure.

I'm sure you'll go on to say you can view the image in windows or any other image viewer. I can't explain that, It's way over my head.

If it only affects a few images, loading them in an editor and "saving as" might generate new files that can be read.

Regarding the time consuming resize operations, you might consider caching the results so it only has to be done once.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-06-10 16:26:18
One thing to be aware of is that Windows is VERY forgiving about file names, but foobar isn't quite as forgiving. You can save a .jpg and call it a .png or .gif and Windows will display it just fine. Foobar seems to be able to load .jpgs as .pngs and vice versa, but if one of those is a gif it doesn't work.

Photoshop will complain if the file is misnamed which is how I discovered this in the first place. Resaving files in an image editor that can open them is definitely good advice.

When you speak of speed in resizing, how big are these images in resolution and file size, and what size are you scaling them to? I do a lot of resizing from 2000x2000 (and occasionally larger) images down to pixel display size (usually around 1400x1400) and it's fast, as in always <1 second fast. It's gonna grow logarithmically though as original file size increases. I know Qwertiest used to complain how slow just loading 3000x3000 images was in JSP, and I doubt it's any faster in FSM.

Caching is definitely the way to go. Here's my implementation of an LRU ArtCache (https://github.com/kbuffington/Georgia/blob/master/js/image-caching.js) that should be fairly simple to adapt to any script.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: SUPERCOOLMAN on 2021-06-10 17:02:06
One thing to be aware of is that Windows is VERY forgiving about file names, but foobar isn't quite as forgiving. You can save a .jpg and call it a .png or .gif and Windows will display it just fine. Foobar seems to be able to load .jpgs as .pngs and vice versa, but if one of those is a gif it doesn't work.

Photoshop will complain if the file is misnamed which is how I discovered this in the first place. Resaving files in an image editor that can open them is definitely good advice.

When you speak of speed in resizing, how big are these images in resolution and file size, and what size are you scaling them to? I do a lot of resizing from 2000x2000 (and occasionally larger) images down to pixel display size (usually around 1400x1400) and it's fast, as in always <1 second fast. It's gonna grow logarithmically though as original file size increases. I know Qwertiest used to complain how slow just loading 3000x3000 images was in JSP, and I doubt it's any faster in FSM.

Caching is definitely the way to go. Here's my implementation of an LRU ArtCache (https://github.com/kbuffington/Georgia/blob/master/js/image-caching.js) that should be fairly simple to adapt to any script.

they are all 3000x3000 or 5000x2000. each file is 10MB-30MB in size. with more than 30 images to load, I guess thumb's implementation of loading every image at the beginning is slowing everything down causing the fb2k freeze. for comparison, windows and other image viewers are able to batch convert all of them in less than 2 seconds (read all files, convert and write downscaled images back all on HDD), so at least disk operations shouldn't be the bottleneck

is there anyway to load image in the background or separate thread while not freeze/holding fb2k? I had tried LoadImageAsyncV2, but that seemed to also freeze fb2k for some moments while loading images as well
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-06-10 18:02:54
One thing to be aware of is that Windows is VERY forgiving about file names, but foobar isn't quite as forgiving. You can save a .jpg and call it a .png or .gif and Windows will display it just fine. Foobar seems to be able to load .jpgs as .pngs and vice versa, but if one of those is a gif it doesn't work.

Can't speak for the album art functions but gdi.Image shouldn't care about the file extension. It uses IStream / SHCreateStreamOnFileEx to create an IStream object which is then passed as an arg to the Gdiplus::Bitmap constructor. It has no clue about the file extension at that point...

https://github.com/marc2k3/foo_jscript_panel/blob/f03851583d109c39a5b4aafc942deacd87c2f7a7/src/Helpers/Image.h#L60-L61

Pretty sure SMP does exactly the same as the code was inherited from WSH panel mod.

edit: tested just to make sure. These are 5 gif files renamed with different extensions...

(https://i.imgur.com/fhny3xC.png)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: SUPERCOOLMAN on 2021-06-10 18:58:23
One thing to be aware of is that Windows is VERY forgiving about file names, but foobar isn't quite as forgiving. You can save a .jpg and call it a .png or .gif and Windows will display it just fine. Foobar seems to be able to load .jpgs as .pngs and vice versa, but if one of those is a gif it doesn't work.

Can't speak for the album art functions but gdi.Image shouldn't care about the file extension. It uses IStream / SHCreateStreamOnFileEx to create an IStream object which is then passed as an arg to the Gdiplus::Bitmap constructor. It has no clue about the file extension at that point...

https://github.com/marc2k3/foo_jscript_panel/blob/f03851583d109c39a5b4aafc942deacd87c2f7a7/src/Helpers/Image.h#L60-L61

Pretty sure SMP does exactly the same as the code was inherited from WSH panel mod.

edit: tested just to make sure. These are 5 gif files renamed with different extensions...

(https://i.imgur.com/fhny3xC.png)
is JScript Panel going to add Direct2D or more efficient image drawing, loading...etc support so we don't have to get stuck with gdi?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: SUPERCOOLMAN on 2021-06-10 19:07:28
one weird behaviour I'm seeing is that, on pretty much every startup, I'm getting below error, but everything works if I just click Reload. it seems that something broken only during fb2k startup, but not after fb2k had started
Code: [Select]
Error: Spider Monkey Panel v1.4.1 (Thumbs: Thumbs by marc2003)
Resize failed:
Failed to create GdiPlus object (0x2): InvalidParameter

File: thumbs.js
Line: 540, Column: 122
Stack trace:
  iter_image_load_resize@thumbs.js:540:122
  c@lodash.min.js:6:348
  tu@lodash.min.js:67:168
  _thumbs/this.update@thumbs.js:544:25
  _thumbs/this.metadb_changed@thumbs.js:171:14
  on_metadb_changed@<main>:25:9
  _panel/this.item_focus_change@panel.js:11:4
  @<main>:12:7
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-06-10 20:42:34
is JScript Panel going to add Direct2D or more efficient image drawing, loading...etc support so we don't have to get stuck with gdi?

Nope. I wouldn't know where to start even I wanted to. And I don't.... :P

Your use case is very much non standard and it's not really worth the effort it would take anyone else trying to it solve for you. Your super huge images might give you a warm fuzzy feeling inside but what's the point? Even my largest 3000x3000 album art is no bigger than 4MB. Even fb2k itself defaults to ignoring images over 8MB (yes, I'm aware that can be overridden in the advanced preferences).

Regarding your error above, are you using the latest official build?? IIRC Mordred provided a supposedly optimised build a few weeks ago but it was in fact buggy and would cause that error.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-06-10 22:45:08
one weird behaviour I'm seeing is that, on pretty much every startup, I'm getting below error, but everything works if I just click Reload. it seems that something broken only during fb2k startup, but not after fb2k had started
Code: [Select]
Error: Spider Monkey Panel v1.4.1 (Thumbs: Thumbs by marc2003)
Resize failed:
Failed to create GdiPlus object (0x2): InvalidParameter

File: thumbs.js
Line: 540, Column: 122
Stack trace:
  iter_image_load_resize@thumbs.js:540:122
  c@lodash.min.js:6:348
  tu@lodash.min.js:67:168
  _thumbs/this.update@thumbs.js:544:25
  _thumbs/this.metadb_changed@thumbs.js:171:14
  on_metadb_changed@<main>:25:9
  _panel/this.item_focus_change@panel.js:11:4
  @<main>:12:7
Something similar happened to me on startup because I adjusted fontsize according to window size and gdi font size was 0 at that point. It obviously worked right after startup when I reloaded the panel because window size was != 0. I reported it here some weeks ago.

Check you are not doing the same with gdi image at some point, since it always crashes as soon as width or height is zero, which may happen at startup if you are setting them according to window size.

It may well draw nothing in both cases but...
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: SUPERCOOLMAN on 2021-06-11 03:19:09
one weird behaviour I'm seeing is that, on pretty much every startup, I'm getting below error, but everything works if I just click Reload. it seems that something broken only during fb2k startup, but not after fb2k had started
Code: [Select]
Error: Spider Monkey Panel v1.4.1 (Thumbs: Thumbs by marc2003)
Resize failed:
Failed to create GdiPlus object (0x2): InvalidParameter

File: thumbs.js
Line: 540, Column: 122
Stack trace:
  iter_image_load_resize@thumbs.js:540:122
  c@lodash.min.js:6:348
  tu@lodash.min.js:67:168
  _thumbs/this.update@thumbs.js:544:25
  _thumbs/this.metadb_changed@thumbs.js:171:14
  on_metadb_changed@<main>:25:9
  _panel/this.item_focus_change@panel.js:11:4
  @<main>:12:7
Something similar happened to me on startup because I adjusted fontsize according to window size and gdi font size was 0 at that point. It obviously worked right after startup when I reloaded the panel because window size was != 0. I reported it here some weeks ago.

Check you are not doing the same with gdi image at some point, since it always crashes as soon as width or height is zero, which may happen at startup if you are setting them according to window size.

It may well draw nothing in both cases but...

I think I hit your described issue where SMP is telling me Win size of 0, but in a different way. looks like size of 1 is not valid for resize... SMP doc also doesn't say what's the min size for resize

my code already handles Win size of 0 when I hit this crash. I added some console logging to see what's going on
Code: [Select]
let w_height = Math.max(window.Height,1), w_width = Math.max(window.Width,1);
let gbmp = _img(image_path);
if(!gbmp) {
    console.log("Image load Failed=" + image_path );   // SUPERCOOLMAN
    //console.log("Image utils.IsFile=" + utils.IsFile(image_path) );   // SUPERCOOLMAN
    //console.log("Image _isFile=" + _isFile(image_path) );   // SUPERCOOLMAN
    return;
} // end if
let bmp_height = Math.max(gbmp.Height,1), bmp_width = Math.max(gbmp.Width,1);
let height_ratio = Math.ceil(bmp_height/w_height),width_ratio = Math.ceil(bmp_width/w_width);
    console.log(`Image load Failed Win.width=${w_width}\tWin.height=${w_height}`);   // SUPERCOOLMAN
    console.log(`Image load Failed BMP.width=${bmp_width}\tBMP.height=${bmp_height}`);   // SUPERCOOLMAN
    console.log(`Image load Failed width_ratio=${width_ratio}\theight_ratio=${height_ratio}`);   // SUPERCOOLMAN
    console.log(`Image load Failed resized width=${Math.ceil(bmp_width/height_ratio)}\theight=${Math.ceil(bmp_height/height_ratio)}`);   // SUPERCOOLMAN
    console.log(`Image load Failed resized width=${Math.ceil(bmp_width/width_ratio)}\theight=${Math.ceil(bmp_height/width_ratio)}`);   // SUPERCOOLMAN
return (height_ratio >= width_ratio) ? gbmp.Resize(Math.ceil(bmp_width/height_ratio),Math.ceil(bmp_height/height_ratio),0x1): gbmp.Resize(bmp_width/width_ratio,bmp_height/width_ratio,0x1);
result when crashed
Code: [Select]
Image load Failed Win.width=1	Win.height=1
Image load Failed BMP.width=7596 BMP.height=3767
Image load Failed width_ratio=7596 height_ratio=3767
Image load Failed resized width=3 height=1
Image load Failed resized width=1 height=1
foo_spider_monkey_panel:
Error: Spider Monkey Panel v1.4.1 (Thumbs: Thumbs by marc2003)
Resize failed:
Failed to create GdiPlus object (0x2): InvalidParameter

File: thumbs.js
Line: 545, Column: 144
Stack trace:
  iter_image_load_resize@thumbs.js:545:144
  c@lodash.min.js:6:348
  tu@lodash.min.js:67:168
  _thumbs/this.update@thumbs.js:549:25
  _thumbs/this.metadb_changed@thumbs.js:171:14
  on_metadb_changed@<main>:25:9
  _panel/this.item_focus_change@panel.js:11:4
  @<main>:12:7
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-06-11 05:53:44
Can't speak for the album art functions but gdi.Image shouldn't care about the file extension. It uses IStream / SHCreateStreamOnFileEx to create an IStream object which is then passed as an arg to the Gdiplus::Bitmap constructor. It has no clue about the file extension at that point...

...

edit: tested just to make sure. These are 5 gif files renamed with different extensions...
I tried it before posting with a jpg I renamed a gif and *something* didn't load the image... although it's possible I was filtering out .gifs. I was tired this morning. :)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-06-11 05:56:26
is JScript Panel going to add Direct2D or more efficient image drawing, loading...etc support so we don't have to get stuck with gdi?
Odds of this are very low. I looked into it to see how difficult it would be... and it seems to be beyond my powers. It sucks, but for most people doing normal things, gdi is fine. There's no way to get around the processing time required to load very large images. Best to debounce those if you can to avoid everything grinding to a halt, or just... don't have such large images.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: SUPERCOOLMAN on 2021-06-11 06:09:24
found a couple more issues with SMP
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-06-11 15:39:48
Async methods for loading images aren't really doing you many favours. It's a very cheap operation. It's the resizing that's always going to be a problem.

For example, I can use the recursive utils.ListFiles method in JSP to read 2000 images totalling nearly 5GB in size in less than 1 second.

Code: [Select]
var total_size = 0;

var images = utils.ListFiles("z:\\blah", true).toArray().map(function (item) {
total_size += utils.GetFileSize(item);
return gdi.Image(item);
});

console.log(images.length);
console.log(utils.FormatFileSize(total_size));

Code: [Select]
1919
4.94 GB
JScript Panel v2.6.0.1 (id:3016108): initialised in 747 ms



Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-06-11 16:52:52
found a couple more issues with SMP
  • Promise.allSettled is not available in SMP
This isn't an "issue". FSM uses SM68 (https://en.wikipedia.org/wiki/SpiderMonkey) as the execution engine which corresponds to Firefox v68 as you might expect which was released in July 2019. Promise.allSettled was added to SM in release 78 (in v71 for Firefox). I asked last year after 78 was released but apparently upgrading the SM engine is not just a dependency update so unfortunately it's not just a quick thing Qwertiest can do.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: SUPERCOOLMAN on 2021-06-11 18:01:20
Async methods for loading images aren't really doing you many favours. It's a very cheap operation. It's the resizing that's always going to be a problem.

For example, I can use the recursive utils.ListFiles method in JSP to read 2000 images totalling nearly 5GB in size in less than 1 second.

Code: [Select]
var total_size = 0;

var images = utils.ListFiles("z:\\blah", true).toArray().map(function (item) {
total_size += utils.GetFileSize(item);
return gdi.Image(item);
});

console.log(images.length);
console.log(utils.FormatFileSize(total_size));

Code: [Select]
1919
4.94 GB
JScript Panel v2.6.0.1 (id:3016108): initialised in 747 ms
with async image load, I can continue for now, then check back later (from time to time per timer) and only draw/update when the image loading is done without freezing fb2k for long
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: SUPERCOOLMAN on 2021-06-11 18:14:59
found a couple more issues with SMP
  • Promise.allSettled is not available in SMP
This isn't an "issue". FSM uses SM68 (https://en.wikipedia.org/wiki/SpiderMonkey) as the execution engine which corresponds to Firefox v68 as you might expect which was released in July 2019. Promise.allSettled was added to SM in release 78 (in v71 for Firefox). I asked last year after 78 was released but apparently upgrading the SM engine is not just a dependency update so unfortunately it's not just a quick thing Qwertiest can do.
then I use reflect, but the hit the second behaviour causing the array Promise.all resolved to contain whole bunch of nulls resulting crashes if I don't handle these nulls

from the debug, I feel that the few out of many images failing to load is probably due to loading those somehow requires too much memory while the already load&resized images' original, despite only save resized copy in memory at the moment, hasn't been garbage collected resulting out of memory without crash and the symptom shows up as those images somehow needing lots of memory failed to load while many subsequent images needing way less memory loading without problem. why do smaller file size & dimension png images in from the same scan requires significant more memory is beyond me. perhaps the png compression worked well to compress them to smaller file size
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-06-11 18:34:03
then I use reflect, but the hit the second behaviour causing the array Promise.all resolved to contain whole bunch of nulls resulting crashes if I don't handle these nulls

from the debug, I feel that the few out of many images failing to load is probably due to loading those somehow requires too much memory while the already load&resized images' original, despite only save resized copy in memory at the moment, hasn't been garbage collected resulting out of memory without crash and the symptom shows up as those images somehow needing lots of memory failed to load while many subsequent images needing way less memory loading without problem. why do smaller file size & dimension png images in from the same scan requires significant more memory is beyond me. perhaps the png compression worked well to compress them to smaller file size
If you were running out of memory, you'd most likely see the out of memory popup which would kill your script. I think the threshold is ~1TB.

When dealing with images, it's not the file size on disk that matters, as these all get loaded in memory as bitmaps. Think of a standard 8bpc jpg/png is going to take 32 bits (8x4 channels) per pixel. If your image was 2000x2000 that's ~16MB of memory, plus whatever overhead is required for the GdiBitmap class (probably not much here). A 4000x4000 image is 64MB in memory. Don't need to load too many of those and you're bumping up against the memory cap. Obviously you can't predict when GC is going to run either, but you can try and provide opportunities for it to run by debouncing your image loading, batching them into setTimeout calls, etc. Anything you can do to essentially pause the script from doing stuff and return control to FSM component itself. I shouldn't need to point out that trying to rely on this is a bad idea.

It should be relatively easy to test if it's memory/size thing though. Find an image which is failing to load, and then load it by itself. If it doesn't work at least you've ruled out memory.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: SUPERCOOLMAN on 2021-06-11 19:17:45
then I use reflect, but the hit the second behaviour causing the array Promise.all resolved to contain whole bunch of nulls resulting crashes if I don't handle these nulls

from the debug, I feel that the few out of many images failing to load is probably due to loading those somehow requires too much memory while the already load&resized images' original, despite only save resized copy in memory at the moment, hasn't been garbage collected resulting out of memory without crash and the symptom shows up as those images somehow needing lots of memory failed to load while many subsequent images needing way less memory loading without problem. why do smaller file size & dimension png images in from the same scan requires significant more memory is beyond me. perhaps the png compression worked well to compress them to smaller file size
If you were running out of memory, you'd most likely see the out of memory popup which would kill your script. I think the threshold is ~1TB.

When dealing with images, it's not the file size on disk that matters, as these all get loaded in memory as bitmaps. Think of a standard 8bpc jpg/png is going to take 32 bits (8x4 channels) per pixel. If your image was 2000x2000 that's ~16MB of memory, plus whatever overhead is required for the GdiBitmap class (probably not much here). A 4000x4000 image is 64MB in memory. Don't need to load too many of those and you're bumping up against the memory cap. Obviously you can't predict when GC is going to run either, but you can try and provide opportunities for it to run by debouncing your image loading, batching them into setTimeout calls, etc. Anything you can do to essentially pause the script from doing stuff and return control to FSM component itself. I shouldn't need to point out that trying to rely on this is a bad idea.

It should be relatively easy to test if it's memory/size thing though. Find an image which is failing to load, and then load it by itself. If it doesn't work at least you've ruled out memory.

already done all of that debug hence confirming it's actually the memory usage causing images failed to load as resmon shows fk2b memory usage quickly blows up to 2GB or more during the image loads and cliff back down to as if nothing was loaded after image loading&re-size finished. all images loaded fine while memory usage is blowing up, but intermittent images load failures started to show up when memory usage reached ~2GB. I had moved to async image loads to return control back to the main thread (FSM?) immediately and all images loaded just fine. as part of my change few days ago, I had already created a function to perform load+return the resized image to array.map over all image file paths, so an array of original image would never have existed. otherwise, I don't think I would even be able to reach this issue as out of memory popups&crash would have occurred way earlier
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: SUPERCOOLMAN on 2021-06-12 08:12:05
does anyone know how can you draw text over a drawn image or how to erase a drawn image?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: SUPERCOOLMAN on 2021-06-12 09:54:21
please ignore above question. I had set the wrong colour
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Mrakobes on 2021-06-15 18:11:19
Hi, when using the biography script, the player crashes
I raised this topic here https://hydrogenaud.io/index.php?topic=112914.msg998822#msg998822

log https://pastebin.com/uDscCSNz
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-06-15 18:17:49
log https://pastebin.com/uDscCSNz

Nope.

Code: [Select]
Crash location:
Module: foo_uie_esplaylist
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Mrakobes on 2021-06-15 19:58:23
oops, I didn't notice it myself, I just fell several times, the first was the subject, now I looked at the logs - always different! What could it be?
Crash location:
Module: gdi32full
Offset: 59988h
Symbol: "TranslateCharsetInfo" (+20C8h)

Crash location:
Module: foo_dynamic_range
Offset: 1FB10h
Symbol: "foobar2000_get_interface" (+2DA0h)

Crash location:
Module: mozjs-68
Offset: 161D98h
Symbol: "JS::AddServoSizeOf" (+5DC8h)

etc

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-06-17 00:10:57
You're on an old (and early) beta (1.6.5b2). Might want to try and upgrade to 1.6.6 final and see if that improves things.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-06-17 15:34:30
Foobar crashes when trying to open the package manager as soon as any package.json file at packages folder gets corrupted, is empty, some key is missing, etc. without more notice about what the problem is.

Wrong/incomplete packages should be skipped (or show a popup), but not totally crash foobar this way. Specially when you are not even trying to load the culprit
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: dwmartin0906 on 2021-06-22 13:10:02
I'm having a strange issue using on_mouse_mbtn_up.  I have two portable installs, one is DUI with Georgia, and the other is CUI with Georgia-Re-BORN.  Both are on Foobar 1.6.6 and SMP 1.4.1.  With Georgia it works as expected, requiring only a single click.  But with Georgia-Re-BORN it requires a double click.  Any ideas?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-06-23 05:24:52
I suspect foo_ui_hacks is the problem. It's probably configured to let you move the window by holding down the middle button and dragging.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: dwmartin0906 on 2021-06-23 06:45:43
That was it.  Thank you very much.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-06-23 22:23:40
Foobar crashes when trying to open the package manager as soon as any package.json file at packages folder gets corrupted, is empty, some key is missing, etc. without more notice about what the problem is.

Wrong/incomplete packages should be skipped (or show a popup), but not totally crash foobar this way. Specially when you are not even trying to load the culprit
Can't reproduce on dev build.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-06-23 22:34:00
v1.4.1-dev+0f2108d4

This is what happens when you edit the json file and carefully remove a property but the Json is still a valid file.

X

If the json gets corrupted (real corruption, not someone carefully deleting a property  ::) ), it crashes.
If you left a comma in the last key: value pair, it crashes.
If a value is missing but the key is present, it crashes.
etc.

So in fact, it always crashes when there is a real error (not a valid json).


X
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-06-23 23:11:50
already done all of that debug hence confirming it's actually the memory usage causing images failed to load as resmon shows fk2b memory usage quickly blows up to 2GB or more during the image loads and cliff back down to as if nothing was loaded after image loading&re-size finished. all images loaded fine while memory usage is blowing up, but intermittent images load failures started to show up when memory usage reached ~2GB. I had moved to async image loads to return control back to the main thread (FSM?) immediately and all images loaded just fine. as part of my change few days ago, I had already created a function to perform load+return the resized image to array.map over all image file paths, so an array of original image would never have existed. otherwise, I don't think I would even be able to reach this issue as out of memory popups&crash would have occurred way earlier
As MorderKLB correctly mentioned, GDI images are loaded in a special system memory area that is not displayed in usual RAM metrics. And said special area has a much lower memory limit. When said limit is reached, GDI methods start failing randomly and sometimes not really in traceable ways, e.g. image is not loaded but the loading method still returns ok status and reports no error (and that's why you saw promises completion).

I've yet to see SMP to fail GC unreachable objects. So, for GC to work you have to clear the variables that bind the corresponding images.

For example, you should not do this:
Code: [Select]
let images = LoadAllFullSizedImages(image_paths);
let resized_images = ResizeImages(images);

But rather:
Code: [Select]
let images;
for (path of image_paths) {
  let image = LoadImage(path);
  images.push_back(ResizeImage(path));
}
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-06-23 23:15:35
v1.4.1-dev+0f2108d4

This is what happens when you edit the json file and carefully remove a property but the Json is still a valid file.
Maybe it's a WINE thing or smth?

Here is what I get when using json from your post:
X
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-06-23 23:23:22
win 7. No wine.
 
Noticed it because unfortunately a shutdown did corrupt a package json at some point... took me some time to find the problem.
If you need more info, let me know. I can reliably crash it every time I apply any of the changes I wrote. No idea if it's a visual c++ version thing, win 7 related, or what.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-06-23 23:31:31
Latest dev build has 1.4.2 in the version - you only have 1.4.1 something.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: WilB on 2021-06-23 23:46:57
Well I reproduced the crashes on windows 10 in artificial scenarios. fb2k 1.6. SMP 1.4.2-dev+06f421e8. Try closing foobar2000. Delete the author key and its value in package.json or rename package.json to packagee.json. Crashes when try & open foobar2000. I guess this is what regor is talking about. I tested with the bio package.json. Note if foobar2000 is open when you make the changes it'll likely save a valid file on restart & so may not crash. Crash dump below.

Not sure if this is the same crash as reported by Sergey77 for which I believe he sent you the crash dump.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-06-23 23:52:34
Well I reproduced the crashes on windows 10 in artificial scenarios. fb2k 1.6. SMP 1.4.2-dev+06f421e8. Try closing foobar2000. Delete the author key and its value or rename package.json to packagee.json. Crashes when try & open foobar2000. I guess this is what regor is talking about. I tested with the bio package.json. Note if foobar2000 is open when you make the changes it'll likely save a valid file on restart & so may not crash. Crash dump below.

Not sure if this is the same crash as reported by Sergey77 for which I believe he sent you the crash dump.
Thanks for the dump! Yours is a different case from regor's though, since the one you have is a crash on startup.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-06-23 23:54:11
Well I reproduced the crashes on windows 10 in artificial scenarios. fb2k 1.6. SMP 1.4.2-dev+06f421e8. Try closing foobar2000. Delete the author key and value or rename package.json to packagee.json. Crashes when try & open foobar2000. I guess this is what regor is talking about. I tested with the bio package.json. Note if foobar2000 is open when you make the changes it'll likely save a valid file on restart & so may not crash. Crash dump below.

Not sure if this is the same crash as reported by Sergey77 for which I believe he sent you the crash dump.
Ofc if you have the packaged loaded within foobar, the json gets rewritten while foobar is loaded (thus reverting the edit). You have to either restart or unload the package, edit the files, and then open the package manager again. And yes, mine happens when opening the package manager. Have not tried the startup case though.

This works with errors (no version)
Code: [Select]
{
  "author": "TheQwertiest",
  "description": "This is an example package that illustrates the package structure and basic features.",
  "enableDragDrop": false,
  "id": "{A584FDEF-C88A-4849-94D5-F33C71649927}",
  "name": "Example package",
  "shouldGrabFocus": true
}

Crash (missing value)
Code: [Select]
{
  "author": "TheQwertiest",
  "description": "This is an example package that illustrates the package structure and basic features.",
  "enableDragDrop": false,
  "id": "{A584FDEF-C88A-4849-94D5-F33C71649927}",
  "name": "Example package",
  "shouldGrabFocus":
}

Crash (comma at end)
Code: [Select]
{
  "author": "TheQwertiest",
  "description": "This is an example package that illustrates the package structure and basic features.",
  "enableDragDrop": false,
  "id": "{A584FDEF-C88A-4849-94D5-F33C71649927}",
  "name": "Example package",
  "shouldGrabFocus": true,
  "version": "1.0.0",
}

Crash (empty)
Code: [Select]

EDIT: Following WilB report

package.json -> packagee.json
Popup: (No crash)
Quote
Corrupted package: can't find `package.json`

package.json -> (empty file)
No Popup. SMP panel has been removed without notice. (not the script, the entire panel!)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-06-24 00:03:12
@WilB reproduced and fixed on dev build.
@regor I do understand your scenario, I just can't reproduce it. Your issue was most likely fixed a long time ago. As marc2003 mentioned above, you are using a really old dev build (Feb 12 to be precise). Hence the bugs that I can't see.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-06-24 00:16:53
Updated to the latest dev, seem to solve it as you noted.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: WilB on 2021-06-24 12:18:40
Thanks, the crash seems fixed in the dev build.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-06-26 01:01:12
Bug:

Try copying this into any property:
Code: [Select]
style,Psychedelic Folk;style,Latin Rock;style,Electropop;style,Jam;style,Modal Jazz;style,Chicano Rock;style,Soul Blues;style,Thrash Metal;style,Contemporary Jazz;style,British Blues;style,Italian Prog. Rock;style,Jazz-Rock;style,Southern Soul;style,Raga Rock;style,Doom Metal;style,Shoegaze;style,Contemporary Blues;style,Tulsa Sound;style,Jazz-Rap;style,Chanson;style,Guitar Jazz;style,Power Pop;style,Aussie Rock;style,Britpop;style,Eclectic Prog;style,Arena Rock;style,Glam Rock;style,Romantic;style,Classic Grunge;style,Boogie Rock;style,Noise Rock;style,Post-Grunge;style,Desert Blues;style,New Wave;style,Cantautor;style,Freak Folk;style,Heartland Rock;style,Post-Punk Revival;style,Space Rock;style,Post-Bop;style,Ambiental;style,Alt. Country;style,Bebop;style,Conscious;style,Spanish Folk;style,Fusion;style,Outlaw Country;style,Pop Metal;style,Classic Metal;style,Neo Soul;style,Beat Music;style,Alt. Rap;style,British Metal;style,Chicago Blues;style,Jam Band;style,British Folk-Rock;style,Roots Rock;style,Folk Pop;style,Rockabilly;style,Lo-Fi;style,Soft Rock;style,Baroque Pop;style,R&B;style,Heavy Prog;style,Country Folk;style,Garage Rock Revival;style,Acoustic;style,Garage Rock;style,Symphonic Prog;style,Experimental;style,Hard-Bop;style,Country Rock;style,Neo-Psychedelia;style,Stoner Rock;style,Traditional Pop;style,Crossover Prog;style,Piano Jazz;style,Southern Rock;style,Spanish Rock;style,Swing;style,Songwriter;style,Hi-Fi;style,Pop Rock;style,Indie;style,Acid Rock;style,Americana;style,Electric Blues;style,Blues Rock;style,Live;style,Classic Rock;style,Female Vocal;style,Garage Pop;style,Honky Tonk;style,Hip-Hop Soul;style,Easy Listening;style,Chill-Out Downtempo;style,Nu Jazz;style,Jazz-Pop;style,Old-School;style,Jump Blues;style,Punk Pop;style,Hindustani;style,German Rock;style,Son;style,Jazz-Funk;style,Future Bass;style,House;style,Traditional Country;style,Isicathamiya;style,Comedy;style,Celtic Punk;style,Lounge;style,Proto-Punk;style,Niger Folk;style,Traditional American Folk;style,Psychedelic Grunge;style,Nashville Sound;style,Mexican Rock;style,Dub;style,Renaissance;style,Proto-Prog;style,Folk Metal;style,Uruguayan Rock;style,Folk Punk;style,Modernist;style,Israeli Rock;style,Underground Rap;style,Hair Metal;style,Contemporary Classical;style,Jazz Drumming;style,Folktronica;style,Nubian Folk;style,Melodic Hardcore;style,Funk Metal;style,Reggae Fusion;style,Philadelphia Soul;style,Rap Metal;style,Close Harmony;style,Gypsy-Jazz;style,New Acoustic;style,Flamenco Rock;style,Deep Funk Revival;style,Canterbury Scene;style,Disco;style,Trap;style,Brill Building Sound;style,Spanish Hip-Hop;style,Classic Funk;style,Detroit Blues;style,Gothic Metal;style,Black Metal;style,Electro;style,British Folk-Jazz;style,P-Funk;style,Sludge Metal;style,Contemporary Country;style,Pop Rap;style,Pop Folk;style,Vaudeville Blues;style,New Orleans R&B;style,Synth-Pop;style,Post-Rock;style,Proto-Stoner Rock;style,Baroque;style,Hardcore Punk;style,Tex-Mex;style,Avant-Garde Jazz;style,Horrorcore;style,South Coast;style,Motown Sound;style,Instrumental Country;style,Smooth Jazz;style,Riot Grrrl;style,Cowpunk;style,Glam Metal;style,Memphis Blues;style,Big Band;style,Irish;style,Rockabilly Revival;style,Midwest;style,Torch Songs;style,Free Jazz;style,Medieval;style,Roots Reggae;style,Piano Blues;style,Soul-Jazz;style,Vocal Pop;style,Symphonic Metal;style,Bossa Nova;style,Cool Jazz;style,Psychedelic Soul;style,Latin-Jazz;style,Afro-Cuban;style,Grunge Metal;style,Celtic New Age;style,Surf Rock;style,Hardcore;style,Gangsta;style,Country Pop;style,Delta Blues;style,Pop Punk;style,Grunge Punk;style,American Primitive Guitar;style,Modern Electric Blues;style,East Coast;style,Texas Blues;style,Dixieland;style,Country Boogie;style,Free Improvisation;style,Hill Country Blues;style,Retro Rock;style,Post-Punk;style,Grunge Rock;style,Bluegrass;style,Sadcore;style,Progressive Metal;style,Ska Punk;style,Rock Opera;style,Alt. Metal;style,Mainstream Jazz;style,Pub Rock;style,Sunshine Pop;style,Garage Punk;style,Instrumental Rock;style,Speed Metal;style,Malian Folk;style,Flamenco;style,Trip Hop;style,Bal Folk;style,Detroit Rock;style,Geek Rock;style,Folk Baroque;style,Tishoumaren;style,Smooth Soul;style,Proto-Metal;style,Pagan Folk;style,Traditional European Folk;style,Nu Metal;style,Country Blues;style,Celtic;style,Krautrock;style,West Coast;style,Dream Pop;style,Harmonica Blues;style,Psychedelic Funk;style,Contemporary Funk;style,Psychedelic Rap;style,Argentinian Folk;style,Funk Rock;style,Punk Rock;style,Psychedelic Pop;style,British Psychedelia;style,Contemporary Folk;style,Progressive Folk;style,Argentinian Rock;style,Contemporary Rock;style,90s Rock;style,80s Rock;genre,Música Popular Brasileira;genre,Musical;genre,Indian;genre,Gospel;genre,Japanese;genre,Greek;genre,Nubian;genre,Christmas;genre,New Age;genre,Reggae;genre,Soundtrack;genre,Electronic;genre,Funk;genre,African;genre,Classical;genre,Grunge;genre,Latin;genre,Rock & Roll;genre,Punk;genre,Hip-Hop;genre,World;genre,Pop;genre,Soul;genre,Country;genre,Jazz Vocal;genre,Heavy Metal;genre,Instrumental;genre,Jazz;genre,Folk;genre,Blues;genre,Hard Rock;genre,Alt. Rock;genre,Folk-Rock;genre,Rock;genre,Progressive Rock;genre,Psychedelic Rock;style,Venezuelan Folk;style,Neo-Prog;style,Rond;style,Andro;style,Ska Revival;style,Third Stream;style,Kabuki;style,Japanese Classical;style,Christian Rock;style,Tuareg Music;style,Deep Funk;style,Israeli;style,Afghan Folk;style,Tuvan;style,Asian Folk;style,Jazz-Blues;style,Post-Metal;style,Spoken Word;style,Cumbia;style,Gnawa;style,Candombe Beat;style,Future Jazz;style,Avant-Garde Classical;style,Gothic Rock;style,Sahrawi Folk;style,Dance-Rock;style,Calypso;style,Italian Rock;style,Old-Timey;style,Reggaeton;style,Chillwave;style,Stoner Doom;style,Psychedelic Blues;style,Funk Blues;style,Ragga Hip-Hop;style,Contemporary R&B;style,Choral;style,Polka;style,Afrobeat;style,Radio Program;style,Hang Music;style,Groove Metal;style,Europop;style,Japanese Prog. Rock;style,Jig;style,Circle;style,Traditional Folk;style,Bakersfield Sound;style,Scottish;style,Golden Age;style,Stoner Sludge;style,Bourree;style,Healing Music;style,Doo Wop;style,Zydeco;style,Mauritanian Folk;style,Rumba Fusión;style,Progressive Bluegrass;style,Industrial Metal;style,Exotica;style,Power Metal;style,British Hip-Hop;style,Vals;style,Israeli Folk;style,German Folk;style,Mazurka;style,Afro-Rock;style,Children's Music;style,Griot;style,Acid Jazz;style,Classical Period;style,Mexican Folk;style,Éntekhno;style,Instrumental Hip-Hop;style,Avant-Prog;artist,Trobar de Morte;artist,A Tribe Called Quest;artist,Bob Dylan & The Band;artist,Nancy Sinatra;artist,Ben Harper & The Innocent Criminals;artist,HIM;artist,Nneka;artist,Alice In Chains;artist,Beethoven;artist,Comus;artist,Itoiz;artist,Jamiroquai;artist,The Siegel-Schwall Band;artist,Link Wray;artist,The Kooks;artist,Uncle Tupelo;artist,Blondie;artist,Molly Hatchet;artist,Nilsson;artist,Anacrusa;artist,Buena Vista Social Club;artist,Focus;artist,Muse;artist,The Darkness;artist,Procol Harum;artist,Awon & Phoniks;artist,Poco;artist,Radio Moscow;artist,Rival Sons;artist,The Moody Blues;artist,Lauryn Hill;artist,Stills & Nash;artist,P.O.D.;artist,The Dave Brubeck Quartet;artist,The Troggs;artist,Motorpsycho;artist,Slayer;artist,The Tragically Hip;artist,Traffic;artist,Almendra;artist,Blackalicious;artist,Tito & Tarantula;artist,Fairport Convention;artist,La Raíz;artist,T. Rex;artist,Stills;artist,Nash & Young;artist,Veruca Salt;artist,Vivaldi;artist,Love;artist,Candlebox;artist,Stevie Ray Vaughan & Double Trouble;artist,The Blasters;artist,The Steve Miller Band;artist,The Allman Brothers Band;artist,Elephant Revival;artist,Vox Dei;artist,The Cranberries;artist,Miles Davis Quintet;artist,Cheap Trick;artist,Renaissance;artist,Dover;artist,The Jeff Healey Band;artist,Monster Magnet;artist,Steeleye Span;artist,Journey;artist,Pappo's Blues;artist,Nick Cave & The Bad Seeds;artist,Linkin Park;artist,Bill Evans Trio;artist,Quicksilver Messenger Service;artist,Uriah Heep;artist,Frank Sinatra & The Count Basie Orchestra;artist,The Ozark Mountain Daredevils;artist,Wagner;artist,Joss Stone;artist,Bob Seger & The Silver Bullet Band;artist,Mott The Hoople;artist,The Black Crowes;artist,Blackmore's Night;artist,Bon Jovi;artist,The Pretty Things;artist,Steely Dan;artist,Coldplay;artist,Jimi Hendrix & Curtis Knight;artist,Curtis Knight & The Squires;artist,Magna Carta;artist,Rainbow;artist,The Yardbirds;artist,La Oreja de Van Gogh;artist,Queens Of The Stone Age;artist,Van Halen;artist,Big Brother and The Holding Company;artist,Paul McCartney & Wings;artist,Cypress Hill;artist,Buffalo Springfield;artist,Mark Lanegan Band;artist,Savoy Brown;artist,Son Volt;artist,Them;artist,Mountain;artist,Les Menestriers;artist,The Guess Who;artist,Planxty;artist,John Mayall's Bluesbreakers;artist,Grant Green;artist,Eva Cassidy;artist,Mighty Sam McClain;artist,The West Coast Pop Art Experimental Band;artist,Oasis;artist,Blue Öyster Cult;artist,Heron;artist,Ten Years After;artist,Van Der Graaf Generator;artist,America;artist,Cold Chisel;artist,The Black Keys;artist,Grand Funk Railroad;artist,Mazzy Star;artist,Pixies;artist,The Smashing Pumpkins;artist,The Band;artist,Awon;artist,Pescado Rabioso;artist,The Flamin' Groovies;artist,The 13th Floor Elevators;artist,Heart;artist,Lady Gaga;artist,Small Faces;artist,The Mothers of Invention;artist,The Velvet Underground;artist,Faun;artist,Black Flag;artist,Free;artist,UFO;artist,Derek and The Dominos;artist,Scorpions;artist,R.E.M.;artist,Soundgarden;artist,The Shadows of Knight;artist,Whitesnake;artist,La Pegatina;artist,Platero y Tú;artist,King Crimson;artist,The Robert Cray Band;artist,38 Special;artist,Spirit;artist,Big Star;artist,OutKast;artist,Bob Marley & The Wailers;artist,Nirvana;artist,The Jayhawks;artist,Omnia;artist,Yes;artist,Elvis Costello & The Attractions;artist,Kula Shaker;artist,Red Hot Chili Peppers;artist,Wigwam;artist,Nightwish;artist,The Incredible String Band;artist,Megadeth;artist,Dinosaur Jr.;artist,Phoniks;artist,PJ Harvey;artist,Queen;artist,Passenger;artist,Guns N' Roses;artist,Extremoduro;artist,Tom Petty & The Heartbreakers;artist,Diana Krall;artist,Hawkwind;artist,Captain Beefheart and The Magic Band;artist,Jefferson Airplane;artist,Rush;artist,Eagles;artist,Pearl Jam;artist,Cream;artist,Neil Young & Crazy Horse;artist,Simon & Garfunkel;artist,Creedence Clearwater Revival;artist,The Mamas and The Papas;artist,Barclay James Harvest;artist,Eels;artist,Deep Purple;artist,Aerosmith;artist,Supertramp;artist,Thin Lizzy;artist,Black Sabbath;artist,The Oscar Peterson Trio;artist,Dire Straits;artist,Nat King Cole;artist,The Who;artist,Chet Atkins;artist,Chopin;artist,The Beach Boys;artist,Fleetwood Mac;artist,Iron Maiden;artist,Jethro Tull;artist,Donovan;artist,Santana;artist,The Beatles;artist,The Kinks;artist,The Jimi Hendrix Experience;artist,Led Zeppelin;artist,The Rolling Stones

The string is not displayed. The same on a popup, although the string exists and can be copied/pasted into notepad without problems.
Can't reproduce:
X
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-06-26 10:11:05
Click on it to edit the text after you copied it on the property and it was saved.
The text stops to be displayed.

On input popups, if you use that string as default value, it is not shown at all
Still happening on last dev build (just tried it)
X
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-06-26 10:58:40
Show us where else in foobar you can paste and edit that string.

Library menu>Search? Nope
File>Preferences>Display>Default UI>Playlist view>Custom columns? Nope.
Album list>Filter box? Nope.



Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-06-26 11:03:03
And that means... (?)
It's a tool to check the entire library tags, so you can obviously put all the "right" values once checked to exclude them.
It can be copied/pasted fine on many text editors. And the popup window exports that list totally fine too (foobar, omg).

Don't get your point. Is it really big? yes. And what? It clearly makes no sense to use that list on Search, view or filter box.

If there is a display limit on properties or the input box just say that and done. But those are clearly 2 places where that string makes sense, and I find easier to point users to copy/paste the list at the end at properties, than telling them to edit another external file. That still doesn't solve the input box problem anyway, which would not be able to show the list.

Spoiler (click to show/hide)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-06-26 11:13:52
edit: not worth it. I'll just use the ignore list from now on.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-06-26 11:15:40
PD: now if you ask me about pasting that string somewhere within foobar to prove nothing, here we go hahaha
Spoiler (click to show/hide)

EDIT: don't' get your passive aggressive reactions every-time, although I appreciate your help many times, so it's fine if you want to ignore me. Not sure what's the problem with so many people on this forum, since it seems to be the common behavior. And it's specially hard for people whose mother language is not English.

I'm just asking you why don't you  simply say what you want to say instead of pointing people to what you seem to think are "stupid" reasons. If you want to note there is an UI limit displaying too long strings say that. It's pretty easy, don't you think? The limit is clearly not on every window, so what you think is so obvious and stupid, is not for me.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-06-26 11:23:19
@regor , still can't reproduce:
Spoiler (click to show/hide)

[EDIT]: default value in inputbox works as well
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-06-26 11:28:02
i think it's a Window 7 bug/limitation (I have a windows 10).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-06-26 11:29:31
It's true that pasting that string into some other foobar places reproduce the same behavior (search/filter/facets, ...). But on the preference panels works right (see at top). May be a win 7 thing as you noted, I have access to another win 7 system with a clear foobar installation and a win 10 system, so I will try on both and report.

Spoiler (click to show/hide)

The string is there, even if it's not displayed, so it can be copied into other place, edited, and pasted back again. So there is a workaround for the bug. Thanks anyway!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-06-26 11:36:41
@regor : FYI: https://github.com/TheQwertiest/foo_spider_monkey_panel/issues/143

PS: please, hide big images under spoiler tags in the future, coz they make browsing a huge pita =)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-06-26 11:49:28
Edited the posts. Will have it in mind from now on.

And thanks

Btw, are negative lookahead assertions (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Assertions) supported on SMP? OR that's one of  RegExp features not included?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-06-26 11:52:17
Edited the posts. Will have it in mind from now on.

And thanks

Btw, are negative lookahead assertions (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Assertions) supported on SMP? OR that's one of  RegExp features not included?
Well, that sample produces the same output both in browser and SMP, which most likely means that it works.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-06-26 12:05:45
I ask because yesterday I tried to replace all single '&' with '&&' but skip all existing '&&', and it was not possible using negative look-ahead:

Code: [Select]
"use strict";

const text = "This is my && text and & text";

console.log(text.replace(/&&/g,'&').replace(/&/g,'&&')); // 2 steps but works as intended
console.log(text.replace(/&(?!&)/g,'&')); // Needs a negative look-ahead too to work right

Code: [Select]
"use strict";

const text = "This is my && text and & text";
console.log(text.replace(/(?<!&)&/g,'&')); // Throws error
console.log(text.replace(/(?<!&)&(?!&)/g,'&')); // Also throws error

The regexp is right (I had to change from javscript to PCRE though):
https://regexr.com/
Spoiler (click to show/hide)
But the mozilla documentation states it's included since ECMA 2018 (?).

EDIT:  all this comes from an omission at the github doc:
https://theqwertiest.github.io/foo_spider_monkey_panel/assets/generated_files/docs/html/MenuObject.html
Because menu entries don't allow single '&'. In win 7 they are converted into blank spaces and in win 10 they make next char underscored.
Which is the warning given here:
https://theqwertiest.github.io/foo_spider_monkey_panel/assets/generated_files/docs/html/GdiGraphics.html#GdiDrawText
But it's missing on the menu object section, where it applies the same (and there is no flag to change that behavior?). So they must be doubled.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-06-26 13:14:42
Another request, https://hydrogenaud.io/index.php?topic=120979.msg999866#msg999866

I use fb.GetQueryItems() with try/catch to check queries (for my playlist manager), but forgot Autoplaylists allow the SORT command at the end. The previous method obviously fails with that command, could it be considered on future releases? Either the same method, or a V2 which allows checking the SORT part too.

Right now either you allow anything (like marc2003 old script) and it will obviously crash as soon as there is a typo, or you don't check anything after SORT to allow those type of autoplaylists.

The second approach is compromise, since it will still crash if you make a typo after the SORT part, even if the other part is valid.
Spoiler (click to show/hide)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-06-26 13:30:49
Is it possible to check for compatibility Spider Monkey Panel v.1.4.1 and foo dockable panels (foo_dockable_panels).
foobar 1.5 crash when I want to add Spider Monkey Panel v.1.4.1. using foo dockable panels.
foo_dockable_panels is a known crashware, hence I'm not really keen on investing time in fixing it's compatibility.

There is foo_flowing though, that looks like a better alternative: https://hydrogenaud.io/index.php?topic=120109.0
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-06-26 13:57:09
About the query checks, meanwhile this edit to my helpers should work for everybody. I'm assuming:
- The sort patters are those and only those.
- The TF part should be right, which can not be checked easily (and should be done using native methods). If you put something like a func without quotes after sort it will still crash.
- The TF part has at least 2 quotes when using functions, but obviously it's not fool-perfect.
- The TF part uses pairs of quotes (2, 4, 6..) when there is a function.

So a SMP method to check the sorting would still be preferred.

Code: [Select]
function checkQuery(query, bAllowEmpty, bAllowSort = false) {
let bPass = true;
if (!bAllowEmpty && !query.length) {return false;}
let queryNoSort = query;
if (bAllowSort) {
const fromIndex = query.indexOf('SORT');
if (query.indexOf('SORT') !== -1) {
if (query.indexOf(' SORT BY ') !== -1) {queryNoSort = query.split(' SORT BY ')[0]}
else if (query.indexOf(' SORT DESCENDING BY ') !== -1) {queryNoSort = query.split(' SORT DESCENDING BY ')[0]}
else if (query.indexOf(' SORT ASCENDING BY ') !== -1) {queryNoSort = query.split(' SORT ASCENDING BY ')[0]}
else {return false;} // Has a typo on sort
if (query.indexOf('$', fromIndex) !== -1) { // Functions require quotes around them
const firstQuote = query.indexOf('"', fromIndex);
if (firstQuote === -1)  {return false;}
else if (firstQuote === query.lastIndexOf('"')) {return false;}
else if (query.slice(fromIndex).match(/"/g).length % 2 !== 0) {return false;}
}
}
}
try {fb.GetQueryItems(new FbMetadbHandleList(), queryNoSort);}
catch (e) {bPass = false;}
return bPass;
}

// Must check query first to be sure it's a valid query!
function stripSort(query) {
let queryNoSort = query;
if (query.indexOf('SORT') !== -1) {
if (query.indexOf(' SORT BY ') !== -1) {queryNoSort = query.split(' SORT BY ')[0]}
else if (query.indexOf(' SORT DESCENDING BY ') !== -1) {queryNoSort = query.split(' SORT DESCENDING BY ')[0]}
else if (query.indexOf(' SORT ASCENDING BY ') !== -1) {queryNoSort = query.split(' SORT ASCENDING BY ')[0]}
}
return queryNoSort;
}
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-06-26 14:25:11
Regarding autoplaylists sample...

https://github.com/TheQwertiest/smp_2003/pull/6
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-06-26 17:52:11
Okay, set this as the content of one.js and let's see if this is minimally reproducible for you:
Fixed in the dev build
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kutuzof on 2021-06-27 09:16:42
The player crashes when adding a new panel to the layout.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-06-27 12:36:25
The player crashes when adding a new panel to the layout.
Not sure, how you've managed to reach that state, but I've added a safe-guard in the dev build.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kutuzof on 2021-06-27 14:36:32
Panels also crash when browsing the menu for a long time.
Spoiler (click to show/hide)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-06-27 16:08:12
@kutuzof fixed in dev build
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2021-06-27 16:54:06
Hey @TheQwertiest, glad you're back  8)

Just wanted to let you know Opentype (.otf) fonts are not initialized with utils.CheckFont and loaded via gdi.Font in AFTER installing GDI+.
But Truetype (.ttf) fonts are displayed correctly... I don't know if it's a SMP or Wine issue...

Last month I wrote two emails to Wine-Devs and still haven't received an answer... I guess they have other problems ;)
Here is an excerpt from the mail:

Spoiler (click to show/hide)

-TT
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kutuzof on 2021-06-27 17:05:37
@TheQwertiest, thank you. With the "Shift" button, it does not open the full list of the "View" menu, or does not open it at all.
Spoiler (click to show/hide)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-06-27 19:32:37
@TT , not sure what your problem is, can you attach a repro code?

@kutuzof if you are talking about `fb.CreateMainMenuManager()` + `Init('View')`, then, well, works for me. You could try `MainMenuManager All-In-One.js` sample to see if it makes a difference. You may also try increasing `base_id` and `count` in `BuildMenu` in case you are somehow reaching the limit.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2021-06-27 23:15:47
Hey @TheQwertiest, glad you're back  8)

Just wanted to let you know Opentype (.otf) fonts are not initialized with utils.CheckFont and loaded via gdi.Font in AFTER installing GDI+.
But Truetype (.ttf) fonts are displayed correctly... I don't know if it's a SMP or Wine issue...

Last month I wrote two emails to Wine-Devs and still haven't received an answer... I guess they have other problems ;)
Here is an excerpt from the mail:

Spoiler (click to show/hide)

-TT

For anyone else wondering regarding the same issue:

The only downloadable form of GDI+ is for Windows XP, and Windows XP never supported OTF.

-TT
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-06-28 18:14:52
Okay, set this as the content of one.js and let's see if this is minimally reproducible for you:
Fixed in the dev build
Sweet, I'll have to give that a check.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-06-28 18:38:07
Sweet, I'll have to give that a check.
I would really appreciate if you could take a look at your PR, so that I could ship it with the release =)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-06-30 00:12:05
Version: 1.5.0
Link: https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/tag/v1.5.0
Changelog:
Spoiler (click to show/hide)
Detailed description of API changes: https://theqwertiest.github.io/foo_spider_monkey_panel/docs/script_documentation/api_changes/#v150
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2021-06-30 02:00:33
Great work @TheQwertiest !

Just tested v1.5 out and it works smooth, the performance is also better!

Thanks for your dedication and hard work!
Now I only need to fix the drag and drop issue on Wine and we're ready to go =)

Cheers

-TT
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2021-06-30 02:24:55
- Deleted -
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-06-30 05:07:46
Regarding the playlist lock functionality, I really think you need to provide a method to get the playlist lock name. Knowing a playlist is locked but not knowing who owns it will lead to confusion if providing buttons/menus to add/edit/remove them.

Since I added this functionality to JScript Panel and the JSplaylist sample, these menu options would be greyed out if another component owned the lock.

(https://i.imgur.com/kAXWH2R.png)


Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-06-30 10:05:08
Regarding the playlist lock functionality...
Good point, thanks!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-07-01 00:45:50
Updated Script Showcase (https://theqwertiest.github.io/foo_spider_monkey_panel/docs/script_showcase/) page:
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-07-01 13:55:44
Great. Btw, I can provide you the images for my scripts if you want to add them.

Would it be possible to add a framework category? To add there base scripts which can be used by users to create its own full scripts. Documentation would be present along the repositories:
https://github.com/regorxxx/Menu-Framework-SMP

Currently working on an options framework: as you can see it's pretty much equal to Wilb html's one, but within an SMP panel, so functional for non IE and wine users. And it would work with arbitrary input, so valid for any type of script.
Spoiler (click to show/hide)

And a tag map framework: (both maps use the same base framework, the cloud tag is equally composed by points with coordinates)
Spoiler (click to show/hide)

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2021-07-01 14:54:57
Thanks @TheQwertiest =)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-07-01 16:26:31
Currently working on an options framework: as you can see it's pretty much equal to Wilb html's one, but within an SMP panel, so functional for non IE and wine users. And it would work with arbitrary input, so valid for any type of script.
Cool stuff. Randomly, I also started down this road, but decided to build out a full UI library first before generating config pages from json schemas. I went with material design as my basis because I thought it'd be fun and challenging. Here's what I've got so far:

(https://user-images.githubusercontent.com/2282004/124149385-248a0600-da56-11eb-99b1-e071180ff332.png)

It's pretty accurate, even down to the subtle onhover effects (see Blue Toggle). Had to make some changes to FSM to get the text box highlighting stuff to work correctly, but now that 1.5 is released I'll probably start back working on this. The color pickers are a little janky, and need some way to type in values, and I need to make some usability improvements to how you create controls, but otherwise it's pretty much done. If you're interested i can share the code before it makes it to Georgia.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-07-01 16:50:14
FWIW, the native windows colour picker is available (utils.ColourPicker).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-07-01 20:49:02
FWIW, the native windows colour picker is available (utils.ColourPicker).
Yeah, I was trying to do it without using any modal popups (select controls obviously have JS popups) because the UX nerd in me wants to show how things look while you're dragging sliders -- i.e. I can show mocked portions of the screen and adjust colors on the fly -- which I think is a better experience, but ultimately I may just scrap it and go that route. They do kinda stick out from everything else unfortunately. I did some research on better color picker controls, but pretty much all of them are beyond the scope of what's possible with FSM or my own knowledge of color spaces.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-07-01 22:22:01
Added a page containing known issues and workarounds for WINE: https://theqwertiest.github.io/foo_spider_monkey_panel/docs/wine/
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-07-01 22:31:50
Great. Btw, I can provide you the images for my scripts if you want to add them.
Sure, but it needs to be
- static (i.e. no animations).
- compact (i.e. minimal zooming required).
- display the actual functionality of the script without showing a lot of unrelated things.

It should also not look very out of place in the dark theme of the site.

Would it be possible to add a framework category? To add there base scripts which can be used by users to create its own full scripts.
I need to think a bit about how to organize it, but I think it's doable. (I've zero UI sense, so it takes a lot of time to decide on those things...)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-07-01 23:09:14
Currently working on an options framework: as you can see it's pretty much equal to Wilb html's one, but within an SMP panel, so functional for non IE and wine users. And it would work with arbitrary input, so valid for any type of script.
Cool stuff. Randomly, I also started down this road, but decided to build out a full UI library first before generating config pages from json schemas. I went with material design as my basis because I thought it'd be fun and challenging. Here's what I've got so far:

(https://user-images.githubusercontent.com/2282004/124149385-248a0600-da56-11eb-99b1-e071180ff332.png)

It's pretty accurate, even down to the subtle onhover effects (see Blue Toggle). Had to make some changes to FSM to get the text box highlighting stuff to work correctly, but now that 1.5 is released I'll probably start back working on this. The color pickers are a little janky, and need some way to type in values, and I need to make some usability improvements to how you create controls, but otherwise it's pretty much done. If you're interested i can share the code before it makes it to Georgia.
That would be great! As long as it works out of the box for other scripts, I really think these things would really make it easier to create new scripts without reinventing the wheel for every new one.

Great. Btw, I can provide you the images for my scripts if you want to add them.
Sure, but it needs to be
- static (i.e. no animations).
- compact (i.e. minimal zooming required).
- display the actual functionality of the script without showing a lot of unrelated things.

It should also not look very out of place in the dark theme of the site.

Ok! No problem, easy. (the bg colours are configurable in 2 of them anyway)

Would it be possible to add a framework category? To add there base scripts which can be used by users to create its own full scripts.
I need to think a bit about how to organize it, but I think it's doable. (I've zero UI sense, so it takes a lot of time to decide on those things...)
At first I thought about editing the foobar wiki (https://wiki.hydrogenaud.io/index.php?title=Category:Foobar2000), but I do really think it would make more sense some kind of list at the place people already download SMP (having a wiki as a secondary resource if anything). Maybe a mix of both would do, links to github on your site (following your simple ui approach), with a link to +info at the wiki.

PD: about the known wine issues, don't forget html popups are totally broken, so other methods are needed (like editing ini files, json, menus, drawing options panel within the panel using js, etc.)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2021-07-01 23:14:16
Added a page containing known issues and workarounds for WINE: https://theqwertiest.github.io/foo_spider_monkey_panel/docs/wine/
Also add: TrueType (.ttf) fonts need to be called via the 'UniqueID' TTF name or the fonts will not be found and recognized via utils.CheckFont() and gdi.Font().
Best would be to have both 'UniqueID' TTF and 'Family' PS/TTF named the same to have Windows and Linux compatibility.
This took me a LONG time through trial and error because there really is no documentation online...

Also as @regor mentioned, WilB's biography script will crash on right click ( option popup ) in Wine...

And this is the drag n drop issue in Wine, you can drag ( selection is displayed ) the music folder onto the playlist,
a plus icon will be also displayed but if you drop nothing happens. No music files are added, the command/execution will be ignored:

Spoiler (click to show/hide)

But native drag n drop in original foobar in Wine works...

More info see here: https://github.com/TT-ReBORN/Georgia-ReBORN/issues/2


-TT
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: paregistrase on 2021-07-02 00:34:07
Added a page containing known issues and workarounds for WINE: https://theqwertiest.github.io/foo_spider_monkey_panel/docs/wine/

I always had to comment out this in scripts, is related with copy and paste i think.

Code: [Select]
const docTxt = ''s.doc.parentWindow.clipboardData.getData('text')*; let idx, Index = 1;

Scripts in sample folder complain about AppliedDPI, this can be avoid adding to the registry

Code: [Select]
HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics
AppliedDPI REG_DWORD 0x00000060 (96)

Scripts do not download images. I don't know why
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-07-02 17:54:13
That would be great! As long as it works out of the box for other scripts, I really think these things would really make it easier to create new scripts without reinventing the wheel for every new one.
Agreed. The only issue with any UI framework is handling the callbacks well. I've paired mine down to the bare minimum but still need to handle: on_mouse_move, on_mouse_lbtn_up, on_mouse_lbtn_down, on_char, and on_key_down (maybe on_mouse_wheel too?). If you do things in a sane way (so *not* the way I ever do things) and have separate FSM windows for these things it's no problem, but if you need to combine them in an existing theme which already has its own callbacks, then things get a little more complex.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-07-02 17:57:45
Agreed. The only issue with any UI framework is handling the callbacks well. I've paired mine down to the bare minimum but still need to handle: on_mouse_move, on_mouse_lbtn_up, on_mouse_lbtn_down, on_char, and on_key_down (maybe on_mouse_wheel too?). If you do things in a sane way (so *not* the way I ever do things) and have separate FSM windows for these things it's no problem, but if you need to combine them in an existing theme which already has its own callbacks, then things get a little more complex.
Are you talking about this? =)
https://github.com/TheQwertiest/foo_spider_monkey_panel/projects/1#card-14354341

PS: This can be easily emulated even in current SMP - https://github.com/TheQwertiest/CaTRoX_QWR/blob/78032d1e8af94d9c97a3a313c7c40bf5624119f6/package_content/%7B1583C4B7-53AD-403F-8F7E-CB20490AAA26%7D/scripts/js_marc2003/js/helpers.js#L52 and https://github.com/TheQwertiest/CaTRoX_QWR/blob/61eecfa4159e3714d58f53ae942d5f1861e83fb2/theme/Scripts/js_marc2003/js/helpers.js#L989
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-07-02 18:09:39
Are you talking about this? =)
https://github.com/TheQwertiest/foo_spider_monkey_panel/projects/1#card-14354341

PS: This can be easily emulated even in current SMP
Ha! That would simplify things.

I know it's not that difficult to emulate, but I was thinking more from a "User Regor wants to add my UI buttons into his theme so he'll need to call my callbacks from his" perspective. You could go the other way and make anyone integrating this framework register their callbacks with mine, but if you're going to be adding event listeners probably no point in worrying about it now.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-07-02 18:40:18
@TheQwertiest 1.5 appears to be causing foobar itself to completely hang when loading themes in some situations. I cannot tell why this is but repeated reloads of Georgia (and Georgia-reborn) cause it to happen. Just load the theme in a FSM panel, reload a few times and it should happen -- but it's not related to reloading quickly. @dwmartin0906 reported this to me, and I was easily able to repro. Unfortunately foobar completely becomes unresponsive and needs to be killed so there's no crash report to point to anything. It's happening in the async include calls my theme uses at startup, and happens at a different file each time it seems. If I disable calling include inside async promises it stops occurring.

(https://user-images.githubusercontent.com/2282004/124310589-01348900-db32-11eb-81ab-72e8eb5ccdc5.png)

Edit: I've tried to create a minimally reproducible sample, but no dice. Just including some simple files async even if they busy wait for a while inside doesn't seem to do anything.

BTW, I'd debug this myself, but for some reason when ever I attach to the debugger, VS doesn't think the FSM dll is loaded or something. It's a pain.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-07-02 20:03:46
@MordredKLB , yup, reproduced. it's a bug.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-07-02 20:53:20
@MordredKLB , can you try the latest dev build and see if it fixes your issue?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: dwmartin0906 on 2021-07-02 22:01:18
Regarding the issue with Georgia hanging up on reloads with FSM 1.5, I just tried your latest dev build and Georgia hung up on the fourth reload.  Thank you for looking at this.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-07-02 22:31:14
@MordredKLB @dwmartin0906 could you plz create the dump when it freezes using the following instructions?
https://github.com/TheQwertiest/foo_spider_monkey_panel/issues/61#issuecomment-470036761
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-07-02 22:39:12
Tried to attach before catching the file size. This is from the latest dev build: removed.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-07-02 23:43:14
Got it, thanks... Sigh... I hate COM objects with every fiber of my being...
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-07-02 23:44:00
That would be great! As long as it works out of the box for other scripts, I really think these things would really make it easier to create new scripts without reinventing the wheel for every new one.
Agreed. The only issue with any UI framework is handling the callbacks well. I've paired mine down to the bare minimum but still need to handle: on_mouse_move, on_mouse_lbtn_up, on_mouse_lbtn_down, on_char, and on_key_down (maybe on_mouse_wheel too?). If you do things in a sane way (so *not* the way I ever do things) and have separate FSM windows for these things it's no problem, but if you need to combine them in an existing theme which already has its own callbacks, then things get a little more complex.

Just wrap them.
Code: [Select]
function onNotifyData(name, info) { 
switch (name) {
case 'Playlist manager: playlistPath': {
if (info && info.length) {
const properties =  getPropertiesPairs((typeof buttons === 'undefined' ? menu_properties : menu_panelProperties), 'menu_');
const playlistPath = JSON.parse(properties.playlistPath[1]);
let bDone = false;
if (isArrayStrings(info)) {
if (!new Set(playlistPath).isSuperset(new Set(info))) {
playlistPath.concat([...new Set(info).difference(new Set(playlistPath))])
bDone = true;
}
} else if (isStringWeak(info)) {
if (playlistPath.indexOf(info) === -1) {
playlistPath.push(info);
bDone = true;
}
}
if (bDone) {
properties.playlistPath[1] = JSON.stringify(playlistPath);
overwriteProperties(properties); // Updates panel
}
}
break;
}
}
}
if (typeof on_notify_data !== 'undefined') {
const oldFunc = on_notify_data;
on_notify_data = function(name, info) {
oldFunc(name, info);
onNotifyData(name, info);
}
} else {var on_notify_data = onNotifyData;}



Had that problem when merging arbitrary buttons/scripts in my buttons bar, not anymore. Now I don't care at all about callbacks being rewritten no matter what I merge.

Obviously if another method is added it would be great too.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-07-03 00:54:16
@MordredKLB, @dwmartin0906 , I've added a workaround that should fix your issue (once dev build is finished building).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: dwmartin0906 on 2021-07-03 06:33:59
Your latest build seems to have fixed the reload issue. I tested both Georgias and gave up after 25 reloads each.  Thank you very much.  And thank you, @MordredKLB, for your help.  Now I'll be ready if you or TT make any future changes requiring FSM 1.5.  You guys are the best.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-07-03 07:36:55
Got it, thanks... Sigh... I hate COM objects with every fiber of my being...


Breaking change for v2... drop support for all of them. :D

You could implement a few file/folder creation/deletion methods so fso is no longer needed. Expose ShellExecute/MessageBox so WshShell isn't required. Exposing the http_client from the SDK would be more effort but maybe less hassle in the long run??

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-07-03 14:00:21
Breaking change for v2... drop support for all of them. :D
I've actually considered doing this multiple times, but (for now?) the pain required to reimplement everything is much bigger than the pain from having to deal with COM...
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kutuzof on 2021-07-03 14:32:32
Cache not working in JS Smooth Browser
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-07-03 14:57:14
Nuke it from orbit/forget it exists.

WilB's library tree now has a grid view with album art display.

https://hydrogenaud.io/index.php?topic=111060.msg997859#msg997859
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-07-03 15:23:35
Currently working on an options framework: as you can see it's pretty much equal to Wilb html's one, but within an SMP panel, so functional for non IE and wine users. And it would work with arbitrary input, so valid for any type of script.
It's pretty accurate, even down to the subtle onhover effects (see Blue Toggle). Had to make some changes to FSM to get the text box highlighting stuff to work correctly, but now that 1.5 is released I'll probably start back working on this. The color pickers are a little janky, and need some way to type in values, and I need to make some usability improvements to how you create controls, but otherwise it's pretty much done. If you're interested i can share the code before it makes it to Georgia.
Why you had to do such changes? I got it working pretty similar without any problem.
Spoiler (click to show/hide)

Found it more simple to change colors directly with ColourPicker and just display the result.

Right now I got 2 themes working (I find yours prettier than WIilbs approach I tried to mimic), also tabs width can be set to according to text width or splitting the window width. But did not care about reproducing the toogle and dropdown lists since the former is essentially a themed checkbox and the latter can be simulated 100% with menus and changing the button title dynamically.

Also found the circle checks are pretty sensitive to size, sometimes being a bit pixelated. Did you have the same problem?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-07-03 18:20:32
Why you had to do such changes? I got it working pretty similar without any problem.
It's all in the PR: https://github.com/TheQwertiest/foo_spider_monkey_panel/pull/140

Quote
Right now I got 2 themes working (I find yours prettier than WIilbs approach I tried to mimic), also tabs width can be set to according to text width or splitting the window width. But did not care about reproducing the toogle and dropdown lists since the former is essentially a themed checkbox and the latter can be simulated 100% with menus and changing the button title dynamically.
You're not wrong. I just wanted to see if I could do them... and it's always nice to have options.

Quote
Also found the circle checks are pretty sensitive to size, sometimes being a bit pixelated. Did you have the same problem?
The GDI+ circle anti-aliasing is not amazing. You definitely need to find some magic numbers and stick with them.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-07-03 18:34:02
This is a VERY ugly, hacked together stand alone version that you can play around with if you want. Requires FSM 1.5. There are no callbacks when you do anything yet and things like the tabs don't actually do anything. Also the initialization of the page is entirely manual and not generated from a schema. I stand by the UI Objects (outside the color picker) which I believe have been implemented pretty well, and nothing else.

You might also want to play around with the fonts listed in on_init and make sure you're choosing ones you have installed.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-07-04 13:19:43
Thanks! I could merge your toogle (even if it's a duplicate functionality, you have already done it... so why not) and/or dropdown list with mine.

Not so sure about the latter, since I also plan to add custom menus -using the already shared menu framework- within the option panel and the list could be essentially the same (the button theme will be different though).
Spoiler (click to show/hide)

Apart from that, it works with schemas as is and already allows saving/loading vars from a properties object. It's mostly done, I only have to think if input boxes should use full column width and what happens if the text within a tab is bigger than the column width (I was thinking about pushing the other columns to another tab automatically to free space).
In these examples, at the second image, I forced 4 columns although only 3 would work fine according to the total width of its elements. 4th column would be pushed to another tab. Although some attention must be put when creating the schema, it makes no sense to fill a tab with too many things if the "standard" panel is meant to be small. Thus the schema should contain columns considering the minimum acceptable panel size.
Spoiler (click to show/hide)

Btw, check the images for the scripts @TheQwertiest on the zip. The buttons bar is meant to be used at top, but bars are themed according to windows colors. I have installed it in a dark themed foobar without main bars to simulate it, YMMV.
Spoiler (click to show/hide)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-07-04 13:24:36
Version: 1.5.1
Link: https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/tag/v1.5.1
Changelog:
Hotfix for v1.5.0 (see changelog above (https://hydrogenaud.io/index.php?topic=116669.msg1000116#msg1000116))
Spoiler (click to show/hide)
Detailed description of API changes: https://theqwertiest.github.io/foo_spider_monkey_panel/docs/script_documentation/api_changes/#v151
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-07-05 14:08:30
Some progress. Tabs with too big columns for the given window size are split into new tabs still following the schema. (have not merged the lists and toggle control yet)

Code: [Select]
// Create panel and add properties or data object with the values
const options = new _window({width: window.Width, height: window.Height, tabWidth: 'full', UI: 'material', properties: getPropertiesPairs(properties)});
options.addTab({title: 'Option 1', columns: 4, data: [
[
{title: 'Title 1', subTitle: 'Subtitle 1', values: [{name: 'This is a value This is ', pId: 'val1', pIdx: 1}, {name: 'Another value:', value: 'This is my text This is a value check 2 scripts\\SMP\\xxx-scripts\\helpers\\JSinputbox.js is is a value This is a'}]},
{subTitle: 'Subtitle 2', values: [{name: 'This is a value check 1:', value: true}]},
{values: [{name: 'Choose color:', value: 0xFFEAE4D1, mode: 'colorPicker'}]}
],
[ // If data doesn't have a pId or pIdx (associated to the previous properties object) then the value must be passed along the schema
{title: 'Title 2', subTitle: 'Subtitle 1', values: [{name: 'This is a value:', value: 20}, {name: 'Another value:', value: 30}]},
{title: 'Title 3', subTitle: 'Subtitle 2', values: [{name: 'This is a value check 2:', value: true, mode: 'checkGroup'}, {name: 'This is a value check 3:', value: false, mode: 'checkGroup'}]}
],
[
{title: 'Title 4', subTitle: 'Subtitle 1', values: [{name: 'This is a value:', value: ['Value 1', 'Value 2', 'Value 3']}]}
]
]});
options.addTab({title: 'Option 2', columns: 3, data: [
[
{title: 'Title 1', subTitle: 'Subtitle 1', values: [{name: 'This is a value:', value: 10}, {name: 'Another value:', value: 20}]},
{title: 'Title 2', subTitle: 'Subtitle 2', values: [{name: 'This is a value check 1:', value: true}]}
],
[
{title: 'Title 3', subTitle: 'Subtitle 1', values: [{name: 'This is a value:', value: 20}, {name: 'Another value:', value: 30}]},
{title: 'Title 4', subTitle: 'Subtitle 2', values: [{name: 'This is a value check 2:', value: false}]}
],
[
{title: 'Title 5', subTitle: 'Subtitle 1', values: [{name: 'This is a value:', value: 20}, {name: 'Another value:', value: 30}]},
{title: 'Title 6', subTitle: 'Subtitle 2', values: [{name: 'This is a value check 3:', value: false}, {name: 'This is a value check 4:', value: false}]}
]
]});
options.addTab({title: 'Option 3', columns: 1});
options.addTab({title: 'Option 4', columns: 2});
options.addTab({title: 'Option 5', columns: 3});
options.fitData(); // Fits the schema at start (is also done automatically on resize)

// Menus to swap panels
var menu = new _menu();
menu.newEntry({entryText: 'Show Options', func: () => {options.properties.bOptions[1] = true; overwriteProperties(options.properties); options.properties = getPropertiesPairs(properties); window.Repaint(true);}});
menu.newEntry({entryText: 'Show Main', func: () => {options.properties.bOptions[1] = false; overwriteProperties(options.properties); window.Repaint(true);}});

Spoiler (click to show/hide)

Tab titles would be cut to 3-4 letters if there is not enough width, and a tooltip would show fhe full name. Still deciding if the save/load part should be done manually (I do it when opening/closing the panel via menus), or via callbacks called by the options panel whenever a value changes, etc..
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2021-07-06 00:19:13
Hey @TheQwertiest ,

unfortunately we need another hotfix, I have an annoying problem with SMP 1.5.1.

Often when you close foobar it will not make a clean exit and gets stuck in the process. In the taskbar you can see foobar2000.exe
is still running in the background and the only way is to kill it. On next foobar start, you'll get the crash popup warning.
You can reproduce it when you open foobar, close it, open foobar, play some songs, close it again etc...
After some tries, it will happen but not always...

I didn't have any problems with v.1.5.0 or v.1.4.1, this happens only with v.1.5.1. Some changes from 1.5.0 to 1.5.1 are producing
this hang up...

-TT

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-07-06 00:31:56
@TT please, generate and send me a dump using the following instructions: https://hydrogenaud.io/index.php?topic=116669.msg1000223#msg1000223
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: always.beta on 2021-07-06 14:00:39
I have encountered a similar situation. Also, right-clicking on the song file and selecting "Open containing folder" occasionally brought up a dialog box for the slow script to run, but now it doesn't, and I can't take a screenshot
https://1drv.ms/u/s!AnFvs7Iqm0IraTdlGovhwJOU1DY?e=ARvwh2
unfortunately we need another hotfix, I have an annoying problem with SMP 1.5.1.
Often when you close foobar it will not make a clean exit and gets stuck in the process. In the taskbar you can see foobar2000.exe
is still running in the background and the only way is to kill it. On next foobar start, you'll get the crash popup warning.
You can reproduce it when you open foobar, close it, open foobar, play some songs, close it again etc...
After some tries, it will happen but not always...
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-07-06 23:00:34
@TT thanks, got your dump files. Found the problem, not sure how to fix it yet though...
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-07-06 23:39:56
Include function relative paths evaluating to the "included" script path instead of the main one is an intentional behavior?

Have a main one ...\foobar2000\scripts\SMP\xxx-scripts\options.js':
Code: [Select]
include('helpers\\window_xxx.js');
include('helpers\\helpers_xxx_properties.js');
include('helpers\\menu_xxx.js');

The first helper file at (' ...\foobar2000\scripts\SMP\xxx-scripts\helpers') 'has:
Code: [Select]
include('helpers\\helpers_xxx_UI.js');
include('helpers\\window_xxx_input.js');
include('helpers\\menu_xxx.js');
include('helpers\\buttons_panel_xxx.js');

Since the helper is called by the main one, I was expecting paths resolving to '..\foobar2000\scripts\SMP\xxx-scripts\helpers\...' but instead they look for '...\foobar2000\scripts\SMP\xxx-scripts\helpers\helpers\...'.

Quote
`${current_script_path}/${path}`, if the script is not a top-level `in-memory` script.
Note the documentation talks about script path (instead of current file path).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-07-07 11:19:03
@regor , yup, that's the intended behaviour. Docs are valid: `current_script_path` is `a path to the file containing the script from which the `include()` method was called`.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-07-07 20:10:12
@TT @always.beta , I've made some changes that should fix your issue (once dev build is finished building).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-07-07 20:27:37
@TT @always.beta , I've made some changes that should fix your issue (once dev build is finished building).
What was the issue?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-07-07 20:29:34
@MordredKLB https://hydrogenaud.io/index.php?topic=116669.msg1000354#msg1000354
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-07-08 10:41:26
Window framework + built in options
Have provided an example file (options.js) to work with it. Feel free to test it before I release it on github
Allows to embed any arbitrary window object too within a tab, so multiple options panels may be added.
Data values may be autosaved/autoloaded, passed as properties or as json.
Spoiler (click to show/hide)

Obviously this is just a beta, don't use without caution.
(the tick at the checkbox problem is already noticed)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-07-08 15:10:16
@regor , yup, that's the intended behaviour. Docs are valid: `current_script_path` is `a path to the file containing the script from which the `include()` method was called`.
Ok! Have one more question.. I'm trying to replace all include calls with relative paths so scripts can be put on any place instead of an specific path. That works, even using '..\\'.

But have not found a way to read text files or images using relative paths, so those are necessarily harcoded to an specific path. And scripts using images or text files are required to either be installed on a path or as a package.

I understand that enabling relative paths at ReadTextFile, etc. would require a rewriting. But do I miss an alternative method? Is there some way to retrieve the path of the current file (or main panel script) to add it to all those paths? (for ex. at Window.ScriptInfo)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-07-09 20:28:46
on_output_device_changed and the dsp counterpart are not called when the respective lists change but the active item has not changed, is that intended (*)? (in other words, there is no way to know if the device list changes at some point without using intervals)
Just noticed while using myself the device auto-switch.

(*) Different behavior since the actual methods to get the dsp and devices don't output just the active items, but the entire list.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-07-09 21:00:19
Believe it or not, it's much less effort to translate what fb2k does in C++ to JavaScript untouched (where reasonable). Intercepting what fb2k does and applying weird logic just to annoy people does sound like fun but not even I would go that far. :p

Also, you might check the docs from time to time...

https://theqwertiest.github.io/foo_spider_monkey_panel/assets/generated_files/docs/html/module-callbacks.html#~on_dsp_preset_changed

I guess there is no note attached to on_output_device_changed because I never had removable devices when testing it.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-07-09 21:34:11
applying weird logic just to annoy people does sound like fun
Indeed, now I actually want to do smth like that xD
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-07-09 23:43:42
Also, you might check the docs from time to time...

https://theqwertiest.github.io/foo_spider_monkey_panel/assets/generated_files/docs/html/module-callbacks.html#~on_dsp_preset_changed

I guess there is no note attached to on_output_device_changed because I never had removable devices when testing it.
... precisely I was asking because I did not understand the rationale behind it (?) Can not care less about what's fun or not.

It's weird that the only method to get the currently used device outputs the entire list which you have to process, and the only callback to notify device changes works only with the current device (so you have to resort to interval functions to check for changes). If they are just a translation of the c++ counterparts or doing it differently would be harder, that's ok.... it's still weird.

Quote
I guess there is no note attached to on_output_device_changed because I never had removable devices when testing it
That's the point of headphones and bluetooth devices, they are removable.

Quote
I understand that enabling relative paths at ReadTextFile, etc. would require a rewriting. But do I miss an alternative method? Is there some way to retrieve the path of the current file (or main panel script) to add it to all those paths? (for ex. at Window.ScriptInfo)
@TheQwertiest
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-07-09 23:48:23
.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-07-10 00:50:46
win 7.

Loading a read only file and editing and trying to save the script crashes foobar.

The same happens for hidden files.

Spoiler (click to show/hide)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-07-11 17:24:12
Ok! Have one more question.. I'm trying to replace all include calls with relative paths so scripts can be put on any place instead of an specific path. That works, even using '..\\'.

But have not found a way to read text files or images using relative paths, so those are necessarily harcoded to an specific path. And scripts using images or text files are required to either be installed on a path or as a package.

I understand that enabling relative paths at ReadTextFile, etc. would require a rewriting. But do I miss an alternative method? Is there some way to retrieve the path of the current file (or main panel script) to add it to all those paths? (for ex. at Window.ScriptInfo)

There is no alternative method for in-memory or file scripts. Heck, that was actually the main reason why I've started working on packages in the first place =)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-07-12 01:03:53
They are not a replacement for all use cases. Specially for scripts which can load multiple files on demand from paths, or have optional add-ons (and are meant to be added/removed by the user, contrary to the way packages work). For ex. presets files, like the ones used at Playlist Tools are totally impossible with packages (or I would have to split saving files at multiple places) (*).

Relative paths are still useful for those cases, and not having to force a pre-defined absolute path (for images, text files, etc.) would be great, which could be done exposing the current panel script path in some way. It's fine if you think otherwise, absolute paths can still be used for those cases... is just that I see room for improvement there, since "script including" is already relative path friendly.

(*) The button bar, automatically loading any button file from a folder is another example. Since packages are meant to be installed and done... I don't see people adding extra files at a later point to the package folder manually, defeating the initial purpose of packages.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-07-12 10:29:28
Minor fix for data folder, now created if it doesn't exist.

@TheQwertiest   not sure if you saw this:
https://hydrogenaud.io/index.php?topic=121277.msg1000545#msg1000545
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2021-07-12 19:02:26
Relative paths are still useful for those cases, and not having to force a pre-defined absolute path (for images, text files, etc.) would be great, which could be done exposing the current panel script path in some way. It's fine if you think otherwise, absolute paths can still be used for those cases... is just that I see room for improvement there, since "script including" is already relative path friendly.
Script including only become relative path friendly after initial load at the 1.5 release (you can see the changelist here (https://github.com/TheQwertiest/foo_spider_monkey_panel/commit/3133ae16d61f2d62695a10d5387b464cbaf0641c)). Seems like the best solution would be to provide a method that retrieves the current path of the file the code is being executed from, and then there's no need to get messy with all the other file/image functions. Obviously if you're doing this in memory, you're out of luck completely though.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-07-12 20:25:59
Relative paths are still useful for those cases, and not having to force a pre-defined absolute path (for images, text files, etc.) would be great, which could be done exposing the current panel script path in some way. It's fine if you think otherwise, absolute paths can still be used for those cases... is just that I see room for improvement there, since "script including" is already relative path friendly.
Script including only become relative path friendly after initial load at the 1.5 release (you can see the changelist here (https://github.com/TheQwertiest/foo_spider_monkey_panel/commit/3133ae16d61f2d62695a10d5387b464cbaf0641c)). Seems like the best solution would be to provide a method that retrieves the current path of the file the code is being executed from, and then there's no need to get messy with all the other file/image functions. Obviously if you're doing this in memory, you're out of luck completely though.

That was exactly my suggestion. For ex a new property could be added to the already existing Window.ScriptInfo data with that path. In memory script's path would simply be null or '' and done.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-07-14 06:17:15
Back by unpopular demand is my ye olde sox spectrogram seekbar from the WSH panel mod days.

You'll need sox and ffmpeg extracted to a folder named sox inside your profile folder (or edit the paths in the script)

Limitations:
since the script passes the filename to ffmpeg for decoding, your input components are irrelevant
it only works on local files with a known length
cue sheets/files with chapters are not supported

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-07-14 08:38:54
I forgot to mention that FontAwesome is required.

https://github.com/FortAwesome/Font-Awesome/blob/fa-4/fonts/fontawesome-webfont.ttf?raw=true

I also forgot to make it clear the image when playback stops. I've attached a fixed version.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-07-14 10:52:42
I really am a bumbling buffoon. The menu option to clear images was broken because I used a function that doesn't exist in SMP. That's now fixed.




Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-07-14 22:45:09
@TT @wcs13 @MordredKLB I've made some changes that should fix the `freeze on exit` issue (once dev build is finished building).

@MordredKLB Note that this build includes the rollback of timer changes.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2021-07-14 23:06:30
@TT @wcs13 @MordredKLB I've made some changes that should fix the `freeze on exit` issue (once dev build is finished building).

@MordredKLB Note that this build includes the rollback of timer changes.

Thank you, my theme is still using the stable v.1.4.1. Will try it out!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-07-14 23:40:54
Back by unpopular demand is my ye olde sox spectrogram seekbar from the WSH panel mod days.

You'll need sox and ffmpeg extracted to a folder named sox inside your profile folder (or edit the paths in the script)

Limitations:
since the script passes the filename to ffmpeg for decoding, your input components are irrelevant
it only works on local files with a known length
cue sheets/files with chapters are not supported
Do you mind if I add it to complete samples in smp_2003 repo?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2021-07-15 21:35:53
@TheQwertiest

The freeze has been fixed, it now makes a clean exit =)
Thanks!

-TT
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-07-16 01:49:17
Do you mind if I add it to complete samples in smp_2003 repo?

Go for it. It's not like there have been restrictions on anything I've posted before. It's horrible code though!

BTW, I noticed that when using utils.ColourPicker, you don't pass the default_colour on to uChooseColor internally. It should do this so the user can actually edit the default colour instead of starting with black every time. My original always did this.

https://github.com/marc2k3/foo_jscript_panel/blob/a96ffd1625caa1b1aa825fc0dd66ff52072a654b/src/ScriptInterface/Utils.cpp#L50L51


Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Koshingg on 2021-07-16 22:38:02
Thanks for the spectrogram seekbar script @snotlicker . That WSH panel script for spectrogram seekbar was hard to find. Definitely it should be added together with the other SMP scripts
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-07-19 22:13:24
There have been at least 2 reports of relative paths not working and crashing even if the files are there with latest dev release and previous ones.
https://hydrogenaud.io/index.php?topic=120979.msg1000890#msg1000890
https://hydrogenaud.io/index.php?topic=121277.msg1000545#msg1000545

The same files work fine on different systems on my side.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Koshingg on 2021-07-20 17:58:44
Another report about relative paths not working, crashing ( windows 10, foobar 1.6.6, SMP 1.5.1 and the latest dev released)

Error: Spider Monkey Panel v1.5.2-dev+327ba5dc ({311F3B08-764E-4315-8AB1-BF3F99B97668})
include failed:
Path does not point to a valid file: helpers\buttons_xxx.js

File: <main>
Line: 35, Column: 2
Stack trace:
  @:35:2

Error: Spider Monkey Panel v1.5.1 (Playlist Manager: Playlist Manager v0.2 by XXX)
include failed:
Path does not point to a valid file: helpers\helpers_xxx.js

File: <main>
Line: 27, Column: 1
Stack trace:
  @:27:1

Error: Spider Monkey Panel v1.5.2-dev+327ba5dc (Playlist Manager: Playlist Manager v0.2 by XXX)
include failed:
Path does not point to a valid file: helpers\helpers_xxx.js

File: <main>
Line: 27, Column: 1
Stack trace:
  @:27:1

Another problem, although I don't know if I should post here or to WiLB's page (it seems that only Library Tree, Biography, Find & Play scripts were affected, every time, other SMP scripts are ok)  After every unexpected shutdown caused by the interruption of electricity I have to reinstall those scripts, packages are corrupted, the settings are lost. Luckily I had those settings saved somewhere. This didn't happen before
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-07-21 08:33:52
There have been at least 2 reports of relative paths not working and crashing even if the files are there with latest dev release and previous ones.
https://hydrogenaud.io/index.php?topic=120979.msg1000890#msg1000890
https://hydrogenaud.io/index.php?topic=121277.msg1000545#msg1000545

The same files work fine on different systems on my side.
And another one
https://hydrogenaud.io/index.php?topic=120979.msg1000966#msg1000966
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kutuzof on 2021-07-26 09:32:18
If there is a folder with a Russian name on the way, then the panel crashes.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: wcs13 on 2021-07-28 07:46:38
@TT @wcs13 @MordredKLB I've made some changes that should fix the `freeze on exit` issue (once dev build is finished building).
Thank you :) Where could I find that new version ? The latest release seems to be still 1.5.1...
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Koshingg on 2021-07-28 08:57:39
It's here https://theqwertiest.github.io/foo_spider_monkey_panel/#links Go to:  Links, and then Dev build
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-07-31 11:45:29
@regor @kutuzof I've made some changes that should fix your issue with script paths (once dev build is finished building).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: WilB on 2021-08-01 12:52:51
Regarding issues with packages when unexpected shutdowns occur, e.g. through power failures (https://hydrogenaud.io/index.php?topic=116669.msg1000951#msg1000951). I have also reproduced the corruption of package.json that occurs in this scenario. Does package.json have to be saved on foobar2000 shutdown, since package.json seems to get saved when changes are made on the package tab anyway? Or can some other fix be implemented?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: annalise on 2021-08-05 08:54:52
Hi everyone, I'm hoping for help resolving script crashes with my foobar install. Basically, all of my SMP panels crash on startup. All of my panels show a variation of this error:

Code: [Select]
Error: Spider Monkey Panel v1.5.1 ({1AE4C679-53B4-412C-A541-F94EE8BE216F}: Album Art by marc2003)
include failed:
ActiveXObject_Constructor failed:
Invalid CLSID: htmlfile

File: helpers.js
Line: 586, Column: 11
Stack trace:
  @helpers.js:586:11
  @album art.js:5:1

Now, because of the "htmlfile" part, I'm 99% sure I caused this problem when I was attempting to set a different program to be my system's default PDF reader. For whatever reason, PDFs and HTML files seem to be linked on Windows 10 with the Microsoft Edge browser being the default reader, so I must have screwed something up trying to change that. Naturally, I've reset all file associations to Windows defaults, but that hasn't helped.

I've also tried going into my other portable foobar installation and creating new panels with SMP and Jscript samples from those respective components—these also crash with the same error messages. Oddly, WilB's Library Tree (JScript version) is still functional on this install.

I'm not really sure what to do here. I've gone into the registry looking at the CLSID list but I'm hesitant to make any changes here, since me messing around is likely what caused this problem in the first place.

Thanks in advance.

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: hexenszene on 2021-08-06 11:04:50
Back by unpopular demand is my ye olde sox spectrogram seekbar from the WSH panel mod days.


Thanks so much for this!  Been hoping that it would be updatedfor SMP,  Cheers mate!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Koshingg on 2021-08-06 22:20:56
Still problems with relative paths, even with the latest dev build (windows 10, foobar 1.6.6) :

Error: Spider Monkey Panel v1.5.2-dev+b064066b (Playlist Manager: Playlist Manager v0.2 by XXX)
include failed:
Path does not point to a valid file: helpers\helpers_xxx.js

File: <main>
Line: 27, Column: 1
Stack trace:
  @:27:1

The path to the scripts : G:\foobar2000\profile\scripts\SMP\xxx-scripts\helpers\helpers_xxx.js
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-08-10 22:39:15
Version: 1.5.2
Link: https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/tag/v1.5.2
Changelog:
Hotfix for v1.5.0 (see changelog above (https://hydrogenaud.io/index.php?topic=116669.msg1000116#msg1000116))
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-08-10 22:44:24
I wanted to include more fixes in this release, but
- too many reports of unicode paths not working.
- too many reports of crashes/freezes.
- don't know when I'll actually have time to do additional fixes.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MojoBass on 2021-08-14 07:53:02
Regarding issues with packages when unexpected shutdowns occur, e.g. through power failures (https://hydrogenaud.io/index.php?topic=116669.msg1000951#msg1000951). I have also reproduced the corruption of package.json that occurs in this scenario. Does package.json have to be saved on foobar2000 shutdown, since package.json seems to get saved when changes are made on the package tab anyway? Or can some other fix be implemented?
As this happened as well on my side where I lost my properties for WilBs packages - would be great if there is a fix for this!
(of course exported now backups of the properties...)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Montchenot on 2021-08-17 22:36:28
Hi Qwertiest,
I've made a small change to Br3tt's JS Smooth Browser so that the labels don't mess with the art when in grid mode.
First I thought of just removing these (by setting to 0 default_botGridHeight and default_botTextRowHeight in lines 58 and 60 in the current jssb.js) but then I tried to keep the nice code you have maintained, along with marc2003, so I've got the labels to show individually only when pointing to each album – here's my jssb.js with the changes commented:

X

By the way, perhaps for my four gigs ram, I needed to rise the threshold for warnings, in the advance preferences.

Also, I still don't know how to enable the caching of all thumb images (as Facets does) so that they don't get strenuously rendered each time I scroll around.

I know there are other solutions for a grid without labels but I like the consistency of JSSB's grid, which is perfectly fit tight together and adjusted to the available panel width, and how it always starts with an aligned first visible row.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: mjm716 on 2021-08-18 09:28:34
Version: 1.5.2


Thanks much! This fixed my hanging FB shut-down problem.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: p90036 on 2021-08-18 20:32:53
(not programmer here)
installed smp and smp-scripts,
added the line in the script:   include(fb.ProfilePath + 'smp-scripts\\smp-date\\smp-date.js');
but its showing me small font and a very detailed date format, on a white background

how do i make it show current date's hour:minutes in a large (impact) font, with the default colors of fb
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-08-26 23:08:03
(not programmer here)
installed smp and smp-scripts,
added the line in the script:   include(fb.ProfilePath + 'smp-scripts\\smp-date\\smp-date.js');
but its showing me small font and a very detailed date format, on a white background

how do i make it show current date's hour:minutes in a large (impact) font, with the default colors of fb

`smp-date` script is a user created script, hence the following disclaimer applies:
Code: [Select]
These scripts are created by SMP users and are not installed with the component.
For installation instructions (and support) see corresponding links.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kgena_ua on 2021-08-27 20:24:27
is it possible to convert a file from svg format (vector graphics) to png format when downloading.
There is a link for an example. I want to download this file in png
Code: [Select]
"https://cdn-gce.allmusic.com/images/logos/allmusic_wordmark.svg"
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kode54 on 2021-08-27 22:50:53
Rendering SVG is a complex process, so much that a lot of projects just import the entirety of InkScape on the command line just to render them.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-08-27 22:57:19
@kgena_ua , what kode54 said =)
Also see https://github.com/TheQwertiest/foo_spider_monkey_panel/issues/107
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kgena_ua on 2021-08-28 07:01:23
kode54, TheQwertiest,
thank you, I understand.

Sometimes if I want to add Spider Monkey Panel to Dockable Panels (foo_dockable_panels.dll) i have crash.
Where am I making a mistake.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-08-28 16:54:37
@kgena_ua I've already answered that here: https://hydrogenaud.io/index.php?topic=116669.msg999869#msg999869
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kgena_ua on 2021-08-29 05:44:04
@kgena_ua I've already answered that here
TheQwertiest, i missed this message.

foo_flowin.dll seems works fine.
Thanks.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-08-30 21:11:27
Got another report about the rel. paths not working:
https://hydrogenaud.io/index.php?topic=120979.0

Btw, while writing some faq about my scripts thought it would be great to have a method to save the panel properties directly to a file (without the UI and user intervention). That would come really handy to create and manage backups or exporting config to other installations from within the script. (*)

(*) For ex. the playlist manager uses the properties for config, an additional json file for autoplaylists, fpl and other playlist's data and finally a folder with the physical playlists. Exporting the entire panel would be a matter of seconds if I simply output a zipped file with all those files/folders. Something similar happens in Bio panel, where backups require locating files from multiple places.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-09-05 20:23:55
@SergPuh.68 - I saw your bug report on the russian forum. This strips the line breaks...

https://github.com/TheQwertiest/smp_2003/pull/8
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: SergPuh.68 on 2021-09-06 06:48:54
Thank you, it works  :)
 X
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-09-08 18:34:42
@regor , I remember you sending me suitable screenshots for your scripts, but I can't for the life of me find them anywhere >_<
Do you recall by any chance where did you post them?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-09-09 23:01:27
Attached.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-09-10 23:31:15
Attached.
Thanks! I'll add them soon.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-09-10 23:35:37
Version: 1.6.0
Link: https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/tag/v1.6.0
Changelog:
Spoiler (click to show/hide)
Detailed description of API changes: https://theqwertiest.github.io/foo_spider_monkey_panel/docs/script_documentation/api_changes/#v160
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kutuzof on 2021-09-11 10:08:55
TheQwertiest, how can I use packaging biography on two panels. Stopped working after updating.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: mjm716 on 2021-09-11 12:38:07
Version: 1.6.0

FYI new SMP panels still display 1.5.2.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-09-11 13:20:20
TheQwertiest, how can I use packaging biography on two panels. Stopped working after updating.
Do you mean WilB's script? And what do you mean by "stopped working"? Is there some kind of error message?

FYI new SMP panels still display 1.5.2.
Try invoking `console.log(utils.Version)`, if it returns 1.5.2, then it means that it's not 1.6.0 and that you are using an old version xD =)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Cardiacs on 2021-09-11 14:23:29
Error: Spider Monkey Panel v1.6.1-dev+d8d0f4bc ({04620F16-1878-47A1-8EFE-0CE0B99566CC}: Georgia-ReBORN v2.0.3 by TT)
include failed:
is_4k is not defined

File: settings.js
Line: 156, Column: 94
Stack trace:
  @settings.js:156:94
  loadAsyncFile/</<@georgia-reborn-theme.js:18:13

Solution?

Best Regards
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kutuzof on 2021-09-11 15:29:16
Do you mean WilB's script? And what do you mean by "stopped working"? Is there some kind of error message?
Yes, the script is from WilB. After updating the SMP, the biography panels (I use two biography panels) stopped loading pictures with text. If I delete one panel, then everything loads fine.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2021-09-11 16:18:17
Error: Spider Monkey Panel v1.6.1-dev+d8d0f4bc ({04620F16-1878-47A1-8EFE-0CE0B99566CC}: Georgia-ReBORN v2.0.3 by TT)
include failed:
is_4k is not defined

File: settings.js
Line: 156, Column: 94
Stack trace:
  @settings.js:156:94
  loadAsyncFile/</<@georgia-reborn-theme.js:18:13

Solution?

Best Regards


Hi Cardiacs,

this issue has been fixed, you can download it here (https://github.com/TT-ReBORN/Georgia-ReBORN/archive/refs/heads/master.zip).
Please post it next time in the Georgia-ReBORN thread, thanks for reporting!

-TT
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-09-11 21:55:55
@kutuzof can't reproduce: both panels work fine for me. Can you share your setup? Or at least those panel's properties?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kutuzof on 2021-09-12 07:10:23
You can download my entire assembly (no new SMP version) here (https://foobar2000.ru/forum/viewtopic.php?t=6549). After opening the properties window and pressing the ok button, pictures with text begin to load. But after restarting the player, they do not load again, you need to open the properties again, etc.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MojoBass on 2021-09-12 07:20:22
With update to SMP1.6.0 I am getting quite some instability and crashes, especially when changing presets within CUI. Crash location SMP,  call path entry=>app_mainloop, see attached.
Reverted back to SMP1.5.2, which is stable on my side. Any idea what could cause the issue?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kgena_ua on 2021-09-12 08:40:48
There is such a script. I use timers. The WSH works fine. Problems with the SMP.
If you have time, look.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: michaengfrv on 2021-09-12 11:37:12
Eole theme has a problem with SMP 1.6.0
Mouse right button menu does not show on some panels.
Library Tree, Playlist manager, Graphic Browser etc...
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-09-12 12:13:07
Thanks everyone for the bug reports!
I've unlisted v1.6.0 for now, till all the reported bugs are fixed.

PS: The the unusual amount of bugs is caused by the total rewrite of one of the core elements of the component (it amounts for ~10% of the whole code), which was needed to fix some long standing bugs and is required for some future features.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-09-12 13:18:25
With update to SMP1.6.0 I am getting quite some instability and crashes, especially when changing presets within CUI. Crash location SMP,  call path entry=>app_mainloop, see attached.
Reverted back to SMP1.5.2, which is stable on my side. Any idea what could cause the issue?

Can you attach a .dmp file as well, please?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-09-12 16:05:25
@kutuzof , @TT , @kgena_ua , I fixed some bugs, could you, plz, try the latest dev build and check if it works for you as well?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kutuzof on 2021-09-12 16:41:52
@TheQwertiest, biography also doesn't work with developer build. Plus, some other panels began to fall.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MojoBass on 2021-09-12 17:56:35
Can you attach a .dmp file as well, please?
Sure :-)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-09-13 11:33:52
ReadTextFile fails detecting the codepage (UTF-8) of this file when BOM is not set (which I have disabled for Unix compatibility). Edit the file path as needed and use this code.
Code: [Select]
include(fb.ComponentPath + 'docs\\Codepages.js');
const playlistPath = 'd:\\foobar2000\\profile\\playlist_manager\\Playlist C.m3u8';
let originalText = utils.ReadTextFile(playlistPath).split('\r\n');
if (typeof originalText !== 'undefined' && originalText.length) {
    console.log(originalText[10]);
    if (originalText[1] === '#EXTENC:UTF-8') {originalText = utils.ReadTextFile(playlistPath, convertCharsetToCodepage('UTF-8')).split('\r\n');} // Hack
    console.log(originalText[10]);
}
Quote
D:\foobar2000\_\Big Retro Hits 90s\063. Wolkenfänger - Rock Me Amadeus.mp3  // Automatic charset detection
D:\foobar2000\_\Big Retro Hits 90s\063. Wolkenfänger - Rock Me Amadeus.mp3  // Hack

Right now I have to use the hack to check for playlists with are encoded as utf-8. Since the manager may also load playlists written by other programs, if I simply force reading as UTF-8 it may break things for playlist written outside Foobar scope.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-09-13 12:25:51
Right now I have to use the hack to check for playlists with are encoded as utf-8. Since the manager may also load playlists written by other programs, if I simply force reading as UTF-8 it may break things for playlist written outside Foobar scope.
Nothing can be done about it - codepage detection is heuristic based, which does not provide 100% accuracy. The only way to ensure that UTF is detected correctly is by using UTF BOM.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-09-13 13:00:42
Not sure I see the issue here. If you have m3u8 files they're always going to be UTF8 with or without BOM.

If a file has any kind of BOM, the optional codepage arg is always ignored because processing never gets that far. BOM handling always takes precedence and the function returns early. If supplying a codepage arg for UTF8 without BOM is required, it's a total non issue.

edit: I am making assumptions about the behaviour of ReadTextFile not having changed that much since the fork :P
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-09-13 23:02:16
I have provided a m3u8 file as example, but obviously the playlists formats are not limited to m3u8 but also m3u and pls and those may use UTF8 with and without BOM. Therefore it's an issue as soon as you apply the same logic to those files. m3u uses the same directives and I would have to look for the #EXTENC:UTF-8 line, since it's perfectly valid to have a m3u utf8 file  ::)

Then the BOM thing... as far as I have been reported, playlist files with BOM are not always compatible with other programs (VLC?) and lets not talk about programs outside windows ecosystem, so I have totally abandoned the idea of forcing BOM as default.

If there is no better approach for the current heuristics, will try adding safe-checks after reading the files (like obvious errors Ä -> ä). And adding some notes about it on the readme to use BOM if still having problems.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-09-14 00:12:28
You haven't comprehended my post at all so here's a code example...

First of all forget this...
Code: [Select]
include(fb.ComponentPath + 'docs\\Codepages.js');

Just use this...
Code: [Select]
const CP_UTF8 = 65001;
const filename = ...
let text = utils.ReadTextFile(filename, CP_UTF8);

This should handle ANY UTF8 file with or without BOM. That was the point I was trying to make. If you can't understand my previous post by reading it, go away and test this with all the UTF8 files you can throw at it. You shouldn't need to inspect the contents of the file, it should just work.

Now the problem you MAY face is that m3u files don't have to be UTF8 and you could be entering the murky world of windows ANSI codepage nonsense which I can't even begin to explain because I'm clueless. If you're dealing with cross platform players like VLC which also run on linux etc, you're unlikely to encounter these.

So now you have 2 choices, don't support those files or check by file extension so that you specify CP_UTF8 for all m3u8 files and if the file extension is m3u then omit the codepage so you call ReadTextFile like this.

Code: [Select]
let text = utils.ReadTextFile(filename);
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-09-14 09:11:24
You haven't comprehended my post at all so here's a code example...

First of all forget this...
Code: [Select]
include(fb.ComponentPath + 'docs\\Codepages.js');

Just use this...
Code: [Select]
const CP_UTF8 = 65001;
const filename = ...
let text = utils.ReadTextFile(filename, CP_UTF8);

This should handle ANY UTF8 file with or without BOM. That was the point I was trying to make. If you can't understand my previous post by reading it, go away and test this with all the UTF8 files you can throw at it. You shouldn't need to inspect the contents of the file, it should just work.

Now the problem you MAY face is that m3u files don't have to be UTF8 and you could be entering the murky world of windows ANSI codepage nonsense which I can't even begin to explain because I'm clueless. If you're dealing with cross platform players like VLC which also run on linux etc, you're unlikely to encounter these.

So now you have 2 choices, don't support those files or check by file extension so that you specify CP_UTF8 for all m3u8 files and if the file extension is m3u then omit the codepage so you call ReadTextFile like this.

Code: [Select]
let text = utils.ReadTextFile(filename);

I have understood it perfectly fine. XD You are telling me: "If you know the codepage, put it in the code". Great, thanks. That's the problem  ::) I have to support multiple file formats from multiple OSes and programs which may use or not UTF8 with or without BOM. And obviously I'm not supposed to know if they will use BOM, neiher their codepage, nor the final user is expected to handle/understand these things. There are some use-cases where the encoding may be written to the file (non standard extensive M3U directives) or suppossed (m3u8 files), but that's not all.

About VLC, they handle non BOM files without problems, like most software. It seems windows is the only OS with software which has problems with UTF8 files without BOM. So I would not consider it as a reference if we talk about codepage handling ::) and for sure I would not code following that behavior if possible.

Code: [Select]
include(fb.ComponentPath + 'docs\\Codepages.js');
const playlistPath = 'd:\\foobar2000\\profile\\playlist_manager\\Playlist C.m3u';
const line = 9;
let originalText = utils.ReadTextFile(playlistPath).split('\r\n');
console.log(originalText[line]);
if (originalText.some((line) => {return line.indexOf('ä') !== -1})){
    originalText = utils.ReadTextFile(playlistPath, convertCharsetToCodepage('UTF-8')).split('\r\n');
    console.log(originalText[line]);
}
Quote
D:\foobar2000\_\Big Retro Hits 90s\063. Wolkenfänger - Rock Me Amadeus.mp3
D:\foobar2000\_\Big Retro Hits 90s\063. Wolkenfänger - Rock Me Amadeus.mp3
Another perfectly fine playlist file in m3u format whose encoding can not be supposed by format or #flags.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-09-14 09:38:55
Your original post was about m3u8. Those absolutely should be UTF8 and if they're not, user error, not interested. OS/BOM are all irrelevant because the file extension alone is enough. It really is that simple.

And now we've moved on to m3u files, you're just parroting what I've already told you. You cannot make assumptions about the contents so I listed the 2 choices you have. Treat them as windows ANSI by not supplying any code page (or use the default of 0) or don't support them at all. My inclination would be to use the default codepage argument of 0 (the same as omitting it) and treat them as windows ANSI. What environment are we using?? Oh yeah, it's windows.

I'd just use this...
Code: [Select]
function is_m3u8(filename) {
   return path.split('.').pop().toLowerCase() ==  'm3u8';
}

const CP_UTF8 = 65001;
const filename = ...
let text = utils.ReadTextFile(filename, is_m3u8(filename ? CP_UTF8 : 0);

This will probably fail for m3u playlists that are UTF8 (which aren't plain text and contain exotic characters). But they should be using m3u8 for that anyway.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-09-14 09:39:52
And you can't simply suppose everything is utf8 and done. Neither letting ReadTextFile identify the codepage works flawlessly.
Code: [Select]
include(fb.ComponentPath + 'docs\\Codepages.js');
const playlistPath = 'd:\\foobar2000\\profile\\playlist_manager\\Playlist D.m3u';
const line = 9;
let originalText = utils.ReadTextFile(playlistPath).split('\r\n');
console.log(originalText[line]);
originalText = utils.ReadTextFile(playlistPath, convertCharsetToCodepage('UTF-8')).split('\r\n');
console.log(originalText[line]);
originalText = utils.ReadTextFile(playlistPath, 28591).split('\r\n');
console.log(originalText[line]);
Quote
D:\foobar2000\_\Big Retro Hits 90s\063. Wolkenf�nger - Rock Me Amadeus.mp3
D:\foobar2000\_\Big Retro Hits 90s\063. Wolkenf�nger - Rock Me Amadeus.mp3
D:\foobar2000\_\Big Retro Hits 90s\063. Wolkenfänger - Rock Me Amadeus.mp3

About these files having to be m3u8 files... well that's your opinion. m3u may use any codepage.. And pls files too https://en.wikipedia.org/wiki/PLS_(file_format). With all due respect, you are the only one who talked specifically about m3u8 and thought I was talking only about them, I said playlist files in general from the start.

The codepage heuristics is not foolproof and that's all. These are not specially exotic files anyway, and other tools identify them without problems:
https://nlp.fi.muni.cz/projects/chared/
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-09-14 09:48:35
Moving the goalposts as always. Your original complaint was about UTF8 detection not working, the developer of the component already told you the detection isn't 100% reliable and then I told you how to override it when you know for sure the files are definitely UTF8 as indicated by the file extension of the only example you gave.

Now your complaint is exclusively about windows codepage detection, I'll leave that between you and @TheQwertiest.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-09-14 09:56:41
Right now I have to use the hack to check for playlists with are encoded as utf-8. Since the manager may also load playlists written by other programs, if I simply force reading as UTF-8 it may break things for playlist written outside Foobar scope.
Nothing can be done about it - codepage detection is heuristic based, which does not provide 100% accuracy. The only way to ensure that UTF is detected correctly is by using UTF BOM.
@snotlicker really... do you read your posts?  ::) he understood my "complaint" from the start and already gave the final answer (heuristics in SMP fail, for UTF8 and for any codepage). Maybe I'm really bad at English, writing my "complains" or whatever, point taken.

But I can't really understand your goals answering in a passive-agressive way everytime treating others like idiots who don't know what they want to do. We already had a clear answer and you simply keep posting and analyzing my code goals doing exactly what you say now (goalpost moving) XD. Take it easy. As said, the answer was already given at his post  ::)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-09-14 10:05:33
FWIW, I think you're the one being needlessly combative.

I'm trying to explain things in the simplest way possible because you really seem to struggle with the basic concepts I'm layout out. Your first post was about m3u8 files without BOM not being handled properly and I gave you a bulletproof workaround for that scenario. No acknowledgement from you, not a word of thanks. Just ranting about other playlists with other extensions that cannot be assumed to be UTF8 which I very clearly stated and agreed with.

Independent readers can make their own minds up.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-09-14 10:18:15
FWIW, I think you're the one being needlessly combative.

I'm trying to explain things in the simplest way possible because you really seem to struggle with the basic concepts I'm layout out. Your first post was about m3u8 files without BOM not being handled properly and I gave you a bulletproof workaround for that scenario. No acknowledgement from you, not a word of thanks. Just ranting about other playlists with other extensions that cannot be assumed to be UTF8 which I very clearly stated and agreed with.

Independent readers can make their own minds up.

Man I'm done. You keep being condescending. Really, check your behavior.

Quote from: regor
ReadTextFile fails detecting the codepage (UTF-8) of this file when BOM is not set (which I have disabled for Unix compatibility)...

The file being m3u8 was a coincidence, an example, not a requisite (which TheQwertiest understood but not you, it's fine, but I explained it later) .

Quote from: TheQwertiest
Nothing can be done about it - codepage detection is heuristic based, which does not provide 100% accuracy. The only way to ensure that UTF is detected correctly is by using UTF BOM.
TheQwertiest already answered it all before you.

Quote from: snotlicker
Not sure I see the issue here. If you have m3u8 files they're always going to be UTF8 with or without BOM.

If a file has any kind of BOM, the optional codepage arg is always ignored because processing never gets that far. BOM handling always takes precedence and the function returns early. If supplying a codepage arg for UTF8 without BOM is required, it's a total non issue.
 
Then you had to continue with obvious comments... like you always do. "hey man, X is X, don't you see it?"

Quote from: regor
I have provided a m3u8 file as example, but obviously the playlists formats are not limited to m3u8 but also m3u and pls and those may use UTF8 with and without BOM. T
I clearly noted I was referring to a variety of playlists formats.

Quote from: snotlicker
You haven't comprehended my post at all so here's a code example...
And then your high point comment. "Let me show you how you don't understand anything again". And so on and so on.

It really takes 1 minute to see your constant attitude of treating others like kids, just joining the points. Please, from now on just skip my comments/complaints/posts since I have no tolerance for that toxic attitude. Thanks.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-09-14 13:04:06
I will always explain component internals in a dumbed down manor. I've never going to assume anyone has read and understood the C++ behind the scenes unless they explicitly state that up front. Clearly you had no idea or your query would not exist.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Koshingg on 2021-09-16 15:22:09
@TheQwertiest I have this error in the Properties script, it happens quite often

Error: Spider Monkey Panel v1.5.2 (Properties: Properties by marc2003)
f is null

File: list.js
Line: 933, Column: 21
Stack trace:
  _list/this.init/this.add_meta@list.js:933:21
  _list/this.update@list.js:574:10
  _list/this.metadb_changed@list.js:91:9
  on_metadb_changed@:33:7
  _panel/this.item_focus_change@panel.js:11:4
  on_playlist_switch@:74:8
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-09-16 15:42:40
That's strange. It implies this call to GetFileInfo is failing and returning null. WSH/JSP never did this and always return a valid object???

https://github.com/TheQwertiest/smp_2003/blob/80af82ddba0b1827dcbd2f03d5b90aaeea5cb8e4/js/list.js#L572

But having checked the docs, it does outline the possibility of the return value being null.

https://theqwertiest.github.io/foo_spider_monkey_panel/assets/generated_files/docs/html/FbMetadbHandle.html#GetFileInfo

I guess the script will need updating to check the return value before trying to use it.

edit: this would render the script utterly useless. It wouldn't be able to iterate over all tags without knowing their names in advance and the tech info fields. Hopefully something can be done component side.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-09-16 16:53:43
I see the difference now. I'm using this "simplified" method

Code: [Select]
	//! Simplified method, always returns non-null, dummy info if nothing to return.
virtual metadb_info_container::ptr get_info_ref() const = 0;

SMP is using

Code: [Select]
	//! \since 1.3
//! Retrieve a reference to the primary info. \n
//! You can hold the reference to the info as long as you like, call the method in any context you like with no lock semantics involved. The info held by the returned reference will remain constant even if the metadb content changes. \n
//! Returns true and sets outInfo to a reference to this item's primary info on success, returns false on failure (no info known at this time).
virtual bool get_info_ref(metadb_info_container::ptr & outInfo) const = 0;
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-09-25 13:59:43
@kutuzof , @TT , @kgena_ua , I fixed some bugs, could you, plz, try the latest dev build and check if it works for you as well?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kutuzof on 2021-09-25 14:32:52
TheQwertiest, thank you! Both biography panels work well. So far, there are no failures.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: loz on 2021-09-27 16:04:22
Two Questions:
Is there any way to change the sort order on autoplaylist.js?
Is there any way to bind ratings to albums in instead of just artist and track while still using SMP database in ratings.js? (I'm guessing no here.)
Thanks.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-09-27 16:23:51
Here's a quick and dirty hack for autoplaylists that will sort by name if you middle click. Right click>Configure and add this...

Code: [Select]
function on_mouse_mbtn_up() {
    if (list.data.length < 2) return;
    list.data = _.orderBy(list.data, 'name');
    list.save();
    list.offset = 0;
    window.Repaint();
}

You can also click entries and move up/down but that's a bit cumbersome.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kgena_ua on 2021-09-27 16:34:21
TheQwertiest, v.1.6.0., my script "clock and timer" works well.
But i have a new problem.
I use pseodo-transparence.
After start Foobar i have black background now (pseodo-transparence does not work). If i go to "Show configure" - "Appearence" and press "OK" pseodo-transparence turns on.

Or I make mistake and must use version 1.5.2.

Thanks.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: loz on 2021-09-27 16:51:27
Here's a quick and dirty hack for autoplaylists that will sort by name if you middle click. Right click>Configure and add this...

Code: [Select]
function on_mouse_mbtn_up() {
    if (list.data.length < 2) return;
    list.data = _.orderBy(list.data, 'name');
    list.save();
    list.offset = 0;
    window.Repaint();
}

You can also click entries and move up/down but that's a bit cumbersome.
Thanks!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-09-28 10:58:40
Download link is missing at
https://www.foobar2000.org/components/view/foo_spider_monkey_panel
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-09-28 13:04:35
@kgena_ua , thanks, I'll take a look.
@regor , that's intentional: I want my download count and fb2k component section does not provide it (I need to feed my sense of importance after all :D)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-09-28 13:48:15
@kgena_ua, wait, is this on 1.6.0 or on the dev build? If it's 1.6.0 can you try the dev build and see if this bug is present there?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kgena_ua on 2021-09-28 14:59:16
can you try the dev build and see if this bug is present there?
@TheQwertiest, sorry, i can not find a link.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-09-28 15:15:18
See the first post in this thread, there is a link called "Dev Build". This link always points to the latest dev build.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kgena_ua on 2021-09-28 15:35:29
See the first post in this thread, there is a link called "Dev Build".
Thanks.
Everything seems to work.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kgena_ua on 2021-10-06 19:29:15
For example, I made a simple script. Sometimes I get an error.
Code: [Select]
const objShellApp = new ActiveXObject("Shell.Application");

function get_folder() {
    var prompt = "\nSelect folder ...";   
    var folder = objShellApp.BrowseForFolder(0, prompt, 512, 17);
    if (folder != null) {
        /// do ...
    }
}

MF_ENABLED = 0x00000000;
MF_SEPARATOR = 0x00000800;

function on_mouse_rbtn_up(x, y){
    const _menu = window.CreatePopupMenu();
    _menu.AppendMenuItem( MF_ENABLED, 100, "Getfolder");
    _menu.AppendMenuItem( MF_SEPARATOR, 0, 0);
    _menu.AppendMenuItem( MF_ENABLED, 230, "Edit Script");

    ret = _menu.TrackPopupMenu(x, y);
   
    switch (ret) {
    case 100:
        get_folder();
        break;
    case 230:
        window.EditScript();  
        break; 
    }
    return true;  
}

This also happens with:
utils.InputBox();
WshShell.Popup();
Select a menu item and wait.
Sometimes the error occurs immediately.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-10-06 21:02:19
For example, I made a simple script. Sometimes I get an error.
Code: [Select]
const objShellApp = new ActiveXObject("Shell.Application");

function get_folder() {
    var prompt = "\nSelect folder ...";   
    var folder = objShellApp.BrowseForFolder(0, prompt, 512, 17);
    if (folder != null) {
        /// do ...
    }
}

MF_ENABLED = 0x00000000;
MF_SEPARATOR = 0x00000800;

function on_mouse_rbtn_up(x, y){
    const _menu = window.CreatePopupMenu();
    _menu.AppendMenuItem( MF_ENABLED, 100, "Getfolder");
    _menu.AppendMenuItem( MF_SEPARATOR, 0, 0);
    _menu.AppendMenuItem( MF_ENABLED, 230, "Edit Script");

    ret = _menu.TrackPopupMenu(x, y);
   
    switch (ret) {
    case 100:
        get_folder();
        break;
    case 230:
        window.EditScript();  
        break; 
    }
    return true;  
}

This also happens with:
utils.InputBox();
WshShell.Popup();
Select a menu item and wait.
Sometimes the error occurs immediately.
Does it happen with the dev build as well?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kgena_ua on 2021-10-07 07:22:17
Does it happen with the dev build as well?
@TheQwertiest.
Happened before And now with the dev build.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-10-08 19:14:30
Not sure if it has been already changed, but on v1.5.2-dev+28cbd05e I have just seen a BSOD and all packages being used have been corrupted, those panel reset and all properties lost.  ::)  Having a backup of the json files as fallback would come handy if that single file can break everything.

Does it happen with the dev build as well?
@TheQwertiest.
Happened before And now with the dev build.
Can also confirm that behavior when opening popups in any way.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kgena_ua on 2021-10-09 11:49:07
Happened before on this example. I had to abandon such a code.
Code: [Select]
MF_ENABLED = 0x00000000;
MF_SEPARATOR = 0x00000800;

var limit = 0;

function on_mouse_rbtn_up(x, y){
    const _menu = window.CreatePopupMenu();
    _menu.AppendMenuItem( MF_ENABLED, 100, "Set limit");
    _menu.AppendMenuItem( MF_SEPARATOR, 0, 0);
    _menu.AppendMenuItem( MF_ENABLED, 230, "Edit Script");

    ret = _menu.TrackPopupMenu(x, y);
   
    switch (ret) {
    case 100:
        download_limit(x, y);
        break;
    case 230:
        window.EditScript();  
        break; 
    }
    return true;   


function download_limit(x, y){
    const _menu = window.CreatePopupMenu();
    _menu.AppendMenuItem(MF_ENABLED, 1, "Increase");
    _menu.AppendMenuItem(MF_ENABLED, 2, "Limit : "  + limit + "     Return to main menu");
    _menu.AppendMenuItem(MF_ENABLED, 3, "Decrease");

    ret = _menu.TrackPopupMenu(x, y);

    switch (ret) {
    case 1:
        limit = limit + 1;
        // do
        download_limit(x, y);
        break;
    case 2:
        on_mouse_rbtn_up (x, y);
        break;
    case 3:
        limit = limit <= 1 ? 1 : limit - 1;
        // do
        download_limit(x, y);
        break;
    }
}
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-10-09 14:02:08
Happened before on this example. I had to abandon such a code.
Code: [Select]
MF_ENABLED = 0x00000000;
MF_SEPARATOR = 0x00000800;

var limit = 0;

function on_mouse_rbtn_up(x, y){
    const _menu = window.CreatePopupMenu();
    _menu.AppendMenuItem( MF_ENABLED, 100, "Set limit");
    _menu.AppendMenuItem( MF_SEPARATOR, 0, 0);
    _menu.AppendMenuItem( MF_ENABLED, 230, "Edit Script");

    ret = _menu.TrackPopupMenu(x, y);
   
    switch (ret) {
    case 100:
        download_limit(x, y);
        break;
    case 230:
        window.EditScript();  
        break; 
    }
    return true;  
}

function download_limit(x, y){
    const _menu = window.CreatePopupMenu();
    _menu.AppendMenuItem(MF_ENABLED, 1, "Increase");
    _menu.AppendMenuItem(MF_ENABLED, 2, "Limit : "  + limit + "     Return to main menu");
    _menu.AppendMenuItem(MF_ENABLED, 3, "Decrease");

    ret = _menu.TrackPopupMenu(x, y);

    switch (ret) {
    case 1:
        limit = limit + 1;
        // do
        download_limit(x, y);
        break;
    case 2:
        on_mouse_rbtn_up (x, y);
        break;
    case 3:
        limit = limit <= 1 ? 1 : limit - 1;
        // do
        download_limit(x, y);
        break;
    }
}

It happens on every instance where the code is waiting for user input to continue execution. Menus, input boxes, etc. Obviously there is not a reason to open a menu and wait... but if you do, you get a warning about script taking too much time. You could bypass it using promises though... but agree a workaround on the base code would be better.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Majestyk on 2021-10-10 10:37:21
Trying to switch Darkone theme to SMP and I was having great success until the Display. I get this...

Failed to create GdiPlus object (0x2): InvalidParameter
File: Display.js
Line: 162, Column: 18
Stack trace:
on_paint@Display.js:16218

Line 162 is: d_font = gdi.Font("Arial Black", f_size);

It happens on bootup. Reloading works fine.

I have made no changes to the code other than taking out Dispose. In fact, anything that has a line like this in it, whether it's Darkone or not, crashes . I can reload but it will crash on bootup.

EDIT: Ok, never mind. It stopped doing this after I "fixed" the Visual switch in the Panel Stack Splitter.  But the switch worked fine with JScript.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-10-10 14:28:24
Just guessing but I suspect the issue is related to the variable f_size being dependent on panel width/height which could be 0 on startup - this would explain why it works after reloading later. Ideally, it should be initialised with a sensible minimum value for a font and only grow if the panel gets bigger.

edit: with regard to JSP behaving differently, SMP is doing it better by throwing more errors. While it might seem like an inconvenience, it actually forces the creation of better scripts.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Majestyk on 2021-10-11 00:17:17
Thanks for the reply. I'm back to that error again. I thought I had it licked. I actually have two displays on my Darkone. (I'm talking about the display with the Elapsed/Remaining time). It's fine with one display but when I add an additional one, it throws the error on bootup.

Only one display is visible at a time.

It used to throw the error when I cycled the displays with the Visual switch but I tweaked the "Switch code" a bit and now it errors only on bootup. 

So how would I go about initializing the width/height?

Thanks, again!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Majestyk on 2021-10-11 07:19:28
Ok, I think I REALLY fixed it this time. :) I believe it had to do with the panel stack settings (as stated above), specifically the Panel List settings (Left, Top, Width, Height). I had duplicate values in both the splitter's $movepanel entries AND the Panel List.  Once I deleted the panel list entries the errors stopped.

Anyway, thanks for your time.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Majestyk on 2021-10-24 05:45:50
I think I've found a bug with SMP 1.6.0. Perhaps it's already been reported. When I use 1.6.0 with Tedgo's Darkone, every SMP panel flickers on and off when I resize the window. What I mean is when I minimize and then grab a corner and stretch it in and out. The buttons also dance around more than they should.

Replacing the 1.6.0 dll with 1.5.8 fixes it.

It took me awhile to trouble shoot it. I killed every panel except one SMP and then I inserted a Jscript panel. The SMP (1.6.0) flickered but the Jscript did not.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-10-24 13:20:20
Don't use 1.6.0, use 1.5.2 instead.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-10-25 08:54:40
Would it be possible to retrieve some kind of uuid for playlists?

That would make a lot easier to track a playlist no matter its position or if there are other playlists with same name. Just asking to get that info, nothing more. Traversing them can be done by idx fine.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-10-25 12:34:15
Would it be possible to retrieve some kind of uuid for playlists?
No can do: fb2k does not provide any such information. It's probably stored as a plain array internally.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-10-28 09:44:10
Other question, could ${current_script_path} be exposed as variable?
https://theqwertiest.github.io/foo_spider_monkey_panel/assets/generated_files/docs/html/global.html#include
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2021-11-18 09:57:10
Not sure if it has been already changed, but on v1.5.2-dev+28cbd05e I have just seen a BSOD and all packages being used have been corrupted, those panel reset and all properties lost.  ::)  Having a backup of the json files as fallback would come handy if that single file can break everything.

Does it happen with the dev build as well?
@TheQwertiest.
Happened before And now with the dev build.
Can also confirm that behavior when opening popups in any way.
Just got a Foobar crash and again all panels with packages got reset and all properties were lost due to json files being corrupted. Packages are becoming an annoyance more than helping... :(
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: lpv on 2021-11-18 12:18:56
Hello,

does anyone know how to fix the ActiveX htmlfile error?:

ActiveXObject_Constructor failed:
Failed to create ActiveXObject object via CLSID: htmlfile
const doc = new ActiveXObject('htmlfile');

Is there a fix or workaround?
I am using the latest Spider Monkey Panel v1.4.1 with foobar 1.6.5...

Thank you

- TT

You need to install the Gecko support in Wine to have basic HTML controls, and even then, it's not guaranteed to be compatible with Windows.

For anyone else that has the same problem running foobar in Wine, installing Gecko solved the problem.
Unfortunately that didn't work for me using WilB's Biography. But.. I'm using the snap foobar package, I'm not sure how much of a difference that makes.
## foobar 1.6.8 snap, wine 6.16(?),  spider monkey 1.5.2
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Majestyk on 2021-11-25 06:54:03
Hi,

Does someone knows a trick to trigger a new evaluation of panel stack splitter scripts, from a SMP panel ?
There is the play/pause way, using the function below, because the PerTrack scripts of a PSS panel are evaluate on playback changes, but this creates some sound glitches, especially while playing live streams (because foobar can't buffer the stream when this is a live stream, it need to synchronize with the stream after a pause command)

Code: [Select]
function RefreshPSS() {
if (fb.IsPlaying || fb.IsPaused) {
fb.PlayOrPause();
fb.PlayOrPause();
}
else {
fb.Play();fb.Stop();
}
}

There is a trick you can try.

You will need to enable is the PSS panels "Evaluate scripts when track info is modified"

Change your function to
Code: [Select]

function RefreshPSS() {
let handle_list = plman.GetPlaylistItems(plman.ActivePlaylist);
handle_list.RefreshStats();
}

There is a limitation:  Your handle list cannot be empty.

Ah yes, thanks! By combining both methods, you end up with something which work all the time:
Code: [Select]
function RefreshPSS() {
if (fb.IsPlaying || fb.IsPaused) {
let handle_list = new FbMetadbHandleList(fb.GetNowPlaying());
handle_list.RefreshStats();
}
else {
fb.Play();fb.Stop();
}
}

Important point:
 "Evaluate scripts when track info is modified" needs to be enabled AND on the script tab of the PSS panel, "Titleformat mode on startup" needs to be on "now playing"

Replying to an older post from Page 8. I have the exact same issue and it's exactly what I need for a theme I'm using, which I haven't yet converted to SMP. (It's currently jscript)

I was wondering if these two lines be converted to jscript...

let handle_list = new FbMetadbHandleList(fb.GetNowPlaying());
handle_list.RefreshStats();
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Majestyk on 2021-11-25 08:17:03
Never mind, I figured it out. :)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: michaengfrv on 2021-11-26 01:30:50
SMP Sample rating.js crashes when adding location
(fb2k profile path\user-components\foo_spider_monkey_panel\samples\complete\rating.js)

The first one or two are fine, but adding more locations causes crashes.

List of location
http://radio.linn.co.uk:8003/autodj
https://q2stream.wqxr.org/q2
http://stream.radioparadise.com/flac


So I have tested after clean install.(portable installation v1.6.8 stable)
I installed 2 components.

Column UI 1.7.0-beta.2
SMP 1.5.2

Reload command of right button menu doesn't work.
But after playing the stream, the error window does not appear.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2021-11-26 02:46:25
It's a known bug with the component. I've submitted a fix on github but it could be some time before the next version is released.



Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: michaengfrv on 2021-11-26 03:09:04
It's a known bug with the component. I've submitted a fix on github but it could be some time before the next version is released.

Thanks for answer. I'll be waiting for the next version.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2021-12-01 16:56:51
yea, work was a being too stressful lately, so had zero capacity for any of my pet projects.
will probably return to (semi-)active development by the end of December/January
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: sub_ubi on 2021-12-05 03:26:12
Hello, I just installed this component today and I'd love to check out some of the user scripts, as described here:
https://theqwertiest.github.io/foo_spider_monkey_panel/docs/script_showcase/single_panel_scripts/#built-in-scripts

I am unable to find the "Open Configure Panel... dialog." option
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: sub_ubi on 2021-12-05 04:30:14
Hello, I just installed this component today and I'd love to check out some of the user scripts, as described here:
https://theqwertiest.github.io/foo_spider_monkey_panel/docs/script_showcase/single_panel_scripts/#built-in-scripts

I am unable to find the "Open Configure Panel... dialog." option
Nevermind, I figured it out. I had to add the spidermonkey layout panel.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kgena_ua on 2021-12-27 18:36:34
How to force execution window.Width and window.Height at the start of the script.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2022-01-07 20:09:43
Hello @TheQwertiest , I am trying to upgrade (inport) Biography JS v1.2.0 over the older 1.1.3 but I cannot do that because FB crashes at each attempt.
I also tried to remove and reinstall SMP (v1.6.0), but once reinstalled that old JS is automatically re-loaded and I have again the same problem.
How can I completely reset my SMP / FP installation? Or how can I simply force a single SMP panel to reset?
Regards, Andrea
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2022-01-08 06:59:18
You should not use SMP v1.6 as it has known issues. Use v1.52 - https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/tag/v1.5.2

If you still have issues then remove the component. Do it manually via explorer if you can't start fb2k (profile\user-components). Now when you start fb2k, you should have a blank space where the previous instance was. Click the blank space and add any other element. This will clear the previous instance data that was there. Now you should install v1.5.2 and replace a new panel as you normally do.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: AndreaT on 2022-01-09 10:59:15
Hello @marc2k3 and @TheQwertiest , I downgraded to SMP 1.5.2 and FB 1.6.9 doesn't crash anymore.
And finaly I could install the new version of the JS.
Thank you so much.
Regards, Andrea
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2022-01-13 21:22:20
For example, I made a simple script. Sometimes I get an error.
Code: [Select]
const objShellApp = new ActiveXObject("Shell.Application");

function get_folder() {
    var prompt = "\nSelect folder ...";   
    var folder = objShellApp.BrowseForFolder(0, prompt, 512, 17);
    if (folder != null) {
        /// do ...
    }
}

MF_ENABLED = 0x00000000;
MF_SEPARATOR = 0x00000800;

function on_mouse_rbtn_up(x, y){
    const _menu = window.CreatePopupMenu();
    _menu.AppendMenuItem( MF_ENABLED, 100, "Getfolder");
    _menu.AppendMenuItem( MF_SEPARATOR, 0, 0);
    _menu.AppendMenuItem( MF_ENABLED, 230, "Edit Script");

    ret = _menu.TrackPopupMenu(x, y);
   
    switch (ret) {
    case 100:
        get_folder();
        break;
    case 230:
        window.EditScript();  
        break; 
    }
    return true;  
}

This also happens with:
utils.InputBox();
WshShell.Popup();
Select a menu item and wait.
Sometimes the error occurs immediately.
No matter how I try, I can't reproduce the issue. Maybe it is OS dependent. What OS are you using?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kgena_ua on 2022-01-14 07:18:42
Quote
No matter how I try, I can't reproduce the issue. Maybe it is OS dependent. What OS are you using?
@TheQwertiest
The problem is gone with the version 1.5.2.
Thanks
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2022-01-14 16:54:39
Version: 1.6.1
Link: https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/tag/v1.6.1
Changelog:
Hotfix for v1.6.0 (see changelog above (https://hydrogenaud.io/index.php?topic=116669.msg1002797#msg1002797))
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2022-01-14 20:03:27
Saw the fileinfo notification on github. Sad times...  :))

I guess the dev build has the fix though. I see it built OK,
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2022-01-14 20:22:05
yea >_<
it will be included in the next hotfix anyway (and I'm sure there *will* be a next hotfix :D)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2022-01-14 20:27:33
@marc2k3 and there is a lot of stuff that I need to steal from JScript as well :P
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2022-01-26 15:21:44
To whoever posts about component dev builds on https://foobar2000.xrea.jp/ : there is no real point in posting info about builds from branches other than `master`, since all `dev build` links always point to the `master`. I.e. users won't be able to easily reach builds from other branches anyway (e.g. builds from PR branches).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2022-01-26 21:38:56
^What you say is the desirable behaviour but it doesn't seem to be the case. I just followed the dev build link in the first post of this thread and installed it. It has the same commit hash as the latest build from another contributors feature branch...

(https://i.imgur.com/Y3a4Rs7.png)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2022-01-27 10:54:29
@marc2k3 thanks for the heads-up!
I was sure that I've fixed all urls a long time ago, guess I missed some...
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2022-02-01 11:15:19
Is this behavior intended?

Pressing R. Click -> NOTHING -> and moving without releasing it -> on_mouse_move -> releasing R. Click -> NOTHING

I was expecting:

Pressing R. Click -> on_mouse_rbtn_down ->  and moving without releasing it -> on_mouse_move -> releasing R. Click -> on_mouse_rbtn_up

PD: last release, win 7, foo 1.6.2
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2022-02-01 11:39:16
My seekbar script included with the component has no issues. This gif shows a red blob to indicate the right mouse button is down.

(https://i.imgur.com/cij2WRE.gif)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2022-02-01 12:54:06
Nope. Tried this on a blank panel:
Code: [Select]
function on_mouse_rbtn_down(x, y, mask) {
console.log('down');
}

function on_mouse_move(x, y, mask) {
    const MK_RBUTTON  = 0x0002;
    if (mask === MK_RBUTTON) { console.log('move');}
}

function on_mouse_rbtn_up(x, y, mask) {
console.log('release');
return true;
}

Spoiler (click to show/hide)
Down and up don't fire when holding the r. click and moving.

Edit: double checked to be sure and it's the 1.6.1 release (no dev).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2022-02-02 09:26:38
Tried it on another pc win 10 and same results.
Left and middle buttons work fine with the same test, right button is bugged.

Btw testing your sample file  track info + seekbar + buttons.js-  (which comes with 1.6.1) I had this error just after setting it:
Code: [Select]
Error: Spider Monkey Panel v1.6.1 (Playlist Manager: Track Info + Seekbar + Buttons by marc2003)
DrawImage failed:
GdiPlus error: DrawImage failed with error (0xb): ValueOverflow

File: helpers.js
Line: 175, Column: 6
Stack trace:
  _drawImage@helpers.js:175:6
  on_paint@track info + seekbar + buttons.js:62:4
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Porcus on 2022-02-23 13:50:07
Suggestion that has possibly been considered and rejected, sorry:
If and when when there is a new version: Put the github URL (like "https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/") in the component's "about", making it easier to find.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: mamema on 2022-02-28 17:39:38
i'm trying to start with SMP. I wantb to use some other components which are relying on SMP

I've installed the SMP component.It's showing up in the components list.
But then the tool relying on SMP asks "to load the .js into SMP

Sorry for this stupid question, but i haven't found where ni can load something into....

Please tell me where this load function is located
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MojoBass on 2022-03-01 05:10:35
SMP stands for Spider Monkey Panel. So you first have to create a SMP panel in your foobar UI. How to create a panel depends on which of the two UIs, which are available in foobar (Default UI - DUI or Columns UI - CUI), you are using (not going into details here).
As soon as you have created a SMP panel, load the respective js file with clicking on the SMP panel, which opens the editor, then select file/import...
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: mamema on 2022-03-01 11:04:03
thank you for your answer. My foobar tells me, that i only have default user interface active.
It's still over my head. Can you provide some walk through / how to links, which help me to start with this?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2022-03-01 11:25:42
Check the installation section within the attached PDF. Default UI or CUI are both the same when editing the layout via 'Live editing'.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: mamema on 2022-03-01 12:47:03
thanks, that was helpful
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Function on 2022-03-02 09:40:53
I might have found a bug or at least an unwanted side effect, but it also could be my own fault.
It seems as if when the JavaScript thread is blocked by something synchronous then some keyboard actions in the F2K GUI don't register even though they are interactible with the mouse.
In my example, i can't press Enter on the "Move to" dialogue to confirm the "Run" button while the SMP component i have is waiting for a WScript.Shell.Run call. I'm running a modified version of marc2k3's spectrogram, the main source code is here: https://gist.github.com/FunctionDJ/914b3066d1ab368c1fd1a62b4e13f55f

As soon as the thread is unblocked (the call finishes and the spectrogram is shown) pressing Enter works again. What surprises me is that everything else about the GUI seems to work fine, like using the mouse to press "Run".
When i use a different SMP component, this issue goes away. Any ideas on why these are correllated?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Function on 2022-03-02 12:42:42
I also have a question: How can i get a FbMetadbHandle from a file path? How can i load the file? From the generated JS doc file it looks like we're not supposed to instantiate FbMetadbHandle ourselves, since the path property is annotated as read-only and not a constructor argument.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2022-03-02 12:54:27
So the file is not in the library or any playlist?? You could use fb.GetQueryItems() with the %path% if it was.

Failing that, you'll have to load files to a temp playlist with plman.AddLocations (takes an array of strings which can be paths/urls/playlists etc)

JScript Panel users have an additional fb.AddLocationsAsync which does the same thing as plman.AddLocations but sends the handles to a callback (on_locations_added).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Function on 2022-03-02 14:27:47
Thanks a lot marc! Good to know! Yeah i meant for files that are not in the library.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Function on 2022-03-03 15:44:58
I have another question (of course, it never stops, i'm so sorry  :-[ )
When i use fb.RunContextCommandWithMetadb("Play", track) it sometimes just doesn't work and the function also returns false.
marc told me that the returned value of RunContextCommandWithMetadb indicates wether the command exists or not (https://github.com/TheQwertiest/foo_spider_monkey_panel/issues/163#issuecomment-1057530228).
So am i using it wrong? The object i'm passing as the second parameter is always a handle of a single file. Why does it sometimes work and sometimes doesn't (returns true or false)?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2022-03-03 20:13:15
The function walks over all the commands for a given selection and keeps going until it finds a text match. That's why the return value is true/false based on that.

The component itself is not responsible for the commands that are provided.

This snippet will give the exact same commands for a given handle list so the command/naming must be an exact match for what you see here...

Code: [Select]
var HANDLE_LIST = fb.GetLibraryItems();

function on_mouse_lbtn_up(x, y) {
var menu = window.CreatePopupMenu();
var context = fb.CreateContextMenuManager();
   
    context.InitContext(HANDLE_LIST);
    context.BuildMenu(menu, 1);

var idx = menu.TrackPopupMenu(x, y);
if (idx > 0) {
context.ExecuteByID(idx - 1);
}
}
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Function on 2022-03-04 10:14:45
The function walks over all the commands for a given selection and keeps going until it finds a text match. That's why the return value is true/false based on that.
[...]

I don't know why or how, but when playing around with the ContextMenuManager and MenuObject it just seemed to fix itself without me actually changing the logic of the playback. Maybe it was also checking and unchecking the "Play" entry in the F2K context menu settings, i'm not sure why it only worked sometimes before and now it works regardless of that setting...
Anyway, thanks a lot - again - for telling me how these APIs work, i learned a lot!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2022-03-04 10:30:12
Btw.... I have been checking it too and noticed a weird thing.
"Play" is NOT available on the contextual menu on playlist items. I double checked and it's enabled on the preferences panel (CUI).
But it's available on the album list panel, whenever you select a single track, but not on multiple selection.

Don't understand the logic behind that behavior, but that may account for the thing you are experiencing... since the entry does not exist in some cases.

PD: even if the entry is hidden, it should work with the proper flag, no matter your preferences.
https://theqwertiest.github.io/foo_spider_monkey_panel/assets/generated_files/docs/html/fb.html#.RunContextCommand
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Function on 2022-03-04 10:59:00
Very interesting regor!

I wanted to share what i made with SMP: A faster delete command (on my computer at least).
Source code: https://gist.github.com/FunctionDJ/47e37ea673ef3fd22279ee17bec13168
When i use F2K normally and i'm deleting tracks while playing them, it can take a few seconds until F2K has figured everything out, deletes the track, and moves playback to the next track. This wait time is absent when none of the selected tracks are being played back.
Also if i'm deleting the currently playing track (A) and the next track (B) F2K will show an error that it can't read file B because that would be next after A gets deleted.
This script works around these issues by figuring out the next track in the playlist that won't be deleted before deletion is attempted and moves the playback to that track, or stopping the playback if there is no next track that won't be deleted.
With this my workflow of going through my library and deleting stuff after listening to it is sped up a lot.
The speed issue might not exist on other people's machines, but at least the error i described should be reproducible, so if anyone would like to try out this script, please let me know what you think!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2022-03-04 11:33:59
"Play" is NOT available on the contextual menu on playlist items.

There are 3 internal SDK methods for generating context menu items. The issue is explained in point 3.

Here's a snippet of C++ and the direct relationship with SMP methods....

Quote
auto ptr = contextmenu_manager::get();

// 1)
// fb.RunContextCommand(command) and ContextMenuManager InitNowPlaying
// both use this internally so there should be direct correlation between
// behaviour
ptr->init_context_now_playing(contextmenu_manager::flag_view_full);

// 2)
// fb.RunContextCommandWithMetadb(command, handle_or_handle_list) and ContextMenuManager InitContext(handle_list
// both use this internally so there should be direct correlation between
// behaviour. "Play" should be available when the handle list count is 1.
// Album list and any other library viewer should be using this
ptr->init_context(handles, contextmenu_manager::flag_view_full);

// 3)
// Only ContextMenuManager InitContextPlaylist uses this internally - also the same as any proper
// playlist uses. This should be the reason for the difference between album list and playlists.
ptr->init_context_playlist(contextmenu_manager::flag_view_full);

edit: it's possible there are javascript-y playlists out there unaware of InitContextPlaylist and may be using plman.GetPlaylistSelectedItems and passing the result to InitContext. How confusing!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Majestyk on 2022-04-07 21:55:53

EDIT... Never mind, I figured it out. I tried gr.DrawString before and it didn't work but that's because I accidentally typed gr.GdiDrawString. Oops.

Question... I'm using a small Scroll Text script and I can't get RGBA to work using gr.GdiDrawText. Only RGB works. Does RGBA not work with gr.GdiDrawText? Is there a work around? I of course have the following at the top:
Quote
// ----- CREATE RGB(A) -------------------------------
function RGBA(r, g, b, a) {
   return ((a << 24) | (r << 16) | (g << 8) | (b));
}

function RGB(r, g, b) {
   return (0xff000000 | (r << 16) | (g << 8) | (b));
}
// ---------------------------------------------------

No smiley faces of course.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: mjm716 on 2022-04-09 08:06:33
Version: 1.6.0

  • Added WIC support in image and art loaders, which enables WebP support (see FAQ for more info).


I'm running FB 1.6.10, SMP 1.6.1 with Wilb's Bio panel 1.2.

Webp files do not display, so I'm wondering:
Are they indeed supported in the 1.6.1 hotfix?
Do panel scripts need to be explicitly updated to support?
Does anyone see webp files in SMP?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2022-04-09 08:48:48
Scripts that display images from given folders will need updating. As an example, the included thumbs script would need editing here...

https://github.com/TheQwertiest/smp_2003/blob/abe16d3095544982ae3bc12ae99e1e041e63d7b2/js/thumbs.js#L573

Searching WilB's scripts for jpg might give you a clue as to what you'll need to edit.

Album art scripts that use the built in album art methods don't need updating as such. You just need to make sure the main preferences are updated (File>Preferences>Display>Album art)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: mjm716 on 2022-04-09 14:57:42
...

thanks Marc

@Wilb seems to be MIA for quite some time, I hope he hasn't given up on his scripts
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: krypton on 2022-05-10 18:38:45
hi, I've got a question about tooltips, I was wondering what the best way of having different tooltips appear in a window based on where the mouse is (or specifically which element the mouse is currently over)? I've been working on a very rudimentary track properties box to fit my theme, and I can add a general tooltip, but I can't quite figure out how to capture the current mouse position to use to change what the tooltip actually says, I'd be grateful of any advice.  :)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2022-05-17 20:14:47
A small update: support for all of my component is on-hold, since I have to spend most of my free time to resolve IRL issues caused by a certain February event. ETA of development restart is autumn (if everything works out).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Black_Over_Bills_Mothers on 2022-05-18 15:26:33
@TheQwertiest
Nice to know you intend to carry on supporting/developing this component.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2022-05-18 18:24:40
@TheQwertiest,

wish you and your family all the best mate, stay strong!

-TT
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: krypton on 2022-05-20 02:35:38
found a way to do what I want with the tooltips, great component!  :D
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2022-07-25 00:03:09
Is there a way of wating for a CMD command without blocking the entire panel? For ex:

Helper:
Code: [Select]
const WshShell = new ActiveXObject('WScript.Shell');

function _q(value) {
return '"' + value + '"';
}

function _runHidden() {
try {
WshShell.Run([...arguments].map((arg) => {return _q(arg);}).join(' '), 0, true);
return true;
} catch (e) {
return false;
}
}

Main file:
Code: [Select]
....
_runHidden(streaming_extractor_music.bat, path, essentiaJSON, essentiaPath);
... do someting with output json

Bat file:
Code: [Select]
@ECHO OFF
REM Helper to execute essentia.exe (%3) on input (%1) and save output to file (%2)
REM Retrieves LRA data as json
SET essPath=%3
%essPath% %1 %2

So when running the bat file, the panel gets blocked. But setting WshShell.Run last arg to false to not wait for termination does not inform the process when it ends.... I was hoping to get somewhat a promise functionality without luck.

Is there a better way than checking for an output file every 100 ms with an interval func or something like that? (or maybe I'm missing another approach to it)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2022-08-17 15:43:47
@TheQwertiest,

pretty excited and scared for foobar2000 v2 x64, because not only Georgia-ReBORN, but your CatRox theme, Eole and many other themes using UIHacks will not work ( I guess ).
I saw in your TODO list you wanted to implement the UIHacks features directly into SMP, I guess you should prioritize this on your list now :-)

Hope your doing well!

-TT
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2022-08-18 01:23:02
Who really cares about UI hacks? Hiding the title bar is nothing.

A far more important dependency for themes like Eole/Catrox/etc is Panel Stack Splitter which will never be updated. I suspect a good chunk of people will stick with 32 bit for that (and many other components that won't be updated).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: always.beta on 2022-08-18 03:03:23
A far more important dependency for themes like Eole/Catrox/etc is Panel Stack Splitter which will never be updated. I suspect a good chunk of people will stick with 32 bit for that (and many other components that won't be updated).
Maybe consider using foo_uie_jsplitter instead of pss
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MojoBass on 2022-08-18 05:56:28
Panel Stack Splitter which will never be updated
Why would PSS never be updated?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: jazzthieve on 2022-08-18 06:06:08
A far more important dependency for themes like Eole/Catrox/etc is Panel Stack Splitter which will never be updated. I suspect a good chunk of people will stick with 32 bit for that (and many other components that won't be updated).

Yep, that would exactly be the reason not to switch to 64bit. Pss and ELplaylist would be the reasons for me to stick to 32bit.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2022-08-18 06:08:51
Why would PSS never be updated?

Well it has been 13 years since the last release. Perhaps I should have used the word unlikely rather than never.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MojoBass on 2022-08-18 06:15:32
I agree: PSS or similar not being available would be a desaster!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2022-08-18 08:00:11
Who really cares about UI hacks? Hiding the title bar is nothing.

I do care and many others too :P. Not only is it for hiding the title bar, but it has also features like window size manipulation, minimum size, drop shadow, etc.

A far more important dependency for themes like Eole/Catrox/etc is Panel Stack Splitter which will never be updated. I suspect a good chunk of people will stick with 32 bit for that (and many other components that won't be updated).

You're right about that, forgot they're using the pss, also Lyrics Show Panel 3 ( hope Openlyrics will get a 64bit ver ) and your and Mordred's enhanced playcount and many other essential components will get into trouble.
Nevertheless there will be exciting times when foobar2000 v2 x64 will be released, let see if new components will arise...

-TT


Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: loz on 2022-08-30 14:51:42
Maybe consider using foo_uie_jsplitter instead of pss
Does anyone have a link for jsplitter? I can't seem to find it in the forums. Thanks.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2022-08-30 14:57:40
You might want google translate...

https://foobar2000.ru/forum/viewtopic.php?t=6378
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: loz on 2022-08-30 15:27:43
You might want google translate...

https://foobar2000.ru/forum/viewtopic.php?t=6378
Thanks. And thanks for all your past help. It is appreciated.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Majestyk on 2022-08-31 10:12:34
The new V2.0 Beta has broken the ratings on JS Playlist. The stars can't be selected anymore. JS Smooth still works.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Majestyk on 2022-08-31 11:56:41
"JS Smooth still works". Actually, it does not. It functions (unlike JS Playlist) but it doesn't save any info.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2022-08-31 12:49:56
Scripts with no concept of fb2k v2 will now always write tags when rating stars are clicked.

This is because previous checks for the existence of foo_playcount will always return false. These scripts should be updated or binned.

And trying to display %rating% no longer works because this field is taken over by playback statistics. Scripts need to be updated to use %rating% for playback statistics and $meta(rating) for file tags. And then functionality needs to be built in to scripts to decide what happens they are clicked.

All this might be confusing for people who aren't familiar with how foo_playcount used to work in the past as it has always taken over the %rating% field. But now it's no longer optional and everyone is affected by it.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: eajoo on 2022-09-07 10:33:54
I installed v1.6.2-dev+997ad85f. The "background image not updating" issue is still seen. https://bytemeta.vip/repo/TheQwertiest/foo_spider_monkey_panel/issues/160 (https://bytemeta.vip/repo/TheQwertiest/foo_spider_monkey_panel/issues/160)

I thought that the issue was fixed in dev build. Did I get a wrong version?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: always.beta on 2022-09-13 10:46:26
Using SMP built-in JSSPM, in the 1.6 series I can directly drag music into the playlist, but update to version 2.0 can not drag, please anyone know what the reason is?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: VlaKor on 2022-09-13 15:41:23
Please tell me, is a version for foobar2000 version 2.0  64 bit planned?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Majestyk on 2022-09-15 06:27:40
Using SMP built-in JSSPM, in the 1.6 series I can directly drag music into the playlist, but update to version 2.0 can not drag, please anyone know what the reason is?

I don't use JSSPM but I just installed it into Darkone to test it. It works for me with Beta 7 32 Bit.

Make sure you have a line like this in your SMP Configuration...
Code: [Select]
window.DefinePanel("JS Smooth Playlist Manager", { features : { drag_n_drop : true }});
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: always.beta on 2022-09-15 07:16:15
Make sure you have a line like this in your SMP Configuration...
Code: [Select]
window.DefinePanel("JS Smooth Playlist Manager", { features : { drag_n_drop : true }});
There is such code that exists, the same in the 1.6 series can be dragged
Code: [Select]
window.DefinePanel("JS Smooth Playlist Manager", { author : "Br3tt aka Falstaff", features : { drag_n_drop : true }});
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2022-09-15 07:54:13
I'd be amazed if v2 broke anything. It certainly hasn't affected my component/scripts.

I hope you're not running fb2k as admin and trying to drag from Explorer? That breaks all drag/drop.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2022-09-15 08:18:47
SMP 1.6.1 / fb2k v2 b7

(https://i.imgur.com/MxqMBeU.gif)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Majestyk on 2022-09-15 08:27:39
Yeah, that's weird. It's almost like it updated with Admin rights. I can't think of anything else it could be. At first I thought maybe it could work with the older Foobar without the Drag'n'Drop Callbacks code in jsspm.js but I removed it and (no surprise) it doesn't work.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: always.beta on 2022-09-15 12:23:33
@Fizbin @marc2k3,I'm sorry. It's that I didn't test enough. smp v1.6.1 drag-and-drop behavior is good, the problem is v1.6.2 dev.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Majestyk on 2022-09-16 02:55:52
I can confirm that drag and drop does not work with v1.6.2 dev.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: DJ FRANK G. on 2022-09-18 10:56:46
Hi, I use spider monkey panel with library tree from WilB...,
in the top panel you see the albums and samplers with songs from elton john based on the filter:

artist IS $nowplaying{$meta(artist,0)}

is there a chance to display also the albums of the second or third etc. artist. In the example I want see albums from kiki dee?

Thanks Frank



Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Green_Buddha on 2022-09-23 08:55:07
Hi! Got Top Panel crashes on launch. Use SMP with CaTRoX_QWR v.5 on FB2K 2 beta9

Quote
"Error: Spider Monkey Panel v1.6.1 (Top Panel: CaTRoX: Top bar v5.0.0 by TheQwertiest)
IsMainMenuCommandChecked failed:
Unknown menu command: View/Visualizations/Video

File: main.js
Line: 438, Column: 41
Stack trace:
  TopPanel@main.js:438:41
  @main.js:31:17"


UPD.
Solved

It turns out that this problem is solved simply and very banal. This error is related to the foo_youtube plugin, or rather to its settings. In case someone also encounters the same error on this build - after installing the foo_youtube plugin in the settings, set the default English language
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: michaengfrv on 2022-09-23 10:43:34
foobar2000 V2.0 beta, Playback Statistics functionality is now built-in.
The foo_playcount mode is disabled in the sample Rating script in Spider Monkey Panel.
How to fix it?

foobar2000 32bit V2.0 beta 9
Spider monkey panel v1.6.1
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2022-09-23 13:16:14
Browse inside the component folder \ samples \ complete \ js

and open rating.js in notepad.

Edit the highlighted line...

https://github.com/TheQwertiest/smp_2003/blob/abe16d3095544982ae3bc12ae99e1e041e63d7b2/js/rating.js#L145

to become

Code: [Select]
this.foo_playcount = true;
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: michaengfrv on 2022-09-23 13:34:30
Thanks for your answer!
Now it works well!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: paregistrase on 2022-09-23 13:39:42
I found a font that display Asian and Western characters to use inside  wine (WenQuanYi Micro Hei) .
but I didn¡t find a way to make the samples that SMP include to use it.

To make
(https://i.imgur.com/Uqm7ZJ4.png)
and
(https://i.imgur.com/T2jT1PW.png)
looks like
(https://i.imgur.com/tTehRax.png)

Also would be cool changing the tags splitter in the bio panel (the ugly squares)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2022-09-24 01:55:06
You should create a .fonts folder inside your $HOME folder. Stick .ttf fonts in there. And the included samples inherit from DUI/CUI preferences so you'd have to set the font there. If you don't want that then you'd have to edit the script here...

https://github.com/TheQwertiest/smp_2003/blob/abe16d3095544982ae3bc12ae99e1e041e63d7b2/js/panel.js#L32L39

You could remove the entire highlighted section and just have

Code: [Select]
const name = "Blah"; //replace with whatever, don't include .ttf

---

Pretty sure the bio script wants FontAwesome (as do most included samples)

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: paregistrase on 2022-09-24 09:53:49
Perfect. That do the trick.
The font was already in place and recognize and used in other instances of foobar. The problem was that I didn't know how to change the sampler's font.
(https://i.imgur.com/iSbI7ty.png)
(https://i.imgur.com/KvgpWi7.png)
With the Bio and Library Tree I changed them in the properties option. It has separates entries for general, headers, etc. I changed the Segoe UI parts and leave the FontAwesome ones as is. The only problem I found is the separator between genre tags in the headers. Display well with SegoeUI but with others fonts show squares. Sometimes the "-" part and with other fonts a space between the tag and the "-". Could be unicode characters?. Maybe I might ask  Wil-B about his topic.

Anyway this a minor glitch, the important part is that now my foobar can show asian characters in all instances instead of ugly squares.
(https://i.imgur.com/eli2Kh2.png)
Thank you


Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: paregistrase on 2022-09-24 11:59:44
The solution was easy...find another font.

Arial Unicode MS display asian characters and the correct ones in bio panel.

(https://i.imgur.com/3Kn28o3.png)

Rating stars

(https://i.imgur.com/bLuSo3Y.png)

and rare characters

(https://i.imgur.com/cRxAFH1.png)
(https://i.imgur.com/CoU8hvK.png)

Not the best looking font, but fully functional.

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2022-09-24 13:16:56
Great to see other people also listening to Jambinai (https://www.youtube.com/watch?v=wje_Uij4aBA)  8)

-TT
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: paregistrase on 2022-09-24 13:52:41
Great to see other people also listening to Jambinai (https://www.youtube.com/watch?v=wje_Uij4aBA)  8)

-TT

The Korean instruments they use (zither, flute and a guitar) sound great, Plus my Post-Rock obsession  :))
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Ottodix on 2022-09-25 11:38:30
Hi,

I need a little help for a script which try to open a jpg file from foobar.

Here is the script below. First it creates a jpg file of the cover of the playing song (so you need to play a song with an existing cover before executing my example). Then it try to open it using a WScript.shell. It's supposed to run the default program for displaying jpg. It works on my computer, using windows 10, but it doesn't always work on windows 11.

If someone know a more robust approach in order to do the same thing, I would appreciate. Thanks!

Code: [Select]
var img = utils.GetAlbumArtV2(fb.GetNowPlaying(), 0, false);
var filepath = fb.ProfilePath+"\\original_size.jpg";
img.SaveAs(filepath, "image/jpeg");
var WshShell = new ActiveXObject("WScript.Shell");
WshShell.Run("\"" + filepath + "\"", 0);
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2022-09-25 11:53:45
It's entirely up to each user to set a default app for opening jpg (or any other) files. On clean installs, the user is usually prompted the first time they try and open a file from Explorer. Once that is done, the script should succeed.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Ottodix on 2022-09-25 18:07:08
It's entirely up to each user to set a default app for opening jpg (or any other) files. On clean installs, the user is usually prompted the first time they try and open a file from Explorer. Once that is done, the script should succeed.
I don't think it's the right explanation. I just tried on windows 10 to unset the default app for .jpg, and the script then crashed, saying "unfound app"
One user reported that nothing happens on windows 11 on his side, no error message, just nothing
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2022-09-25 18:23:28
I'd wrap all WshShell.Run calls in try/catch just to be safe.

The album art sample bundled with SMP uses it. Double click the panel to test. It will silently fail if no application is associated with the image type.

As for the person with the problem, did they associate a .jpg file with Explorer? If it doesn't work, right click a jpg>Open with

(https://i.imgur.com/91jHBpK.png)

Make sure to check that box.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Ottodix on 2022-09-25 18:40:08
Yep, I just looked at this album art sample, and it uses the same kind of code that my script. I didn't use try/catch there for testing purpose.
I'll ask some more testing to this guy, thanks marc
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Ottodix on 2022-09-26 16:25:50
The issue was the intWindowStyle argument of the WshShell.Run method, it was set to 0, and removing it fixed it. Don't know exactly why it doesn't support an intWindowStyle set to 0, but whatever
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2022-09-26 17:09:32
Must admit, I totally missed that in your original post. It's expected as that hides the window. You use 0 when you want to run command line apps without a window popping up like my helper here...

https://github.com/TheQwertiest/smp_2003/blob/master/js/helpers.js#L495-L500
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2022-10-01 16:37:07
Well since the docs/wiki for framework was not done, seeing what marc did with it's component page, I created 2 for all my SMP scripts.

Scripts for final users (https://regorxxx.github.io/foobar2000-SMP.github.io/)
Frameworks: (https://regorxxx.github.io/foobar2000-Framework-SMP.github.io/)


And... there is a new script named ListenBrainz-SMP, wip, which can be tested by anyone who wants: (*)
https://regorxxx.github.io/foobar2000-SMP.github.io/scripts/listenbrainz-smp/
Essentially uses the ListenBrainz account to retrieve site-wide or user top tracks by a time range, allows to love/hate tracks and finally create playlists with the tracks recommended to the user by ListenBrainz . Requires an user token.

Note I also added full playlist syncing with ListenBrainz on the Playlist Manager script, with content resolution (similar to XSPF playlists), so almost every feature of ListenBrainz is now integrated in foobar2000 with both scripts. Listen syncing requires the foo_listenbrainz2 plugin (and I don't plan to substitute it).

Finally I plan to create another script to notify about new releases for rtists on library. This is trivial with MusicBrainz integration and requires no account. Similar to this, fully automated and configurable by release (album, live, single, ...) and allowing blacklisting / whitelisting.
https://www.musicbutler.io/#top
https://www.whathifi.com/news/spotifys-whats-new-feature-alerts-you-to-new-releases-from-your-favourite-artists

(*) In such case, first update all my other scripts from repository, not the releases. Then install the ListenBrainz script. Otherwise just test it in a new portable install.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Function on 2022-10-04 15:28:45
hi! i have a couple of questions:

- how do i run a command and read the stdout? i found the WScript.Exec command which surprisingly works, but it always briefly opens a console window when i run ffmpeg, which is annoying. there doesn't seem to be a flag for it like there is for WScript.Run. i'm using ffmpeg to calculate an audio-only hash of files.

- i asked in a new thread about the differences between SpiderMonkeyPanel and JScript 3 (https://hydrogenaud.io/index.php/topic,123084.new.html), the thread probably drowned and i should have asked in this thread in the first place.

thanks a lot! :)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2022-10-04 17:09:14
hi! i have a couple of questions:

- how do i run a command and read the stdout? i found the WScript.Exec command which surprisingly works, but it always briefly opens a console window when i run ffmpeg, which is annoying. there doesn't seem to be a flag for it like there is for WScript.Run. i'm using ffmpeg to calculate an audio-only hash of files.

- i asked in a new thread about the differences between SpiderMonkeyPanel and JScript 3 (https://hydrogenaud.io/index.php/topic,123084.new.html), the thread probably drowned and i should have asked in this thread in the first place.

thanks a lot! :)
You can send command output to a txt file and then read the file with SMP.

You can start an executable in a hidden window btw, but just ussing run command. Why do you want to use Exec?

But there is no further interaction between the command line and SMP.

Code: [Select]
const WshShell = new ActiveXObject('WScript.Shell');

function _runHidden() {
try {
WshShell.Run([...arguments].map((arg) => {return '"' + arg + '"';}).join(' '), 0, true);
return true;
} catch (e) {
return false;
}
}

//_runHidden(folders.xxx + 'helpers-external\\fpcalc\\fpcalc.bat', filePath, fpcalcJSON, folders.xxx + 'helpers-external\\fpcalc\\fpcalc.exe');

fpcalc.bat
Code: [Select]
@ECHO OFF
REM Helper to execute fpcalc.exe (%3) on input (%1) and save output to file (%2)
REM Retrieves raw fingerprint as json
%fpPath% -raw -json -length 240 %1>%2
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Function on 2022-10-04 17:18:59
You can send command output to a txt file and then read the file with SMP. You can start an exec in a hidden window btw.

But there is no further interaction between the command line and SMP.
I could do that but that would be a filesystem roundtrip that I'd really like to avoid. It shouldn't be necessary and it actually isn't, though as i said the problem with the following solution (TypeScript) is that it spawns a console window briefly.
Code: [Select]
// ./utils/shell.ts

interface Stream {
ReadAll(): string;
}

interface ExecObject {
Status: 0 | 1 | 2;
ProcesID: any;
ExitCode: any;
StdOut: Stream;
StdErr: Stream;
}

interface Shell extends ActiveXObject {
Run(command: string, intWindowStyle: number, waitOnReturn: boolean): number;
Exec(command: string): ExecObject;
}

const shell = new ActiveXObject("WScript.Shell") as Shell;

export const exec = (command: string): Promise<string> => {
const execObj = shell.Exec(command);

return new Promise((res, rej) => {
const intervalID = setInterval(() => {
if (execObj.Status === 2) {
rej(execObj.StdErr.ReadAll());
clearInterval(intervalID);
}

if (execObj.Status === 1) {
res(execObj.StdOut.ReadAll());
clearInterval(intervalID);
}

// do nothing
}, 1);
});
};

// usage
import * as shell from "./utils/shell.ts"

shell
.exec(`ffmpeg -i "${metaDB.Path}" -vn -loglevel 0 -f md5 -`)
.then((stuff) => console.log(stuff));
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2022-10-04 17:27:26
If you insist on using Exec, try this (obviously window will be shown and there is no way around that):
Code: [Select]
"use strict";
const WshShell = new ActiveXObject('WScript.Shell');
const WshRunning = 0;
const WshFinished = 1;
const WshFailed = 2;
const command = "ping.exe 127.0.0.1"

const obj = WshShell.Exec(command);

const check = setInterval((obj) => {
    let output;
    switch (obj.Status) {
       case WshFinished: {output = obj.StdOut.ReadAll(); break;}
       case WshFailed: {output = obj.StdErr.ReadAll(); break;}
       default: {/*Nothing;*/}
    }
    if (output) {
        clearInterval(check);
        console.log(output);
    }
}, 100, obj);

EDIT: Ups, sorry, didn't saw your post @Function. Similar solution XD, but there you got it in plain JS.

No, there is no workaround to the console showing.

Unless you want to try with bat files or using START command to create another hidden window?
Maybe one of those third party execs out there able to span a process without a console window? Have no idea.

The run approach lets you do it, although I agree it's dirtier. A workaround probably requires a new SMP method, the same than marc implemented a method to run commands on CMD + callback.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Function on 2022-10-04 17:36:28
No, there is no workaround to the console showing. Unless you want to try with bat files or using START command to create another hidden window? Maybe one of those third party execs out there able to span a process without a console window? Have no idea. The run approach lets you do it.
That's unfortunate. Since the console window is annoying, i'll go with the Shell.Run() solution for now. Maybe TheQwertiest has a tipp or solution? 👀
Anyway, thanks for the reply Regor.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MojoBass on 2022-10-04 20:49:27
- how do i run a command and read the stdout? i found the WScript.Exec command which surprisingly works, but it always briefly opens a console window when i run ffmpeg, which is annoying. there doesn't seem to be a flag for it like there is for WScript.Run. i'm using ffmpeg to calculate an audio-only hash of files.
@Function: maybe this helps: Link (https://hydrogenaud.io/index.php/topic,45223.msg983946.html#msg983946)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Function on 2022-10-04 21:31:11
@Function: maybe this helps: Link (https://hydrogenaud.io/index.php/topic,45223.msg983946.html#msg983946)
Thanks but i think that's exactly the opposite of what i'd like to happen 😅
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2022-10-04 22:35:36
https://stackoverflow.com/questions/32297699/hide-command-prompt-window-when-using-exec
https://groups.google.com/g/microsoft.public.scripting.vbscript/c/VNPfLikhG60/m/q72slhuXwZQJ

Some solutions are offered here, and the should work within SMP context with obvious changes. As noted they involve either creating secondary hidden console windows or using third party binaries.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2022-10-12 21:19:02
- "Moving" tracks to a playlist item at the panel.
Quote
(Spider Monkey Panel specific) All mouse callbacks are suppressed during drag operation (including on_mouse_lbtn_up, but excluding on_mouse_mbtn_up and on_mouse_rbtn_up).
But according to the documentation, I can not track the mouse movement within the panel (?) to check the index the mouse is over. So judging the dragndrop sample  I should use on_drag_enter() , etc. with the same functions I already have at on_mouse_move(x, y) to check the index I'm over, and then link that index to the handles I drop. Right?
Yes, on_mouse_move is replaced with on_drag_over.
Well I looked at it again and maybe I miss something but that part can not be done too. The drag n drop sample just redirects the action to another playlist by Id.
I can drop tracks to a playlist already loaded since I can assign its Id to the action (b), but I can not simply get the handle list of the drag n drop action without sending it to a playlist (a).

a) My workflow is: drop -> handle list -> get paths of tracks -> save paths into .m3u8 file
b) For a playlist already loaded:   drop -> playlist -> autosave paths to linked  .m3u8 playlist file

Answering to myself some time later... it's possible to get the handle list without sending it to any playlist, as long as the tracks are dragged from foobar2000 and are selected on the active playlist. It will cancel the drop action after doing something with the selected tracks and cancel it when the files are from outside (obviously it can be improved using 'on enter', instead of only 'on move', etc.)

Code: [Select]
// Drag n drop to copy/move tracks to playlists (only files from foobar)
addEventListener('on_drag_over', (action, x, y, mask) => {
// Avoid things outside foobar
if (action.Effect === dropEffect.none || (action.Effect & dropEffect.link) === dropEffect.link) {action.Effect = dropEffect.none; return;}
// Set effects
if (mask === dropMask.ctrl) {action.Effect = dropEffect.copy;} // Mask is mouse + key
else {action.Effect = dropEffect.move;}
on_mouse_move(x, y, mask);
});

addEventListener('on_drag_drop', (action, x, y, mask) => {
// Avoid things outside foobar
if (action.Effect === dropEffect.none || (action.Effect & dropEffect.link) === dropEffect.link) {action.Effect = dropEffect.none; return;}
if (plman.ActivePlaylist !== -1) {
const selItems = plman.GetPlaylistSelectedItems(plman.ActivePlaylist);
const bSucess = doSomething(selItems);
if (bSucess) {
// Remove track on move
if (mask !== MK_CONTROL) {plman.RemovePlaylistSelection(plman.ActivePlaylist);}
}
}
action.Effect = dropEffect.none; // Forces not sending things to a playlist
});
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Cardiacs on 2022-10-14 17:20:07
You can implement GIF support into Spider Monkey Panel ( WebP )?

Best Regards

Cardiacs

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2022-10-15 09:03:53
https://theqwertiest.github.io/foo_spider_monkey_panel/docs/faq/#why-i-cant-load-wepb-images
Are the docs wrong about webp (?)
Also gif is already supported (?)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2022-10-15 23:14:02
@regor,

the docs are missing to state that only still ( one image ) images work, but not if content is animated ( more than one image ).
I don't know how people are using WebP, but I always thought that it's the best replacement for the ugly GIF format that should not exist since the 90's imo...
Using it since 3 years and I'm happy with it, more than 4x smaller than GIF and with good colors ( more than the lousy 256 colors in GIF ).

You can try download my WebP (https://github.com/TT-ReBORN/Georgia-ReBORN-images/raw/master/02_Georgia_Reborn_Theme_Styles_Animation.webp) ( animated ) and load it in SMP,
I get an img = null error if you try it with marc's apply mask basic sample, that means it can't be read and loaded at all...

-TT 
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2022-10-16 12:52:06
I have no issues with SMP loading that image. It works via gdi.Image or via the album art methods.

(https://i.imgur.com/gSye6ya.png)

Animation is another thing entirely and you're unlikely to see it in any fb2k component.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2022-10-16 16:49:23
Well for me only still image ( content with one image only ) WebP works, for animated ( content with more images ) WebP I get null:

(https://i.ibb.co/GQ9nDGC/SMP-WEBP-TEST.jpg)

How do you do it with the animated that at least only the first image shows?

Also can't get it to work with:

gdi.LoadImageAsync
gdi.LoadImageAsyncV2
gdi.GetAlbumArtAsyncV
gdi.GetAlbumArtAsyncV2

Only the still image WebP works...

-TT
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2022-10-16 17:12:41
Btw, I'm using the WebP codec from Google:
https://developers.google.com/speed/webp/download

-TT
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2022-10-16 17:46:45
Using SMP 1.6.1, webp codec included with windows 10.

I've tested gdi.Image and the screenshot I posted with the tooltip showing the image path/size is the included album art sample which uses utils.GetAlbumArtAsyncV2.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2022-10-20 12:52:21
Just in case someone is interested, put on github a profiler framework with some standard samples (mostly from other standard JS profiler libraries). I know it can be done on a few lines of code, but this helps creating standard tests and getting table formatted results.
https://regorxxx.github.io/foobar2000-Framework-SMP.github.io/scripts/profiler-smp/

It should be pretty easy for any developer to create their own profiles, and maybe it helps to test execution time on different systems (looking at you foobar 2.0 XD) to further fine-tune or standardize specific routines according to OS or fb version.

WIP, will be adding more specific foobar/SMP tests soon.
Spoiler (click to show/hide)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2022-11-09 14:24:41
A small status update:
This year was (and still is)... not fun to say the least, thanks to certain February events. Regretfully, almost nothing went according to my plans, so I'm still unable to spend any time on my pet projects.
I don't have any ETA on my return, but I'm 99.9% sure that it won't be this year.

PS: @marc2k3 huge thank you for providing support, even though it's not your component.
PPS: But oh boy, things I have planned for this component =)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Black_Over_Bills_Mothers on 2022-11-09 15:22:21
@TheQwertiest
Good to know you  intend to return as I don't really want to switch back to the JScriptPanel. However, I must admit I'm also impressed how marc2k3 has help out. Thank you.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2022-11-09 15:37:20
Yuri we need you <3
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: redorb on 2022-11-11 06:45:09
TheQwertiest ❤️
Thanks for Spider Monkey Panel
Things will get better, I'm sure it will!
Wish you all the best.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: ifrankyman on 2022-11-17 11:47:49
I can't get old script from "kgena_ua" working on Spider Monkey Panel. It works perfectly with JScript Panel. Can someone help me please.
Code: [Select]
// ==PREPROCESSOR==
// @name "check playlist type (if youtube)"
// @feature "v1.4"
// @feature "watch-metadb"
// ==/PREPROCESSOR==

var set_path = fb.foobarPath + "\\Themes\\DarkOne\\Others\\Settings\\"
var fso = new ActiveXObject("Scripting.FileSystemObject");

try {
    fso.deleteFile( set_path + "y_pllist_type_*");
} catch(e) {};
fso.CreateTextFile( set_path + "y_pllist_type_" );

var pllist_type, prev_pllist_type;
var path, metadb;

on_item_focus_change();

function on_item_focus_change() {
   metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
    if (metadb) on_metadb_changed();
}

function on_playlist_switch() {
    on_item_focus_change();
}

function on_playback_new_track() {
    on_item_focus_change();
}

function on_selection_changed(metadb) {
    on_item_focus_change();
}

function on_playback_stop() {
    on_item_focus_change();
}

function on_metadb_changed() {
    if (metadb){
        check_pllist()
    }
}

function check_pllist(){
    count = plman.PlaylistItemCount(plman.ActivePlaylist);
    if (count > 0) {
        path = fb.Titleformat("%path%").EvalWithMetadb(metadb);

        if (path.indexOf("youtube") >= 0 || path.indexOf("video") >= 0 || path.indexOf("dailymotion") >= 0 || path.indexOf("vimeo") >= 0){
            pllist_type = "youtube";
        } else {
            pllist_type = "not_youtube";
        }
      
        if (prev_pllist_type != pllist_type) {
            try {
                fso.deleteFile( set_path + "y_pllist_type_" + "*" );
            } catch(e) {};
            fso.CreateTextFile( set_path + "y_pllist_type_" + pllist_type);
            RefreshPSS();
            prev_pllist_type = pllist_type;
        }
    }
}

function RefreshPSS() {
    if (fb.IsPlaying || fb.IsPaused) {  
        fb.RunMainMenuCommand("Воспроизведение/Воспроизвести или приостановить");
        fb.RunMainMenuCommand("Воспроизведение/Воспроизвести или приостановить");
    } else {
        fb.RunMainMenuCommand("Воспроизведение/Воспроизвести");
        fb.RunMainMenuCommand("Воспроизведение/Остановить");
    }
}

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kgena_ua on 2022-11-19 19:23:11
Can someone help me please.
@ifrankyman, try
Code: [Select]
var fso = new ActiveXObject("Scripting.FileSystemObject");
var path_set = fb.ProfilePath + "Themes\\DarkOne\\Others\\Settings\\"
var pllist_type = prev_pllist_type = "";
var metadb;

on_item_focus_change();

function on_playlist_switch() {
    on_item_focus_change();
}

function on_playback_new_track() {
    on_item_focus_change();
}

function on_selection_changed(metadb) {
    on_item_focus_change();
}

function on_playback_stop() {
    on_item_focus_change();
}

function on_item_focus_change() {
    metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
    if (metadb) on_metadb_changed();
}

function on_metadb_changed() {
    count = plman.PlaylistItemCount(plman.ActivePlaylist);
    if (count > 0) {
        var tfo = fb.TitleFormat("[%path%]");
        var path = tfo.EvalWithMetadb(metadb);

        pllist_type = (path.indexOf("youtube") >= 0 || path.indexOf("video") >= 0 || path.indexOf("dailymotion") >= 0 || path.indexOf("vimeo") >= 0) ? "youtube" : "not_youtube";
       
        if (prev_pllist_type != pllist_type) {
            try {
                fso.DeleteFile(path_set + "y_pllist_type_*");
            } catch(e) {};
            utils.WriteTextFile(path_set + "y_pllist_type_" + pllist_type, "");
           
            RefreshPSS();
            prev_pllist_type = pllist_type;
        }
    }
}

function RefreshPSS() {
if (fb.IsPlaying || fb.IsPaused) {
fb.PlayOrPause();
fb.PlayOrPause();
} else {
fb.Play();
fb.Stop();
}
}

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: ifrankyman on 2022-11-20 16:06:19
@ifrankyman, try
[/quote]
Now it works. thanks a lot, kgena_ua!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: ifrankyman on 2022-11-20 16:10:01
Now it works. thanks a lot, kgena_ua!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Mrakobes on 2022-12-31 07:30:13
Help set up the code to read the cover folder, the condition is that the Cover folder is located in the Album folder, which has different names, for example

Amorphis
___|Queen of Time (Japanese Edition)
______|Covers
__________|CD1
__________|CD2

or

Amorphis
___|Queen of Time
______|Covers
__________|CD1
__________|CD2

or

Amorphis
___|Queen of Time
______|Covers

etc

With a folder of images of the Artist I got like this:

$left(%path%,$strstr(%path%,\%artist%))%artist%\Images

Maybe it makes sense to play with ,$strstr or $strrchr?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Mrakobes on 2023-01-03 09:48:26
bag - text overlays

(https://i121.fastpic.org/thumb/2023/0103/6b/9459236e331abf2e7e49cecfd2dd306b.jpeg) (https://i121.fastpic.org/big/2023/0103/6b/9459236e331abf2e7e49cecfd2dd306b.png)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Mrakobes on 2023-01-03 11:17:35
I set up my own tags in the properties panel, I enter them, they are displayed in third-party programs, but not on the panel. How do I display all existing tags?

and how to reverse the display order?

(https://i121.fastpic.org/thumb/2023/0103/fc/63d6d91e4966c2bbc4a33dd1bbe43cfc.jpeg) (https://i121.fastpic.org/big/2023/0103/fc/63d6d91e4966c2bbc4a33dd1bbe43cfc.png)
(https://i121.fastpic.org/thumb/2023/0103/c0/4694906a451110762e457476a9d2f9c0.jpeg) (https://i121.fastpic.org/big/2023/0103/c0/4694906a451110762e457476a9d2f9c0.png)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: IP974 on 2023-01-07 10:55:59
Hello,
I'm looking for a vinyl cover style script under SMP.
Thanks in advance
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: nikolai4ik on 2023-01-24 19:30:39
I'm trying to modify sample script with the context menu button - I made the context menu appear on hover, but is there a way to hide it when I stop hovering over the button?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2023-01-24 20:03:35
I'm trying to modify sample script with the context menu button - I made the context menu appear on hover, but is there a way to hide it when I stop hovering over the button?
You will notice even the native foobar buttons/menus don't work while there is a menu open. The entire UI waits tracking the menu. There is no way to change it, unless the actual SMP code is changed.

Only the main menus work different (hovering as you said), but they hide when you hover over other main menu. If you move the mouse over other buttons or UI elements the menu remains there.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: nikolai4ik on 2023-01-24 21:09:34
I'm trying to modify sample script with the context menu button - I made the context menu appear on hover, but is there a way to hide it when I stop hovering over the button?
You will notice even the native foobar buttons/menus don't work while there is a menu open. The entire UI waits tracking the menu. There is no way to change it, unless the actual SMP code is changed.

Only the main menus work different (hovering as you said), but they hide when you hover over other main menu. If you move the mouse over other buttons or UI elements the menu remains there.
Ah, that's unfortunate, thank you very much for your reply.

Anyway, I've been studying javascript and now after 15 years of dreaming to modify foobar2000 myself I've started meddling with sample scripts. So I hope someone will be able to assist me in my newbie issues.

1 - I'm trying to create a general track info panel by combining several samples, for example TrackInfo Follows Cursor and Rating.
In rating component there's ability to switch between follow playback and follow cursor.

in the included file panel.js there's a function

Code: [Select]
function _panel(custom_background = false) {
this.item_focus_change = () => {
if (this.metadb_func) {
if (this.selection.value == 0) {
this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
} else {
this.metadb = fb.GetFocusItem();
}
on_metadb_changed();
if (!this.metadb) {
_tt('');
}
}
}

I don't see where and how the result is stored in the rating sample script so I am having issues assigning handle to a customizable option (from general track info - let handle = fb.GetFocusItem();)

2 - in sample custom context menu how can I modified stuff so that there's a specific area where I want to click (hover, actually, but oh well) which acts as a button.

Code: [Select]
    gr.DrawImage(img, 340, 200, img.Width, img.Height, 0, 0, img.Width, img.Height);
function menu() {
    let _context = fb.CreateContextMenuManager();
    let _basemenu = window.CreatePopupMenu();
    let _child = window.CreatePopupMenu();

    // start index at 1, NOT 0
    _basemenu.AppendMenuItem(MF_STRING, 1, "Open facets");
    _basemenu.AppendMenuItem(MF_STRING, 2, 'item2');
    if (fb.GetNowPlaying()) {
        _child.AppendTo(_basemenu, MF_STRING, 'Now Playing');
    }
   
    _context.InitNowPlaying();
    _context.BuildMenu(_child, 3);

    const idx = _basemenu.TrackPopupMenu(1, 4);
   
    switch (idx) {
        case 0: //user dismissed menu by clicking elsewhere.
            break;
        case 1:
            fb.RunMainMenuCommand("Library/Facets");
            break;
        case 2:
            fb.ShowPopupMessage('OK, item2 is clicked.');
            break;
        default:
            _context.ExecuteByID(idx - 3);
            break;
}}

function on_mouse_lbtn_up(x, y) {
    if (x > 350 && x < 370 && y > 200 && y < 240) {
        menu();
    }
    rating.lbtn_up(x, y);
}
How do I make the context menu open at specific coordinates? Right now it opens at 0,0.

3 - how can I add an onclick function to a simple text line?    like on this one gr.GdiDrawText("foobar2000", gdi.Font('Product Sans', 36, 1), RGB(245,245,245), 0, 0, window.Width, 30, DT_VCENTER | DT_CENTER | DT_END_ELLIPSIS | DT_CALCRECT | DT_NOPREFIX);
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2023-01-24 21:27:52
3 is not possible. You are expecting browser behavior here, adding event listeners to any object (like html items). SMP objects don't work like that.
You draw a string, but there is no string "object" to attach anything to. It's just a UI cosmetic thing.

You would need to calculate the position of the string, width, height, etc. and then associate a event listener to that spatial position. It's the same for any item you consider. There is no buit-in object-like instances of items. If at any point the spatial position changes, you have to re-adjust the event listener.

Developers usually code from scratch having this in mind, creating things which track their  own position to make their life easier. You may find such examples in more complex scripts: for ex. my world map script and how countries are associated to clickable points in a map. Or any of the playlists/album list managers. The item list is internally tracked, so somewhere X = 5 and y= 30 is associate to item 1, but there is no way to to retrieve a item by its position unless you code it by yourself.

For strings is a bit trickier as soon as you add flags like center or vcenter, since you have to calculate the position relative to the total width / height.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2023-01-24 21:30:22
2. check this:
https://github.com/regorxxx/Profiler-SMP

That UI is the more simple thing you can find in a real tool, and surely it will answer your doubts. 4 "buttons", 4 areas on UI to click. Look for 'on_mouse_lbtn_up' (for the click) and 'on_mouse_move' (for the tooltip).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2023-01-24 21:37:25
1. Did not create those samples and don't really want to take a deep look at them... but the selection mode is set according to "this.selection.value". When it's zero uses playback (and fallbacks to cursor if nothing plays), otherwise uses cursor.

This.selection refers to a variable within _panel function. I suppose at some point this.selection is saved at the properties of the panel (to maintain the config on different sessions).

This.handle does the same.

So if you want to access this.handle outside _panel.... just point to "panel.handle". I say "panel" but there should be an actual variable name at the main sample script. The SMP samples use helpers multiple times, so _panel is used in multiple scripts, and every one calls it on the main js file. The constructor is named _panel, and the instance will probably be panel. Check it.

Not sure if those are your doubts (?)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: nikolai4ik on 2023-01-27 10:13:59
Thanks regor! Those 3 issues are dealt with :)

Some more, maybe someone can point me to existing scripts or methods which can help me...

(https://i.ibb.co/3mCh212/image.png)

1 - is there a way to have words wrap?
2 - tooltips in jscript panel 3 follow my dark theme while SMP shows light tooltips - how to fix?
3 - same with SimpleThemedButton sample - the buttons are white and don't follow CUI dark settings, judging by the code they are supposed to.

(https://i.ibb.co/chFLGcP/image.png)
I started working on my custom menu - is it possible to add icons next to the text? or maybe replace the context menu completely and have another panel open... I can do it in browser JS and CSS but alas not in SMP  :))
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2023-01-27 20:17:01
1. Do you mean...? The quiet things that.... -> The quiet things \newline that sound....
Nope. Well you use this: https://theqwertiest.github.io/foo_spider_monkey_panel/assets/generated_files/docs/html/GdiGraphics.html#EstimateLineWrap
For a desired width, then you draw each string manually.

2. No fix. SMP is in need of updating since months XD (for multiple bugs, dark theme support, x64 support...). Not saying is not stable, just that there have been no updates in half a year, V2 has been released meanwhile, dark theme support and a few bugs found since then. There are also some long term bugs not resolved.

3. The buttons don't follow CUI settings, but system settings. But not necessarily in the way you expect. Buttons fill color is not the same than the theme color. In my scripts you can find and alternative buttons framework which allows to paint buttons without background matching the CUI colors on the toolbar (or the background of the panel). Or you can simply set the background color. You may be interested on that. I did it since WINE systems don't work properly with the theme-manager thing from the samples, but it applies now too to dark themes...

4. No. You can add a character which looks like an icon (a heart for ex). Look for ASCII codes. That's all. But you are limited to the font used by the menu.

SMP is not currently able to open new panels. You can open an HTML popup which probably does what you want.
https://theqwertiest.github.io/foo_spider_monkey_panel/assets/generated_files/docs/html/utils.html#.ShowHtmlDialog
And that requires standard CSS and JS coding.

You may also be able to open a new panel with this:
https://github.com/ttsping/foo_flowin
Calling within SMP the main menus which open the flowin panel, and you could put there another script which interacts with the first one. It's on my todo list to try for some fancy scripts, but not currently on the mood.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: nikolai4ik on 2023-01-28 12:44:32
1. Do you mean...? The quiet things that.... -> The quiet things \newline that sound....
Nope. Well you use this: https://theqwertiest.github.io/foo_spider_monkey_panel/assets/generated_files/docs/html/GdiGraphics.html#EstimateLineWrap
For a desired width, then you draw each string manually.

2. No fix. SMP is in need of updating since months XD (for multiple bugs, dark theme support, x64 support...). Not saying is not stable, just that there have been no updates in half a year, V2 has been released meanwhile, dark theme support and a few bugs found since then. There are also some long term bugs not resolved.

3. The buttons don't follow CUI settings, but system settings. But not necessarily in the way you expect. Buttons fill color is not the same than the theme color. In my scripts you can find and alternative buttons framework which allows to paint buttons without background matching the CUI colors on the toolbar (or the background of the panel). Or you can simply set the background color. You may be interested on that. I did it since WINE systems don't work properly with the theme-manager thing from the samples, but it applies now too to dark themes...

4. No. You can add a character which looks like an icon (a heart for ex). Look for ASCII codes. That's all. But you are limited to the font used by the menu.

SMP is not currently able to open new panels. You can open an HTML popup which probably does what you want.
https://theqwertiest.github.io/foo_spider_monkey_panel/assets/generated_files/docs/html/utils.html#.ShowHtmlDialog
And that requires standard CSS and JS coding.

You may also be able to open a new panel with this:
https://github.com/ttsping/foo_flowin
Calling within SMP the main menus which open the flowin panel, and you could put there another script which interacts with the first one. It's on my todo list to try for some fancy scripts, but not currently on the mood.
Thank you so much for all your advice! :)
1 - EstimateLineWrap wasn't very easy for me but I did it.

2 - that's what I was wondering about... I am moving away from WSH panels right now and I had to pick what to use. Went with SMP, but JSPanel seems to be maintained better nowadays?
3, 4 - got it, thanks.
5 - considering I won't be able to use SMP methods this HTML window will be useless, so I'll pass.

Instead of it I decided to add another panel and managed to do what I wanted for literally 5+ years - a toggleable stop after queue/stop after current song which displays its state, I'm so proud  :))

Now I want to combine JSPlaylist's mood button with sample last.fm love button (either left/right clicks or maybe just %SMP_loved% to current date), the script in the playlist uses %MOOD% field and puts current time in it. However getTimestamp() which is used in WSHPlaylist.js  (handles.UpdateFileInfoFromJSON(JSON.stringify({"MOOD" : getTimestamp()}));) throws error when I put it elsewhere. Kind of lost at the moment...

Also how do you write SMP commands for these context menu items?
Adding these buttons works easily in standard buttons panel, but just       fb.RunContextCommandWithMetadb("Last.fm/Last.fm Love Track", items); doesn't work with javascript.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2023-01-28 17:07:14
If you use JSPlaylist bundled with JScript Panel 3 and my foo_lastfm_playcount_sync component, you can easily love tracks from clicking the mood column.

https://marc2k3.github.io/component/lastfm-playcount-sync/

https://jscript-panel.github.io/gallery/jsplaylist/#loving-tracks-on-lastfm-with-foo_lastfm_playcount_sync
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2023-01-29 10:54:53
Quote
Went with SMP, but JSPanel seems to be maintained better nowadays?
Yep. I can't stand not being able to use standard ES6 javascript, so I prefer SMP.  This is also something to consider when you code things meant to be used outside foobar or integrated with standard JS libraries (which require ES6 and missing things in JSP).

But there are multiple examples right now where JSP has been fixed or has superior methods.

There is a catch, though, you need IE9 in JSP. That's a no for me and I care about wine compatibility.

Now I want to combine JSPlaylist's mood button with sample last.fm love button (either left/right clicks or maybe just %SMP_loved% to current date), the script in the playlist uses %MOOD% field and puts current time in it. However getTimestamp() which is used in WSHPlaylist.js  (handles.UpdateFileInfoFromJSON(JSON.stringify({"MOOD" : getTimestamp()}));) throws error when I put it elsewhere. Kind of lost at the moment...

Also how do you write SMP commands for these context menu items?
Adding these buttons works easily in standard buttons panel, but just       fb.RunContextCommandWithMetadb("Last.fm/Last.fm Love Track", items); doesn't work with javascript.
Don't really understand your problem. If getTimeStamp() is not a native JS function, just create one by yourself (?)
https://stackoverflow.com/questions/9756120/how-do-i-get-a-utc-timestamp-in-javascript

WSH and JSP don't share the same methods and functions than SMP. But just rely on native JS, instead of foobar specific functions whenever possible.

Did you read the docs?
https://theqwertiest.github.io/foo_spider_monkey_panel/assets/generated_files/docs/html/fb.html#.RunContextCommand
Quote
8 - flag_view_full. This can be useful if you need to run context commands the user may have hidden using File>Preferences>Display>Context Menu
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: nikolai4ik on 2023-01-29 13:59:17
Did you read the docs?
https://theqwertiest.github.io/foo_spider_monkey_panel/assets/generated_files/docs/html/fb.html#.RunContextCommand
Quote
8 - flag_view_full. This can be useful if you need to run context commands the user may have hidden using File>Preferences>Display>Context Menu
They aren't available at all in the main menu, only context menu. And in context menus the options are dynamically filled with artist and title, I guess that;s why it doesn't work with JS?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2023-01-29 18:01:09
I love the mental gymnastics on display here:

I can use title formatting to display text in a panel.
I cannot use title formatting to build a string to run a context menu command.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2023-01-29 22:36:12
Did you read the docs?
https://theqwertiest.github.io/foo_spider_monkey_panel/assets/generated_files/docs/html/fb.html#.RunContextCommand
Quote
8 - flag_view_full. This can be useful if you need to run context commands the user may have hidden using File>Preferences>Display>Context Menu
They aren't available at all in the main menu, only context menu. And in context menus the options are dynamically filled with artist and title, I guess that;s why it doesn't work with JS?
What he means, without passive-aggressive replies... is that you have to use the proper menu name to call the menu. And if the context menu changes according to track, then change your string. I did not understand your question since you already pointed to what your problem was...

Code: [Select]
"use strict";

const sel = fb.GetSelection();
const tf = fb.TitleFormat('%TITLE%|||$meta(artist,0)');
const [title, artist] = tf.EvalWithMetadb(sel).split('|||');
const menu = 'Last.fm Love track \'' + title + '\' By \'' + artist + '\'';
console.log(menu);
fb.RunContextCommandWithMetadb(menu, sel, 8);

Quote
Last.fm Love track 'Something just like this' By 'The Chainsmokers'
foo_softplaylists: feed downloading: error
foo_softplaylists: failed to love track: authentication failed: empty reply
foo_softplaylists: failed to love track 'Something just like this' by 'The Chainsmokers'

Works fine, there is no problems at all with JS calling dynamic menus.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: nikolai4ik on 2023-01-30 19:41:38
Thanks, I've tried something like 'Last.fm Love track \'' + %title% + '\' By \'' + %artist% + '\''; which looking back, is not correct lol
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2023-02-03 18:28:16
This issue: https://github.com/TheQwertiest/foo_spider_monkey_panel/issues/192

Made me think some common SMP bugs usually appear because every developer is using their own set of helpers and there is not a single place of "knowledge". What about unifying all those helpers into a central repository (classified by usage: file | tags | playlists | etc.)?

Like sometimes I have found a rare bug on my own helpers, and sometime later I see the same coding error on someone's else code, but not going to write every script developer about it. This would be easily managed if there was a central repository of common scripts (and the helpers provided by SMP on install does not suffice).

Is anyone interested? Do we really need like 5 different versions of the isFile helper? XD
I already applied this philosophy on the frameworks though (https://regorxxx.github.io/foobar2000-Framework-SMP.github.io/). But this would be a community effort.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2023-02-03 20:52:45
I really like this idea and it would help and make life easier for other users too!
Would be cool if @TheQwertiest would make an extra section on SMP (https://theqwertiest.github.io/foo_spider_monkey_panel/) and showcase them all.
Also put them in a new .js file in the SMP docs.

-TT
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2023-02-07 07:09:38
Is anyone interested? Do we really need like 5 different versions of the isFile helper? XD
I already applied this philosophy on the frameworks though (https://regorxxx.github.io/foobar2000-Framework-SMP.github.io/). But this would be a community effort.
Isn't this the problem with JS at-large versus other languages? There's no std library and everybody roles their own thing to handle their own specific use case so there are 31 different flavors of anything you could want. :D

It's not a bad idea, but a lot of us have written our own things in the past and migrating it is almost never worth the hassle when we know how the code works and it's been well tested for years. That's why this kind of generic stuff is unlikely to catch on (unlike components, etc.)

That said, what would be useful to tons of people is a standard UI library for doing stuff in SMP. I got pretty far along with my Material Design one, but then got distracted when I needed to take the next leap to make it easily usable/composable by anyone (still awesome for whipping up quick demos though!). Also since TT's Georgia-Reborn has far surpassed the original in popularity, I don't have a ton of motivation to work on general stuff that it seems only I'd ever take advantage of. This is not a good attitude but I'm busy/lazy.  8)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2023-02-07 09:49:20
It's not a bad idea, but a lot of us have written our own things in the past and migrating it is almost never worth the hassle when we know how the code works and it's been well tested for years. That's why this kind of generic stuff is unlikely to catch on (unlike components, etc.)
As long as people currently coding get involved, it should be pretty easy to migrate. 'The well tested for years', well SMP has been getting more and more updates and helpers from some years are deprecated, have problems in Wine,  don't work on specific OS versions as expected, etc.

Everybody is using either _isFile, or isFile, etc. JS lets you wrap the same function with 5 different names. If we can agree that _isFile should not crash on external and virtual disk sand do X simple task, it would work for everybody.

Obviously other helpers could not be easily replaced without a consensus, but at least this is something. The simple ones are the ones giving problems...

Developers may not care about updating or using them... but at least some of us may simple point them to the files when a bug is found.

In any case agree with your comments.

About the standard libraries... well, I shared a menu framework, a statistics framework (https://regorxxx.github.io/foobar2000-Framework-SMP.github.io/scripts/statistics-framework-smp/) with support for multiple graphs, a map framework (which may be used for a world map, but also for a tags map, or whatever), etc. it's just that no one but me is using them XD

I have seen other user creating graphs in JSP, and he started from scratch... so... Already recommended theQwertiest to clearly point on the docs to such libraries, but without that support, any user starting with SMP has no way to look for them.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2023-02-07 11:43:15
Side-note regarding isFile and etc: in v2 of SMP I will most likely replace all fs related methods with a module similar to `fs` module in NodeJS (albeit simplified)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2023-02-07 11:51:08
Side-note regarding isFile and etc: in v2 of SMP I will most likely replace all fs related methods with a module similar to `fs` module in NodeJS (albeit simplified)
Hey great to see u again, sorry for filling github with so many reports ;)

Any improvement on file-management will be appreciated.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2023-02-07 14:48:19
That said, what would be useful to tons of people is a standard UI library for doing stuff in SMP. I got pretty far along with my Material Design one, but then got distracted when I needed to take the next leap to make it easily usable/composable by anyone (still awesome for whipping up quick demos though!). Also since TT's Georgia-Reborn has far surpassed the original in popularity, I don't have a ton of motivation to work on general stuff that it seems only I'd ever take advantage of. This is not a good attitude but I'm busy/lazy.  8)

Mate, I'm feeling a little bit bad to have "stolen" your motivation and I have kinda knew about it for a long time, actually since not updating your theme :(
But keep in mind, Georgia-ReBORN would have been not possible without your original Georgia theme, so I myself and many other users are grateful.
Btw, I have put your Material Design into good use and made some custom menus ( metadata grid, custom theme ). Since Beta 11, users can create their own themes  8)
So thanks for that!

-TT

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2023-02-07 15:19:24
@MordredKLB,

P.S: I would love if you would work with me and also see Georgia-ReBORN as half as your own.
You know I've invited you on Github and I really don't care about ego, credit, fame, recognition and all this stuff.
I just want to create and use great things and share that experience with other users.
In my opinion that's what open source is all about.

-TT
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2023-02-07 19:17:12
Mate, I'm feeling a little bit bad to have "stolen" your motivation and I have kinda knew about it for a long time, actually since not updating your theme :(
But keep in mind, Georgia-ReBORN would have been not possible without your original Georgia theme, so I myself and many other users are grateful.
Btw, I have put your Material Design into good use and made some custom menus ( metadata grid, custom theme ). Since Beta 11, users can create their own themes  8)
So thanks for that!
Haha, don't feel bad! It's just that Georgia fits all of my needs currently (with one big exception of automatic discart downloading that I have to implement at some point) and so adding features for what seems to be mostly non-existent users just feels like making extra work for myself. I think it's awesome what you've done. Also I can't believe you were able to make anything usable out of the Material design ux stuff I shared here so long ago. It was a neat demo, but I didn't think it was far enough along to be easily usable by anyone but me. I'll have to check out the latest beta when I find more of that time I never seem to have enough of.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2023-02-07 23:06:35
Yea, we need a component ( foo_fanart ) that auto downloads disc art, band logo, label logo and missing album art from fanart.tv
Unfortunately this is beyond my scope as I have no idea how to write a user-component in C++.
I have took a look at the API from fanart.tv and it should be straight forward.
We just need to have options for custom download directories for disc art, band and label logos and album art...

Maybe if we friendly ask @marc2k3 ? He is lately on fire with user-components ;-)

-TT
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: mjm716 on 2023-02-11 15:58:22
general tip for anyone else who may be experiencing panel crashes or SMP performance issues.

via @Regor (big thanks!)
in FB prefs>advanced>search "heap"
(under spider monkey panel) set Maximum Heap Size number by entering 999999999999 (it will auto populate with your max)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2023-02-11 17:10:38
general tip for anyone else who may be experiencing panel crashes or SMP performance issues.

via @Regor (big thanks!)
in FB prefs>advanced>search "heap"
(under spider monkey panel) set Maximum Heap Size number by entering 999999999999 (it will auto populate with your max)
No, this is one of the worst advices I've seen and nobody should *ever* follow it if they want their SMP (and fb2k by extension) to remain stable.

What this "general tip" does, is it effectively removes all limits on RAM usage by SMP. Problem being that the same RAM is used by fb2k and other components as well. So, what will happen, is that after some time fb2k process will run out of memory, because SMP will use up every last bit of it, and fb2k will crash randomly during memory allocation (which can happen in fb2k itself, in other components or in SMP itself). And by crash I mean literal crash to desktop, not a script crash in SMP.

TLDR: do *not* ever do this. It will break your fb2k with almost 100% certainty.

PS: this "tip" makes scripts work "better" , because it almost totally disables garbage collection (i.e. cleanup of the stuff that uses RAM), it's akin to removing breaks from the car that runs downhill to make it go faster...
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2023-02-11 19:03:52
general tip for anyone else who may be experiencing panel crashes or SMP performance issues.

via @Regor (big thanks!)
in FB prefs>advanced>search "heap"
(under spider monkey panel) set Maximum Heap Size number by entering 999999999999 (it will auto populate with your max)
No, this is one of the worst advices I've seen and nobody should *ever* follow it if they want their SMP (and fb2k by extension) to remain stable.

What this "general tip" does, is it effectively removes all limits on RAM usage by SMP. Problem being that the same RAM is used by fb2k and other components as well. So, what will happen, is that after some time fb2k process will run out of memory, because SMP will use up every last bit of it, and fb2k will crash randomly during memory allocation (which can happen in fb2k itself, in other components or in SMP itself). And by crash I mean literal crash to desktop, not a script crash in SMP.

TLDR: do *not* ever do this. It will break your fb2k with almost 100% certainty.

PS: this "tip" makes scripts work better, because it almost totally disables garbage collection (i.e. cleanup of the stuff that uses RAM), it's akin to removing breaks from the car that runs downhill to make it go faster...
+1

If I ask you to test something for testing on PMs, don't suppose that's a tip for everybody or a recommended setting for everyday usage  ::)

Anyway, in this particular case, the user was having ram allocation failures on handle list creation due to SMP, with the ram limit imposed.

Quote
Error: Spider Monkey Panel v1.6.1 ({B48F5B98-0687-4D8A-84E5-B5E3271D364B})
FbMetadbHandleList_Constructor failed:
allocation size overflow

Fb.getLibraryItems would fail at 340K tracks, also when retrieving tags.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: mjm716 on 2023-02-12 00:49:49
What this "general tip" does, is it effectively removes all limits on RAM usage by SMP. Problem being that the same RAM is used by fb2k and other components as well. So, what will happen, is that after some time fb2k process will run out of memory, because SMP will use up every last bit of it, and fb2k will crash randomly during memory allocation (which can happen in fb2k itself, in other components or in SMP itself). And by crash I mean literal crash to desktop, not a script crash in SMP.

I appreciate the add'l info - I was already experiencing FB memory crashes regularly via SMP. My comment was intended as a debugging tip, not perm setting.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2023-02-13 17:03:36
FB memory crashes regularly via SMP

You are conflating two different issues:
- SMP script crash: popup "your script uses too much memory X/Y" with SMP panel turning red. The player itself continues working normally and panel can be restarted.
- fb2k crash: whole player crashes. I.e. you can't continue using player and have to actually restart the application.

That "tip" turns the first scenario (SMP crash) into the second scenario (fb2k crash)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2023-02-13 21:19:31
You are conflating two different issues:
- SMP script crash: popup "your script uses too much memory X/Y" with SMP panel turning red. The player itself continues working normally and panel can be restarted.
- fb2k crash: whole player crashes. I.e. you can't continue using player and have to actually restart the application.

That "tip" turns the first scenario (SMP crash) into the second scenario (fb2k crash)
Please, re-read the report. The user was experiencing fb2k crashes before changing anything, so in fact you are conflating the issues (and probably some info is missing too). Hope this clarifies it:

- The user had fb2k crashes regularly, from time to time, with other scripts.

- The user had fb2k crashes at startup with my script: https://hydrogenaud.io/index.php/topic,120982.msg1022427.html#msg1022427

- The user had sometimes panel crashes with multiple scripts, included mine, while trying to process entire library at random points (reported by PM).

- FbMetadbHandleList_Constructor failed: allocation size overflow with standard settings with a 300K tracks size, which should work with default ram settings and worked fine on independent tests. (*) So the constructor fails when garbage collection has not freed enough ram on the panel (reaching the limit), although it could have simply take more ram from foobar, etc.. (I assume this with the following point)

- Then they tried changed the settings, following my suggestion, to find where the problem lied; since fb2k should not crash with the default config as you noted. They had no more FbMetadbHandleList_Constructor crashes AND no more fb2k crashes. So in fact crashes were gone with the debugging setting, not the opposite.

- Finally user reports here the "tip", which is obviously not applicable as a recommended setting.

(*) Blank panel with script getting library items in multiple iterations, it was able to fill up to 294.967.295 items on a handle list on the user's system. Which is obviously much higher than 300 K.

PD: this will obviously be a non-issue on x64 whenever there is a release, but it could be interesting to fix it on the actual release too since fb2k crashes are not expected as you noted.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2023-02-13 22:20:27
Btw, is it possible if SMP could delete created font objects from cache on window.Reload?
Well my theme is using "some" fonts and after the 20th window.Reload or so when using the new custom menu I've implemented,
I get a win API font crash.
I know from the docs it is limited by Windows, but I think there is nothing I could really do about it, I am reusing fonts where possible...

-TT
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2023-02-13 23:07:35
Well my theme is using "some" fonts and after the 20th window.Reload or so when using the new custom menu I've implemented,
How many is "some"? Georgia calls GDI.font about 45 times at startup with 12 different font faces to cache all the fonts the theme uses, and I can window.reload as much as I want without ever having a single API font crash. I do have a fair amount of memory though, so maybe that's why?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2023-02-14 00:47:17
I don't think it's an ram issue but a GDI handle limit and good old GDI is just the culprit.
So if I close and reopen the new custom menu ( based on your Material design )
about 275 times ( didn't use window.Reload for this test ), and the menu uses one gdi.Font object:

Code: [Select]
Error: Spider Monkey Panel v1.6.2-dev+7c0928bf ({04620F16-1878-47A1-8EFE-0CE0B99566CC}: Georgia-ReBORN v2.3.0 by TT)
include failed:
Font failed:
WinAPI error:
  CreateFont failed with error (0x0):
    Function failed, but returned a `SUCCESS` error code, which is usually caused by a bugged WinAPI. One such case is when process runs out of GDI handles and can't create a new GDI object.

This isn't that much to be honest because when you're using the theme for hours and creating a new custom theme,
it will eventually crash. When the crash happened I've had enough ram, but it could be 32bit app ram limitation?
Afaik 32bit apps can only use max 4gb, but I've read somewhere that fb2k x86 only uses max 2gb if I'm not mistaken.
But I don't think it has anything to do with the GDI handle limit, not sure...

P.S Tested on a laptop...

-TT
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: elia_is_me on 2023-02-14 05:53:18
fgt what i said...
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2023-02-14 06:09:18
I don't think it's an ram issue but a GDI handle limit and good old GDI is just the culprit.
So if I close and reopen the new custom menu ( based on your Material design )
about 275 times ( didn't use window.Reload for this test ), and the menu uses one gdi.Font object:
So just so I understand, the menu is calling gdi.Font everytime it initializes? Definitely those fonts need to be cached so you aren't creating them every time the menu is expanded. If you look at my original code I'm creating all the fonts I plan to use (https://github.com/kbuffington/Georgia/blob/skunkworks/js/settings-view.js#L35), and then just passing those in when creating the underlying controls (https://github.com/kbuffington/Georgia/blob/skunkworks/js/settings-view.js#L190), instead of calling gdi.font once for each control (which it sounds like you might be doing).

Elia might have deleted their post but if you're doing something different than I think, a memoized function that only calls gdi.font could be another really good idea.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: elia_is_me on 2023-02-14 06:50:15
I don't think it's an ram issue but a GDI handle limit and good old GDI is just the culprit.
So if I close and reopen the new custom menu ( based on your Material design )
about 275 times ( didn't use window.Reload for this test ), and the menu uses one gdi.Font object:
So just so I understand, the menu is calling gdi.Font everytime it initializes? Definitely those fonts need to be cached so you aren't creating them every time the menu is expanded. If you look at my original code I'm creating all the fonts I plan to use (https://github.com/kbuffington/Georgia/blob/skunkworks/js/settings-view.js#L35), and then just passing those in when creating the underlying controls (https://github.com/kbuffington/Georgia/blob/skunkworks/js/settings-view.js#L190), instead of calling gdi.font once for each control (which it sounds like you might be doing).

Elia might have deleted their post but if you're doing something different than I think, a memoized function that only calls gdi.font could be another really good idea.

i del my post because i found a 'gdi_font' function in his geogia_reborn repo.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2023-02-14 06:56:02
Last he told me, the code from his betas isn't in the repo yet, so it's unclear what he's using in this particular instance.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2023-02-14 08:24:43
I don't think it's an ram issue but a GDI handle limit and good old GDI is just the culprit.
So if I close and reopen the new custom menu ( based on your Material design )
about 275 times ( didn't use window.Reload for this test ), and the menu uses one gdi.Font object:
So just so I understand, the menu is calling gdi.Font everytime it initializes? Definitely those fonts need to be cached so you aren't creating them every time the menu is expanded. If you look at my original code I'm creating all the fonts I plan to use (https://github.com/kbuffington/Georgia/blob/skunkworks/js/settings-view.js#L35), and then just passing those in when creating the underlying controls (https://github.com/kbuffington/Georgia/blob/skunkworks/js/settings-view.js#L190), instead of calling gdi.font once for each control (which it sounds like you might be doing).

Elia might have deleted their post but if you're doing something different than I think, a memoized function that only calls gdi.font could be another really good idea.
It seems so.

gr-helpers
Code: [Select]
function font(name, size, style) {
let font;
try {
font = gdi.Font(name, Math.round(scaleForDisplay(size)), style);
} catch (e) {
console.log('\nFailed to load font >>>', name, size, style);
}
return font;
}

Should be something like this: (as bonus, don't spam the console with font missing messages!)
Code: [Select]
function _gdiFont(name, size, style) {
let id = name.toLowerCase() + '_' + size + '_' + (style || 0);
if (!fonts[id]) {
fonts[id] = gdi.Font(name, size, style || 0);
}
if (fonts[id].Name !== name && fonts.notFound.indexOf(name) === -1) { // Display once per session, otherwise it floods the console with the same message...
fonts.notFound.push(name);
fb.ShowPopupMessage('Missing font: ' + name + '\n\nPlease install dependency found at (a restart is required):\n' + folders.xxx + '_resources', window.Name);
console.log('Missing font: ' + name);
}
return fonts[id];
}

gr-menu.js is also full of calls to gdi.Font. Which should be cached.

Btw, if you are lazy, you can simply edit the gdi.Font method to cache fonts. That ensures it will apply on any instance, instead of using a new function. (*)  For ex I did this on TitleFormat (adding a Expression property to retrieve the original string, and caching):
Code: [Select]
// Add caching
Object.defineProperty(fb, 'tfCache', {
  enumerable: false,
  configurable: false,
  writable: false,
  value: {}
});

// Augment fb.TitleFormat() with 'Expression' property and add caching
{
const old = fb.TitleFormat;
fb.TitleFormat = function TitleFormat() {
const bCache = fb.tfCache.hasOwnProperty(arguments[0]);
const that = bCache ? fb.tfCache[arguments[0]] : old.apply(fb, [...arguments]);
that.Expression = arguments[0];
if (!bCache) {fb.tfCache[arguments[0]] = that;}
return that;
}
}

Btw I'm confused with other point. you did report that window.Reload did not cleared the fonts (?) I mean, wether you cache them or not, they should be removed at window.Reload. Or at least that's what I always thought. Is not that method supposed to be the same than loading the script from zero?

 (*) While this is not recommended on JS for web, in SMP libraries are not shared -but unique to every script/developer-, so in fact this should be the recommended way IMO... also it would help unifying helpers use for developers (the conversation at SMP thread).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2023-02-14 10:40:09
Btw, is it possible if SMP could delete created font objects from cache on window.Reload?
It *should* delete everything allocated by the script after reload. Last time I checked (t'was quite a long time ago though) all corresponding GDI handles were removed between reloads. Maybe I've reintroduced the bug, or maybe it's Windows being buggy (you *are* on windows and not wine, right?) and not actually destroying objects, or maybe you are reloading too much too fast which causes garbage collector not being fast enough thus leaving Font object alive for too long (they do not occupy a lot of space, hence they are not a priority target for GC).

More testing is required...

- Then they tried changed the settings, following my suggestion, to find where the problem lied; since fb2k should not crash with the default config as you noted. They had no more FbMetadbHandleList_Constructor crashes AND no more fb2k crashes. So in fact crashes were gone with the debugging setting, not the opposite.
This is really weird. I'd have liked to debug that (but not yet, since I'm still not back). Maybe there is a bug in SMP with GC that causes dangling references of some sort.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2023-02-14 15:45:14
Thanks for the replies,

yes latest code is not yet available on the Georgia-ReBORN repo ( last commit was on Aug 28, 2022 )
but here "LATEST WORK IN PROGRESS VERSION: Georgia-ReBORN v2.3.0 Beta 11b":
https://github.com/TT-ReBORN/Georgia-ReBORN/discussions/74#discussion-4190799

So I have quite modified your Material code to my needs, full code is in gr-menu-custom.js

Basically class BaseControl constructor only has one declared font "this.font = ft.popup" that has been created via gdi.Font ( font helper in gr-setup.js ) on theme init startup:
Code: [Select]
class BaseControl {
constructor(x, y, label) {
/** @protected */ this.x = x;
/** @protected */ this.y = y;
/** @protected */ this.label = label;
this.state = {};
this.doubleClickTime = 300;
this.lastClickTime = null;
this.focus = false;
this.disabled = false;
this._hovered = false;
this.font = ft.popup;
this.popupFontSize = pref.layout === 'artwork' ? pref.popupFontSize_artwork : pref.popupFontSize_default;
this.closeBtn = this.label === '\u2715';
/** @protected @private */ this.i = gdi.CreateImage(1, 1);
/** @protected */ this.g = this.i.GetGraphics(); // GdiBitmap used for MeasureString and other functions
}

then all other child classes ( DropDownMenu, StringInput, ColorPicker and Info ) are using this.font.

When the custom theme menu will be opened by the user via top menu Options > Theme > Custom > Edit custom theme, or
when a custom theme slot was selected from top menu Options > Theme > Custom, via the quick navigation right click context menu > Edit custom theme :
Code: [Select]
function initCustomThemeMenu(playlist_section, main_section, library_section, biography_section, info) {
if (pref.libraryLayout   === 'full') pref.libraryLayout   = 'normal'; setLibrarySize();
if (pref.biographyLayout === 'full') pref.biographyLayout = 'normal'; setBiographySize();
if (pref.lyricsLayout    === 'full') pref.lyricsLayout    = 'normal'; resizeArtwork(true);

controlList = [];

const margin = scaleForDisplay(40);
const baseX = displayBiography || pref.displayLyrics ? ww * 0.5 + margin : !displayPlaylist && !displayLibrary && !displayBiography ? noAlbumArtStub ? ww * 0.3 : albumArtSize.x + margin : margin;
let x = baseX;
let y = geo.topMenuHeight + margin * 0.75;

const mainSection      = ['main_bg', 'main_bar', 'main_text', 'main_btns', 'main_btns2', 'main_style'].includes(main_section);
const playlistSection  = ['pl_bg',   'pl_text1', 'pl_text2',  'pl_misc', 'pl_btns'].includes(playlist_section);
const librarySection   = ['lib_bg',  'lib_text', 'lib_node',  'lib_btns'].includes(library_section);
const biographySection = ['bio_bg',  'bio_text', 'bio_misc',  'bio_btns'].includes(biography_section);

const menu = new DropDownMenu(x, y, 'Main', ['Bg', 'Bar', 'Text', 'Btns', 'Btns 2', 'Style'], 0);
controlList.push(menu);
x += controlList[controlList.length - 1].w + 1; controlList.push(new DropDownMenu(x, y, 'Playlist',  ['Bg', 'Text', 'Text 2', 'Misc', 'Btns'], 0));
x += controlList[controlList.length - 1].w + 1; controlList.push(new DropDownMenu(x, y, 'Library',   ['Bg', 'Text', 'Node', 'Btns'], 0));
x += controlList[controlList.length - 1].w + 1; controlList.push(new DropDownMenu(x, y, 'Biography', ['Bg', 'Text', 'Misc', 'Btns'], 0));
x += controlList[controlList.length - 1].w + 1; controlList.push(new DropDownMenu(x, y, 'Options',   ['Info', '', 'Theme 01', 'Theme 02', 'Theme 03', 'Theme 04', 'Theme 05', 'Theme 06', 'Theme 07', 'Theme 08', 'Theme 09', 'Theme 10', '', 'Reset'], 0));
x += controlList[controlList.length - 1].w + 1; controlList.push(new DropDownMenu(x, y, '\u2715',    ['']));
x = baseX;
y += menu.h + margin * 0.75;

switch (true) {
case playlistSection:  customPlaylistColors(x, y, ww * 0.5, wh - geo.topMenuHeight - geo.lowerBarHeight, playlist_section); break;
case mainSection:      customMainColors(x, y, ww * 0.5, wh - geo.topMenuHeight - geo.lowerBarHeight, main_section); break;
case librarySection:   customLibraryColors(x, y, ww * 0.5, wh - geo.topMenuHeight - geo.lowerBarHeight, library_section); break;
case biographySection: customBiographyColors(x, y, ww * 0.5, wh - geo.topMenuHeight - geo.lowerBarHeight, biography_section); break;
case info:             customThemeInfo(x, y, ww * 0.5, wh - geo.topMenuHeight - geo.lowerBarHeight); break;
}
}

Thanks for the tips @regor, I'll see what I can do with it.

-TT
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2023-02-14 20:36:08
@TT your link doesn't include beta 11b, just beta 11, and that one doesn't have gr-menu-custom.js, just gr-menu.js.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2023-02-14 20:47:04
Both versions are in the first post, it is the second download link right beneath Beta 11 ;-)
@MordredKLB, check also my PM.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2023-02-14 22:04:50
Both versions are in the first post, it is the second download link right beneath Beta 11 ;-)
@MordredKLB, check also my PM.
Reading comprehension was never my strong suit. :) Thanks.

Depending on how gdi.font resources are garbage collected, you could run into problems when changing font sizes since many of your menu options generate multiple gdi.font calls.

I would hope that doing:
Code: [Select]
ft.cached =  gdi.Font('fontAwesome', 22,  0);
// and then
ft.cached =  gdi.Font('fontAwesome', 30,  0);
Would release the first gdiFont handle. But @TheQwertiest would have to confirm.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2023-02-14 22:31:08
So in the test I was doing on Windows 10, I did not even use the top menu Options at all.
That means no gdi.Font calls from gr-menu.js -> function fontSizeOptions(menu)

I was just always calling ( ~275 times until crash ) the right click context menu > Edit custom theme
from Control_ContextMenu.js and there are no gdi.Font calls at all.

I can reproduce it with this, put this code at the end ( after initMain ) in gr-main.js and start foobar:
Code: [Select]
setInterval(() => {
displayCustomThemeMenu = true;
displayPanel('playlist');
initCustomThemeMenu('pl_bg');
window.Repaint();
}, 500);

It will crash after some time with the WinAPI font error message...
Also, if you window reload after the crash, it will not free the GDI handles, the error message still remains.
Only a foobar program restart helps!

-TT
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2023-02-14 23:45:47
It will crash after some time with the WinAPI font error message...
Repro'd. The issue isn't in your or my code, it's in biography. Your initCustomTheme calls setBiographySize, and inside interface.js's getFont function there's this block of code:
Code: [Select]
		this.font.items.forEach(v => {
const style = pptBio[v[0]] < 4 ? pptBio[v[0]] : (pptBio[v[0]] - 4) * 2;
this.font[v[1]] = gdi.Font(pptBio[v[0]] < 4 ? this.font.main.Name : 'Segoe UI Semibold', this.font.main.Size, style);
});

among others. gdi.Font is called 20x in that one single getFont from the on_size generated in setBiographySize. I'm guessing if you just displayed the biography panel and then resized the window multiple times you'd encounter the exact issue.

You should determine if setBiographySize should even be called first of all, and @WilB should probably use his own memoized version instead of gdi.Font inside getFont, and probably FSM itself should memoize the actual gdi.Font function if at all possible so that us programmers can continue doing dumb things :)


I can probably help you with that if need be.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2023-02-14 23:59:10
Do you mean this section here?

Code: [Select]
function initCustomThemeMenu(playlist_section, main_section, library_section, biography_section, info) {
if (pref.libraryLayout   === 'full') pref.libraryLayout   = 'normal'; setLibrarySize();
if (pref.biographyLayout === 'full') pref.biographyLayout = 'normal'; setBiographySize();
if (pref.lyricsLayout    === 'full') pref.lyricsLayout    = 'normal'; resizeArtwork(true);

That is the only time I use setBiographySize but ONLY if the biography layout is in full width. Because the custom theme menu is
on the album art so the biography can't be full width. But as you see that shouldn't be a problem at all ( well in the test case with the interval ) because it will be reset to normal width and the function won't be called at all. Also this crash happens when the biography is also in normal width, so setBiographySize won't be called at all, otherwise I'm missing something...

Edit: Just commented this out, it's the same crash.
Tried to resize the biography for 5 mins and no crash =)

-TT
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2023-02-15 00:11:42
Do you mean this section here?

Code: [Select]
function initCustomThemeMenu(playlist_section, main_section, library_section, biography_section, info) {
if (pref.libraryLayout   === 'full') pref.libraryLayout   = 'normal'; setLibrarySize();
if (pref.biographyLayout === 'full') pref.biographyLayout = 'normal'; setBiographySize();
if (pref.lyricsLayout    === 'full') pref.lyricsLayout    = 'normal'; resizeArtwork(true);
That code isn't doing what you think it's doing. Put curly braces around the "then" portions of the if statement like so: { pref.biographyLayout = 'normal'; setBiographySize(); } and then it will.
As it's written it calls setLibrarySize, setBiographySize, and resizeArtwork every time that function is called, regardless of what the layout is.

Also I tracked it down to setBiographySize due to the stack trace on crash. Keep your console open when debugging and see if you get one.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2023-02-15 00:17:16
Haha, forgot the curly braces xD happens if you code till 3am and you should be sleeping.
But still as I've written, if you comment this out it still crashes with the interval...

Console output:
foo_spider_monkey_panel:
Error: Spider Monkey Panel v1.6.2-dev+7c0928bf ({04620F16-1878-47A1-8EFE-0CE0B99566CC}: Georgia-ReBORN v2.3.0 by TT)
SetTextRenderingHint failed:
GdiPlus error: SetTextRenderingHint failed with error (0x2): InvalidParameter

File: gr-main.js
Line: 21, Column: 5
Stack trace:
  drawBackgrounds@gr-main.js:21:5
  drawMain@gr-main.js:925:2
  on_paint@gr-main.js:991:2

Does not tell anything, only that GDI is out of handles for text rendering...
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2023-02-15 00:31:22
Haha, forgot the curly braces xD happens if you code till 3am and you should be sleeping.
But still as I've written, if you comment this out it still crashes with the interval...
BaseControl badly leaks GDIHandles:
Code: [Select]
		/** @protected @private */ this.i = gdi.CreateImage(1, 1);
/** @protected */ this.g = this.i.GetGraphics(); // GdiBitmap used for MeasureString and other functions
That was a really dumb idea. The destructor has to be manually called before the object goes out of scope (which is obviously very hard to do), otherwise you leak that handle. Better would be to have written it so that this.i and this.g are singletons, and every BaseControl shares the same one. Alternately you could make .g not be a part of the the object, and instead just call this.GetGraphics before it's used and then immediately after. Not sure if there are any performance considerations there. CalcTextWidth/Height can get called frequently so that's what I was trying to avoid.

Edit:
Code: [Select]
let __i_ = undefined;
let __g_ = undefined;

class BaseControl {
constructor(x, y, label) {
                . . . clipped other class members here
/** @protected */ this.g;
if (!__i_) {
__i_ = gdi.CreateImage(1, 1);
__g_ = __i_.GetGraphics(); // GdiBitmap used for MeasureString and other functions
}
this.g = __g_;
}

destructor() {
}
Does not crash, or at least not for a very long time. Was able to call initCustomThemeMenu over 3000 times. Seems that gdi.Font handles are released when they go out of scope, so biography panel was just a symptom of this bug and nothing bad is actually happening there on resize.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2023-02-15 01:09:34
Yep that does it, hammering with 100ms and it goes smoothly =)
Thanks a lot for your first line support Kevin and also for your Material design<3
Would not been able to create custom themes without it, I owe you one.

P.S Sorry for polluting your thread @TheQwertiest ;-)

-Tom
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: maniac736 on 2023-02-21 08:40:36
Greetings. I installed foo_spider_monkey 1.6.1. I used the status bar + volume.js script with this module. When I try to manually adjust the colors, the script crashes with the foo_spider_monkey_panel error:
Error: Spider Monkey Panel v1.6.1 ({74372042-65B9-4EDC-8274-71117899FE7D}: Status Bar + Volume by marc2003)
properties.background.set is not a function

File: statusbar + volume.js
Line: 132, Column: 25
Stack trace:
   on_mouse_rbtn_up@status bar + volume.js:132:25
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2023-02-21 15:15:56
Change line 132 to this

Code: [Select]
properties.background.value = utils.ColourPicker(window.ID, properties.background.value);

and line 136...

Code: [Select]
properties.text.value = utils.ColourPicker(window.ID, properties.text.value);
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: maniac736 on 2023-02-21 16:33:57
Thank you Mark. Everything works great.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: PhillipeCasa on 2023-02-23 01:05:16
Greetings. I have the habit of making my own very amateur skins using Columns.Ui, and I use the Spider Monkey Panel for some elements, taking advantage of ready-made single panels such as "Volume Bar", "Seekbar", "Playlist Manager", etc. I'm very new to javascript, the most I can do is enter the codes of the single panels and change the attributes of colors, fonts, etc., when these attributes appear available there.
Well, I wanted to know if there is a very simple single panel for Spider Monkey Panel only with the track info (basically a panel that shows only artist, album, date, tracknumber, title, playback time, length, bitrate and samplerate), so I could stop using the "Item Details" component from Columns.Ui and change for one more element via Spider Monkey Panel.
Thank a lot for the attention.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2023-02-23 10:20:18
I think you are looking for this:
https://theqwertiest.github.io/foo_spider_monkey_panel/docs/script_showcase/single_panel_scripts/#track-properties
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: PhillipeCasa on 2023-02-23 20:16:51
I think you are looking for this:
https://theqwertiest.github.io/foo_spider_monkey_panel/docs/script_showcase/single_panel_scripts/#track-properties

Thank you for your attention, Regor.
In fact, I had already taken a look at this Properties Panel, but it doesn't allow me to choose just a few items I would like to use. Normally I "simulate" a LED display in the Foobar skin using the "Item Details" component, available in ColumnsUI, where I can put the artist, the album (with the year), the number and the name of the song and also the playback time of the running track. I choose a nice font, a background color that deceives like a display and it suits me. The problem is that this component is annoying to handle because if you change its background color in a skin, it automatically changes in all skins, it is not independent, then every time I want to use a skin that I made a long time ago, it appears there with the wrong colors.
Whenever I find a problem similar to this in a component, I solve it by changing it to a similar Panel from Spider Monkey, which is spectacular, I love Spider Monkey, but I have many limitations to work with it because I am a layman in Javascript. And I didn't find a single panel where I could choose attributes to show just some basic track information to my liking.

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Bollerkopp on 2023-03-03 12:18:07
@marc2k3

Would it be possible to make a "Text Display"-script for SMP, like you have it in JSP?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2023-03-03 13:21:58
No. JSP3 has new text rendering APIs that make styling text with $rgb and my own $font function very easy.

Probably not impossible but it would be very difficult to replicate in SMP.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Bollerkopp on 2023-03-03 13:45:54
Ok, I see. Honestly I ask only, because in JSP3 my used font Tahoma looks awful with this rendering. See the screenshot. Is there any way to make it look like the playlist font rendering on the left? :)

X
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2023-03-03 15:59:09
Not sure what I can do really. The entire text string is passed to a single function with a few simple args for text alignment etc. Maybe I need to consider custom line spacing which is currently not implemented. But any further comments about this should be in the JSP thread.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Wzor on 2023-03-11 20:31:19
marc, hi! Could you help me? The following error occurs:

Error: Spider Monkey Panel v1.6.1 (Last.fm Similar Artists + User Charts + Recent Tracks: Last.fm Similar Artists + User Charts + Recent Tracks by marc2003)
CheckMenuRadioItem failed:
Index is out of bounds

File: panel.js
Line: 91, Column: 12
Stack trace:
  _panel/this.rbtn_up@panel.js:91:12
  on_mouse_rbtn_up@:72:15
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Wzor on 2023-03-12 00:06:16
Marc, and one more question - how to set up the font size for popups?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2023-03-12 03:23:18
The script error is caused by you using the properties dialog to override the font size. Using built in values would never cause an error.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Wzor on 2023-03-12 06:55:29
Thanks, that's what I thought. I added a font size to the script, and everything was OK. But I couldn't find a way to change the size of the popup messages.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Sue Dunham on 2023-03-19 18:04:37
I'm modifying a script, and I think I may have run afoul of item number 6 from the Notes & Hints file, which states the following.

Quote
It's NOT recommended to create objects in callback function on_paint(), since it will be called frequently.

But it's just a tiny little object that doesn't seem all that, um, objectionable. I'd like to know how bad this is and what to look for that might indicate that I need to find another way.

Basically, I was getting spacing issues with the original script and thought that the problem might be the use of gr.MeasureString in conjunction with gr.GdiDrawText inside the on_paint callback. So I replaced those calls with calls to this function instead. (Maybe using gr this way violates Notes & Hints #4, but I think I'm in the clear there.)

Code: (javascript) [Select]
function calc_text(gr, str, font, use_exact=false) {
    // Get text width and height with output like gr.MeasureString
    let w = gr.CalcTextWidth(str, font, use_exact);
    let h = gr.CalcTextHeight(str, font);
    return {Width: w, Height: h};
};

I wanted to mimic the output of gr.MeasureString to avoid changing the way it is subsequently used. I figure I'm just switching one object for one that was already there, but I'm still learning this stuff.

So can I get away with that? At the moment, there aren't too many other SMPs present, but this will change. The script I'm modifying autoscrolls long artist-title strings, and that still seems to be happening smoothly. OK, maybe there are some slight jolts if I concentrate on watching it.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: MordredKLB on 2023-03-20 05:19:10
So can I get away with that? At the moment, there aren't too many other SMPs present, but this will change. The script I'm modifying autoscrolls long artist-title strings, and that still seems to be happening smoothly. OK, maybe there are some slight jolts if I concentrate on watching it.
There's nothing wrong with what you're doing. You're creating a very small POJO and then returning it inside the on_paint where presumably you're assigning it to a const that will go out of scope as soon as on_paint is done and therefore will eventually get garbage collected.

That warning is for two reasons:
1) You want on_paint to be fast, and new'ing some object could potentially be slow depending on the constructor and all the initialization needed (although it's unlikely to noticeably affect things)
and mainly:
2) If you're new'ing an object in the on_paint, and keeping a reference to it for some reason that doesn't go out of scope when on_paint ends, you could quickly run out of memory given how often the on_paint runs.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Majestyk on 2023-03-30 06:25:20
Is there a reason why the default.jpg wallpaper doesn't work on SMP's JSP & JSS? No matter what path I use it won't find the file. Except if I put the full path like:

C:\Users\username\AppData\Roaming\foobar2000\user-components\foo_spider_monkey_panel\samples\jsplaylist-mod\images\default.jpg

With various jscript versions all I need is:

user-components\foo_jscript_panel\samples\images\jsplaylist\default.jpg
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Majestyk on 2023-03-30 06:50:14
Ok, I put fb.ProfilePath + in front of properties.wallpaperpath and the following path now works:

".\\user-components\\foo_spider_monkey_panel\\samples\\jsplaylist-mod\\images\\default.jpg"

However, it will not work on portable versions of Foobar2000, which is really odd. The default.jpg wallpaper in the Jscript versions of JSP/JSS works in portable as well. It shouldn't matter where FB2K resides, as long as it finds the user-components directory.

I'm wondering if it could be a SMP issue.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2023-03-30 09:34:37
You can't compare samples from different components like that, because they are not the same at all. Code is totally different.

The JS Smoot Playlist sample at SMP, at least looking the wallpaper part, is coded in a way that makes zero sense.
Obviously it can not work, and adding fb.ProfilePath is not doing at all what you expect. Neither it's a SMP problem if the code is wrong.

Restore default property and replace sample file. I'm not bothering rewriting anything, just a fast fix.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Majestyk on 2023-03-30 10:47:20
That works, thanks! I'll see if I can incorporate this into JSP. And with some luck, maybe make JSS so it can auto load the default.jpg if there is no artwork, like JSP can.

Thanks again!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2023-03-30 10:51:37
That works, thanks! I'll see if I can incorporate this into JSP. And with some luck, maybe make JSS so it can auto load the default.jpg if there is no artwork, like JSP can.

Thanks again!
Have no idea which scripts are those XD but all 'js-smooth' scripts use the same common file, so this will fix them all.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Majestyk on 2023-03-30 11:18:56
It was very easy to incorporate this to JSP. Both JSP and JSS will now work in portable mode.

Muchas gracias!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: NewLeaf42 on 2023-04-09 04:03:41
Sorry if there's already been an answer to this, but was there ever a simple way to fix drag n drop on Linux with Wine for people who aren't programmers? I already deleted/rebuilt my prefix like 10 times today, it's been exhausting. First dragging files into the playlist did nothing, now it's just causing foobar to quit immediately. I don't know if this has something to do with me attempting to install dotnet20 on a 64 bit prefix. I was testing with spider monkey panel 1.4.1 and 1.5.2 hotfix
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2023-04-10 13:33:45
Sorry if there's already been an answer to this, but was there ever a simple way to fix drag n drop on Linux with Wine for people who aren't programmers? I already deleted/rebuilt my prefix like 10 times today, it's been exhausting. First dragging files into the playlist did nothing, now it's just causing foobar to quit immediately. I don't know if this has something to do with me attempting to install dotnet20 on a 64 bit prefix. I was testing with spider monkey panel 1.4.1 and 1.5.2 hotfix

I've fixed this in Georgia-ReBORN ( since Beta 11 ) and it's working fine if you're downgrading to SMP v1.5.2.
The problem is that it is a Wine bug and the current SMP sample scripts and original playlist script are not working properly.
But there is a workaround for this, see here. (https://github.com/TT-ReBORN/Georgia-ReBORN/issues/2#issuecomment-1248667529)
Also keep in mind that this "fix" is working only with SMP v1.5.2 and is NOT working with SMP v1.6.0/1.6.1/1.6.2-dev,
because TheQwertiest changed drag and drop behavior since SMP v1.5.2.

-TT
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Majestyk on 2023-04-15 05:18:57
Does code like this work in SMP?

Quote
var arr = []; // array to store colours
var img = utils.GetAlbumArtV2(fb.GetNowPlaying(), 0);
if (img) {
   arr = JSON.parse(img.GetColourSchemeJSON(5));
}

If I copy it into a playlist it will slow it to a crawl. The last line (JSON...) is the culprit.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2023-04-15 06:22:40
Themes like Georgia/Reborn variant have been using it for years with no issue.

Perhaps you're putting it somewhere stupid where it's called more often than it needs to be??
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Majestyk on 2023-04-15 06:34:24
Not sure why it would be called so much. I even stumped ChatGPT. hehe.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2023-04-15 06:37:35
Well your code snippet indicates you want the playing track colours. You should be calling it when the track changes via on_playback_new_track - typically once every few minutes. What are you doing?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Majestyk on 2023-04-15 06:41:35
I'm not using that snippet. I just pasted here for an example.

I just noticed Darkone 2019 also uses it as well in their cover art but I have no idea why it's there. Being beta It was probably just unfinished.

PS: Just got it working in Darkone. The picture frame now changes color according to artwork, but of course without further color picker code it looks bad with dark or black artwork.

Still can't figure out why I can't get it working in some other environments but I'll keep working on it.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2023-04-15 07:27:49
Well my top tip for the day is that you only want the to use the retrieved colours for backgrounds. The text colour should be determined from the background automatically so it contrasts. I'm using these functions stolen from the foobar2000 C++ SDK and ported to javascript....

Code: [Select]
// getRed etc should be in docs\helpers.js

function Luminance(colour) {
var r = getRed(colour);
var g = getGreen(colour)
var b = getBlue(colour);
return (0.2126 * r + 0.7152 * g + 0.0722 * b) / 255.0;
}

// The resulting text colour is always black or white....
function DetermineTextColour(background) {
var l = Luminance(background);
if (l > 0.6) {
return RGB(0, 0, 0);
} else {
return RGB(255, 255, 255);
}
}

Now...

Code: [Select]
var bg = // most dominant colour extracted by GetColourSchemeJSON
var txt = DetermineTextColour(bg);
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Majestyk on 2023-04-15 07:51:25
I'll take a look at this tomorrow. Thanks!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: to-us on 2023-04-16 12:35:33
Hello, my first steps with scripting months ago and now my DUI interface is finished.  I want to say "Thank you" to @TheQwertiest and all the other authors who shared their work and knowledge. So I decided to share a bit of my work which I find particularly successful - my version of album art with reflection.

For me it works perfectly but I am a beginner. Maybe the code is terrible and you'll find some copied code snippets but I went my own way.

(https://i.ibb.co/N7bh2sh/Holly-shot.png) (https://ibb.co/N7bh2sh)

Attached script is without the buttons and codec info...
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Majestyk on 2023-04-20 08:56:06
Does SMP remember utils.ColourPicker settings? As in showing the current values being used. (As opposed to just showing black). I just want to make sure the menu is working properly.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2023-04-20 09:15:32
https://github.com/TheQwertiest/foo_spider_monkey_panel/issues/203
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Majestyk on 2023-04-20 22:12:11
Ok, good to know it's 'normal' behavior.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2023-04-21 08:15:05
Until the bug gets fixed, yep hahahaha
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2023-05-01 12:37:55
I've attached a new compile based on 1.6.1 with some fixes.

-A bug with utils.IsFile / utils.IsDirectory throwing script errors instead of returning false when trying unavailable drives has been fixed.
-The colour picker now functions as expected and custom colours can be added/stored until fb2k closes.
-There are utils.GetClipboardText and utils.SetClipboardText methods which are generally nicer than messing around with ActiveX objects. Some people who previously had dev builds might be used to these already.

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2023-05-01 13:24:01
Hahaha, just released a new beta and now I see this, should have checked before xD
Thanks anyways @marc2k3 =)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: paregistrase on 2023-05-01 13:40:29
I've attached a new compile based on 1.6.1 with some fixes.

-A bug with utils.IsFile / utils.IsDirectory throwing script errors instead of returning false when trying unavailable drives has been fixed.
-The colour picker now functions as expected and custom colours can be added/stored until fb2k closes.
-There are utils.GetClipboardText and utils.SetClipboardText methods which are generally nicer than messing around with ActiveX objects. Some people who previously had dev builds might be used to these already.

I gonna change my username to some people  ;) 

Thank you very much
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2023-05-01 20:59:12
So the compile I posted earlier only had fixes by myself. This one also includes fixes by TheQwertiest for pseudo transparency and tooltip TrackPosition().








Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2023-05-02 10:53:32
@marc2k3,

foo_spider_monkey_panel\docs\html directory is missing and can you rename to v1.6.1-5-g7c0928bf in
Preferences > Components > Installed Components > Spider Monkey Panel

Thanks

-TT
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2023-05-02 11:38:38
I'm only appending -mod to the version so you know it's not official. Docs have been restored. This also has most 3rd party dependencies updated to latest versions.

edit: I forgot to mention I refactored the pseudo-transparency to use code from the Columns UI SDK.

Changes are on my personal copy on github: https://github.com/marc2k3/spider-monkey-panel/commit/eed51320c7d38ced4ecd68bc110e6f1f27508c07

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2023-05-02 12:12:57
Thanks Marc,

by any chance, can you fix the drag n drop for the Wine folks please? (https://hydrogenaud.io/index.php/topic,121786.msg1015718.html#msg1015718)
Because they're currently stuck with SMP 1.5.2 which works for them.
I and the Linux Wine folks would greatly appreciate it =)

Thanks!

-TT
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2023-05-02 12:34:16
Nope, not happening. I'd have to instal linux/WINE to test and I'm not wasting my time with that shit.

If people want to use a media player written for windows with components written for windows, they should use windows.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2023-05-02 12:52:01
Come on Marc...
we know you're a good guy that helps people. Think of it that you will accumulate additional positive + karma points
and have hope for a good afterlife O:)

The problem is, that on Linux there aren't that many good music players...

I'm crossing my fingers anyways, otherwise there will be a RIOT ;-)

-TT
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: paregistrase on 2023-05-02 12:56:48
Nope, not happening. I'd have to instal linux/WINE to test and I'm not wasting my time with that shit.

If people want to use a media player written for windows with components written for windows, they should use windows.

If you need to do testing with wine, feel free to contact me. I will be happy to help.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2023-05-02 12:59:46
Good to know that paregistrase is on board, I know that many others are too.
We can also start a petition to convince Marc otherwise =)

-TT
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2023-05-02 13:02:03
What planet are you cunts from? Honestly, I'll take a permanent forum ban at this point.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: paregistrase on 2023-05-02 13:13:56
What planet are you cunts from? Honestly, I'll take a permanent forum ban at this point.

There is no need to disrespect anybody.
If you can't behave like a person in public is nobody fault.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2023-05-02 15:51:41
Man Marc... At this point I thought we were no complete strangers at all.
I guess there will be no more jokes in the future, I tried and I failed :(

-TT
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Mrakobes on 2023-05-08 06:39:43
(https://i.ibb.co/RPRQ13J/2023-05-08-06-53-13.png) (https://i.ibb.co/sJ7KPQb/2023-05-08-06-53-04.png)



An error constantly crashes, what should I do? Is it a problem in the covers or?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: ApacheReal on 2023-05-19 18:30:23
I have the following error:

Error: Spider Monkey Panel v1.6.1 (Lastfm Cover: Lastfm Cover by zeremy)
CheckMenuRadioItem failed:
Index is out of bounds

File: thumbs.js
Line: 345, Column: 25
Stack traces:
  _thumbs/this.rbtn_up@thumbs.js:345:25
  _panel/this.rbtn_up@panel.js:85:11
  on_mouse_rbtn_up@lastfm_cover.js:197:18

The error occurs when I right-click on the "Panel properties" menu and change the value from 3 to 4 in the "THUMBS.ASPECT" field

The problem also occurs in the original smoralis footuner-master skin.

(https://i.postimg.cc/3yNDJtQQ/1.png) (https://postimg.cc/3yNDJtQQ)

(https://i.postimg.cc/5QdHg1Yf/3.png) (https://postimg.cc/5QdHg1Yf)

(https://i.postimg.cc/rKtTcWPZ/4.png) (https://postimg.cc/rKtTcWPZ)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: zeremy on 2023-05-19 18:56:06
I have the following error:

Error: Spider Monkey Panel v1.6.1 (Lastfm Cover: Lastfm Cover by zeremy)
CheckMenuRadioItem failed:
Index is out of bounds

File: thumbs.js
Line: 345, Column: 25
Stack traces:
  _thumbs/this.rbtn_up@thumbs.js:345:25
  _panel/this.rbtn_up@panel.js:85:11
  on_mouse_rbtn_up@lastfm_cover.js:197:18

The error occurs when I right-click on the "Panel properties" menu and change the value from 3 to 4 in the "THUMBS.ASPECT" field

The problem also occurs in the original smoralis footuner-master skin.

(https://i.postimg.cc/3yNDJtQQ/1.png) (https://postimg.cc/3yNDJtQQ)

(https://i.postimg.cc/5QdHg1Yf/3.png) (https://postimg.cc/5QdHg1Yf)

(https://i.postimg.cc/rKtTcWPZ/4.png) (https://postimg.cc/rKtTcWPZ)

4 is an invalid value.
Valid values are 0,1,2,3.

Code: [Select]
panel.m.AppendMenuItem(MF_STRING, 1510, 'Crop (focus on centre)');
                panel.m.AppendMenuItem(MF_STRING, 1511, 'Crop (focus on top)');
                panel.m.AppendMenuItem(MF_STRING, 1512, 'Stretch');
                panel.m.AppendMenuItem(MF_STRING, 1513, 'Centre');
                panel.m.CheckMenuRadioItem(1510, 1513, this.properties.aspect.value + 1510);
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: ApacheReal on 2023-05-19 19:26:03
It is a problem of having the same size between the radio station logo cover and the album cover downloaded in real time.

(https://i.postimg.cc/7GmjQDqv/1-4.png) (https://postimg.cc/7GmjQDqv)

(https://i.postimg.cc/N5yZbWVV/2-3.png) (https://postimg.cc/N5yZbWVV)

(https://i.postimg.cc/HjvfwpSX/3-3.png) (https://postimg.cc/HjvfwpSX)

(https://i.postimg.cc/V5kx0SFz/4-3.png) (https://postimg.cc/V5kx0SFz)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: zeremy on 2023-05-19 20:00:26
I can't answer if you don't provide with what script / panel you are using to display the radio station cover.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: ApacheReal on 2023-05-19 20:12:05
I can't answer if you don't provide with what script / panel you are using to display the radio station cover.

It is the same as the footuner lastfm_cover.js:

https://github.com/smoralis/footuner

https://github.com/smoralis/footuner/tree/master/profile/themes/footuner/js
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: zeremy on 2023-05-19 20:28:43
You are using the same panel twice? one for the radio station cover and the other for last. fm cover?
The scripts in footuner are modified specifically for the layout, and I will not support any modifications needed to use otherwise.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: ApacheReal on 2023-05-21 11:27:01
I was slow to answer because in the meantime after various attempts I managed to reduce the radio station logo panel so as to have uniformity between the radio logo cover and that of the album that downloads in real time.

(https://i.postimg.cc/pm3ZRnSk/Radio-1.png) (https://postimg.cc/pm3ZRnSk)

(https://i.postimg.cc/YGHzmBMW/Radio-1-bar-new-options.png) (https://postimg.cc/YGHzmBMW)

(https://i.postimg.cc/62fLrbp1/Radio-1-new-BIO.png) (https://postimg.cc/62fLrbp1)

(https://i.postimg.cc/R3fTFZ5m/Radio-1-scroll.png) (https://postimg.cc/R3fTFZ5m)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: ApacheReal on 2023-06-01 12:40:47
Why do I find 2 Spider Monkey Panels in Advance setting and what should I do to uninstall and reinstall?

(https://i.postimg.cc/ThYfDsGX/Immagine-2023-06-01-133459.png) (https://postimg.cc/ThYfDsGX)

I also have Out of Memory issues.

Can I implement memory?

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2023-06-01 13:48:49
I suspect the duplicate entry comes from JSplitter which is forked from SMP.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: ApacheReal on 2023-06-01 14:43:44
Yes, it is.

At the moment I leave the JSplitter (first entry)

For Out of Memory problems I had benefit to change the value (maximum eap size....) to 4294967295

The next value I added a leading 1 152428800

But that's not enough to handle the extra panels.

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TF3RDL on 2023-06-03 18:38:42
Is it possible to make visualizations like this (https://codepen.io/collection/NqMMWo) using SMP since I've created several Web Audio API visualizations that uses custom FFT instead of getByteFrequencyData() for the spectrum analyzer?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: octopusmyrtle on 2023-06-03 22:04:46
Got this error when trying to import a theme:

Code: [Select]
Error: Spider Monkey Panel v1.6.1 (TitleBar: TitleBar v1.2.3b21 by Ottodix)
ShowHtmlDialog failed:
WinAPI error:
  put_designMode failed with error (0x80004001):
    Not implemented.

File: JStheme_common.js
Line: 314, Column: 8
Stack trace:
  NoticeBox@JStheme_common.js:314:8
  on_init/welcome_msg_timer<@WSHtitle_bar.js:2941:4
What is this? It also shows the "Aw, crashed :(" message in red but only on the top bar.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kutuzof on 2023-06-22 12:32:54
How to correctly write a condition for displaying one or another text, depending on whether a track is selected in the playlist or not.
Code: [Select]
if selected ? text 1 : text 2
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2023-06-22 12:36:59
How to correctly write a condition for displaying one or another text, depending on whether a track is selected in the playlist or not.
Code: [Select]
if selected ? text 1 : text 2
Without any context there is no proper answer:
https://theqwertiest.github.io/foo_spider_monkey_panel/assets/generated_files/docs/html/plman.html#.GetPlaylistSelectedItems

Code: [Select]
const myText = plman.GetPlaylistSelectedItems(plman.ActivePlaylist).Count ? 'text 1' : 'text2';
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kutuzof on 2023-06-22 12:48:32
Thank you!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TF3RDL on 2023-07-06 04:35:39
Quote
Is it possible to make visualizations like this (https://codepen.io/collection/NqMMWo) using SMP since I've created several Web Audio API visualizations that uses custom FFT instead of getByteFrequencyData() for the spectrum analyzer?
Nvm, I think you can use audiowaveform or ffprobe to make audio waveform data and take only short chunk of it something like this (https://github.com/AlexVestin/musicvid.org/blob/master/src/editor/audio/Sound.js#L167) (assuming it doesn't support WASM at all) with offset equal to current playback time for FFT spectrum analysis or something like that

Or is it that requires updating the SMP to support visualizations so Web Audio visualizers can be put into fb2k through SMP?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2023-07-06 16:53:42
@TF3RDL , Web Audio API is not a part of ECMAScript standard and SpiderMonkey (which is the engine that SMP is using) is a pure JavaScript engine without any DOM extensions. SMP v1.x does not implement any DOM facilities either (except for small things like timers and console.log). Hence it's impossible to do what you want with SMP.

Additionally, Web Audio API is a *very* complex API which has a rather limited application in fb2k environment, so it won't be implemented in SMP v2.x either (i.e. features it provides are just not worth the time it requires to implement it).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Majestyk on 2023-07-21 05:34:54
Is there a simple method to make a font using GdiDrawText or DrawString to appear upside down?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2023-07-21 09:04:39
I had the same problem and not founding a proper way to do it, without creating intermediate images, just used inverted chars.

Code: [Select]
"use strict";

include(fb.ComponentPath + 'docs\\Flags.js');

String.prototype.flip = function() {
const last = this.length - 1;
let result = new Array(this.length)
for (let i = last; i >= 0; --i) {
let c = this.charAt(i);
let r = flipTable[c];
result[last - i] = r !== void(0) ? r : c;
}
return result.join('');
}

const flipTable = {
a : '\u0250',
b : 'q',
c : '\u0254',
d : 'p',
e : '\u01DD',
f : '\u025F',
g : '\u0183',
h : '\u0265',
i : '\u0131',
j : '\u027E',
k : '\u029E',
//l : '\u0283',
m : '\u026F',
n : 'u',
r : '\u0279',
t : '\u0287',
v : '\u028C',
w : '\u028D',
y : '\u028E',
'.' : '\u02D9',
'[' : ']',
'(' : ')',
'{' : '}',
'?' : '\u00BF',
'!' : '\u00A1',
"\'" : ',',
'<' : '>',
'_' : '\u203E',
';' : '\u061B',
'\u203F' : '\u2040',
'\u2045' : '\u2046',
'\u2234' : '\u2235',
'\r' : '\n'
}
for (let i in flipTable) {flipTable[flipTable[i]] = i}

const gFont = gdi.Font('Segoe UI', 10);

function on_paint(gr) {
    const text = 'Hello'.flip();
    gr.SetTextRenderingHint(TextRenderingHint.ClearTypeGridFit);
    const w = gr.CalcTextWidth(text, gFont);
    const h = gr.CalcTextHeight(text, gFont);
    gr.GdiDrawText(text, gFont, 0x000000, (window.Width - w)/2, (window.Height - h)/2, window.Width, window.Height); // From top to bottom
    gr.SetTextRenderingHint(TextRenderingHint.SystemDefault);
    let x = (window.Width - w)/2;
    let y = (window.Height - h)/2 + 20;
    [...text].reverse().forEach((key, i) => {
        const w = gr.CalcTextWidth(key, gFont);
        gr.GdiDrawText(key, gFont, 0x000000, x, y, w, h, StringFormatFlags.DirectionVertical); // From top to bottom
        x += w;
    });
    x = (window.Width - w)/2;
    y += 20;
    [...text].reverse().forEach((key, i) => {
        const w = gr.CalcTextWidth(key, gFont);
        gr.GdiDrawText(key, gFont, 0x000000, x, y, w, h, StringFormatFlags.DirectionVertical); // From top to bottom
        y += h;
    });
}
Play with chars and flags.

Have not found a way to align text to top, i.e. 'H' does not measure in height the same than 'o', but CalcTextHeight keeps giving the same result for both (so I can not reduce the vertical offset per letter).
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Majestyk on 2023-07-25 06:29:53
Thanks for getting back. (I've been away)

This is what I was looking for. I tried ChatGPT but this is much better than what 'he' came up with. :)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TheQwertiest on 2023-07-30 23:14:04
A small status update: I've managed to switch jobs and relocate to Netherlands, which should secure my livelihood for mid-term (and hopefully long-term as well). It will be a little hectic while I'm settling down, but after that I should have enough free time and (more importantly :) ) mental energy to work on my components (especially once I secure a proper workstation instead of my subpar-performance netbook).

Meanwhile, I was working a bit on v2 of SMP in the background. It's still far from ready, but I wanted to share a sneak-peek on some of it's features.

One of the main goals of v2 is to make SMP much friendlier for JS devs, both for those who have experience working with JS (e.g. NodeJS, web API) and for those who don't. This is achieved by replacing most(all?) ad-hoc solutions with standard or standard-like solutions:
- New NodeJS-like package format instead of ad-hoc packages.
- Module import/export support instead of `include`.
- API rewrite:
  - 'Modulerised' API: all API is now accessible through built-in modules.
  - WebAPI-like/NodeJS-like API: replaced old API with standard analogues. E.g. `Graphics` > CanvasAPI, static hardcoded event callbacks >`addEventListener` in corresponding objects, `FileSystemObject` and various file text APIs > nodejs fs module.
  - Async/off-thread methods where needed: in v1 some methods perform very CPU intensive operations, which blocks the main thread and makes UI unresponsive. Async methods instead return a Promise which will be resolved in the worker thread, thus removing the blocking.
  - Huge performance and memory consumption improvements.
  - Lots of new stuff that was not possible or available in the v1.
- TypeScript type bindings for SMP API.
- v1 compatibility mode.

Progress on v2 can be tracked via this ticket: https://github.com/TheQwertiest/foo_spider_monkey_panel/issues/213

See ya all later and stay safe :)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Montchenot on 2023-07-31 00:49:43
Wonderful news! Thanks for your follow up!
Good luck with your new job!
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kahel on 2023-07-31 15:15:40
Sound good... have a nice (busy) relocation.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2023-07-31 17:09:41
Yuri, it is good to hear you're doing fine, hope you like the Netherlands and its folks.
You should make a diary and write about your Dutch adventures, I would buy it =)
Also have fun starting to learn the Dutch language =)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Gabriel Schwartz on 2023-08-26 13:35:22
Anyone knows how to automate this to download Reviews and Art Images for the entire library without going song by song?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TF3RDL on 2023-08-30 03:03:26
A small status update: I've managed to switch jobs and relocate to Netherlands, which should secure my livelihood for mid-term (and hopefully long-term as well). It will be a little hectic while I'm settling down, but after that I should have enough free time and (more importantly :) ) mental energy to work on my components (especially once I secure a proper workstation instead of my subpar-performance netbook).

Meanwhile, I was working a bit on v2 of SMP in the background. It's still far from ready, but I wanted to share a sneak-peek on some of it's features.

One of the main goals of v2 is to make SMP much friendlier for JS devs, both for those who have experience working with JS (e.g. NodeJS, web API) and for those who don't. This is achieved by replacing most(all?) ad-hoc solutions with standard or standard-like solutions:
- New NodeJS-like package format instead of ad-hoc packages.
- Module import/export support instead of `include`.
- API rewrite:
  - 'Modulerised' API: all API is now accessible through built-in modules.
  - WebAPI-like/NodeJS-like API: replaced old API with standard analogues. E.g. `Graphics` > CanvasAPI, static hardcoded event callbacks >`addEventListener` in corresponding objects, `FileSystemObject` and various file text APIs > nodejs fs module.
  - Async/off-thread methods where needed: in v1 some methods perform very CPU intensive operations, which blocks the main thread and makes UI unresponsive. Async methods instead return a Promise which will be resolved in the worker thread, thus removing the blocking.
  - Huge performance and memory consumption improvements.
  - Lots of new stuff that was not possible or available in the v1.
- TypeScript type bindings for SMP API.
- v1 compatibility mode.

Progress on v2 can be tracked via this ticket: https://github.com/TheQwertiest/foo_spider_monkey_panel/issues/213

See ya all later and stay safe :)
Hopefully, the visualizations like spectrum analyzer (https://codepen.io/TF3RDL/pen/poQJwRW) are possible through a non-standard API (since implementing WebAudio API might be completely pointless for fb2k environment except as a separate DSP component that implement these nodes as DSPs, which foo_dsp_effect does similarly for some of them), just like on Wallpaper Engine with web wallpapers (which gets spectrum data for stereo channels), that gets waveform data (since I've used to custom FFTs) of any channels unlike getFloatTimeDomainData method of AnalyserNode
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: ApacheReal on 2023-09-07 07:04:19
I made a change in JScommon.js  (line 975) for the Simple Playlist Manager sample and put the background image in the correct size.

Spoiler (click to show/hide)

Now I have to center it, does anyone know how to do it?

(https://i.postimg.cc/Rq1CSw3j/Screenshot-2023-09-07-080250.png) (https://postimg.cc/Rq1CSw3j)


Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: ApacheReal on 2023-09-07 13:39:33
I made a change in JScommon.js  (line 975) for the Simple Playlist Manager sample and put the background image in the correct size.

Spoiler (click to show/hide)

Now I have to center it, does anyone know how to do it?

(https://i.postimg.cc/Rq1CSw3j/Screenshot-2023-09-07-080250.png) (https://postimg.cc/Rq1CSw3j)

Resoveled:

Spoiler (click to show/hide)

(https://i.postimg.cc/JsPYKMrz/Screenshot-2023-09-07-144012.png) (https://postimg.cc/JsPYKMrz)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Majestyk on 2023-10-06 04:16:11

Can anyone, with some spare time on their hands, convert this JSPlaylist wallpaper script below so it can instead load already installed biography images? The images would come from a folder (say, Biography) with subfolders inside. Each subfolder would be the name of the Artist. So something like:

fb.ProfilePath + Biography + artist folder + artist jpg file

So an 'Abba' folder with 'Abba.jpg' inside.

Code: [Select]
// ===================================================== // Wallpaper

function setWallpaperImg(path, metadb) {
    var fmt_path = fb.TitleFormat(properties.wallpaperpath).Eval().replace(/^\.?\\/, fb.ProfilePath);
var fmt_path_arr = utils.Glob(fmt_path);
if (fmt_path_arr.length > 0) {
var final_path = fmt_path_arr[0];
} else {
var final_path = null;
}

if (metadb && properties.wallpapermode > -1) {
var tmp_img = utils.GetAlbumArtV2(metadb, properties.wallpapermode);
} else {
if (final_path) {
tmp_img = gdi.Image(final_path);
} else {
tmp_img = null;
}
}
if (!tmp_img) {
if (final_path) {
tmp_img = gdi.Image(final_path);
} else {
tmp_img = null;
}
}

p.wallpaperImg = null;
var img = FormatWallpaper(tmp_img, ww, wh, 2, 0, 0, "", true);
return img;
}
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: yetanotherid on 2023-11-18 17:09:16
No doubt it's because I'm an idiot, but I'm having a hard time working out where to begin when it comes to using Spider Monkey Panel.

I haven't written anything in javascript before, although I suspect learning what I need to know won't be too hard once I know how to get started, as my needs are fairly simple. I want to create a GUI element that displays track/file information to replace the Text Display component. I'm after something similar to the included text display sample script, although I don't need any right click options aside from choosing to display the playing track or the selected one.

What I need at the moment is an example of the syntax required for a GUI element to have the same colors as the DUI, only with a different font, and an example of how to display fb2k's title formatting as text. Hopefully that'll be enough to get me started. If there's a Wiki or help file with the info I'm after I must be too silly to find it, however if that's the case I'd be grateful if someone would point me in the right direction.

Thanks
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2023-11-20 19:06:36
If someone knows a way to bypass this bug (since I don't expect and update soon), please let me know.
https://github.com/TheQwertiest/foo_spider_monkey_panel/issues/225

Quote
function a() {
   const handleList =  plman.GetPlaylistItems(plman.PlayingPlaylist);
   const tags = fb.TitleFormat('$if($not(),1,0)').EvalWithMetadbs(handleList);
   console.log(tags);
}
a();

Should output all 1s. but as you can see it output 0s.

EDIT: It's a bug on $not implementation, but it can bypassed adding an argument to not, like $not("").
Thing is different components are applying TF expressions in a different way, giving different results.
https://github.com/TheQwertiest/foo_spider_monkey_panel/issues/225#issuecomment-1819647388
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Case on 2023-11-21 02:43:34
What makes you blame Spider Monkey Panel? Pretty sure every single instance of title format code in all components is sent to the core to be processed, except Title Formatting Sandbox seems to do its own parsing and appears to break the function as its output doesn't match core results.

The evaluation you are testing is nonsense, The term "$not()" evaluates to nothing as it's missing a variable to not. Your code is functionally equal to "$if(,1,0)".
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2023-11-21 08:49:28
Case have you read at all my link? xd like... thanks for repeating the same I said.

The easiest and fatest way to test a TF code is using a sandbox, so one could expect a TF sandbox SHOULD apply TF properly. And the error only appeared on SMP, so that was my first option, obviously. I already stated on the link the bug is not on SMP (?), but the most logical reason was SMP (your own words "every single instance of title format code in all components is sent to the core to be processed", so if I applied that logic to a sandbox... then SMP was the culprit).

Now, saying "$not()" is nonsense (which worked fine on the sandbox)... well, that's your opinion. Let me show you the nonsense on TF:
Code: [Select]
[$ifequal(%RATING%,5,1$not(0),0$not(0))] // 1 or 0
[$ifequal(%RATING%,5,1,0)] // outputs nothing
X
I'm not the one who has coded TF that way, but please don't tell me doing $not() is ridiculous (it is not in any programming language), while $if functions don't output boolean values at all and require hacking $not, $and to output things.  ::)  ::) I mean, maybe native TF doesn't allow $not(), but that's just a design decision, not nonsense.

Lets see more "nonsense" examples:
Code: [Select]
[$ifequal($ifequal(%RATING%,5,1,0),1,%date%,$add(%date%,1))] // 2018
[$ifequal($ifequal(%RATING%,1,1$not(0),0$not(0)),5,%date%,$add(%date%,1))] // 2019
$ifequal($ifequal(%RATING%,5,1,0),1,%date%,$add(%date%,1)) // 2018
$ifequal($ifequal(%RATING%,1,1$not(0),0$not(0)),5,%date%,$add(%date%,1)) // 2019
X

So there was a real reason to make use of $not() within $if functions, to follow the "nonsense" rules of TF. Now, if the sandbox is broken... great. xd And if I simply have to replace $not() with $not(""), so be it. But I don't see a reason to specify an argument when checking for false, it's totally non intuitive.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Case on 2023-11-21 09:37:06
You are missing the point. The "$not()" function can have its uses in logical operations, but it's used by giving it an argument that you want to negate for the test, like "$if($not(%artist%),No artist tag,Artist tag exists)".

Code: [Select]
[$ifequal(%RATING%,5,1$not(0),0$not(0))] // 1 or 0
[$ifequal(%RATING%,5,1,0)] // outputs nothing
The reason second line outputs nothing is because you are misusing the square brackets. They leave out the output if fields referenced inside are missing. It's meant for just tag fields so that you don't need to hide missing results with complex $if() functions. I think it's a bug that the output is affected by adding the $not() there. Anyway, the square brackets are not needed here as they have no missing tag field question marks to hide. The proper fix is to remove the square brackets and use just
Code: [Select]
$ifequal(%RATING%,5,1,0) // 1 or 0

[...]

Lets see more "nonsense" examples:
Code: [Select]
[$ifequal($ifequal(%RATING%,5,1,0),1,%date%,$add(%date%,1))] // 2018
[$ifequal($ifequal(%RATING%,1,1$not(0),0$not(0)),5,%date%,$add(%date%,1))] // 2019
$ifequal($ifequal(%RATING%,5,1,0),1,%date%,$add(%date%,1)) // 2018
$ifequal($ifequal(%RATING%,1,1$not(0),0$not(0)),5,%date%,$add(%date%,1)) // 2019
I think you made a mistake with your examples. The lines without $not() work logically just like they should. The lines with $not() are nonsensical. The inner $ifequal() returns either 0 or 1 and you compare it against 5 so it is never true.
Here too the square brackets are useless but fortunately don't affect anything.
But why do you have to write these in such complicated manner? The first variant can be simply written as
Code: [Select]
$ifequal(%RATING%,5,%date%,$add(%date%,1))
And it works exactly the same but is much easier to follow.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Sue Dunham on 2023-11-21 11:27:59
Change line 132 to this

Code: [Select]
properties.background.value = utils.ColourPicker(window.ID, properties.background.value);

and line 136...

Code: [Select]
properties.text.value = utils.ColourPicker(window.ID, properties.text.value);

I'm using the ColourPicker like this, but I'd like to be able to set its starting value to that stored property. At present, it always opens set to (0, 0, 0). Can this be done?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2023-11-21 11:55:34
It was an error typing then. The example is part of a much bigger script, I obviously know there is a more simple way to do output the same thing of the example.

Quote
[...] (conditional section)

Evaluates the expression between [ and ]. If it has the truth value true, its string value and the truth value true are returned. Otherwise an empty string and false are returned.

Example: [%artist%] returns the value of the artist tag, if it exists. Otherwise it returns nothing, when artist would return "?".
Honest question. You say I'm misusing brackets, but the docs clearly states it works for expressions. (?)

And that is reflected by $not() or $and() affecting the brackets.

Otherwise how do you do this?
Code: [Select]
[$if([%RATING%],$not("")$ifequal(%RATING%,5,1,0),)s] // 1s, 0s, nothing
[$if([%RATING%],$not("")$ifequal(%RATING%,5,1,0),)$ifequal(%DATE%,2018,s,o)] // 1s, 0o, nothing

Code: [Select]
[$if([%RATING%],$ifequal(%RATING%,5,1,0),)s] // nothing
[$if([%RATING%],$ifequal(%RATING%,5,1,0),)$ifequal(%DATE%,2018,s,o)] // nothing

Code: [Select]
$if([%RATING%],$ifequal(%RATING%,5,1,0),)s // 1s, 0s, s
$if([%RATING%],$not("")$ifequal(%RATING%,5,1,0),)$ifequal(%DATE%,2018,s,o) // 1s, 0o, o

X

You could convert that to...
Code: [Select]
$if([%RATING%],$not("")$ifequal(%RATING%,5,1s,0s),) // 1s, 0s, nothing
$if([%RATING%],$ifequal(%RATING%,5,1$ifequal(%DATE%,2018,s,o),0$ifequal(%DATE%,2018,s,o)),)// 1s, 0o, nothing

In complex expressions, being able to conditionally evaluate an entire branch (and not a tag) greatly simplifies the usage
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2023-11-21 11:56:18
Change line 132 to this

Code: [Select]
properties.background.value = utils.ColourPicker(window.ID, properties.background.value);

and line 136...

Code: [Select]
properties.text.value = utils.ColourPicker(window.ID, properties.text.value);

I'm using the ColourPicker like this, but I'd like to be able to set its starting value to that stored property. At present, it always opens set to (0, 0, 0). Can this be done?

It's a bug.
https://github.com/TheQwertiest/foo_spider_monkey_panel/issues/203
Use the version attached here:
https://github.com/regorxxx/Playlist-Manager-SMP/releases/tag/v0.9.0
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Case on 2023-11-21 13:05:04
Evaluates the expression between [ and ]. If it has the truth value true, its string value and the truth value true are returned. Otherwise an empty string and false are returned.
The wiki contains user-written content. That is not what official document says. Easy way to prove that square brackets don't return true value for evaluated expression: "$if([$ifequal(1,1,1,)],true,false)" will only return false. The result is false without square brackets too. They are meaningless when not producing output from tag fields.

The official document states
Quote
Discards contents of the bracket when no fields referenced inside are present. Commonly used to create parts of formatting scripts that are active only when relevant fields are found. Example: %artist% - [%album% / ]%title%

Otherwise how do you do this?
Code: [Select]
[$if([%RATING%],$not("")$ifequal(%RATING%,5,1,0),)s] // 1s, 0s, nothing
[$if([%RATING%],$not("")$ifequal(%RATING%,5,1,0),)$ifequal(%DATE%,2018,s,o)] // 1s, 0o, nothing

Using that syntax you would do it like this:
Code: [Select]
$if(%RATING%,$ifequal(%RATING%,5,1,0)s)) // 1s, 0s, nothing
$if(%RATING%,$ifequal(%RATING%,5,1,0)$ifequal(%DATE%,2018,s,o)) // 1s, 0o, nothing
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2023-11-21 14:16:56
What I need at the moment is an example of the syntax required for a GUI element to have the same colors as the DUI, only with a different font, and an example of how to display fb2k's title formatting as text.

You can use JScript Panel 3 and my included Text Display clone for this....

https://jscript-panel.github.io/gallery/text-display/

By default it always tracks UI colours and has its own $font function - easier than writing your own javascript. :P

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Sue Dunham on 2023-11-22 17:46:05
Public Service Announcement

I just spent more time than I intended learning that using the vertical positioning flags—DT_VCENTER and DT_BOTTOM—with the GdiDrawText method will not actually position the text elsewhere than at the top unless one also adds another flag, DT_CALCRECT. So, do that, then. :)

The other vertical positioning flag, DT_TOP, is the default setting with a value of zero.

Perhaps those who actually know javascript or Windows GUI methods already know this, but I am not one of those.

Now, I shall resume utterly abusing the volume slider in status bar + volume.js. It seems to respond poorly to being maybe-kinda resized and repositioned as one jacks around with the font size of the text around it. I begin to doubt the wisdom of making the font and font size into properties customizable with the context menu, but, by gum, I'll find the way somehow.  :o
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Majestyk on 2023-11-27 04:21:41
Is there a simple method (IE: plman...) to restore a removed playlist? I'd like to add that to JSPlaylist.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Majestyk on 2023-11-27 12:59:46
Is there a simple method (IE: plman...) to restore a removed playlist? I'd like to add that to JSPlaylist.

Ah... I forgot FB2K natively can do this. It's been so long since I used the built in pm. So I think I can do it through the fb.RunMainMenuCommand.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2023-11-27 13:27:48
There is no main menu command to run unless you mean opening the built in playlist manager??

SMP (and other scripting components) have always been able to restore deleted playlists. You just need to read the docs. Look for recycler.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel) Cant import packages
Post by: Shmingas. on 2023-12-10 12:19:58
Currently get an error everytime I try to import a package stating "Corrupted package: can't find `package.json`"

 I dont know if Im missing something ashmedly basic, or if something needs to be fixed.

Any help would be appreciated
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2023-12-10 14:03:16
Currently get an error everytime I try to import a package stating "Corrupted package: can't find `package.json`"

 I dont know if Im missing something ashmedly basic, or if something needs to be fixed.

Any help would be appreciated
Provide the package
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Shmingas. on 2023-12-10 20:59:03
Thanks for the assistance.

I've attempted to istall these packages (not both at the same time), and I get the same error with both.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2023-12-10 21:07:52
Those are not valid packages, not sure where you got them from...

Look at this one, which is valid. All the files are at the root, not a subfolder within the zip.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: fbuser on 2023-12-10 21:57:05
I've attempted to istall these packages (not both at the same time), and I get the same error with both.
You have downloaded the git main branches from the github repository as zip instead of the releases. You need to follow the "Releases" link on the right side of the page and download the package from there.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: srdn on 2023-12-11 12:10:56
You need to download another archive
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Archivist on 2023-12-21 15:42:49
Currently get an error everytime I try to import a package stating "Corrupted package: can't find `package.json`"

 I dont know if Im missing something ashmedly basic, or if something needs to be fixed.

Any help would be appreciated

Having the exact same issue with the QWR edition of the CaTRoX theme.

The Qwertiest's own instructions call for downloading the most recent iteration of the theme's release, and to extract the master zip, then drag subsequent zip package archives to the script package manager, at which point I receive the same error.
I have a "Packages" folder with "Control", "Menu", "Mini", "Seekbar" etc. which all have their own "package.json" files.

Honestly not sure what on earth I'm missing here?
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Gabriel Schwartz on 2023-12-22 15:37:33
AllMusic review is broken
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: TT on 2023-12-22 20:52:09
AllMusic review is broken

AllMusic fetching was broken because they relaunched their website ( new website structure ).

You can try the latest Biography version from WilB, which has fixed this issue:
https://github.com/Wil-B/Biography/releases/tag/v1.4.2

-TT
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kikimm on 2024-01-29 21:51:47
Back by unpopular demand is my ye olde sox spectrogram seekbar from the WSH panel mod days.

Hey Marc, thank you for developing this script!

I just made an account here because I can't solve my issue with it, my spectrogram is always black, maybe you can help me.


I followed all information online, installed everything correctly, set the right paths. I am not sure where the issue is.

I've attached screenshots below.

I hope you can help me.

Have a nice day :)

Best,
kiki


P.S. sorry for the formating, i haven't used a 2000's style forum board in a long time


MOD edit: replace missing /quote
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: kikimm on 2024-01-29 23:11:02
Back by unpopular demand is my ye olde sox spectrogram seekbar from the WSH panel mod days.

Hey Marc, thank you for developing this script!

I just made an account here because I can't solve my issue with it, my spectrogram is always black, maybe you can help me.


I followed all information online, installed everything correctly, set the right paths. I am not sure where the issue is.

I've attached screenshots below.

I hope you can help me.

Have a nice day :)

Best,
kiki


P.S. sorry for the formating, i haven't used a 2000's style forum board in a long time


MOD edit: replace missing /quote


I figured it out... By default "Only analyse tracks in library" was checked... Yeah, that's solved now.

Any tips on how to make the markings for the frequency cutoffs visible on the spectogram though? Looks all the same no matter if i analyse an mp3 192 or a lossless. Is it possible to have markings and not just the image? Like on the left image on the attached screenshot

Greets

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Gabriel Schwartz on 2024-01-30 15:49:13
AllMusic review is broken

AllMusic fetching was broken because they relaunched their website ( new website structure ).

You can try the latest Biography version from WilB, which has fixed this issue:
https://github.com/Wil-B/Biography/releases/tag/v1.4.2

-TT


That fixed it.

Thanks
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2024-01-30 17:23:16
Any tips on how to make the markings for the frequency cutoffs visible on the spectogram though? Looks all the same no matter if i analyse an mp3 192 or a lossless. Is it possible to have markings and not just the image? Like on the left image on the attached screenshot

I disabled it on purpose because enabled, it wouldn't be a functional seekbar. I wouldn't know where the position marker should start and end.

To change it, you'd have to refer to the SoX documentation and find the line in the script that executes sox command. It's been years and I have no interest in looking it up.

Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Majestyk on 2024-02-01 04:43:17
Can anyone tell me how to refresh/repaint this type of function? I have fonts changing colors in some areas but because this is outside 'gr' it won't change unless I manually refresh, like minimize/maximize.

This is from jsplaylist topbar.js

Code: [Select]
	this.setButtons = function () {

var color_txt = g_color_normal_txt;
var color_bg = g_color_normal_bg;
var bt_w = zoom(18, g_dpi);
var bt_h = zoom(18, g_dpi);

// normal close Image
this.close_off = gdi.CreateImage(bt_w, bt_h);
var gb = this.close_off.GetGraphics();
gb.SetSmoothingMode(2);
gb.SetTextRenderingHint(4);
gb.DrawString(String.fromCharCode(209), gdi_font(g_font_wd2.Name, g_font_wd2.Size - g_z6, 0), blendColors(color_bg, color_txt, 0.75), 0, 0, bt_w, bt_h, cc_stringformat);
gb.SetSmoothingMode(0);
this.close_off.ReleaseGraphics(gb);

// hover close Image
this.close_ov = gdi.CreateImage(bt_w, bt_h);
var gb = this.close_ov.GetGraphics();
gb.SetSmoothingMode(2);
gb.SetTextRenderingHint(4);
gb.DrawString(String.fromCharCode(209), gdi_font(g_font_wd2.Name, g_font_wd2.Size - g_z2, 0), color_txt, 0, 0, bt_w, bt_h, cc_stringformat);
gb.SetSmoothingMode(0);
this.close_ov.ReleaseGraphics(gb);

this.button = new button(this.close_off, this.close_ov, this.close_ov);
};
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Majestyk on 2024-02-01 07:22:45
I figured it out. I had to put p.topBar.setButtons() in on_notify_data
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: aelklirion on 2024-02-29 06:44:37
I think you are looking for this:
https://theqwertiest.github.io/foo_spider_monkey_panel/docs/script_showcase/single_panel_scripts/#track-properties

Thank you for your attention, Regor.
In fact, I had already taken a look at this Properties Panel, but it doesn't allow me to choose just a few items I would like to use. Normally I "simulate" a LED display in the Foobar skin using the "Item Details" component, available in ColumnsUI, where I can put the artist, the album (with the year), the number and the name of the song and also the playback time of the running track. I choose a nice font, a background color that deceives like a display and it suits me. The problem is that this component is annoying to handle because if you change its background color in a skin, it automatically changes in all skins, it is not independent, then every time I want to use a skin that I made a long time ago, it appears there with the wrong colors.
Whenever I find a problem similar to this in a component, I solve it by changing it to a similar Panel from Spider Monkey, which is spectacular, I love Spider Monkey, but I have many limitations to work with it because I am a layman in Javascript. And I didn't find a single panel where I could choose attributes to show just some basic track information to my liking.


I'm the exact same situation. I just want an SMP script that works exactly like Item Details, with a code that intuitevely allows one to change what tags appear. Specifically:
Track title
Artist
Album (year)
Time elapsed/track length

Item Details has two problems for me: you can't customize it differently for every layout (I want a white mode and night mode layout), and you also can't do advanced text formatting with it
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2024-02-29 07:09:52
You can use $rgb / $set_font with item details. Not sure what else you can mean by advanced text formatting,

Anyway, I'm going to pimp my alternative component. It's 32bit/64bit and works the same in Default UI and Columns UI. It has many more feature than any competitor. It can display album art, blurred backgrounds, colour emoji, supports exclusive title format fields not available in any other component...

https://jscript-panel.github.io/gallery/text-display/

Docs/requirements: https://jscript-panel.github.io/docs/

Extra docs for $rgb / $font: https://jscript-panel.github.io/docs/guides/font-rgb/

If you want day/night mode, you'd have to write you own javascript for that.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2024-02-29 17:26:11
Just for reference, a similar thing is technically possible on SMP. There is no font for flags though, nor emojis. Which personally I don't care.

X

Spent the morning hacking the JSP display script and creating from scratch the layout code to parse RGB and font functions and apply them when needed:
X

Code: [Select]
$font(Segoe UI,24,1)$rgb(200,50,50)
'(ෆ˙ᵕ˙ෆ)♥'$crlf()
$font(Segoe UI,24,1)$rgb(200,50,50)
[%title%$crlf()]
$font(Segoe UI,18)$rgb(200,200,50)
[%artist%$crlf()]
$font(Segoe UI,14)$rgb(0,0,0)
[%album% '('%date%')'$crlf()]
$font(Segoe UI,10)
[%__bitrate% kbps %codec% [%codec_profile% ][%__tool% ][%__tagtype%]]

The panel background is the same code of all my scripts which allows blur, transparencies, multiple gradient options, etc.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2024-02-29 18:37:31
And updated per second:
X
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2024-02-29 21:08:24
And wrapping font/rgb over multiple lines? Text alignment?


Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2024-02-29 21:59:43
xd not a competition, but all that seems possible with the current framework. This bit calculates the height along multiple lines with wrapping.
https://theqwertiest.github.io/foo_spider_monkey_panel/assets/generated_files/docs/html/GdiGraphics-MeasureStringInfo.html
And alignment is just a matter of setting the flags.

Anyway it's a pain to re-create the layout functions manually, so I will probably stick to something a bit simpler in terms of formatting.

Personally I have better things to do than this thing xd it was just a matter of showing it can be done and people is just lazy or have not tried to edit the current scripts to their needs. And in such case, just use marc's JSP script which is complete.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: aelklirion on 2024-03-01 06:58:07
Thanks guys, this is what I was looking.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2024-03-20 10:10:56
Spent some time today and here it is with wrapping in any alignment, mixing colors in same lines, etc. while it changes every second during playback.
X
X
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: Bollerkopp on 2024-03-20 20:56:57
@regor : Very nice. Could you share the script? :)
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2024-03-21 11:53:52
When it's done. Don't want to have tons of bug reports for a wip thing.

Currently addding support for all playlist-only fields, playlist name (both the JSP version and mine from dynamic queries) and extra functions.
Also a switchable scrollbar, maybe clickable links at some points, not sure.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2024-03-21 12:35:56
Code: [Select]
#PLAYLIST#$crlf()
$jsp3_since(%last_played%)$crlf()
$font(Segoe UI,24,700)
[%title%$crlf()]
$font(Segoe UI,18)
[%artist%$crlf()]
$font(Segoe UI,14)
[%album% '('%date%')'$crlf()]
$font(Segoe UI,10)
[%__bitrate% kbps %codec% [%codec_profile% ][%__tool% ][%__tagtype%]]

X

Showing support for $jsp3_since(%DATE_TAG%), %jsp3_playlist_name%, #PLAYLIST#, etc.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2024-03-21 13:48:43
Using the jsp3_ prefix is strange. It was meant to uniquely identify fields/functions unique to my component. Copying the functionality is fine but give them a different name starting with smp, xxx or something else.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: regor on 2024-03-21 15:57:24
Using the jsp3_ prefix is strange. It was meant to uniquely identify fields/functions unique to my component. Copying the functionality is fine but give them a different name starting with smp, xxx or something else.
Why? I simply want to support anything people can put on your panel (or my other scripts), so people don't have to "learn" different code for different scripts, and they would work as is on any theme out there. I see them like tag names.
I don't really care about the names though; I mean if you really want me to change it, fine; but I don't really see a compelling reason to not support already existing names.
Title: Re: Spider Monkey Panel (foo_spider_monkey_panel)
Post by: marc2k3 on 2024-03-21 16:04:06
Nah, you carry on.