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 script discussion/help (Read 282952 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

Re: JScript Panel script discussion/help

Reply #550
What is the best way to get a list of all values in a specific field? For example, how can I get a list of all artists in my music library (or in a playlist)?

I've been looking in Falfstaff's and Wilb's library browser scripts, but they are far too complex for me to extrapolate the code I'm looking for.
I tried with some loops, but all I got was foobar2000 unresponsive.
I'm late

Re: JScript Panel script discussion/help

Reply #551
Code: [Select]
// ==PREPROCESSOR==
// @import "%fb2k_component_path%samples\complete\js\lodash.min.js"
// @import "%fb2k_component_path%samples\complete\js\helpers.js"
// ==/PREPROCESSOR==

var tag = "artist"; //don't use %%

var tags = [];
var items = fb.GetQueryItems(fb.GetLibraryItems(), tag + " PRESENT");
for (var i = 0; i < items.Count; i++) {
var num = _.tf("$meta_num(" + tag + ")", items.Item(i));
for (var j = 0; j < num; j++) {
tags.push(_.tf("$meta(" + tag + "," + j + ")", items.Item(i)));
}
}
items.Dispose();
fb.ShowPopupMessage(_.uniq(tags.sort(), true).join("\n"));

Re: JScript Panel script discussion/help

Reply #552
Code: [Select]
// ==PREPROCESSOR==
// @import "%fb2k_component_path%samples\complete\js\lodash.min.js"
// @import "%fb2k_component_path%samples\complete\js\helpers.js"
// ==/PREPROCESSOR==

var tag = "artist"; //don't use %%

var tags = [];
var items = fb.GetQueryItems(fb.GetLibraryItems(), tag + " PRESENT");
for (var i = 0; i < items.Count; i++) {
var num = _.tf("$meta_num(" + tag + ")", items.Item(i));
for (var j = 0; j < num; j++) {
tags.push(_.tf("$meta(" + tag + "," + j + ")", items.Item(i)));
}
}
items.Dispose();
fb.ShowPopupMessage(_.uniq(tags.sort(), true).join("\n"));


Thanks for the script. What is the meaning of the underscore syntax? I often see it in your scripts, but couldn't find any reference.
I'm late

Re: JScript Panel script discussion/help

Reply #553
On the 2nd line of the example above, you'll see I import a file name lodash.min.js - don't try and read it because it's minified but lodash is a javascript library containing lots of useful functions that I use throughout my scripts.

I have to use an older version (3.10.1) which is compatible with windows script host used by the component. All the functions are documented here....

https://lodash.com/docs/3.10.1

Just to confuse things, it also lets you add your own functions which can be called using _.functionName so there are plenty of those throughout my scripts as well. These are not documented anywhere but most are defined inside helpers.js starting here...

https://github.com/19379/foo-jscript-panel/blob/master/component/samples/complete/js/helpers.js#L103

In that previous snippet, _.tf is my own custom function defined here...

https://github.com/19379/foo-jscript-panel/blob/master/component/samples/complete/js/helpers.js#L571

whereas _.uniq is part of lodash itself which is documented here...

https://lodash.com/docs/3.10.1#uniq


Re: JScript Panel script discussion/help

Reply #554
Is there a way to identify a playlist regardless of the index or playlist name?
I'm late

 

Re: JScript Panel script discussion/help

Reply #555
Feature request (forgive me if this has already been asked):

Is it possible to include support in a future version of JScript Panel for high-resolution monitors when viewing tooltip messages (the messages that appear when you hover over an object with a text caption)?

My new laptop has a 4k screen, which makes viewing these hover messages difficult.

Re: JScript Panel script discussion/help

Reply #556
The component supports custom fonts/sizes for tooltips but each script would need updating. If you were using my scripts, you need to open

samples\complete\js\helpers.js and edit line 51..

Code: [Select]
var tooltip = window.CreateTooltip();

so it becomes

Code: [Select]
var tooltip = window.CreateTooltip("Segoe UI", 20, 0);

The 20 is the font size in pixels and the 0 is style. You can change that to 1 if you want a bold font.

Using any other script, you need to edit window.CreateTooltip as above. It should appear only once in any script do don't just add it.

Re: JScript Panel script discussion/help

Reply #557
Is it DPI aware? That may be the issue they're experiencing.

Re: JScript Panel script discussion/help

Reply #558
No it isn't. It's entirely up to script authors if they want to cater for this sort of thing. I believe the registry can be queried to get the current DPI setting with WshShell..

Code: [Select]
var WshShell = new ActiveXObject("WScript.Shell");
var blah = WshShell.RegRead("HKCU\\....");

Here's a silly example with an extreme tooltip size made with the changes I mentioned in the previous post.


Re: JScript Panel script discussion/help

Reply #559
Well, it is true, most people still have 1080p or less screens. The rest can ask their favorite script authors to add HiDPI support to their scripts.

E: And for a second, I thought you posted a High DPI image, but the forum just shrank it with tags, until it was slightly larger than its physical resolution on my display.

Re: JScript Panel script discussion/help

Reply #560
That was my 2560x1440 desktop at 200%. As you can see, the rest of the destop and default UI elements are respecting it - the only things that aren't are my scripts. However, I'm working on adding DPI support for them to the next release so casual users won't have to edit scripts.

Re: JScript Panel script discussion/help

Reply #561
Code: [Select]
// ==PREPROCESSOR==
// @import "%fb2k_component_path%samples\complete\js\lodash.min.js"
// @import "%fb2k_component_path%samples\complete\js\helpers.js"
// ==/PREPROCESSOR==

var tag = "artist"; //don't use %%

var tags = [];
var items = fb.GetQueryItems(fb.GetLibraryItems(), tag + " PRESENT");
for (var i = 0; i < items.Count; i++) {
var num = _.tf("$meta_num(" + tag + ")", items.Item(i));
for (var j = 0; j < num; j++) {
tags.push(_.tf("$meta(" + tag + "," + j + ")", items.Item(i)));
}
}
items.Dispose();
fb.ShowPopupMessage(_.uniq(tags.sort(), true).join("\n"));


What does the Dispose method exactly do? Same question for all the dispose methods listed in the interfaces.txt document. I tried executing the script without that last-but-one line and nothing seems to change.
BTW are the methods mentioned in the interfaces.txt better defined in some other document?
I'm late


Re: JScript Panel script discussion/help

Reply #563
Can someone help me to adjust Br3tt's JS Smooth Browser script so that it works off of Album Artist instead of Artist? I don't want it splitting up all my compilation albums and split EPs.

Thanks!

Re: JScript Panel script discussion/help

Reply #564
@marc2003  Is there a quick way to change the font selection sizes for your sample scripts? Currently the options are 10, 12, 14, 16. Am looking to change to smaller intervals 10, 11, 12, 13 I tried looking into helpers.js and panels.js but couldn't find anything there.
Also, can type font and/or color font be changed?

Re: JScript Panel script discussion/help

Reply #565
Can someone help me to adjust Br3tt's JS Smooth Browser script so that it works off of Album Artist instead of Artist? I don't want it splitting up all my compilation albums and split EPs.
Code: [Select]
	tf_groupkey_artist: fb.TitleFormat("$if2($meta(album artist,0),Unknow Artist)"),
works for me.

Re: JScript Panel script discussion/help

Reply #566
Hi marc2003
I use your panel with a script to process new music files . I've got a working version but with a few annoying issues. I wonder if you can help;
1) I use thr RunContextComandWithMetadb to replay/gain a playlist selection, remove all embedded images and to optimise file layout and minimise file size. But these commands do not wait for completion. I have to catch the generated event to ensure the command has completed. Can we have a version of this command that blocks until completed?

