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: JScript Panel (Read 302497 times) previous topic - next topic
esa372 and 2 Guests are viewing this topic.

Re: JScript Panel

Reply #1200
I've made some inputbox improvements but I'm not doing a brand new release. I've simply updated the component archives on github with the updated script files. The component remains untouched with the same version number.


Re: JScript Panel

Reply #1201
I've made some inputbox improvements but I'm not doing a brand new release. I've simply updated the component archives on github with the updated script files. The component remains untouched with the same version number.

Sorry, didn't see this message (new page).

I can confirm the changes are perfect in all scaling. Thanks.

I also had a look at Wil-B/Library-Tree and that looks great! Not really an issue it only runs on x86 since pretty much all I use is not supported on x64 anyway.

I really hope someday there will be a wrapper under x64 that at least runs x86 visuals in a kinda sandbox.

Re: JScript Panel

Reply #1202
Is it possible for GetAlbumArt() to return if the image returned as the IJSImage is a file or embedded?

Re: JScript Panel

Reply #1203
Check the path of the image against the handle path.

Code: [Select]
var is_embedded = false;
var handle = fb.GetFocusItem();

if (handle) {
var img = handle.GetAlbumArt();
if (img) {
is_embedded = img.Path == handle.Path;
}
}

Path being a property of most images is new in JSP3.

https://jscript-panel.github.io/docs/interfaces/IJSImage/

Re: JScript Panel

Reply #1204
Check the path of the image against the handle path.

Code: [Select]
var is_embedded = false;
var handle = fb.GetFocusItem();

if (handle) {
var img = handle.GetAlbumArt();
if (img) {
is_embedded = img.Path == handle.Path;
}
}

Path being a property of most images is new in JSP3.

https://jscript-panel.github.io/docs/interfaces/IJSImage/
Perfect!
Thanks

Re: JScript Panel

Reply #1205
How do I get  the current state of PlaybackOrder in jscript3?

In WSHpanel fb.PlaybackOrder is available and contains the state. This is not available in jscript2/jscript3 to my knowledge.

However if you change the playbackorder from a jscript button the value of fb.PlaybackOrder within WSH has been changed accordingly (including the graphical display based on this value).

I need this value to be "known" in jscript to show a jscript button with an image displaying the current state of PBO.

Is there a global state variable available in jscript I'm overlooking?

Re: JScript Panel

Reply #1206
IIRC, WSH panel mod had fb.PlaybackOrder and plman.PlaybackOrder which did the same thing.

One of the first things I ever did was remove the fb variant. It's plman only.

https://jscript-panel.github.io/docs/namespaces/plman/


Re: JScript Panel

Reply #1207
IIRC, WSH panel mod had fb.PlaybackOrder and plman.PlaybackOrder which did the same thing.

Based on plman.PlabackOrder I can select the correct image now.

However if I change the PBO status with the (jscript2) button it doesn't repaint the button (WSH Display panel does BTW).
Tried multiple things in the code but I just cannot get it to update after a change of playbackorder. Only way I get the current and correct image is when I resize the window (and force an on_size I guess).

So where and how do I force a repaint of the PBO button to reflect the current state of playbackorder (even when it is changed via the Menu button)? I included the current test jscript2 PBO button script.

Would be much obliged.

Re: JScript Panel

Reply #1208
The WSH panel mod script will use this exact same callback.

https://jscript-panel.github.io/docs/callbacks/#on_playback_order_changednew_order_index

Nothing has changed in this regard.

Everything function prefixed on_XXX like this...

Code: [Select]
function on_playback_order_changed(new_index) {
   // do something
}

is triggered by the component forwarding messages from fb2k itself.

Re: JScript Panel

Reply #1209
I added to my code:

function on_playback_order_changed(new_index) {
//   window.RepaintRect(0, 0, 26, 22);
//   panel.size();
   buttons.update();
}

Small improvement. If you go to the button (hover) it changes the image to the corrrect one. If you unhover the correct image is shown as well. Unfortunately you have to hover to get the correct PBO representation in the first place.

I really feel kind of stupid. I created some 475K of PSS code and 180K of ELP code and everything works exactly as I planned/programmed. Unfortunately PSS does not support dropdown menu's and rightclick on either textbuttons or imagebuttons.
I just don't have a clue how jscript works. All I did so far is based on reverse engineering (which drives me nuts).

What do I have to add to the jscript code to force an update upon changing the playbackorder (not only on hover)?

Re: JScript Panel

Reply #1210
Code: [Select]
function on_playback_order_changed(new_index) {
   buttons.update();
   window.Repaint();
}

Just like most of my other scripts that react to various player events...

https://github.com/jscript-panel/component/blob/418edec427d371c3b700c51f8e4f26a3a0106245/samples/Playback%20Buttons.txt#L104-L122

Re: JScript Panel

Reply #1211
Code: [Select]
function on_playback_order_changed(new_index) {
   buttons.update();
   window.Repaint();
}

Phew. Thank you. This one does the job. I thought I tried the window.Repaint() one, but obviously not.

Anyway, next step will be cleaning up this button and migration to JS3. This is my last JS2 one except for the Artwork panel. Tried JS3 but that one does not show which image it is showing on mousewheel (Front cover, Back Cover, Disc, Icon, Artist, Picture 1/5)


Re: JScript Panel

