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 294789 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Re: JScript Panel

Reply #1050
Quote
fb.RunMainMenuCommand

This is the main menu....



QSearch provides context menu commands. Not the same.

https://jscript-panel.github.io/docs/namespaces/fb/#fbruncontextcommandcommand

Thanks for your answer marc2k3.

I have used fb.RunContextCommand(command) and it works perfectly but only if the track is playing, which makes the option to create a button not so profitable.

Code: [Select]
buttons.update = function () {
var y = (Math.round((panel.h - bs) / 2)) + posi_horiz_bot;
this.buttons.lupa1 = new _button(panel.w - posi_vert_bot - (sep_bot * 2) - (bs * 2), y, bs, bs, { char : chars_cosi.lupa1, colour:colours.buttons }, null, function () { fb.RunContextCommand('QSearch/title HAS'); }, 'title HAS');
this.buttons.lupa2 = new _button(panel.w - posi_vert_bot - (sep_bot * 1) - (bs * 1), y, bs, bs, { char : chars_cosi.lupa2, colour:colours.buttons }, null, function () { fb.RunContextCommand('QSearch/album IS'); }, 'album IS');

}

If there is another better solution I would appreciate if you could tell me about it.

Re: JScript Panel

Reply #1051
If there is another better solution I would appreciate if you could tell me about it.
I would recommend you to read the docs first...
X
https://jscript-panel.github.io/docs/interfaces/IMetadbHandleList/#runcontextcommandcommand
Replace
Code: [Select]
fb.RunContextCommand('QSearch/title HAS');
With this or something similar
Code: [Select]
if (plman.ActivePlaylist !== -1) {
var handleList = plman.GetPlaylistSelectedItems(plman.ActivePlaylist);
if (handleList && handleList.Count !== 0) {
handleList.RunContextCommand("'QSearch/title HAS");
}
}

Re: JScript Panel

Reply #1052
For QSearch to work, the handle list count must be 1. And since you have multiple buttons, it would be best to create a re-usable function like this...

Code: [Select]
function qsearch(what) {
// prefer playing file if playing or use selected playlist item if not
var handle = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
if (handle) {
fb.CreateHandleList(handle).RunContextCommand('QSearch/' + what);
}
}

Code: [Select]
	this.buttons.lupa1 = new _button(panel.w - posi_vert_bot - (sep_bot * 2) - (bs * 2), y, bs, bs, { char : chars_cosi.lupa1, colour:colours.buttons }, null, function () { qsearch('title HAS'); }, 'title HAS');
this.buttons.lupa2 = new _button(panel.w - posi_vert_bot - (sep_bot * 1) - (bs * 1), y, bs, bs, { char : chars_cosi.lupa2, colour:colours.buttons }, null, function () { qsearch('album IS'); }, 'album IS');

If you don't want that behaviour, you can prefer the selected playlist item at all times regardless of what is playing...

Code: [Select]
function qsearch(what) {
var handle = fb.GetFocusItem();
if (handle) {
fb.CreateHandleList(handle).RunContextCommand('QSearch/' + what);
}
}

Or if you want it to work on an item selected from a library viewer like album list you can use fb.GetSelection() like this

Code: [Select]
function qsearch(what) {
var handles = fb.GetSelection();
if (handles.Count == 1) {
handles.RunContextCommand('QSearch/' + what);
}
}

Note that the behaviour of fb.GetSelection is controlled by File>Preferences>Display>Selection viewers.

Re: JScript Panel

Reply #1053
3.0.17 for fb2k 1.6.6+
3.2.3 for fb2k 2.0 Beta 18+

The main landing page now contains version info/download links for both versions.

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


Re: JScript Panel

Reply #1055
3.2.5 for fb2k 2.0 Beta 18+

- Prevent component from loading on unsupported versions of foobar2000.
- Add plman.GetQueryItems.
- Add plman.GetGUID.
- Add plman.FindByGUID.

https://github.com/jscript-panel/release/releases

Beta 18 was stated as a minium requirement since 3.2.0 was released but wasn't enforced. Now it is.

Re: JScript Panel