2) Some of the commands above, such as remove images and optimise files, generate user interface prompts. Can these be bypassed in any way?

Once again thanks for your efforts in giving us the capability to customise foobar so much. ANy help greatfully appreciated.

Re: JScript Panel script discussion/help

Reply #567
The component supports custom fonts/sizes for tooltips but each script would need updating.

Thanks, I'll give this a try!

Is it DPI aware? That may be the issue they're experiencing.

Yes, this is what I was asking about, actually. If there's no support for this, then I'm happy to use the directions that marc2003 suggested.



Re: JScript Panel script discussion/help

Reply #570
Argh, thanks for spotting.

If anyone has this problem, it should be...

Code: [Select]
var panel = new _.panel('Musicbrainz', ['metadb']);

Re: JScript Panel script discussion/help

Reply #571
Hi Guys,
New to this Foobar thing, but it appeals to me because of the seemingly endless skinning possibilities, thanks due in no small part to all those clever guys who made the components/dlls etc allowing mortals like me to hook into.

I have searched the forums over the last few days but have not been able to find any posts that could point me towards a solution to my problem.

What I would like to do is close the "Console" and "Preferences" dialogs through a button on my JScript panel. I can open these dialogs easily through,
fb.RunMainMenuCommand("View/Console"); and
fb.RunMainMenuCommand("File/Preferences");

