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 348049 times) previous topic - next topic
Majestyk and 2 Guests are viewing this topic.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

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

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #651
- "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

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #652
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).

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #653
@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

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #654
@TheQwertiest
Just updated to foobar2000 1.6.4 (from early beta) and all working with SMP latest nightly.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #655
@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.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

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

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #657
This component supports ActiveX?

Re: Spider Monkey Panel (foo_spider_monkey_panel)

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

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #659
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`.


Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #661
Hi, I'm noob ...
Could you send me any link where I could see how to implement JS in foobar ?

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #662
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).

Re: Spider Monkey Panel (foo_spider_monkey_panel)

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

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #664
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?
I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #665
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)

Re: Spider Monkey Panel (foo_spider_monkey_panel)

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

Re: Spider Monkey Panel (foo_spider_monkey_panel)

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

Re: Spider Monkey Panel (foo_spider_monkey_panel)

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

Re: Spider Monkey Panel (foo_spider_monkey_panel)

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

 

Re: Spider Monkey Panel (foo_spider_monkey_panel)

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



Re: Spider Monkey Panel (foo_spider_monkey_panel)

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

Re: Spider Monkey Panel (foo_spider_monkey_panel)

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

Re: Spider Monkey Panel (foo_spider_monkey_panel)

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

Re: Spider Monkey Panel (foo_spider_monkey_panel)

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