Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Spider Monkey Panel (foo_spider_monkey_panel) (Read 337571 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #775
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



My file structure looks like this



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


Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #776
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.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #777
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.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #778
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.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #779
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.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #780
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.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #781
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.


Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #782
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?


Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #784
Please, help.
I have never encountered such an error. What is the problem ?
When can this message appear?
UR5EQF. Ukraine

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #785
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.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #786
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.
UR5EQF. Ukraine

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #787
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');
}

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #788
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.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #789
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.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #790
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?


Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #791
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.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #792
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.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #793
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

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #794
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?

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #795
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, 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/');

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #796
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.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #797
@TheQwertiest you may want to add the scripts to your list 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

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #798
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 :)

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #799
Would it be possible to set lock states of playlists? It would be immediately added to Playlist tools, 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 slots and startup), while still allowing to replicate at least some of their use-cases.