but cannot find an equivalent to close them by toggling my buttons.

Have I missed something obvious or is going to be a matter of some serious scripting?
Any pointers would be gratefully received.
Apologies if this has been raised before and I have missed the solution in the my search of the forums!
Cheers
mph64

Re: JScript Panel script discussion/help

Reply #572
Calling @TheQwertiest - their modified component might be able to do this, mine can't.

Re: JScript Panel script discussion/help

Reply #573
It seems I've been a bit careless with the last few sample updates. Some silly bugs have crept in which I can only apologise for. I'll try and test a bit more thoroughly for next time. It looks like I broke tooltips in the album art script and my attempts at DPI support in the track info +seekbar+buttons script was half baked. :/

Re: JScript Panel script discussion/help

Reply #574
marc2003, where are the options regarding font size and font name stored in your scripts? What would be the easiest way to modify/override them if I only want a specific font and size for the panel below?

Code: [Select]
// ==PREPROCESSOR==
// @name "Last.fm Similar Artists / User Charts"
// @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"
// @import "%fb2k_component_path%samples\complete\js\list.js"
// @import "%fb2k_component_path%samples\complete\js\lastfm.js"
// ==/PREPROCESSOR==

// Requires the "Guifx v2 Transports.ttf" font which can be downloaded from
// http://blog.guifx.com/2009/04/02/guifx-v2-transport-font/

var panel = new _.panel('Last.fm Similar Artists / User Charts', ['metadb']);
var lastfm = new _.lastfm();
var list = new _.list('lastfm_info', LM, TM-35, 0, 0);

panel.item_focus_change();

function on_notify_data(name, data) {
lastfm.notify_data(name, data);
}

function on_size() {
panel.size();
list.w = panel.w - (LM * 2);
list.h = panel.h - TM+50;
list.size();
}

function on_paint(gr) {
panel.paint(gr);
//gr.FillSolidRect(0, 0, panel.w, TM, panel.colours.header);
//gr.GdiDrawText(list.header_text(), panel.fonts.title, panel.colours.highlight, LM, 0, panel.w - (LM * 2), TM, LEFT);
list.paint(gr);
}

function on_metadb_changed() {
list.metadb_changed();
}

function on_mouse_wheel(s) {
list.wheel(s);
}

function on_mouse_move(x, y) {
list.move(x, y);
}

function on_mouse_lbtn_up(x, y) {
list.lbtn_up(x, y);
}

function on_key_down(k) {
list.key_down(k);
}

function on_mouse_rbtn_up(x, y) {
return panel.rbtn_up(x, y, list);
}

Also, I'd like to modify the script so it would cross reference my library and would only show similar artists which I don't have yet. Any ideas?