Reply #1056
I want to thank regor (#1051) and marc2k3 (#1052) for their great help in creating my panel3 buttons

Re: JScript Panel

Reply #1057
3.2.5 for fb2k 2.0 Beta 18+

- Prevent component from loading on unsupported versions of foobar2000.
- Add plman.GetQueryItems.
- Add plman.GetGUID.
- Add plman.FindByGUID.

https://github.com/jscript-panel/release/releases

Beta 18 was stated as a minium requirement since 3.2.0 was released but wasn't enforced. Now it is.
Hoping to see an SMP update someday XD

The GUID thing would have made mi life much easier for the manager.
Now that I think of it, does it match the 'playlists-v1.4' index and names and also the 'playlists-v2.0' file names?

playlist-E1629559-B78C-45BE-A2C2-804141CC5E29
0B92BFBD7E2CEE9E2CCBDC69CBC910A7
...

I could try to hack it by reading files, instead of relying on SMP methods.

Re: JScript Panel

Reply #1058
Yes, the GUIDs match the content of the playlists-v2.0 folder. One minor difference is that my strings are wrapped in {}

Code: [Select]
console.log(plman.GetGUID(0)); // {88340458-489F-4B8C-AF30-040B6F82F424}

This is because the windows API for transforming strings back in to GUIDs expects them.

edit: I don't think hacks would work because playlist files are not generated in the playlists folder for empty playlists.


Re: JScript Panel

Reply #1059
Hi guys, I am trying to refresh my FB skin to newer versions (guess I'm a masochist) and my seekbar which I stole from DarkOne long time ago broke. So I switched to sample seekbar.

However it crashes when I switch tracks
Code: [Select]
JScript Panel v2.6.0-Beta.2 (Seekbar by marc2003)
JavaScript runtime error:
Invalid procedure call or argument
File: <main>
Line: 26, Col: 3
The code is

Code: [Select]
function on_paint(gr) {

gr.FillRoundRect(seekbar.x, seekbar.y, seekbar.w, seekbar.h, 6, 5, seekbar.c1);
if (fb.IsPlaying && fb.PlaybackLength > 0) {
gr.SetSmoothingMode(2);
gr.FillSolidRect(seekbar.x, seekbar.y, seekbar.pos(), seekbar.h, seekbar.c2);
gr.FillRoundRect(seekbar.x, seekbar.y, seekbar.pos(), seekbar.h, 6, 5, seekbar.c2);

FillRoundRect is what's crashing the seekbar, solidRect doesn't - why?


Re: JScript Panel

Reply #1061
You've set the arc_width to be 6px so the rectangle width needs to be at least double that. You're using seekbar.pos() for the width which can be less than 12px when a track starts.
Thank you very much!

Re: JScript Panel

Reply #1062
Advance warning for JSPlaylist users: The next version for fb2k 2.0 will have support for collapsable headers removed.

If you want to keep this functionality then you can can take these steps right now.

- Download this: https://jscript-panel.github.io/files/jsplaylist.zip
- Extract the jsplaylist folder to your foobar2000 profile folder
- Replace the contents of any JS Playlist instance with the contents of JS Playlist.txt

Any future component updates will not be able to touch these files!

Obviously this will be unsupported and will not receive any future updates.

Re: JScript Panel

Reply #1063
3.2.6 for fb2k 2.0 Beta 18+ https://github.com/jscript-panel/release/releases

- Minor IThemeManager bug fix.
- JS Playlist has had support for collapsable group headers removed. See the above post if you want to preserve this functionality by downloading a standalone copy.
- The playlist manager built in to JS Playlist and Smooth Playlist Manager now expose the foobar2000 context menu for playlist content.
- The Spectrogram Seekbar scripts can now generate images for tracks longer than 1 hour in length. This requires ffmpeg 6.0.

Re: JScript Panel

Reply #1064
3.0.18 for fb2k 1.6.6 - 1.6.16 https://github.com/marc2k3/fb2k-archive/releases/tag/latest

- Minor IThemeManager bug fix.
- The Spectrogram Seekbar scripts can now generate images for tracks longer than 1 hour in length. This requires ffmpeg 6.0.

Re: JScript Panel

Reply #1065
 @marc2k3
For some reasons, after the update,  "plman.GetGUID(playlistIndex)" doesnt work anymore (maybe it's me).
I tried :
Code: [Select]
function getData() {  	
var data = [];
for (var i = 0; i < plman.PlaylistCount; i++) {
data.push({
name: plman.GetPlaylistName(i),
value: plman.GetPlaylistItemCount(i),
size: plman.GetPlaylistItems(i).CalcTotalSize(),
id: plman.GetGUID(i),
});
}
for (var i = 0; i < data.length; i++) {
console.log(data[i].name);
}
}

and i have a crash  :
Erreur d’exécution JavaScript
(translated from french) :
the object doesnt manage the method "GetGUID"



Re: JScript Panel

Reply #1066
Looks like you've downloaded the wrong version meant for fb2k 1.6.x. It's not available there.

The docs are tagged with the minimum version required for certain methods/properties.

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

Re: JScript Panel

Reply #1067
what an idiot i am. Sorry.

Re: JScript Panel

Reply #1068
Hello,
can somebody please help me how I can configure my Jscript-component step by step if I want to see more than 4 images during a song played in Foobar? All the images are always in one folder called "covers".
An my folders look like this:
Music-A-Artist Name-Song Name (incl. the mp3-files)-covers
Music-B-Artist Name-Song Name (incl. the mp3-files)-covers
Music-C-Artist Name-Song Name (incl. the mp3-files)-covers.......
etc.
Sorry, tried it many times but it seems that I am really stupid.

Re: JScript Panel

Reply #1069
Using the Thumbs sample, you can right click and set a folder path to a folder. It will display all images contained within.

It's very hard to determine your intent from what you wrote but assuming covers is a subfolder where the playing/selected track is, this would work

Code: [Select]
$directory_path(%path%)\covers




Re: JScript Panel

Reply #1070
3.0.19 for fb2k 1.6.6 - 1.6.16
3.2.7 for fb2k 2.0 Beta18+

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

- Fixes a bug with the 3rd party Lexilla library used for keyword highlighting in the Configuration Window.

If, like me, you didn't notice - it's because lower case words were fine. Only words with uppercase chars like Date, JSON, Array, etc were affected.


Re: JScript Panel

Reply #1071
I have a script here that renders a Seekbar in the WSH Panel Mod. This script should be configured to work in JScript3 as well.

Code: [Select]
DT_TOP = 0x00000000;
DT_LEFT = 0x00000000;
DT_CENTER = 0x00000001;
DT_RIGHT = 0x00000002;
DT_VCENTER = 0x00000004;
DT_BOTTOM = 0x00000008;
DT_SINGLELINE = 0x00000020;
DT_NOPREFIX = 0x00000800;

//--------

var g_font = gdi.Font("arial",18,1);
var g_font_rating = gdi.Font("Arial Unicode MS",25,0);
var g_fileinfo = null;

var g_drag = 0;
var g_drag_seek = 0;

var ww, wh, area;

//--------

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

function RGBA(r,g,b,a){
return ((a<<24)|(r<<16)|(g<<8)|(b));
}

//--------

function Separator(x) {
this.left = x;

this.draw = function (gr) {
gr.FillGradRect(this.left-1,0, 1, wh-1, 90, RGB(133,133,133), RGB(0,0,0));
gr.FillGradRect(this.left,0, 1, wh-1, 90, RGB(163,163,163), RGB(163,163,163));
gr.FillGradRect(this.left+1,0, 1, wh-1, 90, RGB(60,59,59), RGB(0,0,0));
}
}

function separatorsDraw(gr) {
for (i in Separators) {
Separators[i].draw(gr);
}
}

//--------

function TimeFmt(t){
var zpad = function(n){
var str = n.toString();
return (str.length<2) ? "0"+str : str;
}

var h = Math.floor(t/3600); t-=h*3600;
var m = Math.floor(t/60); t-=m*60;
var s = Math.floor(t);
if(h>0) return h.toString()+":"+zpad(m)+":"+zpad(s);
return m.toString()+":"+zpad(s);
}

// --- APPLICATION START

function on_paint(gr){
var pos = 0;
var length = fb.PlaybackLength;
var txt;

if(length > 0){
if(g_drag){
pos = area * g_drag_seek;
txt = "Seek " + TimeFmt(g_drag_seek * length) + " / " + TimeFmt(length);
}
else{
pos = area * (fb.PlaybackTime / length);  
var g_titlefmt = fb.TitleFormat("[%album artist% - ][%album% ]['['%date%']' - ]%title% >> $div($mul(100,%playback_time_seconds%),%length_seconds%) '%'");
txt = g_titlefmt.Eval();
}
}

gr.FillGradRect(4, 0, area, wh/2, 270, RGB(90, 90, 90), RGB(0, 0, 0));
gr.FillGradRect(4, wh/2, area, wh/2, 90, RGB(90, 90, 90), RGB(0, 0, 0));
gr.FillGradRect(0, 0, pos, wh/2, 270, RGB(0, 200, 200), RGB(0, 0, 0));
gr.FillGradRect(0,wh/2, pos, wh/2, 90, RGB(0, 200, 200), RGB(0, 0, 0));

gr.FillGradRect(2, 0, 1, wh-1, 90, RGB(163, 163, 163), RGB(163, 163, 163));
gr.FillGradRect(3, 0, 1, wh-1, 90, RGB(60, 59, 59), RGB(0, 0, 0));

separatorsDraw(gr);

gr.FillGradRect(ww-4, 0, 1, wh-1, 90, RGB(133, 133, 133), RGB(0, 0, 0));
gr.FillGradRect(ww-3, 0, 1, wh-1, 90, RGB(163, 163, 163), RGB(163, 163, 163));

gr.DrawRect(0, 0, ww, wh, 4.0, RGB(0,0,0));

gr.GdiDrawText(txt, g_font, RGB(255, 255, 255), 0, 0, ww, wh, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);

var tfo_rating_a = fb.Titleformat("$if(%rating%,$repeat($char(9733),%rating%),)");
var tfo_rating_b = fb.Titleformat("$if(%rating%,$repeat($char(9734),$sub(5,%rating%)),)");
var txt_rating_a = tfo_rating_a.Eval();
var txt_rating_b = tfo_rating_b.Eval();

gr.GdiDrawText(txt_rating_a, g_font_rating, RGB(0,255,0), ww-120, 0, 110, wh, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
gr.GdiDrawText(txt_rating_b, g_font_rating, RGB(255,0,0), ww-120, 0, 105, wh, DT_RIGHT | DT_VCENTER | DT_SINGLELINE);
}

function on_size(){
ww = window.Width;
wh = window.Height;
area = ww - 4;

Separators = {
one: new Separator((ww-4)/10),
two: new Separator((ww-4)/5),
three: new Separator(3*(ww-4)/10),
four: new Separator(2*(ww-4)/5),
five: new Separator(ww/2),
six: new Separator(3*(ww-4)/5),
seven: new Separator(7*(ww-4)/10),
eight: new Separator(4*(ww-4)/5),
nine: new Separator(9*(ww-4)/10)
}
}

function on_mouse_lbtn_down(x,y){
g_drag = 1;
}

function on_mouse_lbtn_up(x,y){
if(g_drag){
g_drag = 0;
g_drag_seek = x / area;
g_drag_seek = (g_drag_seek<0) ? 0 : (g_drag_seek<1) ? g_drag_seek : 1;
fb.PlaybackTime = fb.PlaybackLength * g_drag_seek;
}
}

function on_mouse_move(x,y){
if(g_drag){
g_drag_seek = x / area;
g_drag_seek = (g_drag_seek<0) ? 0 : (g_drag_seek<1) ? g_drag_seek : 1;
window.Repaint();
}
}

function on_playback_new_track(metadb){
window.Repaint();
}

function on_playback_stop(){
window.Repaint();
}

function on_playback_seek(time){
window.Repaint();
}

function on_playback_time(time){
window.Repaint();
}

// --- APPLICATION END

I can't do it with my basic scripting skills.
Maybe someone can help me here.

Thanks in advance.

Re: JScript Panel

Reply #1072
There's no point. WSH panel mod didn't suddenly stop working. The whole point of JScript Panel is that it supports bucket loads of new features that don't exist in other components. If you're not going to use those features, why bother?

Re: JScript Panel

Reply #1073
Ok, Thanks for the answer.

Actually I wanted to ban the WSH panel mod from my configuration. Because I have already implemented 2 other ads via JScript Panel, my Seekbar should also run over it. But I didn't get it.
Then it shouldn't be.

Re: JScript Panel

Reply #1074
Advance warning for JSPlaylist users: The next version for fb2k 2.0 will have support for collapsable headers removed.

I can live with that. I never liked that concept.