Reply #1213
Hi Marc2k3,

Small issue with foobar2000 2.1 preview 2023-06-20 with jscript3  3.2.25.

When I use File - Add Location and add a new stream list.js crashes. If I reload it still crashes. When I play the newly added stream and hit reload it is fine.

See attaches screenshots

Thx

 


Re: JScript Panel

Reply #1216
Hi Marc,
Quick question for you. I'm struggling to set up a recursive function in the playlist organizer script.
It seems that when the function is called within the same function, it works but doesnt come back to finish the initial function (not sure i'm clear).
Would you happen to know if there is an issue in JScript ?
thanks

Re: JScript Panel

Reply #1217
Not really sure what you mean?? The simplest recursive function would be something like this...

Code: [Select]
function sqaure(n, max) {
    console.log(n * n);
    n++;
    if (n <= max) {
        square(n, max);
    }
}

square(1, 10);

You need to tell it when to stop otherwise you'll have an infinite loop of doom. :P

Re: JScript Panel

Reply #1218
Here is a simple test :
Code: [Select]
var data2 = [1,2,3,4,5];
function recurs(numb) {
for (i=0; i<data2.length;i++)
if (data2[i] == numb)
recurs(11);
else
console.log(data2[i]);
}
recurs(2);

The result is :
Code: [Select]
1
1
2
3
4
5
So when it reaches 2, it goes to a new loop (the recurs(11);), go through all the data2 and then, i wish when the
Code: [Select]
the recurs(11);
is done, it goes back to the first loop to finish it.
The result should be (in my opinion) :
Code: [Select]
1
1
2
3
4
5
3
4
5


Re: JScript Panel

Reply #1220
Computers may be stupid. The code logic is flawless, and the problem is a JS bug-feature from old days without a proper standard.
The problem is variable scope. No idea if 'use strict' is supported by JScript panel, but if it does, please USE IT. It's the default in SMP for a good reason.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode

Code: [Select]
var data2 = [1,2,3,4,5];
function recurs(numb) {
for (var i=0; i<data2.length;i++) { // Must set scope to i here!!
if (data2[i] == numb) {
recurs(11);
} else {
    console.log(data2[i]);
        }
    }
    return;
}
recurs(2);

Note the "var i ="  part. Without it, i is added as a global variable, so your second call at recurs(11) sets the variable to 5 after finishing and the first loop is ended at that point. You should always set the scope of a variable.

These errors are impossible with 'use strict' usage, since panel would crash immediately, giving you a warning about many bad coding practices.

Re: JScript Panel

Reply #1221
marc2k3:  I have added your Thumbs sample set to show an artist bio picture downloaded from Last.fm and underneath it the Last.fm Bio to a DUI panel in my fb2k v2.1, and it's amazing how fast and accurately they both work with radio stream metadata, they've transformed the GUI and I appreciate it!!

I would like to know if there is some extra script I can add to the end of one or both samples that, upon script unloading, would delete the contents of the js_data/artists folder of the subfolders with the artists' names and their contents of both the downloaded image and the Bio .js file.  You generously supplied a script to me earlier that did this with the contents of the spectrogram_cache folder.

I am using jscript panel 3 version 3.2.26.  Thanks for any help you can provide!

Re: JScript Panel

Reply #1222
Computers may be stupid. The code logic is flawless, and the problem is a JS bug-feature from old days without a proper standard.
The problem is variable scope. No idea if 'use strict' is supported by JScript panel, but if it does, please USE IT. It's the default in SMP for a good reason.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode

Code: [Select]
var data2 = [1,2,3,4,5];
function recurs(numb) {
for (var i=0; i<data2.length;i++) { // Must set scope to i here!!
if (data2[i] == numb) {
recurs(11);
} else {
    console.log(data2[i]);
        }
    }
    return;
}
recurs(2);

Note the "var i ="  part. Without it, i is added as a global variable, so your second call at recurs(11) sets the variable to 5 after finishing and the first loop is ended at that point. You should always set the scope of a variable.

These errors are impossible with 'use strict' usage, since panel would crash immediately, giving you a warning about many bad coding practices.

Thanks. 3 letters that made it. I cant possibly say how long i've been staring at my code wondering what was going on.

Re: JScript Panel

Reply #1223
Hi there, apologies if this is the wrong thread for me to post this.

I'm new to Foobar2k and I've recently installed JSPlaylist. It's working very well, my only issue is the default sorting of albums. I'd like the albums to sort by year , descending. How would I go about enforcing that?

Kind regards
Monolith

EDIT: I've figured it out, Thanks for developing such a great component!

Re: JScript Panel

Reply #1224
Jscript Panel 3.2.26, Foobar v2.1 x64 Preview 06-24-1023.

I am running the Thumbs sample (set to "Last.fm artist art" and "Automatic downloads") and Last.fm Bio concurrently in different panels.  I notice that when listening to radio streams that send artist/track metadata, when the song on the same stream changes, the Last.fm Bio panel will auto-update every time to the new artist.  However, the Last.fm artist art panel will change to empty and not update automatically, but only grab the new artist art when "Download now" is clicked--the autodownload option is only invoked when actually changing radio streams.  Is there a way to modify the Last.fm artist art Thumbs code so that it auto-updates when the same stream's metadata changes, like what already happens with Last.fm Bio?