HydrogenAudio

Hosted Forums => foobar2000 => 3rd Party Plugins - (fb2k) => Topic started by: marc2003 on 2015-11-11 05:33:08

Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-11-11 05:33:08
To keep the main JScript Panel thread (https://www.hydrogenaud.io/forums/index.php?showtopic=110499) for component updates/issues only, I've started this.

Although many scripts should work in WSH Panel Mod and JScript Panel, there are incompatibilities which are only going to increase as time goes forward.

First of all, here is how to update WSH Panel Mod scripts for JScript Panel:

https://github.com/19379/foo-jscript-panel/...r-JScript-Panel (https://github.com/19379/foo-jscript-panel/wiki/Updating-WSH-Panel-Mod-scripts-for-JScript-Panel)
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-11-11 05:40:00
New JScript sample lastfm bio.txt used in chooser panel crashes. The other text samples I used (properties & thumbs) work fine. Error message below.

Code: [Select]
JScript Panel (Panel Receiver by marc2003): Microsoft JScript runtime error:
'this.content.length' is null or not an object
Line: 1, Col: 1
<source text only available at compile time>


Well it works for me so try putting the bio script in a fresh panel and see if you get the same error. If you do, try browsing wsh_data\artists\WHOEVER IT WAS and deleting the bio.www.last.fm.json file.
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-11-11 10:46:12
@Falstaff, I just installed your SmoothBrowser script and noticed a couple of things...

This can be removed from the preprocessor section...

Code: [Select]
// @feature "v1.4"
// @feature "watch-metadb"


Also...

Code: [Select]
if (!("FormatDuration" in utils))


That's in WSH Panel Mod v1.6.3 so you need to use something only available in JScript Panel...

Code: [Select]
if (!("ShowAutoPlaylistUI" in plman))
Title: JScript Panel script discussion/help
Post by: bdport67 on 2015-11-13 15:44:29
question concerning art viewer

is there a way to show a jpg in a top level folder that does not have media in it?
Kinda like a placeholder say for a band name folder when there are album directories below

currently if I have more than 1 folder in a band directory it defaults to the first found art in the first found folder
even if I have art in the "band" folder(but no media)
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-11-13 15:53:53
File>Preferences>Display>Album art

Code: [Select]
..\image.jpg


Title: JScript Panel script discussion/help
Post by: bdport67 on 2015-11-13 16:02:33
File>Preferences>Display>Album art

Code: [Select]
..\image.jpg

hmm?
doesnt seem to work or Im not understanding
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-11-13 16:14:32
the ..\ tells it to look in the parent folder. also, what image gets displayed depends on the order it appears in the list. if you put it before the pattern that gets the art from the same folder as the music then it will always override when it exists. if it goes after then it won't be displayed when there is art present in the same folder.
Title: JScript Panel script discussion/help
Post by: bdport67 on 2015-11-13 16:19:18
the ..\ tells it to look in the parent folder. also, what image gets displayed depends on the order it appears in the list. if you put it before the pattern that gets the art from the same folder as the music then it will always override when it exists. if it goes after then it won't be displayed when there is art present in the same folder.

ok I was thinking thats what you meant
poking a bit more
see if I can find a combo that works
Title: JScript Panel script discussion/help
Post by: bdport67 on 2015-11-13 16:27:51
the ..\ tells it to look in the parent folder. also, what image gets displayed depends on the order it appears in the list. if you put it before the pattern that gets the art from the same folder as the music then it will always override when it exists. if it goes after then it won't be displayed when there is art present in the same folder.

ok I was thinking thats what you meant
poking a bit more
see if I can find a combo that works

ok so maybe its my lazyness thats catching up with me 
my default art search pattern is *.jpg(*bmp,*.png) as I don't have my cover art all name formatted(Front,cover,back etc)
(put a jpg in the folder,whatever its name and wildcard it)

does this make a difference?

Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-11-13 23:02:32
No. foobar works its way from top to the bottom of the list and stops whenever an image is found.
Title: JScript Panel script discussion/help
Post by: MachineHead on 2015-11-14 10:23:07
Well it works for me so try putting the bio script in a fresh panel and see if you get the same error. If you do, try browsing wsh_data\artists\WHOEVER IT WAS and deleting the bio.www.last.fm.json file.


Removing the json file doesn't help entirely. It will repeatedly crash on one artist in particular every time. (hed)PE, if selected from any library browser or filter, causes it to fold instantly. Naming issue perhaps? WSH version works flawlessly yet.
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-11-14 12:14:02
That artist works fine for me with JScript panel so it's not that. I think your best bet is to stick with WSH panel mod.
Title: JScript Panel script discussion/help
Post by: MachineHead on 2015-11-14 12:29:28
Already switched back. Error spam below.

Code: [Select]
JScript Panel (Panel Receiver by marc2003): JavaScript runtime error:
Unable to get property 'length' of undefined or null reference
Line: 1262, Col: 25
<source text only available at compile time>
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-11-14 12:38:32
If you're going to report errors, don't use the panel receiver script because it's impossible to tell what file/line it's referring to.
Title: JScript Panel script discussion/help
Post by: MachineHead on 2015-11-14 12:51:33
Sorry about that. In this case it triggers on LastFM Bio.
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-11-14 14:04:19
Yeah, you mentioned that in your original post. How else do you think I tested it?

Seeing as my previous post was too cryptic, let's just forget it. You use WSH panel mod and don't ever bother me again. 
Title: JScript Panel script discussion/help
Post by: MachineHead on 2015-11-14 14:30:19
File: Desktop\foobar2000-5555\js_marc2003\js\text.js
Line: 261, Col: 25
Title: JScript Panel script discussion/help
Post by: Skibbi on 2015-11-14 20:53:53
Dragging & dropping folders with mp3 over JScript Paned doesn't work in Windows 10. Is it a limitation of the component?
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-11-15 01:01:56
Drag/dropping files on to the panel works fine. You cannot drag files out though - that is a limitation of the component.

JSplaylist is a fully working example: https://github.com/19379/jsplaylist-mod (https://github.com/19379/jsplaylist-mod)

That script has been broken the last few days as I forgot to update paths in it when I renamed a folder. It is working now though.
Title: JScript Panel script discussion/help
Post by: bas on 2015-11-15 03:09:20
I am using HiDPI settings on Windows 10 (200%), and with the new JScript Panel the tooltips are appearing very small.
With WSH Panel Mod the tooltips used to be properly scaled.

(http://i.imgur.com/RpCQ1pO.jpg)

Hopefully this can be fixed.

Thanks & regards,
bas
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-11-15 03:37:03
Search your script for window.CreateTooltip and then add your font name/size/style.

https://github.com/19379/foo-jscript-panel/...es.txt#L546L549 (https://github.com/19379/foo-jscript-panel/blob/5413fde00760437b4fa85e4d008f21723fc35757/foobar2000/foo_jscript_panel/docs/Interfaces.txt#L546L549)

BTW, WSH panel mod didn't make tooltips bigger automatically. They must have been coded in script somewhere using on_tooltip_custom_paint which JScript Panel doesn't support. I've updated my wiki page with this info...

https://github.com/19379/foo-jscript-panel/...r-JScript-Panel (https://github.com/19379/foo-jscript-panel/wiki/Updating-WSH-Panel-Mod-scripts-for-JScript-Panel)

Title: JScript Panel script discussion/help
Post by: Case on 2015-11-15 07:57:58
The LastFM bio panel crashes if the download fails for any reason. When the json file is zero bytes in size this.content is null at https://github.com/19379/js-marc2003/blob/m...js/text.js#L250 (https://github.com/19379/js-marc2003/blob/master/js/text.js#L250) and you can't access length element of null object. You can fix crashing by adding "|| !this.content" before you check the length. It might also make sense to report to console potential issues with the bio download.
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-11-15 09:01:14
^That would also cause the script to crash in WSH panel mod but Machinehead insists that works ok...

edit: It has now been fixed...

https://github.com/19379/js-marc2003/releases (https://github.com/19379/js-marc2003/releases)
Title: JScript Panel script discussion/help
Post by: bas on 2015-11-15 14:18:03
Search your script for window.CreateTooltip and then add your font name/size/style.

https://github.com/19379/foo-jscript-panel/...es.txt#L546L549 (https://github.com/19379/foo-jscript-panel/blob/5413fde00760437b4fa85e4d008f21723fc35757/foobar2000/foo_jscript_panel/docs/Interfaces.txt#L546L549)

BTW, WSH panel mod didn't make tooltips bigger automatically. They must have been coded in script somewhere using on_tooltip_custom_paint which JScript Panel doesn't support. I've updated my wiki page with this info...

https://github.com/19379/foo-jscript-panel/...r-JScript-Panel (https://github.com/19379/foo-jscript-panel/wiki/Updating-WSH-Panel-Mod-scripts-for-JScript-Panel)


Thank you for your reply. I use window.CreateTooltip("Segoe UI", 24, 0) now in order to double the font size, which is working fine.
BTW, I didn't use on_tooltip_custom_paint anywhere in my scripts. But passing the font parameters explicitly resolves my issue anyway.

Regards, bas
Title: JScript Panel script discussion/help
Post by: WilB on 2015-11-16 18:11:51
    I've ported YouTube Track Manager to work with  JScript Panel.

    YouTube Track Manager was originally a database search  companion for the foo_youtube (https://www.hydrogenaud.io/forums/index.php?showtopic=104379) plug-in,  but now offers much more, including comprehensive discography, track choosers, operation  with the media library and a nowplaying display. Here is an updated summary of  the main features:

                                    For further details, see earlier posts here (https://www.hydrogenaud.io/forums/index.php?s=&showtopic=105522&view=findpost&p=890289) or  here (https://www.hydrogenaud.io/forums/index.php?s=&showtopic=105522&view=findpost&p=909160).  Download the latest release (YouTube Track Manager v2.2) here (https://www.hydrogenaud.io/forums/index.php?s=&showtopic=105522&view=findpost&p=911008).

The updated screenshot  shows YouTube Track Manager in the left panel with a top 50 loaded into a  playlist on the right

(http://i.imgur.com/JAhxZFZ.png)


Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-11-17 04:48:25
I had my Musicbrainz script crash on me yesterday so I've uploaded a fix for it.

https://github.com/19379/js-marc2003/releases (https://github.com/19379/js-marc2003/releases)

    I've ported YouTube Track Manager to work with  JScript Panel.


Nice. 
Title: JScript Panel script discussion/help
Post by: Scrummble on 2015-11-19 18:08:09
Help needed - Is this a bug?

The method "GetPlaylistSelectedItems" with callback "on_item_focus_change" does not seem well in my scripts.
I used scripts like this:
Code: [Select]
var font = gdi.Font(fb.TitleFormat("%theme_font%").Eval(), 12, 2);
var margin_x = 30;
var handles, displayed;

function reload() {
    handles = plman.GetPlaylistSelectedItems(plman.ActivePlaylist);
    if (handles.Count < 2) {
        displayed = plman.PlaylistItemCount(plman.ActivePlaylist) + " items / " + utils.FormatDuration(plman.GetPlaylistItems(plman.ActivePlaylist).CalcTotalDuration()) + " / " + utils.FormatFileSize(plman.GetPlaylistItems(plman.ActivePlaylist).CalcTotalSize());
    } else {
        displayed = "Selected " + handles.Count + " of " + plman.PlaylistItemCount(plman.ActivePlaylist) + " items / " + utils.FormatDuration(handles.CalcTotalDuration()) + " / " + utils.FormatFileSize(handles.CalcTotalSize());
    }
}

function on_size() {
    if (!window.Width || !window.Height) return;
    handles = plman.GetPlaylistSelectedItems(plman.ActivePlaylist);
    reload();
}

function on_paint(gr) {
    gr.SetSmoothingMode(4)
    gr.FillSolidRect(0, 0, window.Width, window.Height, 0xaa111111);
    gr.FillGradRect(0, window.Height - 12, window.Width, 12, 90, 0x00000000, 0x88000000);
    gr.GdiDrawText(displayed, font, 0xffffffff, margin_x, 4, window.Width - 2 * margin_x, 16, 0x00000001 | 0x00000004 | 0x00008000);
}

function on_item_focus_change(playlist, from, to) {
    reload();
    window.Repaint();
}

And the displayed number of selected tracks went wrong. Everytime I use main menu command "Edit/Select all", the displayed number never changed.
When using ELPlaylist, selecting any single track worked correctly, but if selected a whole group, things went wrong like above.
In addition, I tried to avoid the GPSI method, and used the scripts below instead:
Code: [Select]
function reload() {
    var nppl = plman.ActivePlaylist;
    var total = plman.PlaylistItemCount(nppl);
    var evtg = plman.GetPlaylistItems(nppl)
    var selected = 0;
    var dur = 0;
    var siz = 0;
    for (var i=0; i<total; i++) {
        if (plman.IsPlaylistItemSelected(nppl, i)) {
            selected++;
            dur += evtg.Item(i).Length;
            siz += evtg.Item(i).FileSize;
        };
    }
    
    if (selected < 0) {
        displayed = total + " items / " + utils.FormatDuration(evtg.CalcTotalDuration()) + " / " + utils.FormatFileSize(evtg.CalcTotalSize());
    } else {
        displayed = "Selected " + selected + " of " + total + " items / " + utils.FormatDuration(dur) + " / " + utils.FormatFileSize(siz);
    }
}

But things just remained the same.
Title: JScript Panel script discussion/help
Post by: Scrummble on 2015-11-19 18:23:36
Alright, here's some further discovery.
The callback "on_item_focus_change()" is not called when using "Edit/Select all".
As in ELPlaylist, the callback is called, but its output is still not ideal.
Still wondering why.
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-11-19 18:55:10
replace on_item_focus_change() with on_selection_changed().
Title: JScript Panel script discussion/help
Post by: Scrummble on 2015-11-19 18:56:53
OK, it seemed to be solved with the method "on_playlist_items_selection_change()".
I found it in Br3tt's JS Smooth Playlist (thanks). Why isn't it referred in the docs?

Code: [Select]
on_playlist_items_selection_change()
on_selection_changed()
on_item_selection_change()
on_item_focus_change()


They look so similar. Could anyone explain their difference to me?
Title: JScript Panel script discussion/help
Post by: Scrummble on 2015-11-19 18:58:29
replace on_item_focus_change() with on_selection_changed().

Thanks. I am still wondering what differs them two.
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-11-19 19:18:31
Code: [Select]
on_playlist_items_selection_change()


That was missing from the docs so I need to update them. According to the original docs, it was added as a workaround for 3rd party playlist viewers not working with on_selection_changed(). So they're basically the same thing.

on_item_focus_change only triggers when the focused item has changed. Using Edit>Select all doesn't change the focused item.

And there is no such thing as on_item_selection_change().
Title: JScript Panel script discussion/help
Post by: Scrummble on 2015-11-20 10:34:47
Code: [Select]
on_playlist_items_selection_change()


That was missing from the docs so I need to update them. According to the original docs, it was added as a workaround for 3rd party playlist viewers not working with on_selection_changed(). So they're basically the same thing.

on_item_focus_change only triggers when the focused item has changed. Using Edit>Select all doesn't change the focused item.

And there is no such thing as on_item_selection_change().

Yes, that's the exact answer to the problem.
Thanks for the help.
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-11-20 11:14:18
I just realised on_playlist_items_selection_change() wasn't in the original docs either. My previous post about the workaround was taken from the changelog.

If you want the updated file to go in your docs folder, you can download it here:

https://raw.githubusercontent.com/19379/foo...s/Callbacks.txt (https://raw.githubusercontent.com/19379/foo-jscript-panel/master/foobar2000/foo_jscript_panel/docs/Callbacks.txt)

I'll update the component download later on.
Title: JScript Panel script discussion/help
Post by: Scrummble on 2015-11-20 20:05:36
Another question.
When drawing a gradrect over a semitransparent solidrect, an unexpected black border appears.
Just like this: http://imgur.com/qjrTKl6 (http://imgur.com/qjrTKl6)
(It's very dark; a black horizontal line in the middle; you may miss it)
I tried to change the smoothing mode, but it only got lightened, not disappeared.
Is this a bug in GDI or something like that? or I just used the wrong interface function?
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-11-20 20:44:32
This issue has been raised before and the original developer of WSH panel mod tried to fix it but it didn't go to plan....

https://www.hydrogenaud.io/forums/index.php...st&p=705543 (https://www.hydrogenaud.io/forums/index.php?s=&showtopic=70363&view=findpost&p=705543)

It seems from the preceding post that you can workaround it by increasing/decreasing the rectangle height by 1px.
Title: JScript Panel script discussion/help
Post by: Scrummble on 2015-11-21 08:51:15
This issue has been raised before and the original developer of WSH panel mod tried to fix it but it didn't go to plan....

https://www.hydrogenaud.io/forums/index.php...st&p=705543 (https://www.hydrogenaud.io/forums/index.php?s=&showtopic=70363&view=findpost&p=705543)

It seems from the preceding post that you can workaround it by increasing/decreasing the rectangle height by 1px.


Thanks for the answer. May it be fixed in the component, anyway? It may be problematic in adjustable DPIs...
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-11-21 10:07:16
From what I've read, the only "fixes" are hacks like adjusting the width/height/angle. From some quick testing, adjusting the angle by a degree or 2 can work rather well, assuming the dimensions aren't too small.

While I could implement this in the component, there's a possibility it could break some existing scripts that have worked fine up until this point. I'm not prepared to take that kind of risk so I'd rather keep the component behaviour consistent and let script writers fix these issues as they encounter them.
Title: JScript Panel script discussion/help
Post by: Scrummble on 2015-11-21 13:04:58
From what I've read, the only "fixes" are hacks like adjusting the width/height/angle. From some quick testing, adjusting the angle by a degree or 2 can work rather well, assuming the dimensions aren't too small.

While I could implement this in the component, there's a possibility it could break some existing scripts that have worked fine up until this point. I'm not prepared to take that kind of risk so I'd rather keep the component behaviour consistent and let script writers fix these issues as they encounter them.

Adjusting the angle by 1 degree worked. This idea is brilliant.
Title: JScript Panel script discussion/help
Post by: Scrummble on 2015-11-22 20:28:35
Another question:
In a single callback, is window.Repaint() only available to be called once?
i.e. If I use more than one window.Repaint() in one callback, is it that only the first one worked, and the others are ignored?

The situation is:
I have multiple rectangles on screen. The width of each rectangle is determined by the width of texts in it.
The method gr.CalcTextWidth(str, IGdiFont) can only be called within on_paint(gr), so the widths are not certain until a window.Repaint() is called.
In a callback, all the texts could be changed, so everything (including the text widths) needs to be refreshed. After the refreshment, some calculation should be done, and it need to be repainted again.
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-11-22 21:00:37
First of all, you can call window.Repaint as often as you like.  The consequence of that may be increased CPU usage especially with large panels layering text/rectangles over images. For plain backgrounds, it usually isn't an issue. It's crude but I use Windows Task Manager to check...

However, in this instance you don't need to call window.Repaint. You can use temporary graphics like this...

Code: [Select]
function CalcTextWidth(value, font) {
    var temp_bmp = gdi.CreateImage(1, 1);
    var temp_gr = temp_bmp.GetGraphics();
    var width = temp_gr.CalcTextWidth(value, font);
    temp_bmp.ReleaseGraphics(temp_gr);
    temp_bmp.Dispose();
    temp_gr = null;
    temp_bmp = null;
    return width;
}


then

Code: [Select]
var font = gdi.Font("Segoe UI", 16);
var text = "fooby dooby doo";
var text_width = CalcTextWidth(text, font);


I don't think this has been documented - I just picked it up from other people's scripts. I'll stick something on my wiki pages in the next day or two with some more examples.
Title: JScript Panel script discussion/help
Post by: Scrummble on 2015-11-23 00:17:53
That's really a good idea - I should take a note.
Thanks.
Title: JScript Panel script discussion/help
Post by: Scrummble on 2015-11-24 01:27:33
Sorry it's me again......
Now I'm learning about timers, and wondering that, within
Code: [Select]
window.SetInterval(function() {
HERE
},interval)

, what is the behaviour of keyword "this"?
Code: [Select]
this.refresh = function () {
    if (this.refresh_frame_count != 0) {
        window.ClearInterval(this.refresh_timer);
        this.refresh_frame_count = 0;
        this.refresh_timer = false;
    }
    window.RepaintRect(this.x, this.y, this.w, this.h);
    this.refresh_timer = window.SetInterval(this.refresh_nested, this.refresh_interval);
}

this.refresh_nested = function () {
    if (this.refresh_frame_count >= 1000 / this.refresh_interval) {
        window.ClearInterval(this.refresh_timer);
        this.refresh_frame_count = 0;
        this.refresh_timer = false;
    } else {
        this.refresh_frame_count ++;
        window.RepaintRect(this.x, this.y, this.w, this.h);
    }
}

This part of code belong to example_object.
In this example, if I call "example_object.refresh", it only refreshes once, and the timer doesn't seem to work.
But once I changed all "this" in the code of "this.refresh_nested" to "example_object", the code worked properly, to refresh 25 times in a second.

I am confused by now. the keyword "this" is too convenient for me to be adapted. And given that the exact name of the used reference is uncertain:
Code: [Select]
var panel = new Array();
panel.push(new example_object);
panel.push(new example_object2);

(I used this kind of code because it's easy to form something like below)
Code: [Select]
function on_mouse_lbtn_down(x, y) {
    for (i = 0; i < panel.length; i++) {
        if (x >= panel[i].x && x < panel[i].x + panel[i].w && y >= panel[i].y && y < panel[i].y + panel[i].h) {
            panel[i].lbtn_down(x, y);
        }
    }
}

I even don't know how to reference the correct variable name in "this.refresh_nested", if "this" is not an option.
Wait. This is hilarious. there actually is a "this" in the workable version of code.
Code: [Select]
this.refresh_timer = window.SetInterval(this.refresh_nested, this.refresh_interval);

"this.refresh_nested". How can that "this" work while the "this"'s within itself cannot?
Desperate.

Appendix: the full code
Code: [Select]
// ==PREPROCESSOR==
// @name "Seekbar"
// ==/PREPROCESSOR==
//--------

// General Functions
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 TimeFmt(t){
    var zpad = function(n){
        var str = n.toString();
        return (str.length<2) ? "0"+str : str;
    }
    var m = Math.floor(t/60); t-=m*60;
    var s = Math.floor(t);
    return m.toString()+":"+zpad(s);
}

// Global Variables

var theme_font = fb.TitleFormat("%theme_font%").Eval(true);
var panelh, panelw;

// for time display
/*
var
*/
// Seekbar

seekbar = function () {

    this.init = function (x, y, w, h) {
        this.name = seekbar;
        this.font = gdi.Font(theme_font, 14, 2);
        this.timewidth = window.GetProperty("seekbar_time_width",70);
        this.iscd = window.GetProperty("seekbar_is_countdown",true);
        this.handle_size = window.GetProperty("seekbar_handle_size__even_only",12);
        this.x = x;
        this.y = y;
        this.w = w;
        this.h = h;
        this.drag = false;
        this.seek = 0;
        this.refresh_interval = window.GetProperty("seekbar_refresh_interval",40)
        this.refresh_frame_count = 0;
        this.refresh_timer = false;
        this.bar = {
            x: this.timewidth,
            y: this.x + Math.floor(this.h / 2) - this.handle_size / 2,
            w: this.w - 2 * this.timewidth
        };
    }
    
    this.draw = function (gr) {
        var newt = 0;
        var pos = 0;
        var t1, t2;
        var length = fb.PlaybackLength;
        
        if (length > 0) {
            if (this.drag) {
                newt = length * this.seek;
                pos = this.bar.w * this.seek;
            } else {
                var pbkt = fb.PlaybackTime;
                newt = pbkt;
                pos = this.bar.w * (pbkt / length);
            }
            newt = (length < newt) ? length: (newt < 0) ? 0: newt;
            t1 = TimeFmt (newt);
            t2 = (this.iscd) ? " -" + TimeFmt(length - newt): TimeFmt(length);
            
        } else {
        t1 = t2 = "-:--";
        }
        
        gr.SetSmoothingMode(2);
        gr.FillSolidRect(this.bar.x, this.bar.y + this.handle_size / 2 + 1, this.bar.w, 1, RGB(67,67,67));
        gr.FillSolidRect(this.bar.x, this.bar.y + this.handle_size / 2 - 1, this.bar.w, 2, RGB(80,80,80));
        gr.FillSolidRect(this.bar.x, this.bar.y + this.handle_size / 2 - 1, pos + 5, 2, RGB(223,232,4));
        gr.FillEllipse(this.bar.x + pos - this.handle_size / 2 - 1, this.bar.y, this.handle_size, this.handle_size, RGB(180,180,180));
        gr.FillEllipse(this.bar.x + pos - this.handle_size / 2, this.bar.y + 1, this.handle_size, this.handle_size, RGB(255,255,255));
        
        var tformat = 0x00000001 | 0x00000004 | 0x00000400 | 0x00000800 | 0x00008000;

        gr.GdiDrawText(t2, this.font, RGB(255,255,255), this.w - this.timewidth, this.y, this.timewidth, this.h, tformat);
        gr.GdiDrawText(t1, this.font, RGB(255,255,255), this.x, this.y, this.timewidth, this.h, tformat);
    }

    this.key_down = function (key) {
        switch (key) {
        }
    }
    
    this.lbtn_down = function (x, y) {
        if (x >= this.bar.x && x < this.bar.x + this.bar.w && y >= this.bar.y && y < this.bar.y + this.handle_size) this.drag = 1;
    }
    
    this.lbtn_up = function (x, y) {
        if (this.drag) {
            this.drag = 0;
            this.seek = (x - this.bar.x) / this.bar.w;
            this.seek = (this.seek < 0) ? 0 : (this.seek < 1) ? this.seek : 1;
            fb.PlaybackTime = fb.PlaybackLength * this.seek;
        } else if (x > this.bar.x + this.bar.w) {
            var val;
            val = this.iscd? false: true;
            window.SetProperty("use_countdown", val)
            this.iscd = val;
        }
    }
    
    this.move = function (x, y) {
        if (this.drag) {
            this.seek = (x - this.bar.x) / this.bar.w;
            this.seek = (this.seek < 0) ? 0 : (this.seek < 1) ? this.seek : 1;
            window.RepaintRect(this.x, this.y, this.w, this.h);
        }
    }
    
    this.refresh = function () {
        if (this.refresh_frame_count != 0) {
            window.ClearInterval(this.refresh_timer);
            this.refresh_frame_count = 0;
            this.refresh_timer = false;
        }
        window.RepaintRect(this.x, this.y, this.w, this.h);
        this.refresh_timer = window.SetInterval(this.refresh_nested, this.refresh_interval);
    }

    this.refresh_nested = function () {
        if (this.refresh_frame_count >= 1000 / this.refresh_interval) {
            window.ClearInterval(this.refresh_timer);
            this.refresh_frame_count = 0;
            this.refresh_timer = false;
        } else {
            this.refresh_frame_count ++;
            window.RepaintRect(this.x, this.y, this.w, this.h);
        }
    }

}

// Panel global variables

var panel = new Array();
panel.push(new seekbar);

function on_paint(gr) {
    for (i = 0; i < panel.length; i++) {
        panel[i].draw(gr);
    }
}

function on_size() {
    panelw = window.Width;
    panelh = window.Height;
    panel[0].init(0, 0, panelw, panelh);
}

function on_key_down(key) {
}

function on_mouse_lbtn_down(x, y) {
    for (i = 0; i < panel.length; i++) {
        if (x >= panel[i].x && x < panel[i].x + panel[i].w && y >= panel[i].y && y < panel[i].y + panel[i].h) {
            panel[i].lbtn_down(x, y);
        }
    }
}

function on_mouse_lbtn_up(x, y) {
    for (i = 0; i < panel.length; i++) {
        if (x >= panel[i].x && x < panel[i].x + panel[i].w && y >= panel[i].y && y < panel[i].y + panel[i].h) {
            panel[i].lbtn_up(x, y);
        }
    }
}

function on_mouse_move(x, y) {
    for (i = 0; i < panel.length; i++) {
        panel[i].move(x, y);
    }
}

function on_mouse_wheel(delta) {
}

function on_playback_starting(cmd, paused){
}

function on_playback_new_track(info){
    panel[0].refresh();
}

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

function on_playback_seek(time){
    panel[0].refresh();
}

function on_playback_pause(state){
    panel[0].refresh();
}

function on_playback_edited(){
}

function on_playback_dynamic_info(){
}

function on_playback_dynamic_info_track(){
}

function on_playback_time(time){
    panel[0].refresh();
}

function on_volume_change(val){
}
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-11-24 10:48:14
You're having a problem with variable scope. That's something you might want to research when you have the time.

Workarounds:

1) When inside your on_playback_seek callback, you're calling your Refresh function using the external name. There's no reason why you can't do the same from inside your SetInterval function.

2) If you google the term I mentioned, you'll find assigning this to another variable works.

Code: [Select]
function timer() {
    this.x = 0;
    var that = this;
    
    window.SetInterval(function () {
        that.x++;
        fb.trace(that.x);
    }, 200);
}

var t = new timer();


3) If you were developing in an environment that supports ECMAscript 5, you could use the bind function. Unfortunately, windows script host only support ECMAscript 3. However, you can work around that by adding a polyfill (https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_objects/Function/bind#Polyfill)

If you added that snippet in to your code, you can use it like this...

Code: [Select]
function timer() {
    this.func = function () {
        this.x++;
        fb.trace(this.x);
    }
    
    this.x = 0;
    
    window.SetInterval(this.func.bind(this), 200);
}

var t = new timer();


4) Rather than using a polyfill for each new fangled javascript function you might want to try, you could use a library like lodash (https://lodash.com/) which is what I currently do. I have the same issue not being able to use this inside the xmlhttp onreadystatechange function. You can see an example of how I use that here...

https://github.com/19379/js-marc2003/blob/0...ist.js#L693L702 (https://github.com/19379/js-marc2003/blob/0242357106591c627f62c71ec5ed9c6faa673ae4/js/list.js#L693L702)

If you do decide to try lodash, get the compat (https://raw.githubusercontent.com/lodash/lodash-compat/3.10.1/lodash.min.js) version and import it in your preprocessor section.

I know you didn't ask for other advice but I'm giving it anyway... 

1) I wouldn't bother creating/clearing/recreating timers. I just create one on startup and let it run indefinitely. In a seekbar example, I'd do this...

Code: [Select]
window.SetInterval(function () {
    if (fb.IsPlaying && !fb.IsPaused && fb.PlaybackLength > 0) {
        refresh();
    }
}, 100);


2) This is rather unnecessary.

Code: [Select]
var val;
val = this.iscd? false: true;
window.SetProperty("use_countdown", val)
this.iscd = val;


You can toggle true/false like this and without creating extra variables...

Code: [Select]
this.iscd = !this.iscd
window.SetProperty("use_countdown", this.iscd)


Also, you could tidy up other areas of the code using the same principal as above.
Title: JScript Panel script discussion/help
Post by: Scrummble on 2015-11-24 12:41:06
Thanks for the reply! It's far more useful than I expected.
I'm feeling silly now for the additional advise 2.
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-11-24 17:44:47
It's official... hell has finally frozen over. Last.fm are now allowing new API key signups.

http://www.last.fm/api/account/create (http://www.last.fm/api/account/create)

Before anyone gets too excited, large portions of it are utterly broken with no acknowledgement to the numerous repeated reports on their forums.
Title: JScript Panel script discussion/help
Post by: awx on 2015-11-25 14:24:35
Hi marc2003, thanks for creating JScript Panel!
I wonder is it possible to modify last.fm bio script so that there will be artist photo behind the text? And I cant find where to edit script in order to change text color/placement etc.
Title: JScript Panel script discussion/help
Post by: awx on 2015-11-27 10:57:47
Hi marc2003, thanks for creating JScript Panel!
I wonder is it possible to modify last.fm bio script so that there will be artist photo behind the text? And I cant find where to edit script in order to change text color/placement etc.


OK, I've found other sample script - Now Playing - it is what I was looking for. Only one problem - artist art doesn't download automatically.
Title: JScript Panel script discussion/help
Post by: Scrummble on 2015-11-29 22:29:30
Help needed for 2 questions:

1. Does fb.VolumeMute() have a different behaviour to the main menu command?
When first called, it mutes the volume, but when called for the second time, the volume won't resume.

2. Is there any function to draw a "glowing" shape?
I've seen the "glow text example", but did not find any reference to a shape to do so.

Appreciate any replies.
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-11-30 12:18:38
Only one problem - artist art doesn't download automatically.


That's by design and I'm not changing it.

1. Does fb.VolumeMute() have a different behaviour to the main menu command?


No. If you put that command in a blank panel, keep the configuration window open and repeatedly click Apply, it toggles the volume between mute and the current value like you would expect.

Quote
I've seen the "glow text example", but did not find any reference to a shape to do so.


If you try the Guifx v2 Transports (http://blog.guifx.com/2009/04/02/guifx-v2-transport-font/) font, it has a few basic shapes. If that's not good enough, I'd probably use gdi.Image on some image created in another program.
Title: JScript Panel script discussion/help
Post by: nightrise on 2015-12-04 13:19:02
Hi, i would like if somebody would post the most minimal scripts (wsh/jspanel) for the seekbar and volume. (maybe even other things if you have the will.)
so... solid colors, black on white, just the pure script, no @import .js stuff. so i can learn from that.

There are already minimal scripts here i know, but i find them slightly modified and its hard to modify/remove things i dont want. i want to start from the begining, thus the request.

also..
2.
i know how to make a square and circle with gr.Fill ... and all
but how do i make a triangle pointing this > direction. maybe you are already figured for what

3.
this is more advanced i guess and probably off topic.
is there a plugin/script/anything that gives foobar an ASCII visualisation, like the ones you can occasionaly spot in ncmpcpp on linux.
Title: JScript Panel script discussion/help
Post by: Scrummble on 2015-12-04 15:45:38
1. #43 reply in this topic is my example of seekbar, though there still are some issues to solve...
2. You can use the polygon functions to draw triangles.
3. You mean the DOS-like interface? I guess you could make that with simply text drawing and on_key callbacks...
Title: JScript Panel script discussion/help
Post by: Scrummble on 2015-12-04 15:51:13
Btw I think I've got it how to draw infusing shadows: by box blur...
That may be slow, but as I hate external images, that's affordable.
Those who remain at Pentium 4 and win xp don't deserve to enjoy my creations. Yup.
Title: JScript Panel script discussion/help
Post by: awx on 2015-12-06 01:14:54
Marc2003, I'm trying to combine AlbumArt sample with BoxBlur with no luck. Is it possible to do that albumart would be shown as blurry image?
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-12-06 06:41:03
Insert this directly after var albumart = new _.albumart(0, 0, 0, 0);

Code: [Select]
albumart.metadb_changed = function () {
    if (panel.metadb) {
        this.img && this.img.Dispose();
        this.tooltip = "";
        this.path = "";
        var img = utils.GetAlbumArtV2(panel.metadb, this.id);
        if (img) {
            this.img = gdi.CreateImage(img.Width, img.Height);
            var g = this.img.GetGraphics();
            _.drawImage(g, img, 0, 0, img.Width, img.Height);
            this.img.ReleaseGraphics(g);
            this.img.BoxBlur(20, 2); //mess around with these values
            utils.GetAlbumArtAsync(window.ID, panel.metadb, this.id, true, false, true);
        }
        window.Repaint();
    }
}
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-12-06 08:28:09
I just realised the above snippet will crash when there is no album art. This fixes it...

Code: [Select]
albumart.metadb_changed = function () {
    if (panel.metadb) {
        this.img && this.img.Dispose();
        this.tooltip = "";
        this.path = "";
        var img = utils.GetAlbumArtV2(panel.metadb, this.id);
        if (img) {
            this.img = gdi.CreateImage(img.Width, img.Height);
            var g = this.img.GetGraphics();
            _.drawImage(g, img, 0, 0, img.Width, img.Height);
            this.img.ReleaseGraphics(g);
            this.img.BoxBlur(20, 2); //mess around with these values
            utils.GetAlbumArtAsync(window.ID, panel.metadb, this.id, true, false, true);
        } else {
            this.img = null;
        }
        window.Repaint();
    }
}
Title: JScript Panel script discussion/help
Post by: awx on 2015-12-06 19:59:37
Marc2000, beautiful!!! Thanks a lot!!! This is the result:
(http://i.imgur.com/yEkBfCA.png)
Title: JScript Panel script discussion/help
Post by: samithaj on 2015-12-07 07:13:09
I'm using this code to love tracks with marc's button script
Code: [Select]
 fb.RunContextCommand("Last.fm/Last.fm Love Track '" + fb.TitleFormat("%title%").Eval() + "' By '" + fb.TitleFormat("%artist%").Eval() + "'");

When i click on it it freezes the whole foobar for like two seconds for it to love track  (not the playback ,but still very annoying- I can see this in the channel spectrum panel )
Is this a issue with Last.fm or what??

@marc
any chance including last.fm love/unlove part in your scripts(not playcount sync only love /unlove part)
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-12-07 10:43:40
It looks like you're using foo_softplaylists so I guess that is the culprit? Surely you get the same delay when using the right click menu from the playlist??

As for me providing a script, not much chance of that. I simply can't be bothered with last.fm any more. FWIW, my old WSH panel mod scripts can still love/unlove tracks. It's just the server response is broken meaning the script doesn't update foo_customdb or display any message. If you check the WSH script thread, I've posted a hack to fix that. Of course you'll need a copy of the old script because I don't keep any of my old stuff.
Title: JScript Panel script discussion/help
Post by: samithaj on 2015-12-07 17:42:35
Ya same delay when using context menu  nothing to do then
I thought old script broked with new update to last.fm
Guess i can use it then
Title: JScript Panel script discussion/help
Post by: awx on 2015-12-07 21:16:06
Marc2003, can you show me a hint how to assign different font symbol to every element of PBOArray in PBOButton(Menu).txt sample? I'm trying to get rid of image icons at all.
Title: JScript Panel script discussion/help
Post by: samithaj on 2015-12-09 13:18:43
I want to have button to love/unlove based on rating
if loved -> rating =5
Unlove -> rating = 0
Code: [Select]
 buttons.buttons.love = new _.button(100, 0, 40, 40, {
        normal: _.tf("%rating%", panel.metadb) == 5 ? "buttons\\love_h.png" :"buttons\\love.png",
        hover :"buttons\\love_h.png"
    }, function() {

_.tf("%rating%", panel.metadb) == 5 ?fb.GetNowPlaying().UpdateFileInfoSimple("RATING",5,"RATING"): fb.GetNowPlaying().UpdateFileInfoSimple("RATING", 0, "RATING");
        
        


    }, "Love");

but it's not working
any idea why??
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-12-09 13:52:33
@awx, use an array like this.

Code: [Select]
var symbols = ["a", "b", "c", "d", "e", "f", "g"];


Replace each letter with the character(s) from your font. Then inside your on_paint function, remove the code that draws the buttons and use gdi.DrawText with your custom font and this as the text

Code: [Select]
symbols[plman.PlaybackOrder]


@samithaj

Code: [Select]
panel.metadb.UpdateFileInfoSimple("RATING", panel.tf("%rating%") == 5 ? "" : 5);


Using double quotes deletes the tag. If you really want to write 0 then you can change it.
Title: JScript Panel script discussion/help
Post by: samithaj on 2015-12-10 19:18:12
@samithaj

Code: [Select]
panel.metadb.UpdateFileInfoSimple("RATING", panel.tf("%rating%") == 5 ? "" : 5);


Using double quotes deletes the tag. If you really want to write 0 then you can change it.

Thanks that worked
After updating to change the icon to love_h.png i used
Code: [Select]
 window.RepaintRect(buttons.buttons.love.x, buttons.buttons.love.y, buttons.buttons.love.w, buttons.buttons.love.h);

in the button's function
but it doesn't work, only after reloading the script it shows the updated icon image
sorry for all the stupid questions
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-12-11 11:30:53
Presumably your code that creates the button is inside the on_metadb_changed callback? If not, it should be. The window.RepaintRect should be last line of code inside the callback, not inside the button function.
Title: JScript Panel script discussion/help
Post by: samithaj on 2015-12-11 14:40:14
Presumably your code that creates the button is inside the on_metadb_changed callback? If not, it should be. The window.RepaintRect should be last line of code inside the callback, not inside the button function.

worked after putting button inside the on_metadb_changed callback
Thanks again
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-12-14 17:23:49
General question:

Is it possible to make a button in JScript with (switch to playlist) as menu?

Thx


Yes. If you browse samples that came with the component, take the MainMenuManager All-In-One.txt script and replace the menu function with this:

Code: [Select]
function menu() {
    var m = window.CreatePopupMenu();
    m.AppendMenuItem(MF_GRAYED, 0, "Switch to..."); //you wouldn't use an ID of 0 with a normal menu item but it's ok because this is greyed out.
    m.AppendMenuSeparator();
    for (var i = 0; i < plman.PlaylistCount; i++) {
        m.AppendMenuItem(MF_STRING, 1 + i, plman.GetPlaylistName(i).replace(/&/g, "&&"));
    }
    if (plman.ActivePlaylist > -1)
        m.CheckMenuRadioItem(1, plman.PlaylistCount + 1, plman.ActivePlaylist + 1);
    var idx = m.TrackPopupMenu(b.buttons.menu.x, b.buttons.menu.y);
    if (idx > 0)
        plman.ActivePlaylist = idx - 1;
    m.Dispose();
}
Title: JScript Panel script discussion/help
Post by: Rhand on 2015-12-14 17:49:48
General question:

Is it possible to make a button in JScript with (switch to playlist) as menu?

Thx


Yes. If you browse samples that came with the component, take the MainMenuManager All-In-One.txt script and replace the menu function with this:

Code: [Select]
function menu() {
    var m = window.CreatePopupMenu();
    m.AppendMenuItem(MF_GRAYED, 0, "Switch to..."); //you wouldn't use an ID of 0 with a normal menu item but it's ok because this is greyed out.
    m.AppendMenuSeparator();
    for (var i = 0; i < plman.PlaylistCount; i++) {
        m.AppendMenuItem(MF_STRING, 1 + i, plman.GetPlaylistName(i).replace(/&/g, "&&"));
    }
    if (plman.ActivePlaylist > -1)
        m.CheckMenuRadioItem(1, plman.PlaylistCount + 1, plman.ActivePlaylist + 1);
    var idx = m.TrackPopupMenu(b.buttons.menu.x, b.buttons.menu.y);
    if (idx > 0)
        plman.ActivePlaylist = idx - 1;
    m.Dispose();
}




Thank you working!!!! Great
Title: JScript Panel script discussion/help
Post by: blaxima on 2015-12-16 17:45:31
I'm not really sure why you removed the file. The error tells you exactly what to do:

Quote
"It appears the cached file has been corrupted. Use the right click menu>Force Update to try again."


If it's happening randomly (fixed by a forced update) then there isn't much I can do. If you can't get the bio of specific artist with multiple retries then I can take a look if you tell me what the artist is.

edit: If you reply, please do it in the script thread: https://www.hydrogenaud.io/forums/index.php?showtopic=110516 (https://www.hydrogenaud.io/forums/index.php?showtopic=110516)


I had tried numerous times to update it, but that did not work so I tried removing the file to see if that would. As I mentioned in the other thread, other info (similar artist, other releases) does fetch fine.

This has happened with a few artists but the last 2 are

http://www.last.fm/music/This+Will+Destroy+You (http://www.last.fm/music/This+Will+Destroy+You)
http://www.last.fm/music/Maybeshewill (http://www.last.fm/music/Maybeshewill)

Thanks
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-12-16 19:44:07
They both work fine for me so I blame your computer or internet connection.

Open js_marc2003\js\text.js in a text editor, go to line 338 and replace this...

Code: [Select]
            case "lastfm_bio":
                var content = _(_.getElementsByTagName(this.xmlhttp.responsetext, "div"))
                    .filter({"className" : "wiki-content"})
                    .map("innerHTML")
                    .stripTags()
                    .value();
                _.save(JSON.stringify([content]), f);
                this.artist = "";
                panel.item_focus_change();
                break;


with

Code: [Select]
            case "lastfm_bio":
                fb.ShowPopupMessage(this.xmlhttp.responsetext, 1);
                var content = _(_.getElementsByTagName(this.xmlhttp.responsetext, "div"))
                    .filter({"className" : "wiki-content"})
                    .map("innerHTML")
                    .value();
                fb.ShowPopupMessage(content, 2);
                content = _.stripTags(content);
                fb.ShowPopupMessage(content, 3);
                fb.ShowPopupMessage(JSON.stringify([content]), 4);
                break;


Delete the cached file and then let the script run. 4 popup windows should open at once and I'd like to see the contents of each one. Each window will be labelled with a number 1-4. Use something like pastebin for the first window because it should be a large chunk of html.
Title: JScript Panel script discussion/help
Post by: blaxima on 2015-12-16 20:38:50
They both work fine for me so I blame your computer or internet connection.

Delete the cached file and then let the script run. 4 popup windows should open at once and I'd like to see the contents of each one. Each window will be labelled with a number 1-4. Use something like pastebin for the first window because it should be a large chunk of html.


Damn computer 

Those other 3 windows did indeed show the bio.

HTML
https://copy.com/9Ui6X0t3qXJz9MKt (https://copy.com/9Ui6X0t3qXJz9MKt)

Window 2
https://copy.com/lQLIBInfZ1UKmijH (https://copy.com/lQLIBInfZ1UKmijH)

Window 3
https://copy.com/9N1lCTnCfoImIXA1 (https://copy.com/9N1lCTnCfoImIXA1)

Window 4
https://copy.com/iGxONECt8hWOdFnf (https://copy.com/iGxONECt8hWOdFnf)


Thanks
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-12-16 21:02:58
Well if the bio is fine there, the only thing that can break it from that point onwards is the process of saving it to disk. All my scripts use the same _.save function though so I can't explain why it only seems to happen randomly in the bio script???
Title: JScript Panel script discussion/help
Post by: blaxima on 2015-12-16 21:37:43
Well if the bio is fine there, the only thing that can break it from that point onwards is the process of saving it to disk. All my scripts use the same _.save function though so I can't explain why it only seems to happen randomly in the bio script???


It does create a "bio.www.last.fm.json" file but it's empty. When I try to copy and paste from the actual bio, the file gets wiped once I play a song. I made the file "read only" but even that never gets loaded. However, if I choose another Last.fm site, it works  . Now I just need to brush up on my French or German or Italian or etc. 

Oh well, thanks for your time.

Cheers
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-12-17 07:12:48
However, if I choose another Last.fm site, it works 


That really makes no sense at all.  But given your location says Canada, French should be no problem for you. 
Title: JScript Panel script discussion/help
Post by: widerock on 2015-12-17 10:17:54
I have a panel for "playback button + status bar" within single panel.
The little buggy point is that the panel doesn't refresh when I resize foobar.
The buttons and status information stick to the initial postion even after I resized my foobar.
So,  I want to know if there is any method to refresh this panel whenever I change the foobar size.
Thank you for your help.
Code: [Select]
// ==PREPROCESSOR==
// @name "Playback Buttons"
// @author "marc2003"
// @import "%fb2k_profile_path%js_marc2003\js\lodash.min.js"
// @import "%fb2k_profile_path%js_marc2003\js\helpers.js"
// @import "%fb2k_profile_path%js_marc2003\js\panel.js"
// ==/PREPROCESSOR==

var panel = new _.panel("Playback Buttons", ["custom_background"]);
var buttons = new _.buttons();
var bs = 32;
var guifx_font = _.gdiFont(guifx.font, 8, 1);

var ww = window.Width;
var wh = window.Height;

var left_text_tf = "%playback_time%[ / %length%] :: %__bitrate% kbps %codec% [%codec_profile% ]";
var text_colour = _.RGB(40, 40, 40);

var show_volume = window.GetProperty("2K3.STATUS.SHOW.VOLUME", true);
var font = _.gdiFont("Segoe UI", 11);
var count = 0;
var right_text = "";
var right_text_width = 0;
refresh();

buttons.buttons.menu = new _.button(5, 5, bs, bs, {normal : "buttons\\menu.png"}, function () { _.menu(0, 16); }, "Menu");
buttons.buttons.stop = new _.button(ww/2-2*bs-15, 5, bs, bs, {normal : "buttons\\stop.png"}, function () { fb.Stop(); }, "Stop");
buttons.buttons.play = new _.button(ww/2-bs-5, 5, bs, bs, {normal : !fb.IsPlaying || fb.IsPaused ? "buttons\\play.png" : "buttons\\pause.png"}, function () { fb.PlayOrPause(); }, !fb.IsPlaying || fb.IsPaused ? "Play" : "Pause");
buttons.buttons.previous = new _.button(ww/2+5, 5, bs, bs, {normal : "buttons\\previous.png"}, function () { fb.Prev(); }, "Previous");
buttons.buttons.next = new _.button(ww/2+bs+15, 5, bs, bs, {normal : "buttons\\next.png"}, function () { fb.Next(); }, "Next");

buttons.update = function () {
this.buttons.play = new _.button(ww/2-bs-5, 5, bs, bs, {normal : !fb.IsPlaying || fb.IsPaused ? "buttons\\play.png" : "buttons\\pause.png"}, function () { fb.PlayOrPause(); }, !fb.IsPlaying || fb.IsPaused ? "Play" : "Pause");
window.RepaintRect(this.buttons.play.x, this.buttons.play.y, this.buttons.play.w, this.buttons.play.h);
}

function on_playlist_stop_after_current_changed() {
window.RepaintRect(buttons.buttons.stop.x, buttons.buttons.stop.y, buttons.buttons.stop.w, buttons.buttons.stop.h);
}

function on_size() {
panel.size();
window.MinHeight = 45;
window.MaxHeight = 45;
}

function on_paint(gr) {
panel.paint(gr);
buttons.paint(gr);
gr.SetTextRenderingHint(4);
if (fb.StopAfterCurrent)
gr.DrawString("", guifx_font, _.RGB(196, 30, 35), buttons.buttons.stop.x, buttons.buttons.stop.y + 1, buttons.buttons.stop.w, buttons.buttons.stop.h, SF_CENTRE);
if (fb.IsPlaying)
gr.GdiDrawText(_.tfe(left_text_tf), font, text_colour, 0, 2, ww - 55, font.Height, RIGHT);
if (count > 0)
gr.GdiDrawText(right_text, font, text_colour, 0, 22, ww - 5, font.Height, RIGHT);
if (show_volume)
gr.GdiDrawText(fb.Volume.toFixed(2) + " dB", font, text_colour, 0, 2, ww - 5, font.Height, RIGHT);
}

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

function on_playback_pause() {
buttons.update();
}

function on_playback_starting() {
buttons.update();
}

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

function on_mouse_leave() {
buttons.leave();
}

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

function on_mouse_rbtn_up(x, y) {
if (buttons.buttons.stop.trace(x, y)) {
var m = window.CreatePopupMenu();
m.AppendMenuItem(MF_STRING, 1, "Stop After Current");
m.CheckMenuItem(1, fb.StopAfterCurrent);
m.AppendMenuSeparator();
m.AppendMenuItem(MF_STRING, 2, "Configure...");
var idx = m.TrackPopupMenu(x, y);
if (idx == 1)
fb.StopAfterCurrent = !fb.StopAfterCurrent;
else if (idx == 2)
window.ShowConfigure();
m.Dispose();
return true;
} else {
return panel.rbtn_up(x, y);
}
}

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

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

function on_mouse_wheel(s) {
if (!show_volume)
return;
if (s == 1)
fb.VolumeUp();
else
fb.VolumeDown();
}

function on_mouse_lbtn_dblclk() {
fb.RunMainMenuCommand("View/Show now playing in playlist");
}

function on_mouse_rbtn_up(x, y) {
if (utils.IsKeyPressed(VK_SHIFT))
return false;
var m = window.CreatePopupMenu();
var c = fb.CreateContextMenuManager();
if (fb.IsPlaying) {
c.InitNowPlaying();
c.BuildMenu(m, 1, -1);
m.AppendMenuSeparator();
}
m.AppendMenuItem(MF_STRING, 10000, "Show volume");
m.CheckMenuItem(10000, show_volume);
m.AppendMenuSeparator();
m.AppendMenuItem(MF_STRING, 10001, "Configure...");
var idx = m.TrackPopupMenu(x, y);
switch (true) {
case idx == 0:
break;
case idx == 10000:
show_volume = !show_volume;
window.SetProperty("2K3.STATUS.SHOW.VOLUME", show_volume);
window.Repaint();
break;
case idx == 10001:
window.ShowConfigure();
break;
default:
c.ExecuteByID(idx - 1);
break;
}
m.Dispose();
c.Dispose();
return true;
}

function on_playlist_items_added(p) {
if (p == plman.ActivePlaylist)
refresh();
}

function on_playlist_items_removed(p) {
if (p == plman.ActivePlaylist)
refresh();
}

function on_playlist_switch() {
refresh();
}

function refresh() {
var items = plman.GetPlaylistItems(plman.ActivePlaylist);
count = items.Count;
right_text = count + (count == 1 ? " track :: " : " tracks :: ") + utils.FormatDuration(items.CalcTotalDuration()) + " :: " + utils.FormatFileSize(items.CalcTotalSize());
right_text_width = _.textWidth(right_text, font);
window.Repaint();
items.Dispose();
}
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-12-17 23:36:46
Get rid of the ww/wh variables and use panel.w and panel.h instead. Also, your buttons should go inside the on_size function, after panel.size().
Title: JScript Panel script discussion/help
Post by: widerock on 2015-12-18 00:19:17
Get rid of the ww/wh variables and use panel.w and panel.h instead. Also, your buttons should go inside the on_size function, after panel.size().


It works well. Thank you, marc2003!
Title: JScript Panel script discussion/help
Post by: blaxima on 2015-12-19 17:12:38
However, if I choose another Last.fm site, it works 


That really makes no sense at all.  But given your location says Canada, French should be no problem for you. 


 

huzzah, saw on Devart that someone else is having the same problem as me so it isn't my puter.
Quote
Hello, I got some songs fetching last.fm artist biography get some error on foobar

Unable to get property 'length' of undefined or null reference
File: D:\Program Files\foobar2000\skins\Zetro\scripts\text.js
Line: 249, Col: 25

how to fix this?


any ideas?

Thanks
Title: JScript Panel script discussion/help
Post by: marc2003 on 2015-12-19 18:52:37
huzzah, saw on Devart that someone else is having the same problem as me so it isn't my puter.


It just means both of your computers are broken and should be disposed of at once. 

I don't have a serious reply because you said yourself it works with languages other than English. There is nothing I can think of to troubleshoot an issue like that.
Title: JScript Panel script discussion/help
Post by: blaxima on 2015-12-19 20:53:28
huzzah, saw on Devart that someone else is having the same problem as me so it isn't my puter.


It just means both of your computers are broken and should be disposed of at once. 

I don't have a serious reply because you said yourself it works with languages other than English. There is nothing I can think of to troubleshoot an issue like that.


   

Oh well, thanks again for your time
Title: JScript Panel script discussion/help
Post by: roninmedia on 2015-12-24 14:47:56
Does anyone have some recommended resources/references I can take a look at? I've taken a look at some of Marc's sample scripts and just want to see examples of what I could do to modify the look to my ideal set-up.

I'm especially interested in the drawing functions; shadows, border, gradient, etc.
Title: JScript Panel script discussion/help
Post by: needs_therapy on 2015-12-27 15:25:57
Get rid of the ww/wh variables and use panel.w and panel.h instead. Also, your buttons should go inside the on_size function, after panel.size().

I'm having a similar problem. The values of panel.w and panel.h are equal to 0 so they are not useful for my purpose.

I need the values  of window.height and window.width to automatically update.

Code: [Select]
// ==PREPROCESSOR==
// @name "np_basic"
// @author "marc2003"
// @import "%fb2k_profile_path%js_marc2003\js\lodash.min.js"
// @import "%fb2k_profile_path%js_marc2003\js\helpers.js"
// @import "%fb2k_profile_path%js_marc2003\js\panel.js"
// @import "%fb2k_profile_path%js_marc2003\js\thumbs.js"java script:bbc_pop()
// @import "%fb2k_profile_path%js_marc2003\js\text.js"
// @import "%fb2k_profile_path%js_marc2003\js\rating.js"
// ==/PREPROCESSOR==

//the track info section displays 3 lines of title formatted text. you can customise that here/////////////////////////////////////////////
var line1 = {
text: "", //leave this blank
tf: "%title%", //enter any title formatting
font: _.gdiFont("Calibri", 24, 0), //font name, size, style. 1 means bold and 0 is normal.
    colour: _.RGB(240, 240, 240), //colour
y: 0 //change this value to move text up or down.
}
var line2 = {
    text: "",
tf: "%album artist% - %album%",
font: _.gdiFont("Segoe UI", 16, 0),
colour: _.RGB(240, 240, 240),
y: 40
}
var line3 = {
text: "",
tf: "[%album% ]['('%date%')']",
font: _.gdiFont("Segoe UI", 14, 1),
colour: _.RGB(180, 180, 180),
y: 65
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

var panel = new _.panel("np_basic", ["metadb", "remap", "custom_background"]);
var text = new _.text("lastfm_bio", 20, 0, 0, 0);
var thumbs = new _.thumbs();
var panw = window.Width; // panel width
var pan_h = window.Height; // panel height
thumbs.mode = 5;
var bar_h = 80; // height of the title stuff
var buttons = new _.buttons();
var mbuts = 48; // menu button size
buttons.buttons.menu = new _.button( panw - 5 - mbuts, (bar_h - mbuts) / 2, mbuts, mbuts, {normal : "misc\\foobar2000.png"}, function () { _.menu(0, 36); }, "Menu");
var guifx_font = _.gdiFont(guifx.font, 8, 1);
//rating
var r_x = (panw - 28 * 5) / 2; // rating buttons starting x position
var r_y = bar_h + 5; //rating buttons starting y position
var rating = new _.rating(r_x, r_y, 28,  _.RGB(128, 128, 128), _.RGB(255, 128, 0));
//playback buttons
var bs = 80; // playback buttons size
var strpnt_x = (panw - bs) / 2; // playback buttons starting x position
var strpnt_y = pan_h - 100; // playback buttons starting y position

buttons.buttons.stop = new _.button(strpnt_x - bs * 3, strpnt_y, bs, bs , {normal : "buttons\\stop.png"}, function () { fb.Stop(); }, "Stop");
buttons.buttons.play = new _.button(strpnt_x, strpnt_y, bs, bs, {normal : !fb.IsPlaying || fb.IsPaused ? "buttons\\play.png" : "buttons\\pause.png"}, function () { fb.PlayOrPause(); }, !fb.IsPlaying || fb.IsPaused ? "Play" : "Pause");
buttons.buttons.previous = new _.button(strpnt_x - bs * 1.5, strpnt_y, bs, bs, {normal : "buttons\\previous.png"}, function () { fb.Prev(); }, "Previous");
buttons.buttons.next = new _.button(strpnt_x + bs * 1.5 , strpnt_y, bs, bs, {normal : "buttons\\next.png"}, function () { fb.Next(); }, "Next");
buttons.buttons.next1 = new _.button(strpnt_x + bs * 3, strpnt_y, bs, bs, {normal : "buttons\\next.png"}, function () { fb.Next(); }, "Next");

buttons.update = function () {
this.buttons.play = new _.button(bs, 0, bs, bs, {normal : !fb.IsPlaying || fb.IsPaused ? "buttons\\play.png" : "buttons\\pause.png"}, function () { fb.PlayOrPause(); }, !fb.IsPlaying || fb.IsPaused ? "Play" : "Pause");
window.RepaintRect(this.buttons.play.x, this.buttons.play.y, this.buttons.play.w, this.buttons.play.h);
}


panel.item_focus_change();

function on_size() {
panel.size();
thumbs.size();
text.y = _.floor(panel.h * 0.75);
text.w = panel.w - 40
text.h = panel.h - text.y - 5;
text.size();
}

function on_paint(gr) {
panel.colours.text = _.RGB(220, 220, 220);
panel.paint(gr);
thumbs.paint(gr);
gr.FillSolidRect(0, 0, panel.w, bar_h, _.RGBA(0, 0, 0, 196));
gr.GdiDrawText(line1.text, line1.font, line1.colour, 10, line1.y, panel.w - 20, line1.font.Height, LEFT);
gr.GdiDrawText(line2.text, line2.font, line2.colour, 10, line2.y, panel.w - 20, line2.font.Height, LEFT);
//gr.GdiDrawText(line3.text, line3.font, line3.colour, 10, line3.y, panel.w - 20, line3.font.Height, LEFT);
//gr.FillSolidRect(text.x - 15, text.y, text.w + 30, text.h, _.RGBA(0, 0, 0, 156));
text.paint(gr);
    buttons.paint(gr);
    gr.SetTextRenderingHint(4);
if (fb.StopAfterCurrent)
gr.DrawString("4", guifx_font, _.RGB(196, 30, 35), buttons.buttons.stop.x, buttons.buttons.stop.y + 1, buttons.buttons.stop.w, buttons.buttons.stop.h, SF_CENTRE);
    rating.paint(gr);
}

function on_metadb_changed() {
thumbs.metadb_changed();
//text.metadb_changed();
if (panel.metadb) {
line1.text = panel.tf(line1.tf);
line2.text = panel.tf(line2.tf);
line3.text = panel.tf(line3.tf);
}
window.Repaint();
    rating.metadb_changed();
}

function on_playlist_stop_after_current_changed() {
window.RepaintRect(buttons.buttons.stop.x, buttons.buttons.stop.y, buttons.buttons.stop.w, buttons.buttons.stop.h);
}

function on_playback_stop() {
buttons.update();
}

function on_playback_pause() {
buttons.update();
}

function on_playback_starting() {
buttons.update();
}

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

function on_mouse_leave() {
buttons.leave();
    rating.leave();
}

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

function on_mouse_rbtn_up(x, y) {
    return panel.rbtn_up(x, y);
if (buttons.buttons.stop.trace(x, y)) {
var m = window.CreatePopupMenu();
m.AppendMenuItem(MF_STRING, 1, "Stop After Current");
m.CheckMenuItem(1, fb.StopAfterCurrent);
m.AppendMenuSeparator();
m.AppendMenuItem(MF_STRING, 2, "Configure...");
var idx = m.TrackPopupMenu(x, y);
if (idx == 1)
fb.StopAfterCurrent = !fb.StopAfterCurrent;
else if (idx == 2)
window.ShowConfigure();
m.Dispose();
return true;
} else {
return panel.rbtn_up(x, y);
}
}

Sorry if its a bit messy.
Title: JScript Panel script discussion/help
Post by: SplitEnz on 2015-12-28 01:54:06
Hey all, thanks marc2003, Br3tt and everyone else for your work. I've just installed the "foo_jscript_panel-v1.0.7.fb2k-component" and Br3tt's JS Smooth script.
When I import it, I get the following in the console:

One JScript panel said:
The following preprocessor @import file(s) were not found:

C:\Users\Ben\AppData\Roaming\foobar2000\js_br3tt\jssb\js\JScommon.js
C:\Users\Ben\AppData\Roaming\foobar2000\js_br3tt\jssb\js\JSinputbox.js

And the console said:
JScript Panel ({A1765CC9-04BD-4F05-A555-F42F57233ACE}): initialized in 0 ms
Error: JScript Panel (JS Smooth Browser v20151114-1630-340 by Br3tt aka Falstaff >> http://br3tt.deviantart.com): (http://br3tt.deviantart.com):) Parsing file "C:\Users\Ben\AppData\Roaming\foobar2000\js_br3tt\jssb\js\JScommon.js": Failed to load.
Error: JScript Panel (JS Smooth Browser v20151114-1630-340 by Br3tt aka Falstaff >> http://br3tt.deviantart.com): (http://br3tt.deviantart.com):) Parsing file "C:\Users\Ben\AppData\Roaming\foobar2000\js_br3tt\jssb\js\JSinputbox.js": Failed to load.
Error: JScript Panel (JS Smooth Browser v20151114-1630-340 by Br3tt aka Falstaff >> http://br3tt.deviantart.com): (http://br3tt.deviantart.com):) Microsoft JScript runtime error:
Object expected
File: <main>
Line: 126, Col: 1
<source text only available at compile time>

I had a look at the script and the only reference to those two variables are in a (commented out) preprocessor block as follows:

// ==PREPROCESSOR==
// @name "JS Smooth Browser"
// @version "20151114-1630-340"
// @author "Br3tt aka Falstaff >> http://br3tt.deviantart.com" (http://br3tt.deviantart.com&quot;)
// @feature "v1.4"
// @feature "watch-metadb"
// @import "%fb2k_profile_path%js_br3tt\jssb\js\JScommon.js"
// @import "%fb2k_profile_path%js_br3tt\jssb\js\JSinputbox.js"
// ==/PREPROCESSOR==

I tried changing the path to the actual location (my foobar install isn't where it went looking), but that only gave a different error.

Any ideas? Please let me know if you need more information to debug/identify. Thanks in advance.
Title: JScript Panel script discussion/help
Post by: Daeron on 2015-12-28 07:30:20
I'm in the process of migrating from foo_uie_biography and I have some questions.

I would like to recreate my original panel (top picture) as closest as possible using your last.fm biography script (bottom). This means no headers, very small margins and the text filling as much space as it can. I removed the corresponding lines which draw the header and the square behind it and tried to adjust the position of the text. However at the top and the bottom there are white spaces that I can't get rid of (and text can't flow there). Any idea how to do that? I'd imagine that's governed by one of the prerequisites in \js\, but it would take me a long time to figure anything out there.

Furthermore, foo_uie_biography had an option for short descriptions. This most of the time meant the pulled text fit the given area perfectly, unlike your script which downloads the entire page. This often results in even just the main paragraph running out of bounds and any further information is also only accessible after scrolling down. Which I rarely do, so I won't need that. Is the short description part of the API still usable? Can this be added to the script?

It also appears that this version of your thumbs script doesn't have an automatic download function. Is this the result of some API changes at last.fm or simply a precaution so people don't spam your API key? Can this be readded with the criterion that everyone must acquire and use their own key? If not, do you know if the old script is still technically operational (as long as I switch to my key)?


(http://i.imgur.com/LEcx9HH.png)

The slightly modified last.fm biography script:
Code: [Select]
// ==PREPROCESSOR==
// @name "Last.fm Bio"
// @author "marc2003"
// @import "%fb2k_profile_path%js_marc2003\js\lodash.min.js"
// @import "%fb2k_profile_path%js_marc2003\js\helpers.js"
// @import "%fb2k_profile_path%js_marc2003\js\panel.js"
// @import "%fb2k_profile_path%js_marc2003\js\text.js"
// ==/PREPROCESSOR==

var panel = new _.panel("Last.fm Bio", ["metadb", "remap"]);
var text = new _.text("lastfm_bio", 0, 0, 0, 0);

panel.item_focus_change();

function on_size() {
panel.size();
text.w = panel.w;
text.h = panel.h;
text.size();
}

function on_paint(gr) {
panel.paint(gr);
text.paint(gr);
}

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

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

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

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

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

function on_mouse_rbtn_up(x, y) {
return panel.rbtn_up(x, y, text);
}
Title: JScript Panel script discussion/help
Post by: Decalicatan_Decalicatan on 2015-12-28 13:17:36
Hi!

Sorry for this very stupid question, but what is the color code to use with FillSolidRect function ?
If I use hex color code such as 0x0080C0 it doesn't work (although this code is ok when I use GdiDrawText function).

Thanks in advance

Title: JScript Panel script discussion/help
Post by: MachineHead on 2015-12-28 13:26:25
Something like this should work.

Code: [Select]
gr.FillSolidRect(0, 0, panel.w, panel.h, _.RGB(150,150,250));
Title: JScript Panel script discussion/help
Post by: roninmedia on 2015-12-28 14:58:25
I'm examining some of the samples that came along with the plugin. The one I'm interested in is the "Themed Seek Bar" and I am having a hard time understanding how to color it so say white rather than the default green and keep the default style.

Code: [Select]
// ==PREPROCESSOR==
// @name "Themed Seek Bar"
// @author "marc2003"
// @import "%fb2k_component_path%docs\helpers.txt"
// ==/PREPROCESSOR==

var tooltip = window.CreateTooltip();
var g_theme = window.CreateThemeManager("PROGRESS");
// seekbar is defined inside docs\helpers.txt
// 4 arguments are x, y, w, h
// y and w are dynamic based on panel size so we set those inside on_size function
var s = new seekbar(10, 0, 0, 20);

function on_size() {
s.y = Math.floor((window.Height - 20) / 2);
//because we've set x 10 pixels from the left, the seekbar width can be the panel
//width minus 20 pixels to leave the same gap on the right side.
s.w = window.Width - 20;
}

function on_paint(gr) {
g_theme.SetPartAndStateID(1, 0);
g_theme.DrawThemeBackground(gr, s.x, s.y, s.w, s.h);
if (fb.IsPlaying && fb.PlaybackLength > 0) {
g_theme.SetPartAndStateID(5, fb.IsPaused ? 3 : 1);
g_theme.DrawThemeBackground(gr, s.x, s.y, s.pos(), s.h);
}
}

function on_playback_seek() {
s.playback_seek();
}

function on_playback_stop() {
s.playback_stop();
}

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

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

function on_mouse_lbtn_down(x, y) {
s.lbtn_down(x, y);
}

function on_mouse_lbtn_up(x, y) {
s.lbtn_up(x, y);
}
Title: JScript Panel script discussion/help
Post by: Decalicatan_Decalicatan on 2015-12-28 15:16:23
Something like this should work.


Thanks !
Title: JScript Panel script discussion/help
Post by: samithaj on 2015-12-29 13:01:59
I'm in the process of migrating from foo_uie_biography and I have some questions.

I would like to recreate my original panel (top picture) as closest as possible using your last.fm biography script (bottom). This means no headers, very small margins and the text filling as much space as it can. I removed the corresponding lines which draw the header and the square behind it and tried to adjust the position of the text. However at the top and the bottom there are white spaces that I can't get rid of (and text can't flow there). Any idea how to do that? I'd imagine that's governed by one of the prerequisites in \js\, but it would take me a long time to figure anything out there.


You can try something like
Code: [Select]
var text = new _.text("lastfm_bio", 0, -10, 0, 0);
text.h = panel.h+20;
Title: JScript Panel script discussion/help
Post by: Daeron on 2015-12-29 14:07:51
Works, thanks. Seems like I forgot you can add to the add to the height of the text panel not just remove the subtraction.
Title: JScript Panel script discussion/help
Post by: Falstaff on 2015-12-30 09:11:15
Hey all, thanks marc2003, Br3tt and everyone else for your work. I've just installed the "foo_jscript_panel-v1.0.7.fb2k-component" and Br3tt's JS Smooth script.
When I import it, I get the following in the console:

One JScript panel said:
The following preprocessor @import file(s) were not found:

C:\Users\Ben\AppData\Roaming\foobar2000\js_br3tt\jssb\js\JScommon.js
C:\Users\Ben\AppData\Roaming\foobar2000\js_br3tt\jssb\js\JSinputbox.js

And the console said:
JScript Panel ({A1765CC9-04BD-4F05-A555-F42F57233ACE}): initialized in 0 ms
Error: JScript Panel (JS Smooth Browser v20151114-1630-340 by Br3tt aka Falstaff >> http://br3tt.deviantart.com): (http://br3tt.deviantart.com):) Parsing file "C:\Users\Ben\AppData\Roaming\foobar2000\js_br3tt\jssb\js\JScommon.js": Failed to load.
Error: JScript Panel (JS Smooth Browser v20151114-1630-340 by Br3tt aka Falstaff >> http://br3tt.deviantart.com): (http://br3tt.deviantart.com):) Parsing file "C:\Users\Ben\AppData\Roaming\foobar2000\js_br3tt\jssb\js\JSinputbox.js": Failed to load.
Error: JScript Panel (JS Smooth Browser v20151114-1630-340 by Br3tt aka Falstaff >> http://br3tt.deviantart.com): (http://br3tt.deviantart.com):) Microsoft JScript runtime error:
Object expected
File: <main>
Line: 126, Col: 1
<source text only available at compile time>

I had a look at the script and the only reference to those two variables are in a (commented out) preprocessor block as follows:

// ==PREPROCESSOR==
// @name "JS Smooth Browser"
// @version "20151114-1630-340"
// @author "Br3tt aka Falstaff >> http://br3tt.deviantart.com" (http://br3tt.deviantart.com&quot;)
// @feature "v1.4"
// @feature "watch-metadb"
// @import "%fb2k_profile_path%js_br3tt\jssb\js\JScommon.js"
// @import "%fb2k_profile_path%js_br3tt\jssb\js\JSinputbox.js"
// ==/PREPROCESSOR==

I tried changing the path to the actual location (my foobar install isn't where it went looking), but that only gave a different error.

Any ideas? Please let me know if you need more information to debug/identify. Thanks in advance.



all is explained as well, the folder js_br3tt (that contain all ressources for the main script) MUST be in your foobar2000 profile folder, and it isn't !

the foobar2000 profile folder is the foobar2000 program folder if you have installed foobar2000 as a portable installation
else, if standard installation done, the profile folder is C:\Users\username\AppData\Roaming\foobar2000

you should figure it out, but if not, do not try to use scripts anymore and stay with basics interfaces and panels.
Title: JScript Panel script discussion/help
Post by: SplitEnz on 2015-12-30 09:57:21
OH. Profile folder, not Foobar install folder. Misread the instructions. Thanks  It's noticeably quicker than facets. Is there a way to make it even faster in loading up the album images? eg. using smaller image sizes or similar?
Title: JScript Panel script discussion/help
Post by: blaxima on 2016-01-02 07:08:22
I don't have a serious reply because you said yourself it works with languages other than English. There is nothing I can think of to troubleshoot an issue like that.


Finally!! I got it sorted. It was the scripting engine.
Title: JScript Panel script discussion/help
Post by: marc2003 on 2016-01-02 12:47:25
I've tracked down the source of the problem but I have no idea why it fails in the JScript9 engine but not JScript. I have added a workaround though. This works in both engines.

https://raw.githubusercontent.com/19379/js-...ster/js/text.js (https://raw.githubusercontent.com/19379/js-marc2003/master/js/text.js)

Save it in js_marc2003\js

@Daeron, I don't use the API for bio text or images. That means fetching all text is mandatory but everything else is by design and I have no intention of changing it. I suppose cutting the text off at the first double line break to get the first paragraph could be possible if you feel like tinkering with it.
Title: JScript Panel script discussion/help
Post by: blaxima on 2016-01-02 18:02:50
I've tracked down the source of the problem but I have no idea why it fails in the JScript9 engine but not JScript. I have added a workaround though. This works in both engines.

https://raw.githubusercontent.com/19379/js-...ster/js/text.js (https://raw.githubusercontent.com/19379/js-marc2003/master/js/text.js)


Thank you.
Title: JScript Panel script discussion/help
Post by: WilB on 2016-01-02 18:27:52
    New for 2016 - JScript Library Tree

Download and info here (https://www.hydrogenaud.io/forums/index.php?showtopic=110938)


Title: JScript Panel script discussion/help
Post by: samithaj on 2016-01-03 06:37:33
This is mostly regarding performance of foobar
I want change all of my JScript panel's (i have about 10 ) background colour on every playback of new song
I have two options
1)
put the the panel on transparent mode and
put
Code: [Select]
function on_playback_new_track() {
    window.Reload();
}
 
on every panel because the transparent  background doesn't change  when new new playback occurs
Is there any way to do this without using window.Reload() ??
2)
Use function  window.NotifyOthers() to pass the new background colors to all other  panels  and use that via on_notify_data(name, info) 
I use  window.Repaint() on that callback and i pass two values( background, foreground ) so i think window.Repaint will get called twice??
Is there a way to pass two values (array) by window.NotifyOthers ??

Either way i'm experiencing like 3 second lag in between when i change a track(not entirely sure this happen because of this but i guess it had to do something with window.Reload() window.Repaint() functions getting called lot of times)
so what is the best (faster) way to do this ?
and is there any other way to do this faster?

And one other question
So not all of my JScript panels are visible in one layout, they are hidden via  panel stack splitter till assessed
so this hidden panels get affected too ? (will they be executed ?)
Pardon my English 
Title: JScript Panel script discussion/help
Post by: marc2003 on 2016-01-03 16:14:40
If using panel stack splitter with a background image, position your panels using Forced layout and $movepanel / $movepanel_c

And yes, you can pass arrays with window.NotifyOthers. The docs even say so...

Code: [Select]
        window.NotifyOthers(name, info); (void)
        /*
        name: string
        info: all variable/array/object types should be supported
        listen for notifications in other panels using on_notify_data(name, info) {}
        */


Title: JScript Panel script discussion/help
Post by: samithaj on 2016-01-04 17:18:22
If using panel stack splitter with a background image, position your panels using Forced layout and $movepanel / $movepanel_c

Thing is i'm already using it like this , but background color stays the same colour when track changes (panel stack splitter's background color changes according to  album artwork's Color Scheme)
only a reload() in jscript panel or REFRESH in panel stack splitter will ensure the colour will changed
any idea about that??
So I guess the  using window.NotifyOthers() is better because it uses only repaint() rather than reload() in transparent method

I realised later the 3 second delay was because of a silly mistake made by me while editing one of scripts   
but there still some laggy behavior while changing the tracks
Could on_notify_data(name, info) function being used in lot of panels can cause this??
Title: JScript Panel script discussion/help
Post by: marc2003 on 2016-01-04 17:36:55
I tested using panel stack splitter to display album art and had a pseudo-transparent JScript panel on top. It updates fine on a new track with different cover. Do you have your Panel stack splitter>script tab>titleformat mode on startup: set to now playing?
Title: JScript Panel script discussion/help
Post by: samithaj on 2016-01-04 17:42:54
Yes
Evaluate scripts when track info is modified on behavior tab doesn't changes anything either :/
maybe it's because of i'm changing a color via $drawrect per track
Artwork  change could be trigger a REFRESH  maybe ??
Title: JScript Panel script discussion/help
Post by: marc2003 on 2016-01-04 17:48:36
I doubt it. The artwork is displayed using PSS $functions

Code: [Select]
$puts(bg.p,$directory_path(%path%)\cover.jpg)
$imageabs(,,,,$get(bg.p),nodisplay,,)
$puts(scale1,$div($mul(%_width%,10000),$getimagewidth($get(bg.p))))
$puts(scale2,$div($mul(%_height%,10000),$getimageheight($get(bg.p))))
$puts(scale,$max($get(scale1),$get(scale2)))
$puts(w,$ifgreater($get(scale1),$get(scale2),%_width%,$muldiv($getimagewidth($get(bg.p)),$get(scale),10000)))
$puts(h,$ifgreater($get(scale2),$get(scale1),%_height%,$muldiv($getimageheight($get(bg.p)),$get(scale),10000)))
$puts(x,$div($sub(%_width%,$get(w)),2))
$puts(d,$ifgreater(12,$div($mul($getimagewidth($get(bg.p)),10),$getimageheight($get(bg.p))),3,2))
$puts(y,$div($sub(%_height%,$get(h)),$get(d)))
$drawimage($get(x),$get(y),$get(w),$get(h),$get(bg.p),,,255)
Title: JScript Panel script discussion/help
Post by: samithaj on 2016-01-04 18:01:01
That's wired i have to reload the script panel to get the updated image
I have my behavior tab with all options disabled what settings do you use??

now it works!!!
sorry for all the trouble
Title: JScript Panel script discussion/help
Post by: marc2003 on 2016-01-04 18:12:52
edit: nvm, you sorted it.
Title: JScript Panel script discussion/help
Post by: samithaj on 2016-01-04 18:26:38
I had my jscript panels on top of another panel stack splitter and in them no forced layout only on the outer panel 
using only a jscript panel it works!!
Thank you very much for pointing me in the right direction
sorry for all the trouble
Title: JScript Panel script discussion/help
Post by: colagen on 2016-01-05 14:38:17
Hello,
Does someone know a way to play a different track from an already playing playlist without activating the playlist ?
With plman.ExecutePlaylistDefaultAction(), if the target playlist is already playing but not active, the default action seems to be to stop playback, you can try with the code sample below, instead of playing the first track of the playing playlist on double click, it will stop playback
Code: [Select]
function on_mouse_lbtn_dblclk(){
    plman.ExecutePlaylistDefaultAction(plman.playingPlaylist, 0);
}
Title: JScript Panel script discussion/help
Post by: marc2003 on 2016-01-05 17:09:34
For me it plays the selected track from the active playlist which is completely wrong. I guess that's because I've altered my playback follows currsor/cursor follows playback settings. It seems the function plain doesn't work unless you feed it the active playlist as the playlist argument. Given its pretty much direct access to the SDK method, there isn't anything I can do. I do wonder if it's broken given this post from 2008 accurately describes the same issue...

https://www.hydrogenaud.io/forums/index.php..._default_action (https://www.hydrogenaud.io/forums/index.php?showtopic=62390&hl=playlist_execute_default_action)
Title: JScript Panel script discussion/help
Post by: XPEHOPE3 on 2016-01-08 12:09:14
marc2003, is there an example script calling context menu command(s) on a selection?

Is it possible to execute a script from context menu itself?
Title: JScript Panel script discussion/help
Post by: marc2003 on 2016-01-08 12:27:45
Code: [Select]
var selected_items = plman.GetPlaylistSelectedItems(plman.ActivePlaylist);
fb.RunContextCommandWithMetadb("Properties", selected_items);


Just modify the text in quotes to whichever command you want.
Title: JScript Panel script discussion/help
Post by: XPEHOPE3 on 2016-01-08 13:15:46
That's a godsend, thanks!
Title: JScript Panel script discussion/help
Post by: needs_therapy on 2016-01-08 15:39:01
Is is possible to use your rating script without the playback statistics component? It shows the rating but doesn't let me change it.

I keep the ratings in the file metadata and would like to edit them with your script.

Or instead make the panel able to display and edit the file ratings instead
Title: JScript Panel script discussion/help
Post by: marc2003 on 2016-01-08 16:15:38
Open up the editor dialog and replace

Code: [Select]
function on_mouse_lbtn_up(x, y) {
    rating.lbtn_up(x, y);
}


with

Code: [Select]
function on_mouse_lbtn_up(x, y) {
    if (rating.trace(x, y) && panel.metadb)
        panel.metadb.UpdateFileInfoSimple("RATING", rating.hrating == rating.rating ? "" : rating.hrating);
}


Title: JScript Panel script discussion/help
Post by: marc2003 on 2016-01-08 18:00:23
I forgot you'll need to edit js_marc2003\js\rating.js to stop the warning dialog popping up on each start. Just remove this from the end...

Code: [Select]
        if (!utils.CheckComponent("foo_playcount", true))
            window.SetTimeout(function () {
                WshShell.popup("This script requires foo_playcount.", 0, panel.name, popup.stop);
            }, 500);


Title: JScript Panel script discussion/help
Post by: ZarkBit on 2016-01-08 21:11:44
Anyone here with Foobar2000 through Wine? JSPanel seems to crash  is there any Windows dependent component required?
Title: JScript Panel script discussion/help
Post by: marc2003 on 2016-01-08 21:24:26
https://www.hydrogenaud.io/forums/index.php...st&p=876501 (https://www.hydrogenaud.io/forums/index.php?s=&showtopic=77883&view=findpost&p=876501)
Title: JScript Panel script discussion/help
Post by: ZarkBit on 2016-01-08 22:17:45
thx marc, I have tried that, doesn't crash anymore, but common7.js is acting up lol

Code: [Select]
JScript Panel (Now Playing by marc2003): Microsoft JScript runtime error:
Automation server can't create object
File: Z:\home\zarkbit\.wine32\drive_c\Program Files\foobar2000\marc2003\common7.js
Line: 1426, Col: 2
<source text only available at compile time>


Checked line 1426, seems to be empty, or am I missing something?

There's also this, which affects most samples I'm using

Code: [Select]
JScript Panel (Playback Buttons by marc2003): Microsoft JScript runtime error:
Automation server can't create object
File: Z:\home\zarkbit\.wine32\drive_c\Program Files\foobar2000\js_marc2003\js\helpers.js
Line: 42, Col: 1
<source text only available at compile time>


Line 42: var vb = new ActiveXObject("ScriptControl");

Edit: ie8 32bit is acting up, trying to get ie8 32bit on 64bit OS.
Title: JScript Panel script discussion/help
Post by: MachineHead on 2016-01-08 23:08:00
Can the items in the red box (Properties - STYLE) shown in image be reverted to a single comma separated line? I disabled all autoplaylist functions since I have no need for them being created via Properties. Which I think is why they were changed to that. I'm not sure which JS script controls that behavior now. Guessing it is list.js, though.

Title: JScript Panel script discussion/help
Post by: marc2003 on 2016-01-08 23:25:43
@Zarkbit, I have no idea about the first one and you can comment the second one out. It was used for an input dialog but you can set variables by other means.

@MachineHead insert this in your editor window directly after var list = new...

Code: [Select]
list.add_meta = function (f) {
    for (var i = 0; i < f.MetaCount; i++) {
        this.add([f.MetaName(i).toUpperCase()]);
    }
}
Title: JScript Panel script discussion/help
Post by: SplitEnz on 2016-01-09 02:12:09
I've been looking at Br3tt's JS Smooth Browser. I'd like to force the script to load up ALL images into the cache when the panel starts (to avoid the 'loading' symbol and the wait for covers to display in Album mode). I've added a few debugs and noticed that the function 'image_cache' is no longer called once I've scrolled through all the albums (and no more loading symbols are shown. I don't fully understand all the code yet, but think it's because the resource has been loaded from the resource array into the cache. So I'm thinking this could be forced to occur up front. Any suggestions would be welcome. I dev in java/C++ for work, but haven't done much in JS so functions being called vs 'invoked' and some of the syntax throws me
Title: JScript Panel script discussion/help
Post by: always.beta on 2016-01-09 05:07:48
http://i.imgur.com/u2f7Rr6.png (http://i.imgur.com/u2f7Rr6.png)

Does your list is ELP? Are you able to share the playlist‘s configuration?
Title: JScript Panel script discussion/help
Post by: always.beta on 2016-01-09 05:08:51
I have a poor network speed, replied twice, can not find revoked, sorry!
Title: Re: JScript Panel script discussion/help
Post by: MachineHead on 2016-01-09 18:43:37
@MachineHead insert this in your editor window directly after var list = new...

Thanks.
Title: Re: JScript Panel script discussion/help
Post by: samithaj on 2016-01-14 20:28:52
I was thinking maybe we could have a separate thread only for scripts
So we can share and find useful scripts  8)
And if you can somehow update the first post in case of a script update (I don't know whether it's possible)
Then we'll have one updated place for look for useful scripts :)

And these russian forums (http://foobar2000.ru) have some interesting scripts too
Title: Re: JScript Panel script discussion/help
Post by: elia_is_me on 2016-01-16 00:44:54
I was thinking maybe we could have a separate thread only for scripts
So we can share and find useful scripts  8)
And if you can somehow update the first post in case of a script update (I don't know whether it's possible)
Then we'll have one updated place for look for useful scripts :)

And these russian forums (http://foobar2000.ru) have some interesting scripts too

There is a good place for new/updated things, not only scripts though.
http://foobar2000.xrea.jp/
Title: Re: JScript Panel script discussion/help
Post by: OoNebsoO on 2016-01-20 14:50:44
marc2003, just a few questions.

About last.fm user charts script, would've it be possible for script to display specific artist charts, like for instance, top songs from The Beatles, but using only songs that we have listened, from our library. Now top tracks and top albums of particular artist come from last.fm, and doesn't matter if we listened to them or not.

What I hope will be available in the future are last.fm-like charts' scripts but without last.fm. Using our tags from files (or customdb).

EDIT: Seems, these would be urls for data...

http://www.last.fm/user/*username*/library/music/*artist*/+tracks
http://www.last.fm/user/*username*/library/music/*artist*/+albums
Title: Re: JScript Panel script discussion/help
Post by: blaxima on 2016-01-20 18:29:51
So, with the lyrics3 panel no longer working I was wondering if it at all possible to have a script whipped up that could fetch lyrics? The ability to add our own sites for the query would be a nice option the extension was missing.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-01-21 04:57:35
@OoNebsoO, use foo_facets with foo_playcount. Use a statistics column to reverse sort.
Title: Re: JScript Panel script discussion/help
Post by: MachineHead on 2016-01-21 06:19:31
Is there a way to alter tag colors in properties.txt like this that doesn't involve editing the list.js color option? I dislike poking around in the scripts but in this case it was the only way I seem to be able to do it.

(http://i.imgur.com/AwtupI3.png)
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-01-21 09:47:04
inside on_paint before calling list.paint(gr)...

Code: [Select]
panel.colours.text = _.RGB(1, 2, 3);
panel.colours.highlight = _.RGB(4, 5, 6);
Title: Re: JScript Panel script discussion/help
Post by: OoNebsoO on 2016-01-21 12:59:50
@OoNebsoO, use foo_facets with foo_playcount. Use a statistics column to reverse sort.

Thanks, marc2003. Though, shame facets do not work within Column UI.

I am fooling around a bit with autoplaylists + esplaylist (elp in future most likely). Used a bit graphical browser, but for some reason, that won't display all the results. Works well with the whole library, of course, Can't figure out a query for a particular artist that is selected, or is playing though. If that's possible anyway...

(http://i.imgur.com/FnlZ9TP.gif)

Title: Re: JScript Panel script discussion/help
Post by: nikolai4ik on 2016-01-21 16:32:29
I am getting this error with one of your sample scripts:

JScript Panel (Album Art + Allmusic Review by marc2003): JavaScript runtime error:
Unable to get property 'getElementsByTagName' of undefined or null reference
File: C:\Users\xxx\AppData\Roaming\foobar2000\js_marc2003\js\text.js
Line: 316, Col: 8
<source text only available at compile time>
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-01-21 16:48:11
Is it happening with all artists/albums or just a specific one? If it's just one then let me know what it is and I'll take a look.
Title: Re: JScript Panel script discussion/help
Post by: nikolai4ik on 2016-01-21 17:12:22
Is it happening with all artists/albums or just a specific one? If it's just one then let me know what it is and I'll take a look.
Well it's very rare and random it seems. I posted when it crashed during playing
Code: [Select]
Artist Name : Straylight Run
Track Title : Tool Sheds And Hot Tubs
Album Title : Straylight Run
Date : 2004
Genre : Alternative
but playing it a few more times just now didn't give any errors.

Also thanks a lot for your samples, I can't do anything in javascript so these are very helpful  ;)
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-01-21 17:57:41
Well it worked first time for me. There's not a lot I can when I can't reproduce the problem but I guess I should handle errors more gracefully.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-01-22 07:31:15
The script now displays a message in the Console when reading the server response fails. Just save this inside js_marc2003\js

https://raw.githubusercontent.com/19379/js-marc2003/master/js/text.js
Title: Re: JScript Panel script discussion/help
Post by: elia_is_me on 2016-01-22 09:52:58
So, with the lyrics3 panel no longer working I was wondering if it at all possible to have a script whipped up that could fetch lyrics? The ability to add our own sites for the query would be a nice option the extension was missing.

you may mean this: (http://snag.gy/5BPIr.jpg)
but......... could read Chinese? or ESLyric would be a good choice.
Title: Re: JScript Panel script discussion/help
Post by: OoNebsoO on 2016-01-22 20:31:21
marc2003, could Autoplaylists use only the currently playing playlist, and not the whole library? Or think that query could be made that uses currently playing (or selected artist) automatically? Something like %artist% (is playing/is selected) SORT DESCENDING BY %title%?

Thanks.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-01-22 22:13:38
Using a custom source for autoplaylists would require component changes way beyond my extremely limited capabilities.

You can run a query against an existing playlist and send the results to a new (standard) playlist. This method doesn't support SORT BY but you can use regular title formatting to sort instead.
Title: Re: JScript Panel script discussion/help
Post by: OoNebsoO on 2016-01-23 11:49:27
Using a custom source for autoplaylists would require component changes way beyond my extremely limited capabilities.

Dread to think how limited some of ours' capabilites are then. ;)

Thank you. Found also one older thread (https://hydrogenaud.io/index.php/topic,99876.0.html) where you again helped a member who had quite similar questions like I had.
Title: Re: JScript Panel script discussion/help
Post by: blaxima on 2016-01-23 18:54:42
So, with the lyrics3 panel no longer working I was wondering if it at all possible to have a script whipped up that could fetch lyrics? The ability to add our own sites for the query would be a nice option the extension was missing.

you may mean this: (http://snag.gy/5BPIr.jpg)
but......... could read Chinese? or ESLyric would be a good choice.

Thank you but I did not have any luck with this
Title: Re: JScript Panel script discussion/help
Post by: beesmyer on 2016-01-24 07:48:57
I hope this is the best place to ask this...
THe "now playing (basic)" Script... is it possible to change the location where the images are downloaded to? When selecting to download the images from last.fm it saves to the user configuration folder.. can I for example change this to my album artist folder? (drive\album artist\artowrk\?) This is something I already use for one source for my images.. ($replace(%path%,$directory(%path%)\%filename_ext%,)extrathumbs\*)
Title: Re: JScript Panel script discussion/help
Post by: elia_is_me on 2016-01-25 01:10:14
So, with the lyrics3 panel no longer working I was wondering if it at all possible to have a script whipped up that could fetch lyrics? The ability to add our own sites for the query would be a nice option the extension was missing.

you may mean this: (http://snag.gy/5BPIr.jpg)
but......... could read Chinese? or ESLyric would be a good choice.

Thank you but I did not have any luck with this

Once @dreamawake made an English version of ESLyric and shared it with her configuration "Foobox" on deviantart, but got "SHIT" feedback... maybe that is why @ttsping(aka oyeah) has no motion to compile an english version.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-01-25 10:23:47
I hope this is the best place to ask this...
THe "now playing (basic)" Script... is it possible to change the location where the images are downloaded to? When selecting to download the images from last.fm it saves to the user configuration folder.. can I for example change this to my album artist folder? (drive\album artist\artowrk\?) This is something I already use for one source for my images.. ($replace(%path%,$directory(%path%)\%filename_ext%,)extrathumbs\*)

Theoretically possible but tricky to explain so I'm just going to say no.  :))
Title: Re: JScript Panel script discussion/help
Post by: beesmyer on 2016-01-25 12:43:52
Theoretically possible but tricky to explain so I'm just going to say no.  :))

Thank you. That's all I needed. Being new to foobar my head is spinning a little and wanted to make sure I wasn't overlooking anything.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-01-27 16:56:57
Last.fm updated their website today and it broke image downloading in my thumbs/now playing (simple) scripts. This fixes it...

https://raw.githubusercontent.com/19379/js-marc2003/master/js/thumbs.js

Just save it inside js_marc2003\js.
Title: Re: JScript Panel script discussion/help
Post by: nikolai4ik on 2016-01-28 06:07:18
Getting API error after I enter my last.fm password into last.fm sync sample panel, do I have to manually enter it into one of the .js files?
Title: Re: JScript Panel script discussion/help
Post by: nikolai4ik on 2016-02-04 13:39:44
I want to add a few extra buttons to marc2003's sample "track info + seekbar + buttons", where do I find the functions syntax I need?
For example stop after queue/current.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-02-04 18:13:41
docs\interfaces.txt contains most of what you need. You can get/set the state of stop after current with fb.StopAfterCurrent. You can also detect when the state changes using the on_playlist_stop_after_current_changed callback. See callbacks.txt

Assuming stop after queue is provided by some third party component, all you can do is trigger the menu command using fb.RunMainMenuCommand. You cannot query its state.
Title: Re: JScript Panel script discussion/help
Post by: Jailhouse on 2016-02-04 20:58:57
docs\interfaces.txt contains most of what you need.

I opened interfaces.txt in Notepad and quickly found that was a mistake. So I opened it in the JScript Panel editor, which obviously should have been my first choice. Can you recommend a text editor that works the same way?
Title: Re: JScript Panel script discussion/help
Post by: nikolai4ik on 2016-02-05 06:27:08
docs\interfaces.txt contains most of what you need. You can get/set the state of stop after current with fb.StopAfterCurrent. You can also detect when the state changes using the on_playlist_stop_after_current_changed callback. See callbacks.txt

Assuming stop after queue is provided by some third party component, all you can do is trigger the menu command using fb.RunMainMenuCommand. You cannot query its state.

Thank you.
Title: Re: JScript Panel script discussion/help
Post by: nikolai4ik on 2016-02-05 07:31:23
All samples I find for playback order button work fine in wsh panel but in js panel they give error -
Quote
JavaScript runtime error:
Overflow
File: <main>
Line: 132, Col: 2
<source text only available at compile time>
line is   k.CheckMenuRadioItem(1, 7, fb.PlayBackOrder + 1);

removing +1/-1 stops crashing but then the menu doesn't actually do anything. Is there a way to make it JS panel friendly?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-02-05 07:36:53
Use plman.PlaybackOrder

It is documented in the changelog...

https://github.com/19379/foo-jscript-panel/blob/master/CHANGELOG.md#v100-compared-to-wsh-panel-mod-156
Title: Re: JScript Panel script discussion/help
Post by: nikolai4ik on 2016-02-05 10:16:18
Perfect, thanks again.
Title: Re: JScript Panel script discussion/help
Post by: seriousstas on 2016-02-07 17:19:28
Last.fm updated their website today and it broke image downloading in my thumbs/now playing (simple) scripts. This fixes it...

https://raw.githubusercontent.com/19379/js-marc2003/master/js/thumbs.js

Just save it inside js_marc2003\js.

Thank you.
Each folder is now duplicates example:
Medeski, Martin & Wood 100596f6218c45c69164896428acb00a.jpg
Medeski, Martin & Wood_100596f6218c45c69164896428acb00a.jpg.jpg
This can be fixed?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-02-07 17:46:04
Thanks for spotting that. The updated file can be downloaded using the same link:

https://raw.githubusercontent.com/19379/js-marc2003/master/js/thumbs.js
Title: Re: JScript Panel script discussion/help
Post by: zeremy on 2016-02-11 10:05:59
I'm having a problem with the on_mouse_wheel callback. (jscript panel & wsh panel)
Any help is appreciated.

Using an external mouse with my laptop , scrolling is possible and  the callback returns step of 1 or -1 .

Using the touchpad though , with Asus Smart Gesture drivers , two-finger scrolling returns multiple steps of 0  and scrolling does not work right.

Is it a crappy driver issue , or an issue with the callback ?

Native playlists views , scollbars and volume are working fine with the two-finger scroll.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-02-11 11:55:06
Code: [Select]
function on_mouse_wheel(a, b, c) {
    fb.trace("a: " + a);
    fb.trace("b: " + b);
    fb.trace("c: " + c);
}

Can you report the value of b when you scroll up/down with your trackpad.
Title: Re: JScript Panel script discussion/help
Post by: zeremy on 2016-02-11 12:08:39
Down
Code: [Select]
b: -80 
b: -82
b: -82
b: -46
b: -46
b: -46
b: -46
b: -46
b: -46
b: -46
b: -46
b: -46
b: -46
b: -46
b: -45
b: -45
b: -45
b: -45
b: -45
b: -45
b: -45
b: -44
b: -44
b: -44
b: -44
b: -44
b: -43
b: -43
b: -43
b: -43
b: -42
b: -42
b: -42
b: -42
b: -41
b: -41
b: -41
b: -40
b: -40
b: -40
b: -39
b: -39
b: -38
b: -38
b: -38
b: -37
b: -37
b: -36
b: -36
b: -35
b: -35
b: -35
b: -34
b: -34
b: -33
b: -33
b: -32
b: -31
b: -31
b: -30
b: -30
b: -29
b: -29
b: -28
b: -27
b: -27
b: -26
b: -26
b: -25
b: -24
b: -24
b: -23
b: -22
b: -22
b: -21
b: -20
b: -19
b: -19
b: -18
b: -17
b: -16
b: -16
b: -15
b: -14
b: -13
b: -13
b: -12
b: -11
b: -10
b: -9
b: -8
b: -7
b: -7
b: -6
b: -5
b: -4
b: -3
b: -2
b: -1
 
Up
Code: [Select]
b: 112 
b: 112
b: 40
b: 64
b: 64
b: 64
b: 64
b: 64
b: 64
b: 64
b: 64
b: 64
b: 64
b: 64
b: 63
b: 63
b: 63
b: 63
b: 63
b: 63
b: 63
b: 62
b: 62
b: 62
b: 62
b: 62
b: 61
b: 61
b: 61
b: 61
b: 60
b: 60
b: 60
b: 60
b: 59
b: 59
b: 59
b: 58
b: 58
b: 58
b: 57
b: 57
b: 56
b: 56
b: 56
b: 55
b: 55
b: 54
b: 54
b: 53
b: 53
b: 52
b: 52
b: 52
b: 51
b: 50
b: 50
b: 49
b: 49
b: 48
b: 48
b: 47
b: 47
b: 46
b: 45
b: 45
b: 44
b: 44
b: 43
b: 42
b: 42
b: 41
b: 40
b: 40
b: 39
b: 38
b: 37
b: 37
b: 36
b: 35
b: 34
b: 34
b: 33
b: 32
b: 31
b: 30
b: 30
b: 29
b: 28
b: 27
b: 26
b: 25
b: 24
b: 24
b: 23
b: 22
b: 21
b: 20
b: 19
b: 18
b: 17
b: 16
b: 15
b: 14
b: 13
b: 12
b: 11
b: 10
b: 9
b: 8
b: 7
b: 6
b: 5
b: 4
b: 2
b: 1
b: 2
b: 2
b: 2
b: 2
b: 2
b: 2
b: 2
b: 2
b: 2
b: 2
b: 2
b: 2
b: 2
b: 2
b: 2

a = 0
c = 120
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-02-11 12:18:08
Can you try this updated component. It's just the dll but I'm sure you know where to put it.

edit: temporary link removed. I'll publish a proper update later.
Title: Re: JScript Panel script discussion/help
Post by: zeremy on 2016-02-11 12:35:13
Thanks for your help marc2003.

The updated component resolved the problem and works fine. :)
Title: Re: JScript Panel script discussion/help
Post by: Jailhouse on 2016-02-14 04:22:01
@marc2003   How can I change the Volume sample script so that it works vertically instead of horizontally?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-02-14 20:51:21
Inside your panel, replace the on_paint function with this:

Code: [Select]
function on_paint(gr) {
gr.FillSolidRect(volume.x, volume.y, volume.w, volume.h, volume.c1);
gr.FillSolidRect(volume.x, volume.y + volume.h - volume.pos(), volume.w, volume.pos(), volume.c2);
}

Then open js_marc2003\js\volume.js and replace the this.move function with this:

Code: [Select]
		this.move = function (x, y) {
this.mx = x;
this.my = y;
if (this.trace(x, y)) {
y -= this.y;
var pos = y < 0 ? 1 : y > this.h ? 0 : 1 - (y / this.h);
this.drag_vol = 50 * Math.log(0.99 * pos + 0.01) / Math.LN10;
_.tt(this.drag_vol.toFixed(2) + " dB");
if (this.drag)
fb.Volume = this.drag_vol;
this.hover = true;
return true;
} else {
if (this.hover)
_.tt("");
this.hover = false;
this.drag = false;
return false;
}
}

and replace the this.pos function with this:

Code: [Select]
		this.pos = function () {
return _.ceil(this.h * (Math.pow(10, fb.Volume / 50) - 0.01) / 0.99);
}

Make sure reload the panel after editing the .js file.
Title: Re: JScript Panel script discussion/help
Post by: Jailhouse on 2016-02-15 02:32:35
@marc2003 I now have a vertical volume bar. Thank you!
Title: Re: JScript Panel script discussion/help
Post by: OoNebsoO on 2016-02-23 18:13:42
marc2003, any way for different Autoplaylist panels to keep their own queries? As it is now, one will 'pick off' queries from another, and you'll end up with two panels with same queries on both.

Title: Re: JScript Panel script discussion/help
Post by: seriousstas on 2016-02-26 02:35:13
Thanks for spotting that. The updated file can be downloaded using the same link:
https://raw.githubusercontent.com/19379/js-marc2003/master/js/thumbs.js
Hello !
Help please with thumbs. Is it possible to change the aspect of double-clicking on the screen?
I tried through window.SetProperty ( "2K3.THUMBS.ASPECT", 0);
window.SetProperty ( "2K3.THUMBS.ASPECT", 1);
window.SetProperty ( "2K3.THUMBS.ASPECT", 2);
window.SetProperty ( "2K3.THUMBS.ASPECT", 3);
but window.Repaint ();  does not work here.
After window.Reload (); do not load next images from the Internet
How to refresh the screen? Thank you!
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-02-26 14:07:50
OoNebsoO, autoplaylists is meant to be single instance only. However, you could try hacking it like this

Code: [Select]
var list = new _.list("autoplaylists", 10, 24, 0, 0); //original line - do not touch
list.filename = folders.settings + "autoplaylists2.json"; //only add this/modify filename in extra panels. autoplaylists.json is the original filename so don't use that
list.update();

seriousstas,

Code: [Select]
thumbs.aspect++;
if (thumbs.aspect > 3)
    thumbs.aspect = 0;
window.SetProperty("2K3.THUMBS.ASPECT", thumbs.aspect);
window.Repaint();

Title: Re: JScript Panel script discussion/help
Post by: seriousstas on 2016-02-26 16:14:42
seriousstas,
thumbs.aspect++;
Thnx !
Title: Re: JScript Panel script discussion/help
Post by: OoNebsoO on 2016-02-26 16:30:02
Much appreciated, yet again, marc. :)
Title: Re: JScript Panel script discussion/help
Post by: seriousstas on 2016-02-26 20:35:57
Yet one question :):
Delete function for a single file:
Code: [Select]
this.delete_image = function () {
_.recycleFile (this.files [this.images]);
this.update (); }
How do delete all the files in the current folder?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-02-26 22:28:57
Code: [Select]
		this.delete_image = function () {
_.map(this.files, _.recycleFile);
this.update();
}
Title: Re: JScript Panel script discussion/help
Post by: Daeron on 2016-02-27 11:40:23
Seems like if a character tabulation (U+0009) is present in a tag and a script tries to access it the result is a crash.
https://en.wikipedia.org/wiki/Whitespace_character

(http://i.imgur.com/M6PNFAM.png)

Don't expect to have any in my tags, just thought I'd mention it anyway.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-02-27 12:12:15
There is no problem accessing/displaying tags with these characters in. The error is caused by the script trying to create a new folder based on the tag value. I'll look at handling this better.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-02-27 12:42:02
This is now fixed. Save this inside js_marc2003\js

https://raw.githubusercontent.com/19379/js-marc2003/master/js/helpers.js

The full zip has also been updated here...

https://github.com/19379/js-marc2003/releases
Title: Re: JScript Panel script discussion/help
Post by: Daeron on 2016-02-27 17:37:59
Thank you for your work marc!
Title: Re: JScript Panel script discussion/help
Post by: nikolai4ik on 2016-02-28 08:45:27
marc, in your sample track info + seekbar + buttons is it possible to have a notch/mark on the seekbar at a certain percent? Any directions if you don't mind?

(http://i.imgur.com/e5GTSG7.jpg)
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-02-28 10:10:39
Look inside the on_paint function for if (fb.PlaybackLength > 0) and replace that section with this...

Code: [Select]
		if (fb.PlaybackLength > 0) {
var pos = seekbar.pos();
gr.FillSolidRect(seekbar.x, seekbar.y + 7, pos, 6, colours.seekbar_progress);
gr.FillSolidRect(seekbar.x + _.round(seekbar.w * 0.2) + 13, seekbar.y + 7, 3, 6, colours.seekbar_knob); //20%
gr.FillSolidRect(seekbar.x + _.round(seekbar.w * 0.8) + 13, seekbar.y + 7, 3, 6, colours.seekbar_knob); //80%
gr.FillRoundRect(seekbar.x + pos, seekbar.y + 2, 16, 16, 8, 8, colours.seekbar_progress);
gr.FillRoundRect(seekbar.x + pos + 3, seekbar.y + 5, 10, 10, 5, 5, colours.seekbar_knob);
gr.GdiDrawText(_.tfe("%playback_time%  "), panel.fonts.normal, colours.time, seekbar.x - 60, 0, 60, panel.h, RIGHT);
gr.GdiDrawText(_.tfe("  %length%"), panel.fonts.normal, colours.time, seekbar.x + seekbar.w + 16, 0, 60, panel.h, LEFT);
}

edit: top tip for anyone use imgur. Edit the url so it's https rather than http. That way, we get full size images like this...

(https://i.imgur.com/M6PNFAM.png)

(https://i.imgur.com/e5GTSG7.jpg)


Title: Re: JScript Panel script discussion/help
Post by: nikolai4ik on 2016-02-28 11:13:23
Thank you so much :)
Title: Re: JScript Panel script discussion/help
Post by: seriousstas on 2016-02-28 23:15:22
Quote
this.delete_image = function
THANX Again ! :)  
Title: Re: JScript Panel script discussion/help
Post by: Jailhouse on 2016-03-03 00:31:02
I'm working on modifying the "track info + seekbar + buttons" sample script. I've noticed that cover art images are cropped by JScript Panel whereas foobar's Album Art Viewer renders them correctly.

In the attachment, the panel is sized to 400 px tall to result in a 400 x 400 image, which mimics the Art Viewer. This cover art is enlarged from 310 x 310, but the problem exists regardless of the size of the source image or the panel size.

This is the line that displays the image, compared to the original. The only modification is to place it at the right side of the panel as opposed to the left side.

Code: [Select]
img && _.drawImage(gr, img, 0, 0, panel.h, panel.h, image.centre); //original 
img && _.drawImage(gr, img, panel.w - panel.h + 1, 0, panel.h, panel.h, image.centre);

Can this be fixed?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-03-03 02:07:26
To get the image untouched, simply omit the last argument like this...

Code: [Select]
img && _.drawImage(gr, img, panel.w - panel.h + 1, 0, panel.h, panel.h);
Title: Re: JScript Panel script discussion/help
Post by: Jailhouse on 2016-03-03 05:04:46
Problem solved! Thank you.

Now I'm curious: is "image.centre" broken? If not, what would it be used for, given that behavior?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-03-03 08:56:54
It's by design and  was asked for as a feature request by someone else. It trims 5px off each edge of the original image before resizing it. This helps when you have less than perfect images. I may have done it for my thumbs script originally but it shares the same drawImage function with the artreader. I think you're the first person to notice it- or at least tell me about it.

Having the option to draw images untouched by omitting that last argument is also by design because it absolutely matters when making buttons where you could be using images as small as 16px to begin with.
Title: Re: JScript Panel script discussion/help
Post by: Jailhouse on 2016-03-03 16:15:10
It's by design and was asked for as a feature request by someone else. [-snip-]

Excellent explanation, thank you.

Another question, then: Is "image.center" the only possible argument, or are there others?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-03-03 16:37:32
Code: [Select]
image.crop
image.crop_top
image.stretch
image.centre

Just load my artreader script and use the right click options to see each one in action.

(https://i.imgur.com/yXoLbCa.png)

It really helps if you make the panel an extreme rectangle rather than a square to see what it does.

Title: Re: JScript Panel script discussion/help
Post by: Jailhouse on 2016-03-03 20:50:32
Just load my artreader script and use the right click options to see each one in action.

Ah, I haven't looked at that script yet. (I should probably look at all of them.) The menu image you posted is a good explanation.

Thanks!
Title: Re: JScript Panel script discussion/help
Post by: Jailhouse on 2016-03-05 00:06:31
While still working on modifying the "track info + seekbar + buttons" sample script, I moved the seekbar around a bit. I had trouble moving the %playback_time% and %length% text to follow it, as the text kept appearing above where I expected.

The panel height is currently 228 pixels. The var seekbar.y is (panel.h - 20) / 2, which is 104, and the seekbar is about where I expect it to be. So I figured I needed 104 or thereabouts for the gr.GdiDrawText 'h' value, but that doesn't work. I did some testing and came up with this...

Code: [Select]
//Test
// syntax:  gr.GdiDrawText(str, IGdiFont, color, x, y, w, h, [format]);
gr.GdiDrawText("50h", _.gdiFont("Segoe UI", 12, 0), _.RGB(255, 255, 0), seekbar.x + seekbar.w + 60, 0, 40, 50, RIGHT);
gr.GdiDrawText("150h", _.gdiFont("Segoe UI", 12, 0), _.RGB(255, 255, 0), seekbar.x + seekbar.w + 60, 0, 40, 150, RIGHT);
gr.GdiDrawText("228h", _.gdiFont("Segoe UI", 12, 0), _.RGB(255, 255, 0), seekbar.x + seekbar.w + 60, 0, 40, 228, RIGHT);
gr.GdiDrawText("456h", _.gdiFont("Segoe UI", 12, 0), _.RGB(255, 255, 0), seekbar.x + seekbar.w + 60, 0, 40, 456, RIGHT);
gr.GdiDrawText("panel.h = " + panel.h, _.gdiFont("Segoe UI", 12, 0), _.RGB(255, 255, 255), 10, panel.h - 70, 900, 24, LEFT);

...which produces the result shown below. I see now that the value of 'h' needs to be double the pixel distance the text is to be moved below 'y' (which is zero in this case). Not what I expected, but at least it's not hard to remember.

Why does gr.GdiDrawText work this way?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-03-05 00:35:31
The RIGHT variable is actually a combination of flags (see helpers.js) and one of them is to vertically centre the text. If you draw rectangles using the same co-ordinates as your text, you'll see a result like this.

(https://i.imgur.com/l2VX8MH.png)

This is working exactly as expected and I'm not really sure what your problem is???

Also, never use gdiFont inside on_paint like that. Just create a variable outside the function and re-use it

Code: [Select]
var font = _.gdiFont("Segoe UI", 12);

function on_paint(gr) {
    gr.GdiDrawText("50h", font, _.RGB(255, 255, 0), 10, 10, 40, 50, RIGHT);
}

edited: because I don't really understand what you're asking.
Title: Re: JScript Panel script discussion/help
Post by: Jailhouse on 2016-03-05 01:24:20
It is working exactly as expected and your problem is how you've decided to increment the height of the rectangles rather than using a fixed height and adjusting the y position.

Also, never use gdiFont inside on_paint like that. Just create a variable outside the function and re-use it

Code: [Select]
var font = _.gdiFont("Segoe UI", 12);

function on_paint(gr) {
    gr.GdiDrawText("50h", font, _.RGB(255, 255, 0), 10, 10, 40, 50, RIGHT);
}


So I'm basically making a box and putting text in it; okay, that makes sense now. Part of my confusion is that the original script left y at zero (to my befuddlement) and changed h (ditto), and I followed suit. I find it obvious now that it was done that way to allow the text to stay in the middle of the panel with the seekbar when the panel height changes. My panel will fit into a specific area, so I'm hard-coding the positioning.

The original script also uses panel.fonts and at the time I couldn't find where that was to make changes (panel.js, I now presume), so I went with what I knew would work. I'll definitely create variables for fonts and colors and such from here on out.

Thank you for the information. It is very much appreciated.
Title: Re: JScript Panel script discussion/help
Post by: Axonn on 2016-03-06 14:21:00
Hey guys :). I'd like to start work at a script for the JS Panel in Foobar. Where can I find some tutorials regarding the API of JSPanel? I already found this:

https://github.com/19379/foo-jscript-panel/wiki/Editor-Properties

And of course I can look at some source code from the existing scripts.

But is there any tutorial anywhere which covers some of the basics of setting up an UI and calling Foobar API?

I'm talking about stuff like this: fb.CreateContextMenuManager();

I'd like to see all the methods that the fb object has, along with signatures (arguments required, returned types).
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-03-06 16:11:49
Unfortunately, there aren't any tutorials as such. The main file you want to look at is the component folder>docs>Interfaces.txt

Most methods have a single line example but more complex ones like fb.CreateContextMenuManager will point you toward some scripts contained within the samples folder.

https://github.com/19379/foo-jscript-panel/blob/master/foobar2000/foo_jscript_panel/docs/Interfaces.txt#L87L102
Title: Re: JScript Panel script discussion/help
Post by: juniiflow on 2016-03-06 17:58:21
kinda enjoyed the more plain look on the other wsh playlist
Title: Re: JScript Panel script discussion/help
Post by: juniiflow on 2016-03-07 04:51:33
By the way do any of you know how to remove the track # for this playlist? I remember I did it on the other one with whs mod
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-03-09 10:51:13
If anyone uses my JSplaylist-mod, it has been updated so the minutes/seconds display text in the group header is replaced with just numbers.

https://github.com/19379/jsplaylist-mod
Title: Re: JScript Panel script discussion/help
Post by: Axonn on 2016-03-11 09:50:24
Hey marc :). Apparently you blocked PMs so...

I really like what you've done with the JS Panel and WSH Panel. You've helped / are helping a lot of people build components. I'd like to donate to you, as a sign of appreciation for your contributions.
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2016-03-13 14:06:58
I'm trying to run the "quicksearch for same" command on every new track and I guess jscript is the only way. Is there a script I can look at to understand how to do this? I mean a script that does something simple when a new track starts.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-03-13 15:48:42
@Axonn, just sling a few pennies towards a charity of your choice.

@davideleo, you can do something like...

Code: [Select]
function on_playback_new_track() {
    fb.RunContextCommand("path/to/command");
}

IIRC, you use columns UI so you can hide this panel.
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2016-03-13 16:42:54
@davideleo, you can do something like...

Code: [Select]
function on_playback_new_track() {
    fb.RunContextCommand("path/to/command");
}

IIRC, you use columns UI so you can hide this panel.

Wow! That worked, thanks a lot!!  :D 
Now I'd like to make it a little bit more complicated: the quick search command should be different according to which panel is visible. I'm already using a PSS global variable which is called "quicksearch" and is set to the proper parameter (genre, artist or album) when I click on the panel switch.

I guess I have to declare a jscript variable and write something like:

Code: [Select]
var quicksearch = "the PSS global variable value";
var command = "Quicksearch for same/" + quicksearch;

function on_playback_new_track() {
    fb.RunContextCommand(command);
}

Besides the syntax of what I wrote above, which is likely faulty here and there, can I recall PSS global variable values in the jscript panel?
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2016-03-13 17:55:55
Besides the syntax of what I wrote above, which is likely faulty here and there, can I recall PSS global variable values in the jscript panel?

I tried this:
Code: [Select]
var quicksearch = fb.TitleFormat("%quicksearch%");
var command = "Quicksearch for same/" + quicksearch;

function on_playback_new_track() {
    fb.RunContextCommand(command);
}


I don't know if it makes sense, but it doesn't work.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-03-13 19:30:48
can I recall PSS global variable values in the jscript panel?

Short answer: no
Longer answer: with lots of script hacking it may me possible. Basically you'd use $movepanel in PSS to resize the Jscript Panel based on the value of your global variable. JScript Panel can then detect its own height/width and adjust the command accordingly. I don't really have the time or inclination to spell it all out though.

BTW, fb.TitleFormat is used for reading tags from files and you need to use it in conjunction with Eval or EvalWithMetadb
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-03-13 22:54:52
Bit of a schoolboy error but I just realised my track info + seekbar + buttons didn't update the artist/title if tags were edited during playback, This has now been fixed.

https://github.com/19379/js-marc2003/releases
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2016-03-14 00:18:08
can I recall PSS global variable values in the jscript panel?

Short answer: no
Longer answer: with lots of script hacking it may me possible. Basically you'd use $movepanel in PSS to resize the Jscript Panel based on the value of your global variable. JScript Panel can then detect its own height/width and adjust the command accordingly. I don't really have the time or inclination to spell it all out though.

I actually found out all I need to do is put a jscript panel as a child in each of the PSS panels, with a different quicksearch command for each of them. You really made my day! Now my set up is almost perfect, thanks again.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-03-14 00:41:21
You do realise all code in each panel will be executed at once? This is going to trigger your quicksearch command 3 times if the previous post about genre, artist and album was correct. If that was your intention, you can do it from a single panel/function.
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2016-03-14 00:55:49
You do realise all code in each panel will be executed at once? [...] If that was your intention, you can do it from a single panel/function.

I just did and nope, that was not my intention.
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2016-03-14 01:04:21
Longer answer: with lots of script hacking it may me possible. Basically you'd use $movepanel in PSS to resize the Jscript Panel based on the value of your global variable. JScript Panel can then detect its own height/width and adjust the command accordingly. I don't really have the time or inclination to spell it all out though.

Let me see if I got this right: you mean I could write a conditional statement in the jscript panel which outputs a different quicksearch command according to the size of the panel?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-03-14 01:53:28
You can use window.Width and window.Height.

Code: [Select]
if (window.Height == 1)

or

Code: [Select]
switch (window.Height) {
case 1:
    //do something
   break;
case 2:
   //do something else
   break;
}
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2016-03-14 02:38:46
I managed!  :))  Excellent! Thanks a lot marc!
Title: Re: JScript Panel script discussion/help
Post by: Jailhouse on 2016-03-14 23:00:54
@marc2003

When creating a volume object ...
Code: [Select]
var volume = new _.volume(0, 0, 0, 0);
... do the arguments take only numbers, i.e., are variables not allowed?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-03-14 23:55:16
Of course you can use variables - so long as they are numbers.

Code: [Select]
var a = 200; //right
var b = "boo"; //wrong
var c = false; //wrong

 Just remember that x,y,w,h set there can only be fixed values. If you need position/size relative to the overall panel size then you update in the on_size callback like my sample already does.

Code: [Select]
function on_size() {
volume.w = window.Width;
volume.h = window.Height;
}

If you want it to float in the bottom right of the panel, you can do something like this...

Code: [Select]
function on_size() {
volume.x = window.Width - 200;
volume.y = window.Height - 20;
volume.w = 195;
volume.h = 15;
}




Title: Re: JScript Panel script discussion/help
Post by: Jailhouse on 2016-03-15 01:14:32
That makes sense, but why shouldn't this work...
Code: [Select]
var vx = (panel.w - panel.h) - 27;
var volume = new _.volume(vx, 70, 10, 110);
//vx result is 27 but should be 759
...while this does?
Code: [Select]
var vx = 759;
var volume = new _.volume(vx, 70, 10, 110);
I'm missing something.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-03-15 01:46:05
panel.w and panel.h

There is no panel object in the volume/seekbar scripts. You really must have been sleeping!
Title: Re: JScript Panel script discussion/help
Post by: Jailhouse on 2016-03-15 02:10:25
But there is in 'track info + seekbar + buttons', which is the basis of this project. And this works:

Code: [Select]
function on_size() {
panel.size();
seekbar.x = 100;
seekbar.w = panel.w - panel.h - 300;
seekbar.y = (panel.h - 20) / 2;
    volume.x = panel.w - panel.h - 27; //no problem
buttons.update();
}

I edited my last reply; you may need to re-read it. Oh, and the result for vx is -27, not 27. Has on_size not run yet?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-03-15 02:29:00
Docs\Notes & Hints...

https://github.com/19379/foo-jscript-panel/blob/master/foobar2000/foo_jscript_panel/docs/Notes%20%26%20Hints.txt#L10L11
Title: Re: JScript Panel script discussion/help
Post by: Jailhouse on 2016-03-15 02:34:32
I read that a while ago; I should probably review it every so often. Like daily.  :-[ 

Thanks!
Title: Re: JScript Panel script discussion/help
Post by: fabiospark on 2016-03-16 19:57:25
I'm trying your samples scripts and I have a little question.

The Allmusic review looks for the album review: can I change it to look for the title review?
And also for the Allmusic categories for the title?

Thanks.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-03-17 00:00:58
I had a quick look at the underlying html of the song search results and it's quite different to the album results so it would require a good bit of work to get it done. I might have a look when I have more time.
Title: Re: JScript Panel script discussion/help
Post by: Jailhouse on 2016-03-24 04:53:17
Using the const statement results in an error:

Code: [Select]
JavaScript compilation error:
Syntax error
File: <main>
Line: 66, Col: 1
const ppd = "■";

The const keyword highlights in blue in the editor as expected. Using ASCII characters or numbers as opposed to the char shown produces the same result.

I understand the const statement is a relatively new addition to JavaScript. Is it not supported by the version used for JScript Panel?
Title: Re: JScript Panel script discussion/help
Post by: kode54 on 2016-03-24 04:58:06
It probably uses Windows Scripting Host, which probably won't be updated for ES2015, which is required for the const keyword.

So, expect whatever level of JavaScript capability that will work with the version of Internet Explorer or cscript/wscript on your machine.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-03-24 08:08:16
We're basically stuck with windows script host which is IE8 levels of Javascript support.

However, you can use libraries like lodash or underscore which provides all sorts of neat ES5 features like filter, map, bind, foreach etc. I already bundle lodash with my sample scripts and full docs for it can be found here...

https://github.com/lodash/lodash/blob/3.10.1/doc/README.md
Title: Re: JScript Panel script discussion/help
Post by: Jailhouse on 2016-03-24 18:37:21
Because it's included by your script I'm using as a base, I looked at lodash.js in Notepad++ () and found it rather dense, to say the least. I didn't think to search for it online, although that results in information overload. So many thanks for the link; it's exactly what I needed.

I see from a Microsoft support page that their browsers (including Edge) support const. Too bad they haven't extended that to WSH. Being a long-time user of VBA (and thus const), I'm kind of peeved about that.
Title: Re: JScript Panel script discussion/help
Post by: foosion on 2016-03-24 21:40:51
Microsofts JavaScript engine Chakra has its own set of APIs which are incompatible with WSH. There are good reasons for that. With the COM based API of WSH some modern JavaScript features are hard* or impossible to implement or just plain slow**. With the new engine you gain a lot at the cost of settling for a single language.

You can embed the new engine in your own applications (see JavaScript Runtime Hosting (https://msdn.microsoft.com/en-us/library/dn249673(v=vs.94).aspx), JSRT). However this is not an option for foo_jscript_panel. The differences between JSRT and WSH are just too big, regarding both the APIs for embedding and the APIs available to scripts.

*: Try to store a function of the standard JS objects in a variable, e.g. Math.sin. Now do the same for a function implement by this component. It would be a hell of a lot of work to make this possible. With JSRT it is trivial.
**: An array in a WSH script is really a dictionary where the keys are the lexical representations of the indices. This means anArray[myIndex] is really the same as anArray[myIndex.toString()].
Title: Re: JScript Panel script discussion/help
Post by: Jailhouse on 2016-03-25 00:35:14
Well, I'll just have to take what I'm given and like it then! Fortunately, I do, even without const. Thanks for the explanation.

As to arrays, are they so slow that they should be avoided in JScript Panel scripts?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-03-25 01:33:13
I looked at lodash.js in Notepad++ () and found it rather dense,

You missed a key part of the filename. It is lodash.min.js which indicates it has been minified (https://en.wikipedia.org/wiki/Minification_%28programming%29)!

I should add that you should only refer to the document I linked to. Do not look at the current lodash website/docs as WSH is no longer supported and there have been significant changes to their API which don't apply to the version we're using.

As for arrays, I use them extensively when using web services or scraping websites. No one has complained about the milliseconds it takes to parse being too slow.
Title: Re: JScript Panel script discussion/help
Post by: Jailhouse on 2016-03-25 04:07:30
Yes, you got me--I missed the .min. But now I know what that signifies, so I've proven I can learn from my mistakes. And I won't make the mistake of deviating from the linked doc because I'd just confuse myself all the more. Thanks again.
Title: Re: JScript Panel script discussion/help
Post by: migynster on 2016-03-25 06:36:34
I'm trying to switch to this from Biography View plugin, someone can point me out to a script similar to Thumbs but for automatically download ALBUM art from last.fm?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-03-25 17:46:13
I'm not aware of any. I've never bothered myself because the quality is pretty bad. Although the same can be said of some artist images, there is some decent stuff to be found.

IIRC, the image functionality of that other component still works so there's no reason not to continue using it.
Title: Re: JScript Panel script discussion/help
Post by: migynster on 2016-03-25 22:30:54
I use it primarily as a source for internal Album Art Viewer. So quality is not really bother me, just too lazy to search.
It downloads now only one picture 300x300, but i need biography and other stuff. Don't see the point to use 2 plugins with same functionality. I waited half year for update or something, time to move on i guess.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-03-26 03:17:17
I'll take a look at the last.fm website later and see if it's an easy fix. If it's just a few lines of code, I can post an update.
Title: Re: JScript Panel script discussion/help
Post by: foosion on 2016-03-26 09:44:03
As to arrays, are they so slow that they should be avoided in JScript Panel scripts?
No, as marc2003 said you should be fine. This is just one factor which makes WSH slower than a modern JavaScript engine. You probably should not try to use asm.js code in scripts though.
Title: Re: JScript Panel script discussion/help
Post by: Jailhouse on 2016-03-26 14:39:24
You probably should not try to use asm.js code in scripts though.

That shouldn't be a problem. I'm still basically a JavaScript noob, and I had to go look up what asm.js is.
Title: Re: JScript Panel script discussion/help
Post by: TakuSkan on 2016-03-27 07:01:55
I'll take a look at the last.fm website later and see if it's an easy fix. If it's just a few lines of code, I can post an update.

It'd be really great if you could get that going marc2003.  I finally got around to putting together a build based on br3tt's old Kameleon using his new jscript smooth playlist panels and a number of yours including the last.fm bio script.  It'd be really nice to have it auto-download album art.  I'll get back here to post a few questions in a new thread.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-03-27 08:41:09
No album art yet but I have posted some other updates.

Quote
Thumbs: Download limits have been increased and the default has been reset to 10. Also, automatic downloads are now an option but turned off by default. Simply use the right click menu to enable.

Automatic downloads only trigger when the following conditions are true:

  • a new track begins and the artist is different from the previous track
  • there are no existing images. Use the Download now option if you want to check for more.
  • the last automatic check was more than an hour ago. Timestamps are maintained by the script to prevent unnecessary requests if there were no images found previously.

Musicbrainz: Now attempts to retry up to 5 times on failure.

https://github.com/19379/js-marc2003/releases

Also, I just want to make one thing very clear.... there is no support if automatic downloads don't work for you. Simply use another script/software/fix it yourself/whatever.  ;D

It should work with dynamic stream changes but I haven't tested that. It would be good to get some confirmation on that.
Title: Re: JScript Panel script discussion/help
Post by: TakuSkan on 2016-03-27 11:41:09
Thumbs.txt in v3.0 is identical to thumbs.txt in v2.7??  ???
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-03-27 11:46:01
Correct. All the changes are to files inside the js_marc2003\js folder.

edit
: I just realised my wiki page was poorly worded so I've updated it.

Quote
Unlike previous versions, updates must be downloaded manually. Just extract the whole zip contents in to your existing js_marc2003 folder and overwrite the old files when prompted. On the rare occasion a script inside a panel needs updating, it will be mentioned on the releases page.

https://github.com/19379/js-marc2003/wiki/Updates-&-Support

You should be able to tell from the new right click menu options:

(https://i.imgur.com/gUIrFNh.png)
Title: Re: JScript Panel script discussion/help
Post by: mire777 on 2016-03-27 12:05:43
I'll take a look at the last.fm website later and see if it's an easy fix. If it's just a few lines of code, I can post an update.


I noticed, that your thumbs script keep rotating images, insted it stops and start again when download is finished..
If you need, here is fix for that(you can figure it out):

Code: [Select]
 
//Download Image
function download()
{
try {
if (lfm_folder=="<default>") {folder = fbfolder + "\\" + p.clean_filename(p.artist) + "\\";}
if (lfm_folder=="") {folder = fbfolder + "\\" + p.clean_filename(p.artist) + "\\";}
if (lfm_folder.indexOf(":\\") > 0) {folder = lfm_folder + "\\" + p.clean_filename(p.artist) + "\\";}
}catch (err) {{fb.trace("Biography Photos: " + "TypeError: 'folder path' undefined");} var folder;}
if (!p.fso.FolderExists(folder)) return;
{
        if (p.artist == "" || p.artist == "?") return;
       
this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(p.artist) + "/+images", true);
this.xmlhttp.send();
this.xmlhttp.onreadystatechange = function() {
if (this.xmlhttp.readyState == 4) {
if (this.xmlhttp.status == 200) {
var text = this.xmlhttp.responsetext;
                   
                    try {
                   
if (!im.doc) im.doc = new ActiveXObject("htmlfile");
im.doc.open();
var div = im.doc.createElement("div");
div.innerHTML = text;
var data = div.getElementsByTagName("img");
var urls = [];
for (i = 1; i < data.length; i++) {
if (data[i].src.indexOf("http://img2-ak.lst.fm/i/u/avatar170s/") == 0) urls.push(data[i].src.replace("avatar170s", size == "low" ? "300x300" : size == "medium" ? "500x500" : size == "high" ? "_" : "_"));
}
                   
for (i = 0; i < Math.min(urls.length, im.limit, 50); i++) {
p.WshShell.Run("cscript //nologo \"" + p.script_path + "bio_photos.vbs\" \"" + urls[i] + "\" \"" + [folder + p.clean_filename(p.artist) + "_" + i] + urls[i].substring(urls[i].lastIndexOf("/")+1000) + ".jpg" + "\"",0,false);
                    }
                   
                    //Update Images--------------------------------------------
                    var cicleTimerStarted2 = false;
                    var cicleTimer2 = null;
                   
                    //Start Timer 2 (Func)
                    (function startTimer2(){
                    if(!cicleTimerStarted2){
                    cicleTimer2 = window.SetInterval(function() {on_timer();}, "500");
                    cicleTimerStarted2 = true;
                    }})();
                   
                    //Stop Timer 2 (Func)
                    function stopTimer2(){
                    if(!cicleTimerStarted2) return;
                    window.ClearInterval(cicleTimer2);
                    cicleTimer2 = undefined;
                    cicleTimerStarted2 = false;
                    }
                   
                    //Definitions
                    var pos = 0;
                    if(urls.length<im.limit) {var num = urls.length;}
                    else
                    if(urls.length>im.limit) {var num = im.limit;}
                   
                    //*On Timer*
                    function on_timer(id) {
                    if(cicleTimer2 && id == cicleTimer2.ID){

                    //Check Files on Timer
                    var list = utils.Glob(folder + "\\*.jpg").toArray();
                    var a = [];
                    //fb.trace("files: " + list);
                    for (i = 0; i < list.length; i++) {
                    if (list[i]) a.push(list[i]);  
                    }
                   
                    //Length
                    l = list.length;
                   
                    //Update On First Down.(Keep Position)
                    if(im.images.length==0 && l>0) {
                    im.update();
                    pos = list.toString();
                    if(pos.indexOf("_0")>0) {pos=0;}
                    else
                    if(pos.indexOf("_1")>0) {pos=1;}
                    else
                    if(pos.indexOf("_2")>0) {pos=2;}
                    else
                    if(pos.indexOf("_3")>0) {pos=3;}
                    else
                    if(pos.indexOf("_4")>0) {pos=4;}
                    else
                    if(pos.indexOf("_5")>0) {pos=5;}
                    }
                   
                    //Stop Main Timer
                    stopTimer();
                   
                    //Wait Untill All Images Are Down.
                    if(l<num) {return true;}
                   
                    //Update All Images
                    im.update();
                    window.NotifyOthers("images", "update");
                   
                    //Keep Image Position
                    im.index=pos;
                   
                    //Stop Timer 2
                    stopTimer2();
                   
                    //Start Main Timer
                    startTimer();
                    return false;
                    }}
                    //End Of Update--------------------------------------------

                    im.doc.close();
                    } catch (err) {im.doc.close();}

    } else {
p.console("HTTP error: " + this.xmlhttp.status);
}}}}}
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-03-27 12:41:21
(https://i.imgur.com/43HrVqh.jpg)
Title: Re: JScript Panel script discussion/help
Post by: TakuSkan on 2016-03-27 13:07:42
Correct. All the changes are to files inside the js_marc2003\js folder.

Very, very nice marc2003.
Title: Re: JScript Panel script discussion/help
Post by: Jailhouse on 2016-03-30 01:15:06
I have four playlists which among them should contain every track in my library. To make sure of that, I post the number of tracks in each playlist along with their total and compare the total to the number of tracks in the Album List. I had been getting the latter figure by opening Properties on the All Music entry at the top of the list and reading the number of items listed in the title bar, but thought there must be a way to let my script retrieve it. This is what I came up with...

Code: [Select]
LibraryTotalTracks = fb.GetLibraryItems().count;

..but in testing, I've determined that fb.GetLibraryItems() gets handles for the tracks in the playlists rather than the Album List as I had led myself to believe. (I thought Library != Playlists. Oops!)

Is there a method to get the Album List number of tracks? Or do I need to revert to stare-and-compare?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-03-30 02:57:31
..but in testing, I've determined that fb.GetLibraryItems() gets handles for the tracks in the playlists rather than the Album List as I had led myself to believe. (I thought Library != Playlists. Oops!)

I suggest you go away and test again. For you to think fb.GetLibraryItems has anything to do with playlist contents is quite insulting.

Remember that you need to use the on_library_items_added and on_library_items_removed callbacks if you want to track changes while foobar is running.
Title: Re: JScript Panel script discussion/help
Post by: Jailhouse on 2016-03-30 05:09:48
I suggest you go away and test again. For you to think fb.GetLibraryItems has anything to do with playlist contents is quite insulting.
I'm sorry if you feel insulted, as that is never my intent, but that is what it looked like to me. I'm still relatively new at both JavaScript and foobar, so I'm going to be confused on occasion. It's a good thing I learn from my mistakes, because I make a lot of them. And hey, I was right about fb.GetLibraryItems in the first place; I just blew the call on my results.

Quote
Remember that you need to use the on_library_items_added and on_library_items_removed callbacks if you want to track changes while foobar is running.
I didn't really know that in the first place, so memory couldn't have served. The problem is that I use Notepad++ to keep documentation files open for reference, but I didn't have Callbacks.txt onboard and didn't realize what I was missing. I would have searched on 'library' (which is how I found fb.GetLibraryItems), found the callbacks mentioned and, because on_playlist_items_added and on_playlist_items_removed are already in the script, would probably have eventually figured I needed those, too.

I wonder what the hell else I'm missing.

Anyway, thanks for setting me straight on the missing callbacks. I'll add them in, rip more CDs and see what I get.
Title: Re: JScript Panel script discussion/help
Post by: yuushin on 2016-03-30 05:58:30
No album art yet but I have posted some other updates.

Quote
Thumbs: Download limits have been increased and the default has been reset to 10. Also, automatic downloads are now an option but turned off by default. Simply use the right click menu to enable.

Automatic downloads only trigger when the following conditions are true:

  • a new track begins and the artist is different from the previous track
  • there are no existing images. Use the Download now option if you want to check for more.
  • the last automatic check was more than an hour ago. Timestamps are maintained by the script to prevent unnecessary requests if there were no images found previously.

Musicbrainz: Now attempts to retry up to 5 times on failure.

https://github.com/19379/js-marc2003/releases

Also, I just want to make one thing very clear.... there is no support if automatic downloads don't work for you. Simply use another script/software/fix it yourself/whatever.  ;D

It should work with dynamic stream changes but I haven't tested that. It would be good to get some confirmation on that.
my artist arts don't get downloaded at all, I even emptied the wsh_data folder, the bio got downloaded, but not the arts
is there any way to troubleshoot this ? I'm new to this foobar thing
Title: Re: JScript Panel script discussion/help
Post by: yuushin on 2016-03-30 10:49:20
my artist arts don't get downloaded at all, I even emptied the wsh_data folder, the bio got downloaded, but not the arts
is there any way to troubleshoot this ? I'm new to this foobar thing

Oh jeez never mind, turns out my .vbs file needed to be re-associated

btw there is no edit button for the post here ?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-03-30 12:04:13
File associations shouldn't even matter because my script calls cscript.exe with the full path to the vbs file.

BTW, you can only edit during the first hour after posting. It's hidden away under the More button at the bottom right of each your posts.
Title: Re: JScript Panel script discussion/help
Post by: yuushin on 2016-03-30 12:42:23
I dunno what that cscript.exe is but I ran that whole command "csript //nologo "download.vbs" "url" "filename" and got the error "input error:there is no script engine for file extension ".vbs"" in command prompt
so I re-associate it with "assoc .vbs=VBSFile" and it's working the way it should be
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-03-30 12:55:08
That's weird. I just associated vbs files with Notepad++ and my script still works for me.

edit: just checked with assoc and it still says VBSFILE..

Code: [Select]
.vbs=VBSFile

I guess this goes beyond what I know about.  :-X
Title: Re: JScript Panel script discussion/help
Post by: yuushin on 2016-03-30 13:00:33
Yea I just did the same experiment as you and it worked too. I guess it's another kind of association that was lost due to the long time use of windows (I haven't reinstalled since 2009).
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-04-02 12:17:12
It seems the echonest have shut down their API so I've removed the script from my package. Also, my thumbs script has been updated so it only downloads automatically when playing.

https://github.com/19379/js-marc2003/releases
Title: Re: JScript Panel script discussion/help
Post by: Just_Addict on 2016-04-03 02:18:41
Is it possible with a JScript panel script to utilize Windows API calls?

I seem to remember that since it uses the scripting engine, this was possible.

The reason why I ask is that I have constructed a panel layout using a Panel Stack Splitter to split that panel in several sections (2 rows of 3) to house some Channel Spectrum panels.

Now for the effect I am after, these Channel Spectrums need to have their border property set to to None. But the Panel Stack Splitter itself does not have an option to set the border style.

So I was thinking, if a JScript can access the Windows API, I could insert a very small JScript panel into this layout (got some playroom) to set the border style of the container Stack Panel to Static Edge (equals the "Grey" style from the border style dropdowns)

PS. hehe, was enumeriting the Foobar window to see if there's even a border style that could be set and noticed the developer(s) probably had some difficulties with certain panel groups :) saw some names like ..._STATUS_PAIN... and ..._TOOLBAR_PAIN :p

PS; I realize trial & error could possibly get me the answer, but I can barely manage to modify an existing script to do what I want, let alone write one from scratch. I don't mind going that route but then I would like to know up front if this is possible from within a JScript panel. Wouldn't want to spent a lot of time trying to master the intricacies of the JScript Panel only to find out it isn't possible.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-04-03 04:22:03
Why not use the edge style options built in to the channel spectrum component? As for everything else, the answer is no.
Title: Re: JScript Panel script discussion/help
Post by: Just_Addict on 2016-04-03 12:31:08
Why not use the edge style options built in to the channel spectrum component?
Well, that's exactly what I didn't want to do since that kills the effect I was going for...
it also looks ugly having a bunch of little rectangular edges inside the main panel.
So I guess I have to stick with the ugly metro look for that panel. Flat....

thanks for preventing a wild goose chase.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-04-03 13:23:26
You can probably mimic the effect by using $drawrect in your PSS.
Title: Re: JScript Panel script discussion/help
Post by: juniiflow on 2016-04-03 18:31:44
By the way do any of you know how to remove the track # for this playlist? I remember I did it on the other one with whs mod
Still looking for a way to do this if any of you know please tell me
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-04-04 11:01:31
What playlist are you talking about? Falstaff's JSplaylist (which I modded for JScript Panel) uses columns like other playlists which you can toggle on/off. Press CTRL+t if you've hidden the column headers.

If you're using Falstaff's JSsmooth playlist, you might need to edit the script.
Title: Re: JScript Panel script discussion/help
Post by: Andreasvb on 2016-04-04 16:41:20
marc2003, using your old script for writing playcount from last.fm and getting following error with both the updated WSH and JScript Panel.
Code: [Select]
JScript Panel (Playcount Sync (file tags) by marc2003): Microsoft JScript runtime error:
Object doesn't support this property or method
File: D:\Apps\PortableApps\foobar2000\scripts\marc2003\common.js
Line: 130, Col: 16
<source text only available at compile time>
Error row:
Code: [Select]
if (g_metadb) window.UnwatchMetadb();

Any suggestion how to make it work again?
Thanks.

Panel code:
Spoiler (click to show/hide)
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-04-04 16:50:05
You need WSH panel mod v1.5.6 for a script that old.

https://code.google.com/archive/p/foo-wsh-panel-mod/downloads
Title: Re: JScript Panel script discussion/help
Post by: Andreasvb on 2016-04-04 18:03:45
You need WSH panel mod v1.5.6 for a script that old.

https://code.google.com/archive/p/foo-wsh-panel-mod/downloads
It's such a good script, not willing to abandon it for a newer non-compliant version.  O:)
Thanks for making it.
Title: Re: JScript Panel script discussion/help
Post by: Mans on 2016-04-06 18:04:30
Problem  with mouse wheel scrolling, in last fm bio  text, steps are big, about 5 strings, and breaks appear in reading text. problem in the computer or in a script? changed computer mouse options does nothing
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-04-07 07:52:45
Put this in a panel and show me the results from the console when scrolling up and then down...

Code: [Select]
function on_mouse_wheel(a, b, c) {
    fb.trace("a: " + a);
    fb.trace("b: " + b);
    fb.trace("c: " + c);
}

In the meantime, you can use the up/down buttons to scroll (install the font if you can't see them). If using the now playing (basic) script, there is a bug where clicking too quickly will open the background image so this has been fixed.

https://github.com/19379/js-marc2003/releases

I've also added a Stop button to track info + seekbar + buttons.
Title: Re: JScript Panel script discussion/help
Post by: Mans on 2016-04-07 12:09:01
Down
a: -1
b: -120
c: 120
Up
a: 1
b: 120
c: 120
using up/down buttons same too
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-04-07 15:59:13
Ah, you don't have the problem I was thinking of.

The default of 5 shouldn't be a problem so long as you don't do anything stupid like having a really small panel. If you want to change the default of 5 lines, you can open js_marc2003\js\text.js and look for the this.wheel function. Inside, change the number 5 to whatever.

If you're getting big gaps between lines/paragraphs then that will be because of how the source text is formatted on Last.fm. Anyone with an account can edit the wiki pages.
Title: Re: JScript Panel script discussion/help
Post by: Scrummble on 2016-04-12 14:32:16
.......... I just solved my problem 5 minutes after this post. Dismiss this please.
Title: Re: JScript Panel script discussion/help
Post by: Scrummble on 2016-04-13 09:11:11
Another problem came up.
It seems that if I create an empty image (gdi.CreateImage), and write some text in it (GdiDrawText), the edge of the characters' shape are seen as 1px dark lines. If the image is going to be used on a white background, the dark edges can be annoying.
Are there any methods to avoid them, without giving up using gdi.CreateImage? I thought this was due to SetTextRenderingHint, but soon it was denied in experiments.
screenshot: (http://i.imgur.com/SZqTbJI.png)
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-04-13 11:06:11
Try DrawString instead...

Code: [Select]
temp_gr.SetTextRenderingHint(4);
temp_gr.DrawString(...);
Title: Re: JScript Panel script discussion/help
Post by: Scrummble on 2016-04-13 15:34:17
Try DrawString instead...
That works. Thanks!
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-04-14 23:24:25
I've knocked up a quick and dirty script for downloading album art from Last.fm if anyone wants to test it.

https://gist.github.com/19379/685a2fac5d45fd9a6231fe5fab156dc5

Make sure you edit the filename to match what you want and also update the main foobar2000 album art preferences to match.

It requires the js_marc2003 folder from my main samples (link in sig).
Title: Re: JScript Panel script discussion/help
Post by: Daeron on 2016-04-15 13:17:44
Seems to be working fine, thanks marc2003!

A suggestion: add a toggle to set whether art should be downloaded for all tracks, or tracks in the library only.
Title: Re: JScript Panel script discussion/help
Post by: Axonn on 2016-04-16 10:08:03
marc2003, thank you so much for replying here so often and supporting your component in this wonderful way. I flung more than a few pennies towards charities and artists and also supporting Foobar mobile & component developers. Yet, your support, time and effort is much appreciated and I'd still like to contribute somehow. So if money's not an option, let's see what scripts I can make :).

Now I have a question concerning hotkeys. I am quite keyboard-focused and for me it's essential to be able to navigate through a program using the keyboard. My question is this:

Is it possible for each JS Panel to hook into Foobar's keyboard shortcuts system and register a shortcut for bringing the keyboard focus to that panel? I'm asking this because I plan to have 2-3 JS Panels open, plus a ColumnsUI playlist and I'd like to navigate between them. In the same time, I'd like each panel to react to its own keyboard shortcuts only when I'm inside that panel (I've seen that scripts already do this, for example when doing name searches inside a JS Panel you see those letters show up that show what you've been typing).

Another question: are CTRL, ALT modifiers usable with the JS Panel?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-04-16 14:49:21
A suggestion: add a toggle to set whether art should be downloaded for all tracks, or tracks in the library only.

Yep, I'll post in this thread when I update it.

Now I have a question concerning hotkeys.

Currently, the panel has to have focus to accept input. You can use modifiers like this...

Code: [Select]
var VK_SHIFT = 0x10;
var VK_CONTROL = 0x11;
var VK_ALT = 0x12;

function on_key_down(vkey) {
if (utils.IsKeyPressed(VK_CONTROL) && utils.IsKeyPressed(VK_ALT) && vkey == 65)
fb.ShowPopupMessage("ctrl + alt + a");
}

The likelihood of me creating keyboard shortcuts to focus a panel is pretty much zero but I think it would be possible to create main menu items which could trigger callbacks in all panels. Obviously those menu items have to be shared across all scripts from all users so my recommendation would be to implement them in personal scripts only and of course each user would have to bind these menu items to their own keyboard combinations in the main preferences.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-04-16 19:10:53
I've updated my samples...

Quote
status bar: now shows playlist name next to stats. Use the right click menu to toggle details on/off. For existing users, this update requires importing the new txt file in to the panel.

All list/text based scripts have the mouse scroll step set to 3 lines.

https://github.com/19379/js-marc2003/releases
Title: Re: JScript Panel script discussion/help
Post by: Axonn on 2016-04-23 10:51:58
marc2003: I've checked the window structure of Foobar. I noticed that the JS panel windows have the class "uie_jscript_panel_class". Initially, I thought of a really ugly workaround: I will try to write a simple C++ application which can do the focusing of the JS panels for me, by using WIN32 API calls. But now I realize I could make a Foobar component that offers shortcuts for the user to set. I'd like to do this :), but a few pointers from you would be priceless to say the least. Here are 2 questions:

1. Can you indicate a way through which I can separate one JS Panel from another? They have the same class but no caption, no window title. A window title would be very handy, because I could use it when creating keyboard shortcuts for focusing the panels: <Activate JS Panel "Smooth Browser">, <Activate JS Panel "Custom Buttons">.

2. Can you (or anybody here knowledgeable in Foobar components) give me a link to a component that registers shortcuts in Foobar? An example always goes a long way :).

Thank you in advance! :)
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-04-23 17:19:04
^I have no idea. I have zero C++ knowledge and only created this component because a) WSH panel mod was already rock solid with barely any issues and b) adding new stuff from the foobar2000 SDK is easy enough when so much similar code already existed in the original component. I'm just good at copy/paste.

As I mentioned above, the code already exists for when the panel has focus and I believe the only way to create global shortcuts is by generating main menu or context menu items. These can then be bound to global keys in the main foobar preferences.





Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-04-23 17:20:37
I've updated my samples so Last.fm chart data is now accurate. There was nothing wrong with my previous code - it's just that I stupidly followed Last.fm's documented methods which I no longer do.

https://github.com/19379/js-marc2003/releases

Title: Re: JScript Panel script discussion/help
Post by: Jailhouse on 2016-04-25 00:09:59
When playing tracks in Random order, as I do most of the time, the Previous button stops playback. Since I already have a Stop button, I decided to eliminate the redundancy by repurposing Previous to act as a Back button, which restarts playback of the current track from the beginning.

I changed this (slightly modified) line from marc2003's "track info + seekbar + buttons" sample script...

Code: [Select]
this.buttons.previous = new _.button(722, 364, 36, 36, {normal : "mono\\appbar.control.rewind.png"}, function () { fb.Prev(); }, "Previous");
...to this:

Code: [Select]
this.buttons.previous = new _.button(722, 364, 36, 36, {normal : "mono\\appbar.control.rewind.png"}, plman.PlaybackOrder == random_order ? function () {fb.PlaybackTime = 0;} : function () { fb.Prev(); }, "Previous");

random_order is a var set to 3 to clarify what I'm testing for.

The Previous button works normally when not in Random order playback mode.
Title: Re: JScript Panel script discussion/help
Post by: juniiflow on 2016-04-28 16:43:17
What playlist are you talking about? Falstaff's JSplaylist (which I modded for JScript Panel) uses columns like other playlists which you can toggle on/off. Press CTRL+t if you've hidden the column headers.

If you're using Falstaff's JSsmooth playlist, you might need to edit the script.


I am talking about the default one, I just want to remove the track numbers on the left.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-04-28 18:59:27
Do you have any idea what thread you're posting in?
Title: Re: JScript Panel script discussion/help
Post by: matif on 2016-05-02 03:59:27
Hi, this is my litte work for auto tag from file name in playlist, I wrote it long time ago, grabbed from my foobar200 skin (http://forum.gamer.com.tw/Co.php?bsn=60030&sn=1589300).

If file name is "Artist - Title", and no tag, in playlist this code will make list itme show "Artist*" - "Title*", " * " means it grab from file name, then you can auto tag it, the sample code is use in playlist's context menu.
Code: [Select]
var tf_artist = fb.TitleFormat("$if(%length%,$if2(%artist%,$ifgreater($strchr(%filename%,-),0,$trim($substr(%filename%,1,$sub($strchr(%filename%,-),1)))*,?)),)");
var tf_title = fb.TitleFormat("$ifgreater($strchr(%filename%,-),0,$trim($substr(%filename%,$add($strchr(%filename%,-),1),100)*),%title%)");
//......make tf_artist & tf_title use in your playlist or elsewhere you want.

function new_context_menu(x, y, id, array_id) {
//......
list.metadblist_selection = plman.GetPlaylistSelectedItems(plman.ActivePlaylist);
var info = list.metadblist_selection.item(i).GetFileInfo();
var o_title = info.MetaValue(info.MetaFind("TITLE"), 0) ? tf_titleO : fb.TitleFormat("");
var o_artist = fb.TitleFormat("$ifequal($stricmp(%artist%,?),1,,%artist%)");
var o_album = fb.TitleFormat("$ifequal($stricmp(%album%,?),1,,%album%)");
//......
_menu.AppendMenuItem(list.metadblist_selection.count==1 && info.MetaValue(info.MetaFind("TITLE"), 0) && !tf_artist.EvalWithMetadb(list.metadblist_selection.item(i)).match(/\*/) ? MF_GRAYED|MF_DISABLED : MF_STRING, 3000, list.metadblist_selection.count==1 && ( !info.MetaValue(info.MetaFind("TITLE"), 0) || tf_artist.EvalWithMetadb(list.metadblist_selection.item(i)).match(/\*/) ) ? "Auto Tag *:" + (o_title.EvalWithMetadb(list.metadblist_selection.item(i)) ? "" : tf_title.EvalWithMetadb(list.metadblist_selection.item(i)).replace("*", "") + (o_artist.EvalWithMetadb(list.metadblist_selection.item(i)) ? "" : ", ")) + (o_artist.EvalWithMetadb(list.metadblist_selection.item(i)) ? "" : tf_artist.EvalWithMetadb(list.metadblist_selection.item(i)).replace("*", "")) : "Auto Tag *");
//......
case 3000:
for (i=0; i<list.metadblist_selection.count; i++) {
if (tf_title.EvalWithMetadb(list.metadblist_selection.item(i)).match(/\*/)) {
var title = tf_title.EvalWithMetadb(list.metadblist_selection.item(i)).replace("*", "");
list.metadblist_selection.item(i).UpdateFileInfoSimple("TITLE", title);
}
if (tf_artist.EvalWithMetadb(list.metadblist_selection.item(i)).match(/\*/)) {
var artist = tf_artist.EvalWithMetadb(list.metadblist_selection.item(i)).replace("*", "");
list.metadblist_selection.item(i).UpdateFileInfoSimple("ARTIST", artist);
}
}
break;
//......please shows source if you use this, thanks ;)......

I don't if it work in JScript Panel, just share, maybe useful for someone.
Title: Re: JScript Panel script discussion/help
Post by: widerock on 2016-05-02 05:19:58
I'd like to adjust the size of JS panel with foobar resizing as follows.
In other words, the size of JS panel shoud change proportionally with the main foobar window size.

Is ther any method to retrieve the foobar window size into the JS panel for this purpose?


Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-05-02 11:11:18
That's something foobar does by default with all panels - assuming you don't lock any splitters.
Title: Re: JScript Panel script discussion/help
Post by: widerock on 2016-05-02 11:22:11
That's something foobar does by default with all panels - assuming you don't lock any splitters.
Thank you for your reply.

More specifically, what I want to do is
In the max foobar size, I fixed the JS panel width/height = 600/400.

function on_size() {
    ww = window.Width;
    wh = window.Height;
 
    window.MinWidth = 600;
    window.MaxWidth = 600;

    window.MinHeight = 400;
    window.MaxHeight = 400;
}

And,, then I resize the foobar window size to the x% of the max foobar size.
In this case, I want to resize JS panel width/height = (600/400) * x/100.

Is this possible?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-05-02 11:36:21
Well of course it won't work if you're locking the size. Read my post again.
Title: Re: JScript Panel script discussion/help
Post by: widerock on 2016-05-02 11:42:15
Well of course it won't work if you're locking the size. Read my post again.
I'm sorry for the uncertain question.
My question is, if I can adjust the values as follows with not fixed, but as variables
    window.MinWidth = 600;   --> window.MinWidth = 0.4 x (Foobar window width)
    window.MaxWidth = 600;   --> window.MinWidth = 0.4 x (Foobar window width)
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-05-02 11:49:18
I start off with a small window and my JScript Panel is just over one third of foobar's width. I resized the splitter manually...

http://i.imgur.com/jbzzp8Y.png

Now I max the window and foobar has kept the same proportions. No script, no locked splitters.

http://i.imgur.com/MQ6eKSu.png

edit: I don't think you will be able to set a min width because then foobar will forget the proportions when you start going larger again.

I suppose you could have another panel taking up the entire width and have that notify your other panel when it is resized. I'll post something for that later but I have to go out now.
Title: Re: JScript Panel script discussion/help
Post by: widerock on 2016-05-02 11:53:57
I start off with a small window and my JScript Panel is just over one third of foobar's width. I resized the splitter manually...

http://i.imgur.com/jbzzp8Y.png

Now I max the window and foobar has kept the same proportions. No script, no locked splitters.

http://i.imgur.com/MQ6eKSu.png
OK. I got it. Thank you for your time and help.
Title: Re: JScript Panel script discussion/help
Post by: widerock on 2016-05-05 18:34:20
I'm using "now playing (basic)" script after small modification like this

Code: [Select]
var ft1 = 50, ft2 = 42, ft3 = 30, y1 = 0, y2 = 75, y3 = 150;

//the track info section displays 4 lines of title formatted text. you can customise that here/////////////////////////////////////////////

var line1 = {
text: "", //leave this blank
tf: "$if2(%artist%,No Artist Info)", //enter any title formatting
font: _.gdiFont("Segoe UI", ft1, 1), //font name, size, style. 1 means bold and 0 is normal.
colour: _.RGB(40, 40, 40), //colour
y: y1 //change this value to move text up or down.
}
var line2 = {
text: "",
tf: "$if2(%title%,No Song Info)",
font: _.gdiFont("Segoe UI", ft2, 1),
colour: _.RGB(90, 90, 90),
y: y2
}
var line3 = {
text: "",
tf: "$if([%album% ]['('%date%')'],[%album% ]['('%date%')'],No Album Info)",
font: _.gdiFont("Segoe UI", ft3, 1),
colour: _.RGB(140, 140, 140),
y: y3
}

And, I'm trying to change the font & location of line1, line2, line3 after getting a notification from another panel.
I've put "window.NotifyOthers("width_notify",ww);" within 'function on_size()' in another panel.
So, I inserted the following code to change the font size and location.
Code: [Select]
function on_notify_data(name, info) {
    if(name=="width_notify") {
        if(info==1920) {
            ft1 = 50, ft2 = 42, ft3 = 30, y1 = 0, y2 = 75, y3 = 150;
            window.Repaint();
        } else {
            ft1 = 30, ft2 = 22, ft3 = 15, y1 = 0, y2 = 40, y3 = 80;
            window.Repaint();
        }
    }
}

But this dosen't work for my purpose. I'm not familiar with the programming language.
So, please give me some hint.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-05-06 08:44:02
You're basically doing this...

Code: [Select]
var a = 1;
var b = a;

function blah() {
    a = 2; // now you're expecting "b" to take on the new value of "a" which is never going to work
}

You need to update the variables directly

Code: [Select]
line1.font = 50;
line1.y = 0;
...
Title: Re: JScript Panel script discussion/help
Post by: widerock on 2016-05-06 16:16:16
You're basically doing this...

Code: [Select]
var a = 1;
var b = a;

function blah() {
    a = 2; // now you're expecting "b" to take on the new value of "a" which is never going to work
}

You need to update the variables directly

Code: [Select]
line1.font = 50;
line1.y = 0;
...
Thank you for your help. The following is what I'm using now.
Code: [Select]
function on_notify_data(name, info) {
    if(name=="width_notify") {
        if(info==1920) {
            line0.font = _.gdiFont("Cambria", 110, 1);
            line0.y = 0;
            window.Repaint();
        } else {
            line0.font = _.gdiFont("Cambria", 80, 1);
            line0.y = 20;
            window.Repaint();
        }
    }
}
Title: Re: JScript Panel script discussion/help
Post by: widerock on 2016-05-09 17:34:38
Again, me.. :-[

Is there any method to make a shadow effect on the "now playing panel" text?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-05-10 02:16:03
Draw the text twice and have a slight offset between each one's x and y positions. Also some contrasting colour would help.

Or if you want something more fancy, see the samples folder inside the component directory>glow text sample.txt
Title: Re: JScript Panel script discussion/help
Post by: TakuSkan on 2016-05-10 09:00:07
I've knocked up a quick and dirty script for downloading album art from Last.fm if anyone wants to test it.

https://gist.github.com/19379/685a2fac5d45fd9a6231fe5fab156dc5

This works great marc.  Still am naming all my album cover art %album%, so it's nice this works since the last time (https://hydrogenaud.io/index.php/topic,103681.msg851682.html#msg851682) I stumbled around a script.

I wonder if you could help me with a problem I'm having with br3tt's smooth playlist (http://br3tt.deviantart.com/art/JS-Smooth-Playlist-571375892) script marc.  For the thumbnail cache files created in '\js_br3tt\cache\imgcache' the script looks to the track's folder, and it seems like if it doesn't find any variations in the script, it selects the 1st jpg in the folder with *.* and uses that.  I tried with limited success to change the code for name of the files the cache uses from:

Code: [Select]
masks: window.GetProperty("_PROPERTY: Cover art masks (used for the cache)","*front*.*;*cover*.*;*folder*.*;*.*"),
to just:
Code: [Select]
masks: window.GetProperty("_PROPERTY: Cover art masks (used for the cache)","%album%.*"),

It seemed like when a cache file wasn't already made, that tended to work.  But in later attempts it seemed that wasn't the case, and the script would just choose the 1st jpg in the folder it pleased.

And I've found no way to clear the cached file for the thumbnails that are wrong without deleting the entire cache folder.

Any ideas on how to address these probs?

Another problem came up.
It seems that if I create an empty image (gdi.CreateImage), and write some text in it (GdiDrawText), the edge of the characters' shape are seen as 1px dark lines. If the image is going to be used on a white background, the dark edges can be annoying.
Are there any methods to avoid them, without giving up using gdi.CreateImage? I thought this was due to SetTextRenderingHint, but soon it was denied in experiments.
screenshot: (http://i.imgur.com/SZqTbJI.png)

I'd really love to have this set up in my build to enable quick playback order preferences.  Anywhere I can grab the code for this and the graphic?



Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-05-10 11:04:00
I need to rework that album art script because it doesn't account for people using title formatting with the filename. Currently it won't work if the album contains characters that are illegal in windows. I'll post an update later.

As for looking at Falstaff/Br3tt's other scripts... nope. I made some minor mods to jsplaylist because I use it everyday. I have no interest in other people's scripts that I don't use.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-05-10 13:50:08
A suggestion: add a toggle to set whether art should be downloaded for all tracks, or tracks in the library only.

Sorry I forgot about this. It's now a variable you set at the start of the script.

https://gist.github.com/19379/685a2fac5d45fd9a6231fe5fab156dc5

It also handles illegal characters that may be contained in any title formatting used for the filename.
Title: Re: JScript Panel script discussion/help
Post by: TakuSkan on 2016-05-10 15:02:11
I need to rework that album art script because it doesn't account for people using title formatting with the filename. Currently it won't work if the album contains characters that are illegal in windows. I'll post an update later.
OK.  I just set it up, so I haven't tested it a lot.  Will keep an eye out for your update.

Quote
As for looking at Falstaff/Br3tt's other scripts... nope.
I haven't checked recently, but Br3tt never seemed to hang out in the forums very much.  Think he'd notice if I addressed him here directly?  Or maybe I'd have better luck posting on his DeviantArt page.

... I made some minor mods to jsplaylist because I use it everyday.
That's a WSH panel script from his DeviantArt page (http://br3tt.deviantart.com/art/JSPlaylist-509803158), right?  I did give that try and had considered using it as an alternative.  But since I last posted, I've confirmed that both jsplaylist and his smooth playlist prevent FB2K from completely shutting down in Windows 10.  I had to delete panels 1 by 1 until I finally found the culprit.  Wonder if your mod would be any different.  Have you made it available for download anywhere?
Title: Re: JScript Panel script discussion/help
Post by: TakuSkan on 2016-05-10 15:37:09
Sorry I forgot about this. It's now a variable you set at the start of the script.

https://gist.github.com/19379/685a2fac5d45fd9a6231fe5fab156dc5

It also handles illegal characters that may be contained in any title formatting used for the filename.

This is crashing the panel when I replace the old code marc.
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2016-05-10 17:17:03
I've knocked up a quick and dirty script for downloading album art from Last.fm if anyone wants to test it.

https://gist.github.com/19379/685a2fac5d45fd9a6231fe5fab156dc5

Make sure you edit the filename to match what you want and also update the main foobar2000 album art preferences to match.

It requires the js_marc2003 folder from my main samples (link in sig).

It works good for me. Is there a simple script line I could add to automatically attach the picture to all the files in the folder after downloading it?
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2016-05-10 19:34:21
I've knocked up a quick and dirty script for downloading album art from Last.fm if anyone wants to test it.

https://gist.github.com/19379/685a2fac5d45fd9a6231fe5fab156dc5

Make sure you edit the filename to match what you want and also update the main foobar2000 album art preferences to match.

It requires the js_marc2003 folder from my main samples (link in sig).

It works good for me.

Actually I realized it doesn't show the online pictures, even though it downloads them correctly.
Title: Re: JScript Panel script discussion/help
Post by: TakuSkan on 2016-05-10 19:47:41
Actually I realized it doesn't show the online pictures, even though it downloads them correctly.

"online pictures"??  The script will crop a little of the borders.  Resizing the panel will show the edges better.  Not sure what you mean.

Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2016-05-10 19:51:22
Actually I realized it doesn't show the online pictures, even though it downloads them correctly.

"online pictures"??  The script will crop a little of the borders.  Resizing the panel will show the edges better.  Not sure what you mean.



I mean when the album art picture is missing from the local directory, isn't the script supposed to show the picture from the lastfm online resource?
Title: Re: JScript Panel script discussion/help
Post by: TakuSkan on 2016-05-10 20:11:56
I mean when the album art picture is missing from the local directory, isn't the script supposed to show the picture from the lastfm online resource?

The script saves the graphic file in the same folder as the track, and is named: lastfm.jpg  Check the track folder to see if its there.
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2016-05-10 20:22:09
I mean when the album art picture is missing from the local directory, isn't the script supposed to show the picture from the lastfm online resource?

The script saves the graphic file in the same folder as the track, and is named: lastfm.jpg  Check the track folder to see if its there.

Yes, that works and I managed to change the default picture name as I wanted. I just thought I could see a preview of the picture on the panel.
Title: Re: JScript Panel script discussion/help
Post by: TakuSkan on 2016-05-10 20:31:35
The image should load when you skip forward a track, and then back up again if you have playback order set to default.  But you have to set FB2K to recognize the file name lastfm.jpg in preferences:

 Preferences > Display > Album Art > Front cover

What's your default cover art naming pattern?
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2016-05-10 20:44:47
The image should load when you skip forward a track, and then back up again if you have playback order set to default.  But you have to set FB2K to recognize the file name lastfm.jpg in preferences:

 Preferences > Display > Album Art > Front cover

What's your default cover art naming pattern?

$directory_path(%path%)\front.jpg (I edited the script accordingly at line 17) which I embed in the music files, so my jscript artreader is set to show the Icon. When there's no embedded icon (which usually means there's no front.jpg in the file directory either) the panel is a just a white background, even if the script finds the picture on lastfm and downloads it properly.
Title: Re: JScript Panel script discussion/help
Post by: TakuSkan on 2016-05-10 20:51:42
If you rename the downloaded file from lastfm.jpg to front.jpg, does the panel then display it?
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2016-05-10 20:56:16
If you rename the downloaded file from lastfm.jpg to front.jpg, does the panel then display it?

I edited the script so that it downloads it as "front.jpg" by default, but in order to see it in the panel I have to embed the picture first.
Title: Re: JScript Panel script discussion/help
Post by: TakuSkan on 2016-05-10 21:05:20
Okay... I missed what you'd written there. Sounds like you need the script to recognize 2 different cover art names... front.jpg for your embedded tags, and now lastfm.jpg that this script is creating.   I had this problem of with another script a while ago where I wanted the script to look for art in a couple places.  But as I recall, the script (I think in Br3tt's Kameleon) wouldn't allow it.  marc2003 or someone else may be able to tell you if it's possible.

Or... you need something to automatically write the downloaded file to the tags... if I back up I think that's what you were asking.
Title: Re: JScript Panel script discussion/help
Post by: TakuSkan on 2016-05-10 21:17:40
directory_path(%path%)\front.jpg (I edited the script accordingly at line 17)
Wait... line 17 is from marc's lastest offering above.  That crashed every copy of FB2k I tried pasting it into a jscript panel.  Did you get it to work?

The code in that script is: var filename_tf = fb.TitleFormat("lastfm.jpg");
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2016-05-10 21:30:02
directory_path(%path%)\front.jpg (I edited the script accordingly at line 17)
Did you get it to work?

The code in that script is: var filename_tf = fb.TitleFormat("lastfm.jpg");

Sure, I simply edited "lastfm.jpg" to "front.jpg".
Title: Re: JScript Panel script discussion/help
Post by: TakuSkan on 2016-05-10 21:37:25
Man... This script?  It's crashed every time I've tried putting into a jscript panel. Maybe I need the newer foo_jscript_panel-v1.1.4.

Code: [Select]
// ==PREPROCESSOR==
// @name "Last.fm Album Art Downloader"
// @author "marc2003"
// @import "%fb2k_profile_path%js_marc2003\js\lodash.min.js"
// @import "%fb2k_profile_path%js_marc2003\js\helpers.js"
// @import "%fb2k_profile_path%js_marc2003\js\panel.js"
// @import "%fb2k_profile_path%js_marc2003\js\albumart.js"
// ==/PREPROCESSOR==

// Affects downloads only. Album art will always be displayed if it's found via the patterns
// in the main preferences.
var library_tracks_only = false;
// Note that any attempt to use a folder that doesn't already exist will silently fail
var folder_tf = fb.TitleFormat("$directory_path(%path%)\\");
// Make sure File>Preferences>Display>Album art>Front matches this filename for the image
// to be displayed. Title formatting is supported.
var filename_tf = fb.TitleFormat("lastfm.jpg");

///////////////////////////////////////////////////////////////////////////////////////////////////

var panel = new _.panel("Last.fm Album Art Downloader", ["metadb", "custom_background"]);
var albumart = new _.albumart(0, 0, 0, 0);
var x = new ActiveXObject("Microsoft.XMLHTTP");
var ini = folders.settings + "album-art.ini";
_.createFolder(folders.settings);

panel.item_focus_change();

function on_size() {
panel.size();
albumart.w = panel.w;
albumart.h = panel.h;
}

function on_paint(gr) {
panel.paint(gr);
albumart.paint(gr);
}

function on_metadb_changed() {
albumart.metadb_changed();
var np = fb.GetNowPlaying();
if (panel.metadb && np && np.Compare(panel.metadb) && np.RawPath.indexOf("file://") == 0 && (!library_tracks_only || fb.IsMetadbInMediaLibrary(np))) {
var ar = panel.tf("%album artist%");
var al = panel.tf("%album%");
var f = folder_tf.EvalWithMetadb(panel.metadb) + _.fbSanitise(filename_tf.EvalWithMetadb(panel.metadb));
var tmp = _.q(_.fbSanitise(ar + al));
var n = _.round(_.now() / 1000);
var t = utils.ReadINI(ini, "Timestamps", tmp, 0);

switch (true) {
case !_.tagged(ar):
case !_.tagged(al):
case _.isFile(f):
case n - t < ONE_DAY:
break;
default:
utils.WriteINI(ini, "Timestamps", tmp, n);
x.open("GET", "http://www.last.fm/music/" + encodeURIComponent(ar) + "/" + encodeURIComponent(al) + "/+images", true);
x.setRequestHeader("If-Modified-Since", "Thu, 01 Jan 1970 00:00:00 GMT");
x.send();
x.onreadystatechange = function () {
if (x.readyState == 4) {
if (x.status == 200) {
var o = _.first(_.filter(_.getElementsByTagName(x.responsetext, "img"), {"className" : "image-list-image"}));
if (o) {
var u = o.src.replace("avatar170s", "ar0");
_.runCmd("cscript //nologo " + _.q(folders.home + "download.vbs") + " " + _.q(u) + " " + _.q(f), false);
window.SetTimeout(function () {
panel.item_focus_change();
}, 3000);
}
} else {
panel.console("HTTP error: " + x.status);
}
}
}
break;
}
}
}

function on_get_a
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2016-05-10 22:00:52
Man... This script?  It's crashed every time I've tried putting into a jscript panel. Maybe I need the newer foo_jscript_panel-v1.1.4.

Code: [Select]
// ==PREPROCESSOR==
// @name "Last.fm Album Art Downloader"
// @author "marc2003"
// @import "%fb2k_profile_path%js_marc2003\js\lodash.min.js"
// @import "%fb2k_profile_path%js_marc2003\js\helpers.js"
// @import "%fb2k_profile_path%js_marc2003\js\panel.js"
// @import "%fb2k_profile_path%js_marc2003\js\albumart.js"
// ==/PREPROCESSOR==

// Affects downloads only. Album art will always be displayed if it's found via the patterns
// in the main preferences.
var library_tracks_only = false;
// Note that any attempt to use a folder that doesn't already exist will silently fail
var folder_tf = fb.TitleFormat("$directory_path(%path%)\\");
// Make sure File>Preferences>Display>Album art>Front matches this filename for the image
// to be displayed. Title formatting is supported.
var filename_tf = fb.TitleFormat("lastfm.jpg");

///////////////////////////////////////////////////////////////////////////////////////////////////

var panel = new _.panel("Last.fm Album Art Downloader", ["metadb", "custom_background"]);
var albumart = new _.albumart(0, 0, 0, 0);
var x = new ActiveXObject("Microsoft.XMLHTTP");
var ini = folders.settings + "album-art.ini";
_.createFolder(folders.settings);

panel.item_focus_change();

function on_size() {
 panel.size();
 albumart.w = panel.w;
 albumart.h = panel.h;
}

function on_paint(gr) {
 panel.paint(gr);
 albumart.paint(gr);
}

function on_metadb_changed() {
 albumart.metadb_changed();
 var np = fb.GetNowPlaying();
 if (panel.metadb && np && np.Compare(panel.metadb) && np.RawPath.indexOf("file://") == 0 && (!library_tracks_only || fb.IsMetadbInMediaLibrary(np))) {
 var ar = panel.tf("%album artist%");
 var al = panel.tf("%album%");
 var f = folder_tf.EvalWithMetadb(panel.metadb) + _.fbSanitise(filename_tf.EvalWithMetadb(panel.metadb));
 var tmp = _.q(_.fbSanitise(ar + al));
 var n = _.round(_.now() / 1000);
 var t = utils.ReadINI(ini, "Timestamps", tmp, 0);
 
 switch (true) {
 case !_.tagged(ar):
 case !_.tagged(al):
 case _.isFile(f):
 case n - t < ONE_DAY:
 break;
 default:
 utils.WriteINI(ini, "Timestamps", tmp, n);
 x.open("GET", "http://www.last.fm/music/" + encodeURIComponent(ar) + "/" + encodeURIComponent(al) + "/+images", true);
 x.setRequestHeader("If-Modified-Since", "Thu, 01 Jan 1970 00:00:00 GMT");
 x.send();
 x.onreadystatechange = function () {
 if (x.readyState == 4) {
 if (x.status == 200) {
 var o = _.first(_.filter(_.getElementsByTagName(x.responsetext, "img"), {"className" : "image-list-image"}));
 if (o) {
 var u = o.src.replace("avatar170s", "ar0");
 _.runCmd("cscript //nologo " + _.q(folders.home + "download.vbs") + " " + _.q(u) + " " + _.q(f), false);
 window.SetTimeout(function () {
 panel.item_focus_change();
 }, 3000);
 }
 } else {
 panel.console("HTTP error: " + x.status);
 }
 }
 }
 break;
 }
 }
}

function on_get_a

I'm talking about this script (https://hydrogenaud.io/index.php?msg=920337).
Title: Re: JScript Panel script discussion/help
Post by: TakuSkan on 2016-05-10 22:13:52
I found the problem davideleo ... I copied the code to the bottom of the github page marc posted, but I failed to notice I'd missed a little more that was underneath.  My bad    :-[   All's good now  ;)
Title: Re: JScript Panel script discussion/help
Post by: chigaimaro on 2016-05-12 02:01:14
I'm new to jscript and after following the tutorials I built the following script.  Everything displays correctly, but the loop I have keeps re-drawing the panel.  Was wondering if there's a way to keep the loop from re-drawing or is there a way to just re-draw the section where time elapse and time remaining counts up and down?

Hope this makes sense  :)  Thanks in advance for any help or comments (also thanks for marc2003 for making the jscript plugin)


Code: [Select]
// ==PREPROCESSOR==
// @name "Title Header"
// @author "Chigaimaro"
// @feature "watch-metadb"
// @import "%fb2k_component_path%docs\flags.txt"
// @import "%fb2k_component_path%docs\helpers.txt"
// ==/PREPROCESSOR==

var setTitlefont = gdi.Font("Segoe UI", 16.5,0);
var artist_font = gdi.Font("Segoe UI", 13,0);
var album_font = gdi.Font("Segoe UI", 12,0);



var g_is_default_ui = window.InstanceType;
var g_font = null;
var ww = 0, wh = 0;
var g_textcolor = 0, g_textcolor_hl = 0;
var g_backcolor = 0;
var time_font = gdi.Font("Segoe UI", 18, 0);
var stat_font = gdi.Font("Segoe UI", 13, 0);
var counter = 0;
get_font();
get_colors();

   

function get_font() {
    if (g_is_default_ui) { // DUI
        g_font = window.GetFontDUI(FontTypeDUI.defaults);
    } else { // CUI
        g_font = window.GetFontCUI(FontTypeCUI.items);
    }
}

function get_colors() {
    if (g_is_default_ui) { // DUI
        g_textcolor = window.GetColorDUI(ColorTypeDUI.text);
        g_textcolor_hl = window.GetColorDUI(ColorTypeDUI.highlight);
        g_backcolor = window.GetColorDUI(ColorTypeDUI.background);
        g_selectcolor = window.GetColorDUI(ColorTypeDUI.selection);
    } else { // CUI
        g_textcolor = window.GetColorCUI(ColorTypeCUI.text);
        g_textcolor_hl = window.GetColorCUI(ColorTypeCUI.text);
        g_backcolor = window.GetColorCUI(ColorTypeCUI.background);
    }
}



function on_size() {
    ww = window.Width;
    wh = window.Height;
}

function on_paint(gr) {
    gr.FillSolidRect(0, 0, ww, wh, g_backcolor);
    for(counter = 0; counter < 6; counter++){
    var allMargin = ["0", "110", "220", "330", "440", "550"];
    var time_tags = [fb.TitleFormat("%playback_time%").Eval(),
        fb.TitleFormat("%playback_time_remaining%").Eval(),
        fb.TitleFormat("%length%").Eval(),
        fb.TitleFormat("$if2(%tracknumber%,'00')/$if2(%totaltracks%,'00')").Eval(),
        fb.TitleFormat("$if(%discnumber%,$pad_right(%discnumber%,2),'00')$if(%totaldiscs%,'/'$pad_right(%totaldiscs%,2),)").Eval(),
        fb.TitleFormat("[%replaygain_track_gain%]')").Eval()
            ]
    var labels = ["Elapsed", "Remaining", "Length", "Track/Total", "Disc/Total", "Replaygain"];
    var info_tags = [fb.TitleFormat("$info(encoding)").Eval(),
        fb.TitleFormat("$info(codec)").Eval(true),
        fb.TitleFormat("$if($info(bitrate),$info(bitrate)' kb/s','00 kb/s')").Eval(),
        fb.TitleFormat("$channels()").Eval(true),
        fb.TitleFormat("%__bitspersample%-bits").Eval(true),
        fb.TitleFormat("$info(samplerate) hz").Eval()
            ]
        tagNames = String(time_tags[counter]);
        infoNames = String(info_tags[counter]);
        labelNames = labels[counter];
        xPosition = Number(allMargin[counter]);
        gr.FillSolidRect(xPosition+5, wh - 30, 100, 20, RGBA(220,220,220,025));
        gr.DrawRoundRect(xPosition+5, wh - 30, 100, 20, 4, 4, 1, g_selectcolor);
        gr.FillGradRect(0,(wh / 2), ww, 2, 180, g_backcolor, (g_selectcolor + g_textcolor), focus = 0.5);
        gr.GdiDrawText(labelNames, stat_font, (g_selectcolor + g_backcolor), xPosition+5, wh-75, 100, 30, DT_VCENTER| DT_CALCRECT | DT_CENTER);
        if(fb.IsPlaying) {
        gr.GdiDrawText(tagNames, time_font, g_textcolor_hl, xPosition+5, wh-58, 100, 30, DT_VCENTER| DT_CALCRECT | DT_CENTER);
        gr.GdiDrawText(infoNames, stat_font, g_textcolor, xPosition+5, wh-35, 100, 30, DT_VCENTER| DT_CALCRECT | DT_CENTER);   
        gr.GdiDrawText(fb.TitleFormat("$if2(%TITLE%,'N/A')").Eval(), setTitlefont, g_textcolor, 0, 0, ww, wh, DT_WORDBREAK | DT_CALCRECT | DT_CENTER | DT_END_ELLIPSIS);
        titleCount = gr.MeasureString(fb.TitleFormat("$if2(%TITLE%,'N/A')").Eval(), setTitlefont, 0, 0, ww, wh);
        fb.trace(titleCount.Height);
        gr.GdiDrawText(fb.TitleFormat("by: $if(%ARTIST%,%ARTIST%[' feat.'%ARTISTFEATURED%],'N/A')").Eval(), artist_font, g_textcolor_hl, 0, titleCount.Height+3, ww, wh, DT_WORDBREAK | DT_CALCRECT | DT_CENTER | DT_END_ELLIPSIS);
        artistCount = gr.MeasureString(fb.TitleFormat("$if(%ARTIST%,%ARTIST%[' feat.'%ARTISTFEATURED%],'N/A')").Eval(), artist_font, 0, 0, ww, wh);
        gr.GdiDrawText(fb.TitleFormat("On Album: $if(%ALBUM%,%ALBUM%$if(%RELEASE_DATE%,' ('%RELEASE_DATE%')',' ('%DATE%')'),'N/A')").Eval(), album_font, g_selectcolor, 0, (artistCount.Height + titleCount.Height + 5), ww, wh, DT_WORDBREAK | DT_CALCRECT | DT_CENTER | DT_END_ELLIPSIS);
               }
           }
}

function on_font_changed() {
    get_font();
    window.Repaint();
}

function on_colors_changed() {
    get_colors();
    window.Repaint();
   
}

function on_playback_stop(reason) {
    if(reason != 2) window.Repaint();
}

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

function on_playback_time() {
   window.RepaintRect(0, wh-60, 400, 25);
}
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-05-12 04:45:52
That's a WSH panel script from his DeviantArt page (http://br3tt.deviantart.com/art/JSPlaylist-509803158), right?  I did give that try and had considered using it as an alternative.  But since I last posted, I've confirmed that both jsplaylist and his smooth playlist prevent FB2K from completely shutting down in Windows 10.  I had to delete panels 1 by 1 until I finally found the culprit.  Wonder if your mod would be any different.  Have you made it available for download anywhere?

I can't imagine why you'd have that issue with the original jsplaylist. The modifications I've made are very minor so are unlikely to change anything in that regard. It can be found via the link in my signature.

It works good for me. Is there a simple script line I could add to automatically attach the picture to all the files in the folder after downloading it?

No.

I edited the script so that it downloads it as "front.jpg" by default, but in order to see it in the panel I have to embed the picture first.

That would only happen if the file already has art embedded in it?? What gets displayed first depends on this setting:

File>Preferences>Advanced>Display>Album art>Embedded vs external.

or is there a way to just re-draw the section where time elapse and time remaining counts up and down?

I've not tried the script but it looks like you're already doing that with window.RepaintRect(x,y,w,h)  ??
Title: Re: JScript Panel script discussion/help
Post by: TakuSkan on 2016-05-12 10:37:29
I can't imagine why you'd have that issue with the original jsplaylist. The modifications I've made are very minor so are unlikely to change anything in that regard. It can be found via the link in my signature.

I did some relatively extensive testing today marc.  I found that if there is a panel with one of your jscripts in a very basic FB2K build that includes panels with either Br3tt's SP or your jsplaylist-mod (https://github.com/19379/jsplaylist-mod), FB2K will not fully shut down in Windows 10.  I detailed the tests I did on SP in a reply to Br3tt on DA (http://br3tt.deviantart.com/art/JS-Smooth-Playlist-571375892).

Had the same problem with Br3tt's older wsh panel mod JSPlaylist (http://br3tt.deviantart.com/art/JSPlaylist-509803158).
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-05-12 12:04:40
Try a brand new portable install with no components except JScript panel. Add jsplaylist-mod as the only panel in the layout so it looks like the screenshot on my github page. Now play some music and see if foobar closes.
Title: Re: JScript Panel script discussion/help
Post by: TakuSkan on 2016-05-12 14:18:18
I'll try that later today marc.  I'm pretty sure foobar will shut down fine.  As I pointed out to Br3tt, it's only been when I have one of his scripts in a panel in foobar along with just 1 of 3 of your jscripts that Win10 that doesn't fully shut down: 'thumbs', 'now playing' & 'Last.fm Album Art Downloader'.  Just 2 panels and nothing else.  I don't think any of your other scripts cause the problem, but I'll test them

Edit: DA seems to be down at the moment.

Edit 2: jsplaylist-mod set up quickly.  I didn't find the Github screenshot, but I used 'View > Layout > Enable layout mode editing' to clear what was there, add a jscript panel and pasted in jsplaylist-mod. 
Added tracks played fine, and foobar shut down in Win10 fine.
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2016-05-12 14:36:45
I edited the script so that it downloads it as "front.jpg" by default, but in order to see it in the panel I have to embed the picture first.

That would only happen if the file already has art embedded in it?? What gets displayed first depends on this setting:

File>Preferences>Advanced>Display>Album art>Embedded vs external.

Of course, my foobar is set to display the embedded art first and that's exactly how I want it to be, it's not an issue. What I was asking for is if it is possible to preview the lastfm picture before I embed it or even download it, like the foo_uie_biography (https://hydrogenaud.io/index.php/topic,70955.0.html) component does. I would actually like the features of both the biography view component and your script. If I can remember correctly one of your WSH album art reader would show an online picture instead of the blank background.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-05-12 14:44:57
If you want to preview images before downloading, I suggest using dedicated app like album art downloader. It has many more options and sources that are much better than the crap on last.fm.

https://hydrogenaud.io/index.php/topic,57392.0.html

Or you could just use my standard artwork panel right click option that launches google images in a browser with the artist/album as search terms.
Title: Re: JScript Panel script discussion/help
Post by: TakuSkan on 2016-05-12 15:34:45
Or you could just use my standard artwork panel right click option that launches google images in a browser with the artist/album as search terms.

That's what I've been doing with a run service script.  Clicking your panel is a lot more convenient method to launch a browser search though. Kudos marc... it's brillant  :) 
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2016-05-12 15:41:59
If you want to preview images before downloading, I suggest using dedicated app like album art downloader. It has many more options and sources that are much better than the crap on last.fm.

https://hydrogenaud.io/index.php/topic,57392.0.html

I know that software, but I never found it really useful. I prefer a foobar component because it allows me to check the album art on the go, while I'm listening and eventually preview the new picture in the exact size and context it will actually look in the player once it is downloaded and embedded.
Anyway, I just found out the biography view component has an automatically download option which I never noticed until today!



Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-05-12 16:04:39
Clicking your panel is a lot more convenient method to launch a browser search though. Kudos marc... it's brillant  :)

I think google images is pretty much the best way to source art. It will usually have high quality art from amazon or the artist's own site/record label near the top of the search results and of course you can filter the image size. I then right click a playlist entry>open containing folder and drag the file straight from the browser in to explorer. Then with the file highlighted, press F2 to rename it. OK, it's a few manual steps but it's worth it.
Title: Re: JScript Panel script discussion/help
Post by: TakuSkan on 2016-05-13 01:55:56
I think google images is pretty much the best way to source art. It will usually have high quality art from amazon or the artist's own site/record label near the top of the search results and of course you can filter the image size. I then right click a playlist entry>open containing folder and drag the file straight from the browser in to explorer. Then with the file highlighted, press F2 to rename it. OK, it's a few manual steps but it's worth it.
Wow... drag and drop.  Nice.  I've been going a similar route, but I start with opening the track folder, copying the path, right-clicking the art panel and selecting google search.  When I find the cover art I select 'View Image', right-click and select 'Save Image As', paste the path to the track's folder, save it, rename it.  I like your method better marc.  :)
Title: Re: JScript Panel script discussion/help
Post by: TakuSkan on 2016-05-13 03:58:30
Try a brand new portable install with no components except JScript panel. Add jsplaylist-mod as the only panel in the layout so it looks like the screenshot on my github page. Now play some music and see if foobar closes.

Well I learned how to set up foobar via "Enable Layout Editing Mode' in the default UI today instead of using columns UI as I have for years.  I downloaded jsplaylist-mod from GitHub (https://github.com/19379/jsplaylist-mod), extracted the zip, renamed 'js-marc2003-master' to just 'js-marc2003 and copied it to the foobar root directory.  In the default foobar installation I went to preferences > components and added foo_jscript_panel-v1.1.4.fb2k-component.  Enabled layout editing and deleted the 2 existing sections of the layout, inserted just one JScript Panel. and copied the script from "jsplaylist main script.txt" to it  Added tracks and played them.  Stopped playback and shut down foobar.  Foobar shut down in Win10 completely.

(http://oi63.tinypic.com/ib9ts5.jpg)

So I took it to the next step, and starting from scratch added marc's Now Playing JScript panel to what I'd just made.  That 1st involved downloading the latest js-marc2003 scripts from GitHub (https://github.com/19379/js-marc2003/releases), and then extracting the contents of the zip to the \js_marc2003 folder in foobar.  This time I configured a left / right (horizontal in Columns UI) splitter, added 2 JScript panel panels, and put the "now playing (basic).txt" script in one and "jsplaylist main script.txt" in the other.  That got me this:

(http://oi63.tinypic.com/34fcx77.jpg)

Unfortunately after playing a few tracks, stopping, and then shutting down foobar, it remained in Windows 10's Task Manger and I had to end task in order to completely shut down foobar and restart it.

If that wasn't disconcerting enough, when I started it up again and began playback, on the 3rd or 4th track, I was presented with a whole new issue:

(http://oi63.tinypic.com/jgkumw.jpg)
Title: Re: JScript Panel script discussion/help
Post by: TakuSkan on 2016-05-13 05:43:55
http://xxxx.tinypic.com/xxxxxx.jpg

Ads...   >:(  They weren't displayed when I was previewing the post or when I was reviewing the message after submitting it.  Am open to suggestions for an alternative ad-free image hosting site.  imgur?
Title: Re: JScript Panel script discussion/help
Post by: TakuSkan on 2016-05-13 05:59:11
If that wasn't disconcerting enough, when I started it up again and began playback, on the 3rd or 4th track, I was presented with a whole new issue:

Here's the script's error message:
Code: [Select]
JScript Panel (np_basic by marc2003): Microsoft JScript runtime error:
Permission denied
File: C:\Foobar2000\js_marc2003\js\thumbs.js
Line: 526, Col: 6
<source text only available at compile time>

var url = item.src.replace("avatar170s", "ar0");
Code: [Select]
		this.success = function (base) {
_(_.getElementsByTagName(this.xmlhttp.responsetext, "img"))
.filter({"className" : "image-list-image"})
.take(this.download_limit)
.forEach(function (item) {
var url = item.src.replace("avatar170s", "ar0");
var filename = base + url.substring(url.lastIndexOf("/") + 1) + ".jpg";
_.runCmd("cscript //nologo " + _.q(folders.home + "download.vbs") + " " + _.q(url) + " " + _.q(filename), false);
})
.value();
}
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-05-13 08:21:29
Can you run process explorer and see if anything is showing as "child" of foobar2000.exe? Also, right click foobar2000.exe>Properties>Threads tab and see if anything is using any CPU?

https://technet.microsoft.com/en-us/sysinternals/processexplorer.aspx

As for the script error, not had that before and I even tested using the same artist as you just now and it was fine. I guess you could try this...

Code: [Select]
		this.success = function (base) {
_(_.getElementsByTagName(this.xmlhttp.responsetext, "img"))
.filter({"className" : "image-list-image"})
.take(this.download_limit)
.forEach(function (item) {
var src = item.src;
var url = src.replace("avatar170s", "ar0");
var filename = base + url.substring(url.lastIndexOf("/") + 1) + ".jpg";
_.runCmd("cscript //nologo " + _.q(folders.home + "download.vbs") + " " + _.q(url) + " " + _.q(filename), false);
})
.value();
}
Title: Re: JScript Panel script discussion/help
Post by: TakuSkan on 2016-05-13 09:53:11
Can you run process explorer and see if anything is showing as "child" of foobar2000.exe? Also, right click foobar2000.exe>Properties>Threads tab and see if anything is using any CPU?

I see nothing as a child:
(http://i.imgur.com/OQwGbTF.jpg)

There are a few threads using minimal CPU:
(http://i.imgur.com/GSqhKaD.jpgg)

Will try your code later on.  Meanwhile Br3tt replied to my test results on DA (http://br3tt.deviantart.com/art/JS-Smooth-Playlist-571375892) and found my link between SP and your scripts to be interesting & something he'll look into.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-05-13 10:15:21
Were those screenshots taken at a time you were unable to close foobar? I forgot to mention it but I thought it would be obvious....

edit: Just looked at DA and I don't understand this...

"During my tests today I did see a connection between SP and marc2003's jscripts.  His Album Art Downloader panel will notice the thumbnail SP creates for mp3s lacking album tags"

IIRC, smooth playlist creates a cache of artwork inside the js_br3tt folder and my script uses the main foobar2000 preferences. Did you really configure your setup to look inside that folder?

edit2: jsplaylist-mod (and the original jsplaylist for WSH panel mod) don't use any external cached images and use the same main preferences as my scripts.
Title: Re: JScript Panel script discussion/help
Post by: TakuSkan on 2016-05-13 10:39:45
As for the script error, not had that before and I even tested using the same artist as you just now and it was fine. I guess you could try this...
More power with E Power  ;)  ...Sounds like a slogan for an alternative energy company.

No luck with the script modification.  It may download thumbs for 1 or 2, or up to 8 or 10 successive tracks before it crashes.  I've been having this problem with test builds on both Win7 PC and Win10 Notebook for the past month.  To get a lot downloaded I left foobar with both NP and thumbs panels play overnight as background music while I was sleeping.  The crash doesn't prevent the script from downloading the graphics.  Wonder if it could be something in my MP3Tag tagged lame / dbpoweramp encoded files.
Title: Re: JScript Panel script discussion/help
Post by: TakuSkan on 2016-05-13 10:55:54
Were those screenshots taken at a time you were unable to close foobar? I forgot to mention it but I thought it would be obvious....

Thats what PE was displaying while foobar was running.  I'm not all that quick.  You might have intended for me to do the check after I'd closed foobar. That;d make more sense.  I'll do it again.

Quote
IIRC, smooth playlist creates a cache of artwork inside the js_br3tt folder and my script uses the main foobar2000 preferences. Did you really configure your setup to look inside that folder?

No.  Not at all.  I think I set up everything the way both of you specify.  His scripts in \js_br3tt and yours in \js_marc2003.

Quote
edit2: jsplaylist-mod (and the original jsplaylist for WSH panel mod) don't use any external cached images and use the same main preferences as my scripts.

As you pointed out, his scripts create thumnails in his \js_br3tt\cache\imgcache folder all randomly named with no extension... right?  I have no idea how Last.fm Album Art Downloader picked up on that and displayed them in its panel.  I tested it a couple times.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-05-13 10:59:50
If you tried to close foobar and it wouldn't, it would still be running.... right?

I have no idea how Last.fm Album Art Downloader picked up on that and displayed them in its panel.  I tested it a couple times.

It's fortunate that my album art panel has tooltips showing the path of being displayed so you can provide proof of this.

Title: Re: JScript Panel script discussion/help
Post by: TakuSkan on 2016-05-13 11:06:47
After shutting down foobar, Process Explorer shows no child or and it's the only thing in the threads tab this time showing no CPU usage at all

(http://i.imgur.com/MHI38aP.jpg)

(http://i.imgur.com/f2c7HYL.jpg)
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-05-13 11:13:30
After shutting down foobar

I'm done. I'm not wasting any more of my time on this.

If you tried to close foobar and it wouldn't, it would still be running.... right?
Title: Re: JScript Panel script discussion/help
Post by: TakuSkan on 2016-05-13 11:31:51
I just went back to my test build and can now explain what's happening.  As I told Brett, his script looks for the 1st art file named %album%.jpg alphabetically a-z among several in a 'Various Tracks" folder where I have a lot of >very< old mp3s that lack any album tag.  It then creates thumbs based on that 1 jpg for every single mp3 lacking that tag. 

I just tested it again by removing all but 1 cover art jpg in that folder.  I delete all cached files in Br3tt's and WSH folders: \js_br3tt\cache\imgcache and \wsh_settings and \wsh_data, and start this test foobar.  SP instantly creates thumbs for every track missing the album tag from that one jpg.  And Album Art Downloader is associating that one art jpg with every track that lacks the tag.  So the 2 scripts aren't interacting.  They're both just both producing similar results.

Sorry if this has been confusing marc.  It's late here and I'm not as focused as I should be.
Title: Re: JScript Panel script discussion/help
Post by: TakuSkan on 2016-05-13 11:36:08
If you tried to close foobar and it wouldn't, it would still be running.... right?

It closes its GUI, but its exe remains active.  I can't start foobar again unless I end task on it.  If I start foobar again without ending task on the 1st copy, a 2nd foobar2000 will appear in task manager and I have to end task on both in order to start foobar again.
Title: Re: JScript Panel script discussion/help
Post by: TakuSkan on 2016-05-14 11:24:38
Today I finally remembered one of the primary rules of troubleshooting computer related problems, probably 2nd only to simply rebooting: Disable any antivirus program.  It wasn't effecting Windows 7, but in Windows 10 for some reason was causing marc's Now Playing script to crash.   That as well as keeping every copy of foobar that had both marc's and Br3tt's scripts set in JScript panels to remain in task manger after closing foobar, preventing it from restarting.  My most sincere apologies to you marc for what I ended up putting you through the other day. 

That solved 2 of the 3 issues I was having.  But both marc's Album Art Downloader & Br3tt's Smooth Playlist scripts are still displaying the same cover art jpg for every mp3 in my 'Various Tracks' folder / playlist that doesn't have an album tag set.  Here's what's I'm seeing in a copy of foobar with those panels. The 1st track has an album track, the next 4 don't:

(http://i.imgur.com/QYQviGo.gif)
Title: Re: JScript Panel script discussion/help
Post by: coffeemugger651 on 2016-05-14 20:13:26
Stupid here.

Is there any way of getting specific album image data (such as the color of a pixel, for instance?). I know this is possible with canvas, but I don't know about the internals of this plugin

I'm trying to make a method that will get the average color of an image.  I want the walls to match the furniture, so to speak.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-05-15 01:48:25
You can use GetColorScheme like this...

Code: [Select]
var img = utils.GetAlbumArtV2(fb.GetFocusItem(), 0);
if (img) {
    var arr = img.GetColorScheme(1).toArray();
    var col = arr[0];
}

You can increase the number 1 to get more colours. The first is the most dominant and so on...
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2016-05-18 22:42:58
Is there a way to make a value calculated in the script available to the whole program as a global variable or can it only be displayed in the panel where the script is written?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-05-19 03:45:36
Nope, no global variables.
Title: Re: JScript Panel script discussion/help
Post by: Just_Addict on 2016-05-21 21:41:16
I've got a problem where I think JScript Panel might just be the thing that could solve it.

Current situation
I'm using m-TAGs in Foobar2000 to tag my files.
I'm also using KeyFinder to determine key values. But that is oblivious to the existence of m-TAG.
Which means I have media files that have been read by m-TAG to collect tag info and have gotten their tag info updated by an external soft.
Now, m-TAG only reads the media file tags upon creation of a tags file, after that it don't touch the media file no more for that.
now, if those m-TAG files hadn't already acquired additional information it would be just a case of wiping the .tags files and let m-TAG recreate them to pickup said changed/new information. Sadly that is not an option, order of processing is not fixed, plus I didn't start using KeyFinder from the beginning so a lot of files are already m-TAGged to which substantial  tag info has been added since.

Still with me?
Scripting would be the only way I see to prevent me from having to manually extract the Key value from the media file and update the m-TAG reference.
Since both the m-TAG playlist entry and the actual media file playlist entry are an exact duplicate of each other, only differing on the changed/new added Key value, in my mind it should be a piece of cake if a scripting option existed that I could instruct like

"Ok, I've got these two identical entries except for tag now go out and find each m-TAG entry, match the duplicate entry that has the new tag and copy the content to the m-TAG entry"

I thought maybe masstagger had the solution but if it has I don't see how, it's basically the same as mp3tag's actions system which also has no way of doing this. Even if it did, it don't know about m-TAG either so that route is closed anyway.

Since JScript panel uses scripting like there is no tomorrow, I was hoping it could modify tag values too I've no clue about that, I'm not familiar enough with the component to know if it can change tags directly through scripting.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-05-22 00:23:41
I'm not familiar with m-tags but from what I gather, you use the properties dialog to edit "tags" in the same way you do with normal files. If that it the case, simply add all the m-tags to one playlist and add all the real audio files to another. Then you can use this technique for copying tags from one set of files to another.

http://wiki.hydrogenaud.io/index.php?title=Foobar2000:How_to_transfer_tags_between_two_sets_of_tracks
Title: Re: JScript Panel script discussion/help
Post by: Just_Addict on 2016-05-22 13:53:10
I'm not familiar with m-tags but from what I gather, you use the properties dialog to edit "tags" in the same way you do with normal files. If that it the case, simply add all the m-tags to one playlist and add all the real audio files to another. Then you can use this technique for copying tags from one set of files to another.

http://wiki.hydrogenaud.io/index.php?title=Foobar2000:How_to_transfer_tags_between_two_sets_of_tracks
Damn, so simple....
[walks off silently with bowed head]

Thanks :)

EDIT: WOOT! Works like a charm, would'ave thunk?! LOL
Title: Re: JScript Panel script discussion/help
Post by: samithaj on 2016-05-24 17:26:19
Is anyone using jScript panel and marc's scripts on mac ox (via crossover or vine) ??
Some simple scripts works but not marc's scripts or WilB's scripts  :(
No console massages are shown for WilB's scripts 
and for marc's scripts,
Code: [Select]
JScript Panel (Allmusic review by marc2003): Parsing file "C:\users\crossover\Application Data\foobar2000\js_marc2003\js\lodash.min.js"
[size=2]JScript Panel (Allmusic review by marc2003): Parsing file "C:\users\crossover\Application Data\foobar2000\js_marc2003\js\helpers.js"[/size]
[size=2]JScript Panel (Allmusic review by marc2003): Parsing file "C:\users\crossover\Application Data\foobar2000\js_marc2003\js\panel.js"[/size]
JScript Panel (Allmusic review by marc2003): Parsing file "C:\users\crossover\Application Data\foobar2000\js_marc2003\js\text.js"

Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-05-24 18:18:57
You need IE8 installed in wine for the internet stuff to work. Also, search the WSH script thread for all references to winetricks because there are some other packages needed as well.
Title: Re: JScript Panel script discussion/help
Post by: MachineHead on 2016-05-30 01:31:58
Is there a way to meta-test certain fields in the Properties script from the samples? In particular, play count, first played, and rating. Image below shows the fields in question. I'd like them to not show until they become populated if possible.

(http://i.imgur.com/PcfBHsD.png)
Title: Re: JScript Panel script discussion/help
Post by: jazzthieve on 2016-05-30 18:50:01
Marc, is it possible to have the Thumbs script point to a specific file in a folder and only that file instead of pointing it to a folder with multiple image files. I know there are other components I can use that do this but none of those have the crop functionality your thumbs script has, which is really handy for non square images,
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-06-01 19:44:54
Use the album art script - assuming you're not already using all of the available types?? Just configure the main preferences with the filename.
Title: Re: JScript Panel script discussion/help
Post by: tarkus721 on 2016-06-07 03:25:38
Is anyone using jScript panel and marc's scripts on mac ox (via crossover or vine) ??
Some simple scripts works but not marc's scripts or WilB's scripts  :(
No console massages are shown for WilB's scripts
and for marc's scripts,

Yes, I'm using marc's JScript panel in foobar2000 under wine 1.6.2 in Linux (Ubuntu, Mint) and most everything I've tried works except downloading artist images in his thumbs script. You'll need to install these dll's using winetricks in this order (very important).

Code: [Select]
gdiplus_winxp
wsh57
fontsmooth=rgb
msscript
ie8
msls31
w_workaround_wine_bug-25648
msxml3
wmp10
vb6run
vcrun2010

I did try WilB's Library Tree script and it worked, but I didn't care much for it. So I went back to a WSH panel mod script I modified earlier for myself. marc's older WSH panel mod scripts also work well. Except for (wait for it...) thumbs artist art and love button. Thanks last.fm. A few of Falstaff's (br3tt) older WSH panel mod scripts work also.

Hope this helps. :)
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2016-06-10 11:22:42
Hey everyone!
Is it possible to check panel visibility state from WSH\Jscript? E.g. I have a few heavy panels that are not ever visible simultaneously, so if it's possible to analyze the state of the panel, then I can avoid all the useless art reloading\repainting and etc.

PS: @marc2003 , what's your position on pull requests to https://github.com/19379/js-marc2003/tree/master/js?
Title: Re: JScript Panel script discussion/help
Post by: jazzthieve on 2016-06-11 10:08:05
A question about the allmusic review script. Why is it saving the json of the album review in the data folder even if no album review is found on allmusic? Is this intended behavior?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-06-11 18:32:41
@TheQwertiest

First of all, you should find nothing happens in on_paint if the panel is hidden in tab. Also, there is window.IsVisible. Take this example bit of code

Code: [Select]
window.SetInterval(function () {
    fb.trace("Timer: " + new Date());
    window.Repaint();
}, 1000);

function on_paint(gr) {
    fb.trace("paint: " + window.IsVisible);  
}

When in a visible tab, the output is...

Code: [Select]
Timer: Sat Jun 11 18:27:51 UTC+0100 2016 
paint: true
Timer: Sat Jun 11 18:27:52 UTC+0100 2016
paint: true
Timer: Sat Jun 11 18:27:53 UTC+0100 2016
paint: true
Timer: Sat Jun 11 18:27:54 UTC+0100 2016
paint: true

Now select another tab so the panel is hidden and you only get...

Code: [Select]
Timer: Sat Jun 11 18:28:06 UTC+0100 2016 
Timer: Sat Jun 11 18:28:07 UTC+0100 2016
Timer: Sat Jun 11 18:28:08 UTC+0100 2016
Timer: Sat Jun 11 18:28:09 UTC+0100 2016
Timer: Sat Jun 11 18:28:10 UTC+0100 2016
Timer: Sat Jun 11 18:28:11 UTC+0100 2016
Timer: Sat Jun 11 18:28:12 UTC+0100 2016
Timer: Sat Jun 11 18:28:13 UTC+0100 2016
Timer: Sat Jun 11 18:28:14 UTC+0100 2016
Timer: Sat Jun 11 18:28:15 UTC+0100 2016
Timer: Sat Jun 11 18:28:16 UTC+0100 2016
Timer: Sat Jun 11 18:28:17 UTC+0100 2016
Timer: Sat Jun 11 18:28:18 UTC+0100 2016

You can also experiment by putting fb.trace(window.IsVisible); inside the timer to see it change to false when hidden.

As for my repo, it's just my personal files that happen to be online so I'm unlikely to accept requests unless it's a bug fix for something I'm not aware of.

@jazzthieve, yes it's intentional. Having an empty file present prevents the script from looking up again too soon. It checks the age of the file is over 24 hours before making another request to their servers.
Title: Re: JScript Panel script discussion/help
Post by: foosion on 2016-06-12 00:16:22
It is possible to go even further regarding timers in inactive panels. You can stop the timer when the panel is not visible. The easiest way is to use one-shot timers and restart them in on_paint. For example:
Code: [Select]
function timerCallback() {
    fb.trace("Timer: " + new Date());
    window.Repaint();
}

function on_paint(gr) {
    fb.trace("on_paint: " + new Date() + " " + window.IsVisible);
    window.SetTimeout(timerCallback, 1000);
}

window.SetTimeout(timerCallback, 1000);
If you need the timer to trigger at specific times, for example on a full second, you need to calculate the timeout in the on_paint function accordingly.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-06-14 00:25:59
I've made some minor updates to a couple of my scripts:

https://github.com/19379/js-marc2003/releases
Title: Re: JScript Panel script discussion/help
Post by: Black_Over_Bills_Mothers on 2016-06-17 12:47:03
@ marc2003
I think I've found a small bug in your np_basic script. Line 38 (thumbs.mode = 5;) seems to override the saved property value for the thumbs mode. The symptom is that the thumbs setting is always reset to off whenever the script is started or foobar is started.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-06-17 13:11:02
It's intentional. The "bug" is the thumbs menu being there when it really shouldn't be. Surely you must realise it looks like crap when you enable one of the options because the text is in the way. Thumbs should be left off.

edit: This updated version of thumbs.js properly hides the menu. Save it inside js_marc2003\js

https://raw.githubusercontent.com/19379/js-marc2003/master/js/thumbs.js

Title: Re: JScript Panel script discussion/help
Post by: Black_Over_Bills_Mothers on 2016-06-21 11:53:57
@marc2003
I've got a problem in some code that I've adapted from yours. I'm trying to enumerate through files in a folder and using the following code;
Code: [Select]
if (_.isFolder(folder)) {
var files = [];
var fl = fso.GetFolder(folder);
fb.trace("File Count", fl.files.count);
var en = new Enumerator(fl.files);
var i = 0;
for (; !en.atEnd(); en.moveNext())
i = i + 1;
fb.trace("i total", i);
}

What I see in the console output is;
File Count 48
i total 19

I think that both lines should give me the same output ie 48. What am I doing wrong?

Edit: After restarting foobar both values are the same. Curious!
Title: Re: JScript Panel script discussion/help
Post by: ehrgeiz on 2016-07-05 13:24:05
Hello,
i would need help regarding Br3tt's / Falstaffs "JS Smooth Browser" [1]
it is similar to facets and has the ability to group library/playlist into an artists/albums with corresponding artist/cover pictures.
album grouping works fine, but when using artists it looks for an "artist.jpg" in the folder the audiofiles are located and uses that
for display. however i would like to use the artist pics that marcs script once scraped into this folder (%appdata%\foobar200\wsh_data\artists\%artist%\%artist%*.*)

i thought that the "tf_path_artist" property would set the path where to look for the artistart but it seems that does nothing.
even if i hardcode it to one specific file it won't display.
is anyone using his script and found out how to make that work?

i guess i have to modify the portion of the code where it loads the images (line ~270):
Code: [Select]
image_cache = function () {
    this._cachelist = {};
    this.hit = function (metadb, albumIndex) {
        var img = this._cachelist[brw.groups[albumIndex].cachekey];
        if (typeof(img) == "undefined" || img == null) { // if image not in cache, we load it asynchronously
            //if(!isScrolling  && !cScrollBar.timerID) { // and when no scrolling
                if(ppt.enableDiskCache) {
                    brw.groups[albumIndex].crc = check_cache(metadb, albumIndex);
                    if(brw.groups[albumIndex].crc && brw.groups[albumIndex].load_requested == 0) {
                        // load img from cache
                        if(!timers.coverLoad) {
                            if(!isScrolling  && !cScrollBar.timerID) {
                                timers.coverLoad = window.SetTimeout(function() {
                                    try {
                                        brw.groups[albumIndex].tid = load_image_from_cache(metadb, brw.groups[albumIndex].crc);
                                        brw.groups[albumIndex].load_requested = 1;
                                    }; catch(e) {};
                                    timers.coverLoad && window.ClearTimeout(timers.coverLoad);
                                    timers.coverLoad = false;
                                }, 5);
                            }; else {
                                timers.coverLoad = window.SetTimeout(function() {
                                    try {
                                        brw.groups[albumIndex].tid = load_image_from_cache(metadb, brw.groups[albumIndex].crc);
                                        brw.groups[albumIndex].load_requested = 1;
                                    }; catch(e) {};
                                    timers.coverLoad && window.ClearTimeout(timers.coverLoad);
                                    timers.coverLoad = false;
                                }, 20);
                            };
                        };
                    };
                };
                if(!ppt.enableDiskCache || !(ppt.enableDiskCache && brw.groups[albumIndex].crc && brw.groups[albumIndex].load_requested == 0)) {
                    if(brw.groups[albumIndex].load_requested == 0) {              
                        // load img default method
                        if(!timers.coverLoad) {
                            timers.coverLoad = window.SetTimeout(function() {
                                if(ppt.albumArtId==5) { // genre
                                    var arr = brw.groups[albumIndex].groupkey.split(" ^^ ");
                                    try {
                                        var genre_img = gdi.Image(images.path + "genres\\" + arr[0] + ".jpg");
                                    } catch(e) {
                                        var genre_img = gdi.Image(images.path + "genres\\" + "default.jpg");
                                    };
                                    brw.groups[albumIndex].cover_img = g_image_cache.getit(metadb, albumIndex, genre_img);
                                    brw.repaint();
                                }; else {
                                    this.albumArtId = ppt.albumArtId == 0 ? albumIndex + 5 : ppt.albumArtId;
                                    utils.GetAlbumArtAsync(window.ID, metadb, this.albumArtId, true, false, false);
                                };
                                timers.coverLoad && window.ClearTimeout(timers.coverLoad);
                                timers.coverLoad = false;
                            }, (!isScrolling  && !cScrollBar.timerID ? 5 : 20));
                        };
                    };
                };
            //};
        };
        return img;
    };

and insert another exception like "if(ppt.albumArtId==5) { // genre" for genre.
i tried this:
first i added a new property called
Code: [Select]
tf_path_artist_source: fb.TitleFormat(window.GetProperty("_PROPERTY: Artist Images Folder (source)", fb.ProfilePath+"\\wsh_data\\artists\\$meta(album artist,0)\\")), 
and added in the function "image_cache"
Code: [Select]
if(ppt.albumArtId==4) { // test for album art
                                    try {
                                        var artist_img = gdi.Image(ppt.tf_path_artist_source.EvalWithMetadb(metadb) + "test.jpg");
                                    } catch(e) {
                                        var artist_img = gdi.Image(ppt.tf_path_artist_source.EvalWithMetadb(metadb) + "test.jpg");
                                    };
                                    brw.groups[albumIndex].cover_img = g_image_cache.getit(metadb, albumIndex, artist_img);
                                    brw.repaint();
                                };

so far so good, the test.jpg in the corresponding artist folder is being displayed, yay! however i have no idea how to do wildcard calls, because the files are called something like "artist_1235123.jpg" or "artist_123412.png".

I don't think that's trivial but there are already masks defined in the properties to look for *cover*.* front.* *.jpg and last *.* so i guess that's already implemented in some way, i just have no idea how to do this.

you probably laugh at me now, but i'm proud that i made it this far :D
any help is appreciated :) for now i have set the AlbumArtID for artist grouping to display the front cover, that's ok for me too, but it would be nice to have real artist pics displayed.

[1] http://br3tt.deviantart.com/art/JS-Smooth-Browser-571376160

Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-07-05 16:26:46
I think you need to delete all the cached images that were generated after the script first ran. IIRC, the folder is inside js_br3tt,
Title: Re: JScript Panel script discussion/help
Post by: Daeron on 2016-07-17 17:27:42
marc2003, how do you feel about the possibility of adding a secondary/fallback titleformatting pattern in your scripts that pull album/artist art (presumably from last.fm), for cases when the primary pattern have failed to retrieve anything?

Would be useful in scenarios where artists have changed names multiple times, are simply known under two different names (like Japanese writing vs Latin letters) or really just whenever ALBUM ARTIST and ARTIST are different and one might retrieve useful information while the other would not. The last.fm database is not exactly consistent enough to commit to one style of formatting and it wouldn't be desired to do so either.

Also noticed you 'added library tracks only' support for the last.fm cover art downloader script (was a while ago, but only checked it now), thanks for that.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-07-18 10:22:16
Previously someone asked for multiple artist support for collaborations etc and I said no because it would be a real PITA. Buf if it's for different variants of the same artist which can share the same folder, it could be doable.
Title: Re: JScript Panel script discussion/help
Post by: Daeron on 2016-07-18 19:31:53
Well, what I'm asking should be a lot more simple than that.

Run query with %artist%. If a match has been found, save cover art to $directory_path(%path%)\lastfm.jpg and stop.
Otherwise run another query with %album artist%. If a match has been found, save cover art to $directory_path(%path%)\lastfm.jpg and stop.

(If the identical filenames are a problem, the result of the second query can just always be saved as lastfm2.jpg instead.)
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-07-18 23:28:01
I didn't realise you were talking about the album art script. Modifying that should be easier.
Title: Re: JScript Panel script discussion/help
Post by: michtar on 2016-07-21 22:05:30
About 'now playing (basic)', is it possible to change fallback font?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-07-22 08:09:41
Samples updated: https://github.com/19379/js-marc2003/releases

michtar, what do you mean by "fallback"??
Title: Re: JScript Panel script discussion/help
Post by: michtar on 2016-07-22 08:36:31
what do you mean by "fallback"??
The font that replaces regular font when it can't can't display certain characters or script can't recognize font at all (name).
Looks like this (it's draw.string but with GdiDrawText it's the same). Looks like Microsoft Sans Serif to me:
(http://i.cubeupload.com/iNSAWI.png)
http://i.cubeupload.com/iNSAWI.png

Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-07-22 12:22:38
Well I don't know anything about that. Use something else to display the track title. It's not like there is a shortage of alternatives.
Title: Re: JScript Panel script discussion/help
Post by: michtar on 2016-07-22 15:07:59
Of course, it was only a question. Thanks for scripts anyway.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-07-22 15:27:41
I guessed it was the soundtrack for the Amelie movie so found the track title on wikipedia. It looks OK with all these different fonts??

(https://i.imgur.com/O4pWEdc.png)

The code for the above...

Code: [Select]
// ==PREPROCESSOR==
// @import "%fb2k_profile_path%js_marc2003\js\lodash.min.js"
// @import "%fb2k_profile_path%js_marc2003\js\helpers.js"
// ==/PREPROCESSOR==

var tag = "La valse d'Amélie";

var text_colour = _.RGB(192, 192, 192);
var font_names = ["Segoe UI", "Tahoma", "Microsoft Sans Serif", "Verdana", "Calibri", "Impact"];
var fonts = _.map(font_names, function (item) {
return _.gdiFont(item, 32);
});

function on_paint(gr) {
gr.FillSolidRect(0, 0, window.Width, window.Height, _.RGB(30, 30, 30));
_.forEach(fonts, function (item, i) {
gr.GdiDrawText(item.Name, item, text_colour, 5, 5 + (i * 45), window.Width - 10, 40, LEFT);
gr.GdiDrawText(tag, item, text_colour, 5, 5 + (i * 45), window.Width - 10, 40, RIGHT);
});
}
Title: Re: JScript Panel script discussion/help
Post by: michtar on 2016-07-22 15:40:39
- Yes, it is clearly this particular font problem, no doubt about it at any stage. It cannot display certain characters (incl. national).
- I thought that fallback font option is included somewhere in scripts and you can change it, for example: if you put Ariol instead of Arial  :) certain default font is displayed
- it's not - not a problem, must be some system setting(? or whatever),
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-07-22 18:21:44
- I thought that fallback font option is included somewhere in scripts and you can change it, for example: if you put Ariol instead of Arial  :) certain default font is displayed

It looks like the gdi.Font function built in to the component handles that...

Code: [Select]
var font = gdi.Font("ariol", 12);
fb.trace(font.Name); // outputs "Microsoft Sans Serif"
Title: Re: JScript Panel script discussion/help
Post by: csmrtr on 2016-08-01 04:12:11
Can anyone link a biography script that fetches the bio from Wikipedia?
Title: Re: JScript Panel script discussion/help
Post by: ruebe on 2016-08-01 14:27:14
Now that foo_uie_biography seems to have stopped working, I'm looking for something that (upon selection/playing) downloads artist art (from last.fm or where ever) and saves it to a predefined folder (if there isn't already one).

I think that the thumbs sample does almost what I want it to, however I have a couple of questions:
1. Is it possible to change the path the images get downloaded to as well as the way the images are named? I looked through the code and I suspect I found the lines I would have to change...but yeah, I can't code, so I stopped before breaking something...
2. In contrast to the biography viewer, thumbs seems rather slow with respect to fetching the images. Is there something I can do about this? By slow I mean 5 seconds instead of ~ 1.
3. Biography viewer somehow only downloaded square images...is this also possible with thumbs? For layout reasons I'd prefer the same ratio for all the pictures...

Thank you very much in advance!
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-08-01 15:44:45
1) No, I'm not providing help on how to change filenames. They must keep the ID from the source on last.fm to prevent them being downloaded again.

The album art preferences in foobar support wildcards so you can specify a path to the folder meaning any component like EsPlaylist/facets/etc can use the images...

Code: [Select]
D:\path\to\wsh_data\artists\%artist%\*.jpg

2) I have no way to detect when images are downloaded so the script runs on a timer checking the folder for changes every 3 seconds.

The script used to detect when an image had completed and refreshed itself but that prevented you from closing foobar while it was running so I had to remove that feature.

3) Use a square panel with one of the crop options enabled.

Basically, if you don't like how it works... don't use it.
Title: Re: JScript Panel script discussion/help
Post by: ruebe on 2016-08-03 13:43:30
Not quite what I was hoping for :)
Thanks anyway, keep up your great work!
Title: Re: JScript Panel script discussion/help
Post by: YOGAM on 2016-08-23 14:07:43
Hi,
I noticed a weird thing with the LastFM biography JScript : quite often, informations about a specific artist disapear (the LastFM biography file for the artist is still on my HDD, but when I open this file using Notepad or a similar software, it’s blank. The biography text isn’t here anymore).
Each time,  I have to delete the empty file stored on my HDD in order to be able to recover the artist biography…  It’s quite disturbing. I noticed, most of the time, it  happens with artists I listen very often (e.g : Pink Floyd)
It looks to me that, from time to time, LastFM biography script tries to update informations already stored on the dedicated local folder and, somehow, fail to do so.
So far, I assumed when LastFM biography script found a file with the artist biography stored in the local folder, it didn’t try to connect  to LastFM site in order to update biography, but maybe I was wrong … Was I ?
If there is some kind of « automatic update » feature included in the script, is there a way to disable it ?
Thanks a lot for the help !
YOGAMAN
P.S. Obviously, english is not my mother tongue, so please, excuse my french ;-).
Title: Re: JScript Panel script discussion/help
Post by: flacker on 2016-08-24 15:31:35
Hello !

I really enjoy your Jscript plugin. Thanks for the hard work.

I'm not a programmer, but through errors I've made many modifications to your basic examples in order to fit my needs.

Unfortunately, one thing I can't do no matter what.

I want to have toggle buttons - when I press a button it should stay pressed and activate an option. When I press it once more, it should deselect itself and deactivate that option.

I've tried modifying your example with Simple themed buttons, but with no success.

PS: Any work around would be OK for me if my requirement can't be done with this plugin.

Screenshot - Foobar - My buttons (https://snag.gy/dtuiJ1.jpg)

Here is the original script:

Code: [Select]
// vi:set ft=javascript ff=dos ts=4 sts=4 sw=4 et:

// ==PREPROCESSOR==
// @name "SimpleThemedButton"
// @author "T.P Wang"
// ==/PREPROCESSOR==

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

ButtonStates = {
    normal: 0,
    hover: 1,
    down: 2,
    hide: 3
}

var DT_TOP = 0x00000000;
var DT_CENTER = 0x00000001;
var DT_VCENTER = 0x00000004;
var DT_WORDBREAK = 0x00000010;
var DT_CALCRECT = 0x00000400;
var DT_NOPREFIX = 0x00000800;

var g_theme = window.CreateThemeManager("Button");
var g_font = gdi.Font("Tahoma", 12);

function SimpleButton(x, y, w, h, text, fonClick, state) {
    this.state = state ? state : ButtonStates.normal;
    this.x = x;
    this.y = y;
    this.w = w;
    this.h = h;
    this.text = text;
    this.fonClick = fonClick;
   
    this.containXY = function (x, y) {
        return (this.x <= x) && (x <= this.x + this.w) && (this.y <= y) && (y <= this.y + this.h);
    }
   
    this.changeState = function (state) {
        var old = this.state;
        this.state = state;
        return old;
    }

    this.draw = function (gr) {
        if (this.state == ButtonStates.hide) return;
       
        switch (this.state)
        {
        case ButtonStates.normal:
            g_theme.SetPartAndStateId(1, 1);
            break;
           
        case ButtonStates.hover:
            g_theme.SetPartAndStateId(1, 2);
            break;
           
        case ButtonStates.down:
            g_theme.SetPartAndStateId(1, 3);
            break;
           
        case ButtonStates.hide:
            return;
        }

        g_theme.DrawThemeBackground(gr, this.x, this.y, this.w, this.h);
        gr.GdiDrawText(this.text, g_font, RGB(0,0,0), this.x, this.y, this.w, this.h, DT_CENTER| DT_VCENTER | DT_CALCRECT | DT_NOPREFIX);
    }

    this.onClick = function () {
        this.fonClick && this.fonClick();
    }
}

function drawAllButtons(gr) {
    for (var i in $buttons) {
        $buttons[i].draw(gr);
    }
}

function chooseButton(x, y) {
    for (var i in $buttons) {
        if ($buttons[i].containXY(x, y) && $buttons[i].state != ButtonStates.hide) return $buttons[i];
    }

    return null;
}

$buttons = {
    Console: new SimpleButton(5, 5, 80, 26, "Console", function () {
        fb.ShowConsole();
    }),
    Configure: new SimpleButton(5, 40, 80, 26, "Configure", function () {
        window.ShowConfigure();
    })
}

var cur_btn = null;
var g_down = false;

// --- APPLICATION START

function on_paint(gr) {
    drawAllButtons(gr);
}

function on_mouse_move(x, y) {
    var old = cur_btn;
    cur_btn = chooseButton(x, y);
   
    if (old == cur_btn) {
        if (g_down) return;
    } else if (g_down && cur_btn && cur_btn.state != ButtonStates.down) {
        cur_btn.changeState(ButtonStates.down);
        window.Repaint();
        return;
    }
       
    old && old.changeState(ButtonStates.normal);
    cur_btn && cur_btn.changeState(ButtonStates.hover);
    window.Repaint();
}

function on_mouse_leave() {
    g_down = false;
   
    if (cur_btn) {
        cur_btn.changeState(ButtonStates.normal);
        window.Repaint();
    }
}

function on_mouse_lbtn_down(x, y) {
    g_down = true;
   
    if (cur_btn) {
        cur_btn.changeState(ButtonStates.down);
        window.Repaint();
    }
}

function on_mouse_lbtn_up(x, y) {
    g_down = false;
   
    if (cur_btn) {
        cur_btn.onClick();
        cur_btn.changeState(ButtonStates.hover);
        window.Repaint();
    }
}

// --- APPLICATION END
Title: Re: JScript Panel script discussion/help
Post by: YOGAM on 2016-09-02 10:59:32
Samples updated: https://github.com/19379/js-marc2003/releases


Hi Marc,
I noticed most of the jscripts you created are no longer stored on GitHub (error 404). Maybe you choose to remove them for some reason (in that case, I hope they'll be back soon because they're so helpfull. Thanks by the way !), but if the removal wasn't done on purpose, then there is a problem with GitHub.
Title: Re: JScript Panel script discussion/help
Post by: sss666 on 2016-09-03 17:38:46
can anyone post a working script that mimics the biography component/panel (artist and album)?

thx
Title: Re: JScript Panel script discussion/help
Post by: necozy on 2016-09-04 08:32:04
Does someone have "foo_uie_wsh_panel.dll"?
It's not foo_uie_wsh_panel_mod.
Could you post please?
Title: Re: JScript Panel script discussion/help
Post by: Falstaff on 2016-09-04 14:25:54
@necozy

what for ? this dll is old and wsh panel mod (and now jscript panel) offer the same in better ...
Title: Re: JScript Panel script discussion/help
Post by: necozy on 2016-09-05 09:16:15
thanx Falstaff

I got foo_uie_wsh_panel.dll already.Thank you for your trouble.
But I am looking for "foo_uie_trackinfo.dll" also not mod one
for some theme and skins this time.
I do not know the reason why "mod" does not work.
Those theme and skins are required original.

thank you

Title: Re: JScript Panel script discussion/help
Post by: necozy on 2016-09-05 13:30:47
Finally I found "foo_uie_trackinfo.dll" .
thank you anyway.

cheers
Title: Re: JScript Panel script discussion/help
Post by: necozy on 2016-09-06 10:26:24
Jesus different version!
I'd like use http://br3tt.deviantart.com/art/KUNG-FOO-foobar-config-96607000
So somebody post all dlls that are necessary please.
Title: Re: JScript Panel script discussion/help
Post by: jazzthieve on 2016-09-06 16:48:11
This thread is for jscript discussions. None of what you ask has anything to do with jscript and you should ask your questions in the relevant thread either existing or new. TOS  #5 (https://hydrogenaud.io/index.php/topic,3974.html#post_tos5)
Perhaps a moderator could intervene?
Title: Re: JScript Panel script discussion/help
Post by: necozy on 2016-09-07 10:24:46
jazzthieve and everyone

Very sorry  if you know suitable thread notice me please.

thank you
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2016-09-11 16:50:29
Is it possible with jscript to hide or show a columns ui panel? In other words to trigger the panelshow command of panel stack splitter?
Title: Re: JScript Panel script discussion/help
Post by: necozy on 2016-09-11 17:37:36
davideleo

thank you for reply.
I don't understand details for java script.
I just want to use "kung-foo_black_1.3a".
So I need foo_uie_trackinfo.dll for correct version for this.
I have visited many sites.
Link is still there but the file is not exist anymore.
Now a days, 8 years ago is really long long time ago.
I will wait and I am not in hurry.

thank you
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-09-21 08:04:13
The following scripts from my old samples are now bundled with the component itself:

Code: [Select]
albumart.txt
autoplaylists.txt
menu button.txt
playback buttons.txt
properties.txt
rating.txt
seekbar.txt
track info + seekbar + buttons.txt
volume.txt

Also included is jsplaylist-mod. When you right click the blank panel of the latest component, there is an "Open component folder" menu item which takes you directly to the folder containing all the docs and samples.

https://github.com/19379/foo-jscript-panel/releases
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2016-10-06 03:59:13
Apologies cause this is gonna be slightly off-topic, but not sure there's a better place for it.

Hey guys, I'm a longtime WSH/JPanel user. I love what it can do and I've built out pretty extensive themes with it. Here's the thing, it's not great for graphical stuff, especially if you want any kind of animation. Using setInterval for this sort of thing sucks. It's not predictable, it's processor intensive. Having to repaint portions of the screen is also dumb, and can be difficult to manage. JPanel has a ton of great drawing features, but frankly using GDI kinda sucks. It's 2016. Javascript wasn't designed for this kinda stuff.

You know what is designed for all this stuff? HTML. CSS. And Javascript works so much better with those than GDI bitmaps.

Wouldn't it be great if we had a plugin where we could display HTML and execute Jscript code too? Wouldn't it be so much better to create dom elements for text/images. Wanna rotate an image? Just use CSS: transform: rotate(7deg);. Wanna do a progressbar? No more messing with draw stuff in fast setInterval's. You could just do { transition: 1s; transition-timing-function: linear } along with a setInterval for 1000ms that just sets the element width and now you've got a beauitful, perfectly smooth progressbar. To see if a button or element was clicked on, just add a click handler to the DOM, no more checking x,y coords to see if the object you're interested in was clicked on.

Obviously you'd still need some of the JScript Panel interfaces to retrieve artwork/metadata and make it available to the HTML, but I think a lot of the other JScript interfaces/methods could be completely stripped out.

Has anybody looked into building something like this before? I feel like the WebBrowser control offers everything you need except for the JScript/Foobar connection already. My C++ is a little lacking (I'm a JS/WebDev), but I'd be happy to help out if someone got this project going.

Thoughts?
Title: Re: JScript Panel script discussion/help
Post by: always.beta on 2016-10-06 07:18:16
Wouldn't it be great if we had a plugin where we could display HTML and execute Jscript code too?

need some of the JScript Panel interfaces to retrieve artwork/metadata and make it available to the HTML

There is a component to meet your needs. It uses HTML/CSS and compatible WSH component interfaces. But because no one uses or writes scripts, the component is currently in a state of death/freeze. If you have plenty of time to explore/try to write script examples (just like WSH component contains examples), perhaps you can urge the author to continue to update the component.
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2016-10-06 08:08:36
There is a component to meet your needs. It uses HTML/CSS and compatible WSH component interfaces. But because no one uses or writes scripts, the component is currently in a state of death/freeze. If you have plenty of time to explore/try to write script examples (just like WSH component contains examples), perhaps you can urge the author to continue to update the component.
What's the component?

Just in case it's what you're referring to, foo_httpcontrol is not what I'm looking for. That obviously exists outside foobar (and I use it for certain cases like remote control of foobar), and it doesn't have a lot of the abilities/features that JScript/WSH already does.
Title: Re: JScript Panel script discussion/help
Post by: always.beta on 2016-10-06 09:04:44
What's the component?
Sciter UI (is different from DUI or CUI.)
Note: the component is unable to get foobar2000 's context menu and cover.
Installation:
1.foobar2000\components\foo_ui_sciter.dll
2.foobar2000\sciter32.dll
3.foobar2000\ui\default.htm (Create and write.)
4.sciter32.dll can be downloaded from here: (github.com/c-smile/sciter-sdk), while you can find some examples.
If you do not know please do not download and try it.
Title: Re: JScript Panel script discussion/help
Post by: always.beta on 2016-10-06 13:28:43
Upload a new version of SUI and an imperfect sample. Recommended to use with UiHacks components.


Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2016-10-07 15:55:26
There is a component to meet your needs. It uses HTML/CSS and compatible WSH component interfaces. But because no one uses or writes scripts, the component is currently in a state of death/freeze.

Maybe an official component page and an own discussion thread would help. This component sounds very promising, but I never heard of it and I believe this is the only post in the forum where it is mentioned. Previous to this I only found this 2007 post (https://hydrogenaud.io/index.php/topic,54506.msg490163.html#msg490163) where stormgren says he would like to implement something similar, is he the developer?

Title: Re: JScript Panel script discussion/help
Post by: elia_is_me on 2016-10-07 17:18:46
There is a component to meet your needs. It uses HTML/CSS and compatible WSH component interfaces. But because no one uses or writes scripts, the component is currently in a state of death/freeze.

Maybe an official component page and an own discussion thread would help. This component sounds very promising, but I never heard of it and I believe this is the only post in the forum where it is mentioned. Previous to this I only found this 2007 post (https://hydrogenaud.io/index.php/topic,54506.msg490163.html#msg490163) where stormgren says he would like to implement something similar, is he the developer?

no, it is @ohyeah the developer.

Title: Re: JScript Panel script discussion/help
Post by: always.beta on 2016-10-12 10:02:14
I downloaded the latest version of jsplaylist-mod from github. When scrolling up and down, the playlist area overlaps the Information Panel and Header Toolbar.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-10-12 10:39:23
Luckily that bug is only in master and is not part of the current component download.

Thanks for spotting.
Title: Re: JScript Panel script discussion/help
Post by: Pollux88 on 2016-10-16 00:15:37
Is it possible to have two separate Jscript panel instances in the toolbar?
Title: Re: JScript Panel script discussion/help
Post by: shortdude123 on 2016-10-16 00:31:37
can anyone post a working script that mimics the biography component/panel (artist and album)?

thx

Seconded.  The Last.Fm Bio sample that was included with the plugin no longer works. 
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-10-16 01:09:28
Is it possible to have two separate Jscript panel instances in the toolbar?

Yes. Hold Shift when selecting it.
Title: Re: JScript Panel script discussion/help
Post by: Pollux88 on 2016-10-16 01:15:29
Yes. Hold Shift when selecting it.
Perfect, thanks!
Title: Re: JScript Panel script discussion/help
Post by: zeremy on 2016-10-17 11:02:56
What's the component?
Sciter UI (is different from DUI or CUI.)
Note: the component is unable to get foobar2000 's context menu and cover.
Installation:
1.foobar2000\components\foo_ui_sciter.dll
2.foobar2000\sciter32.dll
3.foobar2000\ui\default.htm (Create and write.)
4.sciter32.dll can be downloaded from here: (github.com/c-smile/sciter-sdk), while you can find some examples.
If you do not know please do not download and try it.

@ohyeah
Thanks for sharing.

One question.
Is it possible instead of a complete UI replacement for this component to be compiled to be used with DUI or CUI as a panel?
I like the possibilities after trying it out , but I don't like the limitation not to be able to be used in conjunction with other panels.
Currently using dockable or pop-up panels as a workaround .
Title: Re: JScript Panel script discussion/help
Post by: always.beta on 2016-10-17 13:29:50
Is it possible instead of a complete UI replacement for this component to be compiled to be used with DUI or CUI as a panel?
ohyeah had ideas as you say, but now either the new UI or new components are stopped. Due to pressure of work, the current spare time is mainly used to maintain the ESLyric components.
I will ur..ge.. him to develop.
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2016-10-17 14:54:34
I like the possibilities after trying it out , but I don't like the limitation not to be able to be used in conjunction with other panels.
Currently using dockable or pop-up panels as a workaround .

How? I have both sciter UI and popup panels installed, but in the popup panels context menu I can't see a sciter panel option.
Title: Re: JScript Panel script discussion/help
Post by: ohyeah on 2016-10-17 16:18:24
What's the component?
Sciter UI (is different from DUI or CUI.)
Note: the component is unable to get foobar2000 's context menu and cover.
Installation:
1.foobar2000\components\foo_ui_sciter.dll
2.foobar2000\sciter32.dll
3.foobar2000\ui\default.htm (Create and write.)
4.sciter32.dll can be downloaded from here: (github.com/c-smile/sciter-sdk), while you can find some examples.
If you do not know please do not download and try it.

@ohyeah
Thanks for sharing.

One question.
Is it possible instead of a complete UI replacement for this component to be compiled to be used with DUI or CUI as a panel?
I like the possibilities after trying it out , but I don't like the limitation not to be able to be used in conjunction with other panels.
Currently using dockable or pop-up panels as a workaround .

Both using sciter as child window and using DUI/CUI panels in Sciter UI are possible, but I have not try yet.............
Title: Re: JScript Panel script discussion/help
Post by: MachineHead on 2016-10-27 02:56:14
Is there a way to mimic this PSS code in something like the 'track info + buttons + seekbar sample'? Not sure if context menu items can be used in that script.


Code: [Select]
$textbutton(,,,,,,)
$imagebutton($sub(%_width%,23),$sub(%_height%,32),24,24,$get(button)\gray.png,$get(button)\red.png,CONTEXT:'Slow Tagger/Toggle love tag')
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-10-27 03:22:33
https://github.com/19379/foo-jscript-panel/blob/e93048c9bbd1dcbb2e38a8b38229dc46b3fd7841/component/docs/Interfaces.txt#L225L234
Title: Re: JScript Panel script discussion/help
Post by: MachineHead on 2016-10-27 05:39:07
Thanks. I was looking in the wrong place (callbacks).
Title: Re: JScript Panel script discussion/help
Post by: elia_is_me on 2016-10-27 11:48:19
What's the component?
Sciter UI (is different from DUI or CUI.)
Note: the component is unable to get foobar2000 's context menu and cover.
Installation:
1.foobar2000\components\foo_ui_sciter.dll
2.foobar2000\sciter32.dll
3.foobar2000\ui\default.htm (Create and write.)
4.sciter32.dll can be downloaded from here: (github.com/c-smile/sciter-sdk), while you can find some examples.
If you do not know please do not download and try it.

@ohyeah
Thanks for sharing.

One question.
Is it possible instead of a complete UI replacement for this component to be compiled to be used with DUI or CUI as a panel?
I like the possibilities after trying it out , but I don't like the limitation not to be able to be used in conjunction with other panels.
Currently using dockable or pop-up panels as a workaround .

Both using sciter as child window and using DUI/CUI panels in Sciter UI are possible, but I have not try yet.............

So I believe you will try. :D
Title: Re: JScript Panel script discussion/help
Post by: tedgo on 2016-10-28 15:59:16
Is there any way to "convert" textstrings to "normal script"?

I use the Properties window for creating custom buttons. The "user" only needs to write the command here and needs to select between different "command styles":
0 = main menu command (the command will be executed as fb.RunMainMenuCommand(string))
1 = context menu command (the command will be executed as fb.RunContextCommandWithMetadb(string, fb.GetSelections(), 8 ))
2 = scripted command
But with the latter i have a problem since the properties window only transfers the input text as textstring.
For example:
var abc = 1 + 2 + 3; var def = 4 + 5 + 6;fb.ShowPopupMessage( abc + def);
becomes:
"var abc = 1 + 2 + 3; var def = 4 + 5 + 6;fb.ShowPopupMessage( abc + def);"

For the moment i use this:
Code: [Select]
var str_arr = string.split(";"),
for (var i in str_arr) eval("(" + str_arr[i] + ")");
to convert the textstring to "script".
It works but not at all... so it seems to not being possible to "create" local variables (e.g. var abc = "blablabla") here.
Also the try/catch method doesn't works... (okay... the window is really small for this purposes ;) ... but i don't want to force the users to scamp my scripts :D)

Has anyone a better idea how to convert textstrings to "script"?

EDIT: Or at least an idea how i get local variables and try/catch and maybe others i haven't tested so far to work with my method?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-10-28 17:19:01
I don't know why you're splitting the string at ; just eval the whole thing. It seems to work here.

Code: [Select]
var a = window.GetProperty("a", "test");

function on_mouse_lbtn_dblclk() {
    try {
        eval(a);
    } catch(e) {
        fb.trace(e);
    }
}

Use the properties window to add your code...

Code: [Select]
var abc = 1 + 2 + 3; var def = 4 + 5 + 6;fb.ShowPopupMessage( abc + def);

Double click the panel and it pops up 21.
Title: Re: JScript Panel script discussion/help
Post by: tedgo on 2016-10-28 18:08:23
Hmm... works for me too, but not in my script.
I send the string to a function called "AddBtnCmd()" and call this in the button.
This works for main menu and context menu, but not for the "scripted commands"...

Could you take a look at my whole script?
Maybe i made a really big mistake in it... and haven't found it so far...
(Haven't scripted for a long time... and maybe i think too complicated...)

http://pastebin.com/nv8bvkv7

It is a big script now... because i have inserted all preprocessors to get it working in every JScript panel (without the images of course).
There must be a big issue in it, because it doesn't works here... and i need to split the command at all with my script or i get an error...

From line 250 i create the function that creates the window.GetProperty() and the AddBtnCmd().
From line 372 the panel script is written (this should be the parts where my issue must have been).
(the this.funcOption comes from the TextButton the AddBtnCmd will work as command).
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-10-28 18:48:46
This works fine, I simply replaced your string split code with my try/catch??

Code: [Select]
function AddBtnCmd() {
    var str = this.funcOption.CmdString;
    this.funcOption.CmdStyle == 0 && fb.RunMainMenuCommand(str);
    this.funcOption.CmdStyle == 1 && fb.RunContextCommandWithMetadb(str, fb.GetSelections(), 8);
    if (this.funcOption.CmdStyle == 2) {
        try {
            eval(str);
        } catch (e) {
            fb.trace("Custom button error: " + e);
        }
    }
}

I'd write it like this but it's purely cosmetic and doesn't change anything...

Code: [Select]
function AddBtnCmd() {
switch (this.funcOption.CmdStyle) {
case 0:
fb.RunMainMenuCommand(this.funcOption.CmdString);
break;
case 1:
fb.RunContextCommandWithMetadb(this.funcOption.CmdString, fb.GetSelections(), 8);
break;
case 2:
try {
eval(this.funcOption.CmdString);
} catch (e) {
fb.trace("Custom button error: " + e);
}
break;
}
}
Title: Re: JScript Panel script discussion/help
Post by: tedgo on 2016-10-28 19:01:07
 :o

That's odd... so easy? :D
I'm confused... and it really works!
Big thanks!!!

I hope you haven't found another big issue in my script...
Title: Re: JScript Panel script discussion/help
Post by: tedgo on 2016-10-30 09:37:22
This makes me wonder if its possible to determine if a command is executed as fb.RunMainMenuCommand, fb.RunContextMenuCommandWithMetadb or eval().
So i could implement an automatic switch and not have to force the user to enter a number for the switch manually (when the entry is executed with one of the commands on first click i could set the property with window.SetProperty() automatically and on every next click it will again executed with the command thats binded to this property).

Any ideas?

EDIT: Nevermind. Found it out :)
Title: Re: JScript Panel script discussion/help
Post by: tedgo on 2016-10-30 11:10:29
Damn... doesn't works as expected...

I made a quick test to determine the kind of command and set the panel property with this:
Code: [Select]
var test = window.GetProperty("command style", 0);
var command = window.GetProperty("command", "");

function on_mouse_lbtn_up () {
    fb.RunMainMenuCommand(command) && window.SetProperty("command style", 1);
    fb.RunContextCommandWithMetadb(command, fb.GetSelections(), 8) && window.SetProperty("command style", 2);
    try {
        eval(command) && window.SetProperty("command style", 3);
    } catch(e) {
        fb.ShowPopupMessage("Optional button: " + e + "\n\nPlease correct your command string!")
    }
    fb.trace(window.GetProperty("command style");
}
Works for the both fb.Run... commands, but not for eval().
The command will be executed (when its a correct command) but the property will not be set.
Where is my logical flaw?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-10-30 11:49:09
Obviously eval is not returning true/false like the fb.Run... commands. What made you think it does that?

Also, I wouldn't even bother trying to determine the "style". I'd just do it on the fly each time.

Code: [Select]
function on_mouse_lbtn_up(x, y) {
if (fb.RunMainMenuCommand(command)) {
return;
} else if (fb.RunContextCommandWithMetadb(command, fb.GetSelections(), 8)) {
return;
} else {
try {
eval(command);
} catch(e) {
fb.ShowPopupMessage("Optional button: " + e + "\n\nPlease correct your command string!")
}
}
}
Title: Re: JScript Panel script discussion/help
Post by: tedgo on 2016-10-30 12:44:08
Obviously eval is not returning true/false like the fb.Run... commands. What made you think it does that?
I hoped it... :D

I ended up with exactly the same idea to not determine the style in the meantime.
And nearly exactly the same code as yours ;)
Because i realised that the button may stop working if the command will be changed and the previous command was binded to a "style"... that would force the user to change the style manually again...

But thanks again for your quick reply :)
Title: Re: JScript Panel script discussion/help
Post by: MachineHead on 2016-10-31 02:26:13
I may have asked this before, but is there a non-filthy way to pull this PSS script off with a jscript variant?

Code: [Select]
$if($isvisible_c(H1),
$imagebutton($sub(%_width%,26),$sub(%_height%,35),30,30,$get(button)\ex2.png,$get(button)\ex2h.png,PANELSHOW:H1:0;REFRESH,,),
$imagebutton($sub(%_width%,26),$sub(%_height%,35),30,30,$get(button)\ex1.png,$get(button)\ex1h.png,PANELSHOW:H1:1;REFRESH,,))

I know this (https://hydrogenaud.io/index.php?topic=63984.msg912994#msg912994) configuration uses wsh scripting to trigger panel changes. However, it doesn't seem to be be able to toggle visibility of a single panel and is pretty specific to that setup.
Title: Re: JScript Panel script discussion/help
Post by: tedgo on 2016-10-31 08:30:26
Why?
If you want to replace PSS completely its not possible at all...
If you only want a button, why don't stick with PSS?

But if its really needed to create the button in JScript panel it is possible like its done in the config you linked to.
But be aware of that JScript panel will not be able to determine if a panel is visible or not!
And you have to refresh the PSS to take effect immediately (otherweise the panel switch would take effect only on track change).

I'd do it like this (please replace <PATH> with your path to the file!):
(Code for JScript panel)
Code: [Select]
var fso = new ActiveXObject("Scripting.FileSystemObject");
var PANELoff = <PATH> + "H1_0";
var PANELon = <PATH> + "H1_1";
fso.FileExists(PANELoff) || fso.FileExists(PANELon) ? null : fso.CreateTextFile(PANELoff, true);

function PanelSwitch() {
fso.FileExists(PANELoff) ? fso.MoveFile(PANELoff, PANELon) : fso.MoveFile(PANELon, PANELoff);

if (fb.IsPlaying || fb.IsPaused) {
fb.PlayOrPause();
fb.PlayOrPause();
} else {
fb.Play();
fb.Stop();
}
}
Call the function as command for your button simply as PanelSwitch.

In PSS you will have to enter this lines (as replacement for your button):
Code: [Select]
$init_ps_global(panel.toggle,0)
$set_ps_global(panel.toggle,$right($findfile(<PATH>H1_*),1))
$showpanel_c(H1,%panel.toggle%)

If i haven't made a mistake this should work (but haven't tested it yet... have written it from scratch now...)
Title: Re: JScript Panel script discussion/help
Post by: elia_is_me on 2016-10-31 10:00:21
if you wish to switch panels using jscript I would like to introduce you shutter by jensen and dreamxis whitch doesnot use pss script at all.
Title: Re: JScript Panel script discussion/help
Post by: tedgo on 2016-10-31 10:45:09
Switching panels from JScript panel without PSS?
Is there a JScript Splitter i've never heard of?
Would be great... so i could finally dispose the old PSS...
Title: Re: JScript Panel script discussion/help
Post by: elia_is_me on 2016-10-31 12:15:04
Switching panels from JScript panel without PSS?
Is there a JScript Splitter i've never heard of?
Would be great... so i could finally dispose the old PSS...
pss component is still needed.
(another panel stack component is mega panel splitter but the author afk long time ago.)
Title: Re: JScript Panel script discussion/help
Post by: MachineHead on 2016-10-31 22:58:43
Why?
If you want to replace PSS completely its not possible at all...
If you only want a button, why don't stick with PSS?

I do not want to replace PSS. I want to trigger a hidden panel. The reason is pretty simple really. To do this you need to have the parent splitter exposed somewhere in your configuration to be able to use a button of some sort to trigger action.

While maybe not practical currently, I'd like to just have a button drawn on my JScript control bar. This would eliminate the need to do UI gymnastics (placement issues) of leaving some part of the parent splitter exposed to get at that trigger.

Anyway, I managed to get the script to not crash the panel but the actual command to trigger the action is eluding me. I've tried looking at all examples in the interfaces that may be relevant but no luck.
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2016-11-18 16:09:02
@marc2003 : Hey again, do you know if there is any difference (performance-wise) between using pseudo-transparency in Jscript panel and plain old gr.FillSolidRect in the said Jscript panel? I.e. using background color with pseudo-transparency vs painting my own background.

Thanks in advance =)

PS: Uhm, could you please check my PR on JScript? Or is it only PRs with bugfixes that are acceptable?
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2016-12-12 16:25:32
I do not want to replace PSS. I want to trigger a hidden panel. The reason is pretty simple really. To do this you need to have the parent splitter exposed somewhere in your configuration to be able to use a button of some sort to trigger action.

While maybe not practical currently, I'd like to just have a button drawn on my JScript control bar. This would eliminate the need to do UI gymnastics (placement issues) of leaving some part of the parent splitter exposed to get at that trigger.

Anyway, I managed to get the script to not crash the panel but the actual command to trigger the action is eluding me. I've tried looking at all examples in the interfaces that may be relevant but no luck.

Do you mean something like this? (.gif under spoiler) (right-click is handled via JScript, Spectrum is a PSS panel)
Spoiler (click to show/hide)
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2016-12-13 10:47:34
@marc2003 : it seems that you are ignoring me, but hey, no hard feelings =). Anyways, I think I might've found a bug, when using arrays with your latest helpers.js, caused by Array.prototype.srt. Here is an example that illustrates the bug:
Script:
Code: [Select]
// ==PREPROCESSOR==
// @name "Test Script"
// @import "%fb2k_component_path%samples\complete\js\lodash.min.js"
// @import "%fb2k_component_path%samples\complete\js\helpers.js"
// ==/PREPROCESSOR==

var my_array = ["a", "b", "c"];
for (var i in my_array){
fb.trace("my_array: ", i);
}
Result:
Code: [Select]
my_array:  0
my_array:  1
my_array:  2
my_array:  srt

PS: Yay for the triple-post!
Title: Re: JScript Panel script discussion/help
Post by: MachineHead on 2016-12-13 14:53:28
Do you mean something like this? (.gif under spoiler) (right-click is handled via JScript, Spectrum is a PSS panel)

Indeed. Although I'd probably opt for a button instead of the r-click. Did you alter cattrox for that?
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2016-12-13 15:44:49
Indeed. Although I'd probably opt for a button instead of the r-click. Did you alter cattrox for that?

Well, my version of CaTRoX had been mostly rewritten: replaced WSH with JScript, integrated marc2003's helpers, refactored code, optimizations, new features and etc. Music spectrum toggle is one of those additions.

The idea behind this is the usual PSS switch via file communication (and the only way to communicate between script from PSS panel and JScript AFAIK): you use some file to store a variable, which you can change from JScript. On every such change you execute Play and Pause from JScript. This triggers PSS PerTrack script, in which you can change panel's positions and\or size.

If you need, I can post a source code with an example later. Or if you want to figure it out yourself, you can Google "PSS Switch" =)
Title: Re: JScript Panel script discussion/help
Post by: always.beta on 2016-12-14 09:46:06
if you wish to switch panels using jscript I would like to introduce you shutter by jensen and dreamxis whitch doesnot use pss script at all.
WSH-splitter is used in the Shutter. A gif:
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2016-12-14 12:27:28
WSH-splitter is used in the Shutter.
I've tried searching for Shutter and WSH-splitter, but could not find anything. Do you by chance have a link to either of them?

[EDIT]: Nvm, found it on some chinese site. Wow, that is a lot of hacks in a single script =) Thanks for pointing it out ;)
Title: Re: JScript Panel script discussion/help
Post by: always.beta on 2016-12-14 17:24:10
Shutter
  —— by Jensen (coding) & dReamxis (design)
(http://imgur.com/a/T7Tc1)
(http://imgur.com/a/xzdgA)

>FB_Shutter_v1.1_U(Original version): based on wsh panel mod v1.5.6 & foo_ui_hacks.dll+dsound.dll+AutoItX3.dll+dynwrapx.dll
>FB_Shutter_v1.1_U+(Modified a little, may have bugs): based on wsh panel mod plus v1.5.7.4, without foo_ui_hacks.dll+dsound.dll+AutoItX3.dll+dynwrapx.dll. Replace WSH Lyric with ESLyric. Replace Albumlist with Library Tree.
>ShutterIcon: specifically designed for the shutter.
>Wsh-splitter_by_jensen(Original version): based on wsh panel mod v1.5.6 & foo_ui_hacks.dll+dsound.dll+AutoItX3.dll+dynwrapx.dll. Use Chinese to write the interface description. Looking for a good translator.
Download! (https://1drv.ms/f/s!AnFvs7Iqm0IrgdsqnuVrUBRi3tAZAQ)
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-12-17 16:38:37
Anyways, I think I might've found a bug, when using arrays with your latest helpers.js, caused by Array.prototype.srt.

Yes, it's a side effect of me messing around with the prototype. But I'll be keeping it as it has no effect on my own scripts.

Lots of workarounds...

#1
Code: [Select]
var my_array = ["a", "b", "c"];
for (var i in my_array){
    if (my_array.hasOwnProperty(i))
        fb.trace("my_array: ", i);
}

#2
Code: [Select]
var my_array = ["a", "b", "c"];
for (var i = 0; i < my_array.length; i++){
    fb.trace("my_array: ", i);
}

#3
Code: [Select]
var my_array = ["a", "b", "c"];
_.forEach(my_array, function (item, i) {
    fb.trace("my_array: ", i);
});

_.forEach is a lodash function documented here... https://lodash.com/docs/3.10.1#forEach

#4
Code: [Select]
// ==PREPROCESSOR==
// @name "Test Script"
// @import "%fb2k_profile_path%your_scripts\your_helpers.js"
// ==/PREPROCESSOR==
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2016-12-19 14:35:23
Yes, it's a side effect of me messing around with the prototype. But I'll be keeping it as it has no effect on my own scripts.
Thanks for the suggestions!
I've googled a bit and it seems that using "for var in" is considered a bad practice in JavaScript precisely because of things like that (properties and methods appearing while looping)... Additionally, "for var in" is worse performance-wise than classical "for; ;" loop and _.forEach loop. I.e. no reason at all for using "for var in" =)


Shutter
  —— by Jensen (coding) & dReamxis (design)

Thanks for the wsh_splitter tip! Incorporated needed functions in JScript from WSH-Plus and now panel toggles are much more manageable! And I can resize everything without editing every var manually =)
Though now I will have to recompile JScript every release, because of these hacks -_-""
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2016-12-22 14:01:27
Wohoo! list.js got back it's last.fm and musicbrainz support! @marc2003: was it intentional? =)
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2016-12-23 09:34:36
Does anyone know, how to get filename of the .js from .js itself?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-12-24 04:00:02
Well there are no .txt files to support the changes to list.js so I have no idea what you're talking about.  :P

I don't understand your last post or what you're trying to do.
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2016-12-26 08:40:33
Well there are no .txt files to support the changes to list.js so I have no idea what you're talking about.  :P
That is unless I don't have your old scripts saved =)

I don't understand your last post or what you're trying to do.
Here is what I'm trying to do.
Let's say I have my_script.js:
Code: [Select]
function Func()
{
    fb.trace("script name is ", GetMyName() );
}

function GetMyName()
{
/* magic here */
}

The result output of Func() should be "script name is my_script.js"
So I was wondering if it is possible to make such GetMyName() function (googling didn't help).
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-12-26 11:39:17
If you have the old .txt files then you more than likely have the old .js files. :/

As for your script name thing, it's beyond nonsensical. It serves no purpose. Type it in manually if you must.

edit: you must realise each preprocessor must contain functions that have unique names for the them to work properly. If you define the same function multiple times with the same name, only the last instance will ever get called.
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2016-12-26 12:16:18
If you have the old .txt files then you more than likely have the old .js files. :/
Yeah, but now it went from "unsupported legacy" script to "supported up-to-date" script. I.e. bug-fixes and all =)

As for your script name thing, it's beyond nonsensical. It serves no purpose. Type it in manually if you must.
Well, there is at least some value in my usage scenario: since I'm fiddling a lot with scripts, I have "Edit this script" menu item in every panel, which opens the required script file in the editor (e.g. _.run("notepad++.exe " + pathToScriptFolder + "Panel_MainScript.js") ). And if there was a way to get a script name, I could use the same code everywhere, without editing it manually.

edit: you must realise each preprocessor must contain functions that have unique names for the them to work properly. If you define the same function multiple times with the same name, only the last instance will ever get called.
Yes, of course. As far as I understand, @import is somewhat like #include, so unique name for every globally accessible function/var is a must.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-12-26 13:16:40
I still don't get it. If you have a single preprocessor file then you'd use a variable containing the file name inside the .js file itself.

Code: [Select]
var script_name = "helpers.js";

Getting the filename dynamically isn't doing anything for you. If you're constantly renaming your file... then stop being a doofus.

If you have multiple preprocessor files, I'd do one of 2 things.

a) Get all .js files in a given folder in to an array and have a custom menu that lists them all. Use utils.glob or if using my helpers.js, there is my _.getFiles function

Code: [Select]
var scripts = _.getFiles(path_to_folder, "js"); // if you want to get more than one file type, separate each one with | like "txt|log"

b) Always import a given file first and initialise a new array inside that .js file..

Code: [Select]
var scripts = ["my_script.js"];

Then in any subsequent files, add this code

Code: [Select]
scripts.push("my_script2.js");

Now build a custom menu and it will only contain menu items for the specific files used by the current script.
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2016-12-26 13:31:36
If you're constantly renaming your file... then stop being a doofus.
I probably should stop...

Now build a custom menu and it will only contain menu items for the specific files used by the current script.
Now that's a neat idea! Not sure how to implement it in my existing code yet, but I do like the concept!
Title: Re: JScript Panel script discussion/help
Post by: Scrummble on 2016-12-29 06:16:21
Sorry for disturbing back again...
If GdiDrawText is called in gdi.CreateImage(), is it impossible to avoid the black edge, even if having filled a solid background behind that?
(http://i.imgur.com/iv7FrYw.png)
The highlighted "Oh Nana" was drawn in an image created, with the pink background just behind it in the same image, while the "(2016)" was drawn directly in on_paint() callback.

I know that drawstring() could solve this problem, but I just do not like its look, and wonder if there is a way to perfectly use GDI.
Thanks for any help or hints...
Title: Re: JScript Panel script discussion/help
Post by: Scrummble on 2016-12-29 06:25:14
By the way, my reason to use temp images, is to make some scrolling effect. Like this:
(http://i.imgur.com/zHyTIwP.png)
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-12-29 09:12:12
This seems to work??

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

var font = _.gdiFont("Segoe UI", 16, 1);
var white = _.RGB(255, 255, 255);
var black = _.RGB(0, 0, 0);
var x = 0;
var img = gdi.CreateImage(100, 30);
var gb = img.GetGraphics();
gb.gdiDrawText("JScript", font, white, 0, 0, 100, 30, CENTRE); //using my own CENTRE flag, normally you'd combine your own DT_XXX
img.ReleaseGraphics(gb);


function on_paint(gr) {
gr.FillSolidRect(0, 0, window.Width, window.Height, black);
gr.DrawImage(img, x, 0, 100, 30, 0, 0, 100, 30);
}

window.SetInterval(function () {
if (x < window.Width - 100) {
x++;
window.Repaint();
}
}, 10);
Title: Re: JScript Panel script discussion/help
Post by: Scrummble on 2016-12-29 09:24:34
This seems to work??

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

var font = _.gdiFont("Segoe UI", 16, 1);
var white = _.RGB(255, 255, 255);
var black = _.RGB(0, 0, 0);
var x = 0;
var img = gdi.CreateImage(100, 30);
var gb = img.GetGraphics();
gb.gdiDrawText("JScript", font, white, 0, 0, 100, 30, CENTRE)
img.ReleaseGraphics(gb);


function on_paint(gr) {
gr.FillSolidRect(0, 0, window.Width, window.Height, black);
gr.DrawImage(img, x, 0, 100, 30, 0, 0, 100, 30);
}

window.SetInterval(function () {
if (x < window.Width - 100) {
x++;
window.Repaint();
}
}, 10);

It doesn't. The black edge is unsurprisingly hard to recognize when the background is also black... And if the background is red, it looks like this:
(http://i.imgur.com/KJZDYSs.png)
Just change "var black = _.RGB(0, 0, 0);" to any brighter color, and you'll notice the difference......

It's frustrating to see a... feature? bug? like this. I guess it's Windows's fault. Now I have to use some dirty hacks, such as caching the pseudo-transparent background and use it to overlay the hidden parts. I feel sorry of my CPU for the extra process to do...
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-12-29 09:28:50
Well I used black because I thought your 2nd image was your desired end result!

I very much doubt I'll be able to do anything but I'll have a look.
Title: Re: JScript Panel script discussion/help
Post by: Scrummble on 2016-12-29 09:32:56
Forgot to say, even if adding "gb.FillSolidRect(0, 0, 100, 30, black);" in the temp image part, the problem remains the same.
Code: [Select]
// ==PREPROCESSOR==
// @import "%fb2k_component_path%samples\complete\js\lodash.min.js"
// @import "%fb2k_component_path%samples\complete\js\helpers.js"
// ==/PREPROCESSOR==

var font = _.gdiFont("Segoe UI", 16, 1);
var white = _.RGB(255, 255, 255);
var black = _.RGB(200, 0, 0);
var x = 0;
var img = gdi.CreateImage(100, 30);
var gb = img.GetGraphics();
gb.FillSolidRect(0, 0, 100, 30, black);
gb.gdiDrawText("JScript", font, white, 0, 0, 100, 30, CENTRE)
img.ReleaseGraphics(gb);


function on_paint(gr) {
 gr.FillSolidRect(0, 0, window.Width, window.Height, black);
 gr.DrawImage(img, x, 0, 100, 30, 0, 0, 100, 30);
}

window.SetInterval(function () {
 if (x < window.Width - 100) {
 x++;
 window.Repaint();
 }
}, 10);
Title: Re: JScript Panel script discussion/help
Post by: Scrummble on 2016-12-29 09:37:19
Well I used black because I thought your 2nd image was your desired end result!

I very much doubt I'll be able to do anything but I'll have a look.
Sorry for the confusion. The second image is "what it looks if left alone", and if the mouse hovers on the text, it should have a grey background to highlight itself. In the first image I used pink to have a trial...
And the background in the second image is not "black"... It's 20-20-20, and you can recognize the 0-0-0 black edge if looking carefully.
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2016-12-29 14:17:03
Interestingly, it seems that, when selection is changed, if you have Window.Repaint() inside on_playlist_items_selection_change, on_paint method won't be called, not until on_item_focus_change is called :\
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-12-29 15:00:42
This works for me without an on_item_focus_change function.

Code: [Select]
var path = fb.GetFocusItem() ? fb.GetFocusItem().Path : "<nothing selected>";
var font = gdi.Font("Segoe UI", 12);

function on_playlist_items_selection_change() {
    path = fb.GetFocusItem() ? fb.GetFocusItem().Path : "<nothing selected>";
    window.Repaint();
}

function on_paint(gr) {
    gr.GdiDrawText(path, font, 0, 0, 0, window.Width, window.Height, 0);
}

I also added an empty one and it works the same.
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2016-12-29 15:12:40
This works for me without an on_item_focus_change function.
What I meant is a little different. Here is an example:

Code: [Select]
var path = fb.GetFocusItem() ? fb.GetFocusItem().Path : "<nothing selected>";
var font = gdi.Font("Segoe UI", 12);

function on_playlist_items_selection_change() {
    fb.trace("on_playlist_items_selection_change");
    path = fb.GetFocusItem().Path;
    window.Repaint();
}

function on_item_focus_change()
{
    fb.trace("on_item_focus_change");
    window.Repaint();
}

function on_paint(gr) {
    fb.trace("on_paint");
    gr.GdiDrawText(path, font, 0, 0, 0, window.Width, window.Height, 0);
}

Trace log when focus is changed:
Code: [Select]
on_playlist_items_selection_change
on_playlist_items_selection_change
on_item_focus_change
on_paint

on_paint was called only once instead of thrice. It might be an optimization feature, but it's not very intuitive and I could not find any mention about it in docs =)

[EDIT]: Do you know the difference between on_playlist_items_selection_change and on_selection_changed? What I gathered from docs is that on_selection_changed might not always work, but then why use it at all instead of always using on_playlist_items_selection_change?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-12-29 15:32:37
Yes, it looks like if you call window.Repaint in rapid succession, it doesn't process. This timer is using 2ms whereas I suspect those callbacks were happening much closer together.

Code: [Select]
var x = 0;

var timer = window.SetInterval(function () {
x++;
if (x > 100)
window.ClearInterval(timer);
fb.trace("timer " + x);
window.Repaint();
}, 2);

function on_paint(gr) {
fb.trace("on_paint " + x);
}

Result:
Code: [Select]
on_paint 0
timer 1
timer 2
on_paint 2
timer 3
timer 4
timer 5
on_paint 5
timer 6
timer 7
on_paint 7
timer 8
timer 9
timer 10
on_paint 10
timer 11
on_paint 11
timer 12
on_paint 12
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2016-12-29 15:36:06
Yes, it looks like if you call window.Repaint in rapid succession, it doesn't process. This timer is using 2ms whereas I suspect those callbacks were happening much closer together.
Darn, guess I'll have to take it into account when making scripts... Thanks for figuring it out.

[EDIT]: it might be linked to monitor refresh rate: 60HZ == 1 refresh every 16,(6) ms. Will test it out on 120HZ monitor later.

[EDIT2]: Nah, I was wrong, it seems it depends purely on CPU, i.e. how fast it can process Repaint calls. Because I have logs like this
Code: [Select]
timer 60
on_paint 60
timer 61
on_paint 61
timer 62
on_paint 62
timer 63
on_paint 63
timer 64
on_paint 64
timer 65
on_paint 65
timer 66
on_paint 66
timer 67
on_paint 67
timer 68
timer 69
on_paint 69
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-12-29 15:36:26
[EDIT]: Do you know the difference between on_playlist_items_selection_change and on_selection_changed? What I gathered from docs is that on_selection_changed might not always work, but then why use it at all instead of always using on_playlist_items_selection_change?

on_selection_changed gets called when selecting tracks in Library viewers like Album List, not just playlists.
Title: Re: JScript Panel script discussion/help
Post by: foosion on 2016-12-29 19:33:50
window.Repaint(force) maps to HostComm::Repaint (https://github.com/19379/foo-jscript-panel/blob/a39c3d56d23a93f80fccbfbebb97f9e309509234/foo_jscript_panel/host.cpp#L39) on the C++ side. With force set to false it just marks the window as as dirty, i.e. it sets a flag which tells the window manager that this window needs to be redrawn. With force set to true it causes the window to be redrawn immediately. The idea is to use the delayed redraw (with force set to false) whenever possible because redrawing a window is usually an expensive operation (compared to setting a flag, adding two numbers or formatting a string). You should generally use a delayed redraw inside a callback from foobar2000, i.e. for playback events or playlist changes.
Title: Re: JScript Panel script discussion/help
Post by: elia_is_me on 2016-12-29 21:57:45
Sorry for disturbing back again...
If GdiDrawText is called in gdi.CreateImage(), is it impossible to avoid the black edge, even if having filled a solid background behind that?
(http://i.imgur.com/iv7FrYw.png)
The highlighted "Oh Nana" was drawn in an image created, with the pink background just behind it in the same image, while the "(2016)" was drawn directly in on_paint() callback.

I know that drawstring() could solve this problem, but I just do not like its look, and wonder if there is a way to perfectly use GDI.
Thanks for any help or hints...

Use g.DrawString instead of gdiDrawText, and g.SetTextRenderingHint(4) before that.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-12-30 04:32:12
window.Repaint(force) maps to HostComm::Repaint (https://github.com/19379/foo-jscript-panel/blob/a39c3d56d23a93f80fccbfbebb97f9e309509234/foo_jscript_panel/host.cpp#L39) on the C++ side. With force set to false it just marks the window as as dirty, i.e. it sets a flag which tells the window manager that this window needs to be redrawn. With force set to true it causes the window to be redrawn immediately. The idea is to use the delayed redraw (with force set to false) whenever possible because redrawing a window is usually an expensive operation (compared to setting a flag, adding two numbers or formatting a string). You should generally use a delayed redraw inside a callback from foobar2000, i.e. for playback events or playlist changes.

Completely forgot about the "force". I've never had to use it myself and I don't think I've seen it anyone else's scripts either. I don't think real world usage needs it. Like you say, the whole point is to reduce redrawing if you can.
Title: Re: JScript Panel script discussion/help
Post by: Scrummble on 2016-12-30 11:27:31
Sorry for disturbing back again...
If GdiDrawText is called in gdi.CreateImage(), is it impossible to avoid the black edge, even if having filled a solid background behind that?
(http://i.imgur.com/iv7FrYw.png)
The highlighted "Oh Nana" was drawn in an image created, with the pink background just behind it in the same image, while the "(2016)" was drawn directly in on_paint() callback.

I know that drawstring() could solve this problem, but I just do not like its look, and wonder if there is a way to perfectly use GDI.
Thanks for any help or hints...

Use g.DrawString instead of gdiDrawText, and g.SetTextRenderingHint(4) before that.

I know. As you see, I mentioned it in the original post.

I'm just not in favor of what it looks like... And the fact that gdidrawstring() resulting weirdly, even if with a solid background, seems strange to me. I hope it can be fixed somehow... Or I have to use those dirty, dirty hacks...
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-12-30 11:44:49
Even this snippet which saves as .png has the same problem. I doubt I'll find out how to fix this.

Code: [Select]
// ==PREPROCESSOR==
// @import "%fb2k_component_path%samples\complete\js\lodash.min.js"
// @import "%fb2k_component_path%samples\complete\js\helpers.js"
// ==/PREPROCESSOR==
var font = _.gdiFont("Segoe UI", 72, 1);
var white = _.RGB(255, 255, 255);
var img = gdi.CreateImage(400, font.Height);
var gb = img.GetGraphics();
gb.gdiDrawText("JScript", font, white, 0, 0, 400, font.Height, CENTRE | DT_VCENTER)
img.ReleaseGraphics(gb);
img.SaveAs("z:\\test.png"); //png is default, no need to specify type
Title: Re: JScript Panel script discussion/help
Post by: Scrummble on 2016-12-30 16:30:18
Even this snippet which saves as .png has the same problem. I doubt I'll find out how to fix this.

Code: [Select]
// ==PREPROCESSOR==
// @import "%fb2k_component_path%samples\complete\js\lodash.min.js"
// @import "%fb2k_component_path%samples\complete\js\helpers.js"
// ==/PREPROCESSOR==
var font = _.gdiFont("Segoe UI", 72, 1);
var white = _.RGB(255, 255, 255);
var img = gdi.CreateImage(400, font.Height);
var gb = img.GetGraphics();
gb.gdiDrawText("JScript", font, white, 0, 0, 400, font.Height, CENTRE | DT_VCENTER)
img.ReleaseGraphics(gb);
img.SaveAs("z:\\test.png"); //png is default, no need to specify type
As I know, gdidrawtext() needs a background to run, and if it is running on a transparent background, as in the snippet above, it will use black (0-0-0) as a background by default.
So, technically, there is no bug in that snippet. And my real problem is, in a temp graphic part, even if a (colorful) background is defined before, the gdidrawtext() still runs as the background is black; while the problem don't appear with normal gr. in on_paint() callbacks.
Hope I successfully delivered what I thought...

Code: [Select]
// ==PREPROCESSOR==
// @import "%fb2k_component_path%samples\complete\js\lodash.min.js"
// @import "%fb2k_component_path%samples\complete\js\helpers.js"
// ==/PREPROCESSOR==
var font = _.gdiFont("Segoe UI", 72, 1);
var white = _.RGB(255, 255, 255);
var img = gdi.CreateImage(400, font.Height);
var gb = img.GetGraphics();
//Pre-define a background
gb.FillSolidRect(0, 0, 400, font.Height, 0xffabcdef);
gb.gdiDrawText("JScript", font, white, 0, 0, 400, font.Height, CENTRE | DT_VCENTER);
img.ReleaseGraphics(gb);
img.SaveAs("z:\\test.png"); //png is default, no need to specify type
Hope this may somehow result a smooth image...
Title: Re: JScript Panel script discussion/help
Post by: foosion on 2016-12-30 17:41:57
The component creates image objects which use premultiplied alpha (see https://github.com/19379/foo-jscript-panel/blob/master/foo_jscript_panel/script_interface_impl.cpp#L1122).

PNG on the other hand uses non-premultiplied alpha (see https://www.w3.org/TR/PNG-Rationale.html#R.Non-premultiplied-alpha).

One would hope that GDI+ did the right thing when drawing an image. On the other hand your experiments indicate that it uses the blend formula for non-premultiplied alpha. As a quick search reveals other people have noticed this behaviour as well (see http://stackoverflow.com/questions/19809506/drawing-pixelformat32bpppargb-images-with-gdi-uses-conventional-formula-instead).

Changing the pixel format would solve this problem. Some part of the code may require changes as well if they expect premultiplied alpha.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2016-12-30 20:21:00
Forgive me if I'm being dense but I'm not sure any of that is relevant given DrawString works fine?? You'll have to ask Scrummble why it's not good enough.

Title: Re: JScript Panel script discussion/help
Post by: foosion on 2016-12-30 21:40:58
You have a point there. I should have paid closer attention. I might have noticed that GdiDrawText does not use GDI+ but plain old GDI.
Title: Re: JScript Panel script discussion/help
Post by: kode54 on 2016-12-30 22:15:08
It's possible to trick it, ala what I did in foo_osd for GDI text drawing: Render an alpha mask separately, by rendering the text again using solid white on solid black, and capture the green channel of the result as the alpha level, and treat the correctly colored text on black background as the color channels pre-multiplied.
Title: Re: JScript Panel script discussion/help
Post by: Scrummble on 2016-12-30 23:06:48
My assumption is that changing PixelFormat32bppPARGB to PixelFormat32bppARGB may works in this issue. Had anyone given it a try? I'm afraid I do not have any knowledge of C++, so please teach me if there's anything wrong.

It's possible to trick it, ala what I did in foo_osd for GDI text drawing: Render an alpha mask separately, by rendering the text again using solid white on solid black, and capture the green channel of the result as the alpha level, and treat the correctly colored text on black background as the color channels pre-multiplied.

Thanks for the alternative method, but it will dispose of the LCD specified rendering. I haven't give it a try, but I guess it may look just like SetTextRenderingHint(4). I think I should stick on the "all on_paint and concealing with fake background" hack anyway...
Title: Re: JScript Panel script discussion/help
Post by: kode54 on 2016-12-30 23:22:47
Thanks for the alternative method, but it will dispose of the LCD specified rendering. I haven't give it a try, but I guess it may look just like SetTextRenderingHint(4). I think I should stick on the "all on_paint and concealing with fake background" hack anyway...
Actually, it only tosses out the LCD rendering for the alpha mask, where it would be impossible to calculate an alpha mask anyway. The red/blue hinting would still exist on the RGB colored text that is rendered separately as the pre-scaled RGB channels. Assuming your GDI rendering code doesn't force grayscale hinting.

And even if that doesn't work, you can always render your own LCD hinted text, simply by scaling the text up to 3x size, then using an RGB matrix to downscale the horizontal part to 1/3 size with just the right R/G/B crosstalk. Search for the old "Clearize" demo for Allegro for an example reduction matrix.

E: Disregard "Clearize" tip, said site and software no longer exists. But there's still this (http://everything2.com/title/ClearType).
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-01-01 06:13:57
I've fixed up all 3 of Falstaff/Br3tt's JS Smooth scripts so they work in the latest version of JScript Panel. It was some badly formatted if/else statements that prevented it working with the Chakra engine.

https://github.com/19379/JS-Smooth-Scripts-By-Br3tt

@Falstaff, if you read this sometime, the new component didn't like you coding like this...

Code: [Select]
if (something) {

};
else {

}

It had to be replaced with

Code: [Select]
} else {

edit: Just realised I missed the catch statements so an updated version has been uploaded.
Title: Re: JScript Panel script discussion/help
Post by: jahwise on 2017-02-10 22:15:53
Hi everyone,

How i can get rid of the white border around the cover in the Js Smooth Playlist ?
Can't spot the function. :(
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-02-11 01:12:36
Do you mean jsplaylist-mod? I can't see any border in the Smooth version.

edit: Seems to be line 770 in user-components\foo_jscript_panel\samples\jsplaylist-mod\js\WSHPlaylist.js. Either change the colour or comment the entire line out. Remember that any future component update would overwrite changes so make sure you save a copy elsewhere.
Title: Re: JScript Panel script discussion/help
Post by: evil roy on 2017-02-18 23:27:18
I have been using JScript Panel along with marc's last.fm bio.txt and thumbs.txt.  Both worked admirably up until some time this week.  At some point after updating JScript to v1.2.0, both now are displaying blank windows for new artists but still showing bio/pics for existing artists (cached I assume).   Is anyone else having this issue?  I tried rolling back the JScript to v 1.1.3--no luck

Any help would be much appreciated.

fb2k v1.3.14
Windows 10
Title: Re: JScript Panel script discussion/help
Post by: magnumforce2006 on 2017-02-19 00:50:29
I have been using JScript Panel along with marc's last.fm bio.txt and thumbs.txt.  Both worked admirably up until some time this week.  At some point after updating JScript to v1.2.0, both now are displaying blank windows for new artists but still showing bio/pics for existing artists (cached I assume).   Is anyone else having this issue?  I tried rolling back the JScript to v 1.1.3--no luck

Any help would be much appreciated.

fb2k v1.3.14
Windows 10

Yeah, I think Last.fm may have done something to break the bio panel on their end. This is what I get when I try to download artist art with the Bio Script:

"np_basic: HTTP error: 0"
Title: Re: JScript Panel script discussion/help
Post by: jazzthieve on 2017-02-19 00:59:31
I have been using JScript Panel along with marc's last.fm bio.txt and thumbs.txt.  Both worked admirably up until some time this week.  At some point after updating JScript to v1.2.0, both now are displaying blank windows for new artists but still showing bio/pics for existing artists (cached I assume).   Is anyone else having this issue?  I tried rolling back the JScript to v 1.1.3--no luck

Any help would be much appreciated.

fb2k v1.3.14
Windows 10

Yep, here too. Had foreseen this was to happen considering last.fm's track record. Lucky I cached as much as I could before it stopped working.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-02-19 06:25:25
Last.fm have updated their website to use https therefore the scripts need to be updated. Edit your text.js/thumbs.js files and replace http with https.

text.js
Code: [Select]
var url = "https://" + this.bio_lastfm_sites[this.bio_lastfm_site] + "/music/" + encodeURIComponent(this.artist) + "/+wiki";

thumbs.js
Code: [Select]
this.xmlhttp.open("GET", "https://www.last.fm/music/" + encodeURIComponent(this.artist) + "/+images", true);
Title: Re: JScript Panel script discussion/help
Post by: Coreda on 2017-02-19 10:13:13
Cross-posting here since it slipped my mind there was a separate discussion/help thread when replying in the other thread and I can't now delete it.

JSplaylist is now bundled with the component itself.

https://github.com/19379/foo-jscript-panel/tree/master/component/samples

Ah, good to know.

With regard to force sorting in the panel, any ideas? I find I have to right-click the columns header>Groups>Apply group sorting to override the filename sorting and apply track number order, but the option doesn't seem to be able to be permanently set.
Title: Re: JScript Panel script discussion/help
Post by: magnumforce2006 on 2017-02-19 12:40:35
Last.fm have updated their website to use https therefore the scripts need to be updated. Edit your text.js/thumbs.js files and replace http with https.

text.js
Code: [Select]
var url = "https://" + this.bio_lastfm_sites[this.bio_lastfm_site] + "/music/" + encodeURIComponent(this.artist) + "/+wiki";

thumbs.js
Code: [Select]
this.xmlhttp.open("GET", "https://www.last.fm/music/" + encodeURIComponent(this.artist) + "/+images", true);
 

Thanks!
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2017-03-03 22:13:55
Is it possible with jscript to hide or show a columns ui panel? In other words to trigger the panelshow command of panel stack splitter?

I finally learned a workaorund for this: you can create and delete an empty text file with the CreateTextFile and DeleteFile methods which than PSS can check out with the $findfile function to trigger any command you like.

I have to credit the russian forum for this.
Title: Re: JScript Panel script discussion/help
Post by: Falstaff on 2017-03-04 14:12:39
I've fixed up all 3 of Falstaff/Br3tt's JS Smooth scripts so they work in the latest version of JScript Panel. It was some badly formatted if/else statements that prevented it working with the Chakra engine.

https://github.com/19379/JS-Smooth-Scripts-By-Br3tt

@Falstaff, if you read this sometime, the new component didn't like you coding like this...

Code: [Select]
if (something) {

};
else {

}

It had to be replaced with

Code: [Select]
} else {

edit: Just realised I missed the catch statements so an updated version has been uploaded.


ok, seen, i'll be aware of that.
Title: Re: JScript Panel script discussion/help
Post by: widerock on 2017-03-07 01:33:49
There is a js-script panel which changes in the size according to the toggle notify. (for example, h1 = 500, h2=1)
In other word,
for toggle --> panel height = h1
for !toggle --> panel height = h2

What I want to do is (%path% is "youtube.com/watch~~~~")
for toggle and %path% include 'youtube' --> panel height = h1
for toggle, and %path% Not include 'youtube' --> panel height = 10
for !toggle  --> panel height = h2

So, I tried like this,
Code: [Select]
var chk_yt = "$left(%path%,7)";

function on_notify_data(name, info) {
    switch(name) {
  case "center_panel":
                      toggle = !toggle;
                      window.SetProperty("toggle", toggle);
                           if(toggle) {
if(chk_yt == "youtube") {
window.MinHeight = h1;
window.MaxHeight = h1;
} else {
window.MinHeight = 10;
window.MaxHeight = 10;
};
                           } else {
                                 window.MinHeight = h2;
                                 window.MaxHeight = h2;
                           };
                           break;
}
}
But, it doesn't work as I wanted. Could anyone give me some hint to make this work?
Title: Re: JScript Panel script discussion/help
Post by: zeremy on 2017-03-07 08:10:49
First replace ..
Code: [Select]
var chk_yt = "$left(%path%,7)";
with
Code: [Select]
var chk_yt = fb.TitleFormat("%path%").Eval().substring(0,7);
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-03-07 12:09:14
That bit of code needs to go inside the function, If it runs outside the function at script startup, the value will never update.

If unsure, you can always output stuff to the console to check the value is what you expect it to be.

Code: [Select]
fb.trace(chk_yt);
Title: Re: JScript Panel script discussion/help
Post by: widerock on 2017-03-07 16:57:21
zeremy & marc2003,
Thank you for your kind help. It was very helpful.

Even though my current foobar is very close to the final target, there is a small problem.
When I change tracks between 'youtube' songs and 'non-youtube' songs, I want the size(panel height) of jsscript panel to automatically be changed according to the source of track.

youtube track --> panel height = h1
non-youtube track  --> panel height = 1


Could you let me know how to change  the following scripts for that purpose?
Code: [Select]
function on_size() {
    ww = window.Width;
    wh = window.Height;
    var chk_yt = fb.TitleFormat("%path%").Eval().substring(0,7);
    if(chk_yt == "youtube") {
        if(toggle) {
            window.MinHeight = h1;
            window.MaxHeight = h1;
        } else {
            window.MinHeight = 1;
            window.MaxHeight = 1;
        };
    } else {
        window.MinHeight = 1;
        window.MaxHeight = 1;
    };
    window.MinWidth = 1;
    window.MaxWidth = 1;
}


function on_notify_data(name, info) {
    switch(name) {
        case "height_notify":
            max_h = (info - 3);
        case "width_notify":
            height = Math.round(info * 0.5625);
            if(height >= max_h) {
                h1 = max_h;
            } else {
                h1 = Math.round(info * 0.5625)-1;
            };
            window.MinHeight = 1;
            window.MaxHeight = 1;
            break;
        case "center_pane":
            toggle = !toggle;
            window.SetProperty("toggle", toggle);
            var chk_yt = fb.TitleFormat("%path%").Eval().substring(0,7);
            if(chk_yt == "youtube") {           
                if(toggle) {
                    window.MinHeight = h1;
                    window.MaxHeight = h1;
                } else {
                    window.MinHeight = 1;
                    window.MaxHeight = 1;
                }
            } else {
                window.MinHeight = 1;
                window.MaxHeight = 1;
            };
            break;
    }
}
Title: Re: JScript Panel script discussion/help
Post by: zeremy on 2017-03-07 18:05:07
I see you are using function on_notify_data(name, info).
Could you clarify if you need to notify from a jscript panel another second jscript panel with window.NotifyOthers .
Are they two separate panels or do you just want one jscript panel height to change when youtube is playing?
What is the purpose of the variable toggle?
Title: Re: JScript Panel script discussion/help
Post by: widerock on 2017-03-08 00:01:44
I see you are using function on_notify_data(name, info).
Could you clarify if you need to notify from a jscript panel another second jscript panel with window.NotifyOthers .
Are they two separate panels or do you just want one jscript panel height to change when youtube is playing?
What is the purpose of the variable toggle?
My configuration is like this.
I have several panels such as "playlists, album art, biography, play control, foo_youtube, etc"
I want 'foo_youtube' panel to be size-adjusted according to the foobar window & other panel sizes, and to be toggled by 'toggle buttons' in a different jscript panel.
For this purpose, I made created two panels with 'left/right'splitter. And 'foo_youtube is implemented in the left panel, and the above code is implemented in the right panel.
So, by changing the height of the right panel, I can hide/show the foo_youtube panel which has 16:9 ratio.
"height_notify" and "width_notify" are notified from the other jscript panels and are used to adjust the right panel height.

At this moment, I can toggle the foo_youtube panel by clicking the 'toggle button'.
The purpose of toggle : "Sometimes I want to see the youtube video, sometimes only want to listen the youtube audio by hiding 'foo_youtube' panel."
But, some playlists have mixes of "youtube songs" and 'non-youtube songs."
For those playlists, it would be nice if the 'foo_youtube' panel can be hide/show automatically by checking if the now-playing song is coming from 'youtube' site.

I hope that the above explanation make clear my intention.
Thank you agian for your interest and help.
Title: Re: JScript Panel script discussion/help
Post by: zeremy on 2017-03-08 07:40:33
You can send the value if "youtube" from your "control panel" on each new track played with:
Code: [Select]
function on_playback_new_track(){
var chk_yt = fb.TitleFormat("%path%").Eval().substring(0,7);
window.NotifyOthers("center_pane",chk_yt);
}

In the panel to be notified add:

Code: [Select]
function on_notify_data(name, info) {
    switch(name) {
        case "center_pane":
            if(info == "youtube") {           
                if(toggle) {
                    window.MinHeight = h1;
                    window.MaxHeight = h1;
                } else {
                    window.MinHeight = 1;
                    window.MaxHeight = 1;
                }
            } else {
                window.MinHeight = 1;
                window.MaxHeight = 1;
            };
            break;
    }
}

toogle and h1 will have to be defined beforehand for it to work though.

The panel cannot be in a PSS  https://github.com/19379/foo-jscript-panel/blob/master/component/docs/Interfaces.txt#L759 (https://github.com/19379/foo-jscript-panel/blob/master/component/docs/Interfaces.txt#L759)

I lost you when you referred to showing/hiding the video panel ( even after a cup of coffee  :D ) , you can only change the jscript panel size,
Title: Re: JScript Panel script discussion/help
Post by: widerock on 2017-03-08 12:56:42
toogle and h1 will have to be defined beforehand for it to work though.
I lost you when you referred to showing/hiding the video panel ( even after a cup of coffee  :D ) , you can only change the jscript panel size,
Thank you very very much for your help.
With minor optimization for your above  code, my foobar is fianlly working as I wanted

For the reference, I leave my final code for my purpose.

In the foobar control jscript  panel,
Code: [Select]
function on_playback_new_track(){
var chk_yt = fb.TitleFormat("%path%").Eval().substring(0,7);
window.NotifyOthers("chk_yt",chk_yt);
}

In the target jscript paenl,
Code: [Select]
function on_notify_data(name, info) {
    switch(name) {
case "center_pane":
            toggle1 = !toggle1;
            window.SetProperty("toggle1", toggle1);
            toggle = toggle1;
            if(chk_yt == "youtube") {
                if(toggle1) {
                    window.MinHeight = h1;
                    window.MaxHeight = h1;
                } else {
                    window.MinHeight = 1;
                    window.MaxHeight = 1;
                };
            } else {
                toggle = false;
                window.MinHeight = 1;
                window.MaxHeight = 1;
            };
            break;
        case "chk_yt":
            chk_yt = info;
            if(info == "youtube") {
                toggle = toggle1;               
                if(toggle1) {
                    window.MinHeight = h1;
                    window.MaxHeight = h1;
                } else {
                    window.MinHeight = 1;
                    window.MaxHeight = 1;
                };
            } else {
                toggle = false;
                window.MinHeight = 1;
                window.MaxHeight = 1;
            };
            break;
    }
}
Title: Re: JScript Panel script discussion/help
Post by: widerock on 2017-03-10 02:40:52
I have a question about  on_playback_stop()  & on_playback_new_track()

Now, I'm using the below code to notify 'stop' to the other panel.
Code: [Select]
function on_playback_stop() {
    window.NotifyOthers("stop_notify","");
buttons.update();
    window.Repaint();
}
Function "on_playback_new_track()"  don't have any NotifyOthers. But, whenever a new track is played according to the plalist queue,  it looks like 'stop_notify' is activated.( playback_new_track --> playback_stop + playback_starting ?)

How can I notify 'stop_notify' only  when I "Really" stop playing foobar?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-03-10 02:49:37
docs\callbacks.txt

https://github.com/19379/foo-jscript-panel/blob/master/component/docs/Callbacks.txt#L133L134

Something like

Code: [Select]
function on_playback_stop(reason) {
    if (reason < 2) {
        window.NotifyOthers("stop_notify","");
    }
    buttons.update();
    window.Repaint();
}
Title: Re: JScript Panel script discussion/help
Post by: widerock on 2017-03-10 03:19:38
docs\callbacks.txt

https://github.com/19379/foo-jscript-panel/blob/master/component/docs/Callbacks.txt#L133L134

Something like

Code: [Select]
function on_playback_stop(reason) {
    if (reason < 2) {
        window.NotifyOthers("stop_notify","");
    }
    buttons.update();
    window.Repaint();
}
Wow. It's so simple.  I didn't know that there are those documents under jscript-panel plugin.
Thank you for your help.
Title: Re: JScript Panel script discussion/help
Post by: Takaji on 2017-03-23 17:29:08
Hi marc2003,

Firstly, thank you for your work on JScript Panel, and thank you for sharing it with the fb2k community.

I'm using your album art script example, and I noticed that the included shadow overlay PNG didn't blend so well at the edges - so I made another version in Photoshop that fixes this and wanted to share it with you snd the community.

Here's the download to the revised shadow.png: http://i.imgur.com/js04cN8.png
And here's the comparison against your original version: http://i.imgur.com/plXl0Nw.png

On a side note, I disabled the forced crop/fill option that you specify when using the CD case background, because some of the releases in my collection are in mini-CD single format, which looks bad when forced to fill the extents of the jewel case. Perhaps you might want to consider making this a toggle that can be selected when using the CD case?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-03-23 18:48:18
I'll use your updated image in the next release. Thanks.

As for the aspect, I always thought cropping the image was best without giving a choice. I think gaps around non square images look bad on the case background?? Still, I suppose I can restore the option to let people choose.

edit: changes have been made in this commit (https://github.com/19379/foo-jscript-panel/commit/d606f953ef6bc1c2ab78123ef46c448ef7a14020).
Title: Re: JScript Panel script discussion/help
Post by: Takaji on 2017-03-23 19:16:38
I think gaps around non square images look bad on the case background?? Still, I suppose I can restore the option to let people choose.

Well, it definitely is not realistic for a tall, rectangular cover to sit inside a CD jewel case tray, but for the few releases I have with album art in that format, it doesn't bother me - seeing the entire album art is a higher priority.

Thanks for the commit! :)
Title: Re: JScript Panel script discussion/help
Post by: Axonn on 2017-03-27 14:26:48
I have a perhaps silly question about debugging scripts running inside JSPanel. Here's an example error:

JScript Panel (Rating by marc2003): Microsoft JScript runtime error:
'_' is undefined
File: <main>
Line: 13, Col: 1
<source text only available at compile time>

What does "source text only available at compile time" mean? Can I actually see more debug info during... compile time? What does "compile time" mean? Can I somehow debug the C++ component using Visual Studio if I launch foobar? Or can I debug the JS script from a tool such as Webstorm? (although this second variant I guess would be a bit more technically challenging to perform since it requires somehow connecting the IDE to the browser VM running under Foobar).
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-03-28 09:34:58
Just ignore the stuff you don't understand. Line 13 and '_' is undefined is actually all the information you need. No fancy IDE/debugger is going to be any more helpful.

Anyway, the reason for that error is that important files are missing because you didn't install the component properly. I did link to the foolproof instructions but I guess you decided you were bit of a gangster and extracted the dll only?

http://wiki.hydrogenaud.io/index.php?title=Foobar2000:How_to_install_a_component
Title: Re: JScript Panel script discussion/help
Post by: Axonn on 2017-03-28 10:06:26
Hey :). I managed to fix the error because the next error was quite clear. Yes, I initially only extracted the DLL. But it wasn't because I wanted more street cred' :). It was because "docs" and "samples" didn't seem to me to need to belong in the components folder. But I'm fine with whatever! :). The component ROCKS and I'm very enthusiastic to work with it now that I finally managed to set some time for this.

I'm trying to build a multi-tag tool. Something that allows to set multiple tags to song and filter on them. Things like a song's style, mood, vocal style, lyrical theme, tempo. What I'm aiming is to allow a user to create auto playlists by requesting, for example, "all songs that feature female vocals, have a slow tempo and have a mystic atmosphere". I plan to perhaps build relations between tags so that similar suggestions are found based on the selected tags.

I do have a few questions to start with:

There is no dropdown list component from what I see? I can probably achieve a similar functionality by creating context menus with options, something I've already seen used in some of your samples. But what if there are more items that fit on the screen? What is your recommendation in that case? Should I use GDI to create my own component?

I'd like to implement an autocomplete textbox. The purpose being that when you start typing any tag, you get a suggestion that you can "tab" to autocomplete. This should be pretty easy right? Just create a hotkey hook. I hope TAB... won't tab me out of the panel :).

I'm kind of aiming to go into the Columns UI code anyway and see if I can find a way to install shortcuts for focusing on various panels, as I am very keyboard driven and would love to operate Foobar as much as possible using keyboard only.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-03-28 10:25:19
If the menu doesn't fit on screen, there will be arrows to scroll up/down. Example....

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

var items = _.range(0, 1000);

function on_mouse_lbtn_up(x, y) {
var m = window.CreatePopupMenu();
_.forEach(items, function (i) {
m.AppendMenuItem(MF_STRING, i + 1, "Menu Item " + i);
});
var idx = m.TrackPopupMenu(x, y);
if (idx > 0)
fb.ShowPopupMessage("You selected item " + (idx - 1));
m.Dispose();
}

Falstaff/Wilb both have scripts available with fully functioning text boxes that you can type in. Look at jsplaylist-mod (included with component) or Wilb's Library tree script.
Title: Re: JScript Panel script discussion/help
Post by: Axonn on 2017-03-28 12:39:39
Perfect. Thank you for all the pointers :). Helpful as usual. Thank you for your patience as you explain these things. I've always been impressed by the quality of work that went into extending Foobar's functionality by all the community.

It's awesome that you implemented autocompletion in the panel editor itself! I suppose this is the preferred method of editing the scripts?

I like to browse various code samples in parallel with coding my own script, especially since I'm quite new at this. For now I'm using IntelliJ for that, since it helps a bit with the coloring. I don't suppose there are ways to make an IDE do code completion based on your .api files. The only reason I'm asking is because code navigation is easier with an IDE thanks to things like "go to definition" and various hover hints, etc etc.
Title: Re: JScript Panel script discussion/help
Post by: Axonn on 2017-04-05 10:20:22
Whoops. Only now after a bit more investigation I realized that all UI work done in a JSPanel has to be done using GDI calls. Basically components have to be created from scratch.

I am probably missing something here :).

I don't really understand why not to develop the component in Visual Studio then, where there is the possibility of using Win32 API to create comboboxes and such. Plus, there's a tighter integration with the rest of the Foobar ecosystem such as Columns UI.

If I'm failing to see something important, please tell me. I haven't yet started any actual coding :). Still investigating SDKs. I got some Visual Studio builds going too. I know my way around C++, although I never went in-depth with it.
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2017-04-05 10:59:43
I don't really understand why not to develop the component in Visual Studio then, where there is the possibility of using Win32 API to create comboboxes and such. Plus, there's a tighter integration with the rest of the Foobar ecosystem such as Columns UI.
That's the entire point of JScript: (kinda) user-friendly way to create 'components'. Especially useful, when you need a simple panel (e.g. a panel that displays some text, or may be a button) - creating a separate full component for every such panel is just pointless.
 
Just compare writing a JS program (with run-time compilation) in JScript windows w\o any need of external software or IDE vs writing a full component based on foobar SDK with all the dependencies, build parameters, dll's and etc, which can't be done without having a proper build environment (compiler/IDE).

But, yeah, if you want to develop a high performance component with the full usage of WinApi, then JScript is not really suitable for your needs.
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2017-04-06 21:10:23
Last.fm have updated their website to use https therefore the scripts need to be updated. Edit your text.js/thumbs.js files and replace http with https.

thumbs.js
Code: [Select]
this.xmlhttp.open("GET", "https://www.last.fm/music/" + encodeURIComponent(this.artist) + "/+images", true);

I applied the same edit to the last.fm albumart downloader script, which I just found out is not working anymore, but it doesn't solve the problem. Is there anyway to get the script back to work? Did it actually stop working in the first place or did I mess up something?
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2017-04-06 22:12:11
Last.fm have updated their website to use https therefore the scripts need to be updated. Edit your text.js/thumbs.js files and replace http with https.

thumbs.js
Code: [Select]
this.xmlhttp.open("GET", "https://www.last.fm/music/" + encodeURIComponent(this.artist) + "/+images", true);

I applied the same edit to the last.fm albumart downloader script, which I just found out is not working anymore, but it doesn't solve the problem. Is there anyway to get the script back to work? Did it actually stop working in the first place or did I mess up something?


Sorry, answering myself: yes, I did mess up something. The script had been updating the album-art.ini file even if the download didn't work and after editing the script I tested it on the same tracks. After erasing the last added lines in the ini file the script was able to download the album covers.
Title: Re: JScript Panel script discussion/help
Post by: ColdChemical on 2017-04-19 04:32:00
I'm trying to create a simple menu button but I can't figure out how to display a "pressed" image that appears while the contextmenu popup is open. The default button only has normal and hover states, and no matter what I try I can't seem to swap the normal image for the pressed one on-the-fly. Any help would be much appreciated. My code is below:

Code: [Select]
// ==PREPROCESSOR==
// @name "MainMenuManager All-In-One"
// @author "YBStone / T.P Wang / marc2003"
// @import "%fb2k_component_path%docs\flags.txt"
// @import "%fb2k_component_path%docs\helpers.txt"
// ==/PREPROCESSOR==

var tooltip = window.CreateTooltip();
// buttons is defined in docs\helpers.txt
var b = new buttons();

var mhx = false;
var pressed = false;
var img1 = "C:\\fooTest\\test01.png";
var img2 = "C:\\fooTest\\test02.png";
var img3 = "C:\\fooTest\\test03.png";
var img4 = "C:\\fooTest\\test04.png";
var img5 = "C:\\fooTest\\test05.png";
var imgN;
var imgH;
var imgP;

if(pressed == true)
    imgP = img1;
else
    imgP = img2;
 
//button is defined in docs\helpers.txt
//arguments are x, y, w, h, {normal image, hover image is optional}, function, tooltip
b.buttons.menu = new button(0, 0, 60, 60, {normal : imgP, hover: img5},function () { menu(); }, "");

function on_paint(gr) {
b.paint(gr);
}

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

function on_mouse_lbtn_up(x, y) {
    if( mhx == false ){
        b.lbtn_up(x, y);
        mhx = true;}
    else if ( mhx == true ){
        mhx = false;}
  
    if( pressed == false ){
        pressed = true;}
    else if( pressed = true ){
        pressed = false;}
}

function on_mouse_leave(x, y) {
b.leave();
    mhx = false;
}

function menu() {
var basemenu = window.CreatePopupMenu();
var contextman = fb.CreateContextMenuManager();
contextman.InitNowPlaying();

var child1 = window.CreatePopupMenu(); //File
var child2 = window.CreatePopupMenu(); //Edit
var child3 = window.CreatePopupMenu(); //View
var child4 = window.CreatePopupMenu(); //Playback
var child5 = window.CreatePopupMenu(); //Library
var child6 = window.CreatePopupMenu(); //Help
var child7 = window.CreatePopupMenu(); //Now playing
    var child8 = window.CreatePopupMenu(); //cherry test
    var child9 = window.CreatePopupMenu(); //apple test

var menuman1 = fb.CreateMainMenuManager();
var menuman2 = fb.CreateMainMenuManager();
var menuman3 = fb.CreateMainMenuManager();
var menuman4 = fb.CreateMainMenuManager();
var menuman5 = fb.CreateMainMenuManager();
var menuman6 = fb.CreateMainMenuManager();

// MF_STRING is defined in docs\flags.txt
child1.AppendTo(basemenu, MF_STRING, "File");
child2.AppendTo(basemenu, MF_STRING, "Edit");
child3.AppendTo(basemenu, MF_STRING, "View");
child4.AppendTo(basemenu, MF_STRING, "Playback");
child5.AppendTo(basemenu, MF_STRING, "Library");
child6.AppendTo(basemenu, MF_STRING, "Help");
child7.AppendTo(basemenu, MF_STRING, "Now Playing");
    basemenu.AppendMenuSeparator();
    child8.AppendTo(basemenu, MF_STRING, "CHERRY");
        child8.AppendMenuItem(MF_STRING, 7501, "cherries in my mouth [Console]");
        child8.AppendMenuItem(MF_STRING, 7502, "cherries in my hand [Open]");
    basemenu.AppendMenuItem(MF_STRING, 8000, "Preferences (Apple)");

menuman1.Init("file");
menuman2.Init("edit");
menuman3.Init("View");
menuman4.Init("playback");
menuman5.Init("library");
menuman6.Init("help");

menuman1.BuildMenu(child1, 1, 200);
menuman2.BuildMenu(child2, 201, 200);
menuman3.BuildMenu(child3, 401, 300);
menuman4.BuildMenu(child4, 601, 300);
menuman5.BuildMenu(child5, 901, 300);
menuman6.BuildMenu(child6, 1201, 100);

contextman.InitNowPlaying();
contextman.BuildMenu(child7, 1301, -100);
   
    var menuY = b.buttons.menu.h + b.buttons.menu.y + 4;
ret = basemenu.TrackPopupMenu(b.buttons.menu.x, menuY);

switch (true) {
case(ret >= 1 && ret < 201):
menuman1.ExecuteByID(ret - 1);
break;

case (ret >= 201 && ret < 401):
menuman2.ExecuteByID(ret - 201);
break;

case (ret >= 401 && ret < 601):
menuman3.ExecuteByID(ret - 401);
break;

case (ret >= 601 && ret < 901):
menuman4.ExecuteByID(ret - 601);
break;

case (ret >= 901 && ret < 1201):
menuman5.ExecuteByID(ret - 901);
break;

case (ret >= 1201 && ret < 1301):
menuman6.ExecuteByID(ret - 1201);
break;

case (ret >= 1301 && ret < 2000):     //case (ret >= 1301):
contextman.ExecuteByID(ret - 1301);
break;
       
    case (ret == 7501):
        fb.RunMainMenuCommand("View/Console");
        break;
    case (ret == 7502):
        fb.RunMainMenuCommand("File/Open...");
        break;
    case (ret == 8000):
        fb.RunMainMenuCommand("File/Preferences");
        break;
}

basemenu.Dispose();
contextman.Dispose();
menuman1.Dispose();
menuman2.Dispose();
menuman3.Dispose();
menuman4.Dispose();
menuman5.Dispose();
menuman6.Dispose();
}
Title: Re: JScript Panel script discussion/help
Post by: always.beta on 2017-04-20 12:58:17
I encountered a error about WSH Cover Panel scripts running inside the new JScript. I can't fix this error (line: 1984). Who can fix it? please. Code is too long, it is in Skins.7z.
Code: [Select]
// ==PREPROCESSOR=====================================
// @name "WSH Cover Panel"
// @version "2.0.1"
// @author "Jensen"
// @email "jensen-yg@163.com"
// ==/PREPROCESSOR====================================

//ThisPanelsName =  "WSHCoverPanel";
//===================================
// Flags, used by Menu -----------------
var MF_STRING = 0x00000000;
var MF_DISABLED = 0x00000002;
var MF_CHECKED = 0x00000008;
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2017-04-24 10:09:29
I'm trying to create a simple menu button but I can't figure out how to display a "pressed" image that appears while the contextmenu popup is open. The default button only has normal and hover states, and no matter what I try I can't seem to swap the normal image for the pressed one on-the-fly. Any help would be much appreciated.
Your code is ...uhm... to put it lightly ... it's bad. I don't even know where to start...

This code:
Code: [Select]
if(pressed == true)
    imgP = img1;
else
    imgP = img2;
Executes only once, so your imgP won't change after script initialization. But that wouldn't have worked anyway, since 'button' object has it's images initialized on creation.

Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-04-24 11:09:08
@ColdChemical, I've updated the code. You can change the images and remove the background colour I added - I just used them fr contrast.

Code: [Select]
// ==PREPROCESSOR==
// @name "MainMenuManager All-In-One"
// @author "YBStone / T.P Wang / marc2003"
// @import "%fb2k_component_path%docs\flags.txt"
// @import "%fb2k_component_path%docs\helpers.txt"
// ==/PREPROCESSOR==

var tooltip = window.CreateTooltip();
var b = new buttons();

var normal_img = fb.ComponentPath + "samples\\complete\\images\\misc\\menu white.png";
var hover_img = fb.ComponentPath + "samples\\complete\\images\\misc\\menu black.png";

b.update = function (pressed) {
    this.buttons.menu = new button(0, 0, 60, 60, {normal : pressed ? hover_img : normal_img, hover: hover_img},function () { menu(); }, "");
    window.Repaint();
}
b.update();

function on_paint(gr) {
    gr.FillSolidRect(0, 0, window.Width, window.Height, RGB(255, 0, 0));
b.paint(gr);
}

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

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

function on_mouse_leave(x, y) {
b.leave();
}

function menu() {
var basemenu = window.CreatePopupMenu();
var contextman = fb.CreateContextMenuManager();
contextman.InitNowPlaying();

var child1 = window.CreatePopupMenu(); //File
var child2 = window.CreatePopupMenu(); //Edit
var child3 = window.CreatePopupMenu(); //View
var child4 = window.CreatePopupMenu(); //Playback
var child5 = window.CreatePopupMenu(); //Library
var child6 = window.CreatePopupMenu(); //Help
var child7 = window.CreatePopupMenu(); //Now playing
    var child8 = window.CreatePopupMenu(); //cherry test
    var child9 = window.CreatePopupMenu(); //apple test

var menuman1 = fb.CreateMainMenuManager();
var menuman2 = fb.CreateMainMenuManager();
var menuman3 = fb.CreateMainMenuManager();
var menuman4 = fb.CreateMainMenuManager();
var menuman5 = fb.CreateMainMenuManager();
var menuman6 = fb.CreateMainMenuManager();

// MF_STRING is defined in docs\flags.txt
child1.AppendTo(basemenu, MF_STRING, "File");
child2.AppendTo(basemenu, MF_STRING, "Edit");
child3.AppendTo(basemenu, MF_STRING, "View");
child4.AppendTo(basemenu, MF_STRING, "Playback");
child5.AppendTo(basemenu, MF_STRING, "Library");
child6.AppendTo(basemenu, MF_STRING, "Help");
child7.AppendTo(basemenu, MF_STRING, "Now Playing");
    basemenu.AppendMenuSeparator();
    child8.AppendTo(basemenu, MF_STRING, "CHERRY");
        child8.AppendMenuItem(MF_STRING, 7501, "cherries in my mouth [Console]");
        child8.AppendMenuItem(MF_STRING, 7502, "cherries in my hand [Open]");
    basemenu.AppendMenuItem(MF_STRING, 8000, "Preferences (Apple)");

menuman1.Init("file");
menuman2.Init("edit");
menuman3.Init("View");
menuman4.Init("playback");
menuman5.Init("library");
menuman6.Init("help");

menuman1.BuildMenu(child1, 1, 200);
menuman2.BuildMenu(child2, 201, 200);
menuman3.BuildMenu(child3, 401, 300);
menuman4.BuildMenu(child4, 601, 300);
menuman5.BuildMenu(child5, 901, 300);
menuman6.BuildMenu(child6, 1201, 100);

contextman.InitNowPlaying();
contextman.BuildMenu(child7, 1301, -100);
  
    var menuY = b.buttons.menu.h + b.buttons.menu.y + 4;
   
    b.update(true);
ret = basemenu.TrackPopupMenu(b.buttons.menu.x, menuY);
    b.update();
   
switch (true) {
case(ret >= 1 && ret < 201):
menuman1.ExecuteByID(ret - 1);
break;

case (ret >= 201 && ret < 401):
menuman2.ExecuteByID(ret - 201);
break;

case (ret >= 401 && ret < 601):
menuman3.ExecuteByID(ret - 401);
break;

case (ret >= 601 && ret < 901):
menuman4.ExecuteByID(ret - 601);
break;

case (ret >= 901 && ret < 1201):
menuman5.ExecuteByID(ret - 901);
break;

case (ret >= 1201 && ret < 1301):
menuman6.ExecuteByID(ret - 1201);
break;

case (ret >= 1301 && ret < 2000):     //case (ret >= 1301):
contextman.ExecuteByID(ret - 1301);
break;
      
    case (ret == 7501):
        fb.RunMainMenuCommand("View/Console");
        break;
    case (ret == 7502):
        fb.RunMainMenuCommand("File/Open...");
        break;
    case (ret == 8000):
        fb.RunMainMenuCommand("File/Preferences");
        break;
}

basemenu.Dispose();
contextman.Dispose();
menuman1.Dispose();
menuman2.Dispose();
menuman3.Dispose();
menuman4.Dispose();
menuman5.Dispose();
menuman6.Dispose();
}

@always.beta - that script loads fine for me. Behaviour seems buggy but it doesn't crash.
Title: Re: JScript Panel script discussion/help
Post by: always.beta on 2017-04-24 14:53:13
@always.beta - that script loads fine for me. Behaviour seems buggy but it doesn't crash.
Use jscript_panel-v1.2.0.1, after a few seconds, it crashes. Please, need your help. Use WSH 1.5.6, it works. But I don't want to install two components, only jscript_panel is enough.

Code: [Select]
JScript Panel (WSH Cover Panel v2.0.1 by Jensen)
JavaScript 运行时错误:
类型不匹配
File: <main>
Line: 1984, Col: 13
<source text only available at compile time>
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-04-24 15:30:03
Top: JScript Panel v1.2.0.1 - cover disappears when I click something but doesn't crash - gif is 15 seconds...
Bottom WSH Panel Mod v1.5.6 - works fine???

(https://i.imgur.com/MWmOo1e.gif)

Title: Re: JScript Panel script discussion/help
Post by: always.beta on 2017-04-24 16:30:36
Bottom WSH Panel Mod v1.5.6 - works fine???
Sorry, do not use it for a long time, I made a mistake. WSH Panel Mod v1.5.6 needs other DLL files. WSH Panel Mod Plus works fine.
Top: JScript Panel v1.2.0.1,  gif is 53 seconds.
Bottom: WSH Panel Plus
(http://imgur.com/a/SvkS9)
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-04-24 17:21:54
edit: The proper fix is to remove the on_metadb_changed callback at line 2370...

Code: [Select]
function on_metadb_changed(metadb, fromhook) {
    MainController.Refresh(true, metadb);
}

This function never ran in WSH panel because it needs these directives set in the preprocessor section but they are missing in this script.

Code: [Select]
// @feature "v1.4"
// @feature "watch-metadb"

If you were to add them , it would crash just like JScript Panel.


Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-04-24 17:38:56
edit: I thought it was a bug in the component but it's not. Phew!
Title: Re: JScript Panel script discussion/help
Post by: always.beta on 2017-04-25 03:34:53
edit: The proper fix is to remove the on_metadb_changed callback at line 2370...
I removed  the on_metadb_changed callback at line 2370, need to manually refresh to display the picture.
(http://imgur.com/a/xmP4w)
The WSH Cover Panel script is included in the Shutter configuration, it works fine with wsh_v1.5.6 in the original configuration.
Shutter
  —— by Jensen (coding) & dReamxis (design)
>FB_Shutter_v1.1_U(Original version): based on wsh panel mod v1.5.6 & foo_ui_hacks.dll+dsound.dll+AutoItX3.dll+dynwrapx.dll
>FB_Shutter_v1.1_U+(Modified a little, may have bugs): based on wsh panel mod plus v1.5.7.4, without foo_ui_hacks.dll+dsound.dll+AutoItX3.dll+dynwrapx.dll. Replace WSH Lyric with ESLyric. Replace Albumlist with Library Tree.
>ShutterIcon: specifically designed for the shutter.
>Wsh-splitter_by_jensen(Original version): based on wsh panel mod v1.5.6 & foo_ui_hacks.dll+dsound.dll+AutoItX3.dll+dynwrapx.dll. Use Chinese to write the interface description. Looking for a good translator.
Download! (https://1drv.ms/f/s!AnFvs7Iqm0IrgdsqnuVrUBRi3tAZAQ)
Title: Re: JScript Panel script discussion/help
Post by: ColdChemical on 2017-04-25 03:54:29
Your code is ...uhm... to put it lightly ... it's bad. I don't even know where to start...
That's not at all surprising to hear haha. I'm a complete novice when it comes to jscript. Despite my attempts at dissecting marc's samples and reading through online documentation, I haven't had much luck in figuring out how to do a lot of things. If there's some resource, guide, or tutorial that might help me become more proficient I would love to know about it. I'm not sure how much, if at all, this component's implementation of jscript differs from more typical environments.

@ColdChemical, I've updated the code. You can change the images and remove the background colour I added - I just used them fr contrast.
Thank you for the help, though what I'm really after is a third button state in addition to normal and hover. Ideally I'd like to have this third button-state image appear whenever the context popup menu is open (similar to the way the Windows start menu button behaves). If there's no way for the jscript panel to "know" when the popup disappears, then I suppose this wouldn't be possible.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-04-25 06:24:27
The WSH Cover Panel script is included in the Shutter configuration, it works fine with wsh_v1.5.6 in the original configuration.

I explained why it worked.

edit: changing my reason!!  :))

It's because on_metadb_changed function always get passed a handle list by JScript Panel. WSH panel mod and variants would do the same IF they had the preprocessors added that I mentioned. The function inside expects a handle, not a handle list and that's why it doesn't work. You can restore the function but modify it slightly...

Code: [Select]
function on_metadb_changed() {
    MainController.Refresh(true); //this function still works if you omit it
}

@ColdChemical - not really possible. Button constructors with a down state typically only support a down image while you hold the mouse key down until you release it again. With a menu, you release the button immediately after pressing and the menu stays open until you click something again. There is no clever way of doing this other than the hack I already posted.

Title: Re: JScript Panel script discussion/help
Post by: Coreda on 2017-04-25 11:22:41
I could probably script something to do it but the track changes may not be entirely seamless. I'll test and report back.

edit: I tried it and it was fine for me but YMMV.

Requires WSH panel mod or JScript panel. You can find the latter via the link in my signature.

Code: [Select]
var t = tracks_to_skip();

function on_playback_new_track() {
var handle = fb.GetNowPlaying();
if (!handle)
return;
var p = handle.Path.toLowerCase();
for (var i = 0; i < t.length; i++) {
if (t[i] == p)
return fb.Next();
}
}

function tracks_to_skip() {
var a = [];
for (var i = 0; i < plman.PlaylistCount; i++) {
if (playlist_name_is_skip(i)) {
var items = plman.GetPlaylistItems(i);
for (var j = 0; j < items.Count; j++) {
a.push(items.Item(j).Path.toLowerCase());
}
}
}
return a;
}

function playlist_name_is_skip(idx) {
return plman.GetPlaylistName(idx).toLowerCase() == "skip";
}

function on_playlist_items_added(p) {
if (playlist_name_is_skip(p))
t = tracks_to_skip();
}

function on_playlist_items_removed(p) {
if (playlist_name_is_skip(p))
t = tracks_to_skip();
}

So this has worked great all this time but I've come across an issue with a track named similarly to another. I have an album where I've split the last track into two tracks since the second half is basically a spoken word segment. I'm wanting to skip the second split track but it continues to be played automatically.

The original title tag is named Mortal Man. The title tags of the split are named Mortal Man [part 1] and Mortal Man [part 2], and the original, unedited track from which these were split from has been hidden in File Explorer so it doesn't appear in fb2k. Apart from that title tag change the only other differences between the tracks are the track numbers (I increased the track number counter by one for the second split), and the filenames (which have been updated with the track number and title tag changes). The Total Tracks tags of all tracks remain the same.

Any idea why the second split track is being played and not skipped, despite appearing in the Skip playlist?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-04-25 13:49:38
Tags are irrelevant. The script only checks the full file path.
Title: Re: JScript Panel script discussion/help
Post by: Coreda on 2017-04-25 15:39:06
Tags are irrelevant. The script only checks the full file path.

Have any thoughts on why the second split track wouldn't be detected in that case, given it has a different filename?

The split tracks appear as the following (artist and album removed here for brevity, though there's no Unicode in the path fwiw):

16 - Mortal Man [part 1].flac
17 - Mortal Man [part 2].flac <- track I'd like to skip

Tested and found the [part 1] track is correctly skipped, just not the second part of the split track.

Update: found that removing the track from the Skip playlist then re-adding it by dragging it into the playlist again fixed the issue. Strange but at least I know what to try next time.
Title: Re: JScript Panel script discussion/help
Post by: always.beta on 2017-04-25 17:44:18
You can restore the function but modify it slightly...
On play a new track, still can not automatically refresh the cover, need to manually refresh or about 20 seconds automatically display the cover of the new track. I might not understand what you say, just copy and paste, thanks for the Guide, I will continue to use the old version.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-04-25 18:23:50
Strange but at least I know what to try next time.

Well I can't really explain that. I added timers and found it can parse 2000 tracks in 0.007 seconds so the chances of you manually doing something quicker than it can catch up seems unlikely. However, I did find removing the playlist named skip didn't update the list of items to skip so you should add this to the end of the script...

Code: [Select]
function on_playlists_changed() {
    t = tracks_to_skip();
}

edit: I've updated it so it takes subsong in to account should you have any cuesheets or tracks with multiple chapters. The old script would skip all tracks sharing the same path. I guess all your tracks are single otherwise you would have complained but it's something I should have added originally. It also spams the console with how long it takes to parse the items..

Code: [Select]
var t = tracks_to_skip();

function on_playback_new_track() {
var handle = fb.GetNowPlaying();
if (!handle)
return;
var p = handle.Path.toLowerCase() + "|" + handle.Subsong;
for (var i = 0; i < t.length; i++) {
if (t[i] == p)
return fb.Next();
}
}

function tracks_to_skip() {
var a = [];
for (var i = 0; i < plman.PlaylistCount; i++) {
if (playlist_name_is_skip(i)) {
var b = new Date().getTime();
var items = plman.GetPlaylistItems(i);
for (var j = 0; j < items.Count; j++) {
a.push(items.Item(j).Path.toLowerCase() + "|" + items.Item(j).Subsong);
}
items.Dispose();
var c = new Date().getTime();
fb.trace("Found a playlist named skip - parsing " + a.length + " items took " + ((c - b) / 1000) + " seconds.");
}
}
return a;
}

function playlist_name_is_skip(idx) {
return plman.GetPlaylistName(idx).toLowerCase() == "skip";
}

function on_playlist_items_added(p) {
if (playlist_name_is_skip(p))
t = tracks_to_skip();
}

function on_playlist_items_removed(p) {
if (playlist_name_is_skip(p))
t = tracks_to_skip();
}

function on_playlists_changed() {
t = tracks_to_skip();
}

another edit: I suppose there is a possibility of a track being missed (not skipped) if you send a track to a new playlist and it begins playback immediately. I guess that could happen while the list is being updated. A workaround would be to be to update the list every time a new track begins but that seems a bit overkill for most cases.



Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-04-25 18:51:55
On play a new track

The code inside both components is identical for on_playback_new_track.
Title: Re: JScript Panel script discussion/help
Post by: Coreda on 2017-04-25 19:14:50
.

Thanks for looking into it. Updated the script and bookmarked for future reference :)
Title: Re: JScript Panel script discussion/help
Post by: always.beta on 2017-04-26 07:50:57
The code inside both components is identical for on_playback_new_track.
Embarrassed,  :-[ ,forgive my poor English. I mean, after modify the code as you said, when I play a new track, still can not automatically refresh the cover, need to manually refresh or about 20 seconds automatically display the cover of the new track.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-04-26 08:31:03
My previous post wasn't any kind of explanation for why it doesn't work for you. It was a simple statement of fact saying that the component works in exactly the same way when a new track begins.

Also, it works fine for me.... this gif is quite large though (12MB)..

http://imgur.com/Ut0bYbt
Title: Re: JScript Panel script discussion/help
Post by: always.beta on 2017-04-26 17:35:37
Also, it works fine for me...
My cover panel still can't be displayed immediately. In jscript_panel, on_metadb_changed and on_selection_changed return metadb values are not normal.
https://1drv.ms/i/s!AnFvs7Iqm0IrgdwWZLaNe1H7bYrMnA
Another question, can you fix the JSSP to allow it to support the 'Prefences>Display>Selection viewers'?
Title: Re: JScript Panel script discussion/help
Post by: Black_Over_Bills_Mothers on 2017-04-28 13:51:47
I need a little help with a script problem I have. How can I modify the replay gain data for a track from within a script?

Thanks in advance for your time.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-04-28 20:49:54
@always.beta, read...

https://github.com/19379/foo-jscript-panel/blob/master/CHANGELOG.md#v121

and

https://github.com/19379/foo-jscript-panel/blob/b2c6698b544958741abf9ea0cf5cac000c33ae4a/component/docs/Callbacks.txt#L146L147

@Black_Over_Bills_Mothers, you can't.
Title: Re: JScript Panel script discussion/help
Post by: Black_Over_Bills_Mothers on 2017-04-30 09:48:27
@marc2003. Thanks for your quick answer. At least I didn't waste too much time trying to find a way to modify the ReplayGain data!

I have another problem.  I've recently downloaded some tracks with their Read-only flag set. This obviosly causes several file update functions to fail. Is there a way to, ideally remove the read-only flag, or at least detect it with utils.FileTest (possible additional mode)?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-04-30 10:51:09
You can use the WshShell ActiveX object to run external commands.

edit: using fso as below is better
Title: Re: JScript Panel script discussion/help
Post by: Black_Over_Bills_Mothers on 2017-04-30 11:17:08
Thanks marc2003.

I've just this minute got a solution working with a file system object. Seems to work fine.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-04-30 11:34:21
Ah yes, using fso is much better.  8)
Title: Re: JScript Panel script discussion/help
Post by: alekksander on 2017-04-30 14:23:38
Last.fm have updated their website to use https therefore the scripts need to be updated. Edit your text.js/thumbs.js files and replace http with https.

text.js
Code: [Select]
var url = "https://" + this.bio_lastfm_sites[this.bio_lastfm_site] + "/music/" + encodeURIComponent(this.artist) + "/+wiki";

thumbs.js
Code: [Select]
this.xmlhttp.open("GET", "https://www.last.fm/music/" + encodeURIComponent(this.artist) + "/+images", true);

latest version here. there are no such lines in these files. can't get biography to work anymore, due to „Last.fm Bio: HTTP error: 0”. any help?

reminder
edit with solution for idiots like me:

these files are located at *user_name*\AppData\Roaming\foobar2000\js_marc2003\js if installed version is standalone (not portable)
Title: Re: JScript Panel script discussion/help
Post by: always.beta on 2017-05-01 14:47:29
I gave up WSH Cover Panel, switch to 'complete\album art.txt'.
Could you consider making these changes? change the (\complete\album art.txt)'s right menu Google image search to two level menu? Like:WSH Cover Panel, the search source is defined in a separate text. Easy to modify the search source and do not affect the search source when the main code updates. the right menu can be added to some attached pictures menu?
Title: Re: JScript Panel script discussion/help
Post by: Viewmax on 2017-05-17 11:38:41
Help please. Is it possible to have two buttons on toolbar "set volume to -10db" and "set volume to -30db" with this component?

Thank you!
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-05-17 12:33:36
Well you can't add toolbars in default UI but here's a custom panel with 2 buttons...

Code: [Select]
// ==PREPROCESSOR==
// @name "SimpleThemedButton"
// @author "T.P Wang"
// @import "%fb2k_component_path%docs\flags.txt"
// @import "%fb2k_component_path%docs\helpers.txt"
// ==/PREPROCESSOR==

var cur_btn = null;
var g_down = false;
var g_theme = window.CreateThemeManager("Button");
var g_font = gdi.Font("Segoe UI", 12);
var ButtonStates = {
normal: 0,
hover: 1,
down: 2,
hide: 3
}

var buttons = {
v30: new SimpleButton(10, 10, 80, 26, "-30 dB", function () {
fb.Volume = -30;
}),
v10: new SimpleButton(100, 10, 80, 26, "-10 dB", function () {
fb.Volume = -10
})
}

function SimpleButton(x, y, w, h, text, fonClick, state) {
this.state = state ? state : ButtonStates.normal;
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.text = text;
this.fonClick = fonClick;

this.containXY = function (x, y) {
return (this.x <= x) && (x <= this.x + this.w) && (this.y <= y) && (y <= this.y + this.h);
}

this.changeState = function (state) {
var old = this.state;
this.state = state;
return old;
}

this.draw = function (gr) {
if (this.state == ButtonStates.hide) return;

switch (this.state)
{
case ButtonStates.normal:
g_theme.SetPartAndStateId(1, 1);
break;

case ButtonStates.hover:
g_theme.SetPartAndStateId(1, 2);
break;

case ButtonStates.down:
g_theme.SetPartAndStateId(1, 3);
break;

case ButtonStates.hide:
return;
}

g_theme.DrawThemeBackground(gr, this.x, this.y, this.w, this.h);
// RGB function is defined in docs\helpers.txt
// DT_* are defined in docs\flags.txt
gr.GdiDrawText(this.text, g_font, RGB(0,0,0), this.x, this.y, this.w, this.h, DT_CENTER| DT_VCENTER | DT_CALCRECT | DT_NOPREFIX);
}

this.onClick = function () {
this.fonClick && this.fonClick();
}
}

function drawAllButtons(gr) {
for (var i in buttons) {
buttons[i].draw(gr);
}
}

function chooseButton(x, y) {
for (var i in buttons) {
if (buttons[i].containXY(x, y) && buttons[i].state != ButtonStates.hide) return buttons[i];
}

return null;
}

function on_paint(gr) {
gr.FillSolidRect(0, 0, window.Width, window.Height, utils.GetSysColor(15));
drawAllButtons(gr);
}

function on_mouse_move(x, y) {
var old = cur_btn;
cur_btn = chooseButton(x, y);

if (old == cur_btn) {
if (g_down) return;
} else if (g_down && cur_btn && cur_btn.state != ButtonStates.down) {
cur_btn.changeState(ButtonStates.down);
window.Repaint();
return;
}

old && old.changeState(ButtonStates.normal);
cur_btn && cur_btn.changeState(ButtonStates.hover);
window.Repaint();
}

function on_mouse_leave() {
g_down = false;

if (cur_btn) {
cur_btn.changeState(ButtonStates.normal);
window.Repaint();
}
}

function on_mouse_lbtn_down(x, y) {
g_down = true;

if (cur_btn) {
cur_btn.changeState(ButtonStates.down);
window.Repaint();
}
}

function on_mouse_lbtn_up(x, y) {
g_down = false;

if (cur_btn) {
cur_btn.onClick();
cur_btn.changeState(ButtonStates.hover);
window.Repaint();
}
}
Title: Re: JScript Panel script discussion/help
Post by: Viewmax on 2017-05-17 12:48:42
OMG! Huge props! I can't PM you :( Could you send me your Paypal? You should have donation button!
Title: Re: JScript Panel script discussion/help
Post by: Viewmax on 2017-05-17 13:11:31
One more question, is it possible to assign a hotkeys to these custom buttons?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-05-17 16:26:12
Not really. The component can accept keyboard input but only when the panel has focus. Click anywhere else on the foobar UI or any other program and the panel loses focus meaning keyboard shortcuts no longer work.

I have an idea of how to make it possible but it's highly convoluted and I'm not really sure if it's worth the effort.
Title: Re: JScript Panel script discussion/help
Post by: Viewmax on 2017-05-18 05:25:06
Not really. The component can accept keyboard input but only when the panel has focus. Click anywhere else on the foobar UI or any other program and the panel loses focus meaning keyboard shortcuts no longer work.
I have an idea of how to make it possible but it's highly convoluted and I'm not really sure if it's worth the effort.
It's not worth, you're right. Thank you one more time for your answers and customized buttons!
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-05-18 07:21:48
It's now possible with the latest component version released just now. Here's the code snippet to go in your panel..

Code: [Select]
function on_main_menu(index) {
switch (index) {
case 1: // triggered when File>JScript Panel>1 is run
fb.Volume = -30;
break;
case 2: // triggered when File>JScript Panel>2 is run
fb.Volume = -10;
break;
}
}

You then have to bind commands 1 & 2 under File>JScript Panel to your keyboard shortcuts in the main preferences...

(https://i.imgur.com/c6XqsBp.png)
Title: Re: JScript Panel script discussion/help
Post by: Viewmax on 2017-05-19 17:14:26
It's just a brilliant! Working absolutely fantastically!
Title: Re: JScript Panel script discussion/help
Post by: Black_Over_Bills_Mothers on 2017-05-20 12:33:53
jsplaylist-mod. Change requests:

I'm not sure who is now maintaining this script but I've just started using it as an alternative to ELPlaylist and it seems a lot quicker.

There are a few things I miss though:
1) Focus the display on a particular playlist
2) Don't show the extra line for each track if none of the columns are displaying anything in it ie all set to null
3) Don't collapse the list if the number of groups is less than a configurable number

Thanks to anyone prepared to implement these.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-05-20 21:47:30
I don't understand the code well enough to make those sorts of changes. I can fix things I break with my component updates but that's about it.
Title: Re: JScript Panel script discussion/help
Post by: MachineHead on 2017-05-21 14:10:07
@marc2003

Is it possible for the switcher script to use one single button to cycle through scripts or does it have to be one per script?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-05-21 19:45:15
It's just this function that does the important bit...

Code: [Select]
window.NotifyOthers(name, info);

How you determine the name and info is entirely up to you.
Title: Re: JScript Panel script discussion/help
Post by: Lucidae on 2017-06-06 01:01:17
Long time lurker, first time poster - I just wanted to thank marc2003 for developing and maintaining this incredibly useful plugin.

I was playing around with the album art jscript panel and I noticed the picture is cropped around the sides compared to the default UI album art panel. Is there anything I can do to adjust this setting?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-06-07 08:37:18
I've tweaked it so the "Centre" and "Stretch" options no longer get trimmed. The "Crop" and "Crop Top" still get trimmed but by a lesser amount. Save this inside your foobar2000 profile\user-components\foo_jscript_panel\samples\complete\js (overwrite the existing helpers.js)

https://raw.githubusercontent.com/19379/foo-jscript-panel/master/component/samples/complete/js/helpers.js
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2017-06-24 21:35:27
You can use GetColorScheme like this...

Code: [Select]
var img = utils.GetAlbumArtV2(fb.GetFocusItem(), 0);
if (img) {
    var arr = img.GetColorScheme(1).toArray();
    var col = arr[0];
}

You can increase the number 1 to get more colours. The first is the most dominant and so on...

I'm trying to use this GetColorScheme function, but it gives me a 10-digit number. How do I convert it to RGB values?
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2017-06-24 22:14:10
You can use GetColorScheme like this...

Code: [Select]
var img = utils.GetAlbumArtV2(fb.GetFocusItem(), 0);
if (img) {
    var arr = img.GetColorScheme(1).toArray();
    var col = arr[0];
}

You can increase the number 1 to get more colours. The first is the most dominant and so on...

I'm trying to use this GetColorScheme function, but it gives me a 10-digit number. How do I convert it to RGB values?


Alright, I managed with Falstaff's GetColorSchemFromImage function.
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2017-06-25 20:25:03
Is it possible to get windows 10 accent color with jscript?
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2017-07-03 21:34:19
Is it possible to get windows 10 accent color with jscript?

Eventually I found out the custom windows accent color is stored in the ColorizationColor registry key in HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\DWM, therefore I managed to get it with the RegRead method.
I can't find a registry key for the taskbar color, though, so I guess it must be a darker shade of the accent color. Is there a formula to get the taskbar color from the accent color?
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2017-07-04 15:42:31
Is it possible to get windows 10 accent color with jscript?

Eventually I found out the custom windows accent color is stored in the ColorizationColor registry key in HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\DWM, therefore I managed to get it with the RegRead method.
I can't find a registry key for the taskbar color, though, so I guess it must be a darker shade of the accent color. Is there a formula to get the taskbar color from the accent color?


For those who are interested, I found out all shades and tints of the accent color are stored in the registry key AccentPalette in HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent. The taskbar color is the 6th in the list when the transparency option is off and the 7th when it is on. Unfortunately the RegRead method does not seem to work with this registry key and I have no idea how to get its value. Any help would be appreciated.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-07-04 16:10:55
If you look at the type of the value in regedit, it's REG_BINARY and if you look at the documentation for it here...

https://msdn.microsoft.com/en-gb/library/x05fawxd(v=vs.84).aspx

... it says it's a VBarray. Therefore you can try using toArray() on the result..

Code: [Select]
var something = WshShell.RegRead("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Accent\\AccentPalette").toArray();

edit: Since I'm feeling nice, I found out how...

Code: [Select]
function RGB(r, g, b) {
    return 0xFF000000 | r << 16 | g << 8 | b;
}

var WshShell = new ActiveXObject("WScript.Shell");
var colours = WshShell.RegRead("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Accent\\AccentPalette").toArray();
var colour = RGB(colours[20], colours[21], colours[22]);

function on_paint(gr) {
    gr.FillSolidRect(0, 0, window.Width, window.Height, colour);
}
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2017-07-04 18:51:18
edit: Since I'm feeling nice, I found out how...

Thanks, it worked! Glad you're feeling nice  :)
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2017-07-10 18:01:52
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.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-07-10 19:48:57
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"));
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2017-07-12 19:51:42
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.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-07-13 07:05:37
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 (https://en.wikipedia.org/wiki/Minification_(programming)) 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

Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2017-07-22 11:59:18
Is there a way to identify a playlist regardless of the index or playlist name?
Title: Re: JScript Panel script discussion/help
Post by: Takaji on 2017-07-26 18:58:42
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.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-07-27 08:00:18
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.
Title: Re: JScript Panel script discussion/help
Post by: kode54 on 2017-07-27 21:40:12
Is it DPI aware? That may be the issue they're experiencing.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-07-27 22:44:22
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.

(https://i.imgur.com/nGhiGBq.jpg)
Title: Re: JScript Panel script discussion/help
Post by: kode54 on 2017-07-28 00:11:29
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.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-07-28 12:59:46
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.
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2017-07-28 19:56:57
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?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-07-28 21:48:15
docs\Notes & hints
https://github.com/19379/foo-jscript-panel/blob/master/foo_jscript_panel/docs/Notes%20%26%20Hints.txt#L8L9

and nope!
Title: Re: JScript Panel script discussion/help
Post by: garbanzo.bean on 2017-08-01 04:16:23
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!
Title: Re: JScript Panel script discussion/help
Post by: jazzthieve on 2017-08-02 19:09:34
@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?
Title: Re: JScript Panel script discussion/help
Post by: MojoBass on 2017-08-03 04:39:35
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.
Title: Re: JScript Panel script discussion/help
Post by: Black_Over_Bills_Mothers on 2017-08-03 11:40:35
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.
Title: Re: JScript Panel script discussion/help
Post by: Takaji on 2017-08-20 17:46:37
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.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-08-20 23:29:37
My own samples in the complete folder are now DPI aware for text/tooltips etc.

https://github.com/19379/foo-jscript-panel/releases
Title: Re: JScript Panel script discussion/help
Post by: zeremy on 2017-08-22 07:04:12
@marc2003

Typo at line 15 with foo-jscript-panel/foo_jscript_panel/samples/complete/musicbrainz.txt.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-08-22 07:23:11
Argh, thanks for spotting.

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

Code: [Select]
var panel = new _.panel('Musicbrainz', ['metadb']);
Title: Re: JScript Panel script discussion/help
Post by: mph64 on 2017-08-24 22:34:06
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
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-08-24 23:35:08
Calling @TheQwertiest - their modified component might be able to do this, mine can't.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-08-25 12:12:19
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. :/
Title: Re: JScript Panel script discussion/help
Post by: Daeron on 2017-08-30 06:47:30
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?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-08-30 10:03:34
Directly after

Code: [Select]
var panel = new _.panel('Last.fm Similar Artists / User Charts', ['metadb']);

insert

Code: [Select]
panel.fonts.normal = _.gdiFont("font name", 12, 0); // 12 size, 0 style
panel.row_height = panel.fonts.normal.Height;

Note that changes to font settings made in the main UI preferences will override this so you'd need to reload the panel.

As for the library referencing thing, possible but could bog down running 100 queries at once??? It has no effect on me because my collection is so small but could be an issue for others. You'll need to edit samples\complete\js\list.js

On line 424, you should find this...

Code: [Select]
						this.data = _(_.get(_.jsonParse(_.open(this.filename)), 'similarartists.artist', []))
.map(function (item) {
return {
name : item.name,
width : _.textWidth(item.name, panel.fonts.normal),
url : this.lastfm_link == 0 ? item.url : 'artist HAS ' + item.name
};
}, this)
.value();

try this instead...

Code: [Select]
						this.data = _(_.get(_.jsonParse(_.open(this.filename)), 'similarartists.artist', []))
.filter(function (item) {
return fb.GetQueryItems(fb.GetLibraryItems(), 'artist IS ' + item.name).Count == 0;
})
.map(function (item) {
return {
name : item.name,
width : _.textWidth(item.name, panel.fonts.normal),
url : this.lastfm_link == 0 ? item.url : 'artist HAS ' + item.name
};
}, this)
.value();

If editing while foobar is open, make sure to reload panel to pick up changes. Also, future component updates will overwrite this file so make notes or move the edited file elsewhere and edit the preprocessor import path for list.js in the Configuration window.
Title: Re: JScript Panel script discussion/help
Post by: Daeron on 2017-08-30 11:07:29
Thanks for the help.

Indeed the query freezes foobar for 1-3 seconds, not too severe, but not optimal either, Probably could be improved by some sort of caching or limiting the last.fm query to a smaller number (and maybe occasionally firing it twice if there aren't enough artist left after the cross reference). But for what I wanted should be good enough.

Changing the font also works. Just for reference in case someone else tries using it too, theres a typo at your second line in your second codebox, 'pane.row_height' should be 'panel.row_height'.

Also one more question, is JScript capable of writing tags? Seems like multiple people are using a convoluted method to retrieve similar artists from last.fm and then later copy its values to a multivalue tag. So I was wondering if one could automatize this with JScript alone. foo_uie_biography can do something similar (makes said data available as a tag for the currently playing song), but stuff like $meta(tag,0) don't work on the provided tag so it's not that useful. I don't really expect a code for this, I'm just curious if it's doable at all.

Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-08-30 11:22:35
Edit .take(20) on line 2...

Code: [Select]
						this.data = _(_.get(_.jsonParse(_.open(this.filename)), 'similarartists.artist', []))
.take(20)
.filter(function (item) {
return fb.GetQueryItems(fb.GetLibraryItems(), 'artist IS ' + item.name).Count == 0;
})
.map(function (item) {
return {
name : item.name,
width : _.textWidth(item.name, panel.fonts.normal),
url : this.lastfm_link == 0 ? item.url : 'artist HAS ' + item.name
};
}, this)
.value();

And yes, you can edit tags with JScript Panel. If you wanted to, you could even update every single file in the library that has the same artist as the current track because obviously the similar artists would be the same. Also, it writes multi-value tags properly.

I'll post a quick and dirty example later.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-08-31 08:52:21
This will update all library files with the same artist (determined using $meta(artist,0) ) as the current track with the first 5 similar artists when you double click the panel. A blank area would be better than clicking on the text! Check the tag_name variable if you want to edit it...

Code: [Select]
function on_mouse_lbtn_dblclk() {
if (list.lastfm_mode != 0 || list.items == 0)
return;
var tags = _(list.data)
.take(5)
.map('name')
.value()
.join(';');
var tag_name = 'similar artists';
var items_to_tag = fb.GetQueryItems(fb.GetLibraryItems(), 'NOT "$ext(%path%)" IS cue AND "$meta(artist,0)" IS ' + list.artist);
if (WshShell.popup('About to update tags in ' + items_to_tag.Count + ' file(s). Continue?', 0, panel.name, popup.question + popup.yes_no) == popup.yes)
items_to_tag.UpdateFileInfoSimple(tag_name, tags, tag_name);
}

It will count the files and prompt you first. If you want it to happen automatically without the prompt, remove this line...

Code: [Select]
	if (WshShell.popup('About to update tags in ' + items_to_tag.Count + ' file(s). Continue?', 0, panel.name, popup.question + popup.yes_no) == popup.yes)

If you really want to do one track at a time...

Code: [Select]
function on_mouse_lbtn_dblclk() {
if (list.lastfm_mode != 0 || list.items == 0)
return;
var tags = _(list.data)
.take(5)
.map('name')
.value()
.join(';');
var tag_name = 'similar artists';
panel.metadb.UpdateFileInfoSimple(tag_name, tags, tag_name);
}
Title: Re: JScript Panel script discussion/help
Post by: Daeron on 2017-08-31 11:18:37
Seems to be working well.

I took the liberty to also hook up on_playback_new_track() or on_playback_starting() with your last script. However both seems to only trigger the tag writing process after you switch away from the track in question (so it basically always updates the previous track when playback has started on a new one).  Is there one that triggers right away or am I doing something fundamentally wrong?

(The goal with this one is to update the currently playing track automatically, similarly how foo_uie_biography works. With the modified list.js that only shows similar artists not yet in library I feel this might better in terms of always showing up to date info. Compared to one batch operation of every file, which would probably work better with the regular lists.js getting all similar artists that should be fairly consistent over time. It's possible there will also be a conflict between the component waveform seekbar which seems to "lock" the files while it's scanning them the first time, we'll see. That can probably be solved by delaying the writing process a couple seconds.)

Code: [Select]
function on_playback_new_track() {
    if (list.lastfm_mode != 0 || list.items == 0)
return;
var tags = _(list.data)
.take(5)
.map('name')
.value()
.join(';');
var tag_name = 'similar artists';
panel.metadb.UpdateFileInfoSimple(tag_name, tags, tag_name);
}
Title: Re: JScript Panel script discussion/help
Post by: garbanzo.bean on 2017-08-31 16:05:18
Can someone please help be with a button to launch the VMDGB webpage for an album based on the tag %vmgdb%

Code: [Select]
http://vgmdb.net/album/%vmgdb%

I would like the button to use a PNG graphic. It would be awesome if the graphic could change if the %vmgdb% tag is empty (I would use a grayed-out version of the button image so it looks disabled).

If anyone has code for a similar button (for loading a URL using a tag value), I can adapt it to fit my needs. I just didn't find anything in the Samples folder.

Thanks :)
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-08-31 22:44:09
or am I doing something fundamentally wrong?

Yes. you've overwritten an already existing on_playback_new_track function in panel.js and completely broken the script's ability to update when a new track starts. If any duplicate functions exist in javascript, the last always takes precedence so you need to include code from the old function. Also, a timer is required to make it work properly because it can take a second or 2 for the web request to complete on new tracks or updating when the cached data is over a day old. I've allowed 5 seconds. You can place this inside the Configuration window...

Code: [Select]
function on_playback_new_track() {
panel.item_focus_change(); //required code from old function
if (list.timer)
window.ClearTimeout(list.timer);
list.timer = window.SetTimeout(function () {
if (list.lastfm_mode != 0 || list.items == 0)
return;
var tags = _(list.data)
.take(5)
.map('name')
.value()
.join(';');
var tag_name = 'similar artists';
try {
panel.metadb.UpdateFileInfoSimple(tag_name, tags, tag_name);
} catch (e) {}
}, 5000);
}

Mr Bean...
Code: [Select]
// ==PREPROCESSOR==
// @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"
// ==/PREPROCESSOR==

var panel = new _.panel('Button', ['metadb', 'custom_background']);
var buttons = new _.buttons();
var off = fb.ProfilePath + "my_images\\off.png"; // edit the folder/image names as needed
var on = fb.ProfilePath + "my_images\\on.ong";

function on_size() {
panel.size();
}

function on_metadb_changed() {
if (panel.metadb) {
var vmgdb = panel.tf("[%vmgdb%]");
//firt 4 values are x,y,w,h
buttons.buttons.vmgdb = new _.button(0, 0, 20, 20, { normal : vmgdb.length ? on : off }, function () {
if (!vmgdb.length)
return; // do nothing if tag is empty
_.run('http://vgmdb.net/album/' + vmgdb);
}, 'VMGDB');
} else {
buttons.buttons = {}
}
window.Repaint();
}

function on_paint(gr) {
panel.paint(gr);
buttons.paint(gr);
}

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

function on_mouse_leave() {
buttons.leave();
}

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

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


Title: Re: JScript Panel script discussion/help
Post by: garbanzo.bean on 2017-09-01 00:00:21
Woot! Thanks mark2003.

Sadly, I get an error:

Quote from: JScript Panel
JScript Panel ({FA8128A9-B8F6-4599-AD1F-C6E6D5BBEF0C})
JavaScript runtime error:
'panel' is undefined
File: <main>
Line: 17, Col: 2
<source text only available at compile time>
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-09-01 00:06:42
It looks like you installed the dll only without the required files contained within the archive. I do give this link on the installation page for a reason...

http://wiki.hydrogenaud.io/index.php?title=Foobar2000:How_to_install_a_component

edit: or you could be using a pretty old version that didn't come with samples. Use the Help menu>Check for updated components.
Title: Re: JScript Panel script discussion/help
Post by: garbanzo.bean on 2017-09-01 00:16:37
Hmm, I didn't use the install, but I did copy all the files from the archive, not just the dll.

I deleted it and used the install, it's working now. Thanks again :)
Title: Re: JScript Panel script discussion/help
Post by: OoNebsoO on 2017-09-01 17:18:02
@marc2003 , quick question about Musicbrainz script. Is is possible for it to check the currently selected artist, and compare album names in our library with musicbrainz info, for releases we already have in our library. And use different font colour, or style, or basically any kind of formatting, for those releases? Extra text, like "in library", next to it, or simple check mark, would work too.

Guessing, but tagging our library with musicbrainz album ID would help there?

Also, left click now gets us to release-group of the album, could it be edited (or small search button added next to releases) that it uses outside pages like google, itunes, spotify, whatever site really, for album search? Links option via right click gives us artist related pages.

Title: Re: JScript Panel script discussion/help
Post by: Daeron on 2017-09-02 01:19:36
I see marc2003, thanks for the help.
Title: Re: JScript Panel script discussion/help
Post by: Daeron on 2017-09-03 05:41:11
It appears that this edit (https://hydrogenaud.io/index.php/topic,110516.msg944334.html#msg944334) results in a crash in the similar artist panel if %artist% is Hidekuni Horita. As long as a letter is changed everything is fine and other metadata doesn't seem to contribute. It also works fine with the unedited list.js. Not really sure why.

Code: [Select]
JScript Panel (Last.fm Similar Artists / User Charts by marc2003)
JavaScript runtime error:

File: foobar2000\user-components\foo_jscript_panel\samples\complete\js\list.js
Line: 427, Col: 9
<source text only available at compile time>

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']);

panel.fonts.normal = _.gdiFont("Segoe UI", 8, 0); // 12 size, 0 style
panel.row_height = panel.fonts.normal.Height;

var lastfm = new _.lastfm();
var list = new _.list('lastfm_info', LM, TM-36, 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+60;
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);
}

function on_mouse_lbtn_dblclk() {
if (list.lastfm_mode != 0 || list.items == 0)
return;
var tags = _(list.data)
.take(5)
.map('name')
.value()
.join(';');
var tag_name = 'similar artists';
panel.metadb.UpdateFileInfoSimple(tag_name, tags, tag_name);
}
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2017-09-04 17:17:09
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");
Calling @TheQwertiest - their modified component might be able to do this, mine can't.

TLDR: Regretfully, there is no easy way to do that, even with WSH methods. There is a messy solution though:
Spoiler (click to show/hide)

Full story: it seems, that foobar2000 creates Console and Preferences windows as separate entities, i.e. they do not have parent-child relationship with foobar2000. Thus, the only way to get those windows is via searching all top level windows, with specific caption and class, since there might be a collision in Caption with other windows.

If there was a proper parent-child relationship, we could get away with Caption only, since there is not a lot of windows in foobar2000 itself.

@marc2003 : Can I post a link to my version of jscript here? Or should I share it only privately (i.e. PM, e-mail, etc)?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-09-04 18:49:24
@OoNebsoO, right click panel>links should give itunes/spotify links for most established artists. You could always contribute to musicbrainz if you find they are missing. I'm not querying the library for releases for performance reasons and I'm not really inclined to add any other options at the moment.

@Daeron , shame I didn't read my own docs when implementing that edit. I know that function can throw errors with invalid queries and I forgot to handle it properly.

Code: [Select]
							.filter(function (item) {
try {
return fb.GetQueryItems(fb.GetLibraryItems(), 'artist IS "' + item.name + '"').Count == 0;
} catch (e) {
return true;
}
})

@TheQwertiest, you can post a link to your component, no problem.

However, I don't think it will work for preferences because the caption changes every time you select a different item in the tree. Also (foobar2000.exe) is only provided by that  banned component we can't really name. And that changes to what ever component provides the option you have selected.
Title: Re: JScript Panel script discussion/help
Post by: Daeron on 2017-09-05 06:54:53
Thanks for the fix marc2003.
Title: Re: JScript Panel script discussion/help
Post by: WilB on 2017-09-05 11:55:31
Is it possible to write more than one proper multivalue tag in one go  & if so what's the syntax?

The following didn't seem to work:

Code: [Select]
handle.UpdateFileInfoSimple("GENRE1", "Downtempo;Ambient", "GENRE1","GENRE2", "Rock;Classic Rock", "GENRE2");
Other variances I tried either only wrote one tag else only one was correctly written as a multivalue tag.

I actually want to write 5 multivalue tags at a time. UpdateFileInfoSimple can be run separately for each, but that then seems to rewrite the file 5 times, and so isn't ideal for many files.

Any help would be appreciated.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-09-05 12:09:13
I thought the existing docs were clear enough... ?? :P

Code: [Select]
UpdateFileInfoSimple(field1, value1 [, field2, value2 [,...] ] [, multivalue_fields]);
if value is an empty string, field will be removed
multivalue_fields is a semicolon-separated list containing field names which need to be treated as multivalue.

So you want something like...

Code: [Select]
handle.UpdateFileInfoSimple("GENRE1", "Downtempo;Ambient", "GENRE2", "Rock;Classic Rock", "GENRE1;GENRE2");

Remember you can use UpdateFileInfoSimple on a handle list as well.
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2017-09-05 14:40:42
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");

Here is updated code and the modded component foo_jscript_panel-v1.2.3.3[modded] (https://www.mediafire.com/file/5ygpu775n5sjp72/foo_jscript_panel.dll) (make a backup of existing one, before replacing though)
Spoiler (click to show/hide)

Also (foobar2000.exe) is only provided by that  banned component we can't really name. And that changes to what ever component provides the option you have selected.
Heh, never knew that, since I was using that component with fb2k from the day one =)
Quite a shame, that it was banned, since it adds so many useful features to fb2k...
Title: Re: JScript Panel script discussion/help
Post by: zeremy on 2017-09-22 07:24:07
Does the new method UpdateFileInfoFromJSON handle threading in a different manner as to bypass the  limit the number of entries we can update in one run as discussed in the WSH panel Mod discussion ?

https://hydrogenaud.io/index.php/topic,77883.msg902143.html#msg902143


Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-09-22 07:36:52
Yep. You now get a progress dialog like this when working with enough files...

(https://i.imgur.com/g9KlV0U.png)

I've only managed to test with 2000 files as that's all I have.  :-[

edit: funny how fbuser was able to tag 500 files at once with the old function. I found my own system crashed after tagging 75.
Title: Re: JScript Panel script discussion/help
Post by: zeremy on 2017-09-22 07:57:17
Yep. You now get a progress dialog like this when working with enough files...

(https://i.imgur.com/g9KlV0U.png)

I've only managed to test with 2000 files as that's all I have.  :-[

edit: funny how fbuser was able to tag 500 files at once with the old function. I found my own system crashed after tagging 75.

Awesome. Thanks :)
Great improvement.

My max was 100 entries...
Title: Re: JScript Panel script discussion/help
Post by: MachineHead on 2017-10-03 20:43:16
@marc2003-

Is there an easy way to change the included jsspm double click selection behavior into single click? At one point Falstaff had this in his original version but changed it for reasons unknown.

I'd like to ask for a 'feature' request as well. I see file properties (from samples) still creates an autoplaylist from any item clicked in that panel. Is there any possibility to change that so it is off by default instead of the way it is now? I personally do not find it useful to have an autoplaylist created from say one files MD5 hash tag. Generally I edit list.js by commenting out those lines but feel that should be optional. Right click option maybe? Don't know and just a suggestion.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-10-05 10:10:19
If anyone has found the included allmusic script has stopped working, you can edit line 253 of user-components\foo_jscript_panel\samples\complete\js\text.js by replacing the http with https like this...

https://github.com/19379/foo-jscript-panel/commit/d216052e4e4863ac6187af9aa1cf968a11953943

edit: just noticed some previous posts have been nuked. I apologise to the mods and the previous poster is on the ignore list.  :P
Title: Re: JScript Panel script discussion/help
Post by: musikomaniak on 2017-10-05 11:20:51
Thanks
Title: Re: JScript Panel script discussion/help
Post by: MachineHead on 2017-10-06 05:04:48
Setting 'Mood' in the jsplaylist-mod causes an instant crash. Error message below. (https://youtu.be/SilHMPTy6Oc) Version 1.3.0.

Code: [Select]
JScript Panel (jsplaylist-mod by Br3tt aka Falstaff >> modded by marc2003)
JavaScript runtime error:
Object doesn't support property or method 'UpdateFileInfoSimple'
File: C:\Users\*\Desktop\foo_test\user-components\foo_jscript_panel\samples\jsplaylist-mod\js\WSHplaylist.js
Line: 1077, Col: 10
<source text only available at compile time>

If someone else runs into this you may wish to inform marc2003 since I apparently tripped his trigger one too many times.
Title: Re: JScript Panel script discussion/help
Post by: always.beta on 2017-10-13 09:21:18
I use Line(2860-2866、2891-2892、2942-2970) and utils.MapString to translate the music tags from traditional Chinese into Simplified Chinese. When the music tags has a null value, it fails while running on JScript Panel, and no error occurs on WSH PLUS (with utils.LCMapString). I don't know if there is a problem with my code or the utils.MapString interface. Can you help me see where the problem is?
Can you add the word wrap function at the JScript Panel Configuration ?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-10-13 11:12:26
You know I copied the function from WSH panel mod plus. The only difference is that I made it throw an error if you don't supply a flag.

I tested these examples and they perform the same in both components.

JScript Panel
Code: [Select]
var test = utils.MapString("", 0x0804, 0x04000000); //returns empty string
var test = utils.MapString(null, 0x0804, 0x04000000); //script error
var test = utils.MapString(undefined, 0x0804, 0x04000000); //returns empty string

WSH Panel Mod Plus
Code: [Select]
var test = utils.LCMapString("", 0x0804, 0x04000000); //returns empty string
var test = utils.LCMapString(null, 0x0804, 0x04000000); //script error
var test = utils.LCMapString(undefined, 0x0804, 0x04000000); //returns empty string

Just use something like this instead...

Code: [Select]
arr[k] = utils.MapString(fileinfo.MetaValue(idx,0) || "", 0x0804, ret - 3000 ? 0x04000000 : 0x02000000);

And no, I'm not adding word wrap to the configuration window. I'll be honest and say I wouldn't know how even if wanted to!
Title: Re: JScript Panel script discussion/help
Post by: always.beta on 2017-10-13 17:12:54
Thanks. It works. Now ttsping focuses on SUI. It's a new user interface that combines sciter and WSH interfaces...
Title: Re: JScript Panel script discussion/help
Post by: always.beta on 2017-10-17 04:47:46
(track info + seekbar + buttons) background color can be changed to automatically get the title bar or taskbar color? Like Groove.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-10-17 07:21:54
I'm not changing it but you can get windows 10 colours from the registry...

https://hydrogenaud.io/index.php/topic,110516.msg941430.html#msg941430
Title: Re: JScript Panel script discussion/help
Post by: MachineHead on 2017-10-18 21:52:11
If anyone is interested I've got a working jscript that switches PSS splitters with buttons from the latest JScript panel. You need to have Columns UI, PSS, and JScript panel installed (portable for testing recommended). I used images out of the mono folder from the jscript component folder for generic buttons images. Once those components are installed you can import this FCL file (https://1drv.ms/u/s!ApfYRpO7XcpKmkZPwnz1NQKfl7Bw) from within Columns UI.

Right clicking the Parent Splitter (https://imgur.com/Txn9hwe) and selecting Splitter Settings (upper one) will show child splitter names in PanelList tab. The Script tab shows the PSS code that must be used in the parent splitter. Note names in Script tab (1-4) and their placement here. They need to match the names in the PanelList tab.

This type of switcher does not need to be in the same parent splitter as is the case for PSS buttons. You can even use this in the CUI toolbar to change the panels. Right click the toolbar > Panels > JScript panel > copy code from orange jscript panel.

I'm unsure if it could be cleaned up or optimized further, but it works quite well.
Title: Re: JScript Panel script discussion/help
Post by: zeremy on 2017-10-20 13:45:27
If anyone is interested I've got a working jscript that switches PSS splitters with buttons from the latest JScript panel. You need to have Columns UI, PSS, and JScript panel installed (portable for testing recommended). I used images out of the mono folder from the jscript component folder for generic buttons images. Once those components are installed you can import this FCL file (https://1drv.ms/u/s!ApfYRpO7XcpKmkZPwnz1NQKfl7Bw) from within Columns UI.

Right clicking the Parent Splitter (https://imgur.com/Txn9hwe) and selecting Splitter Settings (upper one) will show child splitter names in PanelList tab. The Script tab shows the PSS code that must be used in the parent splitter. Note names in Script tab (1-4) and their placement here. They need to match the names in the PanelList tab.

This type of switcher does not need to be in the same parent splitter as is the case for PSS buttons. You can even use this in the CUI toolbar to change the panels. Right click the toolbar > Panels > JScript panel > copy code from orange jscript panel.

I'm unsure if it could be cleaned up or optimized further, but it works quite well.

I just want to mention that the reqiured "hack" to refresh the PSS panel
Code: [Select]
if (fb.IsPlaying || fb.IsPaused) {  
fb.RunMainMenuCommand("Playback/Play or Pause");
fb.RunMainMenuCommand("Playback/Play or Pause");
} else {
fb.RunMainMenuCommand("Playback/Play");
fb.RunMainMenuCommand("Playback/Stop");
}
works well with local media files, but not with internet radio streams where there is a noticable pause in the playback.
Title: Re: JScript Panel script discussion/help
Post by: always.beta on 2017-10-20 15:45:15
Replace Wsh panel mod with jscript panel on catrox. There are some undefined definitions. Who can help me? Like: line: 989 in Control_Scrollbar.js  line: 584 in Panel_Cover.js
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-10-20 17:18:38
Catrox was written for WSH panel mod... so use WSH panel mod. The main reason I created JScript Panel was because of my breaking changes so people can now run both components side by side if they don't know how to update the scripts.

edit: and of course you even have access to WSH panel mod PLUS which seems to contain most functions from both components.
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2017-10-20 18:07:24
@always.beta: Well, actually, original CaTRoX is pretty much compatible with JScript, you just need to follow this guide (https://github.com/19379/foo-jscript-panel/wiki/Updating-WSH-Panel-Mod-scripts-for-JScript-Panel) to make it work.
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-10-21 02:55:55
Well that link is in the first post of this thread.... it's really for script authors who might want to update their scripts and then take advantage of newer features in this component. I figure for the casual user, it's just easier to use the old component - that is you can afford the 1MB or so of disk space it takes.  :P
Title: Re: JScript Panel script discussion/help
Post by: always.beta on 2017-10-21 04:38:49
@always.beta: Well, actually, original CaTRoX is pretty much compatible with JScript, you just need to follow this guide (https://github.com/19379/foo-jscript-panel/wiki/Updating-WSH-Panel-Mod-scripts-for-JScript-Panel) to make it work.
The interface has been updated as instructed. Now the error: createScrollbarImages(line: 989 in Control_Scrollbar.js) is undefined. However, it is defined in line: 165. I don't know how to fix the definition.

Just an act of compulsion. A new components appears, why not upgrade. :)
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-10-21 07:21:14
Possibly related to this... https://hydrogenaud.io/index.php/topic,110499.msg933234.html#msg933234
Title: Re: JScript Panel script discussion/help
Post by: MachineHead on 2017-10-21 17:34:29
I just want to mention that the reqiured "hack" to refresh the PSS panel works well with local media files, but not with internet radio streams where there is a noticable pause in the playback.
That's a well known limitation of PSS and not exactly what the focus of this experiment was. Until there's another component that allows the same flexibility as PSS without it's warts we're sort of stuck with what we have at hand. If a user can live with the drawbacks then this simple script permits PSS switching from anywhere in the UI as long as the jscript panel doing the switching is visible. I even rolled this into my heavily modified 'track info + seekbar + buttons' control bar.
Title: Re: JScript Panel script discussion/help
Post by: zeremy on 2017-10-22 16:25:16
I just want to mention that the reqiured "hack" to refresh the PSS panel works well with local media files, but not with internet radio streams where there is a noticable pause in the playback.
That's a well known limitation of PSS and not exactly what the focus of this experiment was. Until there's another component that allows the same flexibility as PSS without it's warts we're sort of stuck with what we have at hand. If a user can live with the drawbacks then this simple script permits PSS switching from anywhere in the UI as long as the jscript panel doing the switching is visible. I even rolled this into my heavily modified 'track info + seekbar + buttons' control bar.

I just wanted to mention a limitation of your experiment.

There exists a component that can switch & move panels with desired sizes and its called mega_panel_splitter.
http://1drv.ms/1EbzBou (http://1drv.ms/1EbzBou)
It is based on wsh and old version [1.1.10].
https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/foo-wsh-panel-mod/Source-1.1.10.7z

Proof of concept demo: https://www.dropbox.com/s/nvqh5d5y40ae74p/bandicam%202017-10-22%2018-58-27-047.avi?dl=0 (https://www.dropbox.com/s/nvqh5d5y40ae74p/bandicam%202017-10-22%2018-58-27-047.avi?dl=0)

If you need to control a jscript panel from PSS you can use marc2003 new callback, on_main_menu.
https://github.com/19379/foo-jscript-panel/blob/master/foo_jscript_panel/docs/Callbacks.txt#L61

The opposite is not possible though. (Use jscript panel  to notify PSS)

PSS only evaluates scripts on playback start or when  track info is modified.
Title: Re: JScript Panel script discussion/help
Post by: MachineHead on 2017-10-22 19:24:58
I just wanted to mention a limitation of your experiment.
It does exactly what it was supposed to do; control PSS splitters with the only means available to do so at this time. Recommending undocumented components that a handful of people on the planet use (and probably even fewer understand) is going off-topic here.
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2017-11-26 15:26:58
When does the on_mouse_move event actually take place?
I understand if I move the pointer from A to B an on_mouse_event takes place when the pointer stops on B, thus passing the B coordinates as arguments to the on_mouse_move function, but what happens during the path from A to B? Does the event take place only when the pointer stops, or also while it is still moving? In this latter case, is the motion detected on a time interval or a space interval basis?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-11-26 16:30:03
Start with a blank panel...

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

function on_mouse_move(x, y) {
    tt(x + "-" + y);
}

function tt(message) {
    if (tooltip.Text != message) { //must check values have changed otherwise tooltip will flicker
        tooltip.Text = message;
        tooltip.Activate();
    }
}

Now move your mouse and see how often the numbers update.
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2017-11-26 18:03:57
Start with a blank panel...

Spoiler (click to show/hide)
Now move your mouse and see how often the numbers update.

Well, I can't really see in real time what happens if the mouse is moving too fast, however I traced the y value with the console and beyond a certain speed the increments can be greater than 1, therefore I'd say a minimum time interval is required before the event takes place.
I also tried removing the if statement to check if there is a minimum space interval, too, and when moving slow enough, some values were repeated. That means, if I'm correct, that no minimum space interval is required to trigger the event, and since the coordinates are rounded to an integer, an on_mouse_event does not necessarily mean the x and y values have changed. I guess this is something that must be handled with an if statement, like you did, in order to prevent flickering if the on_mouse_event triggers a repaint .
Title: Re: JScript Panel script discussion/help
Post by: Sandman2012 on 2017-12-04 02:28:52
I'm looking for a little help with falstaff's scripts. As an example I installed JS Smooth Playlist Manager and I get this error when applying it:

Code: [Select]
JScript Panel (JS Smooth Playlist Manager v20151115-1000-151 by Br3tt aka Falstaff >> http://br3tt.deviantart.com)
JavaScript compilation error:
Syntax error
File: C:\Users\Daniel\AppData\Roaming\foobar2000\js_br3tt\jsspm\js\JScommon.js
Line: 540, Col: 8
    }; else {

What am I doing wrong?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-12-04 10:25:54
Looks like you have the original version from deviantart - they're not compatible with the latest versions of the component.

However, updated versions of the scripts are bundled inside the component folder so right click in a panel>Open component folder and browse to samples\js-mooth

edit: if you don't have a js-smooth folder, you'll need to update the component (https://github.com/19379/foo-jscript-panel/releases).
Title: Re: JScript Panel script discussion/help
Post by: always.beta on 2017-12-06 17:09:54
JS Smooth Playlist: when the music is played to 1/3, the selection box will automatically switch to the next one, and the current music loses the focus of the playback. How do I close it, please?
Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-12-06 22:58:03
I don't even understand the "question/problem" above! I know my component changes did break the originals some time ago and I did my best to change the code style to make them load. They all do that now and I don't understand the code well enough to make changes to the deeper features/functionality.

Simply put, I don't have the answers. If they don't work as expected, don't use them.

Title: Re: JScript Panel script discussion/help
Post by: zeremy on 2017-12-07 07:27:51
JS Smooth Playlist: when the music is played to 1/3, the selection box will automatically switch to the next one, and the current music loses the focus of the playback. How do I close it, please?
It is a conflict that occurs when you select in ESLyrics , Lyrics save scheme "Save when 60s or 1/3 of length have played".
Title: Re: JScript Panel script discussion/help
Post by: always.beta on 2017-12-07 13:17:33
It is a conflict that occurs when you select in ESLyrics , Lyrics save scheme "Save when 60s or 1/3 of length have played".
I always thought the track title artist information has not changed, and will not affect it. :-[  I've changed the Lyrics save scheme. Thank you.
Title: Re: JScript Panel script discussion/help
Post by: kgena_ua on 2017-12-14 19:29:24
Can I compare two objects?
For example.
I have two massive of embedded covers
I need    if (embedded_1[0] == embedded_2[0] ) {.........}

or

var img1 = gdi.Image(img_path + "1.png"),
var img2 = gdi.Image(img_path + "2.png"),

if ( img1  ==  img2 ) {.........}




Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-12-14 20:06:44
Nope.
Title: Re: JScript Panel script discussion/help
Post by: kgena_ua on 2017-12-14 20:22:52
Nope.
there was hope
Thanks, marc2003
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2017-12-18 15:02:38
Is there a way to detect if the windows theme, or the screen settings were changed?
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2017-12-18 15:29:36
Is there a way to detect if the windows theme, or the screen settings were changed?
Can you elaborate your question a bit? =)
Are you talking about Windows (e.g. Windows 10) theme? Or fb2k theme?
And there a lot of various screen settings as well both in fb2k and Windows...
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2017-12-18 16:08:38
Is there a way to detect if the windows theme, or the screen settings were changed?
Can you elaborate your question a bit? =)
Are you talking about Windows (e.g. Windows 10) theme? Or fb2k theme?
And there a lot of various screen settings as well both in fb2k and Windows...


I'm talking about the windows 10 theme. I have a script that reads the registry key value of the accent color and other related settings such as transparency mode and whether the accent color is applied to the window titlebar. The script than refreshes panel stack splitter in order to apply the new accent color, if changed. At the moment it is triggered by the on_size and by the on_playback_new_track events, but I would like to execute the script when one of those screen settings is changed, or when a new theme is applied.
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2017-12-18 16:17:54
Well, there are no such functions in JScript. But you could probably make something with window.setInterval, i.e. get, compare and update theme values from registry every N seconds .
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2017-12-18 17:08:31
Well, there are no such functions in JScript. But you could probably make something with window.setInterval, i.e. get, compare and update theme values from registry every N seconds .

I'll give it a look, thanks.
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2018-01-17 23:09:20
Does anybody have or know of a fairly simple script for an input box?
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2018-01-18 13:10:31
Does anybody have or know of a fairly simple script for an input box?

I'm trying to replace the quicksearch toolbar with a jscript panel, but I'm not looking for a ready made script, which would probably have the same layout issues that the quicksearch toolbar has.  I've seen some configurations with a jscript searchbox, but they are far too complex to extrapolate the relevant code.
I thought I could build what I needed with the on_key_down and on_key_up events, but perhaps I've been a little too optimistic. What are the basic guidelines? Which callbacks should I use and, by the way, how do I get the proper character codes from key events?
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2018-01-18 16:56:51
I'm trying to replace the quicksearch toolbar with a jscript panel, but I'm not looking for a ready made script, which would probably have the same layout issues that the quicksearch toolbar has.  I've seen some configurations with a jscript searchbox, but they are far too complex to extrapolate the relevant code.
I thought I could build what I needed with the on_key_down and on_key_up events, but perhaps I've been a little too optimistic. What are the basic guidelines? Which callbacks should I use and, by the way, how do I get the proper character codes from key events?
The issue is that JScript is not a web browser (which is my fucking dream... can you imagine how easy this stuff would be if we could use css/html for displaying panels and stuff -- I digress) so you can't really do an input box without completely faking EVERYTHING. i.e. you'd have to draw a rectangle on the screen. When the user clicks on it you have to draw a carat. When the user presses a key you have to draw a character to the screen and move the carat, you have to redraw on backspaces,.... etc.

I assume it *could* be done and maybe someone has done it, but it sounds awful to me.

There is some good news though. Doing something on keypresses is the easy part! The delete and ctrl-A keys call functions specific to my theme, but ctrl-F and Shift-F will run different foobar searches which might be good enough for you.
Code: [Select]
function on_key_down(vkey) {
var CtrlKeyPressed = utils.IsKeyPressed(VK_CONTROL);
var ShiftKeyPressed = utils.IsKeyPressed(VK_SHIFT);
switch (vkey) {
case VK_DELETE:
RemovePlaylistSelection(activeList, crop = false);
break;
case VK_KEY_A:
CtrlKeyPressed && selectAll();
break;
case VK_KEY_F:
CtrlKeyPressed && fb.RunMainMenuCommand("Edit/Search");
ShiftKeyPressed && !CtrlKeyPressed && fb.RunMainMenuCommand("Library/Search");
break;
}
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2018-01-18 19:24:17
There is some good news though. Doing something on keypresses is the easy part! The delete and ctrl-A keys call functions specific to my theme, but ctrl-F and Shift-F will run different foobar searches which might be good enough for you.
Code: [Select]
function on_key_down(vkey) {
var CtrlKeyPressed = utils.IsKeyPressed(VK_CONTROL);
var ShiftKeyPressed = utils.IsKeyPressed(VK_SHIFT);
switch (vkey) {
case VK_DELETE:
RemovePlaylistSelection(activeList, crop = false);
break;
case VK_KEY_A:
CtrlKeyPressed && selectAll();
break;
case VK_KEY_F:
CtrlKeyPressed && fb.RunMainMenuCommand("Edit/Search");
ShiftKeyPressed && !CtrlKeyPressed && fb.RunMainMenuCommand("Library/Search");
break;
}
Thanks a lot! This is the kind of starting point I'm looking for, and thanks for pointing me to the utils interface which for some reason I always fail to take into account. I still can't figure out a reasonable way to determine the character code, though. The combination of keycode and utils.IsKeyPressed is actually enough, but do I really have to go through all possible combinations one by one with a switch statement? Isn't there something like a keyboard mapping? Perhaps some array of values in the registry key?



The issue is that JScript is not a web browser (which is my fucking dream... can you imagine how easy this stuff would be if we could use css/html for displaying panels and stuff -- I digress)
Indeed! I'm still waiting for the sciter ui plug-in.



so you can't really do an input box without completely faking EVERYTHING. i.e. you'd have to draw a rectangle on the screen. When the user clicks on it you have to draw a carat. When the user presses a key you have to draw a character to the screen and move the carat, you have to redraw on backspaces,.... etc.


I assume it *could* be done and maybe someone has done it, but it sounds awful to me.
Yes, someone has. There is one in colagen's eole skin, even though I think the script is taken from the DUItunes skin by Falstaff. The code that implements the searchbox - at least where I'm able to recognize it - is within my reach, but it is hidden in longer multipurpose scripts, specific for that particular configuration or layout and with a maze of crossfererence to other js documents that make reading it a real pain in the neck, unless you are the author, I guess.
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2018-01-18 20:41:11
[Thanks a lot! This is the kind of starting point I'm looking for, and thanks for pointing me to the utils interface which for some reason I always fail to take into account. I still can't figure out a reasonable way to determine the character code, though. The combination of keycode and utils.IsKeyPressed is actually enough, but do I really have to go through all possible combinations one by one with a switch statement? Isn't there something like a keyboard mapping? Perhaps some array of values in the registry key?
on_key_down returns standard ascii character codes. So values 65-90 correspond to A-Z (you need to check if VK_SHIFT is down for upper/lower though). If you want to output the key pressed to the screen you can do something like:
Code: [Select]
var str = String.fromCharCode(65);    // str now contains 'A'
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2018-01-19 01:53:10
on_key_down returns standard ascii character codes. So values 65-90 correspond to A-Z (you need to check if VK_SHIFT is down for upper/lower though). If you want to output the key pressed to the screen you can do something like:
Code: [Select]
var str = String.fromCharCode(65);    // str now contains 'A'

Yes, the A-Z character codes, as well as the blank space and 0-9 characters, are the same as the key code, but all other symbols are messed up and I believe they change with the keyboard settings.
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2018-01-19 02:09:40
I would assume punctuation and other printable characters are the same, but the other things probably require a select statement based off the VK_ defines.
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2018-01-22 22:36:20
on_key_down returns standard ascii character codes. So values 65-90 correspond to A-Z (you need to check if VK_SHIFT is down for upper/lower though). If you want to output the key pressed to the screen you can do something like:
Code: [Select]
var str = String.fromCharCode(65);    // str now contains 'A'

Yes, the A-Z character codes, as well as the blank space and 0-9 characters, are the same as the key code, but all other symbols are messed up and I believe they change with the keyboard settings.

We were on the wrong track! The on_char(code) callback is the one to look at: it takes the character code which is actually mapped to the key, rather than the key code.
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2018-01-23 17:01:27
Nice, I'd never actually used that callback before. Thanks for the info.
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2018-01-24 17:39:10
How do you escape the ampersand? The backslash doesn't seem to work as with other characters.
Basically: how can I write "Tom & Jerry" with a GdiDrawText method?
Title: Re: JScript Panel script discussion/help
Post by: lvqcl on 2018-01-24 18:30:40
Try "Tom && Jerry"
Title: Re: JScript Panel script discussion/help
Post by: zeremy on 2018-01-24 18:31:53
How do you escape the ampersand? The backslash doesn't seem to work as with other characters.
Basically: how can I write "Tom & Jerry" with a GdiDrawText method?
You need to add the flag  DT_NOPREFIX
https://github.com/marc2k3/foo_jscript_panel/blob/master/foo_jscript_panel/docs/Flags.txt#L16

https://github.com/marc2k3/foo_jscript_panel/blob/8ee7c4d084b535946922c05cadc3eba1b0e5c7e4/foo_jscript_panel/docs/Interfaces.txt#L1268

Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2018-01-24 18:35:41
Thanks, both solutions work.
Title: Re: JScript Panel script discussion/help
Post by: Mrakobes on 2018-01-26 13:23:28
Hello. I use
// @name "Text Reader"
// @author "marc2003"

1. I want to use it for viewing сue located of course in the playing folder, how to set the path? Default $directory_path(%path%) ... $directory_path(%path%)\*.CUE ... dont work

2. where to change the font type?

3. I want to display a text file with the name "discography.txt" in the root artist folder, the problem is that sometimes the depth of nesting, for example "artist \ album \" ... "artist \ album \ CD1"
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2018-01-26 18:52:26
EDIT
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2018-01-26 20:03:26
2. where to change the font type?

The panel object uses the DUI or CUI font settings.


3. I want to display a text file with the name "discography.txt" in the root artist folder, the problem is that sometimes the depth of nesting, for example "artist \ album \" ... "artist \ album \ CD1"

It depends on your folder naming standards. For example, if all your multiple discs were in folders named CD%discnumber% this could be your custom path:
Code: [Select]
$if($strcmp($directory(%path%),CD%discnumber%),$replace($directory_path(%path%),$directory(%path%),),$directory_path(%path%))
Title: Re: JScript Panel script discussion/help
Post by: Mrakobes on 2018-01-27 07:17:29
2. where to change the font type?

The panel object uses the DUI or CUI font settings.


3. I want to display a text file with the name "discography.txt" in the root artist folder, the problem is that sometimes the depth of nesting, for example "artist \ album \" ... "artist \ album \ CD1"

It depends on your folder naming standards. For example, if all your multiple discs were in folders named CD%discnumber% this could be your custom path:
Code: [Select]
$if($strcmp($directory(%path%),CD%discnumber%),$replace($directory_path(%path%),$directory(%path%),),$directory_path(%path%))

2. I use when changing columns UI the font of a custom, only the headings change but not the actual display of the text file in the panel

3. CD%discnumber% - use of this code requires the insertion of tags% discnumber% ??? How to be if there are no tags (in CUE), and the folders are called CD1, CD2? And how to complete the code to take only the file with the name "discography.txt"?
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2018-01-27 20:49:16
2. I use when changing columns UI the font of a custom, only the headings change but not the actual display of the text file in the panel
You are right, in text_reader mode the panel always uses the lucida console character for the text. This is not my script, so I'm just groping around, but you can try editing the script and replace on line 11 the word "text_reader" with the word "allmusic", that should apply the CUI font.


3. CD%discnumber% - use of this code requires the insertion of tags% discnumber% ??? How to be if there are no tags (in CUE), and the folders are called CD1, CD2? And how to complete the code to take only the file with the name "discography.txt"?
Something like this?
Code: [Select]
$ifequal($strstr($directory(%path%),CD),1,$replace($directory_path(%path%),\$directory(%path%),),$directory_path(%path%))\discography.txt
Title: Re: JScript Panel script discussion/help
Post by: Mrakobes on 2018-01-28 08:37:09
2. I use when changing columns UI the font of a custom, only the headings change but not the actual display of the text file in the panel
You are right, in text_reader mode the panel always uses the lucida console character for the text. This is not my script, so I'm just groping around, but you can try editing the script and replace on line 11 the word "text_reader" with the word "allmusic", that should apply the CUI font.


3. CD%discnumber% - use of this code requires the insertion of tags% discnumber% ??? How to be if there are no tags (in CUE), and the folders are called CD1, CD2? And how to complete the code to take only the file with the name "discography.txt"?
Something like this?
Code: [Select]
$ifequal($strstr($directory(%path%),CD),1,$replace($directory_path(%path%),\$directory(%path%),),$directory_path(%path%))\discography.txt


1. with allmusic stopped working as text reader((

2. the code does not see the file in the artist folder, you need to make the code for universal viewing from any sub-folder with any recursion up to the folder artist

var 1: artist\album\CD1\playable file

var 2: artist\album\playable file

in both variants "discography.txt" is located in "artist" folder
Title: Re: JScript Panel script discussion/help
Post by: zeremy on 2018-01-28 14:10:17
Hello. I use
// @name "Text Reader"
// @author "marc2003"

1. I want to use it for viewing сue located of course in the playing folder, how to set the path? Default $directory_path(%path%) ... $directory_path(%path%)\*.CUE ... dont work

2. where to change the font type?

3. I want to display a text file with the name "discography.txt" in the root artist folder, the problem is that sometimes the depth of nesting, for example "artist \ album \" ... "artist \ album \ CD1"

1. The text reader looks for *.txt *.log in  default custom path $directory_path(%path%) or a specific file when defined  $directory_path(%path%)\thecuefilename.cue

1a. Either specify the same name to all your cue files eg. tracklist.cue  and define the custom path $directory_path(%path%)\tracklist.cue

OR

1b. Modify text.js  in user-components\foo_jscript_panel\samples\complete\js to include *.cue by changing line #370
this.exts = 'txt|log';

TO
 
this.exts = 'cue|txt|log';

Remember that any future update to the component will overwrite text.js

2. The text panel follows the defined common (list items)  CUI font in the preferences page.
Uncheck "Fixed  width font" from the text panel submenu for it not to use fixed font Lucida Console.

3. This should work
Code: [Select]
$left(%path%,$strstr(%path%,\%artist%))%artist%)\discography.txt

Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2018-01-28 14:23:10
EDIT: actually just follow zeremy's instructions
Title: Re: JScript Panel script discussion/help
Post by: Mrakobes on 2018-01-28 15:18:02
zeremy, Thank you so much! "Fixed  width font" was in the most prominent place))))))))

I added this.exts = 'cue|txt|log'; ... but still does not read the only cue in the folder, only when assigning a relative path, how to make it work on any cue ... $directory_path(%path%)\*.cue  ???
Title: Re: JScript Panel script discussion/help
Post by: zeremy on 2018-01-28 15:26:27
zeremy, Thank you so much! "Fixed  width font" was in the most prominent place))))))))

I added this.exts = 'cue|txt|log'; ... but still does not read the only cue in the folder, only when assigning a relative path, how to make it work on any cue ... $directory_path(%path%)\*.cue  ???


Don't use $directory_path(%path%)\*.cue  in the custom path
Use  $directory_path(%path%)

The script will load the first file found out of the three extensions cue,txt,log ( you cant define a single one ) in the directory,
Title: Re: JScript Panel script discussion/help
Post by: Mrakobes on 2018-01-28 16:27:04
zeremy, Thank you, we created Cue Viewer!
Title: Re: JScript Panel script discussion/help
Post by: zeremy on 2018-01-28 16:45:03
zeremy, Thank you, we created Cue Viewer!
Glad I helped you sort it out.
To be honest, I  just gave you a few pointers.
You should thank @marc2003 who is the author.

Title: Re: JScript Panel script discussion/help
Post by: DVS on 2018-01-28 18:30:46
Code: [Select]
var items = plman.GetPlaylistItems(plman.ActivePlaylist);
for (var i = 0; i < items.Count; i++) {
items.Item(i).SetRating(5);
}
items.RefreshStats();
items.Dispose();
What to do with this script? Thanks.
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2018-02-07 19:36:09
I've been doing a LOT of work with color handling in my script as I'm using image.GetColorScheme() to pull the colors to generate a dynamic theme. It works great, and I can't wait to show it to everyone, but I figured I ought to share some of the helper code I wrote as I'm sure it'd be useful to more than just me.

This code makes extensive use out of the getRed, getGreen, getBlue, rgb, rgba helper functions and I won't bother repeating them unless somebody can't find them in helpers.txt. Also, I renamed RGB and RGBA to lowercase versions.

prettyPrint a color. Useful for logging:
Code: [Select]
function colToRgb(c, showPrefix) {
if (typeof showPrefix === 'undefined') showPrefix = true;
var alpha = getAlpha(c);
var prefix = '';
if (alpha < 255) {
if (showPrefix) prefix = 'rgba'
return prefix + '('+ getRed(c) + ', ' + getGreen(c) + ', ' + getBlue(c) + ', ' + alpha + ')';
} else {
if (showPrefix) prefix = 'rgb'
return prefix + '(' + getRed(c) + ', ' + getGreen(c) + ', ' + getBlue(c) + ')';
}
}

Calculate Brightness of a color:
Code: [Select]
function calcBrightness(c) {
var r = getRed(c);
var g = getGreen(c);
var b = getBlue(c);
return Math.round(Math.sqrt( 0.299*r*r + 0.587*g*g + 0.114*b*b ));
}

Create Shades (darker) or Tints (lighter) of a color. These two functions take a percent number, i.e. pass 20 instead of .2. Passing 100 to shade will result in solid black, 100 to tint is solid white.
Code: [Select]
color = rgb(81, 89, 72); // gray-ish green
darker = shadeColor(color, 30);    // darker = rgb(57, 62, 50)
lighter = tintColor(color, 20);    // lighter = rgb(116, 122, 109)

function shadeColor(color, percent) {
var red = getRed(color);
var green = getGreen(color);
var blue = getBlue(color);

return rgba(darkenColorVal(red, percent), darkenColorVal(green, percent), darkenColorVal(blue, percent), getAlpha(color));
}

function tintColor(color, percent) {
var red = getRed(color);
var green = getGreen(color);
var blue = getBlue(color);

return rgba(lightenColorVal(red, percent), lightenColorVal(green, percent), lightenColorVal(blue, percent), getAlpha(color));
}

// helpers, don't call directly
function darkenColorVal(color, percent) {
var shift = Math.max(color * percent / 100, percent / 2);
val = Math.round(color - shift);
return Math.max(val, 0);
}

function lightenColorVal(color, percent) {
val = Math.round(color + ((255-color) * (percent / 100)));
return Math.min(val, 255);
}
Title: Re: JScript Panel script discussion/help
Post by: colagen on 2018-02-09 09:22:56
HI,
Does somebody know what is the fromhook parameter in this callback function ?
Code: [Select]
function on_metadb_changed(handle_list, fromhook) {}
It seems to be  boolean, and it seems to be true when the callback is from a change by foobar, and false otherwise. Is that true ? Is there a documentation somewhere ? There is nothing in the "official" documentation

Thanks!
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2018-02-09 09:58:45
HI,
Does somebody know what is the fromhook parameter in this callback function ?
Code: [Select]
function on_metadb_changed(handle_list, fromhook) {}
It seems to be  boolean, and it seems to be true when the callback is from a change by foobar, and false otherwise. Is that true ? Is there a documentation somewhere ? There is nothing in the "official" documentation

Thanks!
From fb2k SDK documentation:
//! @param p_fromhook Set to true when actual file contents haven't changed but one of metadb_display_field_provider implementations requested an update so output of metadb_handle::format_title() etc has changed.

E.g. it will be true when %play_count% field provided by foo_playcount component has changed.
Title: Re: JScript Panel script discussion/help
Post by: colagen on 2018-02-10 19:03:05
Okey, thanks, clear enough
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2018-02-19 11:32:55
To anyone using IntelliJ WebStorm or IDEA to create/edit scripts:
I've updated JSDoc'd version of JScript's interface.txt (https://github.com/marc2k3/foo_jscript_panel/blob/master/foo_jscript_panel/docs/Interfaces.txt), which can be used as a plugin/library in IDEA/WebStorm.
This will remove most of 'undefined symbol' warnings and will also provide some type checks when using JScript interface.

Instructions:
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2018-02-19 17:08:12
Is there a way distinguish two different playlists with the same name, without knowing their index?
When I need to perform some action on a specific playlist, I usually retrieve the playlist index by looping through all playlists until I find the one with the matching name, but since nothing in foobar2000 prevents me from accidentally duplicating a playlist name and the index changes when moving the playlist, how can I make sure I identify the right playlist?
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2018-02-19 17:17:05
Is there a way distinguish two different playlists with the same name, without knowing their index?
When I need to perform some action on a specific playlist, I usually retrieve the playlist index by looping through all playlists until I find the one with the matching name, but since nothing in foobar2000 prevents me from accidentally duplicating a playlist name and the index changes when moving the playlist, how can I make sure I identify the right playlist?
Well, if two playlists have the same name and content, then the only way to differentiate them is by their index. If you are working on the currently active playlist you can retrieve it's index via plman.ActivePlaylist. May be you could elaborate your scenario a bit more?

PS: reply #666 > : )
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2018-02-19 17:36:15
Well, if two playlists have the same name and content, then the only way to differentiate them is by their index.

No, I mean two different playlists by all means, different content, but accidentally named alike.

I have some sort of "service" playlists. For example a "Recently Added" autoplaylist with all tracks added in the past 6 weeks. I use a script to create said playlist if it is not present (in case I accidentally delete it, for example). Now, let's say I run the menu command Library-> Playback Statistics -> Show recently added. This will create a second "Recently Added" autoplaylist, but with a different format and content. If I accidentally delete my "Recently Added" playlist, the script will fail to recreate it, because it will find another playlist with the same name and mistake it for the deleted one.


PS: reply #666 > : )
8)
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2018-02-19 17:53:53
I'm pretty sure there must be some sort of playlist identifier, other than the name and the index, because components such as playlist attributes can keep trace of a single playlist settings even if its name is not univocal and even after it is moved around, hence changing its index, but I don't know if and how this identifier is accessible with jscript.
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2018-02-19 18:20:02
I'm pretty sure there must be some sort of playlist identifier, other than the name and the index, because components such as playlist attributes can keep trace of a single playlist settings even if its name is not univocal and even after it is moved around, hence changing its index, but I don't know if and how this identifier is accessible with jscript.
foo_playlist_attributes probably uses this API (https://github.com/marc2k3/foo_jscript_panel/blob/master/foobar2000/SDK/playlist.h#L386), which is not exposed in JScript. Nevertheless, this API only allows to set some property to playlists (i.e. playlists are differentiated by index in fb2k itself), so foo_playlist_attributes most likely sets unique properties to each playlist on startup, which allows it to track all the changes on those playlists.
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2018-02-20 22:26:20
To anyone using IntelliJ WebStorm or IDEA to create/edit scripts:
I've updated JSDoc'd version of JScript's interface.txt (https://github.com/marc2k3/foo_jscript_panel/blob/master/foo_jscript_panel/docs/Interfaces.txt), which can be used as a plugin/library in IDEA/WebStorm.
This will remove most of 'undefined symbol' warnings and will also provide some type checks when using JScript interface.
Damnit, I could really use this for VSCode :)
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2018-02-21 09:29:02
Damnit, I could really use this for VSCode :)
Google is your friend =)
E.g.: https://stackoverflow.com/questions/45332052/how-to-add-an-api-to-visual-studio-code
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2018-02-22 18:06:12
Touché!

Alright, so I added your Interfaces.js to my VS Code, and it works perfectly, almost. fb, gdi, utils, etc. all work out of the box.... except for gr which is the one I most care about :D

Dig a little digging and your code generator was missing the new on the gr constructor. Change 2110 to:
var gr = new IGdiGraphics();

And everything works beautifully. Also, I think I owe you a beer now.
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2018-02-23 21:11:30
I just updated to 2.0.x this week and today I just realized I can't add items to the playbackQueue. Here's my call:

plman.AddPlaylistItemToPlaybackQueue(activeList, focusItemIndex);

where activeList is the index of the playlist and focusItemIndex is the index into that playlist of the song. Both those numbers are correct. Nothing appears to happen though. Am I missing something? There was some stuff in the breaking changes about this playlist stuff, but it doesn't look like AddPlaylistItemToPlaybackQueue was affected.
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2018-02-23 21:44:17
Touché!

Alright, so I added your Interfaces.js to my VS Code, and it works perfectly, almost. fb, gdi, utils, etc. all work out of the box.... except for gr which is the one I most care about :D

Dig a little digging and your code generator was missing the new on the gr constructor. Change 2110 to:
var gr = new IGdiGraphics();

And everything works beautifully. Also, I think I owe you a beer now.

Heh, will be fixed soon =)
And you are welcome! Glad that it was useful for someone other than me :P

I just updated to 2.0.x this week and today I just realized I can't add items to the playbackQueue. Here's my call:

plman.AddPlaylistItemToPlaybackQueue(activeList, focusItemIndex);

where activeList is the index of the playlist and focusItemIndex is the index into that playlist of the song. Both those numbers are correct. Nothing appears to happen though. Am I missing something? There was some stuff in the breaking changes about this playlist stuff, but it doesn't look like AddPlaylistItemToPlaybackQueue was affected.

Not sure about this - AddPlaylistItemToPlaybackQueue works fine for me... Queue is updated and the added item is played next as well :\
The function usage seems the same as well:
https://github.com/TheQwertiest/CaTRoX_QWR/blob/master/theme/Scripts/Panel_Playlist.js#L4013

What do you mean by "Nothing appears to happen"? Is it that the added track is ignored, or on_queue_changed callbacks are not called?

PS: Didn't have a chance to visit Austin (or Texas for that matter) yet, but now I'll have one more excuse to rectify that =)
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2018-02-23 22:21:41
What do you mean by "Nothing appears to happen"? Is it that the added track is ignored, or on_queue_changed callbacks are not called?
Exactly what I said. Nothing "appears" to happen. ;) Turns out everything actually was happening, my playlist just isn't showing the queued status of items. Got to be related to the breaking changes. I fixed the errors, but something still isn't right I guess.

Quote
PS: Didn't have a chance to visit Austin (or Texas for that matter) yet, but now I'll have one more excuse to rectify that =)
Do it! The music is great, the beer is cheap, and the women are gorgeous. You basically can't go wrong.
Title: Re: JScript Panel script discussion/help
Post by: kgena_ua on 2018-02-24 20:12:22
help.
I have LastFm HTML code
Code: [Select]
<li class="metadata-item metadata-item--limit-width other-releases">	
  h2 class="metadata-title">Also featured on</h2>
    <a href="/music/John+Lennon/The+John+Lennon+Collection" title="The John Lennon Collection"><img src="https://lastfm-img2.akamaized.net/i/u/avatar42s/59ecaa8fd6474c48b04cc537a0d9e508.jpg" alt="The John Lennon Collection" /></a>
   <a href="/music/John+Lennon/Lennon" title="Lennon"><img src="https://lastfm-img2.akamaized.net/i/u/avatar42s/937195d43be848959662ad9b615ef1c1.jpg" alt="Lennon" /></a>
   <a href="/music/John+Lennon/Lennon+Legend+-+The+Very+Best+Of+John+Lennon" title="Lennon Legend - The Very Best Of John Lennon"><img src="https://lastfm-img2.akamaized.net/i/u/avatar42s/686afc08c3a94049a235314603e62fe6.jpg" alt="Lennon Legend - The Very Best Of John Lennon" /></a>
   <div class="additional-release-count">
      <a href="/music/John+Lennon/_/Instant+Karma!/+albums"><span class="release-count">+5</span> other releases</a>
    </div>
 </li>
if i I want to get "Also featured on" , I do
Code: [Select]
                var h2 = div.getElementsByTagName("h2");	
                for (i = 0; i < h2.length; i++) {
                    if (h2[i].className == "metadata-title") {
                        t = h2[i].innerHTML;
                        break;
                    }
                }
How I can get (title or alt):
"The John Lennon Collection"
"Lennon"
and
"Lennon Legend - The Very Best Of John Lennon"



Title: Re: JScript Panel script discussion/help
Post by: zeremy on 2018-02-25 14:54:03
@kgena_ua

https://jsfiddle.net/p76j7Lb4/
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2018-02-25 18:50:23
OMG, I'm lost. What are you guys talking about? Is this code for the JScript panel?

if i I want to get "Also featured on" , I do
Code: [Select]
                var h2 = div.getElementsByTagName("h2");	
                for (i = 0; i < h2.length; i++) {
                    if (h2[i].className == "metadata-title") {
                        t = h2[i].innerHTML;
                        break;
                    }
                }

https://jsfiddle.net/p76j7Lb4/
Title: Re: JScript Panel script discussion/help
Post by: zeremy on 2018-02-25 19:36:47
It is an extract from his script where  he is asking how to parse the html to get the values he wants to use.
My fiddle is just pointing out how to get the values.
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2018-02-25 22:21:25
I see the logic of the script, but how do you reference an HTML element in JScript panel? At least I'm guessing the div object is one. I'm still pretty alien to HTML, as I thought it was useless for JScript panel,
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2018-02-26 02:04:57
I see the logic of the script, but how do you reference an HTML element in JScript panel? At least I'm guessing the div object is one. I'm still pretty alien to HTML, as I thought it was useless for JScript panel,
His script is making an AJAX call to a webpage and then attempting to parse the HTML object he gets back to display the text in his theme somewhere. He's (sadly) not manipulating or displaying the HTML directly.
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2018-02-26 09:02:08
Have mercy for a non-developer, simple foobar2000 user. Learning to work with the interfaces and callbacks provided in the component documentation I was able to do wonderful things that were science fiction to me, only one year ago, but you guys are from another planet. What is an AJAX call, now?
Alright, I googled it: it's a jQuey method. So, not only HTML, but jQuery is also available in a non-browser environment such as JScript panel?
I really thought all I needed, besides the basics of jscript, was in the component docs. I'm clearly missing some big part of it.
Please enlighten me.
Title: Re: JScript Panel script discussion/help
Post by: kgena_ua on 2018-02-26 14:44:53
zeremy, thank for the fact that you always help.

OMG, I'm lost. What are you guys talking about? Is this code for the JScript panel?

Code: [Select]
                var h2 = div.getElementsByTagName("h2");	
                for (i = 0; i < h2.length; i++) {
                    if (h2[i].className == "metadata-title") {
                        t = h2[i].innerHTML;
                        break;
                    }
                }
davideleo,
this code for foo_jscript_panel or foo_uie_wsh_panel_mod.
See my topic: Biography Text, Album Info, Picture. www.last.fm
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2018-02-26 14:58:44
davideleo,
this code for foo_jscript_panel or foo_uie_wsh_panel_mod.
See my topic: Biography Text, Album Info, Picture. www.last.fm

Ok, thanks. I must admit I never checked your script. If this is an excerpt from it, I'd better download it and have a look at the whole code. Be prepared for more questions  ;)
Title: Re: JScript Panel script discussion/help
Post by: kgena_ua on 2018-02-27 19:25:15
for example, we got a review of the track
Title: Re: JScript Panel script discussion/help
Post by: firewater on 2018-02-27 20:53:50
I've been modifying an old marc2003 code I had in order for it to fit my setup, and my problem is the elapsed playback time (%playback_time% /") only updates when I refresh the panel (so for example play/pause the song). It drives me nuts, if anyone has any idea on how to fix it, please:

Code: [Select]
// ==PREPROCESSOR==
// @name "track info + seekbar + buttons"
// @author "marc2003"
// @import "%fb2k_profile_path%js_marc2003\js\lodash.min.js"
// @import "%fb2k_profile_path%js_marc2003\js\helpers.js"
// @import "%fb2k_profile_path%js_marc2003\js\panel.js"
// @import "%fb2k_profile_path%js_marc2003\js\seekbar.js"
// ==/PREPROCESSOR==

//note the buttons are white and you'd have to edit the images to change them...
var colours = {
background : _.RGB(255, 255, 255),
title : _.RGB(60, 60, 60),
artist : _.RGB(80, 80, 80),
time : _.RGB(80, 80, 80),
};

//////////////////////////////////////////////////////////////

var panel = new _.panel("track info + seekbar + buttons");
var seekbar = new _.seekbar(60, 5, 0, 20);
var buttons = new _.buttons();
var img = null;
on_playback_new_track();

buttons.update = function () {
var y = _.round((panel.h - 36) / 2);
}

function on_size() {
panel.size();
seekbar.x = panel.h + 310
seekbar.w = panel.w - panel.h - 710;
seekbar.y = (panel.h - 20) / 2;
buttons.update();
}

function on_paint(gr) {
if (fb.IsPlaying) {
img && _.drawImage(gr, img, 0, 0, panel.h, panel.h, image.centre);
        gr.GdiDrawText(_.tfe("%title%"), gdi.Font("Helvetica Bold", 16), colours.title, 82, -1, 500, 40, LEFT);
            gr.GdiDrawText(_.tfe("%artist%"), gdi.Font("Helvetica Light", 16), colours.artist, 82, 20, 500, 30, LEFT);
            gr.GdiDrawText(_.tfe("%playback_time% /"), gdi.Font("Helvetica Light", 16), colours.time, 82, 43, 110, LEFT);
gr.GdiDrawText(_.tfe("%length%"), gdi.Font("Helvetica Light", 16), colours.time, 125, 0, 60, 107, LEFT);
;
}
}

function on_playback_new_track() {
var metadb = fb.GetNowPlaying();
if (!metadb)
return;
_.dispose(img);
img = utils.GetAlbumArtV2(metadb, 0);
window.Repaint();
}

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

function on_playback_seek() {
seekbar.playback_seek();
}

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

function on_playback_pause() {
buttons.update();
window.Repaint();
}

function on_playback_starting() {
buttons.update();
window.Repaint();
}

function on_mouse_wheel(s) {
buttons.leave();
}

function on_mouse_move(x, y) {
if (buttons.move(x, y))
return;
seekbar.move(x, y);
}

function on_mouse_leave() {
buttons.leave();
}

function on_mouse_lbtn_down(x, y) {
seekbar.lbtn_down(x, y);
}

function on_mouse_lbtn_up(x, y) {
if (buttons.lbtn_up(x, y))
return;
if (seekbar.lbtn_up(x, y))
return;
fb.RunMainMenuCommand("View/Show now playing in playlist");
}

function on_mouse_rbtn_up(x, y) {
return panel.rbtn_up(x, y);
}
Title: Re: JScript Panel script discussion/help
Post by: zeremy on 2018-02-27 21:02:23
Have mercy for a non-developer, simple foobar2000 user. Learning to work with the interfaces and callbacks provided in the component documentation I was able to do wonderful things that were science fiction to me, only one year ago, but you guys are from another planet. What is an AJAX call, now?
Alright, I googled it: it's a jQuey method. So, not only HTML, but jQuery is also available in a non-browser environment such as JScript panel?
I really thought all I needed, besides the basics of jscript, was in the component docs. I'm clearly missing some big part of it.
Please enlighten me.

JScript panel is not a browser and you can't import jQuery, but it is possible to import (via ==PREPROCESSOR==)  some JavaScript utility libraries like :
https://lodash.com/ (https://lodash.com/)
http://underscorejs.org/ (http://underscorejs.org/)

As for AJAX , MordredKLB was referring to AJAX = Asynchronous JavaScript And XML (https://www.w3schools.com/xml/ajax_intro.asp) that is possible by using ActiveX object. (Microsoft.XMLHTTP)https://www.w3schools.com/xml/ajax_xmlhttprequest_create.asp (https://www.w3schools.com/xml/ajax_xmlhttprequest_create.asp)

The possibility to use ActiveX objects is documented in the wiki.
https://github.com/marc2k3/foo_jscript_panel/wiki (https://github.com/marc2k3/foo_jscript_panel/wiki)

A few other ActiveX objects (not limited to) that you may find in other jScript panel scripts are :
Scripting.FileSystemObject
WScript.Shell
Shell.Application

They are loaded in the script  (e.g for WScript.Shell)
var WshShell = new ActiveXObject("WScript.Shell");

Study the scripts from the major contributors  and you will discover them and find out how to use them.
 
Title: Re: JScript Panel script discussion/help
Post by: kgena_ua on 2018-02-27 21:08:45
my problem is the elapsed playback time (%playback_time% /") only updates when I refresh the panel

may be add
function on_playback_time(time){}
Title: Re: JScript Panel script discussion/help
Post by: Jailhouse on 2018-02-27 21:44:12
I've been modifying an old marc2003 code I had in order for it to fit my setup, and my problem is the elapsed playback time (%playback_time% /") only updates when I refresh the panel (so for example play/pause the song).

Try:
           if (fb.PlaybackLength > 0) {
                   gr.GdiDrawText(_.tfe("%playback_time% /"), gdi.Font("Helvetica Light", 16), colours.time, 82, 43, 110, LEFT);
           }

Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2018-02-27 22:02:36
may be add
function on_playback_time(time){}
Yeah, you should be able add that callback and throw a window.Repaint() in there and it should solve your problem. Like so:

Code: [Select]
function on_playback_time(time){
    window.Repaint();
}
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2018-02-27 22:36:31
JScript panel is not a browser and you can't import jQuery, but it is possible to import (via ==PREPROCESSOR==)  some JavaScript utility libraries like :
https://lodash.com/ (https://lodash.com/)
http://underscorejs.org/ (http://underscorejs.org/)

As for AJAX , MordredKLB was referring to AJAX = Asynchronous JavaScript And XML (https://www.w3schools.com/xml/ajax_intro.asp) that is possible by using ActiveX object. (Microsoft.XMLHTTP)https://www.w3schools.com/xml/ajax_xmlhttprequest_create.asp (https://www.w3schools.com/xml/ajax_xmlhttprequest_create.asp)

The possibility to use ActiveX objects is documented in the wiki.
https://github.com/marc2k3/foo_jscript_panel/wiki (https://github.com/marc2k3/foo_jscript_panel/wiki)

Thanks zeremy, now it is a bit clearer. I'm aware of the possibility to use ActiveXObjects and I've been using it myself in some scripts. Nevertheless, it's a very wide topic and I don't really know where to look for references. I've learned to use some properties and methods of the Scripting.FileSystemObject and of the WScript.Shell, only because I've seen it done in other people's scripts, but the Microsoft.XMLHTTP is totally new to me (I guess I will find an example in kgena_ua's script). Is there some online resource with a guide to ActiveXObjects? I usually end up on some microsoft doc page when I google, but they're nothing like a guide, they're basically a brief reference for the initiate.
Same thing for the libraries: I've been using the lodash library because I've seen examples in marc2000's scripts (and because it comes bundled with the sample docs of the component), but where do you learn about libraries such as the underscorjs? If I were to look for it myself, I'd be lost (thanks for the link BTW).
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2018-02-27 23:28:44
As for AJAX , MordredKLB was referring to AJAX = Asynchronous JavaScript And XML (https://www.w3schools.com/xml/ajax_intro.asp) that is possible by using ActiveX object. (Microsoft.XMLHTTP)https://www.w3schools.com/xml/ajax_xmlhttprequest_create.asp (https://www.w3schools.com/xml/ajax_xmlhttprequest_create.asp)

So, let me get this straight: are all the methods of the XMLHttpRequest object listed in the w3schools AJAX chapter, available in JScript panel as methods of the Microsoft.XMLHTTP object?
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2018-02-27 23:36:46
davideleo: I won't speak to ActiveX, but there's a whole world of libraries that Javascript developers are typically familiar with which the average person will never need to know about. Libraries like lodash and underscore are pretty common utility libraries that add extra functionality which make working with certain objects/data easier. The thing you need to be aware of is that EVERY javascript library (whether for the browser or JScript, etc.) isn't adding any new building blocks, just arranging them in ways that make things more convenient to use. This is fundamentally different than plugins for foobar or .DLLs for a c++ project.

For clarification, lodash/_ have a _.first(array, n) method which allow you to get the first n values of an array. There's no new functionality here, you could write it yourself in javascript just as easily as:
Code: [Select]
function first(array, n) {
    return array.slice(0, n);
}

That's why in my estimation js libraries are almost always overkill for JScript panels. In that lodash example there are 100+ other new methods, 99% of which you aren't going to use. Figure out what you want to do, see if somebody is doing it in a library already, and then rip off their code. :)

My theme is a massive 8k line beast. There is some functionality I wanted to implement that requires methods available in ES6 (a newer version of javascript than JScript provides). Specifically, I wanted to find keys matching a certain value in an array of JSON objects. ES6 has an array.find, but it doesn't work in JScript. Because I knew the method existed, I looked it up on MDN (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find) and if you scroll down you'll see a Polyfill. That's a piece of code that allows older browsers to implement the new functionality. I just copied that polyfill to my code, and voilá! array.find now works for me.

The JS ecosystem is vast, and ever changing. Unfortunately most of it has moved on from the IE9 browser that JScript implements. Rather than trying to learn it all (and particularly a version 7 years old), your best bet is to google around and ask in here.
Title: Re: JScript Panel script discussion/help
Post by: firewater on 2018-02-28 05:28:36
Additionally, looking for a way to have a different image on hover for these buttons:
Code: [Select]
// ==PREPROCESSOR==
// @name "Playback Buttons"
// @author "marc2003"
// @import "%fb2k_profile_path%js_marc2003\js\lodash.min.js"
// @import "%fb2k_profile_path%js_marc2003\js\helpers.js"
// @import "%fb2k_profile_path%js_marc2003\js\panel.js"
// ==/PREPROCESSOR==

var panel = new _.panel("Playback Buttons", ["custom_background"]);
var buttons = new _.buttons();
var bs = 27;

buttons.update = function () {
this.buttons.previous = new _.button(0, 0, bs, bs, {normal : "buttons\\track_previous.png"}, function () { fb.Prev(); }, "");
    this.buttons.play = new _.button(30, 0, bs, bs, {normal : !fb.IsPlaying || fb.IsPaused ? "buttons\\play.png" : "buttons\\pause.png"}, function () { fb.PlayOrPause(); }, !fb.IsPlaying || fb.IsPaused ? "" : "");
this.buttons.next = new _.button(60, 0, bs, bs, {normal : "buttons\\track_next.png"}, function () { fb.Next(); }, "");
}

function on_size() {
panel.size();
buttons.update();
}

function on_paint(gr) {
panel.paint(gr);
buttons.paint(gr);
}

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

function on_playback_pause() {
buttons.update();
window.Repaint();
}

function on_playback_starting() {
buttons.update();
window.Repaint();
}

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

function on_mouse_leave() {
buttons.leave();
}

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

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

I've been modifying an old marc2003 code I had in order for it to fit my setup, and my problem is the elapsed playback time (%playback_time% /") only updates when I refresh the panel (so for example play/pause the song).

Try:
           if (fb.PlaybackLength > 0) {
                   gr.GdiDrawText(_.tfe("%playback_time% /"), gdi.Font("Helvetica Light", 16), colours.time, 82, 43, 110, LEFT);
           }



Thanks but it doesn't work. It displays it, but still doesn't refresh.
Title: Re: JScript Panel script discussion/help
Post by: MachineHead on 2018-02-28 08:37:11
I've been modifying an old marc2003 code I had in order for it to fit my setup, and my problem is the elapsed playback time (%playback_time% /") only updates when I refresh the panel (so for example play/pause the song). It drives me nuts, if anyone has any idea on how to fix it, please:

Code: [Select]
            gr.GdiDrawText(_.tfe("%playback_time% /"), gdi.Font("Helvetica Light", 16), colours.time, 82, 43, 110, LEFT);

You're missing a coordinate in that line. Unsure if that would break stuff, but it's possible.
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2018-02-28 09:36:38
Thanks but it doesn't work. It displays it, but still doesn't refresh.
Did you see my post with the on_playback_time code? Without that callback it's never going to update unless you manually draw in a loop (which would be REALLY dumb).
Title: Re: JScript Panel script discussion/help
Post by: zeremy on 2018-02-28 17:17:16
As for AJAX , MordredKLB was referring to AJAX = Asynchronous JavaScript And XML (https://www.w3schools.com/xml/ajax_intro.asp) that is possible by using ActiveX object. (Microsoft.XMLHTTP)https://www.w3schools.com/xml/ajax_xmlhttprequest_create.asp (https://www.w3schools.com/xml/ajax_xmlhttprequest_create.asp)

So, let me get this straight: are all the methods of the XMLHttpRequest object listed in the w3schools AJAX chapter, available in JScript panel as methods of the Microsoft.XMLHTTP object?

Here is a link for the basics.
https://developer.mozilla.org/en-US/docs/Web/Guide/AJAX/Getting_Started (https://developer.mozilla.org/en-US/docs/Web/Guide/AJAX/Getting_Started)
Title: Re: JScript Panel script discussion/help
Post by: Jailhouse on 2018-02-28 20:50:15
Thanks but it doesn't work. It displays it, but still doesn't refresh.
Did you see my post with the on_playback_time code? Without that callback it's never going to update unless you manually draw in a loop (which would be REALLY dumb).

I'm also using a script based on marc2003's samples, but it doesn't call on_playback_time anywhere. (!)

My elapsed time code is in an on_paint function which came from the Seekbar sample. It turns out that Seekbar.js continually checks fb.IsPlaying and calls for a refresh if it is, obviating the use of on_playback_time. I wondered what I was doing right....

@firewater   Sorry for wasting your time.
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2018-02-28 21:43:58
My elapsed time code is in an on_paint function which came from the Seekbar sample. It turns out that Seekbar.js continually checks fb.IsPlaying and calls for a refresh if it is, obviating the use of on_playback_time. I wondered what I was doing right....
I haven't looked at that code, but I assume it was doing something similar to:
Code: [Select]
setInterval(function () {
    if (fb.IsPlaying) window.Repaint();
},1000);
That's fine and will obviously work, but the callback is a much cleaner and more accurate way to do it and will have less wasted repaints (which are probably trivial in most cases/themes, but a full repaint for me can take 30-40ms).
Title: Re: JScript Panel script discussion/help
Post by: Jailhouse on 2018-02-28 23:57:22
I haven't looked at that code, but I assume it was doing something similar to:
Code: [Select]
setInterval(function () {
    if (fb.IsPlaying) window.Repaint();
},1000);
That's fine and will obviously work, but the callback is a much cleaner and more accurate way to do it and will have less wasted repaints (which are probably trivial in most cases/themes, but a full repaint for me can take 30-40ms).

It does that, save for more tests in the "if" and "150" instead of the "1000" in your example. I assume that's milliseconds, and that the smaller interval is needed for smoothly animating the moving seek button.

I'll keep the callback in mind for when I rewrite my scripts. Thanks for the lesson!
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2018-03-01 01:14:08
Well you do bring up an interesting point. If you've just got a time counter (which appeared to be what @firewater was doing) then on_playback_time is what you want to use. If you're trying to animate a progress bar, you very well might want to update it more frequently.

I actually do just this in my script, and I figured it would be cool to smoothly fill the progress bar 1 pixel at a time (if possible). In on_playback_new_track() I call a function I wrote called SetProgressBarRefresh():

Code: [Select]
function SetProgressBarRefresh()
{
if (fb.PlaybackLength > 0) {
        t_interval = Math.abs(Math.ceil(1000/(progressBarWidth/fb.PlaybackLength))); // we want to update the progress bar for every pixel so divide total time by number of pixels in progress bar
        if (t_interval < 25) {
            t_interval = 25;   // if interval is too low your refreshes can stack up. Refreshing 40x a second max seems reasonable
        }

if (showDebugTiming)
console.log("Progress bar will update every " + t_interval + "ms or " + 1000/t_interval + " times per second.");

timer && window.ClearInterval(timer);
timer = null;
if (!fb.IsPaused) { // only create timer if actually playing
timer = window.SetInterval(function() {
refresh_seekbar();
}, t_interval);
}
}
}

refreshProgressBar() {
    window.RepaintRect(<<exact dimensions of my progressBar so I don't redraw more stuff>>)
}
timer and t_interval are global variables. progressBarWidth is the width of the progress bar I want to fill. I only redraw the progressBar itself because there's a lot of other crap in my jscript panel. If the only thing in your script is a progress bar then who cares... just to windowRepaint().

This isn't complete because you'll need to clear the timer when the playback stops, and also when paused. You'd also need to call SetProgressBarRefresh in on_size() and when unpausing. There's probably some more stuff too, but that's how I do it. Obviously the draw code is up to you, but Math.floor(progressBarLength * fb.PlaybackTime / fb.PlaybackLength) is the way to calculate the number of pixels of your progressbar to fill.
Title: Re: JScript Panel script discussion/help
Post by: Jailhouse on 2018-03-02 02:23:33
Math.floor(progressBarLength * fb.PlaybackTime / fb.PlaybackLength) is the way to calculate the number of pixels of your progressbar to fill.

It's Math.ceil in the posted code. Is that what you meant?

I've added your post to my samples/notes library for future use. Thanks for another lesson.
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2018-03-02 10:03:18
Well when calculating the interval between refreshes I probably wanted the number to be bigger rather than smaller so that when the interval elapsed you could be sure it was always adding at least one to the fill.

Math.floor rounds down, Math.ceil rounds up, and Math.round roundest to the nearest. When actually drawing a progress bar you probably want to always round one direction or the other, but it doesn't really matter which.
Title: Re: JScript Panel script discussion/help
Post by: grimes on 2018-03-08 13:12:02
Does a Coverflow script for newest JScript Panel exist? The only script I found is: https://br3tt.deviantart.com/art/WSH-CoverFlow-290788027 by Br3tt on Deviantart, but this is only for the old WSH panel mod.
Title: Re: JScript Panel script discussion/help
Post by: kgena_ua on 2018-03-09 16:51:41
Does a Coverflow script for newest JScript Panel exist? The only script I found is: https://br3tt.deviantart.com/art/WSH-CoverFlow-290788027 by Br3tt on Deviantart, but this is only for the old WSH panel mod.

it is necessary to replace window.GetColor by window.GetColour
Code: [Select]
    if(g_instancetype == 0) { // CUI
        g_textcolor = window.GetColourCUI(ColorTypeCUI.text);
        g_textcolor_sel = window.GetColourCUI(ColorTypeCUI.selection_text);
        g_textcolor_hl = window.GetColourCUI(ColorTypeCUI.active_item_frame);
        g_backcolor = window.GetColourCUI(ColorTypeCUI.background);
        g_backcolor_sel = window.GetColourCUI(ColorTypeCUI.selection_background);
    } else if(g_instancetype == 1) { // DUI
        g_textcolor = window.GetColourDUI(ColorTypeDUI.text);
        g_textcolor_sel = window.GetColourDUI(ColorTypeDUI.selection);
        g_textcolor_hl = window.GetColourDUI(ColorTypeDUI.highlight);
        g_backcolor = window.GetColourDUI(ColorTypeDUI.background);
        g_backcolor_sel = g_textcolor_sel;
    };

and replace fb.IsAutoPlaylist by plman.IsAutoPlaylist
Code: [Select]
    _child01.AppendMenuItem((plman.IsAutoPlaylist(panel.active_playlist))?MF_DISABLED|MF_GRAYED:MF_STRING, 1000, "Remove");
    _child02.AppendTo(_child01, MF_STRING, "Add to...");

    _child02.AppendMenuItem(MF_STRING, 2000, "a New playlist...");
    _child02.AppendMenuItem(MF_SEPARATOR, 0, "");
    var pl_count = fb.PlaylistCount;
    for(var i=0;i<pl_count;i++) {
        if(i!=panel.active_playlist && !plman.IsAutoPlaylist(i)) {       
            _child02.AppendMenuItem(MF_STRING, 2001+i, plman.GetPlaylistName(i));
        };
    };
      
Title: Re: JScript Panel script discussion/help
Post by: grimes on 2018-03-09 18:08:18
Works, thanks!
Title: Re: JScript Panel script discussion/help
Post by: kgena_ua on 2018-03-09 18:42:52
what about "EnableMenuItem(id_or_pos, enable, bypos = false)" in jscript panel. Can not find.
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2018-03-09 18:46:30
See https://github.com/marc2k3/foo_jscript_panel/wiki/Breaking-Changes#v203
Title: Re: JScript Panel script discussion/help
Post by: kgena_ua on 2018-03-09 18:50:40
why ....
TheQwertiest, thanks
Title: Re: JScript Panel script discussion/help
Post by: kgena_ua on 2018-03-11 18:06:11
marc2k3, is it possible to return EnableMenuItem
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2018-03-12 02:04:34
marc2k3, is it possible to return EnableMenuItem
There's no need for EnableMenuItem, and it was rightly removed.

Replace your EnableMenuItem calls with something like this:
Code: [Select]
_menu.AppendMenuItem(pref.displayArt ? MF_STRING : MF_DISABLED, 5, 'Display Album Art');
Title: Re: JScript Panel script discussion/help
Post by: kgena_ua on 2018-03-14 12:47:33
marc2k3, is it possible to return EnableMenuItem
There's no need for EnableMenuItem, and it was rightly removed.

Replace your EnableMenuItem calls with something like this:
Code: [Select]
_menu.AppendMenuItem(pref.displayArt ? MF_STRING : MF_DISABLED, 5, 'Display Album Art');

I know that.
I understand if new functions are added that give new opportunities.
but why remove the old convenient features.
I do not understand
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2018-03-14 13:46:04
I know that.
I understand if new functions are added that give new opportunities.
but why remove the old convenient features.
I do not understand
Because it is not really 'convenient', but rather useless. EnableMenuItem would be only useful if the menu could be kept open after clicking on it (i.e. dynamically update a currently open menu), which is not possible in JScript anyway. It would be a different case, if there was some unique functionality that is only available through EnableMenuItem, but all of it's functionality is available through AppendMenuItem flags.

In the old wsh_panel component there were quite a few methods with duplicated functionality, which made scripting interface unnecessary bloated. Removing them allows for easier component development and maintenance.

PS: And I abhor the 'Microsoft' way - indefinite support of the deprecated functionality, which causes a lot of their API to be over-complicated because of the compatibility reasons.
Title: Re: JScript Panel script discussion/help
Post by: colagen on 2018-03-24 13:03:15
Hi,

With the latest jscript panel release, there is a new dodragDrop functionality, which is great, now we can do drag and drop between jscript panels (for the moment, you can't do drag and drop within the same panel and outside the panel at the same time, you have to choose between both actions, but it's the only flaw)

My issue is that an empty semi-transparent rectangle is drawn while dragging tracks next to the mouse pointer, it look a little bit buggy (on windows, this rectangle contain a preview of the dragged content, for ex file icons, but here the rectangle is just empty), is there a way to remove this rectangle ?

(https://thumb.ibb.co/iKSX5S/Untitled_1.png) (https://ibb.co/iKSX5S)
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2018-03-24 15:20:09
for the moment, you can't do drag and drop within the same panel and outside the panel at the same time, you have to choose between both actions, but it's the only flaw
Well, that is not really true, since in my playlist script I'm using drag-n-drop API for both actions =)
I.e. you just have to implement it correctly :P

My issue is that an empty semi-transparent rectangle is drawn while dragging tracks next to the mouse pointer, it look a little bit buggy (on windows, this rectangle contain a preview of the dragged content, for ex file icons, but here the rectangle is just empty), is there a way to remove this rectangle ?
Currently, image for dragging is generated by fb2k interface itself, so this is the intended behaviour of JScript (the square does not look as ugly on my system though (Win7/Win10), it is also quite weird that you don't have a cursor displayed in that drag). I will try to investigate if it's possible to make it prettier (e.g. like CUI playlist) and in case of success will present the results to @marc2003 for approval.

[EDIT] Darn, if we want to change the drag image, the whole image must be generated manually (aero/glass effects and all)...
[EDIT2] Hm, I think it's possible to add the text to that rectangle without much hassle...
Title: Re: JScript Panel script discussion/help
Post by: colagen on 2018-03-24 23:52:28
Well, that is not really true, since in my playlist script I'm using drag-n-drop API for both actions =)
I.e. you just have to implement it correctly :P

Do you have a link to this playlist script, so i can look to the code ? I tried to download and install CaTRoX_QWR from the link in your signature, but i didn't find any external drag and drop.
Currently, the best i'm able to do is to do an internal drag and drop by default, and switch to an external drag and drop when the cursor goes out of the panel limits. But i can't switch back to a internal drag and drop if i move the cursor back into the panel
Title: Re: JScript Panel script discussion/help
Post by: colagen on 2018-03-26 08:08:51
Currently, image for dragging is generated by fb2k interface itself, so this is the intended behaviour of JScript (the square does not look as ugly on my system though (Win7/Win10), it is also quite weird that you don't have a cursor displayed in that drag). I will try to investigate if it's possible to make it prettier (e.g. like CUI playlist) and in case of success will present the results to @marc2003 for approval.

Thanks for taking a look! About the cursor, it's just because my screen capture tool doesn't show the cursor. The cursor is there
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2018-03-26 10:20:17
Do you have a link to this playlist script, so i can look to the code ? I tried to download and install CaTRoX_QWR from the link in your signature, but i didn't find any external drag and drop.
Currently, the best i'm able to do is to do an internal drag and drop by default, and switch to an external drag and drop when the cursor goes out of the panel limits. But i can't switch back to a internal drag and drop if i move the cursor back into the panel
I have yet to release the updated theme (since I'm waiting for @WilB :P), but you can get it manually from git:
 - Download repo as zip.
 - Extract themes folder content to ...\foobar2000\themes\CaTRoX\ (e.g. CaTRoX_QWR\theme\Scripts > ...\foobar2000\themes\CaTRoX\Scripts)
 - Import .fcl.

All the relevant drag-n-drop code is in Playlist script (https://github.com/TheQwertiest/CaTRoX_QWR/blob/master/theme/Scripts/Panel_Playlist.js):
https://github.com/TheQwertiest/CaTRoX_QWR/blob/a1be1e922542193ba7ca0cf9cbf17535f9adfe63/theme/Scripts/Panel_Playlist.js#L938
https://github.com/TheQwertiest/CaTRoX_QWR/blob/a1be1e922542193ba7ca0cf9cbf17535f9adfe63/theme/Scripts/Panel_Playlist.js#L961
https://github.com/TheQwertiest/CaTRoX_QWR/blob/a1be1e922542193ba7ca0cf9cbf17535f9adfe63/theme/Scripts/Panel_Playlist.js#L973
https://github.com/TheQwertiest/CaTRoX_QWR/blob/a1be1e922542193ba7ca0cf9cbf17535f9adfe63/theme/Scripts/Panel_Playlist.js#L1017
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2018-03-26 14:33:23
To anyone using IntelliJ WebStorm, IDEA or Visual Studio Code to create/edit scripts:
I've updated JSDoc'd version of JScript's interface.txt (https://github.com/marc2k3/foo_jscript_panel/blob/master/foo_jscript_panel/docs/Interfaces.txt), which can be used as a plugin/library in WebStorm/IDEA/VisualCode.
This will remove most of 'undefined symbol' warnings and will also provide some type checks when using JScript interface.

Instructions:
Title: Re: JScript Panel script discussion/help
Post by: colagen on 2018-04-01 14:05:38
[EDIT] Darn, if we want to change the drag image, the whole image must be generated manually (aero/glass effects and all)...
[EDIT2] Hm, I think it's possible to add the text to that rectangle without much hassle...

Hi again,
So in the end, you didn't manage to find a way to remove this rectangle, or replace it with something which would make more sense ? Generating a gdi.Image for each drag and drop is completely fine, then it's up to the coder to do something which look nice/is useful in term of UI.

(About the drag and drop inside a panel / outside a panel, i managed to install your catrox theme, and yes, your code do what i'm trying to achieve in term of behavior, so i'm convinced now : ) i need to clean up my drag and drop code to make it work like yours.)
Title: Re: JScript Panel script discussion/help
Post by: zaynmalikvn93 on 2018-04-01 15:03:40
I am newbie to Jscript Panel so I have some questions:
1. I want to create a panel that will run external program (Spek) in that panel, and spek will show the spectrogram of file which is playing? Can I do it?
2. I am searching spectrogram seekbar and after lurking around I find that JScript Panel can create that. Can anyone help me to do that...

Thank you. Sorry for my bad English, it's not my native language
Title: Re: JScript Panel script discussion/help
Post by: nikolai4ik on 2018-04-03 19:42:52
Apparently I was on a very old version 1.3.0 and decided to update just now. Unfortunately a ton of scripts in my skin broke. I fixed some errors regarding fb.trace and getcolorcui replacements but this one I can't beat:
Code: [Select]
Error: JScript Panel v2.1.0.2 (track info + seekbar + buttons by marc2003)
Microsoft JScript runtime error:
Object doesn't support this property or method
File: C:\Users\3\AppData\Roaming\foobar2000\js_marc2003\js\panel.js
Line: 65, Col: 5
<source text only available at compile time>


which is    if (font) {

Please help  :(
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2018-04-03 23:39:11
Apparently I was on a very old version 1.3.0 and decided to update just now. Unfortunately a ton of scripts in my skin broke. I fixed some errors regarding fb.trace and getcolorcui replacements but this one I can't beat:
Those scripts have been updated by marc. The one you want is located in: %appdata%\foobar2000\user-components\foo_jscript_panel\samples\complete\js\panel.js

Use that instead of the one you have installed to that location.
Title: Re: JScript Panel script discussion/help
Post by: Climhazzard1997 on 2018-04-04 17:44:22
To anyone using IntelliJ WebStorm, IDEA or Visual Studio Code to create/edit scripts:
I've updated JSDoc'd version of JScript's interface.txt (https://github.com/marc2k3/foo_jscript_panel/blob/master/foo_jscript_panel/docs/Interfaces.txt), which can be used as a plugin/library in WebStorm/IDEA/VisualCode.
This will remove most of 'undefined symbol' warnings and will also provide some type checks when using JScript interface.

Instructions:
  • Download all files from >>git<< (https://github.com/TheQwertiest/CaTRoX_QWR/tree/master/jscript_api) and put them in some folder.
    • IntelliJ: File > Settings > Languages > JavaScript > Libraries > Add... > + > Attach Directories... > Choose folder from the previous step
    • Visual Studio Code: instructions (https://stackoverflow.com/questions/45332052/how-to-add-an-api-to-visual-studio-code)

You are doing god's work, my friend. Thank you so much.
Title: Re: JScript Panel script discussion/help
Post by: nikolai4ik on 2018-04-04 17:58:11
Apparently I was on a very old version 1.3.0 and decided to update just now. Unfortunately a ton of scripts in my skin broke. I fixed some errors regarding fb.trace and getcolorcui replacements but this one I can't beat:
Those scripts have been updated by marc. The one you want is located in: %appdata%\foobar2000\user-components\foo_jscript_panel\samples\complete\js\panel.js

Use that instead of the one you have installed to that location.
Thanks, I had an old path. Managed to salvage all but one panel.
I also moved to a JS version of smooth playlist (was using WSH), does anyone know how to alight text to the middle of the row vertically?
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2018-04-04 19:12:03
You'll need to find the DrawString call for those texts, and set the last parameter to be: StringFormat(0, 1)

I've found it's easier to set up objects to make handling those StringFormat calls easier, so I have this in my code:
Code: [Select]
var StringAlignment = {Near: 0, Center: 1, Far: 2};
// then you can use it like
gr.DrawString("blah", font, color, x, y, w, h, StringFormat(StringAlignment.Near, StringAlignment.Center));

// or
var leftCenter = StringFormat(StringAlignment.Near, StringAlignment.Center);
gr.DrawString("blah", font, color, x, y, w, h, leftCenter);
You'll also need to make sure the height for the text is the entire height of the row, and not just tall enough for the text.
Title: Re: JScript Panel script discussion/help
Post by: nikolai4ik on 2018-04-05 20:55:27
You'll need to find the DrawString call for those texts, and set the last parameter to be: StringFormat(0, 1)

I've found it's easier to set up objects to make handling those StringFormat calls easier, so I have this in my code:
Code: [Select]
var StringAlignment = {Near: 0, Center: 1, Far: 2};
// then you can use it like
gr.DrawString("blah", font, color, x, y, w, h, StringFormat(StringAlignment.Near, StringAlignment.Center));

// or
var leftCenter = StringFormat(StringAlignment.Near, StringAlignment.Center);
gr.DrawString("blah", font, color, x, y, w, h, leftCenter);
You'll also need to make sure the height for the text is the entire height of the row, and not just tall enough for the text.
Thanks but I couldn't get it to work :P All I managed was to move heart icon via WSHplaylist.js :D
Title: Re: JScript Panel script discussion/help
Post by: nikolai4ik on 2018-04-08 07:16:23
Another question, is there another option apart from fb.GetFocusItem() and fb.GetNowPlaying()?
I want to add tracks to queue with a single MMB click, fb.RunContextCommandWithMetadb("Add to playback queue",fb.GetFocusItem()) needs 2 clicks, first one to select the track with LMB and only then MMB to add to queue.
Title: Re: JScript Panel script discussion/help
Post by: Jamie G on 2018-04-08 13:42:29
Hi,

I hope one of you kind folk can help. I'm a complete coding novice, but have been making small changes to the fantastic work done by others. Thing is, there's something i want to add but have hit a brick wall.

I'd like to add different images to the left of time elapsed on the seekbar depending on the codec of the track playing. So an image for MP3, a different one for FLAC etc etc, you get the picture. Along with that, another image that appears to the left of that only if the track is greater than 16-bit. I've found scripts that do similar, but i can't get my head around what is required from them to achieve this. I've even attempted merging them into my existing edits, but have had nothing but inevitable errors  ::) A lot of Googling and some headaches later, i've decided to admit defeat and ask those that know best!

So if anyone wouldn't mind a bit of hand-holding with a complete newb it'd be very very much appreciated...just assume you're talking to a child  :)) I'm here to learn and improve my knowledge.

Code below and screenshot attached and again, thanks for any assistance guys.

Code: [Select]
// ==PREPROCESSOR==
// @name "Track Info + Seekbar + Buttons"
// @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\seekbar.js"
// ==/PREPROCESSOR==

var colours = {
background : _.RGB(30, 30, 30),
title : _.RGB(255, 255, 255),
artist : _.RGB(240, 240, 240),
    codec : _.RGB(180, 180, 180),
album : _.RGB(180, 180, 180),
time : _.RGB(240, 240, 240),
seekbar_background : _.RGB(160, 160, 160),
seekbar_progress : _.RGB(255, 255, 255),
seekbar_knob : _.RGB(0, 120, 215)
};

var tfo = {
artist : fb.TitleFormat('%artist%'),
title : fb.TitleFormat('%title%'),
    codec : fb.TitleFormat('%codec%'),
album : fb.TitleFormat('%album%'),
playback_time : fb.TitleFormat('%playback_time%  '),
length : fb.TitleFormat('  %length%')
};

//////////////////////////////////////////////////////////////

var panel = new _.panel();
var seekbar = new _.seekbar(0, 0, 0, 0);
var buttons = new _.buttons();
var img = null;
var bs = _.scale(30);
on_playback_new_track(fb.GetNowPlaying());

buttons.update = function () {
var y = Math.round((panel.h - bs) / 1.7);
this.buttons.stop = new _.button(panel.w - LM - (bs * 13.0), y, bs, bs, {normal : 'buttons\\stop_grey_min.png'}, function () { fb.Stop(); }, 'Stop');
this.buttons.previous = new _.button(panel.w - LM - (bs * 11.7), y, bs, bs, {normal : 'buttons\\back_grey_min.png'}, function () { fb.Prev(); }, 'Previous');
this.buttons.play = new _.button(panel.w - LM - (bs * 10.4), y, bs, bs, {normal : !fb.IsPlaying || fb.IsPaused ? 'buttons\\play_grey_min.png' : 'buttons\\pause_grey_min.png'}, function () { fb.PlayOrPause(); }, !fb.IsPlaying || fb.IsPaused ? 'Play' : 'Pause');
this.buttons.next = new _.button(panel.w - LM - (bs * 9.1), y, bs, bs, {normal : 'buttons\\next_grey_min.png'}, function () { fb.Next(); }, 'Next');
this.buttons.random = new _.button(panel.w - LM - (bs * 4.9), y, bs, bs, {normal : 'buttons\\shuffle_grey_min.png'}, function () { fb.Random(); }, 'Random');
this.buttons.console = new _.button(panel.w - LM - (bs * 3.6), y, bs, bs, {normal : 'buttons\\console_grey_min.png'}, function () { fb.ShowConsole(); }, 'Console');
this.buttons.search = new _.button(panel.w - LM - (bs * 2.3), y, bs, bs, {normal : 'buttons\\search_grey_min.png'}, function () { fb.RunMainMenuCommand('Library/Search'); }, 'Library Search');
this.buttons.preferences = new _.button(panel.w - LM - bs, y, bs, bs, {normal : 'buttons\\settings_grey_min.png'}, function () { fb.ShowPreferences(); }, 'Preferences');
   
}

function on_size() {
panel.size();
seekbar.x = Math.round(panel.w * 0.32);
seekbar.w = panel.w - seekbar.x - _.scale(500);
seekbar.h = _.scale(12);
seekbar.y = (panel.h - seekbar.h) / 2;
buttons.update();
}

function on_paint(gr) {
gr.FillSolidRect(0, 0, panel.w, panel.h, colours.background);
buttons.paint(gr);
gr.FillSolidRect(seekbar.x, seekbar.y, seekbar.w + _.scale(6), seekbar.h, colours.seekbar_background);
if (fb.IsPlaying) {
if (img) {
_.drawImage(gr, img, 0, 0, panel.h, panel.h, image.centre);
}
gr.GdiDrawText(tfo.title.Eval(), panel.fonts.title, colours.title, panel.h + 10, 0, seekbar.x - panel.h - _.scale(60), panel.h * 0.4, LEFT);
gr.GdiDrawText(tfo.artist.Eval(), panel.fonts.normal, colours.artist, panel.h + 10, panel.h * 0.3, seekbar.x - panel.h - _.scale(60), panel.h * 0.4, LEFT);
gr.GdiDrawText(tfo.album.Eval(), panel.fonts.normal, colours.album, panel.h + 10, panel.h * 0.3, seekbar.x - panel.h - _.scale(60), panel.h * 1.0, LEFT);
        gr.GdiDrawText(tfo.codec.Eval(), panel.fonts.normal, colours.codec, panel.h + 500, panel.h * 0.3, seekbar.x - panel.h - _.scale(60), panel.h * 0.4, LEFT);
gr.SetSmoothingMode(2);
if (fb.PlaybackLength > 0) {
var pos = seekbar.pos();
gr.FillSolidRect(seekbar.x, seekbar.y, pos, seekbar.h, colours.seekbar_progress);
gr.FillSolidRect(seekbar.x + pos, seekbar.y, _.scale(6), seekbar.h, colours.seekbar_knob);
gr.GdiDrawText(tfo.playback_time.Eval(), panel.fonts.normal, colours.time, seekbar.x - _.scale(45), 0, _.scale(45), panel.h, RIGHT);
gr.GdiDrawText(tfo.length.Eval(), panel.fonts.normal, colours.time, seekbar.x + seekbar.w + _.scale(6), 0, _.scale(45), panel.h, LEFT);
}
}
gr.DrawRect(seekbar.x, seekbar.y, seekbar.w + _.scale(6), seekbar.h, 1, colours.seekbar_progress);
}

function on_playback_new_track(metadb) {
if (!metadb) {
return;
}
_.dispose(img);
img = utils.GetAlbumArtV2(metadb, 0);
window.Repaint();
}

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

function on_playback_seek() {
seekbar.playback_seek();
}

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

function on_playback_pause() {
buttons.update();
window.Repaint();
}

function on_playback_starting() {
buttons.update();
window.Repaint();
}

function on_mouse_wheel(s) {
if (seekbar.wheel(s)) {
return;
}
if (s == 1) {
fb.VolumeUp();
} else {
fb.VolumeDown();
}
}

function on_mouse_move(x, y) {
if (buttons.move(x, y)) {
return;
}
seekbar.move(x, y);
}

function on_mouse_leave() {
buttons.leave();
}

function on_mouse_lbtn_down(x, y) {
seekbar.lbtn_down(x, y);
}

function on_mouse_lbtn_up(x, y) {
if (buttons.lbtn_up(x, y)) {
return;
}
if (seekbar.lbtn_up(x, y)) {
return;
}
fb.RunMainMenuCommand('View/Show now playing in playlist');
}

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

}
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2018-04-09 14:13:16
Hi again,
So in the end, you didn't manage to find a way to remove this rectangle, or replace it with something which would make more sense ? Generating a gdi.Image for each drag and drop is completely fine, then it's up to the coder to do something which look nice/is useful in term of UI.
I kinda forgot about it =)
I will work on it a bit later, when I catch up with some IRL stuff...

(About the drag and drop inside a panel / outside a panel, i managed to install your catrox theme, and yes, your code do what i'm trying to achieve in term of behavior, so i'm convinced now : ) i need to clean up my drag and drop code to make it work like yours.)
Glad that it worked out ;)

You are doing god's work, my friend. Thank you so much.
You are welcome ;)

Another question, is there another option apart from fb.GetFocusItem() and fb.GetNowPlaying()?
I want to add tracks to queue with a single MMB click, fb.RunContextCommandWithMetadb("Add to playback queue",fb.GetFocusItem()) needs 2 clicks, first one to select the track with LMB and only then MMB to add to queue.
Not entirely sure what's the problem, you can do all of this in one call. Smth like this:
Code: [Select]
function on_mouse_mbtn_down(x,y,m) {
    var item_idx;   
    ...
    // Calculate item index
    ...
    plman.SetPlaylistFocusItem(plman.ActivePlaylist, item_idx);
    plman.AddPlaylistItemToPlaybackQueue(plman.ActivePlaylist, item_idx);
}
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2018-04-09 17:47:50
I'd like to add different images to the left of time elapsed on the seekbar depending on the codec of the track playing. So an image for MP3, a different one for FLAC etc etc, you get the picture. Along with that, another image that appears to the left of that only if the track is greater than 16-bit. I've found scripts that do similar, but i can't get my head around what is required from them to achieve this. I've even attempted merging them into my existing edits, but have had nothing but inevitable errors  ::) A lot of Googling and some headaches later, i've decided to admit defeat and ask those that know best!
I'm not going to do all the heavy lifting for you, but I'll show you what I've done to accomplish something similar. Some of this code was written years ago, and the style may not be great, so change it as needed.

First off I'm assuming you have the images you want to display already in a folder somewhere. Let's call it /images/codecs

At the top of your file where you setup your globals:
Code: [Select]
var mediaTypeImg = null;
var pref = {};

pref.codec_base = fb.ProfilePath + 'images/codecs';

Code: [Select]
// gets the correct image
function LoadMediaTypeImage() {
_.dispose(mediaTypeImg);
if (pref.show_codec_img) {
codec = fb.TitleFormat("[%codec%]").Eval();
switch (codec) {
case "DTS":
mediaTypeImg = gdi.Image(pref.codec_base+"DTS.png");
break;
case "ATSC A/52":
mediaTypeImg = gdi.Image(pref.codec_base+"Dolby Digital.png");
break;
case "FLAC":
mediaTypeImg = gdi.Image(pref.codec_base+"FLAC.png");
break;
case "Vorbis":
mediaTypeImg = gdi.Image(pref.codec_base+"Ogg.png");
break;
case "MP3":
mediaTypeImg = gdi.Image(pref.codec_base+"mp3.png");
break;
case "default":
console.log("Unknown codec: "+codec);
break;
}
}
return;
}

Then in your on_playback_new_track before window.Repaint(); call LoadMediaTypeImage(), and dispose the mediaTypeImg in on_playback_stop()

Now all you need to do is add the code to display the image in your on_paint callback which should be fairly trivial. Just do an:
Code: [Select]
// you'll need to figure out what the x, y, w, and h should be
if (mediaTypeImg) {
    gr.DrawImage(mediaTypeImg, x, y, w, h, 0, 0, mediaTypeImg.Width, mediaTypeImg.Height, 0);
}
If you want to check for 24-bit or whatever you can also do that in the LoadMediaTypeImg function and only set that image if bit-depth > 16.

Hope that helps.
Title: Re: JScript Panel script discussion/help
Post by: nikolai4ik on 2018-04-09 20:37:24
Another question, is there another option apart from fb.GetFocusItem() and fb.GetNowPlaying()?
I want to add tracks to queue with a single MMB click, fb.RunContextCommandWithMetadb("Add to playback queue",fb.GetFocusItem()) needs 2 clicks, first one to select the track with LMB and only then MMB to add to queue.
Not entirely sure what's the problem, you can do all of this in one call. Smth like this:
Code: [Select]
function on_mouse_mbtn_down(x,y,m) {
    var item_idx;   
    ...
    // Calculate item index
    ...
    plman.SetPlaylistFocusItem(plman.ActivePlaylist, item_idx);
    plman.AddPlaylistItemToPlaybackQueue(plman.ActivePlaylist, item_idx);
}
Thanks for your reply! It adds track #1 of current playlist to the queue no matter which track I click on though.
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2018-04-09 21:50:12
Thanks for your reply! It adds track #1 of current playlist to the queue no matter which track I click on though.
Welp, that's because you have to implement "// Calculate item index" part yourself :P
Title: Re: JScript Panel script discussion/help
Post by: Jamie G on 2018-04-10 15:40:00
I'd like to add different images to the left of time elapsed on the seekbar depending on the codec of the track playing. So an image for MP3, a different one for FLAC etc etc, you get the picture. Along with that, another image that appears to the left of that only if the track is greater than 16-bit. I've found scripts that do similar, but i can't get my head around what is required from them to achieve this. I've even attempted merging them into my existing edits, but have had nothing but inevitable errors  ::) A lot of Googling and some headaches later, i've decided to admit defeat and ask those that know best!
I'm not going to do all the heavy lifting for you, but I'll show you what I've done to accomplish something similar. Some of this code was written years ago, and the style may not be great, so change it as needed.

First off I'm assuming you have the images you want to display already in a folder somewhere. Let's call it /images/codecs

At the top of your file where you setup your globals:
Code: [Select]
var mediaTypeImg = null;
var pref = {};

pref.codec_base = fb.ProfilePath + 'images/codecs';

Code: [Select]
// gets the correct image
function LoadMediaTypeImage() {
_.dispose(mediaTypeImg);
if (pref.show_codec_img) {
codec = fb.TitleFormat("[%codec%]").Eval();
switch (codec) {
case "DTS":
mediaTypeImg = gdi.Image(pref.codec_base+"DTS.png");
break;
case "ATSC A/52":
mediaTypeImg = gdi.Image(pref.codec_base+"Dolby Digital.png");
break;
case "FLAC":
mediaTypeImg = gdi.Image(pref.codec_base+"FLAC.png");
break;
case "Vorbis":
mediaTypeImg = gdi.Image(pref.codec_base+"Ogg.png");
break;
case "MP3":
mediaTypeImg = gdi.Image(pref.codec_base+"mp3.png");
break;
case "default":
console.log("Unknown codec: "+codec);
break;
}
}
return;
}

Then in your on_playback_new_track before window.Repaint(); call LoadMediaTypeImage(), and dispose the mediaTypeImg in on_playback_stop()

Now all you need to do is add the code to display the image in your on_paint callback which should be fairly trivial. Just do an:
Code: [Select]
// you'll need to figure out what the x, y, w, and h should be
if (mediaTypeImg) {
    gr.DrawImage(mediaTypeImg, x, y, w, h, 0, 0, mediaTypeImg.Width, mediaTypeImg.Height, 0);
}
If you want to check for 24-bit or whatever you can also do that in the LoadMediaTypeImg function and only set that image if bit-depth > 16.

Hope that helps.

Thanks so much for taking the time to give some advice and reply Mordred, and yes I'd certainly rather do the bulk of it myself. How else will I learn!? I will have a proper go at getting it to work at the weekend once I have the time (can see it taking a while!)

I may ask some seemingly stupid questions though...I hope that's ok? (total novice remember).

So the variables can be added below the existing ones in my code? (i.e. before the buttons.update) The code layout is split into sections yes?

Then in your on_playback_new_track before window.Repaint(); call LoadMediaTypeImage(), and dispose the mediaTypeImg in on_playback_stop() I'm sure this probably is easy, but it has thrown me a bit!

Thanks, and again sorry for the probably ridiculously obvious questions. Its very difficult to find much online about how these work though.

Appreciate it Mordred


Jamie
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2018-04-10 23:34:29
Thanks so much for taking the time to give some advice and reply Mordred, and yes I'd certainly rather do the bulk of it myself. How else will I learn!? I will have a proper go at getting it to work at the weekend once I have the time (can see it taking a while!)

I may ask some seemingly stupid questions though...I hope that's ok? (total novice remember).

So the variables can be added below the existing ones in my code? (i.e. before the buttons.update) The code layout is split into sections yes?
There are other variables declared in you script, you can just add them there. I'm confused what you mean by code being split into sections. It's split into functions. I know you said you're new to all of this, so it might be worthwhile checking out a super basic javascript tutorial just so you understand a little bit more about how all this works.

Quote
Then in your on_playback_new_track before window.Repaint(); call LoadMediaTypeImage(), and dispose the mediaTypeImg in on_playback_stop() I'm sure this probably is easy, but it has thrown me a bit!
i.e. just do:
Code: [Select]
function on_playback_new_track(metadb) {
if (!metadb) {
return;
}
_.dispose(img);
img = utils.GetAlbumArtV2(metadb, 0);
LoadMediaTypeImage();
window.Repaint();
}
And just toss a _.dispose(mediaTypeImg);  into your on_playback_stop() function.
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2018-04-12 16:53:05
I've got a playlist in my theme (based on CatRox) and I had a crazy idea that I'm not sure is possible. What I'd like is to turn certain strings in the playlist into buttons (I know how to do this part), which when clicked on will populate a playlist. I.e. Where I list the Artist in the playlist if you clicked on the artist name, it would populate a playlist with all songs from that artist, and set it to active. It'd be like playlist hyperlinks.

Is it possible to create/populate a playlist based on strings from jscript? I confess I haven't really looked into this, just hoping someone can save me some time and trial/error here.
Title: Re: JScript Panel script discussion/help
Post by: zeremy on 2018-04-12 17:17:12
You could create an autoplaylist
  plman.CreateAutoPlaylist  , using the string in the query and then switch to that playlist.
You can find a sample in marc2003 samples,  autoplaylist.txt and the code in list.js
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2018-04-12 17:21:02
One thing though: autoplaylists are read-only, so you'll have to copy it, if you want to have ability to edit it afterwords.
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2018-04-12 17:26:01
One thing though: autoplaylists are read-only, so you'll have to copy it, if you want to have ability to edit it afterwords.
I'm assuming you mean I can't edit it from jscript. Can I at least delete the auto-playlist? I'd hate to have dozens of these things clogging up my playlists dropdown.
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2018-04-12 17:28:49
I'm assuming you mean I can't edit it from jscript. Can I at least delete the auto-playlist? I'd hate to have dozens of these things clogging up my playlists dropdown.
Autoplaylists are not editable in fb2k in general, not just in JScript =)
You can modify playlist itself (move\delete\rename etc), but you can't modify it's contents.
Title: Re: JScript Panel script discussion/help
Post by: WilB on 2018-04-12 17:40:05
fb.GetQueryItems(handle_list, query); (IFbMetadbHandleList) is another possibility

Gives handle list that can add to playlist etc, e.g.

var b = fb.GetQueryItems(fb.GetLibraryItems(), "artist IS Madonna");
Results are unsorted.
NOTE: Use try/catch to handle invalid queries. An empty handle list will be returned if the query is valid but there are no results.
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2018-04-12 17:56:22
Autoplaylists are not editable in fb2k in general, not just in JScript =)
You can modify playlist itself (move\delete\rename etc), but you can't modify it's contents.
Haha, I thought you were trying to say you couldn't modify the query. Yes I realize you can't delete the contents.

var b = fb.GetQueryItems(fb.GetLibraryItems(), "artist IS Madonna");
Results are unsorted.
NOTE: Use try/catch to handle invalid queries. An empty handle list will be returned if the query is valid but there are no results.
Yeah, I was going through interfaces.txt and literally just saw that.

But then with that it looks like I can do:
plman.FindOrCreatePlaylist <- get my special "selected object" playlist
plman.ClearPlaylist
plman.InsertPlaylistItems <- insert that handle_list into the playlist
plman.SortByFormatV2

Boom, done. Thanks guys! This will be a fun project tonight.
Title: Re: JScript Panel script discussion/help
Post by: Sickid on 2018-05-10 18:30:58
foo_jscript_panel\samples\complete\last.fm bio.txt
Some characters cannot be displayed properly.
e.g. "Lou Reed & Metallica" will show "Lou Reed _Metallica".
Title: Re: JScript Panel script discussion/help
Post by: seriousstas on 2018-05-12 12:17:33
Hi!
@marc2003
Please make dialogs window (do not full screen) like this :
http://jpegshare.net/a6/5f/a65f641edb1185583910ba040405d896.png.html
http://jpegshare.net/20/d1/20d148ada69b02b63cd236aed5ed6c14.png.html
Title: Re: JScript Panel script discussion/help
Post by: firewater on 2018-06-04 09:04:32
I have this script by marc2003, which I've edited a little. I'm wondering how can I make the album cover image have a 1px grey border?

Code: [Select]
// ==PREPROCESSOR==
// @name "track info + seekbar + buttons"
// @author "marc2003"
// @import "%fb2k_profile_path%js_marc2003\js\lodash.min.js"
// @import "%fb2k_profile_path%js_marc2003\js\helpers.js"
// @import "%fb2k_profile_path%js_marc2003\js\panel.js"
// @import "%fb2k_profile_path%js_marc2003\js\seekbar.js"
// ==/PREPROCESSOR==

//note the buttons are white and you'd have to edit the images to change them...
var colours = {
background : _.RGB(255, 255, 255),
title : _.RGB(55, 49, 53),
artist : _.RGB(95, 95, 95),
};

//////////////////////////////////////////////////////////////

var panel = new _.panel("track info + seekbar + buttons");
var seekbar = new _.seekbar(60, 5, 0, 20);
var buttons = new _.buttons();
var img = null;
on_playback_new_track();

buttons.update = function () {
var y = _.round((panel.h - 36) / 1);
}

function on_size() {
panel.size();
seekbar.x = panel.h + 310
seekbar.w = panel.w - panel.h - 710;
seekbar.y = (panel.h - 20) / 2;
buttons.update();
}

function on_paint(gr) {
    if (fb.PlaybackLength > 0) {
    img && _.drawImage(gr, img, 12, 12, 50, 50, image.centre);
        gr.GdiDrawText(_.tfe("%title%"), gdi.Font("Helvetica", 16), colours.title, 75, 10, 400, 40, LEFT);
            gr.GdiDrawText(_.tfe("%artist% l %album%"), gdi.Font("Helvetica Light", 16), colours.artist, 75, 32, 400, 30, LEFT);
}
}

function on_playback_new_track() {
var metadb = fb.GetNowPlaying();
if (!metadb)
return;
_.dispose(img);
img = utils.GetAlbumArtV2(metadb, 0);
window.Repaint();
}

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

function on_playback_seek() {
seekbar.playback_seek();
}

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

function on_playback_pause() {
buttons.update();
window.Repaint();
}

function on_playback_starting() {
buttons.update();
window.Repaint();
}

function on_mouse_wheel(s) {
buttons.leave();
}

function on_mouse_move(x, y) {
if (buttons.move(x, y))
return;
seekbar.move(x, y);
}

function on_mouse_leave() {
buttons.leave();
}

function on_mouse_lbtn_down(x, y) {
seekbar.lbtn_down(x, y);
}

function on_mouse_lbtn_up(x, y) {
if (buttons.lbtn_up(x, y))
return;
if (seekbar.lbtn_up(x, y))
return;
fb.RunMainMenuCommand("View/Show now playing in playlist");
}

function on_mouse_rbtn_up(x, y) {
return panel.rbtn_up(x, y);
}
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2018-06-04 18:42:19
Change on_paint(gr) to be:
Code: [Select]
function on_paint(gr) {
    if (fb.PlaybackLength > 0) {
if (img) {
_.drawImage(gr, img, 12, 12, 50, 50, image.centre);
gr.DrawRect(11, 11, 51, 51, 1, _.RGB(96,96,96);
}
gr.GdiDrawText(_.tfe("%title%"), gdi.Font("Helvetica", 16), colours.title, 75, 10, 400, 40, LEFT);
gr.GdiDrawText(_.tfe("%artist% l %album%"), gdi.Font("Helvetica Light", 16), colours.artist, 75, 32, 400, 30, LEFT);
}
}
You might need to play with the coordinates and color in the DrawRect call to get things to your liking, but that should be a good start.
Title: Re: JScript Panel script discussion/help
Post by: firewater on 2018-06-05 02:39:33
Thanks, worked perfectly.
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2018-06-13 15:06:35
What is the meaning of the fromhook parameter in the on_metadb_changed callback?
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2018-06-15 13:36:33
What is the meaning of the fromhook parameter in the on_metadb_changed callback?

I found this explanation in an old WSH panel mod document, but I hardly understand a word of this definition, probably because I have no idea of what the "metadb_display_field_provider" is:
Quote
fromhook: boolean, set to true when actual file contents haven't changed but one of metadb_display_field_provider implementations requested an update so output of metadb_handle::format_title() etc has changed.

Any clue?
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2018-06-15 17:30:03
I don't think it's anything you have to worry about typically.

When fromhook is true, it means that information in a metadb changed, but not the tags in the file itself. For example, if you're using foo_playcount and you rate a song 5 *s, on_metadb_changed will be called with fromhook = true. If you open up the properties dialog and change a song title and then OK out of the dialog, on_metadb_changed will be called with fromhook = false. I can't think of a single good reason you'd want to ignore one or the other type of metadb change, so it's possible it's mainly for informational purposes.
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2018-06-15 17:54:03
Thanks a lot for the explanation, Mordred.
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2018-06-16 12:33:10
I just upgraded from v1.3.2.2 to v2.1.4. I updated every script according to marc2003 instructions and everything works fine, but one panel, which crashes, warning me that "Object doesn't support this property or method". The referenced line, which as far as I can see shouldn't be affected by the breaking changes, is the following:
Code: [Select]
var filtered_list = _.uniq(autocomplete, true).filter(filterAutocomplete);


If it helps, the filter function is the following:
Code: [Select]
function filterAutocomplete(value){
    return value.indexOf(text) == 0;
}

It's a search-box script, where text is what is typed in the search-box and autocomplete is an array of previous entries.
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2018-06-16 15:20:59
I just upgraded from v1.3.2.2 to v2.1.4. I updated every script according to marc2003 instructions and everything works fine, but one panel, which crashes, warning me that "Object doesn't support this property or method". The referenced line, which as far as I can see shouldn't be affected by the breaking changes, is the following:
Code: [Select]
var filtered_list = _.uniq(autocomplete, true).filter(filterAutocomplete);

One more clue: the problem seems to be gone after switching fom jscript to chakra engine.
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2018-06-18 10:35:24
One more clue: the problem seems to be gone after switching fom jscript to chakra engine.
The problem is caused by using different JS engines:
Chakra engine provides ECMA-5 support, while JScript provides ECMA-3 (with some extensions).
`Array.indexOf` is a ECMA-262 5th edition feature, so it is not available under JScript engine, which is used by default when migrating from v1.3.2.2 to v2.* (v1.3.2.2 used Chakra if it was available though).
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2018-06-18 11:52:30
The problem is caused by using different JS engines:
Chakra engine provides ECMA-5 support, while JScript provides ECMA-3 (with some extensions).
`Array.indexOf` is a ECMA-262 5th edition feature, so it is not available under JScript engine, which is used by default when migrating from v1.3.2.2 to v2.* (v1.3.2.2 used Chakra if it was available though).

Thanks, I was not aware of using the Chakra engine, with the previous version. I was actually not even aware that different jscript engines exist.
Title: Re: JScript Panel script discussion/help
Post by: kode54 on 2018-06-19 01:44:29
The plug-in uses system provided jscript engines, or else it would probably be significant in size, if it were, say, providing a complete copy of V8, like nodejs does.
Title: Re: JScript Panel script discussion/help
Post by: flashgor on 2018-06-20 14:39:13
@marc2003
I paid attention to the unexpected value of the variable time:undefined in the function on_playback_time(time) at the beginning of playback.
So it should be, or can it be fixed?

In script:
function on_playback_time(time) {
    fb.trace(' --------- on_playback_time --- time: ' +time+ ' ---- fb.PlaybackTime: ' +fb.PlaybackTime);

In console:
Opening track for playback: .....
 --------- on_playback_time --- time: undefined ---- fb.PlaybackTime: 0.14017006802721077
 --------- on_playback_time --- time: 1 ---- fb.PlaybackTime: 1.1074625850340127
 ...
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2018-06-22 09:42:42
... or else it would probably be significant in size, if it were, say, providing a complete copy of V8, like nodejs does.
Dunno about V8, but SpiderMonkey (Firefox JS engine) takes only ~18Mb, so it's not really that bad =)
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2018-06-22 19:35:29
... or else it would probably be significant in size, if it were, say, providing a complete copy of V8, like nodejs does.
Dunno about V8, but SpiderMonkey (Firefox JS engine) takes only ~18Mb, so it's not really that bad =)
I'm hearing you say you're going to do a fork with spidermonkey and full ES6 support.... ;)
Title: Re: JScript Panel script discussion/help
Post by: TheQwertiest on 2018-06-23 15:53:39
I'm hearing you say you're going to do a fork with spidermonkey and full ES6 support.... ;)
Yeah, but it is a pretty big undertaking, so it won't be ready any time soon... It will probably take months to reimplement all the features.
Title: Re: JScript Panel script discussion/help
Post by: zeremy on 2018-06-27 11:28:11
I am using GetColourSchemeJSON to create themed colors layouts based on album art.
I would appreciate any help on how to determine the best text color ( with JScript )  for the background color, as to achieve comfortable  contrast.
Title: Re: JScript Panel script discussion/help
Post by: zeremy on 2018-06-27 13:58:52
Ignore my previous post,  found a solution.
http://www.nbdtech.com/Blog/archive/2008/04/27/Calculating-the-Perceived-Brightness-of-a-Color.aspx
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2018-06-27 20:18:37
That algorithm uses different numbers than I've seen. My theme currently uses the w3c brightness recommendation for calculating these values (I have a color helper class which makes these things much easier https://github.com/kbuffington/Georgia/blob/master/js/color.js):

Code: [Select]
// brightness from 0-255 divide by 2.55 if you want 0-100%
Math.round(Math.sqrt( 0.299*this.r*this.r + 0.587*this.g*this.g + 0.114*this.b*this.b ));

I can share my color picking code if you're interested. I've spent months on it and finally pretty happy with it.


Title: Re: JScript Panel script discussion/help
Post by: zeremy on 2018-06-28 07:38:15
Thank you for your feedback and link.
I will use the algorithm you recommended.
I will have to study more to understand how to use the helper class, but you provided me a start point.

If you don't mind please share your colour picking code, you seem to have spent a long time implementing it.

As for JScript Panel, I wish interfaces also had
window.SetColourDUI / window.SetColourCUI
Then it would be possible to also change the colours of native panels via JScript script.
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2018-06-28 17:02:10
You use the Color class by just instantiating it with new and passing a color value. Like var col = new Color(rgb(255,0,0)); Then you can just do col.r or col.brightness or col.isCloseToGreyscale. col.val will spit the foobar color back out (pull the latest version of color.js from github because I just changed this 5 minutes ago).

Here's my color picker code which shows this in action:
Code: [Select]
function getThemeColor(image, maxColorsToPull, maxColors) {
var selectedColor;
var minFrequency = 0.015;
var colorsWeighted = [];

try {
colorsWeighted = JSON.parse(image.GetColourSchemeJson(maxColorsToPull));
colorsWeighted.forEach(function (c, i) {
colorsWeighted[i].col = new Color(c.col);
});

console.log('idx      color        bright  freq   weight');
maxWeight = 0;
selectedColor = colorsWeighted[0].col;  // choose first color in case no color selected below
colorsWeighted.forEach(function (c, i) {
var col = c.col;
var midBrightness = 127 - Math.abs(127 - col.brightness);   // favors colors with a brightness around 127
c.weight = c.freq * midBrightness * 10; // multiply by 10 so numbers are easier to compare
if (c.freq >= minFrequency && !col.isCloseToGreyscale && col.brightness < 212) {
console.log(leftPad(i, 2), col.getRGB(true,true), leftPad(col.brightness, 4), ' ', leftPad(parseFloat(c.freq*100).toFixed(2),5) + '%', leftPad(parseFloat(c.weight).toFixed(2), 7));
if (c.weight > maxWeight) {
maxWeight = c.weight;
selectedColor = col;
}
} else if (col.isCloseToGreyscale) {
console.log(' -', col.getRGB(true,true), leftPad(col.brightness, 4), ' ', leftPad(parseFloat(c.freq*100).toFixed(2),5) + '%', '   grey');
} else {
console.log(' -', col.getRGB(true,true), leftPad(col.brightness, 4), ' ', leftPad(parseFloat(c.freq*100).toFixed(2),5) + '%', leftPad(parseFloat(c.weight).toFixed(2), 7));
}
});

if (selectedColor.brightness < 39) {
console.log(selectedColor.getRGB(true), 'brightness:', selectedColor.brightness, 'too dark -- searching for highlight color');
brightest = selectedColor;
maxWeight = 0;
colorsWeighted.forEach(function (c, i) {
if (c.col.brightness > selectedColor.brightness &&
c.col.brightness < 200 &&
!c.col.isCloseToGreyscale &&
c.weight > maxWeight &&
c.freq > .01) {
maxWeight = c.weight;
brightest = c.col;
}
});
selectedColor = brightest;
}
console.log('Selected Color:', selectedColor.getRGB(true));
return selectedColor.val;
} catch (e) {
return undefined;
}
}
Here's the explanation. My theme requires that the theme color (which I use for some backgrounds) has white text and white logos on it. So I want to choose a color that looks good but isn't too bright. I also try and avoid colors that are greyscale or close to it (GetColourSchemeJson will often return colors like rgb(100,101,97) which are essentially greyscale) because those are pretty boring. On my first pass I only want to choose a color that appears at least 1.5% of the time. I also weight colors more with a brightness around 127 (this portion of the weighting is linear but I'd like it to be more of a gaussian weight but it works well enough).

If after the first pass I didn't find a suitable color, I do a second pass looking for basically the brightest non-greyscale color which appears at least 1% of the time. If that still doesn't find anything suitable I just return the very first color because the image is obviously completely greyscale or very close to it.

When running this I have a lot of logging to the console to see what's going on. Change your font to Consolas if you want it to be readable :)
Title: Re: JScript Panel script discussion/help
Post by: seriousstas on 2018-06-28 20:31:50

Have a BIG request (question):
How to achieve the normal operation of timers after exit Sleep or Hibernate.
All timers of various JScript Panel scripts try to "catch up" with the system time.
Help, how to solve this?
Title: Re: JScript Panel script discussion/help
Post by: zeremy on 2018-07-05 10:21:10
@MordredKLB
Thanks for sharing, your reply was very useful :)
Title: Re: JScript Panel script discussion/help
Post by: seriousstas on 2018-07-17 10:53:40
foo_jscript_panel\samples\jsplaylist-mod\
Previously, JS common.js is enough for the playlist (JS Smooth Playlist) to work.
Why now import everything else ?? :
// @import "%fb2k_component_path%samples\jsplaylist-mod\js\WSHcommon.js"
// @import "%fb2k_component_path%samples\jsplaylist-mod\js\WSHinputbox.js"
// @import "%fb2k_component_path%samples\jsplaylist-mod\js\WSHtopbar.js"
// @import "%fb2k_component_path%samples\jsplaylist-mod\js\WSHscrollbar.js"
// @import "%fb2k_component_path%samples\jsplaylist-mod\js\WSHheaderbar.js"
// @import "%fb2k_component_path%samples\jsplaylist-mod\js\WSHplaylist.js"
// @import "%fb2k_component_path%samples\jsplaylist-mod\js\WSHplaylistmanager.js"
// @import "%fb2k_component_path%samples\jsplaylist-mod\js\WSHsettings.js"
// @import "%fb2k_component_path%samples\jsplaylist-mod\js\main.js
 :(
Title: Re: JScript Panel script discussion/help
Post by: mire777 on 2018-08-05 16:11:32
..
Title: Re: JScript Panel script discussion/help
Post by: mire777 on 2018-08-06 13:04:08
I have one question. It seems that framestyle (none, gray , sunken) doesn't work for some old plugins in foobar v 1.4 , and also doesn't work for Jscript. 'Edge Style' is grayed out in Jscript and cant be selected. Would that be fixed? Thanks.
Title: Re: JScript Panel script discussion/help
Post by: mire777 on 2018-08-14 15:57:43
Can someone help me. How to get toolbar panel color?  Which color is that?

I tried:

var CLR = 20;
g_syscolor = utils.GetSysColour(CLR);


This works. But i dont know which color is for toolbar?
Title: Re: JScript Panel script discussion/help
Post by: PleasantSounds on 2018-08-15 03:21:38
I have been using the following definitions:

Code: [Select]
COLOR_SCROLLBAR           0
COLOR_BACKGROUND          1
COLOR_ACTIVECAPTION       2
COLOR_INACTIVECAPTION     3
COLOR_MENU                4
COLOR_WINDOW              5
COLOR_WINDOWFRAME         6
COLOR_MENUTEXT            7
COLOR_WINDOWTEXT          8
COLOR_CAPTIONTEXT         9
COLOR_ACTIVEBORDER        10
COLOR_INACTIVEBORDER      11
COLOR_APPWORKSPACE        12
COLOR_HIGHLIGHT           13
CLOR_HIGHLIGHTTEXT        14
COLOR_BTNFACE             15
COLOR_BTNSHADOW           16
COLOR_GRAYTEXT            17
COLOR_BTNTEXT             18
COLOR_INACTIVECAPTIONTEXT 19
COLOR_BTNHIGHLIGHT        20

I believe the toolbars use the COLOR_BTNFACE value.
Title: Re: JScript Panel script discussion/help
Post by: mire777 on 2018-08-15 09:31:52
I have been using the following definitions:

Code: [Select]
COLOR_SCROLLBAR           0
COLOR_BACKGROUND          1
COLOR_ACTIVECAPTION       2
COLOR_INACTIVECAPTION     3
COLOR_MENU                4
COLOR_WINDOW              5
COLOR_WINDOWFRAME         6
COLOR_MENUTEXT            7
COLOR_WINDOWTEXT          8
COLOR_CAPTIONTEXT         9
COLOR_ACTIVEBORDER        10
COLOR_INACTIVEBORDER      11
COLOR_APPWORKSPACE        12
COLOR_HIGHLIGHT           13
CLOR_HIGHLIGHTTEXT        14
COLOR_BTNFACE             15
COLOR_BTNSHADOW           16
COLOR_GRAYTEXT            17
COLOR_BTNTEXT             18
COLOR_INACTIVECAPTIONTEXT 19
COLOR_BTNHIGHLIGHT        20

I believe the toolbars use the COLOR_BTNFACE value.


No, i tried all that colors and even more, i cant get color for toolbar background.

I need this background color (so it should match OS, if its win 7 then it's blue if win 10 white) :

(https://s15.postimg.cc/gddqh1s6z/20180815_102801.png)
Title: Re: JScript Panel script discussion/help
Post by: PleasantSounds on 2018-08-16 02:30:02
It appears that you are using Aero themes. In that case GetSysColour is not going to help you, as it only returns a single colour value.
If you look closely, the menu background is not a solid colour but a gradient, or maybe even a combination of two gradients depending on the theme.

I'm not aware of any documented ways of getting that info from the system. One thing you could try is extracting a sample of that pattern graphically from a screen shot and stretching it to the desired width.

That may cover your personal setups (until you make any changes in Windows themes), but a generic solution would be much more difficult to build.

Title: Re: JScript Panel script discussion/help
Post by: mire777 on 2018-08-16 10:34:51
It appears that you are using Aero themes. In that case GetSysColour is not going to help you, as it only returns a single colour value.
If you look closely, the menu background is not a solid colour but a gradient, or maybe even a combination of two gradients depending on the theme.

I'm not aware of any documented ways of getting that info from the system. One thing you could try is extracting a sample of that pattern graphically from a screen shot and stretching it to the desired width.

That may cover your personal setups (until you make any changes in Windows themes), but a generic solution would be much more difficult to build.



Yes, another way is to use:

function on_main_menu(index) {

Then i can put buttons on standard toolbar. I tried that and works fine. But problem is that popup menu which buttons open, cant folow button position on toolbar, it folows jscript panel position. So if i move button, menu wont folow.

And i must then somehow hide jscript panel.

Maybe Marc can help?
Title: Re: JScript Panel script discussion/help
Post by: mire777 on 2018-09-05 16:00:35
I have problem with adding "PLAY_COUNT" Tag.

Code: [Select]
var PLAY_COUNT = fb.TitleFormat("%PLAY_COUNT%").EvalWithMetadb(metadb);
//Play Count
if(PLAY_COUNT>=0) {
new_playcounter = Math.floor(PLAY_COUNT) + 1;
} else if(PLAY_COUNT=="?") {
new_playcounter = 1;
} else {
new_playcounter = Math.floor(p_counter) + 1;
}

Everything works fine, but if i have big number in TAG like: "965198981958199645645646456456456" , then when script adds "+1" ,then number converts to scientific  "9.651989819582e+32".

How to avoid this?
Title: Re: JScript Panel script discussion/help
Post by: Mrakobes on 2018-11-24 20:04:49
I also ask you to help, you know how - I took the @text reader@, I registered the path:
$left(%path%,$strstr(%path%,\%artist%))%artist%)\Discography.txt
displays all the same FIRST text file alphabetically, Discography.txt only if it is alone in the folder
+
how to make "album art" that looked in folder Covers located at the root of the album?
Title: Re: JScript Panel script discussion/help
Post by: Mrakobes on 2018-11-24 20:26:01
del
Title: Re: JScript Panel script discussion/help
Post by: mjm716 on 2018-11-25 05:11:55
I also ask you to help, you know how - I took the @text reader@, I registered the path:
$left(%path%,$strstr(%path%,\%artist%))%artist%)\Discography.txt
displays all the same FIRST text file alphabetically, Discography.txt only if it is alone in the folder

ctrl/rt-click for panel properties.

place your custom path\filename in "2K3.TEXT.FILENAME.TF"

not sure if I understand your 2nd question but if you want to set the location of album art:

prefs>display>album art>front cover (search patterns):

Covers\*.*
or might be
$directory_path(%path%)\Covers\*.*
Title: Re: JScript Panel script discussion/help
Post by: Mrakobes on 2018-11-25 05:38:12

place your custom path\filename in "2K3.TEXT.FILENAME.TF"


Please provide a complete code example, where to insert?

Spoiler (click to show/hide)

prefs>display>album art>front cover (search patterns):

Covers\*.*
or might be
$directory_path(%path%)\Covers\*.*

Where???

(https://i108.fastpic.ru/big/2018/1125/1e/97bed1343b04f09226584737505d071e.png) (https://i107.fastpic.ru/big/2018/1125/87/741aeb9bbb2b33f814d0dc52ada22887.png) 
Title: Re: JScript Panel script discussion/help
Post by: mjm716 on 2018-11-25 06:58:00
@text reader@

#1 You have a text reader js panel?

right-click on the panel. Select "Custom path..." and insert your path\filename

(https://i.imgur.com/q5G6YFH.jpg)

cover images

#2 The jspanel uses Foobar preferences cover image location.
FBprefs > Display > Album Art > Front cover (search patterns):

(https://i.imgur.com/bQNzwTF.jpg)

Title: Re: JScript Panel script discussion/help
Post by: Mrakobes on 2018-11-25 08:04:22
I am use foo_jscript_panel by marc2k3 https://github.com/marc2k3 "Album Art" not "text reader" there is no such menu((((

there were 2 questions I confused you (covers + Discography)

added lines to settings still not visible

front.jpg
cover.jpg
%filename%.jpg
%album%.jpg
folder.jpg
folder.png
Covers\*.*
$directory_path(%path%)\Covers\*.*
Title: Re: JScript Panel script discussion/help
Post by: mjm716 on 2018-11-25 09:00:47
I tried Album Art in a panel and it loads the artwork from the album folder, which I believe is the default location from Foobar prefs.
In preferences, try only the path you want?

Otherwise, I recommend trying a different panel : thumbs.txt
located here [foobar]\user-components\foo_jscript_panel\samples\complete\thumbs.txt

You can specify a custom path and it has other options.


I don't understand your discography question.
Title: Re: JScript Panel script discussion/help
Post by: Mrakobes on 2018-11-25 13:19:29
thumbs.txt works !!! deleted *.*

$directory_path(%path%)\Covers\ - such an option, mjm 716 Thanks!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
discography question - There are several text files in the root directory in the executor folder, one of them is diskography.txt. This music is played from subfolders, the script
$left(%path%,$strstr(%path%,\%artist%))%artist%)\Discography.txt
goes to the root but does not read the specified file and displays the first one in alphabetical order

(https://i108.fastpic.ru/big/2018/1125/83/e968f84ec13c2c79d0b340659f126b83.png) (https://i108.fastpic.ru/big/2018/1125/39/d0fe7e7828bb1c312b3943d0c0e9a939.png) 
Title: Re: JScript Panel script discussion/help
Post by: mjm716 on 2018-11-26 09:45:03
maybe this thread is useful for reversing your directory path:
https://hydrogenaud.io/index.php/topic,47627.msg423140.html#msg423140
Title: Re: JScript Panel script discussion/help
Post by: Mrakobes on 2018-11-30 16:19:40
maybe this thread is useful for reversing your directory path:
https://hydrogenaud.io/index.php/topic,47627.msg423140.html#msg423140

No, the required script rises to the folder, but does not open the specified file, but displays the first one alphabetically, in my case it is a biography
Title: Re: JScript Panel script discussion/help
Post by: Mrakobes on 2018-12-03 09:57:57
how to fix the path to the folder "Covers" if it is not in the current but one level higher?

Artist > Covers - $directory_path(%path%)\Covers\

CD1 > Artist > Covers - ???

(https://i108.fastpic.ru/big/2018/1203/2f/c34cb58ef69954eca60add9c14661e2f.png) (https://i107.fastpic.ru/big/2018/1203/69/84c4618fff605af6ce7e234fad15e969.png) 


Title: Re: JScript Panel script discussion/help
Post by: wcs13 on 2018-12-06 04:03:10
Question : I'm using JS Panel as a replacement for the standard album art component. It works well.
However, I have noticed this behaviour :
- If I double-click on a cover and the cover is an image file, the component opens the cover (so I get an enlarged version)
- If I double-click on a cover and the cover is embedded in an audio file, the component opens the audio file directory instead

Is there a way to open/enlarge the cover even if it's embedded ? Thank you.
Title: Re: JScript Panel script discussion/help
Post by: mjm716 on 2018-12-06 13:15:37
@Mrakobes what you want was in the thread I posted for you previously.
http://www.hydrogenaudio.org/forums/index.php?s=&showtopic=43251&view=findpost&p=410071

@wcs13  any chance you give us a hint about what script you are using?
Title: Re: JScript Panel script discussion/help
Post by: wcs13 on 2018-12-06 13:46:44
Sure. "Album Art" by marc2003.

Code: [Select]
// ==PREPROCESSOR==
// @name "Album Art"
// @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\albumart.js"
// ==/PREPROCESSOR==

var panel = new _.panel('custom_background');
var albumart = new _.albumart(0, 0, 0, 0);

panel.item_focus_change();

function on_size() {
panel.size();
albumart.w = panel.w;
albumart.h = panel.h;
}

function on_paint(gr) {
panel.paint(gr);
albumart.paint(gr);
}

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

function on_get_album_art_done(m, id, im, p) {
albumart.get_album_art_done(p);
}

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

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

function on_mouse_lbtn_dblclk(x, y) {
albumart.lbtn_dblclk(x, y);
}

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

function on_key_down(k) {
albumart.key_down(k);
}
Title: Re: JScript Panel script discussion/help
Post by: mjm716 on 2018-12-06 14:34:13
You may want to try out the thumbs.txt sample in the same folder as album_art.txt

It has core functions of albumart but more options, incl. right-click to view image which may also work for embedded.
I don't use embedded art so can't test.
Title: Re: JScript Panel script discussion/help
Post by: wcs13 on 2018-12-06 17:42:06
I've tried thumbs.txt. It doesn't seem to work.
It only displays the folder.jpg if it's present in the audio files directory, but it doesn't display any embedded artwork.
At least album art.txt displays the embedded artwork, even if it doesn't enlarge it.
Title: Re: JScript Panel script discussion/help
Post by: Mrakobes on 2018-12-08 20:35:01
$directory(%path%,$sub($sub($len(%path%),$len($replace(%path%,\,))),1))
@Mrakobes what you want was in the thread I posted for you previously.
http://www.hydrogenaudio.org/forums/index.php?s=&showtopic=43251&view=findpost&p=410071

@wcs13  any chance you give us a hint about what script you are using?




custom folder - $directory(%path%,$sub($sub($len(%path%),$len($replace(%path%,\,))),1))
dont work with // @name "Thumbs" (((
Title: Re: JScript Panel script discussion/help
Post by: wcs13 on 2018-12-15 05:37:22
Hi everybody, still looking for a solution for my problem below :

Question : I'm using JS Panel as a replacement for the standard album art component [with marc2003's albumart script). It works well. However, I have noticed this behaviour :
- If I double-click on a cover and the cover is an image file, the component opens the cover (so I get an enlarged version)
- If I double-click on a cover and the cover is embedded in an audio file, the component opens the audio file directory instead
Is there a way to open/enlarge the cover even if it's embedded ? Thank you.

I think I may have found the small part of marc2003's "albumart.js" file that handles the left double-click on the album art :

Code: [Select]
		this.lbtn_dblclk = function (x, y) {
if (this.trace(x, y)) {
if (panel.metadb && panel.metadb.Path == this.path) {
_.explorer(this.path);
} else if (_.isFile(this.path)) {
_.run(this.path);
}
return true;
} else {
return false;
}
}
Could somebody help me modify it, so that when we double-click it always displays the album art enlarged, whether it's external or embedded ?
Currently it only displays it enlarged if it's an external file. Otherwise it just opens a Windows explorer window to show the audio file folder.
I hope I'm clear enough. Thanks in advance !
Title: Re: JScript Panel script discussion/help
Post by: MojoBass on 2019-01-29 04:57:22
Found a strange behaviour of Br3tts JS Smooth Browser (jssb) on marc2k3s JScript Panel (JScript Panel 2.2.0, PSS 0.3.8.3(alpha), Columns UI 1.0.0, Foobar 1.4.2):
Using the Chakra Engine, in the Album Art Grid Display Mode the Background Wallpaper Options do not work, background always black or white. All other Display Modes work well, changing to JScript Engine also solves the topic.
Title: Re: JScript Panel script discussion/help
Post by: kode54 on 2019-01-29 23:55:34
Cool, the JScript equivalent of coding web pages for IE6.
Title: Re: JScript Panel script discussion/help
Post by: MojoBass on 2019-01-30 04:24:59
Found a strange behaviour of Br3tts JS Smooth Browser (jssb) on marc2k3s JScript Panel (JScript Panel 2.2.0, PSS 0.3.8.3(alpha), Columns UI 1.0.0, Foobar 1.4.2):
Using the Chakra Engine, in the Album Art Grid Display Mode the Background Wallpaper Options do not work, background always black or white. All other Display Modes work well, changing to JScript Engine also solves the topic.

Solved with marc2k3s update of the JScript Panel v2.2.0.1, see here (https://github.com/marc2k3/foo_jscript_panel/releases/tag/v2.2.0.1). Background of jssb with Chakra Engine works now as intended for all Display Modes! See as well commit here (https://github.com/marc2k3/foo_jscript_panel/commits/master).
Thanks Marc for that incredible responsiveness!
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2019-02-23 14:58:45
I actually moved to spider monkey panel, but this looks like a legacy from jscript panel: why are some lines in the flags document commented out? Namely line 37-39. Others are uncommented, but nevertheless followed by a "do not use" remark.

I often use those variables in my scripts and what I actually did is preprocess the flags document after uncommenting those lines. This leads me to a more general question: are we supposed to use the flags and helpers documents this way, in the preprocessor? Or is it a better practice to copy the flags and helpers we need, in our own scripts?
Title: Re: JScript Panel script discussion/help
Post by: davideleo on 2019-03-05 17:49:23
Will somebody explain me the meaning of the numeric arguments in the BuildMenu methods?
Title: Re: JScript Panel script discussion/help
Post by: grimes on 2019-03-16 19:28:51
The JScript "Coverflow View" by Br3tt doesn't work with JScript Panel 2.2.1 anymore.
Problem is line 1535:
Code: [Select]
window.DlgCode = DLGC_WANTALLKEYS;
I tried
Code: [Select]
// window.DlgCode = DLGC_WANTALLKEYS;
but the error still remains.
Title: Re: JScript Panel script discussion/help
Post by: pIv on 2019-03-17 09:29:57
marc2003

I found bug!
When Foobar started a window POPs up with a message:
Quote
JScript Panel v2.2.1 (JS Smooth Playlist Manager v2018-mod by Br3tt aka Falstaff)
JavaScript execution failed:
Overflow
File: G:\Foobar2000\user-components\foo_jscript_panel\samples\js-smooth\js\jsspm.js
Line: 432, Col: 3
Then I go to the window with this script and click on the right mouse button to restart the script. Now it works1
Title: Re: JScript Panel script discussion/help
Post by: jazzthieve on 2019-03-17 09:44:51
FYI marc2003 hasn't been active on the forum since 2017.
Title: Re: JScript Panel script discussion/help
Post by: grimes on 2019-03-17 12:03:55
If you have a bug report for JScript Panel, please contact marc2k3 at Github (https://github.com/marc2k3/foo_jscript_panel) and open an issue.
Title: Re: JScript Panel script discussion/help
Post by: seongbin on 2019-03-23 12:50:24
Hi, marc.
I am currently using SMP, and looking for a method to implement box-shadow effect like in CSS.
Is there any way to do it in albumart.js without using an external shadow image?
Title: Re: JScript Panel script discussion/help
Post by: Ottodix on 2019-03-25 14:38:46
(I'll reply there, but maybe you should consider moving to SMP (https://hydrogenaud.io/index.php/topic,116669.0.html), which is faster and offer more possibilites.)
You need to create an image with this shadow, and then you draw the shadow image below/before the final image. Here is a function which create such image:
Code: [Select]
function createShadow(width, height, color){
var shadow = gdi.CreateImage(width, height);
    var gb = shadow.GetGraphics();
    gb.FillSolidRect(10, 10, width-20, height-20, color);
shadow.ReleaseGraphics(gb);

shadow = shadow.Resize(width*1/10, height*1/10,2);
shadow = shadow.Resize(width, height, 2);
return shadow;
};

And then using this function, it's quite easy:
Code: [Select]
cover_shadow = createShadow(image_width, image_height, RGB(0,0,0));
gr.DrawImage(cover_shadow, 0, 0, image_width+20, image_height+20, 0, 0, cover_shadow.Width, cover_shadow.Height);

To achieve the desired effect (shadow blur radius/position), you need to play mostly with the values in DrawImage
Title: Re: JScript Panel script discussion/help
Post by: seongbin on 2019-03-27 13:55:23
(I'll reply there, but maybe you should consider moving to SMP (https://hydrogenaud.io/index.php/topic,116669.0.html), which is faster and offer more possibilites.)
You need to create an image with this shadow, and then you draw the shadow image below/before the final image. Here is a function which create such image:
Code: [Select]
function createShadow(width, height, color){
var shadow = gdi.CreateImage(width, height);
    var gb = shadow.GetGraphics();
    gb.FillSolidRect(10, 10, width-20, height-20, color);
shadow.ReleaseGraphics(gb);

shadow = shadow.Resize(width*1/10, height*1/10,2);
shadow = shadow.Resize(width, height, 2);
return shadow;
};

And then using this function, it's quite easy:
Code: [Select]
cover_shadow = createShadow(image_width, image_height, RGB(0,0,0));
gr.DrawImage(cover_shadow, 0, 0, image_width+20, image_height+20, 0, 0, cover_shadow.Width, cover_shadow.Height);

To achieve the desired effect (shadow blur radius/position), you need to play mostly with the values in DrawImage

Code: [Select]
function createShadow(width, height, color){
let shadow = gdi.CreateImage(width, height);
let gb = shadow.GetGraphics();
gb.FillSolidRect(0, 0, width, height, color);
shadow.ReleaseGraphics(gb);

shadow = shadow.Resize(width / 128, height / 128, 2);
shadow = shadow.Resize(width, height, 2);
return shadow;
}
Code: [Select]
if (this.img) {
let cover_shadow = createShadow(this.img.Width, this.img.Height, _RGBA(0, 0, 0, 128));
_drawImage(gr, cover_shadow, this.x, this.y, this.w, this.h, this.properties.aspect.value);
_drawImage(gr, this.img, this.x + 10, this.y + 10, this.w - 20, this.h - 20, this.properties.aspect.value);
}
Thanks for the tip.
So, what the script is doing is that resize the image to a smaller size and then resize it back to original dimension so that it can be generated with blurred border? If so, what I don't get is the resized shadow image has blurred edge only on right and bottom, but no blurred effect on left and top. Is this a rendering bug from resize()?
Title: Re: JScript Panel script discussion/help
Post by: Ottodix on 2019-03-28 17:16:39
Yes, you understood correctly. I didn't try myself your code, but i guess the issue is with the rectangle drawn inside the createShadow function. In my function, I intentionly left 10px of padding, in order to leave space for the blur effect:
Code: [Select]
gb.FillSolidRect(10, 10, width-20, height-20, color);
You removed this padding:
Code: [Select]
gb.FillSolidRect(0, 0, width, height, color);

Otherwise, you can probably use the function StackBlur instead of this resize trick which create a blur effect, look into SMP doc.
Title: Re: JScript Panel script discussion/help
Post by: seongbin on 2019-04-04 09:08:53
Yes, you understood correctly. I didn't try myself your code, but i guess the issue is with the rectangle drawn inside the createShadow function. In my function, I intentionly left 10px of padding, in order to leave space for the blur effect:
Code: [Select]
gb.FillSolidRect(10, 10, width-20, height-20, color);
You removed this padding:
Code: [Select]
gb.FillSolidRect(0, 0, width, height, color);

Otherwise, you can probably use the function StackBlur instead of this resize trick which create a blur effect, look into SMP doc.

I found a ref in one of Br3tt's skins https://www.deviantart.com/br3tt/art/DUiTunes-beta3-412700925

I tried different ways to achieve it in SMP, the only function missing for this is BoxBlur() which has been removed since Jscript(?).
Eventually, I am using a png shadow file instead, overall it works fine. Thanks anyway.

https://imgur.com/94NqVBy
Title: Re: JScript Panel script discussion/help
Post by: Ottodix on 2019-04-04 17:45:14
i gave you the name of the function, StackBlur.
For example:
Code: [Select]
function createCoverShadowStack(cover_width, cover_height, color, radius){
var shadow = gdi.CreateImage(cover_width, cover_height);
    var gb = shadow.GetGraphics();
var radius = Math.floor(Math.min(cover_width/2,cover_height/2,radius));
    gb.FillSolidRect(radius, radius, cover_width-radius*2, cover_height-radius*2, color);
shadow.ReleaseGraphics(gb);
shadow.StackBlur(radius);
return shadow;
};
Title: Re: JScript Panel script discussion/help
Post by: seongbin on 2019-04-05 02:06:45
i gave you the name of the function, StackBlur.
For example:
Code: [Select]
function createCoverShadowStack(cover_width, cover_height, color, radius){
var shadow = gdi.CreateImage(cover_width, cover_height);
    var gb = shadow.GetGraphics();
var radius = Math.floor(Math.min(cover_width/2,cover_height/2,radius));
    gb.FillSolidRect(radius, radius, cover_width-radius*2, cover_height-radius*2, color);
shadow.ReleaseGraphics(gb);
shadow.StackBlur(radius);
return shadow;
};


Many THNAKS! It works perfectly.
Title: Re: JScript Panel script discussion/help
Post by: tedgo on 2019-08-29 18:47:02
(Strange that there's no activity in this thread for the last 120 days... are you all moved over to SMP?  ::) )

Hi at all,

i try to calculate the days between %first_played% and today and used this code (example):
Code: [Select]
var a = fb.TitleFormat("$date(%first_played%)").Eval()
var b = new Date();
var c = new Date(a);
var d = Math.floor((b.getTime() - c.getTime()) / 86400000);
I have no idea if i use it correctly because i have no clue about this Date() stuff...

The code snippet works with Chakra engine but not with Jscript engine.
So my question is: do i use it wrong?

Or is there any other (maybe inbuilt?) method for calculate date differences?
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2019-08-30 01:28:19
The code snippet works with Chakra engine but not with Jscript engine.
So my question is: do i use it wrong?

Or is there any other (maybe inbuilt?) method for calculate date differences?
I wonder if Date(a) is failing in Jscript. You should be using Chakra only though. Jscript is outdated.

I don't think there are any built in date difference functions. Yours works pretty well if you just want a good number of days difference. I wanted d/m/y diffs which used normal human differences (i.e. April 5th - Feb 5th = 2 months and not 1 month 28 days), so I wrote my own:

Code: [Select]
function dateDiff(startingDate, endingDate) {
    var hasStartDay = (startingDate.length > 7) ? true : false;
    if (!hasStartDay) {
        startingDate = startingDate + '-02';    // avoid timezone issues
    }
    var startDate = new Date(new Date(startingDate).toISOString().substr(0, 10));
    if (!endingDate) {
        endingDate = new Date().toISOString().substr(0, 10);    // need date in YYYY-MM-DD format
    }
    var endDate = new Date(endingDate);
    if (startDate > endDate) {
        var swap = startDate;
        startDate = endDate;
        endDate = swap;
    }
    var startYear = startDate.getFullYear();
    var february = (startYear % 4 === 0 && startYear % 100 !== 0) || startYear % 400 === 0 ? 29 : 28;
    var daysInMonth = [31, february, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

    var yearDiff = endDate.getFullYear() - startYear;
    var monthDiff = endDate.getMonth() - startDate.getMonth();
    if (monthDiff < 0) {
        yearDiff--;
        monthDiff += 12;
    }
    var dayDiff = 0;
    if (hasStartDay) {
        dayDiff = endDate.getDate() - startDate.getDate();
        if (dayDiff < 0) {
            if (monthDiff > 0) {
                monthDiff--;
            } else {
                yearDiff--;
                monthDiff = 11;
            }
            dayDiff += daysInMonth[startDate.getMonth()];
        }
    }

    return (yearDiff ? yearDiff + 'y ' : '') + (monthDiff > 0 ? monthDiff + 'm ': '') + (dayDiff ? dayDiff + 'd': '');
}

It handles regular foobar dates and also dates without a day value: "2018-08". It's pretty fault tolerant.
Title: Re: JScript Panel script discussion/help
Post by: tedgo on 2019-08-30 12:46:55
@MordredKLB
Thanks for this function, maybe its useful for me ;-)

But for now i only need the day difference for calculating and displaying "autorating" depending on the times a song has been played since "first play" and "today".
Title: Re: JScript Panel script discussion/help
Post by: tedgo on 2019-08-30 14:27:54
Now i've encountered another problem with the latest v2.2.2.4 (that wasn't present in the old v1.2.3 that i used before... yes, i used a quite old version...  :-* )

I coded a button script that has the option to enable additional buttons.
The commands and button names can be typed in a vb InputBox.

But all the time a button is enabled or disabled the default context menu of the jscript panel pops up... and i can't find the reason...

Can somebody (with enough time) please take a look at the code, and tell me what's wrong with it?

https://pastebin.com/tGJgTvta

P.S.: Attention!
Because you don't have the images for the upper two buttons:
If you want to try this script in a config be aware of that the upper left button exits foobar2000!
The upper right one is the menu button, all other buttons are obvious.
Title: Re: JScript Panel script discussion/help
Post by: tedgo on 2019-08-31 17:57:05
Problem solved.
I just forgot to add "return true" after "window.Reload"  to suppress the context menu :-*
Title: Re: JScript Panel script discussion/help
Post by: tedgo on 2019-09-05 11:33:35
And again my optional button panel...

With the linked script i can add optional buttons via context menu and ask for the command and the button name with Input boxes.
With a function (line 335 in the script) i test on first click on the new button if the given command (like: View/Playlist Manager, Playback statisctics/Rating/5 or fb.Play()) is a main menu, context menu or a JScript command and "assign" it, so there's no need to test the command every hit on the button again.
And this works good.

But how can i test (and execute) a predefined function (like getMainMenu, when i created a function getMainMenu() in the Script, like i did at line 470)?

Any ideas are welcome ;)

Optional Button Panel (https://pastebin.com/nZ3z8ApM)

Btw.: If there is someone who has a better idea or a more elegant way to test commands: i'm open for any improvements/enhancements ;)
Title: Re: JScript Panel script discussion/help
Post by: Sue Dunham on 2019-09-05 18:43:48
I'm new to javascript and not entirely sure this is the right place to ask, but it seems better than the others I've found. I've got the various js smooth components loaded into spider monkey panels and love them, but the playlist doesn't seem to support drag and drop. I can drag files onto a playlist in the playlist manager, but I'd like to move them within the playlist itself. Is it a matter of marrying the code in DragnDrop.js in the samples with that in jssp.js? Has anyone done this, and are there any common pitfalls for the unwary? I've successfully made play/pause and mute buttons toggle their images, but that's about my level of sophistication.
Title: Re: JScript Panel script discussion/help
Post by: tedgo on 2019-09-06 07:42:15
Btw. i replaced:
Code: [Select]
eval(tmp_string);
both times with:
Code: [Select]
var tmp_func = new Function('"use strict";' + tmp_string);
tmp_func();
in the script i linked HERE (https://hydrogenaud.io/index.php/topic,110516.msg975146.html#msg975146) in the meantime.
(I'm open for any better solution).

But my question is still relevant: how can i call and execute predefined functions with arguments (i forgot to mention it above, because without arguments my code works well) with my code?
The problem is that sometimes the functions don't have arguments so it should work in both cases.
Title: Re: JScript Panel script discussion/help
Post by: kgena_ua on 2020-05-24 11:24:24
 JScript Panel v 2.2.2.
fb.GetFocusItem() does not work

For for example:
Code: [Select]
    var tfo = fb.TitleFormat("%artist%");
    var items = tfo.EvalWithMetadb(fb.GetFocusItem());
"JavaScript runtime error:
Type mismatch"
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2020-05-24 16:00:53
Read the docs. fb.GetFocusItem can return null if nothing is selected so you must always check it first...

Code: [Select]
var metadb = fb.GetFocusItem();
if (metadb) {
    //do something with metadb
}
Title: Re: JScript Panel script discussion/help
Post by: MojoBass on 2020-07-26 07:39:38
@marc2003/snotlicker: still using your latest version of Coverflow View (originally from Br3tt) version 1.5.1 as posted by Grimes here (https://hydrogenaud.io/index.php?topic=110516.msg969499#msg969499) on JScript panel 2.4.0. It works well except with rightklick - error in line 3604
Code: [Select]
    Context.BuildMenu(_menu, 1, -1);
or when typing a letter to jump to the respective artists - error in line 3510
Code: [Select]
    if(list.total==0 || !fb.GetFocusItem(false)) return true;
Any chance to take a look into that?

I think it would even be great if Coverflow View could be included in the SMP Script Showcases (https://theqwertiest.github.io/foo_spider_monkey_panel/docs/script_showcase/single_panel_scripts/) from TheQweriest.
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2020-07-26 07:55:28
@marc2003/snotlicker: still using your latest version of Coverflow View (originally from Br3tt) version 1.5.1 as posted by Grimes here (https://hydrogenaud.io/index.php?topic=110516.msg969499#msg969499) on JScript panel 2.4.0. It works well except with rightklick - error in line 3604
Code: [Select]
    Context.BuildMenu(_menu, 1, -1);
or when typing a letter to jump to the respective artists - error in line 3510
Code: [Select]
    if(list.total==0 || !fb.GetFocusItem(false)) return true;
Any chance to take a look into that?

I think it would even be great if Coverflow View could be included in the SMP Script Showcases (https://theqwertiest.github.io/foo_spider_monkey_panel/docs/script_showcase/single_panel_scripts/) from TheQweriest.

BuildMenu only takes two parameters now. Just do:
Code: [Select]
Context.BuildMenu(_menu, 1);

fb.GetFocusItem does not take any parameters any longer:
Code: [Select]
if(list.total==0 || !fb.GetFocusItem()) return true;
Title: Re: JScript Panel script discussion/help
Post by: MojoBass on 2020-07-26 08:15:51
@MordredKLB: Wow, that was quick + it works!! Thanks very much!!! :)
Enclosed is the updated script.

What do you think about adding it to the SMP showcases?
Title: Re: JScript Panel script discussion/help
Post by: MordredKLB on 2020-07-26 17:12:11
That'd be a question for TheQwertiest and possibly Marc. I'm not sure if there was a reason it was excluded to begin with.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2020-07-26 20:52:17
I've never had anything to do with that particular script. Obviously the first thing you need to do is make all the changes necessary for it to work in SMP. If it works in JSP v2.4.0 right now, there is absolutely no way it's going to work without some tweaks. @TheQwertiest has detailed documentation on the changes required...

https://theqwertiest.github.io/foo_spider_monkey_panel/docs/guides/jsp_to_smp_migration_guide/
Title: Re: JScript Panel script discussion/help
Post by: gautxori on 2020-08-21 23:50:04
Hi, this is not working:
Code: [Select]
var objShell = new ActiveXObject('Shell.Application');
objShell.NameSpace(panel.tf('$directory_path(%path%)')).ParseName(panel.tf('%filename_ext%')).ModifyDate = '2018/09/07 15:51';
both panel.tf('$directory_path(%path%)') and panel.tf('%filename_ext%') return a correct value for the file to be changed, but date does not get modified.
If I run the same code, replacing 'panel.tf' values, from WSH, it does work. Any clue? Thanks.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2020-08-22 01:29:17
Seems to work fine for me?? Bear in mind that if you have a last modified column in your playlist, it won't update automatically since you're updating the file externally. Running this directly after may help...

Code: [Select]
fb.RunContextCommandWithMetadb("Tagging/Reload info from file(s) if changed", panel.metadb);
Title: Re: JScript Panel script discussion/help
Post by: gautxori on 2020-08-22 07:46:33
Seems to work fine for me??
Actually it works. The reason my code is not working is because there are three lines just before,
Code: [Select]
var handles = fb.CreateHandleList(panel.metadb);
handles.UpdateFileInfoFromJSON(JSON.stringify(obj));
_.dispose(handles);
And it takes some time to update the file, i guess asynchronously, so when my code is run the file is not available. Is there any way to make sure UpdateFileInfoFromJSON has done its job before I update file modified time?

Quote
Bear in mind that if you have a last modified column in your playlist, it won't update automatically since you're updating the file externally. Running this directly after may help...
Code: [Select]
fb.RunContextCommandWithMetadb("Tagging/Reload info from file(s) if changed", panel.metadb);
Thanks for that tip!
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2020-08-22 11:34:24
Yes it's async but I would expect a single track to get updated pretty much instantly?? You get a progress dialog for longer operations and the component has no way of knowing when it's complete.

Anyway, check File>Preferences>Advanced>Tagging>General>Preserve file creation/access/modification time. That probably bypasses the need to write old timestamps back??
Title: Re: JScript Panel script discussion/help
Post by: gautxori on 2020-08-22 12:15:21
Yes it's async but I would expect a single track to get updated pretty much instantly??
Not really, otherwise my code would have worked. I solved it with a window.setTimeout call.

Quote
Anyway, check File>Preferences>Advanced>Tagging>General>Preserve file creation/access/modification time. That probably bypasses the need to write old timestamps back??
That could help. Thanks!.
Title: Re: JScript Panel script discussion/help
Post by: grimes on 2020-12-31 10:55:53
In the sample script "Thumbs", I can search with %artist% in the last fm artist database. I have a lot of classical music and I'm interested in composer pictures. The composers name is stored in my %performer% tag. How can I search in the last fm database with %performer%?
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2020-12-31 11:17:23
Open the configuration window and enter this as the first line of the script before var panel...

Code: [Select]
DEFAULT_ARTIST = '$meta(performer,0)';

You could use %performer% if you were sure all tags are single value. Lookups of multi-value tags would not work well.
Title: Re: JScript Panel script discussion/help
Post by: grimes on 2020-12-31 11:34:24
Thank you, it works!
Title: Re: JScript Panel script discussion/help
Post by: arcos on 2021-04-13 20:57:57
Hello all, i use JS Smooth Browser to see my new album in my librairie, i would like to have the most recent at the beginning so i add this in the Panel properties "sort order album :  $date(%last_modified%) | %album% | %discnumber% | %tracknumber% | %title% ".
l works fine but my newest albums are at the end of the list ...is it possible to sort the list by descending ?
i try : SORT BY DESCENDING  $date(%last_modified%) but nothing changed.....
thanks for your help.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2021-04-13 22:48:15
You can only use standard title formatting there, not query syntax.

Try

Code: [Select]
$sub(99999999,$replace($date(%last_modified%),-,)) | %album% | ....
Title: Re: JScript Panel script discussion/help
Post by: arcos on 2021-04-14 08:27:20
 ;)  ;)  ;)
Fine, thank you !
Title: Re: JScript Panel script discussion/help
Post by: grimes on 2021-06-08 16:47:52
Feature request for sample script "playback buttons": add option to center buttons in panel. Thanks.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2021-06-08 17:40:50
Replace existing buttons.update function with this...

Code: [Select]
buttons.update = function () {
var x_pos = (panel.w - (bs * 4)) / 2;
this.buttons.stop = new _.button(x_pos, 0, bs, bs, {normal : 'buttons\\stop.png'}, function (x, y, mask) { fb.Stop(); }, 'Stop');
this.buttons.play = new _.button(x_pos + bs, 0, bs, bs, {normal : !fb.IsPlaying || fb.IsPaused ? 'buttons\\play.png' : 'buttons\\pause.png'}, function (x, y, mask) { fb.PlayOrPause(); }, !fb.IsPlaying || fb.IsPaused ? 'Play' : 'Pause');
this.buttons.previous = new _.button(x_pos + (bs * 2), 0, bs, bs, {normal : 'buttons\\previous.png'}, function (x, y, mask) { fb.Prev(); }, 'Previous');
this.buttons.next = new _.button(x_pos + (bs * 3), 0, bs, bs, {normal : 'buttons\\next.png'}, function (x, y, mask) { fb.Next(); }, 'Next');
}
Title: Re: JScript Panel script discussion/help
Post by: Majestyk on 2021-07-25 23:17:44
It's nice to see some Coverflow chatter here. Does anyone know how to highlight the cover of the now playing track, only? As opposed to highlighting any cover that's been selected. Thanks!
Title: Re: JScript Panel script discussion/help
Post by: Majestyk on 2021-07-26 00:55:20
Actually, never mind. The Coverflow is buggy and doesn't work properly with JS Smooth playlist. If you click on the Coverflow's album cover, it will not highlight on JSS unless the cover happens to be in view. In other words JSS can't scroll up and down with coverflow. JS Playlist works fine.

I'm using  v1.5.2: Bug Fixes by MordredKLB

EDIT... Actually, it's JSS that's the culprit. Don't know why it started doing this. It wasn't doing this before.

Another EDIT. :) It would seem using 2.5.6 version of JSS causes it to behave this way when 2.6.1 DLL is installed. Problem solved.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2021-07-26 01:45:09
The script isn't at fault - the actual component has a bug that needs fixing. I'll look at pushing out a release later on today.
Title: Re: JScript Panel script discussion/help
Post by: Majestyk on 2021-07-26 02:42:12
LOL, I'm keeping you busy. Anyway, thanks for verifying that.
Title: Re: JScript Panel script discussion/help
Post by: Majestyk on 2021-07-28 23:00:58
How easy/hard is it to fix a line like this (from Darkone) now that "Dispose" doesn't work anymore.

Quote
   this.onMouseOut = function() {
      g_tooltip.Deactivate();
      g_tooltip.Dispose();
   }
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2021-07-28 23:48:43
It should be as simple as removing the line of code that contains the .Dispose call.

However, that would imply the script is calling window.CreateTooltip more than once in a panel instance which no longer permitted. If you remove that line and still get errors, post the whole script and I'll tell you how to adjust it.
Title: Re: JScript Panel script discussion/help
Post by: Majestyk on 2021-07-29 03:07:27
Hey, thanks again! There was a domino effect, so the next trouble line was...

Quote
g_tooltip = window.CreateTooltip();

I changed it to...

Quote
g_tooltip = window.Tooltip;

Then I got another error about mousein or something. Anyway, I deleted all these entries and surprisingly (to me) it worked:

Quote
var g_tooltip;

this.tiptext = tiptext;

   this.onMouseIn = function() {
      g_tooltip = window.CreateTooltip();
      g_tooltip.Text = this.tiptext;
      g_tooltip.Activate();
   }

   this.onMouseOut = function() {
      g_tooltip.Deactivate();
      g_tooltip.Dispose();

(Also deleted some mousein/out entries in the main script)

Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2021-07-30 00:19:15
Well there's no such thing as window.Tooltip. It won't throw errors because window is a global object so you'll end up with an undefined variable meaning you can't do anything with it.

Removing all that code means no tooltips but obviously they're not even close to being required if the button text/icons are clear.
Title: Re: JScript Panel script discussion/help
Post by: ZarkBit on 2022-06-10 22:24:25
...
Title: Re: JScript Panel script discussion/help
Post by: fooball on 2022-07-18 19:29:18
Right, so, with an interest in seeing whether I can use JS to create a custom transport button panel and maybe even tailor the speed/pitch/tempo control, I installed a fresh portable FB2K and added JScript Panel from Github.  So far so good.

I then added JScript Panel to the installed components, and simply replaced the whole Default UI default panel with a JScript Panel panel.  So far so good.

Then I clicked in the panel as instructed (which brought up the editor), clicked "samples", selected "Track Info +Seekbar + Buttons", and then "OK".  But this is what I ended up with:

X

Is that right?  If not, what's gone wrong?  What do I do now?
Title: Re: JScript Panel script discussion/help
Post by: anamorphic on 2022-07-19 09:39:17
^ I'm guessing last thing on the first page of the docs (https://marc2k3.github.io/jscript-panel/docs/) -
Quote
Nearly all included samples require the installation of FontAwesome which you can grab here ...
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-07-19 13:34:48
As above, you're just missing the font.

https://github.com/FortAwesome/Font-Awesome/blob/4.x/fonts/fontawesome-webfont.ttf?raw=true

When present, it should look like this...

https://marc2k3.github.io/jscript-panel/gallery/#track-info-seekbar-buttons

If you want to change the size of the buttons/text easily, you can open the editor and add this at the start of the script..

Code: [Select]
DPI = 144; //150%

If you wanted double the size, you could use 192. You can play around with the values until you find what is best for you.
Title: Re: JScript Panel script discussion/help
Post by: fooball on 2022-07-19 16:06:32
Sorry, I figured buttons would be graphic elements not fonts!
Title: Re: JScript Panel script discussion/help
Post by: mjm716 on 2022-07-24 17:14:09
Regarding JS Smooth sample, can anyone help me find where to adjust source (playlist instead of library)?
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-07-25 12:13:13
It's not easy. Lots of new code would have to written. Making it read playlist contents instead of  the media library when it initialises is easy enough but you want it to respond to playlist switching, items being added/removed/reordered etc. Also, the sort order is forced in Library mode but you'd want original order preserved as a playlist. Then you have the selection logic to contend with such as making your playlist viewer jump to selection etc.

Pretty sure WilB's Library Tree for SMP does it all with zillions of options not present in Smooth Browser so you should be using that.

Title: Re: JScript Panel script discussion/help
Post by: mjm716 on 2022-07-25 12:49:05
It's not easy. Lots of new code would have to written.

ok thanks. It was listed as a feature on Falstaff's old deviant site, but no worries.

Libary Tree bogs down on my collection, while Smooth is still pretty smooth. I'm assuming it is better JSPanel performance over SMP currently.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-07-25 13:22:24
Yeah it did exist previously but it was quite buggy and rather than fix the bugs, I removed it. I may consider restoring it at a later date but no promises.

As for SMP vs JSP, SMP really should be faster at everything. Not sure what is going on there??
Title: Re: JScript Panel script discussion/help
Post by: fooball on 2022-08-21 18:12:07
This is a query about the JS Smooth Playlist Manager sample.

Right-click offers a variety of options, but not Save.  I thought I might find (and alter) the list of options in the script, but it imports a load of other stuff and has limited functionality actually within the JS Smooth Playlist Manager script.

Any pointers?
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-08-21 18:26:14
I assume you're talking about Smooth Playlist Manager and not Smooth Playlist?

In theory it would be possible to add a Save item to the menu but it would only be a shortcut to the main menu command which saves the active playlist only. It's not possible to make it respond to the mouse position and save whichever playlist you happen to be right clicking on.
Title: Re: JScript Panel script discussion/help
Post by: fooball on 2022-08-21 18:37:21
I assume you're talking about Smooth Playlist Manager and not Smooth Playlist?
Yes, sorry, have edited.

In theory it would be possible to add a Save item to the menu but it would only be a shortcut to the main menu command which saves the active playlist only. It's not possible to make it respond to the mouse position and save whichever playlist you happen to be right clicking on.
Better than nothing - how do I go about that?
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-08-21 18:59:17
Right click> save as... https://gist.githubusercontent.com/marc2k3/c980fe6ac21ad6bc7f532c76724a3f42/raw/9c12c335fd53e7c848da03496cc5212a8efeba8b/jsspm.js

Save it inside your foobar2000 profile folder\user-components\foo_jscript_panel\samples\smooth and overwrite the existing file.

edit: restart fb2k if it's running while you do this.
Title: Re: JScript Panel script discussion/help
Post by: fooball on 2022-08-21 19:49:50
That's great, thank you.  I've just adjusted it to read "Save Active Playlist..." (as a reminder it doesn't necessarily mean the one under the mouse).
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-08-21 20:04:37
I might implement a file picker dialog in the component which would make saving the clicked on playlist possible but of course that will be on my new fangled version, not the abandoned one you're using.  :P
Title: Re: JScript Panel script discussion/help
Post by: fooball on 2022-08-21 20:07:37
But the specific script might be translocatable?
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-08-21 20:40:49
Nope. The script would be calling a new method built in to the component which is written in C++. While you could look at the script changes, you can't utilise methods that don't exist in your version.
Title: Re: JScript Panel script discussion/help
Post by: sveakul on 2022-08-22 00:55:44
@marc2k3:  You helped me before with a script addition to the spectrogram seekbar sample code that would force auto-deletion of any images in its cache folder every time the script was unloaded:

Code: [Select]
function on_script_unload() {
utils.ListFiles(spectrogram_cache).toArray().forEach(function (item) {
_deleteFile(item);
});
Since changing from JScript Panel 2.88 to JScript Panel 3 version 3.03 I find that this addition no longer works.  I'd be most grateful if you could post an updated version of the code addition that does the same for 3.03--thanks a million!
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-08-22 02:01:56
Code: [Select]
function on_script_unload() {
utils.ListFiles(spectrogram_cache).toArray().forEach(function (item) {
utils.RemovePath(item);
});
}
Title: Re: JScript Panel script discussion/help
Post by: sveakul on 2022-08-22 20:23:28
Code: [Select]
function on_script_unload() {
utils.ListFiles(spectrogram_cache).toArray().forEach(function (item) {
utils.RemovePath(item);
});
}
Works perfectly, thank you very much!
Title: Re: JScript Panel script discussion/help
Post by: cat_plasma on 2022-09-07 21:37:01
I'm using spectrogramm seekbar and I want to say that png files of spectrograms take up too much disk space. There are much more efficient codecs, namely webp, jxl, avif and heic, but at least jpg. Right now there is no choice in which format the spectrogram file will be saved, but I really want it to appear.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-09-07 21:50:49
ffmpeg generates a png with no choice. I guess I could the read the png, save as jpg and then delete the png. I'll look in to it as an option.

During early development of JSP3, I did toy with the idea of webp encoding but it's too expensive cpu wise. All javascript is running in the main thread and you don't want it blocking.

edit: before anyone says ffmpeg is also blocking, you know it's for a reason.  :P

edit2: or check the post above yours to clear the cache automatically when fb2k exits. Of course that means repeat scanning on every new session.
Title: Re: JScript Panel script discussion/help
Post by: cat_plasma on 2022-09-08 20:03:05
You're wrong, ffmpeg is able to save the spectrogram in any graphic format, just change the file extension from .png to .jpg or .jxl. Just checked, he can do it. But jpg is an old format with bad compression, jxl is much better, please use it.
If encoding seems too long for you, you can add a secondary script that would create spectrograms for each library file in the background without disturbing the user. Or, let's say the user turned on a new album, a spectrogram in png was created for its first track, when playback reaches the second track, a png spectrogram will be created for the second track, and the picture of the spectrogram of the first track in the background will be compressed into webp or jxl.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-09-08 20:53:46
I'll stand corrected then. Not sure where I got the png idea from. Perhaps a hangover from using SoX on a previous version. I can't remember.

I'll probably use webp. jxl is too obscure and would require people going out of their way to find a WIC decoder thingy. webp is generally supported out of the box on 10/11 or google provides a download for 7/8/8.1 users.

edit: I've made the changes here: https://github.com/marc2k3/jscript-panel/commit/a01d7024dba35463676798010f69f7343f0a5d49
Title: Re: JScript Panel script discussion/help
Post by: fooball on 2022-09-09 08:31:42
But jpg is an old format with bad compression, jxl is much better, please use it.
Whether JXL is "better" depends on your point of view.  JPG and MP3 are de facto standards and universally supported, regardless of whether they represent the pinnacle of compression ratio vs. fidelity.  JXL is obscure, and damned if I'm going to adopt it just to save a few megabytes of disk space.
Title: Re: JScript Panel script discussion/help
Post by: cat_plasma on 2022-09-09 20:46:44
Thank you for listening to my request. The default webp is of very low quality, you can visually see how bad the new spectrograms look. If you add the ffmpeg options "-lossless 1 -compression_level 6", you get a lossless webp, which is about 1.5 or 1.8 times more compression ratio than png (I personally checked it). But I still prefer jxl for its relentless and unbelievable compression ratio.
The biggest problem with jxl in jscript-panel is that foobar2000 simply doesn't render .jxl images. I changed .png to .jxl on line 233 of seekbar.js as you did in this commit, first a white rectangle is shown on the background of the empty bar for a few seconds, saying that the spectrogram is in the process of being created, and after that a solid black background. The .jxl file is in the folder, but the image doesn't appear in foobar2000.
It is very sad. However, you can store spectrograms on hdd, which is much cheaper and more reliable than ssd. It would be great to add the option "delete older than a month, two, three months", otherwise a week is somehow not enough.

But jpg is an old format with bad compression, jxl is much better, please use it.
a few megabytes of disk space.

Several megabytes for each file, about 80% of its weight, while the files themselves can be hundreds or thousands.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-09-09 21:19:09
My component can display jxl files if I do this....

https://github.com/saschanaz/jxl-winthumb#how-to-install

Is there a better way?

Incidentally, ffmpeg seems to barf and not generate any file at all.

Everything is in this image.

https://i.imgur.com/ILhtdZv.png

edit: this is all moot, it's not like I'm changing it for this. I just wanted to show that any program with WIC support *should* work if the relevant codecs are installed.

Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-09-10 01:44:19
So of course I was being an idiot trying to run that command in powerhsell without prefixing it with cmd /c. Oops.

But while the file is generated, changing the file extension is seemingly not enough...

(https://i.imgur.com/mUFrhK4.png)

But you can edit it to whatever you like (or ignore it).

And now it's working, it's noticeably slower. I guess that "superiority" comes with a price.

(https://i.imgur.com/NCv20xL.gif)
Title: Re: JScript Panel script discussion/help
Post by: cat_plasma on 2022-09-10 07:26:00
Very strange! You can see from the screenshot that Foobar2000 shows .jxl files. I have these files in the spectrogram_cache folder, but they are not shown in the player itself. I installed jxl-winthumb, in other programs, jxl pictures began to be displayed after installing it. But not in Foobar2000.
Title: Re: JScript Panel script discussion/help
Post by: fooball on 2022-09-10 07:53:52
Several megabytes for each file, about 80% of its weight, while the files themselves can be hundreds or thousands.
That's your own problem!  Maybe instead of
jxl is much better, please use it.
...you actually meant "please make jxl available as an option".
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-09-10 11:33:33
But not in Foobar2000.

Not sure if you're talking about this component or foobar2000 in general??

fb2k itself has only been able to display jxl (and other exotic codecs) since v2 was released nearly 2 weeks ago.

As for my component, only foo_jscript_panel3 can do it. The was released back in April I think. The original foo_jscript_panel can not.

All this comes from utilising the windows imaging component (WIC). The C++ code is entirely generic and has no idea about what codecs you have installed. While the JSP3 source code is not online, I have another component which uses WIC and you can see the code is just a few lines here...

https://github.com/marc2k3/foo_cover_resizer/blob/51776f5480ad72e6a255fa1f955a5d61bba33cc7/src/Helpers.hpp#L7L16




Title: Re: JScript Panel script discussion/help
Post by: cat_plasma on 2022-09-10 12:26:51
Thanks for letting me know about the beta! On the beta version, jxl works for me too.
Now I will look for a way to transfer my settings from the stable version to the beta. Copying the profile folder results in an error at startup.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-09-10 12:33:38
You can use v3.0.3 of my component with fb2k v1.5/1.6.

The album art sample can display .jxl files if you manually add .jxl under File>Preferences>Display>Album Art. Wildcards are not supported like they are for common types like jpg/png/etc

The thumbs sample for displaying multiple images will not display jxl files by default but the script can be edited, After the second line...

Code: [Select]
var thumbs = new _thumbs();

Add

Code: [Select]
thumbs.exts.push('jxl');


Title: Re: JScript Panel script discussion/help
Post by: cat_plasma on 2022-09-10 13:20:39
I am using jscript panel version number 3.03 on foobar version 1.6.7. .jxl doesn't work in this version, but it opens in Foobar2000 beta. And only with 64-bit architecture. But the plugins I need are not available for the 64-bit architecture, they only work in the 32-bit beta version, on which jxl does not work for me. Some kind of curse.
I don't know about any miniatures or album covers.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-09-10 13:31:27
So I didn't test and just assumed...  https://github.com/saschanaz/jxl-winthumb/issues/18
Title: Re: JScript Panel script discussion/help
Post by: cat_plasma on 2022-09-11 18:40:23
Do you have any ideas how to fix this? Add 64bit plugin support to 32bit foobar.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-09-12 00:06:10
/backs out of thread slowly....

Not just for that question but your obsession with jxl. It's getting weird now.
Title: Re: JScript Panel script discussion/help
Post by: sveakul on 2022-09-26 20:32:15
I am asking for the favor of a JScript Panel 3 script that would take simple "now playing" information from Foobar v2 64-bit and write it to an external text file, appending lines within the file as each song is played to a specified limit (lines or file size).  The information would be the date/time played and the <artist> - <title> information from the track, from either dynamic radio station metadata or fixed files.  Nothing would need to be kept in a DB, just written into the text file appending each track while Foobar is in use.  Thanks for any help you can provide.
Title: Re: JScript Panel script discussion/help
Post by: zeremy on 2022-09-27 19:06:21
I am asking for the favor of a JScript Panel 3 script that would take simple "now playing" information from Foobar v2 64-bit and write it to an external text file, appending lines within the file as each song is played to a specified limit (lines or file size).  The information would be the date/time played and the <artist> - <title> information from the track, from either dynamic radio station metadata or fixed files.  Nothing would need to be kept in a DB, just written into the text file appending each track while Foobar is in use.  Thanks for any help you can provide.

This will do it in the background, nothing is displayed in the panel.
Set maxfilesize to your preferred limit (the value is in bytes)

Code: [Select]
var myhistory = fb.ProfilePath + "myhistory.txt";
var maxfilesize = 5242880; //5MB in bytes

if (utils.IsFile(myhistory) == false) {
    utils.WriteTextFile(myhistory, "");
}

function save_history() {
    var fsize = utils.GetFileSize(myhistory);
    if (fsize < maxfilesize) {
        var strContents = utils.ReadTextFile(myhistory);
    } else {
        strContents = "";
    }
var now = Math.round(new Date().getTime() / 1000);
    var artist = fb.TitleFormat("%artist%").Eval();
    var title = fb.TitleFormat("%title%").Eval();
    var strNewContents = strContents + "\n" + "[" + utils.TimestampToDateString(now) + "]  " + artist + " - " + title;
    if (artist && title) {
        utils.WriteTextFile(myhistory, strNewContents);
    }
}

function on_playback_new_track() {
    save_history();
}

function on_playback_dynamic_info_track() {
    save_history();
}
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-09-27 19:50:57
@zeremy

Code: [Select]
function on_playback_dynamic_info_track() {
    save_history();
}

That code might log double entries depending on stream. Since fb2k v1.6.6 came out with support for album art from radio streams, I updated that callback to supply a type argument. It has a value of 0 for metadata updates and 1 for album art updates.

https://marc2k3.github.io/jscript-panel/docs/callbacks/#on_playback_dynamic_info_tracktype
https://marc2k3.github.io/jscript-panel/docs/interfaces/IMetadbHandle/#getalbumartart_id-want_stub

To avoid duplication...

Code: [Select]
function on_playback_dynamic_info_track(type) {
    if (type == 0) save_history();
}

Title: Re: JScript Panel script discussion/help
Post by: zeremy on 2022-09-27 20:00:40
@marc2k3

Yeah , I missed that update on the callback, should have checked your docs.

Thanks for the info.
Title: Re: JScript Panel script discussion/help
Post by: sveakul on 2022-09-27 21:42:38
Thanks zeremy and marc2k3 for the scripts!

From the start I used marc2k3's replacement for the dynamic info.  For fixed music files all works perfect, but for stream track metadata I am seeing doubling (but single in 3 cases) and occasionally tripling of artist/titles lines, and occasionally the station names preceded by a "?" in the artist field.  Sample log below.  Station changes were made by double-clicking a new stream as opposed to hitting stop first.  Any way to fix this?

[2022-09-27 16:28:29]  ? - Decennial Gothica Radio I
[2022-09-27 16:28:29]  ? - Decennial Gothica Radio I
[2022-09-27 16:28:30]  Pain - Dirty Woman
[2022-09-27 16:28:36]  Arcana Elysium - Cold Road
[2022-09-27 16:28:36]  Arcana Elysium - Cold Road
[2022-09-27 16:28:42]  Sirenia - In a maniac
[2022-09-27 16:28:42]  Sirenia - In a maniac
[2022-09-27 16:29:09]  ? - Pangea
[2022-09-27 16:29:09]  ? - Pangea
[2022-09-27 16:29:11]  To Die For - Sorrow Remains
[2022-09-27 16:29:17]  Fleetwood Mac - Little Lies (Extended Remix)
[2022-09-27 16:29:18]  Fleetwood Mac - Little Lies (Extended Remix)
[2022-09-27 16:29:29]  Nikola Iliev - Save Me (Original Mix)
[2022-09-27 16:29:30]  Nikola Iliev - Save Me (Original Mix)
[2022-09-27 16:29:30]  Nikola Iliev - Save Me (Original Mix)
[2022-09-27 16:30:13]  Duran Duran - The Chauffeur [qdI]
[2022-09-27 16:30:13]  Duran Duran - The Chauffeur [qdI]
[2022-09-27 16:30:37]  Cairo Gang - Ice Fishing
[2022-09-27 16:30:37]  Cairo Gang - Ice Fishing
[2022-09-27 16:30:38]  Cairo Gang - Ice Fishing
[2022-09-27 16:30:45]  Lettie - Never Want To Be Alone
[2022-09-27 16:30:45]  Lettie - Never Want To Be Alone
[2022-09-27 16:30:45]  Lettie - Never Want To Be Alone
[2022-09-27 16:30:53]  ? - Lush: Mostly female vocals with an electronic influence. [SomaFM]
[2022-09-27 16:30:53]  ? - Lush: Mostly female vocals with an electronic influence. [SomaFM]
[2022-09-27 16:30:53]  Schiller - Sunrise




Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-09-27 22:19:46
Well the callback responsible is getting more notifications than you would expect and that can only come from the server.

This should workaround it by not logging any consecutive duplicates.

Code: [Select]
// ==PREPROCESSOR==
// @import "%fb2k_component_path%samples\js\lodash.min.js"
// ==/PREPROCESSOR==

var limit = 100;
var tfo = fb.TitleFormat("[%artist% - ]%title%");
var path = "Z:\\fb2k_log.txt";

/////////////////////////////////////////////////////////////////////////////////////////////////////////

var last = '';

function on_playback_new_track() {
log_it();
}

function on_playback_dynamic_info_track(type) {
if (type == 0) {
log_it();
}
}

function now_as_string() {
var now = Math.floor(Date.now() / 1000);
return utils.TimestampToDateString(now);
}

function log_it() {
var current = tfo.Eval();
if (current != last) {
last = current;

var text = utils.ReadUTF8(path);
var arr = _(text.trim().split("\r\n"))
.filter(function (item) { return item.length > 0; })
.takeRight(limit - 1)
.value();
arr.push(now_as_string() + " " + current);
utils.WriteTextFile(path, arr.join("\r\n"));
}
}
Title: Re: JScript Panel script discussion/help
Post by: sveakul on 2022-09-27 22:51:01
Thanks marc2k3 for the new script!  This one works great, no doubles, just the station name on one line followed by the track played on the next.  I really appreciate it.  BTW, can you confirm what the "var limit" number refers to (lines or file size), and if when the limit is reached the log will "scroll delete" the oldest entry from the top of the list?

I listen to a lot of Interent radio and sometimes I hear a song I want to refer back to but forgot the track artist/title; this log feature is perfect for helping to recall it.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-09-27 22:54:47
It's 100 lines. You can obviously change it and the first entry is discarded to make way for a new one when the limit is reached,
Title: Re: JScript Panel script discussion/help
Post by: sveakul on 2022-09-28 01:37:40
OK, thanks!
Title: Re: JScript Panel script discussion/help
Post by: etip on 2022-10-02 09:13:52
Hi all,
I have this abstract of a script below that executes correctly when foobar is running but if i'm closing foobar and opening it again, this code crashes at line 18 ie :
Code: [Select]
img = utils.CreateImage(window.Width, 40);
Anyone would know why ?
Thanks in advance
Code: [Select]
// ==PREPROCESSOR==
// @name "StackBlur (text)"
// @author "marc2003"
// @import "%fb2k_component_path%helpers.txt"
// ==/PREPROCESSOR==

var colour = RGB(129, 166, 192);
var img = null;
var g_font = JSON.stringify({
Name : "Segoe UI",
Size : 32,
Weight : 700,
});

create_image();

function create_image() {
img = utils.CreateImage(window.Width, 40);
var g = img.GetGraphics();
    text_to_draw = "FB";
g.WriteText(text_to_draw, g_font, colour, 150, 0, 40,40, 2, 2, 1, 1);
img.ReleaseGraphics();
g=null;
}
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-10-02 09:28:58
List item 5....

https://marc2k3.github.io/jscript-panel/docs/tips/
Title: Re: JScript Panel script discussion/help
Post by: etip on 2022-10-02 11:00:34
Thanks Marc,
It's true that while i'm reading your docs extensively, this tips section, i may have read it only once !

Still, i cant make it to work.
This is what i've done and now the
Code: [Select]
img = utils.CreateImage(ww, 40);
line raises an error, which is understandable as i'm not resizing the window at startup.

Code: [Select]
// ==PREPROCESSOR==
// @name "StackBlur (text)"
// @author "marc2003"
// @import "%fb2k_component_path%helpers.txt"
// ==/PREPROCESSOR==

var colour = RGB(129, 166, 192);
var img = null;
var ww;
var g_font = JSON.stringify({
Name : "Segoe UI",
Size : 32,
Weight : 700,
});

create_image();

function create_image() {
img = utils.CreateImage(ww, 40);
var g = img.GetGraphics();
    text_to_draw = "FB";
g.WriteText(text_to_draw, g_font, colour, 150, 0, 40,40, 2, 2, 1, 1);
img.ReleaseGraphics();
g=null;
}

function on_size() {
ww=window.Width;
}
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-10-02 11:29:59
on_size is always called as part of the script initialisation process but that doesn't happen until any code not inside any function has run first.

But since you want the image based on the panel width, you should call create_image() from inside on_size like this.

Code: [Select]
var img = null;
var ww = 0;
// create_image(); // remove this.

function on_size() {
ww = window.Width;
create_image();
}

function create_image() {
if (img) img.Dispose();
img = utils.CreateImage(ww, 40);
var g = img.GetGraphics();
text_to_draw = "FB";
g.WriteText(text_to_draw, g_font, colour, 150, 0, 40,40, 2, 2, 1, 1);
img.ReleaseGraphics();
g=null;
}
Title: Re: JScript Panel script discussion/help
Post by: etip on 2022-10-02 12:42:05
and this solves it perfectly !

Thanks for your continued support Marc !

Ps : If i wanted to understand the on_size behavior (the fact it runs after a code not within a function has executed), would you have any pointers ?
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-10-02 14:21:43
Only code outside any function is run when the script parser evaluates the script. You can of course have your own 10,000 line function and call that. Assuming there are no errors during that phase, nothing would ever happen without callbacks sent by the component.

So the first thing that happens is that on_size is called. This has to be faked because if you're editing the script and clicking OK/Apply in the config window, that is not a cause for the panel to be resized. And when on_size is done, on_paint comes next.

After that, it depends entirely on the callbacks you include in the script and the actions you make on the panel and fb2k events such as playback starting/stopping etc. All that is documented on the callbacks page.

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

I should update the entry for on_size to make it clearer what happens on startup.

Title: Re: JScript Panel script discussion/help
Post by: etip on 2022-10-02 21:17:51
alright, it's clearer. Thanks !
Title: Re: JScript Panel script discussion/help
Post by: etip on 2022-10-07 22:42:47
Hi there !
Quick question : Is it possible to retrieve the query from an AutoPlaylist ?
I need to go deeper in a given playlist, ie keep the current filter and append it with another criteria.
I didnt see any Plman functions to provide it hence i'm checking here if there is any workarounds.
Thanks
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-10-08 03:35:19
No, that isn't possible. You can edit the query for an autoplaylist by right clicking any playlist switcher/tab/etc or using plman.ShowAutoplaylistUI

https://marc2k3.github.io/jscript-panel/docs/namespaces/plman/#plmanshowautoplaylistuiplaylistindex
Title: Re: JScript Panel script discussion/help
Post by: etip on 2022-10-08 08:30:31
ah too bad, Thanks for the answer anyways !
Title: Re: JScript Panel script discussion/help
Post by: etip on 2022-10-09 11:33:06
Me again !
I'm trying to make a generic Tagging function which will have 2 parameters : the tag and the value.
unfortunately, i can't manage to set the array correctly.
following the examples from the documentation/forum, i've tried :
Code: [Select]
	arr.push({
        tag : value,
});
and then
Code: [Select]
var str = JSON.stringify(arr);
where as tag and value are parameters from the function (here it's "Rating" and 5).
The result is using "Tag" as a string and not a variable. (so i get an array of : {"Tag":5} instead of {"Rating":5}.

I tried different methods to fill the array (.fill) but i read that the JS engine dont allow it.

Any workarounds ?
Thanks
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-10-09 12:09:27
You have to do it like this...

Code: [Select]
var obj = {};
obj[tag] = value;
arr.push(obj);
Title: Re: JScript Panel script discussion/help
Post by: regor on 2022-10-09 12:39:43
Me again !
I'm trying to make a generic Tagging function which will have 2 parameters : the tag and the value.
unfortunately, i can't manage to set the array correctly.
following the examples from the documentation/forum, i've tried :
Code: [Select]
	arr.push({
        tag : value,
});
and then
Code: [Select]
var str = JSON.stringify(arr);
Just for your info, note according to docs JS supports ES5 (https://marc2k3.github.io/jscript-panel/), in ES6 what you wanted to do is named computed property names:
Code: [Select]
arr.push({
        [tag] : value,
});
But that doesn't work in ES5. (in any case, just putting 'tag' without brackets does nothing)
Title: Re: JScript Panel script discussion/help
Post by: etip on 2022-10-09 13:16:12
As usual, it's perfect.
Thanks Marc !
@regor : thanks for the info
Best
Title: Re: JScript Panel script discussion/help
Post by: metal_termite on 2022-10-10 20:53:54
Since it looks like foo_plorg (aka foo_playlist_organizer) (https://hydrogenaud.io/index.php/topic,80705.0.html) will not be getting any updates, I am wondering if a similar project would be doable in the JScript Panel. Not asking anyone to make this, just curious if its aesthetic and features could be ported to the JScript Panel.

Namely:
- Support for nodes/leafs (nested folders) for playlist organization
- Drag-and-drop support for reorganizing and relocating folders and playlists
- More in attached image mock-up

(Yes, I have seen a few other JScript playlist managers but did not find their UIUX compelling)
Title: Re: JScript Panel script discussion/help
Post by: regor on 2022-10-11 11:03:35
Since it looks like foo_plorg (aka foo_playlist_organizer) (https://hydrogenaud.io/index.php/topic,80705.0.html) will not be getting any updates, I am wondering if a similar project would be doable in the JScript Panel. Not asking anyone to make this, just curious if its aesthetic and features could be ported to the JScript Panel.

Namely:
- Support for nodes/leafs (nested folders) for playlist organization
- Drag-and-drop support for reorganizing and relocating folders and playlists
- More in attached image mock-up

(Yes, I have seen a few other JScript playlist managers but did not find their UIUX compelling)
One problem with such approach, and one of the reasons I did not even consider folders as nodes on my own manager (althought it's for SMP and not JSP), is that user experience for that design/UI only works fine for a small number of playlists and users not using playlist tabs.

It becomes a nightmare to manage +100 pls. You have to rearrange playlists one by one, etc. Playlist tab panel becomes cluttered,. Also the hierarchy is plugin/script dependent. i.e. a person with foo_plorg now has to recreate the entire folder node list on another plugin. And it will be the same on the future when switching to another plugin or installation. Also playlists must be always loaded on the program, since they appear on the manager only because the playlist is loaded within foobar (*). I see that approach too limited.

It's looks cool though. And obviously is good enough for many people.

Working with playlist files, instead of playlists instances within foobar, lets you programmatically add an associated category/folder to playlists. You don't need nodes, since you can simply filter the view for a given category/folder. I have toyed myself with using nodes, but not convinced yet.
Spoiler (click to show/hide)

In the end, I think foobar2000 current approach to playlists is wrongly designed and would need a rework from scratch, not with plugins. With a proper manager built-in (supporting playlist files), and also not forcing users to have playlists loaded 24/7.

(*) Autoplaylists may be saved as queries. That's what marck autoplaylist manager sample file on SMP does, but then you have to either show autoplaylists or playlists. Not both without a complete redesign of what playlist manager does.
Title: Re: JScript Panel script discussion/help
Post by: metal_termite on 2022-10-13 13:50:15
I don't want to ignore your feedback like I don't appreciate the time you took to reply, but it did not answer the primary question: is porting foo_plorg's functionality/features (that I outlined) to JScript a doable task?

- Playlists and autoplaylists organized within nodes and sub nodes
- Drag and drop functionality of all items (to re-locate the position of playlists and nodes)
Title: Re: JScript Panel script discussion/help
Post by: regor on 2022-10-14 00:08:11
I don't want to ignore your feedback like I don't appreciate the time you took to reply, but it did not answer the primary question: is porting foo_plorg's functionality/features (that I outlined) to JScript a doable task?

- Playlists and autoplaylists organized within nodes and sub nodes
- Drag and drop functionality of all items (to re-locate the position of playlists and nodes)
Obviously? XD
If it's doable in SMP, it's doable in JSP. Thought that was implied with my reply. But your primary question would be better answered asking Peter or other developers to properly implement a native manager instead of a javascript plugin.

Also not seeing anyone who would do that task but marc, which would require a great amount of work... just to patch a really big hole in Foobar (i.e. a partial solution); unless he takes the route to create a full fledged manager, which means even more work. Maybe he is in the mood XD who knows

And I don't see a point to to add manual sorting on items on my own SMP manager, nodes/subnodes could be considered. But it seems you are limited to only use JSP (?)

You are clearly making an specific request, and being realistic, since there are only 1 or 2 users who would do that in JSP or SMP, I really think time would be better spent asking peter o CUI's developer to offer a proper playlist manager. But... can be done? Yes. And sticking to a limited set of functions (UI playlists and your screenshots), it's relatively easy.
Title: Re: JScript Panel script discussion/help
Post by: Majestyk on 2022-10-26 03:13:37

Hey Marc! I was wondering if you can tell me where the code is that is creating these underlines in JSP settings?

Thanks!

(https://u.cubeupload.com/Fizbin/JSSUnderline.png)

Title: Re: JScript Panel script discussion/help
Post by: Majestyk on 2022-10-26 07:24:39
Doing some more digging, I wasn't aware you could add an underline to fonts by using the number 4 or 5. I thought you could only do bold or italics. So now I know.  ;D
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-10-26 08:54:25
That's using ye olde gdi.Font for JScript Panel 2.x.

For anyone using JSP3, they'll need to use Underline as part of a JS object before stringifying it...

https://marc2k3.github.io/jscript-panel/docs/fonts/ (scroll to end of page)

Title: Re: JScript Panel script discussion/help
Post by: grimes on 2022-10-27 14:45:23
Feature request: Please add a scrollbar to sample script Text Display (for display of longer text).
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-10-27 17:27:36
I'm far too stupid for that.  :))
Title: Re: JScript Panel script discussion/help
Post by: awx on 2022-10-30 16:00:44
Hi marc2k3, is it possible to change font used for buttons (Track Info + Seekbar + Buttons.txt) to another one by not editing common.js?
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-10-30 16:35:49
Copy the the entire _button function in to your panel and modify the last line starting with this.font =...

https://github.com/marc2k3/jscript-panel/blob/aab9410dfb29785e40fc848ca41e50e9282e091b/component/samples/js/common.js#L13-L50
Title: Re: JScript Panel script discussion/help
Post by: awx on 2022-10-30 16:53:17
Copy the the entire _button function in to your panel and modify the last line starting with this.font =...

https://github.com/marc2k3/jscript-panel/blob/aab9410dfb29785e40fc848ca41e50e9282e091b/component/samples/js/common.js#L13-L50

Got it! Thanks!
Title: Re: JScript Panel script discussion/help
Post by: etip on 2022-11-07 21:18:13
Hi there,
quick question.
I'm trying to open up a pdf file which path is built from tag. One simple example is :
Code: [Select]
Y:\classical\Mozart\Piano variations, Rondos etc\485.pdf
to open it up, i'm using this script which works to open an URL :
Code: [Select]
var WshShell = new ActiveXObject('WScript.Shell');
var pdf = BuildPDF();
WshShell.Run(pdf);

but the last line of code triggers an error.
Do you know what i'm doing wrong ?
thanks
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-11-07 21:48:15
Because the path has spaces in it, you need to wrap it in double quotes like this...

Code: [Select]
WshShell.Run("\"" + pdf + "\"");

If you're using fb2k v2 with component version 3.1.0 or later, you can avoid the WshShell ActiveX object completely and use

Code: [Select]
utils.Run(pdf);

This method does not require wrapping the command in double quotes.
Title: Re: JScript Panel script discussion/help
Post by: etip on 2022-11-07 22:09:35
Perfect Marc ! Great :)
I'm using v1 for now, havent really investigated v2 yet !
Thanks
Title: Re: JScript Panel script discussion/help
Post by: etip on 2022-11-09 22:00:23
Hi there,
i'm just checking but i dont think there is a way to do it :
I'm trying to do a simple pie chart and there is no function that can draw a slice of a circle, right ?
Thanks
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-11-10 07:27:10
It's definitely not possible with the built in drawing functions. Drawing/filling a circle is enough but not sections. Using JSP 2.8.8 or Spider Monkey Panel, you could probably achieve it with the DrawPolygon/FillPolygon methods. These never made it in to JSP3 because they use old Gdiplus APIs but I use Direct2D now. I'm not sure if there is a replacement/alternative as I never did check.

As an alternative, knocking up an SVG in plain text and using utils.LoadSVG would probably work.
Title: Re: JScript Panel script discussion/help
Post by: etip on 2022-11-10 19:07:18
As an alternative, knocking up an SVG in plain text and using utils.LoadSVG would probably work.

Thanks for the answer. Would you mind pointing me into a direction that would help me to understand the above ? (got to say, didnt get the whole sentence).
Title: Re: JScript Panel script discussion/help
Post by: grimes on 2022-11-10 19:28:48
Typo samples script Text Display: (context menu) Horizontal/Vertical aligment. Should be alignment.
Title: Re: JScript Panel script discussion/help
Post by: grimes on 2022-11-10 19:32:47
Request samples script Text Reader: Center Custom title.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-11-10 20:04:12
aligment

I made the same typo in my docs and noticed/fixed it some time ago but didn't think to check the samples at the same time. It will be fixed in the next release, thanks.

As for the text reader title, you can insert this directly after var panel = new _panel();

Code: [Select]
panel.draw_header = function (gr, text) {
gr.WriteText(text, this.fonts.title, this.colours.highlight, LM, 0, this.w - (LM * 2), TM, DWRITE_TEXT_ALIGNMENT_CENTER, DWRITE_PARAGRAPH_ALIGNMENT_CENTER, DWRITE_WORD_WRAPPING_NO_WRAP, DWRITE_TRIMMING_GRANULARITY_CHARACTER);
gr.DrawLine(LM, TM + 0.5, this.w - LM, TM + 0.5, 1, this.colours.highlight);
}
Title: Re: JScript Panel script discussion/help
Post by: fooball on 2022-11-10 20:10:22
As an alternative, knocking up an SVG in plain text and using utils.LoadSVG would probably work.

Thanks for the answer. Would you mind pointing me into a direction that would help me to understand the above ? (got to say, didnt get the whole sentence).
The point is that SVG is a vector graphics format where the graphics are defined using descriptions of (say) a circle at coordinate something, so it should be possible to build an SVG using code, and then load the SVG to create the graphic.
Title: Re: JScript Panel script discussion/help
Post by: etip on 2022-11-10 23:11:19
ok, so i've built the SVG file (not using code yet) and here it is :
Code: [Select]
<svg height="300" width="300" viewBox = "0 0 40 40">
 <circle cx="10" cy="10" r="10" fill="black" />
 <circle cx="10" cy="10" r="5" stroke="red" stroke-width="10" stroke-dasharray="calc(25 * 31.42 / 100) 31.42" transform= "rotate(-90) translate (-20)" fill="transparent" />
</svg>
when i try this code on Codepen.io i have the following result :
X
and when i'm loading this SVG file using the recommended method :
Code: [Select]
this.img = utils.LoadSVG(svg_file);
i have this result :
X

if you think i'm doing something wrong please let me know, otherwise, dont bother, took me the whole evening to just do that :) writing the SVG sounds like a mountain to me :)


Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-11-11 00:13:42
Seems like calc() is for CSS (cascading style sheets in browsers) so you shouldn't be using it.

I really have no idea about any of it so you really are on your own.

edit: this is the SVG library I'm using.

https://github.com/sammycage/lunasvg

You can check the features/TODO (https://github.com/sammycage/lunasvg#features) sections of the readme.
Title: Re: JScript Panel script discussion/help
Post by: fooball on 2022-11-11 00:41:39
ok, so i've built the SVG file (not using code yet) and here it is :
Nice try!

Seems like calc() is for CSS (cascading style sheets in browsers) so you shouldn't be using it.

...so try this:
Code: [Select]
<svg height="300" width="300" viewBox = "0 0 40 40">
 <circle cx="10" cy="10" r="10" fill="black" />
 <circle cx="10" cy="10" r="5" stroke="red" stroke-width="10" stroke-dasharray="7.855 31.42" transform= "rotate(-90) translate (-20)" fill="transparent" />
</svg>
Title: Re: JScript Panel script discussion/help
Post by: etip on 2022-11-11 00:56:24
Ok, i've just done a copy/paste of the SVG without the calc and here is the result :
X

Not there yet but much closer ! thanks.
i'll investigate further tomorrow but yeah, instead of calculating it using SVG, i will calculate it in JS and write the result in the svg file ... i'll start tomorrow.
Thanks !
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-11-11 01:44:30
You don't need to use an SVG file. You could create a string manually...

Code: [Select]
function create_svg(args) {
    var svg ='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200">\n';
   
    //do stuff with args
    svg += ...

    //done
    svg += '</svg>\n';
    return utils.LoadSVG(svg);
}

var img = create_svg(...);

Adding the \n at the end of each line isn't necessary but it would help make it readable if you need to dump it to the console for easy reading.
Title: Re: JScript Panel script discussion/help
Post by: etip on 2022-11-11 07:22:18
oh wow that sounds much easier now :)
thanks !
Title: Re: JScript Panel script discussion/help
Post by: etip on 2022-11-11 10:38:53
ok so i've tried to generate the SVG text :
Code: [Select]
function create_svg(numbr) {
numbr[0] = 100; numbr[1] =  25; numbr[2] = 25; numbr[3] = 50;
var color = [];
var radius = 40;
var offset = 0;
var circumf = 2 * Math.PI * radius;
color[1] = "blue"; color[2] = "red"; color[3] = "yellow";
    var svg ='<svg height="500" width="500" >\n';
    for (var i = 1 ; i< numbr.length; i++) {
var sliceAngle = numbr[i]/numbr[0]*circumf;
svg +='<circle r="' + radius + '" cx="100" cy="100" fill="none"\n';
svg +='stroke="' + color[i] + '"\n';
svg +='stroke-width="'+radius * 2 +'"\n';
svg +='stroke-dasharray="'+ sliceAngle + ' ' + circumf + '"\n'
svg +='stroke-dashoffset="'+offset +'"/>\n'
offset-=sliceAngle;
}
    svg += '</svg>\n';
    return utils.LoadSVG(svg);
}
I reset the numbr array for simplicity.
Here is the result :
X
So it works well except the black triangles in the center, i have not idea where they are coming from

Also, the
Code: [Select]
fill="transparency"
that i was using before in the SVG is not recognized. It has to be replaced by
Code: [Select]
fill="none"
. Maybe it's the reason for the black triangles...

Thanks for the help !
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-11-11 11:32:15
I might look at switching the SVG library soon. The developer of Columns UI (musicmusic) is making a fb2k component which provides an alternative SVG rendering backend for components to use. No idea how long this will take - it looks like work only started on it yesterday.

https://github.com/reupen/svg-services/pull/1

Title: Re: JScript Panel script discussion/help
Post by: etip on 2022-11-11 13:40:52
Sounds promising !
Too bad he's not committing to Text (the other library "Sammycage" didnt either).
Title: Re: JScript Panel script discussion/help
Post by: fooball on 2022-11-11 19:23:14
So it works well except the black triangles in the center, i have not idea where they are coming from
With all due respect to the writer of the SVG library, I wonder how well debugged it is!
Title: Re: JScript Panel script discussion/help
Post by: etip on 2022-11-12 08:47:10
With all due respect to the writer of the SVG library, I wonder how well debugged it is!
well, here is the final result, using my library data.
I dont see anymore these black triangles (even though i'm using the same algorithm that led to these triangles), i think there is only a slight issue to close the pie at roughly 359°.
Biggest issue however is the inability to use Text so i cannot integrate labels & percentage in the graph itself.
X
Title: Re: JScript Panel script discussion/help
Post by: fooball on 2022-11-12 08:48:41
Impressive.
Title: Re: JScript Panel script discussion/help
Post by: awx on 2022-11-14 23:21:39
marc2k3, I'm using DrawImage (normal album art and blurred at the background) and Writetext (fb.TitleFormat("%playback_time%")) on the same panel. As I understand for the playback time to be updated every second, I should use
Code: [Select]
function on_playback_time() {window.Repaint();}
The issue I noticed is with playing 24bit/44Hz Flac files only and using Spectrum Analyzer - it somehow freezes every second, so I though it is related to that window.Repaint. When I delete lines for showing album art - there is no freeze. If I leave album art but delete function on_playback_time - no freeze but also playback time is not updating.

Function for albumart:
Code: [Select]
function update_album_art() {
if (g_img) g_img.Dispose();
g_img = null;
g_metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
if (g_metadb) {
g_img = g_metadb.GetAlbumArt(); // omitting the type defaults to front
if (g_img) {
blur_img = g_img.Clone();
blur_img.StackBlur(radius);
}
}
window.Repaint();
}

Is there a way to do repaint for playback time only or am I getting blurred image in a wrong way?
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-11-15 00:01:42
Use window.RepaintRect with the same x,y,w,h as your WriteText.

https://marc2k3.github.io/jscript-panel/docs/namespaces/window/#windowrepaintrectx-y-w-h

If it's currently the whole panel, fix it to a smaller area just large enough for the playback time.
Title: Re: JScript Panel script discussion/help
Post by: etip on 2022-11-22 21:39:24
hey there,
I'm stuck again, and need help !
I'm trying to have a 2 states button (active/inactive) so the
Code: [Select]
var buttons = new _buttons();
buttons.update = function () {
this.buttons.stop = new _button(100, 0, 35, 35, { char : chars.stop, colour: RGB(255, 250, 250)}, null, function () { console.log("foo");}, 'foo');
this.buttons.Text = new _button(150, 0, 35, 35, { char : chars.console, colour : RGB(255, 250, 250)}, null, function () { console.log("bar"); }, 'bar');
}
in the "Track info + Seekbar + Buttons.txt" example looks perfect for that as i can play with the "char" element.
Also, i have other buttons in the panel using the "SimpleThemedButton + Tooltip" example (i do prefer the round style of the buttons.
My issue is that i dont really understand how to trigger the function
Code: [Select]
console.log("foo")
Here is the Left mouse button up function that is supposed to manage both buttons type :
Code: [Select]
function on_mouse_lbtn_up(x, y) {
g_down = false;
if (buttons.lbtn_up(x, y)) {
return;
}
if (cur_btn) {
if (cur_btn.func) cur_btn.func();
cur_btn.changeState(ButtonStates.hover);
window.Repaint();
}
}
As you can see, i didnt touch the original "SimpleThemedButton + Tooltip" function but i simply added
Code: [Select]
if (buttons.lbtn_up(x, y)) {
return;
}
to follow the example of "Track info + Seekbar + Buttons.txt"

Well, when  i click on the this.buttons.stop, nothing happens.
Am i doing something wrong, is that feasible at all ?

thanks
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-11-23 02:25:44
Are you calling buttons.move(x,y) from on_mouse_move and are tooltips appearing over the buttons? Executing button clicks inside on_mouse_lbtb_up is entirely dependent on that working properly.
Title: Re: JScript Panel script discussion/help
Post by: etip on 2022-11-23 07:39:51
well i wasn't and the
Code: [Select]
if (buttons.move(x, y)) {
return;
}
in the on_mouse_move(x, y) did the trick.
re the tooltip, it appears randomly for a very short while i'll investigate tonight.

Thanks Marc !!
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-11-23 18:22:23
@etip

I'm currently in the process of migrating my SVG rendering code to use musicmusic's component I mentioned earlier. It has no issues with that pie chart...

(https://i.imgur.com/pI5PVPs.png)

But it is about 2.5MB for the 64bit version which I'm testing with. I guess the 32bit version is probably a bit smaller.
Title: Re: JScript Panel script discussion/help
Post by: etip on 2022-11-23 21:15:57
sounds good, how do you measure the size ? seems high for a simple pie chart

Edit : can you use : fill="transparent" ?
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-11-23 21:53:58
Yes the fill is transparent. I used this from a earlier post of yours but where fooball had replaced the calc() code with actual values.

Code: [Select]
<svg xmlns="http://www.w3.org/2000/svg" height="300" width="300" viewBox = "0 0 40 40">
 <circle cx="10" cy="10" r="10" fill="black" />
 <circle cx="10" cy="10" r="5" stroke="red" stroke-width="10" stroke-dasharray="7.855 31.42" transform= "rotate(-90) translate (-20)" fill="transparent" />
</svg>

There are some changes:

1) The opening svg tag has to include this...

Code: [Select]
xmlns="http://www.w3.org/2000/svg"

2) width and height arguments are mandatory eg var img = utils.LoadSVG(svg_text, w, h);
Title: Re: JScript Panel script discussion/help
Post by: etip on 2022-11-23 22:21:37
yep, looks much better, i think the reason why is that "Transparent" is supported which wasnt the case with previous component.

quick question the new Width and height arguments, are they the 'height="300" width="300" ' from the SVG file ?
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-11-24 02:00:52
width and height are whatever you want the returned image to be. That's the whole point of SVG, the source can be any size and you get a scaled image without quality loss.

If you loaded a tiny 16x16px png file with utils.LoadImage and then used the Resize method to make it 1024x1024, it would look terrible.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-11-24 04:47:07
Just as a follow up, you can parse XML with ActiveXObjects like this...

Code: [Select]
var svg_file = fb.ComponentPath + 'samples\\svg\\android.svg';
var svg_text = utils.ReadUTF8(svg_file);

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.6.0");
xmlDoc.async = false;
xmlDoc.loadXML(svg_text);
if (xmlDoc.parseError.errorCode == 0) {
var svg = xmlDoc.childNodes[0];
       // width / height not present in the android.svg but you could access them if you know they are with other content
console.log(svg.getAttribute("viewBox"));
}
Title: Re: JScript Panel script discussion/help
Post by: etip on 2022-11-26 09:27:39
Hi Marc,
Tested the update this morning with the new SVG library
It looks better, the pie close correctly at 360°, thanks !!
here is the result :
X

i will try to check if it accepts "text" but i think i read it was not using it.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-11-26 09:36:14
This is the library I'm now using (scroll down for the readme)

https://github.com/RazrFalcon/resvg

and look here...

https://github.com/RazrFalcon/resvg#limitations

Title: Re: JScript Panel script discussion/help
Post by: etip on 2022-11-26 11:44:33
yep, thanks, i tried it, it seems the <text> tag is not recognized.
this library seems much better than the other one though.
Title: Re: JScript Panel script discussion/help
Post by: etip on 2022-12-10 10:07:05
ok so i was able to test the <text> tag and it works well ! It's much easier to manage the percentage within the SVG creation function rather than going back to the paint function.
I also tested the transform/Skew/rotate function of the <text> tag and it works well as well.

Here is my function (if anyone is interested):
Code: [Select]
function create_svg(crit) {
var color = [];
var radius = 35;
var width = window.Width / 3;
var height = window.Height;
var offset = 0;
var circumf = 2 * Math.PI * radius;
color[1] = "lime"; color[2] = "fuchsia"; color[3] = "gold";
var svg ='<svg xmlns="http://www.w3.org/2000/svg" height="' + height + '" width="' + width + '" viewBox="0 0 200 200" >\n';
    for (var i = 1 ; i< crit.length; i++) { //loop to draw all the slices
var sliceAngle = crit[i]/crit[0]*circumf;
svg +='<circle r="' + radius + '" cx="100" cy="100" fill="none"\n';
svg +='stroke="' + color[i] + '"\n';
svg +='stroke-width="'+radius * 2 +'"\n';
svg +='stroke-dasharray="'+ sliceAngle + ' ' + circumf + '"\n';
svg +='stroke-dashoffset="'+offset + '"\n';
svg += 'transform="rotate(-90) translate(-200)"/>';
offset-=sliceAngle;
var perc = Math.round(crit[i]/crit[0]*100).toFixed(0) + "%"; // percentage as text of the slice
//// Below to calculate X/Y pos of the percentage in the pie //////
var cum = 0; 
var sav = 0; 
for (var j = 1 ; j< i+1; j++) { 
cum +=crit[j];  
}
sav = cum-crit[i] + (crit[i]/2);
var angle = radians(360*sav/crit[0] -90);
var xPos = 100+Math.cos(angle) * radius/2 ;
var yPos = 100+Math.sin(angle) * radius/2 ;
//// End of calculation //////////
svg +='<text x = "'+xPos+'" y = "'+yPos+'" fill="Blue"  font-family="Segoe UI" font-size="13" font-weight="bold">' + perc + '</text>\n'; // put the percentage in the slice
svg+= '<text x = "'+ (43*i) +'" y = "183" fill="White"  font-family="Segoe UI" font-size="13" font-weight="bold">' + perc + '</text>\n'; // put the percentage below
svg+= '<rect x = "'+ (43*i) +'" y = "185" height="7" width="22" fill="'+color[i]+'"/>\n';
}
    svg += '</svg>\n';
//console.log(svg);
    return utils.LoadSVG(svg);
}

function radians(degrees)
{
  var pi = Math.PI;
  return degrees * (pi/180);
}

function takes as a parameter an array with the number for each slice (i chose to have the first element being the total)
I tried to spot the percentages (written in blue) within the pie but it doesnt work, the x/y coordinates and not good (if anyone has knowledge there, i'd be curious to see what i did wrong).

The paint function draws each graph in a loop.
Here is the result :
X

For these wondering about the yellow arrow in the top left corner, it is a switch button that switches the view from graph to text as shown below :
X


Edit : To calculate the coordinates, i've used the following guide :
https://quantrix.com/answers/questions/question/how-to-place-labels-inside-of-a-pie-chart/
Title: Re: JScript Panel script discussion/help
Post by: etip on 2022-12-25 00:13:30
Quick question on the window.NotifyOthers(name, info) function

I have a panel that draws a simple list and i would like to choose the content of the list with another panel. So i would like to pass on an array between these 2 panels.
I cant make it happen.
So on the sending panel i have this (basic example):
Code: [Select]
function notif() {
var data = [];
for (var i = 0; i <plman.PlaylistCount ; i++) {
data.push({
value : plman.GetPlaylistName(i),
});
}
window.NotifyOthers("simple_list", data);
}
then on the other panel (called 'simple_list') i dont really know how to use the
on_notify_data(name, info) callback. i tried all sort of things with no success.
I didnt find any example of it.
Any help would be appreciated :)
thanks
Title: Re: JScript Panel script discussion/help
Post by: regor on 2022-12-25 09:54:35
Quick question on the window.NotifyOthers(name, info) function

I have a panel that draws a simple list and i would like to choose the content of the list with another panel. So i would like to pass on an array between these 2 panels.
I cant make it happen.
So on the sending panel i have this (basic example):
Code: [Select]
function notif() {
var data = [];
for (var i = 0; i <plman.PlaylistCount ; i++) {
data.push({
value : plman.GetPlaylistName(i),
});
}
window.NotifyOthers("simple_list", data);
}
then on the other panel (called 'simple_list') i dont really know how to use the
on_notify_data(name, info) callback. i tried all sort of things with no success.
I didnt find any example of it.
Any help would be appreciated :)
thanks


In script A you put the window.NotifyOthers("simple_list", data); part.
Data is the data to pass to the other panel (I think you got that right).

In Script B, you put the callback. It's a async process, so Panel B gets "notified" at some point after running window.NotifyOthers, and the arguments on the callback are the string "simple_list" and the data you sent.
Code: [Select]
function on_notify_data(name, info)  {
if (name === "simple_list" && info) { // only want to react to our data on Script A, and ensure data is received
if (info.length) { //Array contains items?
// Do your thing with the data
const data = [...info]; // Make a copy, info will not be available later if used in other functions
}
}
}

Note I used some ES6 code, not sure if destructuring is available on JSP.
Title: Re: JScript Panel script discussion/help
Post by: etip on 2022-12-25 11:21:07
thank you ! it works like a charm and is incredibly easy to use !
Title: Re: JScript Panel script discussion/help
Post by: etip on 2022-12-25 11:57:15
i'm coming back on the destructuring topic. Yes, it's not available on JSP and i used the following way to handle this :
Code: [Select]
var data = [];
data = info;

Is that the best way ? i can see some unexpected behaviors and i'm not sure what i did was right.
thanks !
Title: Re: JScript Panel script discussion/help
Post by: regor on 2022-12-25 12:28:11
i'm coming back on the destructuring topic. Yes, it's not available on JSP and i used the following way to handle this :
Code: [Select]
var data = [];
data = info;

Is that the best way ? i can see some unexpected behaviors and i'm not sure what i did was right.
thanks !
Nop, because you are overwriting the [] reference with info's reference.
When you assign Arrays [] and objects {} to a variable, you are only storing the reference.
Code: [Select]
a = [3, 4];
a does not contain [3,4], but only points to that thing.
So when you do
Code: [Select]
b = a;
b[0] = 1;

In fact you have changed the original array to [1, 4]. And both a and b variables point to the same array.

In jsp you should be able to do something like
Code: [Select]
const data = JSON.parse(JSON.stringify(info));
You can also manually copy every item:
Code: [Select]
const data = info.map(function(a) {return a;}); // This works because it's an array
etc.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2022-12-25 13:32:16
Even better is not passing the array at all. Just send a name only and get the other panels to update themselves.

But even that shouldn't be necessary. It's hard to see why you'd need it given the built in callbacks for any playlist manager type scripts to update themselves when playlists are renamed/added/removed in other panels.
Title: Re: JScript Panel script discussion/help
Post by: etip on 2022-12-25 15:04:57
thanks, my playlist example was just an easy example, i'll eventually send arrays of artists/composers ... with the associated # of occurences/songs.
@Regor : thanks, the var data = JSON.parse(JSON.stringify(info)); works !
Title: Re: JScript Panel script discussion/help
Post by: Heat_Death on 2023-01-05 02:00:35
Yo two questions about JS Playlist on JS Script 3.0.14 and Foobar2000 1.6.14. 
 
1) Why playlist custom background image not work https://i.imgur.com/SxCg0DZ.png https://i.imgur.com/kVuoxl9.png (works with album and artist option, just not with default image, tried different formats for the image path and nothing). 
 
2) How to change fonts in the playlist view (CollumsUI and DefaultUI methods listed at https://jscript-panel.github.io/gallery/jsplaylist/ not work, as in, the option to change the fonts for "JSScript" or something similar doesn't exist, and other options don't modify it)

thanks

Edit: for problem #2, I can change font and font size for JS Playlist though common list items in the ColumnsUI setting, but I can't choose different versions of a font (like black or italics).
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-01-05 06:51:11
1) currently, it only supports paths relative to the foobar2000 profile folder. The next release will be updated to support absolute paths.

2) https://hydrogenaud.io/index.php/topic,110499.msg1020722.html#msg1020722

edit: I forgot to mention the JS Playlist code only extracts the name from the font returned by window.GetFontCUI / window.GetFontDUI so other properties like italic are ignored. I'll look at adding some notes to make this clearer.
Title: Re: JScript Panel script discussion/help
Post by: Heat_Death on 2023-01-05 18:12:04
Thanks for the reply, I guess I'll learn some JS on youtube as code is black magic to me. Also the background feature still doesn't work even with images in Users\currentuser\AppData\Roaming\Foobar2000, so I'll just use the default playlist and try again when 2.0 releases a stable version an I can use the updated component.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-01-05 18:34:05
Any image inside the profile folder should definitely work with the current version. This fb2k logo is bundled with the component and works fine...

Code: [Select]
user-components\foo_jscript_panel3\samples\images\foobar2000.png

(https://i.imgur.com/BaSy2R0.png)



Title: Re: JScript Panel script discussion/help
Post by: Farscape on 2023-01-10 06:19:31
Hello,

I searched this subforum since it's jscript-panel-related, but I also googled elsewhere, but I wasn't able to find a solution for the following minor inconvenience: The tooltip fontsize of jscript panel elements are pretty large in comparison to Windows' native tooltip fontsize and I'd like to reduce them to match the other fontsizes.

(https://i.imgur.com/JwMggXt.png)
Title: Re: JScript Panel script discussion/help
Post by: Farscape on 2023-01-10 07:40:04
better image of what I mean (can't edit original post, sorry):
(https://i.imgur.com/R3RH13j.png)
(offtopic) by the way I managed to get a button to work that changes depending on state (active,inactive,hoveronactive,hoveroninactive). Thanks to the awesome people in this forum.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-01-10 11:10:48
You should be able to add this inside your panel(s)...

Code: [Select]
window.SetTooltipFont("Segoe UI", 12);

The default was 16, You can override with any sensible value,
Title: Re: JScript Panel script discussion/help
Post by: Farscape on 2023-01-10 13:46:48
Thank you. However, it spits out the following error message:
Code: [Select]
JScript Panel v2.3.6.1 (Volume by marc2003)
Laufzeitfehler in JavaScript:
Das Objekt unterstützt die Eigenschaft oder Methode "SetTooltipFont" nicht
File: <main>
Line: 9, Col: 1
Runtime error in JavaScript:
The object does not support the property or method "SetTooltipFont".

This is the code I'm using for one of my jscript panels:
Code: [Select]
// ==PREPROCESSOR==
// @name "Volume"
// @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\volume.js"
// ==/PREPROCESSOR==

window.SetTooltipFont("IBM Plex Serif", 12);

var volume = new _.volume(0, 0, 0, 0);
//volume.c1 = _.RGB(238, 238, 238);
volume.c1 = _.RGB(108, 144, 116);
volume.c2 = _.RGB(118, 158, 127);

function on_size() {
volume.w = window.Width;
volume.h = window.Height;
}

function on_paint(gr) {
gr.FillSolidRect(volume.x, volume.y, volume.w, volume.h, volume.c1);
gr.FillSolidRect(volume.x, volume.y, volume.pos(), volume.h, volume.c2);
}

function on_volume_change() {
volume.volume_change();
}

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

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

function on_mouse_lbtn_down(x, y) {
volume.lbtn_down(x, y);
}

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

By the way this script works only in jscript panel, not in jscript panel 3 So maybe your solution was for jscript panel 3?
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-01-10 14:22:44
window.SetTooltipFont does exist in JScript Panel 2.4.something. The last release was 2.8.8. Your version 2.3.6.1 is very old.

Upgrading might break something so you could just remove that code and edit samples\complete\js\helpers.js instead.

look for var tooltip = window.CreateTooltip() and replace it with var tooltip = window.CreateTooltip("Segoe UI", 12)
Title: Re: JScript Panel script discussion/help
Post by: Farscape on 2023-01-10 15:45:41
That worked! And I could wonder for a long time why so many scripts I tried didn't work. Because I use a very old version. Darn it! But now it works and, as some english speaking people say, "never touch a running system" and so that will have to do for now as far as customising Foobar is concerned. Thanks again!
Title: Re: JScript Panel script discussion/help
Post by: Farscape on 2023-01-11 13:47:54
Inside your panel, replace the on_paint function with this:

Spoiler (click to show/hide)

Then open js_marc2003\js\volume.js and replace the this.move function with this:
Spoiler (click to show/hide)

and replace the this.pos function with this:

Spoiler (click to show/hide)
It was a bit like walking in circles in a forest where every tree looks the same. Finding the right files to edit is not so easy because there are so many files with exactly the same name stored under different paths.

First I looked for the volume.js file and went to the appdata folder of the "old" Jscript panel (no1, not no3).
So this path:
[...]AppData\Roaming\foobar2000-v2\user-components\foo_jscript_panel\samples\js
Result: error message.   :-\ 

Then I thought maybe it must be the new JScript 3 panel ([...]user-components\foo_jscript_panel3\samples\js), but a similar result again :o
Code: (error message) [Select]
JScript Panel 3.2.2 (Volume by marc2003)
Runtime error in JavaScript
The object does not support the property or method "FillSolidRect".
File: <main>
Line: 31, Col: 2

Then I looked at your forum post again and noticed that there was no marc2003 folder in the paths, so looked further and the jscript rabbit hole lead me to towards a folder within the spider monkey panels main folder ([…]user-components\foo_spider_monkey_panel\samples\complete\js). I wasn't surprised and accepted my error message.
Then, out of desperation I also gave the uie jsplitter panel a try ([…]user-components\foo_uie_jsplitter\samples\js) …aaaand error message again.  :'(

I was about to give up until I noticed that there are several volume.js files in every single dedicated panel main folder. This time I went back to the JScript (numero uno) panel path and found the correct volume.js in a folder called 'complete' (C:\Users\%username%\AppData\Roaming\foobar2000-v2\foo_jscript_panel\samples\complete\js), which then worked perfectly. Phew! Stupid as a donkey but with my head through the wall it worked after all.  :D

I finally have a rotated or vertical volume bar thanks to your jscript and the awesome community!
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-01-11 14:15:38
The exact paths for your particular component version/script are right there in the snippet you posted earlier...

This is the code I'm using for one of my jscript panels:
Code: [Select]
// ==PREPROCESSOR==
// @name "Volume"
// @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\volume.js"
// ==/PREPROCESSOR==
Title: Re: JScript Panel script discussion/help
Post by: Farscape on 2023-01-11 14:20:50
Now I feel dumb. Albeit the marc2003 folder path was wrong or is now wrong or was right in the past but not now. It was all a bit confusing.
Title: Re: JScript Panel script discussion/help
Post by: nikolai4ik on 2023-01-15 14:31:43
I decided to move from ancient foo_custom to Playback Statistics however when I rate the song in the playlist the rating is being written both to the file and the DB. How can I stop modifying the files?
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-01-15 16:43:46
It's impossible to say what the problem is when you're not stating the version of fb2k, component version and script.

There were changes during early fb2k v2 betas where playback statistics were built in to fb2k and certain scripts were updated to make use of this. But since fb2k 2.0 beta 18 was released, internal playback statistics were dropped and foo_playcount is once again required. The latest component is compatible with these changes.

https://jscript-panel.github.io/gallery/jsplaylist/#clickable-ratings
https://jscript-panel.github.io/gallery/smooth-playlist/#clickable-ratings

Title: Re: JScript Panel script discussion/help
Post by: emwedk on 2023-01-29 17:34:33
Heya - Newb here!
i've been reading and trying a bunch of stuff from the docs.

i simply can't seem to grasp if or how it's possible to interact with a component that 1. isn't "supported" by jsp3 and 2. isn't persay open source.
namely the foo_youtube.

 - if it might be possibly to get the list from a search queue as an object etc, to be able to make a customizable interface for the component.

i was able to get it to open the normal "popup search" with fb.RunMainMenuCommand("View/Youtube Source/Search on Site")
and couldn't seem to parse a "metadata" to it like metadata.RunContextCommand("Youtube Source/Search/Songs by this Artist")
don't know if i would need to craft an object looking like metadata with a title for the search string or some.
maybe i would need to decode or Reverse Engineer the foo_youtube to figure it out, but i simply don't know

maybe it's as simply as, it can't be done?
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-01-29 18:07:28
maybe it's as simply as, it can't be done?

Correct.
Title: Re: JScript Panel script discussion/help
Post by: etip on 2023-01-29 22:26:19
Hi there,
I'm trying to controle the X location of a button but i dont see any way to succeed.
What i want to achieve is to have that button 50 pixels from the right panel's limit.
The below code doenst work but i'm afraid that even if it did, the button will not set to a correct position if the window is resized.

Code: [Select]
// ==PREPROCESSOR==
// @name "Volume"
// @author "marc2003"
// @import "%fb2k_component_path%helpers.txt"
// @import "%fb2k_component_path%samples\js\lodash.min.js"
// @import "%fb2k_component_path%samples\js\common.js"
// @import "%fb2k_component_path%samples\js\volume.js"
// ==/PREPROCESSOR==

var buttons = new _buttons();
var w, h;

buttons.update = function () {
this.buttons.test = new _button(w-50 , 5 , 50, 40, { char: chars.stop , colour: RGB(255, 255, 0) }, null, function () { console.log('test'); }, 'TT test' );
}

buttons.update();

function on_paint(gr) {
console.log(w);
buttons.paint(gr);
}

function on_size() {
w = window.Width;
h = window.Height;
}
function on_mouse_lbtn_up(x, y) {
if (buttons.lbtn_up(x, y)) {
return;
}
}
function on_mouse_move(x, y) {
if (buttons.move(x, y)) {
return;
}
}

I've been trying to add a parameter to the paint function of _button within "common.js" with 0 success.

Code: [Select]
function _button(x, y, w, h, normal, hover, fn, tiptext) {
this.paint = function (gr, x_start) {
if (this.current) {
gr.WriteText(this.current.char, this.font, this.current.colour, x_start, this.y, this.w, this.h, 2, 2);
}
}

Any help is welcome !
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-01-30 02:11:40
There are buttons in my track info + seekbar + buttons sample and they always stick to the right hand side of the panel. Should be obvious really...

https://github.com/jscript-panel/component/blob/ddbb875d5fef480c134710009566eaa0fc3f2f57/samples/Track%20Info%20%2B%20Seekbar%20%2B%20Buttons.txt#L178

Title: Re: JScript Panel script discussion/help
Post by: etip on 2023-01-30 07:27:55
indeed, thanks.
I was missing the panel component !
Title: Re: JScript Panel script discussion/help
Post by: Bollerkopp on 2023-03-03 16:47:31
Coming from here (https://hydrogenaud.io/index.php/topic,116669.msg1023336.html#msg1023336).

I don't mean the text alignment. I mean the font rendering. I think (as a noob) it has something to with GDI versus Directwrite, right? In my screenshot the same font wit the same size looks different and sadly really ugly in the JSP3 Text Display.  :(
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-03-03 19:36:58
Well there's not a lot I can do about your personal preference. You'll just have to choose not to use it.

BTW, this is Tahoma with GDI on the left (using an old version of JScript Panel2) and DirectWrite on the right. The difference is.... meh.

(https://i.imgur.com/vmzVfPd.png)

Not even sure why you're using XP era relic like Tahoma. Segoe UI which has been the default windows font since Vista looks much better.






Title: Re: JScript Panel script discussion/help
Post by: Bollerkopp on 2023-03-03 19:53:27
All good. Sorry, I don't wanted to bother you. I just asked. :) But in your screenshots it looks pretty similar indeed. Strange...

It think it's a matter of taste. I find Tahoma much more pleasent than Segoe UI as a OS font. Altough it isn't bad at all.

Anyway... thank you very much for answering and your great work here. I really appreciate it. :)
Title: Re: JScript Panel script discussion/help
Post by: etip on 2023-03-06 20:49:33
All,
Like others, i was using the playlist_organizer (aka foo_plorg) component until i switched to V2.
As i was missing it, I then tried to redevelop it using JScript Panel 3 functionalities.
I did it originally for myself and i'm far from being a professional developer and as a consequence, this is far from being optimized or well designed or coded correctly.
However it works for me and i'm using it on a daily basis.
There are been a few requests for such a replacement in the playlist_organizer thread but instead of posting there, i decided to post it here, to make sure, i have a few things right (and not all wrong).
the following document contains 3 files :
The last 2 files should be in the "foo_jscript_panel3\samples\js" folder.

Please let me know if it's ok to spread it as a temporary replacement for the foo_plorg component or should i keep it for myself !

X



Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-03-07 02:28:54
The last 2 files should be in the "foo_jscript_panel3\samples\js" folder.

Nobody should ever be putting their own files in the component folder. This is because they get wiped whenever you upgrade.

You really should be instructing people to extract files to a unique folder inside the user's profile and you can use %fb2k_profile_path% to locate them in the preprocessor section like this....

Code: [Select]
// ==PREPROCESSOR==
// @name "Playlist Manager"
// @author "Seb + inspiration and abstract from marc2003"
// @import "%fb2k_component_path%helpers.txt"
// @import "%fb2k_component_path%samples\js\lodash.min.js"
// @import "%fb2k_component_path%samples\js\common.js"
// @import "%fb2k_profile_path%pl_organizer\panel_pl_organizer.js"
// @import "%fb2k_profile_path%pl_organizer\pl_organizer.js"
// ==/PREPROCESSOR==

edit: you also use fb.ComponentPath as a path for writing a file as well which is bad. Replace with fb.ProfilePath.
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-03-07 03:30:43
@etip
Hi :)

https://i.imgur.com/MQT2oxt.png

1.) How to change "folder name font size" ? (add to right click)
2.) I want to display both items and size.

Thanks.
Title: Re: JScript Panel script discussion/help
Post by: etip on 2023-03-07 21:33:50
Thanks Marc for your advices ! i hope i took them into account.

@Air KEN
i linked the font size menu to both playlists and folders so when you increase the size both should increase. let me know how it works for you.

So now the following zip contains 3 files :

The last 2 files are to be copied in the fb.ProfilePath + "\pl_organizer" folder
X
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-03-08 01:12:57
@etip

https://i.imgur.com/eFlDloM.png

fixed.
The font size changes for both the playlist name and folder name.

Many Thanks.
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-03-08 03:21:17
@etip
additional request:

1.) Playlist multiple selection
2.) mouse action (Double click, Middle button)
3.) Context menu (Playlist view)
4.) I want to display both items and size.

Thanks.
Title: Re: JScript Panel script discussion/help
Post by: etip on 2023-03-08 07:43:17
@Airken
Thanks for the feedback.
I'll think about the multiple selection but tbh, i dont really get your points 2 and 3. What would want to achieve with the double click/middle button and what would you want in the context menu ?
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-03-08 08:44:09
@etip
Thank you for your reply.

2.) mouse action (Double click, Middle button)
Send to Playlist or Play etc...
Like other Playlist Panels

3.) Context menu (Playlist view)
Playlist view context menu:
Utilities > Send to playlist... , Add to playback queue, Tagging and Prpperties etc...
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-03-08 09:03:42
3) should be built in to Smooth Playlist Manager / JSplaylist as well. I'll look at adding this.

edit: it's been done, etip can look at this if you want...

https://github.com/jscript-panel/component/commit/dc38b897badd7973d5b65313a5e0b7004aa567ac
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-03-08 10:17:25
@marc2k3 Thanks.

Smooth Playlist Manager (+ itemes > context menu)
https://i.imgur.com/1P2hXaz.png

Is it possible to add a group division function by Folder to Smooth Playlist Manager?
It is luxurious for user to be able to select "Playlist Organizer" and "Smooth Playlist Manager".

Thanks.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-03-08 12:39:20
Someone could do it but I will not. I rarely if ever have more than 2-3 playlists on the go at once. Most of the time it's double click an album from Smooth Browser>send to playlist and play. Yes, I'm so boring that I generally listen to albums in their entirety before moving on to the next.
Title: Re: JScript Panel script discussion/help
Post by: etip on 2023-03-10 20:22:33
so i added the context menu (thanks @marc2k3)
i also added both Size and # of files in a playlist. The switch button in the top right corner switches between the # of files to the # of files + the size (i wont be using this so i took a shortcut).

Not sure i'll do the multiple selection because it's a significant change and i just dont have the courage right now.

The following zip contains 3 files :
main.js file which is the panel script
panel_pl_organizer.js which is a replacement of the panel.js (i simply added a few things)
pl_organizer.js which is the main code

The last 2 files are to be copied in the fb.ProfilePath + "\pl_organizer" folder

X
Title: Re: JScript Panel script discussion/help
Post by: Heat_Death on 2023-03-11 00:09:56
Hi! I installed the JPEG XL WIC extensions and now I have thumbnails + Windows Photo Viewer support for JPEG XL, but the album art JSPanel still won't shot a cover.jpx album art. Should the detection of the WIC extension be automatic?
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-03-11 00:25:44
It should but work but there are 2 things to note:

-It only works with 64bit fb2k 2.0. AFAIK, there is no 32bit version of the JXL DLL. In addition to working with the 64bit version of this component, it should also work with default UI and Columns UI.
-The album art preferences must explicitly specify the file extension. Wildcards won't work.

Title: Re: JScript Panel script discussion/help
Post by: Heat_Death on 2023-03-11 00:29:15
It should but work but there are 2 things to note:

-It only works with 64bit fb2k 2.0 / JScript Panel3. AFAIK, there is no 32bit version of the JXL DLL.
-The album art preferences must explicitly specify the file extension. Wildcards won't work.

Well that explains it, time to transition to foobar 2.0, Thanks for the quick reply!
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-03-11 00:45:27
My original post wasn't entirely accurate making it look like JSP3 is a requirement. Default UI and 64bit Columns UI should also support it.
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-03-11 01:40:37
Hi :) etip
Playlist Organizer (Playlist Manager) (JScript Panel 3 Script) 2023-03-10
https://hydrogenaud.io/index.php/topic,110516.msg1023599.html#msg1023599

Many Thanks.
https://i.imgur.com/yhPyoxs.png
https://i.imgur.com/W4a6lCe.png
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-03-24 23:51:32
Darker colours come from using Default UI (top) as opposed to Columns UI (bottom).
Spoiler (click to show/hide)
Thanks for the reply, I was thought you were using custom build that able to change that main dark background.
---
I have another question. In regard to Track Info + Seekbar + Buttons script. I would like to add a shuffle/default toggle button that can switch between different icon and colour states.
I'm not sure how to make the toggle function work, and I'm not a programmer, so I have them on a separate button instead.
May I ask how to make it on one button toggle?
Many thanks
Code: [Select]
//default
    this.buttons.regular = new _button(panel.w - LM - (bs * 4), y, bs, bs, {
        char: !fb.RunMainMenuCommand('Playback/Order/Default') || fb.RunMainMenuCommand('Playback/Order/Shuffle (tracks)')
            ? '\uF074'
            : chars.music,
        colour: RGB(255, 255, 255)
    }, null, function () {
        if (fb.RunMainMenuCommand('Playback/Order/Shuffle (tracks)')) {
            fb.RunMainMenuCommand('Playback/Order/Default');
        }
    }, !fb.RunMainMenuCommand('Playback/Order/Default') || fb.RunMainMenuCommand('Playback/Order/Shuffle (tracks)')
        ? 'Default'
        : 'Shuffle');

//shuffle
    this.buttons.shuffle = new _button(panel.w - LM - (bs * 5), y, bs, bs, {
        char: '\uF074',
        colour: fb.StopAfterCurrent
            ? colours.sac
            : colours.test
    }, null, function () {
        fb.RunMainMenuCommand('Playback/Order/Shuffle (tracks)');
    }, 'Shuffle');
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-04-03 06:47:17
Hi there, yet another newbie questions.

[Track Info + Seekbar + Buttons]
1. How can I use SVG on the buttons instead of char?

[JS Playlist]
2. How to make the rating color change when on hover just like the standalone rating sample script or like the default rating hover on DUI?
3. Is it possible to load characters from a different set of fonts, such as MaterialIcons fonts?
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-04-22 01:54:13
After hours upon hours, I'm satisfied enough to have this look and function properly.
Thanks for the samples, @marc2k3, even a newbie like me who is new to JavaScript learned a few things here.

(https://i.imgur.com/uYt4pUy.gif)
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-04-22 11:43:35
Your previous post where you were trying to determine the char to display after running main menu commands was too painful for me to respond to. I had to lie down and recover.

I hope you discovered plman.PlaybackOrder as a property than can be used to get and set and the on_playback_order_changed callback.
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-04-22 17:06:02
Yes, that on_playback_order_changed took me a while (days) to figure out. Eventually, I was able to get the function to work properly using setup; perhaps, this is sufficient for me.

Code: [Select]
	//shuffle
    this.buttons.shuffle = new _button(panel.w / 2 - 100, 12, bs, bs, {
char : (plman.PlaybackOrder == 0) ? chars.shuffle
: (plman.PlaybackOrder == 4) ? chars.shuffle
: (plman.PlaybackOrder == 5) ? chars.shuffle2
: (plman.PlaybackOrder == 6) ? chars.shuffle2
: chars.shuffle,
        colour  : (plman.PlaybackOrder == 0) ? colours.buttons
: (plman.PlaybackOrder == 4) ? colours.accent
: (plman.PlaybackOrder == 5) ? colours.sac
: (plman.PlaybackOrder == 6) ? colours.red
: colours.buttons,
    }, null, function () {
shuffle_switch();
}, (plman.PlaybackOrder == 0) ? 'Enable Shuffle'
: (plman.PlaybackOrder == 4) ? 'Shuffle Tracks'
: (plman.PlaybackOrder == 5) ? 'Shuffle Album'
: (plman.PlaybackOrder == 6) ? 'Shuffle Folder'
: 'Shuffle');

Code: [Select]
function shuffle_switch() {
if (plman.PlaybackOrder < 6 && plman.PlaybackOrder > 3) {
plman.PlaybackOrder += 1;
}
else if (plman.PlaybackOrder === 6) {
plman.PlaybackOrder = 0;
}
else {
plman.PlaybackOrder = 4;
}
window.Repaint();
}

Code: [Select]
//finally
function on_playback_order_changed() {
buttons.update();
window.Repaint();
}
Title: Re: JScript Panel script discussion/help
Post by: grimes on 2023-04-23 10:27:24
Thumbs script: Double click on a picture opens external picture viewer. I prefer to use internal foobar2000 picture viewer (see: double click on DUI Album Art Viewer). Is it possible?
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-04-23 12:19:16
Not at the moment, no.

The included album art script already supports it. It has a customisable double click action....

(https://i.imgur.com/giNP5yc.png)

This is because it takes an album_art_data_ptr object as input so I implemented as a metadb handle method where you supply the desired album art id....

https://jscript-panel.github.io/docs/interfaces/IMetadbHandle/#showalbumartviewerart_id-want_stub

Because thumbs loads any old random image from disk, it's obviously not possible right now. I do know to how to create an album_art_data_ptr from image file paths but it would require a brand new method in the component itself. I'll think about it.

edit: the component already has an internal helper method for doing this. Embedding album art requires an album_art_data_ptr and my methods take an image file path for that.

edit2: look at all this code I had to write...

Code: [Select]
STDMETHODIMP Fb::ShowPictureViewer(BSTR path)
{
album_art_data_ptr data = AlbumArt::path_to_data(path);
if (data.is_valid())
{
fb2k::imageViewer::get()->show(core_api::get_main_window(), data);
}
return S_OK;
}

I'm super tired now.  :))
Title: Re: JScript Panel script discussion/help
Post by: grimes on 2023-04-24 10:55:08
Thumbs script: Want to download and display Last.fm artist pictures for classical composers. My problem: The artist field (%artist%) is for example "Englund - Klas, Tampere Philharmonic Orchestra", so it gives no result. "Einar Englund" instead gives results, but its in my %composer% tag. How do I replace %artist% with %composer% in Thumbs script? Thanks.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-04-24 13:28:27
You've asked this before (except it was %performer%). Same technique applies now...

https://hydrogenaud.io/index.php/topic,110516.msg992040.html#msg992040
Title: Re: JScript Panel script discussion/help
Post by: etip on 2023-04-24 20:53:25
Marc,
I did implement a scrollbar to the Playlist organizer script.  The scrollbar appears when i reload the script but does not when Foobar is launched.
Would you have any pointers/direction to look at ? I frankly have no idea why this can happen.

https://hydrogenaud.io/index.php/topic,123820.new.html#new
Thanks in advance
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-04-24 23:25:21
I'm not looking at the code but remember that window.Width / window.Height is always zero on fb2k startup. I guess that's your issue??
Title: Re: JScript Panel script discussion/help
Post by: etip on 2023-04-25 17:50:38
unfortunately not, i'm setting width & height during the on_size callback and the scrollbar Size is also setup during this callback :

Code: [Select]
this.size = function () {
this.panel_h = window.Height;
this.panel_w = window.Width;
this.w = window.Width - cScrollBar.width-5;
this.h = window.Height - TM;
...
p_scrollbar.setSize(this.panel_w - cScrollBar.width, this.ylist, cScrollBar.width, this.h);
p_scrollbar.setCursor(this.rows, this.items, this.offset);

}
Do you know when the on_size callback kicks when the script is launched ?
Title: Re: JScript Panel script discussion/help
Post by: etip on 2023-04-25 22:17:57
it's actually quite weird as the scrollbar loads correctly at startup but at the end of the loading (cursor goes back to normal), the scrollbar disappears. See below :
X
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-04-25 22:30:18
As I've made clear before, I did not write the scrollbar code but it has always worked perfectly for me with thousands of items in JS Playlist and Smooth Playlist. Only your own code can make it appear/disappear?  :o

As for on_size, it's always called when a script initialises. Any code not inside a function runs first then on_size kicks in then on_paint.

After that, a script does nothing until various callbacks are triggered by fb2k core reporting changes/your mouse/keyboard etc.

Title: Re: JScript Panel script discussion/help
Post by: etip on 2023-04-26 00:40:56
ok, thanks. This order is important to me to try to understand what's going on, as you said, it's my code that has an issue (i had no doubt !)
Thanks
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-04-29 01:38:23
3.2.15 for fb2k 2.0 (Beta 18 is the enforced minimum requirement but using the final release is highly recommended)

https://jscript-panel.github.io/docs/
The most recent new button set is a nice addition.
But how can we add more fonts?
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-04-29 02:00:24
You edit your copy of the script - I thought you already did this??
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-04-29 02:26:27
Nevermind. Previously, I intended to add a few more font options, but after testing a few material icon variants, I think the segoe mdl is a good enough alternative.
(https://i.imgur.com/MqeZoC3.gif)
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-04-29 02:32:05
I'm already changing it for the next release, It's not consistent across Windows 10/11 - the console icon I chose is borked on 11.

I'll be using Segoe Fluent Icons. It's included in 11 and can be downloaded for 10.

https://learn.microsoft.com/en-us/windows/apps/design/style/segoe-fluent-icons-font

https://github.com/jscript-panel/component/commit/a8f3c198560af85a4b5619b952147507e1bc6ea8
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-04-29 03:17:37
Yeah, that fluent version looks more consistent.

Segoe Fluent Icons
(https://i.imgur.com/PLloZHa.png)

Segoe MDL2 Assets
(https://i.imgur.com/U3Vx5Vq.png)
Title: tab stack
Post by: Jul2323 on 2023-05-05 16:49:44
tab stack in JSP 3 is pretty ugly .
How to replace it with button image or SVG to switch tabs ?
how to hide and show var panel = new_panel on left click mouse ?
how to change coordinate of the panel ? i know : panel.w and panel.h but the x and y position ?
all of this in jscript panel 3 . thanks
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-05-06 04:29:29
tab stack in JSP 3 is pretty ugly .
How to replace it with button image or SVG to switch tabs ?
how to hide and show var panel = new_panel on left click mouse ?
how to change coordinate of the panel ? i know : panel.w and panel.h but the x and y position ?
all of this in jscript panel 3 . thanks

I think tab stacks are unrelated to JSP 3, but rather a basic UI element from foobar or a Windows element.

Marc did mention replacing the tabs with a single panel but only for JSP panels on this post, but it was too advance for me.
Spoiler (click to show/hide)
--------------
Quote
How to replace it with button image or SVG to switch tabs ?
I'd like to know this as well, although I'm not sure how the built-in panels would fit in.

ColumnsUI would be the only way for beginners like me, as the other option like panel splitter or jsplitter are for advance user only.
There is an open issue on ColumnsUI GitHub regarding these tab stacking to make tab appearance customisable.
https://github.com/reupen/columns_ui/issues/555

Actually, I did modify mine, but only as far as changing its tabs colour background.
Spoiler (click to show/hide)
Title: Re: JScript Panel script discussion/help
Post by: MojoBass on 2023-05-06 06:52:37
If you are on Columns UI, why not use the Panel Stack Splitter (see here (https://wiki.hydrogenaud.io/index.php?title=Foobar2000:Components_0.9/Panel_Stack_Splitter_(foo_uie_panel_splitter))) to place your panels?
Don't get too much confused by the scripting options. To just place panels, you can use the 'Panel List' tab which is pretty much straight-forward.
Title: Re: JScript Panel script discussion/help
Post by: Jul2323 on 2023-05-06 19:10:21
thanks you very much for your help
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-07-25 04:56:29
Playback History + Now Playing 2 (foo_nowplaying2)+ Text Reader
Now Playing 2 (foo_nowplaying2)
https://hydrogenaud.io/index.php/topic,124427.0.html

https://i.imgur.com/NNUtmqr.png

Playback history is displayed in Text Reader in cooperation.
Garbled characters in Text Reader (Japanese).
foo_nowplaying2 is not garbled.

Thanks.
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2023-07-25 06:48:11
I would like some help with the samples jsplaylist.

I would like to set the correct aspect ratio of the image to the background of the playlist (see pictures below)  and reduce the star character / rating.

I understood that the interested module is the main.js but more than having changed the font size of group 1 and 2 I was unable to do thanks

JS Playlist
(https://i.postimg.cc/yDBZCZTB/Screenshot-2023-07-25-073937.png) (https://postimg.cc/yDBZCZTB)

EL Playlist
(https://i.postimg.cc/ZC6dQcpV/Screenshot-2023-07-25-074006.png) (https://postimg.cc/ZC6dQcpV)
Title: Re: JScript Panel script discussion/help
Post by: Jul2323 on 2023-07-25 07:48:22
in playlist.js  line 140 and 141 : g_font_awesome_20 
you can change to g_font_awesome_12

in main.js line 1306 you have the font size . maybe you can add a line :

g_font_awesome_18 = _font("FontAwesome", 18);  with the size you want and put in playlist.js  :g_font_awesome_18

For the background image i don't know
Title: Re: JScript Panel script discussion/help
Post by: Jul2323 on 2023-07-25 07:54:37
Is it possible to make a text like the title song ( gr.WriteText ) to scroll from left to right in Jscript Panel 3 ?

The offset is only vertical in WriteTextLayout( ) ? I can not figure out how to do it another way ? Thanks You .
Title: Re: JScript Panel script discussion/help
Post by: mexx on 2023-07-25 10:29:45
Hello,

how can I set the font and color in JScrip3/Samples:Properties. I already got the color of the heading (see Appendix).
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-07-25 11:31:09
Playback History + Now Playing 2 (foo_nowplaying2)+ Text Reader
Now Playing 2 (foo_nowplaying2)
https://hydrogenaud.io/index.php/topic,124427.0.html

https://i.imgur.com/NNUtmqr.png

Playback history is displayed in Text Reader in cooperation.
Garbled characters in Text Reader (Japanese).
foo_nowplaying2 is not garbled.

Thanks.

and
I would like a Pre-second update option in Text Reader.
Title: Re: JScript Panel script discussion/help
Post by: sveakul on 2023-07-25 23:09:07
I would like a Pre-second update option in Text Reader.
Related to Air KEN's requests for the Text Reader sample:

1) Offer an "auto-refresh" option for Text Reader that will auto-refresh itself each time the text file it's displaying is written to.,

2) Enable the display of Unicode UTF-8;  e.g., while the text file (and window title) correctly shows "2023-07-25 17:55:59  Blacknasty - Давай Идти Никуда," it is displayed in the main Text Reader window as: (https://i.imgur.com/aSK2DVe.png)

Thanks for your consideration!
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-07-25 23:35:15
I would like a Pre-second update option in Text Reader.
Related to Air KEN's requests for the Text Reader sample:

1) Offer an "auto-refresh" option for Text Reader that will auto-refresh itself each time the text file it's displaying is written to.,

2) Enable the display of Unicode UTF-8;  e.g., while the text file (and window title) correctly shows "2023-07-25 17:55:59  Blacknasty - Давай Идти Никуда," it is displayed in the main Text Reader window as: (https://i.imgur.com/aSK2DVe.png)

Thanks for your consideration!

I think it's probably because the font is different.
I want to change the font, but I can't find which script it is.

// @import "%fb2k_component_path%helpers.txt"
// @import "%fb2k_component_path%samples\js\lodash.min.js"
// @import "%fb2k_component_path%samples\js\common.js"
// @import "%fb2k_component_path%samples\js\panel.js"
// @import "%fb2k_component_path%samples\js\text.js"
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-07-26 05:24:25
Solved the garbled problem.
I found that it depends on the installed fonts.
It may be a font other than this.

MaterialIconsRound-Regular,Segoe Fluent Icons fonts
https://mega.nz/file/9S0xQaDL#VCGminQGRN28M5uDaaJgbyx8dM55VnIMyEla7Aa-F2A

for confirmation.
Text Reader right click > Configure... > Samples > Text Reader.
Text Reader right click > Fixed width font on/off repeat.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-07-26 13:12:54
The text reader has been updated in the latest release to try and handle files with other encodings other than UTF8. If it were proper UTF8 (with or without BOM is fine), the previous versions would not have issues.

It has to be manually chosen from the right click menu and may not always work. If it does, great. If not, meh.

All the comments about refreshing and what not I'm just plain ignoring. Don't like it? Don't use it..
Title: Re: JScript Panel script discussion/help
Post by: sveakul on 2023-07-27 00:16:26
The text reader has been updated in the latest release to try and handle files with other encodings other than UTF8. If it were proper UTF8 (with or without BOM is fine), the previous versions would not have issues.

It has to be manually chosen from the right click menu and may not always work. If it does, great. If not, meh.

All the comments about refreshing and what not I'm just plain ignoring. Don't like it? Don't use it..
After replacing the Text Reader sample with the 3.3.2 release, the window does show correct Cyrillic from the target file with "UTF8" selected in the context menu.  Thank you!
Did not mean to annoy you with the feature request for the additional refresh option.
Title: Re: JScript Panel script discussion/help
Post by: ms1602 on 2023-09-23 14:57:34
Hello,

https://imgbox.com/QJK3K1wu

Is it possible for the graphic thumbnails to be displayed in the same order as in the image? So the front cover comes first, then the back cover and a photo of the disc. Apart from that - is it possible to change the background of the thumbnails to make it the same as the large photo? Besides, couldn't you set the photo size differently so that it fits the overall window? (I also marked it in the image). Many thanks in advance for your help!
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-09-27 13:31:00
There's no easy way to sort the files in a specfic order so you'd to bypass adding all images in folder and add them manually. If you browse the component folder\samples\js and open the file thumbs.js in a text editor, line 563 should be...

Code: [Select]
this.files = _getFiles(this.folder, this.exts);

You can replace it with something like...

Code: [Select]
this.files = [];
this.files.push(this.folder + "\\front.jpg");
this.files.push(this.folder + "\\back.jpg");
this.files.push(this.folder + "\\disc.jpg");

Note that title formatting and wildcards are not supported here - the filename/extension must match. And it doesn't matter if a given filename isn't valid for all folders - it will be ignored.
Title: Re: JScript Panel script discussion/help
Post by: ms1602 on 2023-09-27 18:01:42
Thanks for the help!

I noticed that if there are only 2 graphics in the folder (for example, front and back covers), when I go to the second photo, it automatically changes to the first one after a second or two. When there are 3 photos (front cover, back cover, disc) this problem does not occur. One more question - if the name of the disc file is also in .png, should I enter:

this.files.push(this.folder + "\\disc.jpg;disc.png");

?

Edit:

Okay, I see that now the covers saved in the file are not displayed, only those in the folder. Can't you combine it so that the built-in ones and those in the folder are displayed? Do you have to do either way?
Title: Re: JScript Panel script discussion/help
Post by: Cosmik Vek on 2023-09-29 00:11:48
Hi,
I am using the panel pre-configured with the "Text Display" sample
and I have not touched anything in the JS code,
but I have tweaked some of the options from the context menu to display the custom text that I want
and to also display the album cover as the background.

But, something that I really want but can't seem to get working is just trying to add a simple blur to this album cover BG.
I have tried coding this myself and other snippets I have found from here produced JS errors.

So, it would be of great help to know how I can make it all work!

I have the latest version of both FB2K (2.0 / 32 bits) and the JScript 3.0 panel.
Thanks in advance for any help!
Title: Re: JScript Panel script discussion/help
Post by: etip on 2023-09-29 07:22:03
there is actually a simple function that does that (https://jscript-panel.github.io/docs/interfaces/IJSImage/#stackblurradius).
Take a look and let us know if you managed to make it work.
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2023-09-29 13:43:45
there is actually a simple function that does that (https://jscript-panel.github.io/docs/interfaces/IJSImage/#stackblurradius).
Take a look and let us know if you managed to make it work.

(https://i.postimg.cc/68jGr5xj/Immagine-2023-09-29-144148.png) (https://postimg.cc/68jGr5xj)

 :))
Title: Re: JScript Panel script discussion/help
Post by: Cosmik Vek on 2023-09-30 00:35:08
I tried implementing in that "Stack Blur" function before,
but it doesn't seem to work out at all.
In fact, the album art object does not appear to support this method,
because all I get is a "Object doesn't support property or method 'StackBlur' " error in the console when I try to do so.
So, I am really clueless on how I can fix that issue.
Thanks.
Title: Re: JScript Panel script discussion/help
Post by: etip on 2023-09-30 09:20:16
you are probably not applying the StackBlur method to an image.
Can you show us the code ?
Thanks
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-09-30 09:57:52
On line 16 of samples\js\albumart.js is this...

Code: [Select]
this.img = img;

Simply insert this on a new line after it...

Code: [Select]
this.img.StackBlur(50); // valid values are 2-254
Title: Re: JScript Panel script discussion/help
Post by: Cosmik Vek on 2023-10-01 04:09:42
It worked!
I added the new line to the JS file,
but as I am using multiple JScript panels that also displays the album cover,
they're all using that same "albumart" JS script file,
so obviously, (almost) all of the album covers got blurry.

So, to fix that,
I simply duplicated the JS file with a new name ("albumart+blur.js"), added in the StackBlur to it
and in the code for my "Text Display" panel, in the Preprocessor area,
I just changed the import path for the old "albumart" to reflect the new name for the new script just like so!
Code: [Select]
// @import "%fb2k_component_path%samples\js\albumart+blur.js"
After saving the script, it only applied the blur here, which is perfectly what I wanted!

Thanks for the help!
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-10-01 08:47:15
Good to know you got it working, but if I'm not mistaken, all changes made in the JS Sample directories would be overwritten upon update.
Anyway, here's my newbie attempt at a text reader with album art blur code.
We could change the blur radius and the overlay shade here.
Code: [Select]
// ==PREPROCESSOR==
// @name "Text Display + Album Art Blur"
// @author "marc2003"
// @import "%fb2k_component_path%helpers.txt"
// @import "%fb2k_component_path%samples\js\lodash.min.js"
// @import "%fb2k_component_path%samples\js\common.js"
// @import "%fb2k_component_path%samples\js\panel.js"
// @import "%fb2k_component_path%samples\js\albumart.js"
// @import "%fb2k_component_path%samples\js\text_display.js"
// ==/PREPROCESSOR==

// https://jscript-panel.github.io/gallery/text-display/

var radius = 50;
var overlay = 180;

var g_img = null;
var g_metadb = null;
var g_info = '';

var panel = new _panel({ custom_background : true });
var albumart = new _albumart(0, 0, 0, 0);
var text = new _text_display(LM, 0, 0, 0);

var blur_img = null;

var ww = 0, wh = 0;

update_album_art();
StackBlur(radius);

panel.item_focus_change();

function update_album_art() {
if (g_img) g_img.Dispose();
g_img = null;
g_info = '';
g_metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
if (g_metadb) {
g_img = g_metadb.GetAlbumArt(); // omitting the type defaults to front
if (g_img) {
blur_img = g_img.Clone();
blur_img.StackBlur(radius);
}
}
window.Repaint();
}

//
function StackBlur(radius) {
if (blur_img) blur_img.Dispose();
blur_img = g_img.Clone();
g_img.StackBlur(radius);
}
//

function on_colours_changed() {
panel.colours_changed();
text.refresh(true);
//
window.Repaint();
}

function on_font_changed() {
panel.font_changed();
text.refresh(true);
}

function on_item_focus_change() {
panel.item_focus_change();
//
if (!fb.IsPlaying) update_album_art();
}

function on_metadb_changed() {
albumart.metadb_changed();
text.metadb_changed();
}

function on_mouse_lbtn_dblclk() {
if (g_metadb) g_metadb.ShowAlbumArtViewer(0);
}

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

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

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

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

function on_paint(gr) {

panel.paint(gr);

var bg = window.IsDefaultUI ? window.GetColourDUI(1) : window.GetColourCUI(3);
gr.Clear(bg);
    if (g_img) {
        _drawImage(gr, blur_img, 0, 0, panel.w, panel.h, image.crop);
}

    _drawOverlay(gr, 0, 0, panel.w, panel.h, overlay);
text.paint(gr);

}

// get notified of album art changes when listening to a supported stream
function on_playback_dynamic_info_track(type) {
if (type == 1) update_album_art();
// type 0 is metadata which we're not interested in
}

function on_playback_new_track() {
panel.item_focus_change();
//
update_album_art();
}

function on_playback_pause() {
text.refresh();
}

function on_playback_stop(reason) {
text.refresh();
//
if (reason != 2) {
update_album_art();
}
}

function on_playback_time() {
text.playback_time();
}

function on_playlist_items_added() {
panel.item_focus_change();
}

function on_playlist_items_removed() {
panel.item_focus_change();
}

function on_playlist_items_reordered() {
text.refresh();
}

function on_playlist_switch() {
panel.item_focus_change();
//
if (!fb.IsPlaying) update_album_art();
}

function on_size() {
panel.size();
text.w = panel.w - (LM * 2);
text.h = panel.h;
text.size();

ww = window.Width;
wh = window.Height;
}
Preview
Spoiler (click to show/hide)
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2023-10-01 11:32:14
@ eurekagliese

THX.

Already put into practice.

(https://i.postimg.cc/XZvKt341/Screenshot-2023-10-01-122841.png) (https://postimg.cc/XZvKt341)

Edit: When restarting foobar2000 it goes into error.

JScript Panel 3.3.4 (Text Display + Album Art Blur by marc2003)
JavaScript run-time error
Cannot retrieve the 'Clone' property of a null or undefined reference
File: <main>
Line: 52, Col: 2

Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2023-10-01 17:19:49
Solved.
I accidentally added the .js file too.
All you need is the txt file, in the samples directory.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-10-02 09:37:58
I suppose my advice about editing .js files was not good. A better alternative is to transplant the method that handles updates in to the .txt file that goes in the panel.

Inside a panel with the text display script, insert this directly after var albumart = new _albumart(0, 0, 0, 0);

Code: [Select]
albumart.metadb_changed = function () {
var img = null;
if (panel.metadb) {
img = panel.metadb.GetAlbumArt(this.properties.id.value);
}

if (this.img) this.img.Dispose();
this.img = null;
this.tooltip = this.path = '';
if (img) {
this.img = img;
this.img.StackBlur(50); // valid values are 2-254
this.tooltip = 'Original dimensions: ' + this.img.Width + 'x' + this.img.Height + 'px';
this.path = this.img.Path;
if (this.path.length) {
this.tooltip += '\nPath: ' + this.path;
}
}
window.Repaint();
}

Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-10-02 11:06:16
@marc2k3

A: Line 27   this.img.StackBlur(2); // valid values are 2-254

Is there no choice but to modify A to make AlbumArt not blurry?
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-10-02 12:00:53
Eh? The original is not blurred. This edit is only for those who want blur.
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-10-02 12:29:58
I know that.
context menu > Album art background ← normal condition.

Is it possible to add a blurred state and a switching option?
I'm sorry for taking up your precious time.
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-10-02 12:34:52
I know that.
context menu > Album art background ← normal condition.

Is it possible to add a blurred state and a switching option?
I'm sorry for taking up your precious time.
The code I posted earlier actually does that.
It's blurred by default and can be switched to normal if the album art is check on in context menu.
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-10-02 12:59:17
@eurekagliese

I have already tried your script. thank you.
I thought it was great that you could easily switch between these two +1 functions with Option.

1.) Album Art normal
2.) Album Art Blur
3.) Text only
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-10-03 13:36:10
@marc2k3
Thanks.

v3.3.5
Reply #1273 https://hydrogenaud.io/index.php/topic,110499.msg1033624.html#msg1033624

Album art background

(https://foobar2000.xrea.jp/up/files/up1652.png)

Enable blur effect

(https://foobar2000.xrea.jp/up/files/up1653.png)
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-10-03 15:24:23
Is there a script like this?
If you can edit Samples Script, you can probably create it, but I don't have that knowledge.
(Track Info + Seekbar + Buttons.txt etc...)

Now Playing Info

(https://i.imgur.com/HxsvBiW.png)
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-10-03 16:23:27
Add a normal Text Display panel and make sure the album art option is turned off. Also, make sure vertical alignment is set to bottom.

Then on line 16, you should find this...

Code: [Select]
var text = new _text_display(LM, 0, 0, 0);

Insert this directly after it...

Code: [Select]
text.paint = function (gr) {
if (!this.text_layout) return;

var h = panel.h - this.text_layout.CalcTextHeight(text.w) - 50;
_drawImage(gr, albumart.img, 20, 20, panel.w, h, image.centre);

gr.WriteTextLayout(this.text_layout, this.colour_string, this.x, this.y + _scale(12), this.w, this.ha, this.offset);
this.up_btn.paint(gr, this.default_colour);
this.down_btn.paint(gr, this.default_colour);
}
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2023-10-03 18:17:55
With some modifications:

(https://i.postimg.cc/2bMS4jYJ/Screenshot-2023-10-03-191525.png) (https://postimg.cc/2bMS4jYJ)

 :D
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-10-03 21:45:56
Add a normal Text Display panel and make sure the album art option is turned off. Also, make sure vertical alignment is set to bottom.

Then on line 16, you should find this...

Code: [Select]
var text = new _text_display(LM, 0, 0, 0);

Insert this directly after it...

Code: [Select]
text.paint = function (gr) {
if (!this.text_layout) return;

var h = panel.h - this.text_layout.CalcTextHeight(text.w) - 50;
_drawImage(gr, albumart.img, 20, 20, panel.w, h, image.centre);

gr.WriteTextLayout(this.text_layout, this.colour_string, this.x, this.y + _scale(12), this.w, this.ha, this.offset);
this.up_btn.paint(gr, this.default_colour);
this.down_btn.paint(gr, this.default_colour);
}

@marc2k3
Many Thanks.

I needed to adjust the X axis.

(https://i.imgur.com/ezV3qbY.png)

_drawImage(gr, albumart.img, 0, 20, panel.w, h, image.centre);

(https://i.imgur.com/jGpYEkI.png)
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-10-04 10:57:02
I meant to write panel.w - 40 for the width but forgot.
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2023-10-04 11:20:11
My settings:

lines 17-26

Spoiler (click to show/hide)

lines 110-115

Spoiler (click to show/hide)

result:

(https://i.postimg.cc/bZt0dcdw/Screenshot-2023-10-04-121453.png) (https://postimg.cc/bZt0dcdw)

Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-10-04 11:25:10
Oh, I see.
Thanks.

Line 21: _drawImage(gr, albumart.img, 20, 20, panel.w - 40, h, image.centre);

(https://i.imgur.com/GqdIX8F.png)
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2023-10-04 11:57:09
A change would need to be made for vertical alignment to work properly.

The image must translate with the text in the following way:

top image
text bottom

image center
text center

bottom image
text top.

Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2023-10-04 12:35:00
In the end I managed to find the right settings with a static image.
Now even the vertical alignment is optimal.

Spoiler (click to show/hide)
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-10-04 13:02:41
@ApacheReal

We're just changing these values, right?
Can I change it from the context menu?
Spoiler (click to show/hide)
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2023-10-04 13:29:07
@Air KEN

You can make the changes you prefer and give ok.

If they don't work, you can always reload the sample.

If they work well for you, you can export
and overwrite the Text Display + Album Art in the samples directory.

These settings are fine with a $font(Segoe UI,15)

Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2023-10-04 13:29:55
As mentioned above, for optimal use, the image must translate when the vertical alignment is changed

(https://i.postimg.cc/MM9KMfJw/Screenshot-2023-10-04-143251.png) (https://postimg.cc/MM9KMfJw)

(https://i.postimg.cc/0Mkyyd3Z/Screenshot-2023-10-04-143352.png) (https://postimg.cc/0Mkyyd3Z)

(https://i.postimg.cc/R3Q0mbPN/Screenshot-2023-10-04-143454.png) (https://postimg.cc/R3Q0mbPN)
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-10-04 13:56:18
For these modded text display scripts which always display album art not as the background, this function needs updating....

Code: [Select]
function on_playback_dynamic_info_track(type) {
if (type == 0) text.metadb_changed();
else if (type == 1 && text.properties.albumart.enabled) albumart.metadb_changed();
}

should now be...

Code: [Select]
function on_playback_dynamic_info_track(type) {
if (type == 0) text.metadb_changed();
else if (type == 1) albumart.metadb_changed();
}

But it only matters for online streams which supply album art. It can be ignored for local file playback.
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-10-04 14:20:48
(https://i.imgur.com/3V6PH3w.png)

Is it bothersome to blur the image as a background?
The font color also changes according to the background color.
Can also be Enable Dynamic.
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-10-04 14:24:23
Spoiler (click to show/hide)
Is it bothersome to blur the image as a background?
The font color also changes according to the background color.
That would be nice!
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-10-04 17:00:40
Here's a quick and dirty bodge job for having album art above the text and a blurred album art background.

Code: [Select]
// ==PREPROCESSOR==
// @name "Text Display"
// @author "marc2003"
// @import "%fb2k_component_path%helpers.txt"
// @import "%fb2k_component_path%samples\js\lodash.min.js"
// @import "%fb2k_component_path%samples\js\common.js"
// @import "%fb2k_component_path%samples\js\panel.js"
// @import "%fb2k_component_path%samples\js\albumart.js"
// @import "%fb2k_component_path%samples\js\text_display.js"
// ==/PREPROCESSOR==

// https://jscript-panel.github.io/gallery/text-display/

var panel = new _panel({ custom_background : true });
var albumart = new _albumart(0, 0, 0, 0);
var text = new _text_display(LM, 0, 0, 0);

albumart.blur_img = null;

albumart.metadb_changed = function () {
var img = null;
if (panel.metadb) {
img = panel.metadb.GetAlbumArt(0);
}

if (this.img) this.img.Dispose();
if (this.blur_img) this.blur_img.Dispose();
this.img = this.blur_img = null;
this.tooltip = this.path = '';
if (img) {
this.img = img;
if (text.properties.albumart_blur.enabled) {
this.blur_img = this.img.Clone();
this.blur_img.StackBlur(60);
}
this.tooltip = 'Original dimensions: ' + this.img.Width + 'x' + this.img.Height + 'px';
this.path = this.img.Path;
if (this.path.length) {
this.tooltip += '\nPath: ' + this.path;
}
}
window.Repaint();
}


text.paint = function (gr) {
if (!this.text_layout) return;

if (this.properties.albumart.enabled) {
_drawImage(gr, this.properties.albumart_blur.enabled ? albumart.blur_img : albumart.img, 0, 0, panel.w, panel.h, image.crop);
_drawOverlay(gr, 0, 0, panel.w, panel.h, 120);
}

var h = panel.h - this.text_layout.CalcTextHeight(this.w) - 50;
_drawImage(gr, albumart.img, 20, 20, panel.w - 40, h, image.centre);

gr.WriteTextLayout(this.text_layout, this.colour_string, this.x, this.y + _scale(12), this.w, this.ha, this.offset);
this.up_btn.paint(gr, this.default_colour);
this.down_btn.paint(gr, this.default_colour);
}

panel.item_focus_change();

function on_colours_changed() {
panel.colours_changed();
text.refresh(true);
}

function on_font_changed() {
panel.font_changed();
text.refresh(true);
}

function on_item_focus_change() {
if (panel.selection.value == 0 && fb.IsPlaying) return;
panel.item_focus_change();
}

function on_metadb_changed() {
albumart.metadb_changed();
text.metadb_changed();
}

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

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

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

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

function on_paint(gr) {
panel.paint(gr);
text.paint(gr);
}

function on_playback_dynamic_info_track(type) {
if (type == 0) text.metadb_changed();
else if (type == 1) albumart.metadb_changed();
}

function on_playback_new_track() {
panel.item_focus_change();
}

function on_playback_pause() {
text.refresh();
}

function on_playback_stop(reason) {
if (reason != 2) {
panel.item_focus_change();
}
}

function on_playback_time() {
text.playback_time();
}

function on_playlist_items_added() {
text.refresh();
}

function on_playlist_items_removed() {
text.refresh();
}

function on_playlist_items_reordered() {
text.refresh();
}

function on_playlist_switch() {
on_item_focus_change();
}

function on_size() {
panel.size();
text.w = panel.w - (LM * 2);
text.h = panel.h;
text.size();
}

The right click menu options for enabling/blurring the background should work as expected. And the vertical alignment must be set to bottom as per my previous mod.
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-10-04 17:10:47
Here's a quick and dirty bodge job for having album art above the text and a blurred album art background.

Code: [Select]
// ==PREPROCESSOR==
// @name "Text Display"
// @author "marc2003"
// @import "%fb2k_component_path%helpers.txt"
// @import "%fb2k_component_path%samples\js\lodash.min.js"
// @import "%fb2k_component_path%samples\js\common.js"
// @import "%fb2k_component_path%samples\js\panel.js"
// @import "%fb2k_component_path%samples\js\albumart.js"
// @import "%fb2k_component_path%samples\js\text_display.js"
// ==/PREPROCESSOR==

// https://jscript-panel.github.io/gallery/text-display/

var panel = new _panel({ custom_background : true });
var albumart = new _albumart(0, 0, 0, 0);
var text = new _text_display(LM, 0, 0, 0);

albumart.blur_img = null;

albumart.metadb_changed = function () {
var img = null;
if (panel.metadb) {
img = panel.metadb.GetAlbumArt(this.properties.id.value);
}

if (this.img) this.img.Dispose();
if (this.blur_img) this.blur_img.Dispose();
this.img = this.blur_img = null;
this.tooltip = this.path = '';
if (img) {
this.img = img;
if (panel.display_objects.length) {
if (panel.display_objects[0].properties.albumart_blur.enabled) {
this.blur_img = this.img.Clone();
this.blur_img.StackBlur(60);
}
}
this.tooltip = 'Original dimensions: ' + this.img.Width + 'x' + this.img.Height + 'px';
this.path = this.img.Path;
if (this.path.length) {
this.tooltip += '\nPath: ' + this.path;
}
}
window.Repaint();
}


text.paint = function (gr) {
if (!this.text_layout) return;

if (this.properties.albumart.enabled) {
_drawImage(gr, this.properties.albumart_blur.enabled ? albumart.blur_img : albumart.img, 0, 0, panel.w, panel.h, image.crop);
_drawOverlay(gr, 0, 0, panel.w, panel.h, 170);
}

var h = panel.h - this.text_layout.CalcTextHeight(this.w) - 50;
_drawImage(gr, albumart.img, 20, 20, panel.w - 40, h, image.centre);

gr.WriteTextLayout(this.text_layout, this.colour_string, this.x, this.y + _scale(12), this.w, this.ha, this.offset);
this.up_btn.paint(gr, this.default_colour);
this.down_btn.paint(gr, this.default_colour);
}

panel.item_focus_change();

function on_colours_changed() {
panel.colours_changed();
text.refresh(true);
}

function on_font_changed() {
panel.font_changed();
text.refresh(true);
}

function on_item_focus_change() {
if (panel.selection.value == 0 && fb.IsPlaying) return;
panel.item_focus_change();
}

function on_metadb_changed() {
albumart.metadb_changed();
text.metadb_changed();
}

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

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

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

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

function on_paint(gr) {
panel.paint(gr);
text.paint(gr);
}

function on_playback_dynamic_info_track(type) {
if (type == 0) text.metadb_changed();
else if (type == 1) albumart.metadb_changed();
}

function on_playback_new_track() {
panel.item_focus_change();
}

function on_playback_pause() {
text.refresh();
}

function on_playback_stop(reason) {
if (reason != 2) {
panel.item_focus_change();
}
}

function on_playback_time() {
text.playback_time();
}

function on_playlist_items_added() {
text.refresh();
}

function on_playlist_items_removed() {
text.refresh();
}

function on_playlist_items_reordered() {
text.refresh();
}

function on_playlist_switch() {
on_item_focus_change();
}

function on_size() {
panel.size();
text.w = panel.w - (LM * 2);
text.h = panel.h;
text.size();
}

The right click menu options for enabling/blurring the background should work as expected. And the vertical alignment must be set to bottom as per my previous mod.

Thank you, the display looks great!
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2023-10-04 17:58:48
All this studied with the crop image, which cuts the image and for me it is not possible, just see the difference between the left panel (crop image) and the right panel (center image):

(https://i.postimg.cc/47jPqZ3C/Screenshot-2023-10-04-185357.png) (https://postimg.cc/47jPqZ3C)

Then I don't understand the small double image and then the large one.

I can't use it.
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-10-04 22:50:16
@marc2k3

Wow, it really came out. thank you.
Use "Album art background" and "Enable blur effect" differently depending on Album Art.
It is convenient to be able to switch using the context menu.
I feel there are many possibilities.

Many Thanks.

"Enable blur effect"
(https://foobar2000.xrea.jp/up/files/up1660.png)
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-10-04 23:55:19
Album Art Move

Spoiler (click to show/hide)
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2023-10-05 08:17:10
I have a mod version that I have been working on for more than 10 years and it is quite complex.

The skin uses mirrored, modular panels for the left and right and fixed panels in the center.

So I had to make changes to fit this new Text Display which I called Text Display + Album Art Picture in Picture.

Having a Text Display in which dynamic data enters when listening, changing, pausing, skipping the track as listed below:

the progress bar for local files;

the progress bar for streaming radio;

information on the last track listened to;

I had to create two different Text Display + Album Art Picture in Picture, blocking the small picture in picture image:

Text Display + Album Art Picture in Picture (left) with adapted lines (54-55):

var h = panel.h - this.text_layout.CalcTextHeight(this.w);
_drawImage(gr, albumart.img, -225, 3, panel.w - 40, panel.h - 600, image.centre);


Text Display + Album Art Picture in Picture (right) with adapted lines (54-55):

var h = panel.h - this.text_layout.CalcTextHeight(this.w);
_drawImage(gr, albumart.img, -225, 3, panel.w + 940, panel.h - 600, image.centre);

see photo:

(https://i.postimg.cc/qzHT2z32/Screenshot-2023-10-05-090023.png) (https://postimg.cc/qzHT2z32)
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-10-05 09:11:41
Numbers edited by me.

Text Display + Album Art Script (.txt)
https://foobar2000.xrea.jp/up/files/up1668.zip

Text Display + Album Art 3
checked:
Pre-second updates
Album art background
Enable blur effect
Horizontal alignment > Center
Vertical alignment > Bottom

Spoiler (click to show/hide)

Text Display + Album Art 5
checked:
Pre-second updates
Album art background
Enable blur effect
Horizontal alignment > Center
Vertical alignment > Top

Spoiler (click to show/hide)
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-10-05 09:52:20
^Seems like a waste of time having per second updates enabled with no time display??

Any changes to tags are detected automatically as are list index changes from adding/removing/reordering playlist items.
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-10-05 10:05:38
Oops I forgot.
[Playback Time: %playback_time% / ][%length%]
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2023-10-05 14:08:53
I don't know if it's a problem that arose with the latest JS Scrip 3 update, but I noticed a big problem, if you keep two panels open with related samples, when skipping the track, one of the two panels, the one inactive upon selection, changes randomly.

This is a big problem for me.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-10-05 14:26:48
I have no idea what you're on about. You'll have to be more specific.

edit: also, terms like related and inactive are nonsensical. They have no meaning in any discussion about multiple instances.
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2023-10-05 15:14:07
Doing some tests, the problem seems to be, when skipping the track, the switch between an active panel and an inactive panel, the latter should not change when skipping the track, but stay still.

At this point, I think that the problem is not JS Scrip Panel 3, because the problem also occurs with spider monkey panel.

The cause is to be found elsewhere, but I have no idea where.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-10-05 16:57:55
Quote
the switch between an active panel and an inactive panel

I see you're doubling down on the gibberish. What's inactive or active in your mind has no basis in reality.
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2023-10-05 18:02:46
It may be nonsense, but in this video you can clearly see what I mean, talking about an active panel, of the last one selected, from a non-active panel.

With the next track I expect the panel to be inactive, it positions itself on another panel when it should be stationary.

https://www.youtube.com/watch?v=BsvvhhV0-kE
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2023-10-05 22:05:34
I found the cause of the problem on next (trace) command in the right panel.

This happens by pressing next, but also when automatically changing tracks in a playlist. If I am positioned at the 5th button in the right panel, the automatic change also occurs on the left panel, always at the 5th button.

You are on button 4 on the right panel and on button 2 on the left panel and you wait for the normal sequential track change of the next song, well on the right panel you remain positioned on button 4, but the left panel does not remain on button 2, but it changes automatically on button 4 etc....

Title: Re: JScript Panel script discussion/help
Post by: always.beta on 2023-10-06 10:22:27
"Enable blur effect"
ESL panels enable custom layouts, and you can actually merge two panels.
https://imgur.com/a/Y4vtRrA
(https://imgur.com/a/Y4vtRrA)
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-10-06 11:00:14
Is there a simple way to modify the colour of unfilled rating stars?
It would be good if that had its own colour variable.

(https://i.imgur.com/oXiMdWq.png)
                    to
(https://i.imgur.com/dM17fYS.png)

The rating sample code
Code: [Select]
function _rating(x, y, h, colour) {
this.paint = function (gr) {
if (panel.metadb) {
for (var i = 0; i < this.get_max(); i++) {
gr.WriteText(i + 1 > (this.hover ? this.hrating : this.rating) ? chars.rating_off : chars.rating_on, JSON.stringify({Name:'FontAwesome',Size:this.h-2}), this.colour, this.x + (i * this.h), this.y, this.h, this.h, 2, 2);
}
}
}
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-10-06 11:09:00
Don't edit the js file but put this in the main panel directly after var rating = new _rating....

Code: [Select]
rating.paint = function (gr) {
if (panel.metadb) {
var font = JSON.stringify({Name:'FontAwesome',Size:this.h-2});
for (var i = 0; i < this.get_max(); i++) {
if (i + 1 > (this.hover ? this.hrating : this.rating)) {
gr.WriteText(chars.rating_off, font, RGB(192, 192, 192), this.x + (i * this.h), this.y, this.h, this.h, 2, 2);
} else {
gr.WriteText(chars.rating_on, font, this.colour, this.x + (i * this.h), this.y, this.h, this.h, 2, 2);
}
}
}
}
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-10-06 11:37:08
Don't edit the js file but put this in the main panel directly after var rating = new _rating....

Code: [Select]
rating.paint = function (gr) {
if (panel.metadb) {
var font = JSON.stringify({Name:'FontAwesome',Size:this.h-2});
for (var i = 0; i < this.get_max(); i++) {
if (i + 1 > (this.hover ? this.hrating : this.rating)) {
gr.WriteText(chars.rating_off, font, RGB(192, 192, 192), this.x + (i * this.h), this.y, this.h, this.h, 2, 2);
} else {
gr.WriteText(chars.rating_on, font, this.colour, this.x + (i * this.h), this.y, this.h, this.h, 2, 2);
}
}
}
}

That was quick!
Thank you very much!

Preview
Spoiler (click to show/hide)
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2023-10-06 13:16:07
I found the cause of the problem on next (trace) command in the right panel.

This happens by pressing next, but also when automatically changing tracks in a playlist. If I am positioned at the 5th button in the right panel, the automatic change also occurs on the left panel, always at the 5th button.

You are on button 4 on the right panel and on button 2 on the left panel and you wait for the normal sequential track change of the next song, well on the right panel you remain positioned on button 4, but the left panel does not remain on button 2, but it changes automatically on button 4 etc....

Problem solved

I modified the scripts that implement the switch.

For the three Multi Panels on the right I used do.vispanel.switch

For the three Multi Panels on the left I used do.megavis.switch
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-10-06 13:16:24
"Enable blur effect"
ESL panels enable custom layouts, and you can actually merge two panels.
https://imgur.com/a/Y4vtRrA
(https://imgur.com/a/Y4vtRrA)

@always.beta
Thanks.
I'll give it a try.
ーーーーーーーーー
Is there a demand for horizontal orientation?
(https://i.imgur.com/fzetPIi.png)
--------------
imaginary image (Front/Back Cover)

(https://i.imgur.com/rqUHOhq.png)
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2023-10-06 16:06:31
Great thanks.  :))

(https://i.postimg.cc/K3fTbxfq/Screenshot-2023-10-06-170344.png) (https://postimg.cc/K3fTbxfq)
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-10-12 05:28:44
How do I change the volume step when using the mouse wheel to normal?
The volume wheel step is good from 0 to -10db, but when dropped from -10db to -100db, it seems "unnatural". Is there an easy method to increase the wheel step only when it falls below -10db?
I tried this code, however it produces an overflow error after certain values, and the transition from 0 to -10 is not as smooth as it should be.
Code: [Select]
function on_mouse_wheel(s) {
var vl = vol2pos(fb.Volume);
vl += s / 20;
fb.Volume = pos2vol(vl);
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-10-12 11:02:23
vol2pos and pos2vol are for volume sliders ensuring they behave the same the built in DUI toolbar volume control with regards to dragging / rendering.

It's nonsensical to try and use them inside on_mouse_wheel. The most sensible way thing to do is to use fb.VolumeUp and fb.VolumeDown because these respect the step settings from the advanced preferences (File>Preferences>Advanced>Playback>Volume step (db) ). If you really must bypass this, simply fb.Volume += whatever.
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-10-12 20:15:41
vol2pos and pos2vol are for volume sliders ensuring they behave the same the built in DUI toolbar volume control with regards to dragging / rendering.

It's nonsensical to try and use them inside on_mouse_wheel. The most sensible way thing to do is to use fb.VolumeUp and fb.VolumeDown because these respect the step settings from the advanced preferences (File>Preferences>Advanced>Playback>Volume step (db) ). If you really must bypass this, simply fb.Volume += whatever.

Thanks, I think I got it by using switch case on certain value, albeit it may need some adjustment.
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-10-19 09:34:22
Hi there again, I'm trying to get an accent colour from GetNowPlayingColours array.
I tried using the Luminance to select the colour, but I don't know how to retrieve it and stop at the correct colour.
For example, in this album art, colours 0 and 1 do not match; so, skip to the next phase, where colour 2 will be used as the colour accent.
(https://i.imgur.com/EbSVN6T.png)
Spoiler (click to show/hide)
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-10-19 10:07:36
You're mixing things up really. The screenshot you posted is from the basic GetColourScheme sample which doesn't do anything except display the colours in order from most dominant to least.

The GetNowPlayingColours() from helpers.txt is something else entirely and it's what I used for dynamic colours in JSPlaylist and the Smooth samples. The calulations are done for you.

If not playing or there is no art, it returns an empty array so always check for that. If a valid image is found then array length is always 4. Colours are returned in this order....

https://github.com/jscript-panel/component/blob/3547fd4dcdcae0a8e893ae26e083d7a40edccc60/helpers.txt#L283

The background_colour is always the most dominant and the selected_background_colour is calculated to have a luminace value with the biggest distance away from the background_colour. That should be your accent. The text colours are always black or white calculated with DetermineTextColour - this ensures it's always readble.

Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-10-19 21:33:19
Thank you for responding and explaining. I've been using selected_background_colour as g_color_selection for a while now.
Actually, I was trying to always find the light accent, as I'm trying to match it with the dark blur background for the tracks. So the question would be how to always calculate Luminance from dark background or RGB(0,0,0). I tried to emulate using the calculation from the GetNowPlayingColours diff, but had no luck and since this just a minor issue, I might try it again later.

Anyway, I have another question that has been bugging me for a while.
When I set the g_colour_text from GetNowPlayingColours as the button colour, it took about 4 seconds for the button to update the colour when I selected and started a new track.

I have already added the buttons.update() to some function, but several functions, such as on_playback_new_track, on_item_focus_change, and on_colors_changed, returned an error.
Object doesn't support property or method 'update'

The metadb are set to fb.GetNowPlaying. When set to fb.GetFocusItem, it does change on the fly when selecting a new track but as expected it doesn't get the colour for next track, although it can be passed by activating the cursor follow playback.

(https://i.imgur.com/tYovEiH.gif)
Title: Re: JScript Panel script discussion/help
Post by: mexx on 2023-10-23 14:37:13
I'm asking for help.

I display my covers in JScript Panel3 / Album Art.
When I place the cursor over the displayed cover, a pop-up window always appears with information about the cover (see appendix).

How can I turn off this pop-up window?

Sorry for my english. It's google translate.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-10-23 14:44:05
Clicking the panel immediately dismisses it but if you really want to prevent it completely... right click the panel > Configure. Add this code...

Code: [Select]
function _tt() {}
Title: Re: JScript Panel script discussion/help
Post by: mexx on 2023-10-23 14:49:55
Excellent. Thanks for the quick help.
Title: Re: JScript Panel script discussion/help
Post by: samuelawachie on 2023-10-28 05:49:09
I have been using the DarkOne4Mod on foobar for a long time since I've been on Windows. I was on the initial version of the theme all the way to the current version and it uses the JScript component to load most of the panels in the layout.
I have now moved to Linux (ZorinOS) and I'm having trouble getting one particular panel to show up.
I attached a photo to show exactly what I mean.
I think I'm encountering the error/crash due to some font differences between Linux and Windows.
Can someone help me out as to what to edit in the Panel settings to get this to work please?

Console:
Error: JScript Panel (DarkOne4Mod - Display Panel v1.0 build20160929 by super-gau and tedGo, includes partial codes by fbuser, Br3tt and T.P Wang): Invalid parameter.  File: <main>
Line: 184, Col: 3
<source text only available at compile time>

I thought one of those variables was not initialized but my trying to solve it myself didn't work so far.
JScript panel version: 1.1.6
Foobar version: 2.0 (x86) running via PlayOnLinux
Title: Re: JScript Panel script discussion/help
Post by: Majestyk on 2023-10-28 07:50:34
Console:
Error: JScript Panel (DarkOne4Mod - Display Panel v1.0 build20160929 by super-gau and tedGo, includes partial codes by fbuser, Br3tt and T.P Wang): Invalid parameter.  File: <main>
Line: 184, Col: 3
<source text only available at compile time>

I thought one of those variables was not initialized but my trying to solve it myself didn't work so far.
JScript panel version: 1.1.6
Foobar version: 2.0 (x86) running via PlayOnLinux

Does Linux have Microsoft Sans Serif font? If not, type in one you do have. (Try Arial Black) It still shouldn't crash, however. At least it wouldn't in Windows.

Or delete the line or put a // in front of it and see what happens.

I suggest downloading the latest non modded Darkone here...

https://foobar-users.de/index.php?topic=4851.0
Title: Re: JScript Panel script discussion/help
Post by: ms1602 on 2023-10-28 13:50:39
Thank you for responding and explaining. I've been using selected_background_colour as g_color_selection for a while now.
Actually, I was trying to always find the light accent, as I'm trying to match it with the dark blur background for the tracks. So the question would be how to always calculate Luminance from dark background or RGB(0,0,0). I tried to emulate using the calculation from the GetNowPlayingColours diff, but had no luck and since this just a minor issue, I might try it again later.

Anyway, I have another question that has been bugging me for a while.
When I set the g_colour_text from GetNowPlayingColours as the button colour, it took about 4 seconds for the button to update the colour when I selected and started a new track.

I have already added the buttons.update() to some function, but several functions, such as on_playback_new_track, on_item_focus_change, and on_colors_changed, returned an error.
Object doesn't support property or method 'update'

The metadb are set to fb.GetNowPlaying. When set to fb.GetFocusItem, it does change on the fly when selecting a new track but as expected it doesn't get the colour for next track, although it can be passed by activating the cursor follow playback.

(https://i.imgur.com/tYovEiH.gif)

Hello,

How did you arrange the tabs in two rows? What I mean is the point where you have icons above and captions below (Console, New Tab, etc.).

Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-10-28 15:41:57
Hello,

How did you arrange the tabs in two rows? What I mean is the point where you have icons above and captions below (Console, New Tab, etc.).


Hello there,
Make sure to first install the font (icon) you want to use. I'm using Microsoft's Segoe Fluent Icons font for this one. Download Link (https://aka.ms/SegoeFluentIcons)
Then, using the Character Map app, you may view and select it.

(https://i.imgur.com/32EP4XD.gif)
Title: Re: JScript Panel script discussion/help
Post by: samuelawachie on 2023-10-28 18:37:11
Console:
Error: JScript Panel (DarkOne4Mod - Display Panel v1.0 build20160929 by super-gau and tedGo, includes partial codes by fbuser, Br3tt and T.P Wang): Invalid parameter.  File: <main>
Line: 184, Col: 3
<source text only available at compile time>

I thought one of those variables was not initialized but my trying to solve it myself didn't work so far.
JScript panel version: 1.1.6
Foobar version: 2.0 (x86) running via PlayOnLinux

Does Linux have Microsoft Sans Serif font? If not, type in one you do have. (Try Arial Black) It still shouldn't crash, however. At least it wouldn't in Windows.

Or delete the line or put a // in front of it and see what happens.

I suggest downloading the latest non modded Darkone here...

https://foobar-users.de/index.php?topic=4851.0

Yeah thanks. Commenting it out worked to remove the error, but left a blank panel
But changing the font to one that I did have worked perfectly. I had to use FreeSerif which is close enough to the size of what Microsoft Sans Serif would've been.
You're the man, and thanks again.
Merry Christmas (:
Title: Re: JScript Panel script discussion/help
Post by: ms1602 on 2023-10-29 06:50:39
Hello,

How did you arrange the tabs in two rows? What I mean is the point where you have icons above and captions below (Console, New Tab, etc.).


Hello there,
Make sure to first install the font (icon) you want to use. I'm using Microsoft's Segoe Fluent Icons font for this one. Download Link (https://aka.ms/SegoeFluentIcons)
Then, using the Character Map app, you may view and select it.

(https://i.imgur.com/32EP4XD.gif)

Thank you! One more question - is it possible to darken the area (or change the color) that I marked on the screenshot? https://imgbox.com/bJx5uR3l
Title: Re: JScript Panel script discussion/help
Post by: redorb on 2023-10-29 07:50:34
@ms1602
That's a very good lookin' .mp4 screendump!
What program did you use for that?
Title: Re: JScript Panel script discussion/help
Post by: ms1602 on 2023-10-29 10:09:04
@ms1602
That's a very good lookin' .mp4 screendump!
What program did you use for that?

Paint 3D.
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-10-29 13:58:49
Thank you! One more question - is it possible to darken the area (or change the color) that I marked on the screenshot? https://imgbox.com/bJx5uR3l
For the time being, I don't believe that is possible on the Default UI. ColumnsUI can do it, however you may have to change and compile the component from source yourself.
For the JScript panel part, it can be done.
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-11-01 12:11:22
@marc2k3
I always enjoy using it. thank you.

v3.3.8
"Album Art + Text Display" sample

Are the following options no longer available?
- Context menu > Horizontal alignment/Vertical alignment

Thanks.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-11-01 12:50:14
Yep, no alignment options. There's a note in the script if you look in the panel or the online copy here...

https://github.com/jscript-panel/component/blob/96dd92ef8890cf3554ec59810d608c40bf4aa6be/samples/Album%20Art%20%2B%20Text%20Display.txt#L12-L20

Whatever mods you had previously will continue to work so keep using them if needed. There have not been any changes to the underlying .js files.
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-11-01 13:15:28
got it. thank you.
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-11-03 11:36:10
@marc2k3
Isn't "%codec_long%" field supported?

for example:
%codec% Monkey's Audio → %codec_long% Monkey's Audio / High

Foobar2000:Version 2.1 Preview Change Log
2023-06-05
https://wiki.hydrogenaud.io/index.php?title=Foobar2000:Version_2.1_Preview_Change_Log#2023-06-05
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-11-03 12:20:20
Yes it's supported. I don't have any monkey's audio files to test but for an mp3 I'm listening to right now....



Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-11-03 12:41:46
I was finally able to confirm it (Why?).

Thanks.
Title: Re: JScript Panel script discussion/help
Post by: mexx on 2023-11-04 13:10:49
I display the Cdec profile and the bitrate in JScript Panel 3 3.3.9 / Text Display (see appendix).
Unfortunately, an incorrect bit rate is always displayed when starting the file. Instead of 320 kbps it says 328 kbps (see appendix).
Only when I carry out further manipulation (stop or pause) or I edit the properties will the value be displayed correctly.

My costume text:

Code: [Select]
$font(Microsoft Sans Serif,16,700)%codec_profile% / %bitrate% kbps

Where is the error?

I hope you understand Google Translate. Sorry
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-11-05 14:09:05
Use %__bitrate%
Title: Re: JScript Panel script discussion/help
Post by: mexx on 2023-11-05 15:14:33
Small cause - big effect. A little underline...

THX for the help.
Title: Re: JScript Panel script discussion/help
Post by: Defender on 2023-11-05 15:43:41
Use %__bitrate%


Just curious.
What's the difference between %bitrate% (which I use myself and don't have problems with) and %__bitrate% (or $info(bitrate) ) ?
Title: Re: JScript Panel script discussion/help
Post by: mexx on 2023-11-05 17:07:26
I found another option:

Enable per-seconds updates. Then the correct bitrate comes according to the value set in Preferences/Advanced/Properties dialog/VBR bitrate updates per second.

The displayed VBR values ​​also change every second.

If it says "0" seconds, then the CBR value is correct and the VBR values ​​do not change.
Title: Re: JScript Panel script discussion/help
Post by: Defender on 2023-11-05 23:17:34
I found another option:

Enable per-seconds updates. Then the correct bitrate comes according to the value set in Preferences/Advanced/Properties dialog/VBR bitrate updates per second.

The displayed VBR values ​​also change every second.

If it says "0" seconds, then the CBR value is correct and the VBR values ​​do not change.

Yes, I find this a bit annoying especially with AAC radio streams altering between anything like 123 and 130kbps.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-11-06 09:12:39
I forgot to add this callback inside the main panel script which updates VBR bitrates according to the preferences...

Code: [Select]
function on_playback_dynamic_info() {
text.refresh();
}

Title: Re: JScript Panel script discussion/help
Post by: mexx on 2023-11-06 10:38:50
Unfortunately, this doesn't change the fact that the correct kbps value is only displayed after about 1 second.
This is the value set in Preferences/Advanced/Properties dialog/VBR bitrate updates per second.
If it says "0", then the VBR values ​​do not change. But the correct values are displayed without delay.

I inserted the added code in the main panel script and also in the Text Display Script for testing.

But maybe I'm doing something wrong?
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-11-06 13:31:55
 I'm using standard fb2k SDK methods like any other component. Whatever string is returned from the various title format methods are completely untouched by me. I really don't see how I can do anything about it.
Title: Re: JScript Panel script discussion/help
Post by: grimes on 2023-11-06 14:22:54
Same problem with "Item Details". Only MP3's (CBR/VBR) are affected. So its not a problem with the JScript.
Title: Re: JScript Panel script discussion/help
Post by: cat_plasma on 2023-11-08 17:07:43
Recently the developer of https://github.com/saschanaz/jxl-winthumb released a 32-bit version of the wic plugin for the jxl codec. And I again return to my old desire to store a cache of spectrogram images in jxl format. This plugin works, but in foobar2000 the entire jxl image on the panel is covered with a white translucent color, in other programs there is no such behavior, the file itself is of normal color, which means the problem is how the jscript panel processes wic. Find and fix this issue please.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-11-09 13:38:03
Attach the jxl file as embedded art to an audio track. See if fb2k 2.0+ or Columns UI artwork panels display it correctly. I can't test because I don't have admin rights for registering DLLs right now.

Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-11-10 11:35:11
Since I have no idea about the above issue I posted and shared my code in an old jxlthumb issue that mentioned fb2k here...

https://github.com/saschanaz/jxl-winthumb/issues/22#issuecomment-1805551035

edit: so my code isn't at fault. Something in jxlthumb needs fixing.
Title: Re: JScript Panel script discussion/help
Post by: etip on 2023-11-11 00:31:01
@marc2k3 :
I recently updated to the latest version (i was lagging behind a few versions) and for some reasons my rating in JS Playlist are grey instead of the previous version in which they were golden.
Maybe i missed a step or i didnt find the option to change the color. Would you happen to know why ?
thanks
Grey : X

Golden : X
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-11-11 09:18:38
This is a side effect of the dynamic colour support that was added. It defaults to the text colour because that makes sure it's always readable regardless of background colour.

But if you don't use dynamic colours, I guess I should restore the old behaviour or make it customisable. I'll have a fix in the next release.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-11-11 10:48:01
@etip , if you can't wait for the next release, these files should fix your issue. Save inside the component folder/samples/jsplaylist

https://raw.githubusercontent.com/jscript-panel/component/main/samples/jsplaylist/main.js
https://raw.githubusercontent.com/jscript-panel/component/main/samples/jsplaylist/playlist.js
Title: Re: JScript Panel script discussion/help
Post by: etip on 2023-11-11 18:53:12
yep, it works, Thanks !
Title: Re: JScript Panel script discussion/help
Post by: cwb on 2023-11-17 17:15:22
In regard to JS Playlist:
Is there anything I can do on my end to eliminate displaying the information indicated by the red arrows in the two graphics?


Edit: Maybe I am posting in the wrong subforum?
Title: Re: JScript Panel script discussion/help
Post by: cwb on 2023-11-17 18:37:12
Forget the above request. I figured out a way! :)

Edit: ...But it does leave a section of empty vertical space.
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2023-11-18 08:41:26
Is there an auto size function for the contents of a panel?

When I reduce the display of the panel, in the thumbs and album art samples I see an adaptation, while in the text display and texer reader samples, the text does not adapt to the reduction of the panel.

Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-11-18 09:48:25
Edit: ...But it does leave a section of empty vertical space.

Change the row height to 1.
Title: Re: JScript Panel script discussion/help
Post by: cwb on 2023-11-18 11:01:04
Change the row height to 1.

Anything below a setting of 3 in the row height loses the track count and total duration display. (At least on this PC it does)

Anyway, I think it is fine the way it is set up now.
Title: Re: JScript Panel script discussion/help
Post by: Azuriye on 2023-11-18 18:55:26
Hello, sorry for budging in... I was just wondering if is it possible to write values to a Song's Details tab? I want to implement my version of foo_playcount as it's not customisable...

Especially the Played field and the Last played field, in foo_playcount their tags are %play_count% and %last_played% respectively.

I've attached an image to show what I exactly meant...
Title: Re: JScript Panel script discussion/help
Post by: Sue Dunham on 2023-11-18 23:57:44
I've been modding the samples\Status Bar.txt file, and I have it working pretty well. I've come upon a couple issues though.

First, I added items in the context menu for changing the font and fontsize via InputBoxes. After getting the new value, I found that refresh() and window.Repaint() don't suffice, and I've gone with window.Reload(). This works, but after it does, a standard context menu for a default panel shows of its own accord. Is there a way to suppress that?

Second, I'm getting results I don't expect from utils.CalcTextWidth(). I've taken to multiplying the result by a fudge factor that looks pretty close to 96 pixels / 72 points. Does the function return a value in points?
Title: Re: JScript Panel script discussion/help
Post by: Sue Dunham on 2023-11-19 10:34:10
Ah, so I found the step I omitted after changing the font/fontsize and before trying to refresh: I hadn't actually rerun CreateFontString. :-[ Still, the appearing context menu on Reload was weird.

And the CalcTextWidth bit is clear to me now. Give it points, get points back. Want pixels? Give it pixels.
Title: Re: JScript Panel script discussion/help
Post by: Azuriye on 2023-11-19 19:40:15
Hello, sorry for budging in... I was just wondering if is it possible to write values to a Song's Details tab? I want to implement my version of foo_playcount as it's not customisable...

Especially the Played field and the Last played field, in foo_playcount their tags are %play_count% and %last_played% respectively.

I've attached an image to show what I exactly meant...

Found an extension called External Tagger which can tag files and send them to a SQLite DB or APE tags, not sure if it's possible to integrate it with this. There's m-Tags as well but haven't been having a lot of success so far...
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-11-20 09:20:34
Playback statistics were built in to JSP2 (and SMP inherited them) but it was removed in JSP3. I'm working on bringing them back. It's basically done, I just haven't written the docs. That's a hateful job.

You retrieve values with standard title formatting and setting values is done via various handle methods like

Code: [Select]
handle.SetPlaycount(25);

Integration with the properties dialog is all done automatically. Here's an old screenshot as an example:

(https://kbuffington.github.io/foo_jscript_panel/images/single.png)

The one major flaw in previous implementations is that the title formatting was hard coded to %artist% - %title%. All I cared about was storing last.fm stats which worked well for me but it was probably less useful for everyone else. The new version is entirely configurable. But any changes to the title format will wipe all previous data. It has to be used with care!
Title: Re: JScript Panel script discussion/help
Post by: 2tec on 2023-11-20 10:09:52
That's a hateful job.
Speaking as a retired technical writer, I'll freely review and or edit any Foobar2000 developer's documentation, if that will ever help.

Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-11-20 13:04:40
@Azuriye - see the latest release page/docs

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

@2tec - thanks for the offer. Not sure you'd want to check all the content on my docs site though.

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

It's quite a lot and goes way beyond the average fb2k component. :P
Title: help
Post by: lewyturn on 2023-11-20 14:04:10
This is the script I modified from samples. Now I want to make the slider display at the start position of the seekbar and display "0:00" on both sides of the seekbar after the playback stops
Title: Re: JScript Panel script discussion/help
Post by: Azuriye on 2023-11-21 11:29:33
@Azuriye - see the latest release page/docs

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

@2tec - thanks for the offer. Not sure you'd want to check all the content on my docs site though.

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

It's quite a lot and goes way beyond the average fb2k component. :P

Hello! Thanks a lot for implementing this feature, have a small doubt about whether the Playback Statistics (foo_playcount) plugin is needed or if can I remove it now and implement everything with the JScript Panel. Also is it possible to have a context menu to hook it with my foobar toolbar buttons? I've attached images below to explain...
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-11-21 13:01:01
The component already exposes 10 main menu commands and you can use them for your needs.

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

Your code inside the callback can make it function like a context menu item...

(not tested as I don't have a fb2k instance with me right now but you get the idea)

Code: [Select]
function on_main_menu(index) {
if (index >= 1 && index <= 5) {
var items = fb.GetSelection(); // should work with playlist or library viewer selections
if (items.Count == 0) return;

for (var i = 0; i < items.Count; i++) {
items.GetItem(i).SetRating(index);
}
items.RefreshStats();
}

// use one the remaining indexes for setting zero rating or whatever.
}


     
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-11-21 13:27:42
This is the script I modified from samples. Now I want to make the slider display at the start position of the seekbar and display "0:00" on both sides of the seekbar after the playback stops

Inside on_paint, there is this...

Code: [Select]
if (fb.IsPlaying) {
...
}

Just add an else like...

Code: [Select]
if (fb.IsPlaying) {
...
} else {
gr.WriteText("0:00", bold_font, colours.time, seekbar.x - _scale(51), (panel.h - _scale(12)) / 2, _scale(45), _scale(12), DWRITE_TEXT_ALIGNMENT_TRAILING, DWRITE_PARAGRAPH_ALIGNMENT_CENTER);
gr.WriteText("0:00", bold_font, colours.time, seekbar.x + seekbar.w + _scale(12), (panel.h - _scale(12)) / 2, _scale(45), _scale(12), DWRITE_TEXT_ALIGNMENT_LEADING, DWRITE_PARAGRAPH_ALIGNMENT_CENTER);
}
Title: Re: JScript Panel script discussion/help
Post by: Azuriye on 2023-11-21 16:03:32
The component already exposes 10 main menu commands and you can use them for your needs.

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

Your code inside the callback can make it function like a context menu item...

(not tested as I don't have a fb2k instance with me right now but you get the idea)

Code: [Select]
function on_main_menu(index) {
if (index >= 1 && index <= 5) {
var items = fb.GetSelection(); // should work with playlist or library viewer selections
if (items.Count == 0) return;

for (var i = 0; i < items.Count; i++) {
items.GetItem(i).SetRating(index);
}
items.RefreshStats();
}

// use one the remaining indexes for setting zero rating or whatever.
}


     

My bad, I'm sorry for not checking the documentation... However, Thanks a lot for implementing so many features! was about to lose hope and move to MusicBee until you implemented the new feature.
Title: Re: JScript Panel script discussion/help
Post by: Azuriye on 2023-11-21 17:29:14
The component already exposes 10 main menu commands and you can use them for your needs.

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

Your code inside the callback can make it function like a context menu item...

(not tested as I don't have a fb2k instance with me right now but you get the idea)

Code: [Select]
function on_main_menu(index) {
if (index >= 1 && index <= 5) {
var items = fb.GetSelection(); // should work with playlist or library viewer selections
if (items.Count == 0) return;

for (var i = 0; i < items.Count; i++) {
items.GetItem(i).SetRating(index);
}
items.RefreshStats();
}

// use one the remaining indexes for setting zero rating or whatever.
}


     

Hello @marc2k3 I guess I've found a bug with the above code... Here is my implementation so far.
Code: [Select]
function on_main_menu(index) {
switch (index) {
case 1:
var handle_list = plman.GetPlaylistSelectedItems(plman.ActivePlaylist); // I've tried var items = fb.GetSelection(); as well but still the same result.
if (handle_list.Count == 0) return;
if (fb.GetSelectionType() != 1) return;
var tfo = fb.TitleFormat("%jsp3_loved%");
var favourites = tfo.EvalWithMetadbs(handle_list).toArray();
for (var i = 0; i < handle_list.Count; i++) {
if (favourites[i] === "1") handle_list.GetItem(i).SetLoved(0);
else handle_list.GetItem(i).SetLoved(1);
}
handle_list.RefreshStats();
break;
}
}

I have a playlist of 604 tracks selected and on properties tab shows the same...

Upon applying the function and checking the properties tab there are 645 tracks? Around 41 duplicate tracks made in when applying the setLoved function...

Upon further inspecting the playlist of the correct and wrong tracks I've found out it's duplicates with the same track name but different albums.

I've attached images for you to look into. The left playlist is the correct playlist and the right playlist is wrong, You can see how there are entries added in the right playlist but weren't there to begin with in the left playlist.
Title: Re: JScript Panel script discussion/help
Post by: lewyturn on 2023-11-22 08:17:22
This is the script I modified from samples. Now I want to make the slider display at the start position of the seekbar and display "0:00" on both sides of the seekbar after the playback stops

Inside on_paint, there is this...

Code: [Select]
if (fb.IsPlaying) {
...
}

Just add an else like...

Code: [Select]
if (fb.IsPlaying) {
...
} else {
gr.WriteText("0:00", bold_font, colours.time, seekbar.x - _scale(51), (panel.h - _scale(12)) / 2, _scale(45), _scale(12), DWRITE_TEXT_ALIGNMENT_TRAILING, DWRITE_PARAGRAPH_ALIGNMENT_CENTER);
gr.WriteText("0:00", bold_font, colours.time, seekbar.x + seekbar.w + _scale(12), (panel.h - _scale(12)) / 2, _scale(45), _scale(12), DWRITE_TEXT_ALIGNMENT_LEADING, DWRITE_PARAGRAPH_ALIGNMENT_CENTER);
}

Thanks Marc for your help. I added your code but not getting the expected result. Hope to get your help again.
Below is the result I want.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-11-22 09:30:10
Upon further inspecting the playlist of the correct and wrong tracks I've found out it's duplicates with the same track name but different albums.

I've been explicit about this. An earlier comment in this thread before I released the component:

Quote
The one major flaw in previous implementations is that the title formatting was hard coded to %artist% - %title%. All I cared about was storing last.fm stats which worked well for me but it was probably less useful for everyone else. The new version is entirely configurable. But any changes to the title format will wipe all previous data. It has to be used with care!

When I announced the component release in the main thread:

Quote
Playback statistics are back. The title format pattern for binding database records to tracks is no longer hard coded. It can edited to anything you like.

If you missed that, the changelog and release page included this:

Code: [Select]
https://jscript-panel.github.io/docs/playback-statistics/

Read with care. Behaviour and functionality has changed since the previous implementation in JScript Panel 2.

Specifically...

Quote
Unlike previous implementaions in other scripting components, this allows you to customise the title formatting that database records are bound to.

The default is $lower($meta(artist,0) - %title%) but it can be changed via File>Preferences>Advanced>Tools>JScript Panel 3>Playback Statistics Title Format.

Note that changing this requires an immediate foobar2000 restart and any previously saved data is lost forever. Be careful!

Remember that if you think of using %path%, you must also include %subsong%. One physical file can have the same path for multiple handles if it's a cuesheet or other type of track with multiple chapters.

You can grumble all you like about me using a crappy default but I'm not apologising to anyone who doesn't read or did read it but doesn't understand the premise.


Title: Re: JScript Panel script discussion/help
Post by: Azuriye on 2023-11-23 04:00:58
Upon further inspecting the playlist of the correct and wrong tracks I've found out it's duplicates with the same track name but different albums.

I've been explicit about this. An earlier comment in this thread before I released the component:

Quote
The one major flaw in previous implementations is that the title formatting was hard coded to %artist% - %title%. All I cared about was storing last.fm stats which worked well for me but it was probably less useful for everyone else. The new version is entirely configurable. But any changes to the title format will wipe all previous data. It has to be used with care!

When I announced the component release in the main thread:

Quote
Playback statistics are back. The title format pattern for binding database records to tracks is no longer hard coded. It can edited to anything you like.

If you missed that, the changelog and release page included this:

Code: [Select]
https://jscript-panel.github.io/docs/playback-statistics/

Read with care. Behaviour and functionality has changed since the previous implementation in JScript Panel 2.

Specifically...

Quote
Unlike previous implementaions in other scripting components, this allows you to customise the title formatting that database records are bound to.

The default is $lower($meta(artist,0) - %title%) but it can be changed via File>Preferences>Advanced>Tools>JScript Panel 3>Playback Statistics Title Format.

Note that changing this requires an immediate foobar2000 restart and any previously saved data is lost forever. Be careful!

Remember that if you think of using %path%, you must also include %subsong%. One physical file can have the same path for multiple handles if it's a cuesheet or other type of track with multiple chapters.

You can grumble all you like about me using a crappy default but I'm not apologising to anyone who doesn't read or did read it but doesn't understand the premise.




My bad, haven't understood what it fully meant, but it'd definitely fix my issue of duplicate tracks by using path and subsong...

Also is it possible to have a skip field like how we have for play count or would that complicate things up? Would be nice to have skip statistics so that the user knows track ABC has been presented X times and skipped Y times?
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-11-23 14:50:28
I'm not totally averse to adding more fields but foo_skip and foo_skipcount provide that already.

Admittedly I have no idea how those records are bound to tracks.
Title: Re: JScript Panel script discussion/help
Post by: Azuriye on 2023-11-23 17:16:27
I'm not totally averse to adding more fields but foo_skip and foo_skipcount provide that already.

It's just that it would be better to have all of them in one plugin that way the user can customise the logic behind what counts as a play or a skip...
Title: Re: JScript Panel script discussion/help
Post by: boxerfan88 on 2023-11-23 23:26:41
Hi there,

I am new to JScript Panel.
I installed the latest version, and used the sample "Text Display" (as-is, it is not modified).

I see this small square box at the bottom of the panel.
When I click the square box, it goes to the top of the panel.
Any idea how to get rid of it?

(https://i.ibb.co/Wzh61vJ/2023-11-24-07-22-06-foobar-USB-foobar2000.png)
Title: Re: JScript Panel script discussion/help
Post by: grimes on 2023-11-24 00:33:05
"Most included samples require the installation of FontAwesome which you can grab here" https://jscript-panel.github.io/docs/
(Its an arrow)
Title: Re: JScript Panel script discussion/help
Post by: anamorphic on 2023-11-24 11:11:02
^ It would be great to have an option (or pointer to modify the code) to disable those scroll arrows though, because the trouble is when you only want a small 20px height panel, all you get are arrows and no text. (At least that was the case last time I used it)
Title: Re: JScript Panel script discussion/help
Post by: boxerfan88 on 2023-11-24 13:12:20
"Most included samples require the installation of FontAwesome which you can grab here" https://jscript-panel.github.io/docs/
(Its an arrow)

Got it. Thank you.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-11-25 09:40:46
^ It would be great to have an option (or pointer to modify the code) to disable those scroll arrows though, because the trouble is when you only want a small 20px height panel, all you get are arrows and no text. (At least that was the case last time I used it)

I'll remove them in the next release.

edit: code has been updated on github. If anyone wants it right now, save this inside your component folder\samples\js

https://raw.githubusercontent.com/jscript-panel/component/main/samples/js/text_display.js
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-11-25 14:36:32
A new component has been released with text display arrows removed and skipcount added to playback stats. Links in main thread.
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2023-11-26 06:07:14
If possible in the next version of Text Display add the option Album Art bottom, Text top, at the moment I had to add an additional sample panel to recreate the effect as shown in the images:

(https://i.postimg.cc/vDrNYK5C/Screenshot-2023-11-26-065820.png) (https://postimg.cc/vDrNYK5C)

(https://i.postimg.cc/H89Z6JpT/Screenshot-2023-11-26-065912.png) (https://postimg.cc/H89Z6JpT)
Title: Re: JScript Panel script discussion/help
Post by: Azuriye on 2023-11-26 19:20:55
By the way marc2k3, I feel like someone has mentioned this before but is it possible to have JSPlaylist imitate how SimPlaylists work? It will be a really great addition for users who want to switch from SimPlaylists as it's an old component and hasn't been updated so the white borders and bars are really visible in FB2K 2.0, The only two features which are missing are Sub-groups and positioning the album art cover to the left of the tracks apart from that JSPlaylist seems to be very close to replicating SimPlaylists...

If I recollect a WSH Panel version of JSPlaylist had the option to display album art cover to the left of the tracks. I've attached three images including the one with the WSH Panel taken from a Reddit post...
Title: Re: JScript Panel script discussion/help
Post by: josemescud on 2023-11-26 20:30:27
By the way marc2k3, I feel like someone has mentioned this before but is it possible to have JSPlaylist imitate how SimPlaylists work? It will be a really great addition for users who want to switch from SimPlaylists as it's an old component and hasn't been updated so the white borders and bars are really visible in FB2K 2.0, The only two features which are missing are Sub-groups and positioning the album art cover to the left of the tracks apart from that JSPlaylist seems to be very close to replicating SimPlaylists...

If I recollect a WSH Panel version of JSPlaylist had the option to display album art cover to the left of the tracks. I've attached three images including the one with the WSH Panel taken from a Reddit post...
This problem you raise has been my struggle since I installed foobar many years ago. I am referring to the management of groups.

A long time ago, when I was working with Default UI I installed Simplaylist, which has been the playlist manager that I liked the most when it came to grouping albums with several discs. I remember that the only thing that I didn't like was the line that it drew when painting the %discnumber% metadata to the right since it was enough to frame the album the line that was painted in the abum. I think I could not remove it as I was very limited when programming scripts.

Then I installed Columns UI which is more customizable. After creating different scripts I got the current look (Image) which is not perfect either as I don't like that the grouping that deals with the %discnumber% does not allow painting to the right of the cover and does it on top. I have been asking for years to music music that is its creator, but until today I have not obtained it. Even so the appearance of albums with several discs looks pretty good, at least it's the best I could program. I recommend you to install it and try it.

The right panel showing the covers with their most important data is made from the JsPlaylist before Marc2k3 decided to remove the collapsing of the albums. 
Title: Re: JScript Panel script discussion/help
Post by: Azuriye on 2023-11-26 21:22:33
Then I installed Columns UI which is more customizable. After creating different scripts I got the current look (Image) which is not perfect either as I don't like that the grouping that deals with the %discnumber% does not allow painting to the right of the cover and does it on top. I have been asking for years to music music that is its creator, but until today I have not obtained it. Even so the appearance of albums with several discs looks pretty good, at least it's the best I could program. I recommend you to install it and try it.
 

Hey there! Thanks for sharing your insight, just few days ago a friend of mine also showcased me his CUI theme and it caught me by surprise...

Spending my weekend setting up CUI only to release at the end of today that all my efforts are in vain as resizing in CUI wasn't viable with my theming which consists of Spider Monkey and a JScript 3 panel, my layout basically couldn't scale properly when minimised or on fullscreen and I've exhausted all options such as locking layouts and etc. but that didn't resolve the issue to any degree.

This ultimately made me go back to DUI... Now, about JSPlaylist the in-built Playlist Manager/Organizer which is tucked in a small arrow mark looks neat and subtle. It will definitely be a nice to have if JSPlaylist could imitate SimPlaylist to some extent while giving the user the option to do so within the JSPlaylist's option panel.
Title: Re: JScript Panel script discussion/help
Post by: josemescud on 2023-11-26 22:36:49
Then I installed Columns UI which is more customizable. After creating different scripts I got the current look (Image) which is not perfect either as I don't like that the grouping that deals with the %discnumber% does not allow painting to the right of the cover and does it on top. I have been asking for years to music music that is its creator, but until today I have not obtained it. Even so the appearance of albums with several discs looks pretty good, at least it's the best I could program. I recommend you to install it and try it.
 

Hey there! Thanks for sharing your insight, just few days ago a friend of mine also showcased me his CUI theme and it caught me by surprise...

Spending my weekend setting up CUI only to release at the end of today that all my efforts are in vain as resizing in CUI wasn't viable with my theming which consists of Spider Monkey and a JScript 3 panel, my layout basically couldn't scale properly when minimised or on fullscreen and I've exhausted all options such as locking layouts and etc. but that didn't resolve the issue to any degree.

This ultimately made me go back to DUI... Now, about JSPlaylist the in-built Playlist Manager/Organizer which is tucked in a small arrow mark looks neat and subtle. It will definitely be a nice to have if JSPlaylist could imitate SimPlaylist to some extent while giving the user the option to do so within the JSPlaylist's option panel.
I have to tell you that I made several queries to Marc2k3 when I set up my 64-bit foobar2000. I was testing JsPlaylist to see if I liked the groupings. But I didn't like them and I made several requests and he answered me that the component was an inheritance of Br3tt and that he didn't plan to make improvements. 
Title: Re: JScript Panel script discussion/help
Post by: Azuriye on 2023-11-27 02:00:41
I have to tell you that I made several queries to Marc2k3 when I set up my 64-bit foobar2000. I was testing JsPlaylist to see if I liked the groupings. But I didn't like them and I made several requests and he answered me that the component was an inheritance of Br3tt and that he didn't plan to make improvements. 


Ah fair enough, unfortunately I don't think CUI would be a viable option for me yet due to the issue I've mentioned above but apart from that I guess I'm left with nothing on table...
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-11-27 13:39:41
I'm never going back on the changes I've made to JSPlaylist. If anyone doesn't like it, don't use it. It really is that simple.

And subgroups are never going to happen. Anyone can transplant the jsplaylist folder from the component folder to somewhere else where it will untouched by component upgrades and make their own changes.
Title: Re: JScript Panel script discussion/help
Post by: Azuriye on 2023-12-01 16:47:25
By the way marc2k3, is it possible in JSPlaylist > Colours > Text to separate this header section alone and name it as Highlight? Similar to how foobar2000 has a colour section for Text and Highlight separately in Colors and Font?
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-12-01 19:02:16
By the way marc2k3, is it possible in JSPlaylist > Colours > Text to separate this header section alone and name it as Highlight? Similar to how foobar2000 has a colour section for Text and Highlight separately in Colors and Font?

Try this one. Copy and replace the files into your jsplaylist folder. Mine is on
C:\Users\Username\AppData\Roaming\foobar2000-v2\user-components\foo_jscript_panel3\samples\jsplaylist

(https://i.imgur.com/u83Vnnt.png)
Title: Re: JScript Panel script discussion/help
Post by: Azuriye on 2023-12-02 08:14:52
Try this one. Copy and replace the files into your jsplaylist folder. Mine is on
C:\Users\Username\AppData\Roaming\foobar2000-v2\user-components\foo_jscript_panel3\samples\jsplaylist

(https://i.imgur.com/u83Vnnt.png)


Hey, thanks a lot for sharing your patches! I've also noticed you in the DUI Gallery forum post, but to reconfirm for the JS playlist, are you using FontAwesome? or is it a custom font?
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-12-02 08:17:57
Try this one. Copy and replace the files into your jsplaylist folder. Mine is on
C:\Users\Username\AppData\Roaming\foobar2000-v2\user-components\foo_jscript_panel3\samples\jsplaylist
Hey, thanks a lot for sharing your patches! I've also noticed you in the DUI Gallery forum post, but to reconfirm for the JS playlist, are you using FontAwesome? or is it a custom font?
Yes, it's the default FontAwesome.
Title: Re: JScript Panel script discussion/help
Post by: Azuriye on 2023-12-02 08:20:57
Yes, it's the default FontAwesome.

Thanks for confirming.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-02 10:46:37
Just posting a reminder that any mods to files inside the component folder are wiped out on component updates. I will add this for the next release but if you do mods that aren't going to be included, you really should copy the files elsewhere and update the import paths in the main panel.
Title: Re: JScript Panel script discussion/help
Post by: Azuriye on 2023-12-02 13:15:34
Just posting a reminder that any mods to files inside the component folder are wiped out on component updates. I will add this for the next release but if you do mods that aren't going to be included, you really should copy the files elsewhere and update the import paths in the main panel.

Yeah will keep that in mind thanks.
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-12-03 06:26:03
(https://i.imgur.com/fJP2lds.png)

Suggestion to Marc regarding the JSPlaylist. I made the following minor changes:
- Added custom rating colour
- Adjust mood and rating off colour
- Option to hide visible borders (On selected tracks, Headers and Album art)
- Mood size adapt to single track line mode
- Added a toggle switch for last.fm playcount sync
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-04 09:41:46
I've added highlight and rating to the colours menu in the latest release. I'm not interested in the other options.
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-12-04 23:16:35
I've added highlight and rating to the colours menu in the latest release. I'm not interested in the other options.
No problem, thanks for the update tho!
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2023-12-05 09:06:36
- Added custom rating colour
- Adjust mood and rating off colour
- Option to hide visible borders (On selected tracks, Headers and Album art)
- Mood size adapt to single track line mode
- Added a toggle switch for last.fm playcount sync

Interesting, the theme.

I'm making some changes.

Where can I find the icon set you used?

(https://i.postimg.cc/3dzBTYxS/Screenshot-2023-12-05-100032.png) (https://postimg.cc/3dzBTYxS)
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-12-05 10:01:23
- Added custom rating colour
- Adjust mood and rating off colour
- Option to hide visible borders (On selected tracks, Headers and Album art)
- Mood size adapt to single track line mode
- Added a toggle switch for last.fm playcount sync

Interesting, the theme.

I'm making some changes.

Where can I find the icon set you used?

(https://i.postimg.cc/3dzBTYxS/Screenshot-2023-12-05-100032.png) (https://postimg.cc/3dzBTYxS)

Hi there, it's from the Segoe Fluent Icons font.
Spoiler (click to show/hide)
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2023-12-05 12:53:01
@ eurekagliese

Thank you. I'm studying and implementing the theme.

64 bit:

(https://i.postimg.cc/qhnW1YNg/Screenshot-2023-12-05-134506.png) (https://postimg.cc/qhnW1YNg)

(https://i.postimg.cc/bDqp2kYZ/Screenshot-2023-12-05-134958.png) (https://postimg.cc/bDqp2kYZ)
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-12-07 11:03:14
Hello again, Marc. Is there any plan to add more features to the last.fm bio like fetch the artist's country flag, genre, and additional information like the layout on Wil-B's Biography.

(https://i.imgur.com/zOqkZKv.png)
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-07 13:05:33
It's not likely. I use the lastfm API and that information is not present in the JSON I fetch. I assume that SMP script is scraping the html from the website which I really don't want to do.

edit: and yes I'm a big fat hyprocrite for scraping html to download images but that's because I have no other choice. :P
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-12-07 13:12:07
Understandable. Thank you for your response.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-07 13:14:41
At some point I'll probably integrate text and images in the same panel and have a blurry background so it looks a bit nicer.

If people had file tags with the country, I guess displaying that would be super simple as well but I have no idea what standard people are using for that.
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-12-07 13:47:10
Actually I use the tagger tool in SMP Biography to tag genres from last.fm, and it also fetches the artist's locale.
Spoiler (click to show/hide)

I previously used Grimes' Flag script (which works as intended), but I had to manually provide a nation tag to each artist, which is a time-consuming approach that may not be preferable when we like to discover new artists.
I thought it would be cool if there was a country flag script that would automatically fetch and surprise us with where they originated from.
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-12-08 10:02:52
Last.fm Bio + Image

Nice!

(https://i.imgur.com/cCqxgYp.png)
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-08 11:02:10
Regarding flags, it can be done with the Twitter Color Emoji font.

https://github.com/13rac1/twemoji-color-font/releases

Stock windows fonts don't support it.

I'm not checking now but I guess there must be an easier way to map country codes to the unicode needed.

I just manually tested this for GB...

Code: [Select]
var gb = '\uD83C\uDDEC\uD83C\uDDE7';

edit: a quick google found this...

https://gist.github.com/angusjf/cb53d2adabd072331a5aedb05c86cc54

I'll probably bundle it in the next component release and then you can...

Code: [Select]
// _jsonParseFile is from samples\js\common.js
var flags_json = _jsonParseFile(fb.ComponentPath + "country_flags.json");

then..

Code: [Select]
flags_json['gb'].flag
flags_json['us'].flag

etc
Title: Re: JScript Panel script discussion/help
Post by: regor on 2023-12-08 11:35:21
The gist is missing like 20 countries.

You have a complete table of ISO-3 codes, full name and ISO-2 codes conversion tables on my scripts (https://github.com/regorxxx/World-Map-SMP). Also multiple helpers to handle name variations and capitalization (since Last.fm provides the country name, but not the ISO codes).

I use images for flags, though, which are also there. So if you want to use images, there is no need to reinvent the wheel... for fonts that may be the best option.
Spoiler (click to show/hide)
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-09 09:36:48
I'm not going to use images. I'm currently messing around with a title format function built in to the component. Then they can be inlined in any text anywhere.

I'd probably add a utils.GetCountryFlag method or similar for when JS without title format is required,

Title: Re: JScript Panel script discussion/help
Post by: regor on 2023-12-09 10:03:30
That looks great; on second thought fonts resize much better than images so I may switch and use that + my current conversion tables.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-09 10:10:23
That won't be possible until SMP gets DirectWrite support.
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-12-09 13:08:25
It's good to see it's on its way!
Title: Re: JScript Panel script discussion/help
Post by: Azuriye on 2023-12-10 07:32:33
Hello marc2k3, is it possible to let JScript Panels access this panel in Preferences>Keyboard shortcuts? Some components only expose keyboard shortcuts instead of the traditional way through RunContextCommand. What I'm trying to achieve is when I click a JScript Button it executes the keyboard shortcut context. Either this approach or maybe allowing JScript to send key combinations so that Keyboard shortcuts pick it up and run the command?
Title: Re: JScript Panel script discussion/help
Post by: fbuser on 2023-12-10 15:05:34
Hello marc2k3, is it possible to let JScript Panels access this panel in Preferences>Keyboard shortcuts? Some components only expose keyboard shortcuts instead of the traditional way through RunContextCommand.
This actually not what you can call "the traditional way". It is just the option to execute context menu commands.

As you're screen shot shows a part of the random pools keyboard shortcut section, I guess you are refering to its shortcuts for single pools, for which no menu entry exist. But as you also can see on the screen shot, they are listed under [main] and not [context]. Therefore you need to execute them with RunMainMenuCommands().
Title: Re: JScript Panel script discussion/help
Post by: Azuriye on 2023-12-10 18:58:16
This actually not what you can call "the traditional way". It is just the option to execute context menu commands.
My bad my wording was wrong there.

As you're screen shot shows a part of the random pools keyboard shortcut section, I guess you are refering to its shortcuts for single pools, for which no menu entry exist. But as you also can see on the screen shot, they are listed under [main] and not [context]. Therefore you need to execute them with RunMainMenuCommands().

Thanks a-lot, I had some issues figuring out this but it was a combination of incorrect Pool names, fixing this worked like a charm. Thanks a-lot!
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-12-11 11:40:33
Thanks for the update Marc. Another question, how the country flag code read from multiple value tag like <COUNTRY> Gothenburg; Västra Götaland; Sweden ?
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-11 11:54:59
Title format would be

Code: [Select]
$country_flag($meta(country,$sub($meta_num(country),1)))

JS could be

Code: [Select]
var flag = ''
var handle = fb.GetFocusItem();
if (handle) {
var f = handle.GetFileInfo();
var country = f.MetaFind("country");
if (country > -1) {
var num = f.MetaValueCount(country);
var last_value = f.MetaValue(country, num - 1);
flag = utils.GetCountryFlag(last_value);
}
}

Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-12-11 12:00:56
Thank you for the prompt response!
Spoiler (click to show/hide)
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-12-11 12:44:40
@eurekagliese

Text Display.txt
Custom context...

Could you please upload it?

Thanks.
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-12-11 12:46:23
@eurekagliese

Text Display.txt
Custom context...

Could you please upload it?

Thanks.
Sure, here you go
Code: [Select]
$font(Segoe UI,24)
[%title% ]$crlf()
$font(Segoe UI,14)
[%artist% ] [$font(Twitter Color Emoji,18)$country_flag($meta(country,$sub($meta_num(country),1)))$font() ]$crlf()
[%album% '('%year%')']$crlf()

Make sure to install the Twitter Color Emoji font first
https://github.com/13rac1/twemoji-color-font/releases/download/v14.0.2/TwitterColorEmoji-SVGinOT-14.0.2.zip
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-12-11 12:51:05
Great!
Thanks.

(https://i.imgur.com/fNDjXmd.png)
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2023-12-11 12:55:11
I installed the fonts:

https://github.com/13rac1/twemoji-color-font#examples

but to me only the acronym of the nation appears and not the flag:

(https://i.postimg.cc/7f4qb520/Screenshot-2023-12-11-135109.png) (https://postimg.cc/7f4qb520)
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-12-11 12:56:03
Try to reboot first
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2023-12-11 13:13:43
System reboot was missing. Thank you.

(https://i.postimg.cc/qNRFbrKz/Screenshot-2023-12-11-141046.png) (https://postimg.cc/qNRFbrKz)
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-12 12:45:57
Restarting fb2k is enough to pick up new fonts. A system reboot is far too extreme.
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-12-12 13:34:11
Spoiler (click to show/hide)
@eurekagliese

If you look closely, you can see that "Last.fm Bio + Image" is placed above and below.
It can be used for vertically long or almost square panels.

Could you please share "Last.fm Bio + Image" Script?

I'm sorry for always asking for your help.

Thanks.
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-12-12 13:41:15
Spoiler (click to show/hide)
@eurekagliese

If you look closely, you can see that "Last.fm Bio + Image" is placed above and below.
It can be used for vertically long or almost square panels.

Could you please share "Last.fm Bio + Image" Script?

I'm sorry for always asking for your help.

Thanks.

It's not a problem at all. I'm happy to share.
Here's the code, of course the credit goes to Marc, I just changed tiny bit of it.

Code: [Select]
// ==PREPROCESSOR==
// @name "Last.fm Bio"
// @author "marc2003"
// @import "%fb2k_component_path%helpers.txt"
// @import "%fb2k_component_path%samples\js\lodash.min.js"
// @import "%fb2k_component_path%samples\js\common.js"
// @import "%fb2k_component_path%samples\js\panel.js"
// @import "%fb2k_component_path%samples\js\lastfm.js"
// @import "%fb2k_component_path%samples\js\thumbs.js"
// @import "%fb2k_component_path%samples\js\text.js"
// ==/PREPROCESSOR==

var margin = _scale(12);

var panel = new _panel();
var lastfm = new _lastfm();
var text = new _text('lastfm_bio', 0, 0, 0, 0);
var thumbs = new _thumbs();

text.paint = function (gr) {
var colour = thumbs.blur_img ? RGB(255, 255, 255) : panel.colours.text;
var colourh = thumbs.blur_img ? RGB(255, 255, 255) : panel.colours.highlight;

gr.WriteText(this.header_text(), panel.fonts.title, colourh, this.x, margin, this.w, panel.h - (margin * 2), DWRITE_TEXT_ALIGNMENT_LEADING, DWRITE_PARAGRAPH_ALIGNMENT_CENTER, DWRITE_WORD_WRAPPING_NO_WRAP, DWRITE_TRIMMING_GRANULARITY_CHARACTER);

if (this.text_layout) {
gr.WriteTextLayout(this.text_layout, colour, this.x, this.y + margin, this.w, this.ha, this.offset);
this.up_btn.paint(gr, colour);
this.down_btn.paint(gr, colour);
}
}

thumbs.image_containsxXY = function (x, y) {
return this.images.length && this.containsXY(x, y);
}

thumbs.move = function (x, y) {
this.mx = x;
this.my = y;
return this.containsXY(x, y);
}

thumbs.paint = function (gr) {
if (this.images.length) {
_drawImage(gr, this.blur_img, 0, 0, panel.w, panel.h, image.crop_top);
_drawOverlay(gr, 0, 0, panel.w, panel.h, 120);
this.image_xywh = _drawImage(gr, thumbs.images[thumbs.image], this.x, this.y, this.w, this.h, image.crop_top);
} else {
this.image_xywh = [];
}
}

thumbs.size = function () {}

thumbs.wheel = function (s) {
if (this.containsXY(this.mx, this.my)) {
if (this.images.length > 1) {
this.image -= s;
if (this.image < 0) {
this.image = this.images.length - 1;
}
if (this.image >= this.images.length) {
this.image = 0;
}
window.Repaint();
}
return true;
}
return false;
}

panel.item_focus_change();

function on_colours_changed() {
panel.colours_changed();
window.Repaint();
}

function on_download_file_done(path, success, error_text) {
text.download_file_done(path, success, error_text);
}

function on_font_changed() {
panel.font_changed();
window.Repaint();
}

function on_http_request_done(task_id, success, response_text) {
thumbs.http_request_done(task_id, success, response_text);
}

function on_item_focus_change() {
if (panel.selection.value == 0 && fb.IsPlaying) return;
panel.item_focus_change();
}

function on_key_down(k) {
text.key_down(k);
thumbs.key_down(k);
}

function on_metadb_changed(handles, fromhook) {
if (fromhook) return;
text.metadb_changed();
thumbs.metadb_changed();
}

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

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

function on_mouse_lbtn_dblclk(x, y) {
thumbs.lbtn_dblclk(x, y);
}

function on_mouse_rbtn_up(x, y) {
if (text.containsXY(x, y)) {
return panel.rbtn_up(x, y, text);
}
return panel.rbtn_up(x, y, thumbs);
}

function on_mouse_wheel(s) {
if (thumbs.wheel(s)) return;
text.wheel(s);
}

function on_paint(gr) {
panel.paint(gr);
thumbs.paint(gr);
text.paint(gr);
}

function on_playback_dynamic_info_track(type) {
if (type == 0) {
text.metadb_changed();
thumbs.metadb_changed();
}
}

function on_playback_new_track() {
panel.item_focus_change();
thumbs.playback_new_track();
}

function on_playback_stop(reason) {
if (reason != 2) {
panel.item_focus_change();
}
}

function on_playback_time() {
thumbs.playback_time();
}

function on_playlist_switch() {
on_item_focus_change();
}

function on_size() {
panel.size();
var half = panel.h / 2;

thumbs.x = margin;
thumbs.y = margin;
thumbs.w = panel.w - (margin * 2);
thumbs.h = half - (margin * 2);

text.x = margin;
text.y = half;
text.w = panel.w - margin;
text.h = half;
text.size();
}
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-12 13:50:14
I suppose I could add a toggle or maybe auto detect panel dimensions and use the best fit.

BTW, that mod above is not quite correct. The text touches the right hand side of the panel when it shouldn't.

Inside on_size...

Code: [Select]
text.w = panel.w - margin;

should be

Code: [Select]
text.w = panel.w - (margin * 2);
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-12-12 13:53:41
Thank you for the correction.
Perhaps a toggle would be better there.
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-12-12 13:54:34
That's amazing.
Many Thanks.
---
My head is full of country code.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-12 14:49:57
I'm not doing a component release just now but here are some modded files if anyone wants to test the toggle now.

It also fixes automatic image downloads not working for streams. The original thumbs its based on is fine. It's just this new image/text mod that is borked.

Note that the toggle option is only available when right clicking the image (or where the image should be if none are present). Right clicking the text displays text only options.

Save thumbs.js inside the component folder/samples/js
Use the .txt file inside the panel.
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-12-12 15:23:04
@marc2k3

Thank you for your continued quick work.

(https://i.imgur.com/3Fn06n9.png)

In my case, Image:Text=6:4 is good.
Set the ratio of Image and Text as a percentage, Is it troublesome to be able to change it with Panel Properties?
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2023-12-13 09:56:57
@ erukeagliese

I use your Custom Track 3.0 script

With the jscript-panel 3.3.20 update the script crashes, probably because the samples albumart has been modified.

As soon as you update the script, if you can post it.

Thank you.

Cannot retrieve the 'text_objects' property of a null or undefined reference
File: ....foobar2000\profile\user-components\foo_jscript_panel3\samples\js\albumart.js
Line: 198, Col: 2
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-13 10:05:45
Inside that script, look for

Code: [Select]
var panel = new _panel();

Move it so it's the first line of code.
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-12-13 10:16:10
Inside that script, look for

Code: [Select]
var panel = new _panel();

Move it so it's the first line of code.
Thank you!

@ erukeagliese

I use your Custom Track 3.0 script

With the jscript-panel 3.3.20 update the script crashes, probably because the samples albumart has been modified.

As soon as you update the script, if you can post it.

Thank you.

Cannot retrieve the 'text_objects' property of a null or undefined reference
File: ....foobar2000\profile\user-components\foo_jscript_panel3\samples\js\albumart.js
Line: 198, Col: 2

I've updated the script with some minor improvement.
- Albumart cursor
- Volume knob toggle
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2023-12-13 10:47:22
Inside that script, look for

Code: [Select]
var panel = new _panel();

Move it so it's the first line of code.
Thank you!

@ erukeagliese

I use your Custom Track 3.0 script

With the jscript-panel 3.3.20 update the script crashes, probably because the samples albumart has been modified.

As soon as you update the script, if you can post it.

Thank you.

Cannot retrieve the 'text_objects' property of a null or undefined reference
File: ....foobar2000\profile\user-components\foo_jscript_panel3\samples\js\albumart.js
Line: 198, Col: 2

I've updated the script with some minor improvement.
- Albumart cursor
- Volume knob toggle

A thousand thanks

Great script.

I only changed two lines to have the Clear playlist function instead of Remove Playlist.

(https://i.postimg.cc/n9FgrDV0/Screenshot-2023-12-13-114414.png) (https://postimg.cc/n9FgrDV0)
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-12-15 01:28:43
Hello again, Marc. Is there any plan to add Gradient to DrawEllipse and FillEllipse?
I only see the FillGradientRectangle and FillGradientRectangleAdvanced methods that accept the str object.

Thanks

By the way, regarding the jscript-panel.github.io site, perhaps the built-in search can be better. It seems it's only search the whole word.
When I searched for "Gradient," it simply returned "No matching documents."
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-12-15 07:37:52
@marc2k3

I am always grateful for your help.
Can I add "Thumbs Image Options" to "Last.fm Bio + Image"?

Thumbs Image Option:

Crop (focus on centre)
Crop (focus on top)
Stretch
Centre

Thanks.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-15 09:18:00
I'm deliberately suppressing those options for this script and I don't really want to change it. But you can edit the code at the end of line 48 inside the panel. Change image.crop_top to one of...

Code: [Select]
image.crop
image.centre
image.stretch
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-12-15 11:05:24
> I'm deliberately suppressing those options for this script and I don't really want to change it
Yes, I understand.

> But you can edit the code at the end of line 48 inside the panel. Change image.crop_top to one of...
I'm sorry for saying it was impossible.
Changed to image.centre. feel well.

Thanks.
Title: Re: JScript Panel script discussion/help
Post by: MusicHound on 2023-12-18 00:11:56
JScript Panel 3.3.20 (Custom Track 3.1 by eurekagliese)
JavaScript runtime error
Unable to get property 'colour' of undefined or null reference
File: <main>
Line: 1931, Col: 4


Get this error when I play an album cover with an single color, seems to be the only issue I've found
Title: Re: JScript Panel script discussion/help
Post by: shooting☆star on 2023-12-18 01:12:37
Can I set background color opacity in JSplaylist?

I want to peel off the mask of a beautiful girl in wallpaper.
But I'm ignorant. Could you please save the princess?


Thx!
Title: Re: JScript Panel script discussion/help
Post by: seongbin on 2023-12-18 06:46:43
Thanks for bio scripts!

(https://i.imgur.com/PfXMOIl.png)
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-18 10:03:13
Hello again, Marc. Is there any plan to add more features to the last.fm bio like fetch the artist's country flag, genre, and additional information like the layout on Wil-B's Biography.

I'm in the process of changing my mind on this. A preview...

Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-12-18 10:15:05
I'm looking forward to it.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-18 10:33:21
Here are some files for testing. Save the .js in the component folder\samples\js - the .txt goes in the panel. It's optional and can be turned off via the right click menu. The Twitter Color Emoji font is required for country flags.



Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-12-18 10:45:30
@marc2k3

panel crashes.

samples\js\text.js
Last.fm Bio + Images

JScript Panel 3.3.20 (Last.fm Bio + Images by marc2003)
JavaScript 実行時エラー
'_firstElement' は定義されていません。
File: C:\Users\teamf\Documents\Online Soft 03\foobar2000\foobar2000 DUIK x64 (STANDARD)\foobar2000\profile\user-components-x64\foo_jscript_panel3\samples\js\text.js
Line: 233, Col: 6
Title: Re: JScript Panel script discussion/help
Post by: seongbin on 2023-12-18 11:12:04
@marc2k3

panel crashes.


samples\js\text.js
Last.fm Bio + Images

JScript Panel 3.3.20 (Last.fm Bio + Images by marc2003)
JavaScript 実行時エラー
'_firstElement' は定義されていません。
File: C:\Users\teamf\Documents\Online Soft 03\foobar2000\foobar2000 DUIK x64 (STANDARD)\foobar2000\profile\user-components-x64\foo_jscript_panel3\samples\js\text.js
Line: 233, Col: 6

replace "_firstElement" with "_.isElement" in text.js will fix it
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-18 11:22:15
I forgot this file (save in samples\js folder)
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-12-18 11:28:52
@seongbin

Many Thanks.

> replace "_firstElement" with "_.isElement" in text.js will fix it

_.isElement

Line: 233
Line: 264
Line: 265

(https://i.imgur.com/KCrsPAy.png)
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-12-18 11:33:35
@marc2k3

Could you arrange the three files in Reply #1233 ?
text.js, Last.fm Bio + Images.txt and common.js

Thanks.
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-12-18 11:41:15
Hello again, Marc. Is there any plan to add more features to the last.fm bio like fetch the artist's country flag, genre, and additional information like the layout on Wil-B's Biography.

I'm in the process of changing my mind on this. A preview...

Good to see it's coming. Thank you!

JScript Panel 3.3.20 (Custom Track 3.1 by eurekagliese)
JavaScript runtime error
Unable to get property 'colour' of undefined or null reference
File: <main>
Line: 1931, Col: 4

Get this error when I play an album cover with an single color, seems to be the only issue I've found
Thanks for the feedback, I'll look into it. For now, simply Reload the script whenever you play a song with a better album cover.

PS. Pardon me if the issue from my script is cluttering the thread.
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-12-18 11:42:19
@marc2k3

Flag display

text.js, common.js and Last.fm Bio + Images.txt

(https://i.imgur.com/Cz6zU1e.png)
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-18 13:13:50
Pretty sure that only happens with the original code bundled with the component. If you really apply the .txt I attached, it should be fine. :/

edit: I'm attaching a zip with updated samples. It must be extracted manually into the component samples folder. Do this while fb2k is closed and then you can choose updated samples from the menu in the config window.
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-12-18 13:42:43
Reply #1233 https://hydrogenaud.io/index.php/topic,110516.msg1036525.html#msg1036525
Reply #1230 https://hydrogenaud.io/index.php/topic,110516.msg1036520.html#msg1036520

text.js, common.js and Last.fm Bio + Images.txt.
I tried with these 3 files.
------
Reply #1238
samples
Last.fm Bio + Images.txt

Flag is not displayed.
Title: Re: JScript Panel script discussion/help
Post by: shooting☆star on 2023-12-18 13:50:08
Can I set background color opacity in JSplaylist?

I want to peel off the mask of a beautiful girl in wallpaper.
But I'm ignorant. Could you please save the princess?


Thx!
sorry,
×background color
○selected background color
It was a different sentence...
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-18 13:52:32
Flag is not displayed.

Well it probably comes from applying that garbage fix from seongbin. Yes it was my fault for not attaching a required file in the first place but when you have no idea what the code is inside that function, you can't make stuff up and expect it to work.

It might have prevented the script error but it broke the html parsing. The results are cached so you need to delete those bad files.

To fix:

Close fb2k.
Open Explorer and go to profile folder\js_data. Search for files named lastfm.artist.extra.json and delete them all.

edit: but your screenshot in #1237 showed the font name and correctly extracted flag data. This definitely was because the .txt inside the panel had not been updated. How can anyone make any sense of this drivel. :/
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-12-18 14:57:12
Creating a new Panel and loading Last.fm Bio + Images.txt.

Is there anyone who can successfully display the flag?
Title: Re: JScript Panel script discussion/help
Post by: seongbin on 2023-12-18 17:14:19
@marc2k3
Sorry, my bad carelessly handling it.

And I found that "Korea, Republic of" cannt be parsed as expected, cuz it has one more comma.
For test you can use "The Black Skirts" as artist name.
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-12-19 03:18:09
Creating a new Panel and loading Last.fm Bio + Images.txt.

Is there anyone who can successfully display the flag?

It's working fine here.
I just remove the sample folder from the configuration folder first and then replace it with the extracted files from latest sample.zip provided by Marc above.
Spoiler (click to show/hide)

Perhaps the only visible minor issue is the genre tags Case.
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-12-19 04:28:43
@eurekagliese

Thanks.

> I just remove the sample folder from the configuration folder first and then replace it with the extracted files from latest sample.zip provided by Marc above.

I have it configured that way
I don't think you're doing anything unnecessary.
The tag is %country%, right?

(https://i.imgur.com/Pepxuru.png)

Thanks.
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-12-19 05:24:29
@eurekagliese

Thanks.

> I just remove the sample folder from the configuration folder first and then replace it with the extracted files from latest sample.zip provided by Marc above.

I have it configured that way
I don't think you're doing anything unnecessary.
The tag is %country%, right?
Spoiler (click to show/hide)
Thanks.

No, the latest Last.fm Bio + Images script by marc automatically retrieves the flags. It seems that it scrapes the artist profile from the last.fm site, therefore artists who don't have the "Born in" or "Founded in" won't have their nation flag displayed, unlike the Text Display script which depends on the country tag.
Perhaps, as workaround If the country flag is missing on Bio, loading the flag from tag like on Text Display can be might be used.
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-12-19 05:50:00
No, the latest Last.fm Bio + Images script by marc automatically retrieves the flags. It seems that it scrapes the artist profile from the last.fm site, therefore artists who don't have the "Born in" or "Founded in" won't have their nation flag displayed, unlike the Text Display script which depends on the country tag.
Perhaps, as workaround If the country flag is missing on Bio, loading the flag from tag like on Text Display can be might be used.
@eurekagliese

Yes, I finally understand.
The genres of artists I listen to are mostly Indie and minor.

Thank you very much, that was helpful.

@marc2k3 Sorry for polluting the thread just for me.

Spoiler (click to show/hide)
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-19 09:53:22
I've added title format support for country flags in the bio script. Extract the attached zip to the ROOT of the component folder. You should overwrite all files except the dll which is not bundled here.

The default is $country_flag(%country%) but if you need to edit it, hold Shift + Winkey>right click>Edit properties. Look for 2K3.TEXT.BIO.FLAG.TF.

Country tags always take precedence over what is found online.





Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2023-12-19 10:00:36
Thanks for the update Marc, it's working nicely!

Spoiler (click to show/hide)
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-19 10:08:11
And I found that "Korea, Republic of" cannt be parsed as expected, cuz it has one more comma.
For test you can use "The Black Skirts" as artist name.

Yep the comma really messes things up. But even if it was extracted correctly it would still fail for not matching the contents of this file.

https://jscript-panel.github.io/files/countries.json

kr or Republic Of South Korea are expected.

edit: this attached zip contains a one-off hack for Korea, Republic of. It's ugly but should work.

Cached files need to be removed as per these instructions a few posts ago...

Quote
Open Explorer and go to profile folder\js_data. Search for files named lastfm.artist.extra.json and delete them all.
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-12-19 11:03:58
I apologize for the inconvenience caused by my problem.

Artist not displayed.
I think it's a problem with ().

(G)I-DLE
https://www.last.fm/music/(G)I-DLE?setlang=en

South Korea (kr)

Spoiler (click to show/hide)
Title: Re: JScript Panel script discussion/help
Post by: grimes on 2023-12-19 11:17:19
All of my panels have a text font size of 9, except your JScript Panel 3 Text Display. The minimal font size is 10. Please add 9.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-19 13:38:05
Artist not displayed.
I think it's a problem with ().

A silly typo was the cause of this. Should be fixed in the attached zip.

Also, a bug where the panel didn't respond to country tags being modified has been fixed.

edit: this zip also contains updated track info + seekbar scripts. I finally got around to rounded rectangles which look a bit nicer
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-19 13:53:01
All of my panels have a text font size of 9, except your JScript Panel 3 Text Display. The minimal font size is 10.

That might be true for the default size set via the right click menu but you can use $font title formatting which supports 8 as the minimum value.

https://jscript-panel.github.io/docs/font-rgb/#font
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-12-19 13:59:11
Great!
I'm enjoying JScript Panel 3 now.

Spoiler (click to show/hide)

Thank you for listening to such an ignorant request as mine.
Title: Re: JScript Panel script discussion/help
Post by: grimes on 2023-12-19 14:10:38
That might be true for the default size set via the right click menu but you can use $font title formatting which supports 8 as the minimum value.

https://jscript-panel.github.io/docs/font-rgb/#font
But I can only add $font to the Custom title, not to the text.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-19 14:12:24
So you meant Text Reader and not Text Display? :/
Title: Re: JScript Panel script discussion/help
Post by: grimes on 2023-12-19 14:19:36
Yes, was confused.  :-[
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2023-12-20 04:27:59
@marc2k3

Now Playing 2 (Log) + "Text Reader"

Now Playing 2 (foo_nowplaying2)
https://github.com/foxx1337/foo_nowplaying2/releases

I am using "Now Playing 2 (Log)" + "Text Reader" to display Playback History.
Can I select a History Track and display the Playlist View Context menu?
Then I can use Add to playback queue, Send to playback queue, QSearch, Send to playlist, Run service etc...

Spoiler (click to show/hide)
-----------
My request is to create a 64-bit version of Navigator.

Navigator (foo_navigator) 32bit
https://hydrogenaud.io/index.php/topic,45616.msg819089.html#msg819089

It was the wrong thread. sorry.
Title: Re: JScript Panel script discussion/help
Post by: seongbin on 2023-12-20 08:42:46
For some artist, intead of country flag, it displays 'KR'

(https://i.imgur.com/Q7yJPy3.png)
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-20 10:05:38
At first glance, it seems like a bug with the IDWriteTextLayout windows API I'm using. I'm supposed to be able throw different fonts at different ranges of text in the same string but it seems to break down with those korean characters in it.

I can hack around it by making separate calls for rendering the flag and the artist but then I'm in no better position that I would have been using images. Urgh. :/

Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-20 10:12:18
Can I select a History Track and display the Playlist View Context menu?

Of course not. Artists/titles as strings can't be converted in to recognisable playlist items.

Use Playback Statistics with a recently played autoplaylist. Not tested because I don't have the component installed but something like...

Code: [Select]
%last_played% DURING LAST 1 DAY SORT DESCENDING BY %last_played%
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-20 10:25:19
I can hack around it by making separate calls for rendering the flag and the artist but then I'm in no better position that I would have been using images. Urgh. :/

Here's a quick and dirty workaround. On line 24 of original script. replace

Code: [Select]
	var y = thumbs.properties.layout.value == 0 ? margin : this.y - margin;
DrawStyledText(gr, this.header_text(), panel.fonts.title, colourh, this.x, y, this.w, TM, DWRITE_TEXT_ALIGNMENT_LEADING, DWRITE_PARAGRAPH_ALIGNMENT_CENTER, DWRITE_WORD_WRAPPING_NO_WRAP, DWRITE_TRIMMING_GRANULARITY_CHARACTER);


with

Code: [Select]
	var x = this.x;
var y = thumbs.properties.layout.value == 0 ? margin : this.y - margin;
if (this.twitter_font && this.flag.length) {
var font_size = _scale(panel.fonts.size.value);
var font = CreateFontString('Twitter Color Emoji', font_size);
var width = utils.CalcTextWidth(this.flag + '  ', 'Twitter Color Emoji', font_size);
gr.WriteText(this.flag, font, 0, x, y, width, TM, DWRITE_TEXT_ALIGNMENT_LEADING, DWRITE_PARAGRAPH_ALIGNMENT_CENTER);
x += width
}
gr.WriteText(this.artist, panel.fonts.title, colourh, x, y, this.w, TM, DWRITE_TEXT_ALIGNMENT_LEADING, DWRITE_PARAGRAPH_ALIGNMENT_CENTER, DWRITE_WORD_WRAPPING_NO_WRAP, DWRITE_TRIMMING_GRANULARITY_CHARACTER);
Title: Re: JScript Panel script discussion/help
Post by: seongbin on 2023-12-20 11:24:30
Quote

Code: [Select]
	var x = this.x;
var y = thumbs.properties.layout.value == 0 ? margin : this.y - margin;
if (this.twitter_font && this.flag.length) {
var font_size = _scale(panel.fonts.size.value);
var font = CreateFontString('Twitter Color Emoji', font_size);
var width = utils.CalcTextWidth(this.flag + '  ', 'Twitter Color Emoji', font_size);
gr.WriteText(this.flag, font, 0, x, y, width, TM, DWRITE_TEXT_ALIGNMENT_LEADING, DWRITE_PARAGRAPH_ALIGNMENT_CENTER);
x += width
}
gr.WriteText(this.artist, panel.fonts.title, colourh, x, y, this.w, TM, DWRITE_TEXT_ALIGNMENT_LEADING, DWRITE_PARAGRAPH_ALIGNMENT_CENTER, DWRITE_WORD_WRAPPING_NO_WRAP, DWRITE_TRIMMING_GRANULARITY_CHARACTER);

I m totally fine with this one. Thanks for ur support!
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-20 14:04:15
I've posted an updated component and using a new font (Twemoji Mozilla) is required for the flag display in bio scripts. All existing users will need to update the content in their panels to be sure they're using the latest code.

https://github.com/mozilla/twemoji-colr/releases/tag/v0.7.0

I'm not going to pretend I understand how or why this fixes the Korean text/flag issue. It just does.
Title: Re: JScript Panel script discussion/help
Post by: sveakul on 2023-12-20 18:22:30
Thanks marc2k3 for the new component version!  Works fine here:

1.  Installed the Twemoji Mozilla font, restarted PC
2.  Installed jscript panel 3.3.21
3.  Updated both existing Thumbs and Last.fm Bio panels from the new samples
4.  Restarted Foobar 2.1x64

Flags showing from radio streams when Last.FM entries support them.  Have not needed to use the new "Last.fm Bio + Images" sample for my configuration.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-21 09:09:27
I've said it recently and I'll say it again... there is no need to restart your PC after installing a font. That's bonkers.

If you install a font while fb2k is closed, do nothing. It will be fine when you open it.
If you install a font while fb2k is running, restart the app. That is all.

edit: while you don't "need" the combined bio + images script, it does look better without the splitter...

https://jscript-panel.github.io/gallery/lastfm-bio/#__tabbed_1_2
Title: Re: JScript Panel script discussion/help
Post by: sveakul on 2023-12-22 02:40:29
OK on the icons!  Had just uninstalled the Twitter color emojis so was being overly cautious.

Yes the unified panel does look better.  The one thing I miss is the ability to change the 4 image states from the right-click menu as before, but the manual method you posted for Air KEN works here and I appreciate it.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-22 09:28:22
I've restored the right click options for the next release. It can be tested extracting the contents of the attached zip in to the ROOT of the component folder and updating the panel script from the Samples button.

Title: Re: JScript Panel script discussion/help
Post by: sveakul on 2023-12-22 20:03:25
Thank you!!
Title: Re: JScript Panel script discussion/help
Post by: sveakul on 2023-12-23 19:36:03
I am using the following script by marc2k3 to produce a line-limited text file log of recently played songs.  Is there a way to modify it so that the most recent item appears first on the list instead of last?  Thanks for any help!

Code: [Select]
// ==PREPROCESSOR==
// @name "Playback History"
// @author "marc2003"
// @import "%fb2k_component_path%samples\js\lodash.min.js"
// ==/PREPROCESSOR==

var limit = 70;
var tfo = fb.TitleFormat(" [%artist% - ]%title%");
var path = "C:\\foobar2000\\TrackHistory_v1.txt";

/////////////////////////////////////////////////////////////////////////////////////////////////////////

var last = '';

function on_playback_new_track() {
log_it();
}

function on_playback_dynamic_info_track(type) {
if (type == 0) {
log_it();
}
}

function now_as_string() {
var now = Math.floor(Date.now() / 1000);
return utils.TimestampToDateString(now);
}

function log_it() {
var current = tfo.Eval();
if (current != last) {
last = current;

var text = utils.ReadUTF8(path);
var arr = _(text.trim().split("\r\n"))
.filter(function (item) { return item.length > 0; })
.takeRight(limit - 1)
.value();
arr.push(now_as_string() + " " + current);
utils.WriteTextFile(path, arr.join("\r\n"));
}
}
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-23 19:46:57
Replace the log_it function with this...

Code: [Select]
function log_it() {
var current = tfo.Eval();
if (current != last) {
last = current;

var text = utils.ReadUTF8(path);
var arr = _(text.trim().split("\r\n"))
.filter(function (item) { return item.length > 0; })
.take(limit - 1)
.value();
arr.unshift(now_as_string() + " " + current);
utils.WriteTextFile(path, arr.join("\r\n"));
}
}

It does nothing for existing items. You should start with a new file.
Title: Re: JScript Panel script discussion/help
Post by: sveakul on 2023-12-23 22:27:43
Beautiful, thank you yet again.
Title: Re: JScript Panel script discussion/help
Post by: sveakul on 2023-12-27 07:51:44
Foobar 2.1 x64 and 1.6.17.  Since updating to JScript Panel 3.3.25, and updating from Samples the Last.fm Bio + Images panel:  I've noticed that when no image is available, the bold text for the band name shows the highlight color of my Foobar theme setting, but when a band image is loaded, the color of the band name text returns to white.  I'm not sure if this script version is when it started, but is it default behavior (now)?  See image examples.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-27 08:05:26
That was on purpose since the first version of the combined text+images script. If you want white all the time for consistency, try this:

edit: I use white because when there's an image, I blur it and then a semi-transparent dark overlay is drawn over the top. Using UI colours would be unpredictable and might not always be readable.

edit2: the first attachment wasn't quite right. This updated one should be OK.

edit3: the next version will have support for displaying the stub image from the main album art preferences>Artist. I should have thought of that before.
Title: Re: JScript Panel script discussion/help
Post by: sveakul on 2023-12-28 01:08:53
Thanks for explaining, I just hadn't used that sample long enough obviously.  I do like the background overlay and see why plain white is the best choice there.  Cool on adding the stub image choice to load when no last.fm image exists!
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-28 11:18:26
Here's a test version with support for display the album art>artist stub image from the main preferences when no last.fm images are found.

The attachment need to be extracted to the root of the component folder. This for the combined last.fm bio+images script and the original Thumbs in last.fm mode only.

edit: original attachment removed. See below.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2023-12-28 11:57:21
Here's a new attachment with a bug fix for certain artist images not being found. Urgh. :/

Like the instructions above, this needs to be extracted to the root of the component folder.

Original thumbs users also need to replace the code in their panels. No changes needed for last.fm bio+images users.

Title: Re: JScript Panel script discussion/help
Post by: seongbin on 2024-01-05 07:38:34

I think tab stacks are unrelated to JSP 3, but rather a basic UI element from foobar or a Windows element.

Marc did mention replacing the tabs with a single panel but only for JSP panels on this post, but it was too advance for me.
Spoiler (click to show/hide)


This piece of code really helps!

(https://i.imgur.com/eJnAGSy.png)
Title: Re: JScript Panel script discussion/help
Post by: Jul2323 on 2024-01-05 13:52:29
i made a combine panel in jscript panel 3 of the bio and the thumbs from Marc2K3 of course.

(https://i.imgur.com/2vAaNDL.jpg)

the problem is like this : on right click on the text , you are suppose to have the panel menu of the text ( size and others )
but i have the panel of " reload "
after i click reload then the panel of the text appear on right click
How do i fix that  ? . thanks a lot

 
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2024-01-05 15:16:46
Hi :) @Jul2323

Thanks for your script.
But...

JScript Panel 3.3.27 (Thumbs by marc2003)
JavaScript 実行時エラー
型が一致しません。
File: <main>
Line: 167, Col: 9

Type does not match.

Is it not enough to just panelize JSP3 and load "Bio_Thumbs.txt"?
Title: Re: JScript Panel script discussion/help
Post by: Jul2323 on 2024-01-05 15:34:27
Yes u can . If u can fix also what I write in the previous message .... Very annoying. Thanks ... AirKen
Title: Re: JScript Panel script discussion/help
Post by: Air KEN on 2024-01-05 16:58:07
@Jul2323

JScript Panel 3 Properties > Export > *.wsp file
Could you please upload it?
Title: Re: JScript Panel script discussion/help
Post by: Jul2323 on 2024-01-05 18:33:49
Tomorrow I am at home ... I will send you
Title: Re: JScript Panel script discussion/help
Post by: Azuriye on 2024-01-08 16:26:21
Hello, @marc2k3 I have a small issue when using the on_playback_dynamic_info_track function in conjunction with External Tags or m-TAGS. This issue seems to be reciprocated between both of them and I feel like it might be with the way foobar2k is handling tag editing with streams.

Basically in short, when I click on the m-TAG containing a radio station or if there's any stream metadata update. I request an image to download from the Radio station's API page which also has other related data in the JSON field (for reference: https://gensokyoradio.net/api/station/playing/) issue is when I'm trying to populate these JSON fields using UpdateFileInfoFromJSON function to my m-TAGS file or External Tag file (which supports writing to APE tags/SQLite database) my foobar enters a state of write loop where it briefly pauses the stream, writes then plays then abruptly pauses the stream then write the same value again and so forth...

Any idea if there's a way to circumvent this? I can only think of writing it to another file that way it doesn't causes the write loop but not sure how m-TAGS or External Tag would possibly read from another file apart from the one it's using to play.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-01-09 11:01:29
I'm using fb2k SDK methods for writing tags and I do not believe I can do anything differently. It's robust for local files and I have no interest in how it behaves with intermediary components like m-tags or whatever.
Title: Re: JScript Panel script discussion/help
Post by: lewyturn on 2024-01-10 07:57:17
I would like to ask if it is possible to change the default font "FontAwesome"? What should I do, thanks a lot.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-01-10 09:28:21
It's a requirement for the included samples. If you don't want to use them, write your own.
Title: Re: JScript Panel script discussion/help
Post by: emaulana on 2024-01-10 17:25:08
How to combine $directory_path(%path%)\Cover with $directory_path(%path%)\..\Cover commands in Custom Folder setting of Thumbs Sample?? Please forgive me for this stupid question, i have no knowledge of scripting whatsoever. Thank's in advance for your kindly help.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-01-11 10:53:13
The dialog explains all :/
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-01-11 15:30:03
I will improve the custom folder dialog on the next release. It's still ridiculously easy to follow the current instruction of separating multiple folders with the pipe character | but it can be improved with a multi-line edit box where each folder goes on a new line. That will probably come tomorrow.
Title: Re: JScript Panel script discussion/help
Post by: emaulana on 2024-01-11 15:45:25
Thanks for your reply Marc2k3, i'm really not meticulous for something is already obvious in the dialog Panel :-*  O:) Forgive me if it's bothering you.
If you have time please add custom path also for all music review panel, i save cache files of album review in my Eksternal HDD. Thank you for your very useful Jscript3 component, make my life is easier :D
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-01-11 15:52:21
To move the cache, you can add this as the first line of code in your allmusic panel...

Code: [Select]
folders.artists = "Z:\\path\\to\\artists\\";


Title: Re: JScript Panel script discussion/help
Post by: emaulana on 2024-01-11 16:16:11
Ok, thanks for the information. Let's see if i can make it ;D
Title: Re: JScript Panel script discussion/help
Post by: emaulana on 2024-01-11 16:31:45
Ok, thanks for the information. Let's see if i can make it ;D
FYI, this is my Eksternal HDD directories path, H:\Audio\%ARTIST%\#Artist Bio\Allmusic, so i just put folders.artists = H:\Audio\%ARTIST%\#Artist Bio\Allmusic; at the Code first line ?? Is this correct?
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-01-11 16:48:38
No, you cannot use title formatting there. It must be an absolute path to a base "artists" folder. Per artist folders will be generated inside based on the %album artist%*. The script will automatically handle characters that are illegal in windows folder/filenames like "\/*|:<>?. While possible in title formatting it would be tedious and it's why a utils.ReplaceIllegalChars method exists in the component.

https://jscript-panel.github.io/docs/namespaces/utils/#utilsreplaceillegalcharsstr-modern

* that's specific to allmusic review, other scripts like last.fm bio, similar artists, musicbrainz, thumbs all use $meta(artist,0).

edit: i know scripts like WilB's SMP bio offer more advanced customisation of how to configure folder structure but I'm not goinng down that route. If you don't like how this behaves, don't use it or modify it yourself.
Title: Re: JScript Panel script discussion/help
Post by: emaulana on 2024-01-11 17:19:57
Oh, It’s unfortunate, i've made it with Text Reader and Thumbs panel to access my Artists cache files so i don't have to download it again everytime i play the tracks. :-\ Thanks for your help and response anyway.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-01-12 10:58:33
With the allmusic script, files are only downloaded once. If a cached file is detected, it will display it and will never lookup that artist/album again.

BTW, the most common file size is 2KB with the max in my collection being 6KB. For 1000 albums, that could be 6MB (more likely 2-3MB) and for 10000 albums 20-30MB. I really don't see the point in trying to customise the location.

Other scripts like last.fm bio, musicbrainz etc are different because online content can change so new lookups are performed if the cached data is over 24 hours old.
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2024-01-20 09:39:27
@eurekagliese

I think there are some changes to be made to Custom Track 3.1 after updating to JSP 3.3.30.

Currently rolling back JSP 3 to the previous version.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-01-20 10:00:29
^That might be a component bug I need to fix. There have been internal changes to how Repaint / RepaintRect work and everything seemed fine in my own testing and no one reported issues while the component was in beta for a few days. I can't do anything today but might have a fix tomorrow.
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2024-01-20 10:03:49
Thanks for the update and the quick info.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-01-20 11:07:02
Fixed version posted just now.
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2024-01-20 11:10:20
Thanks for the quick update. That repaint issue seems working fine now.
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2024-01-20 11:39:29
Thanks for the quick update. That repaint issue seems working fine now.

JSP 3.3.31 fixes, ok Custom Track.
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2024-01-21 04:26:42
Reverting to JSP 3.3.29, due to audio stream execution issues, stops and freezes.

Edit: Maybe I have a problem with a disk.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-01-21 10:25:16
It's unlikely changed in the latest version would cause this. Since JSP3 doesn't touch audio it could only prevent fb2k from playing normally by gobbling up all the resources it can and that would be noticeable in windows task manager.
Title: Re: JScript Panel script discussion/help
Post by: Jul2323 on 2024-01-25 09:11:07
Is it possible to create a search field in jscript panel 3 ? Like the picture link ?  Global search . Artist song album ...
https://imgur.com/sJKP8Ex
Thanks you
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-01-25 09:27:25
Possible but not easy. I've never done it and I use utils.InputBox / utils.TextBox popup dialogs instead.

Smooth Browser has a search filter in the top left corner for filtering library items. Also, JSPlaylist has inline edit boxes for customising column title formatting, group headers etc. They will be using the inputbox.js files in their respective folders. I will not be helping with this.

Title: Re: JScript Panel script discussion/help
Post by: Jul2323 on 2024-01-25 11:24:04
Possible but not easy. I've never done it and I use utils.InputBox / utils.TextBox popup dialogs instead.

Smooth Browser has a search filter in the top left corner for filtering library items. Also, JSPlaylist has inline edit boxes for customising column title formatting, group headers etc. They will be using the inputbox.js files in their respective folders. I will not be helping with this.


Thanks you anyway for your support . I appreciate...👍👍👍
Title: Re: JScript Panel script discussion/help
Post by: esa372 on 2024-01-25 22:06:35
Is it possible to display the %date% field in Smooth Browser?
Title: Re: JScript Panel script discussion/help
Post by: seongbin on 2024-01-29 07:55:04
Is it possible to create a search field in jscript panel 3 ? Like the picture link ?  Global search . Artist song album ...
https://imgur.com/sJKP8Ex
Thanks you


I have a mod version of SMOOTH PLAYLIST.
https://github.com/seongbin/Vibe2

Title: Re: JScript Panel script discussion/help
Post by: ms1602 on 2024-01-29 18:47:34
Is it possible to create a search field in jscript panel 3 ? Like the picture link ?  Global search . Artist song album ...
https://imgur.com/sJKP8Ex
Thanks you


I have a mod version of SMOOTH PLAYLIST.
https://github.com/seongbin/Vibe2



It looks very nice. How do I add a new panel to this?
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2024-01-30 09:31:20
3.3.35

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

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

This adds utils.RemoveFolderRecursive and $jsp3_since - a title formatting function for showing the difference between a given date string and now. Can be used playback statistics, last.fm last played dates etc.

edit: attached is an example using $jsp3_since(%lfm_last_played%) from Last.fm Playcount Sync

Woah, thank you very much the newly added function.
Question, where can I change the value? I'd like to change it to something like
0d > Today
1d > Yesterday
3d > 3d ago
7d > Last week
2wk > 2 weeks ago
4wk> Last month
52wk> Last year
104wk > 2 years ago
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-01-30 12:31:09
You can't. It's done in C++.

I was lazy using a built in SDK method which only returns weeks / days. Strictly speaking it also included hours/mins/seconds but I stripped that way.

I've now updated it so weeks/days are omitted for anything over one year like this new screenshot. I'm not breaking it down like your request though. You can do it in pure JS if you like.

Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2024-01-30 14:01:15
Thanks, no wonder I couldn't find it.
Anyway, it appears there is a problem. The last played status will disappear when the music is played for 2/3 or registered/scrobbled, and also the last update seems showing an odd number but will also disappear upon restarting fb2k.
$jsp3_since(%lfm_last_played%)
Spoiler (click to show/hide)

and this one with $jsp3_since(%last_played%)
Spoiler (click to show/hide)
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-01-30 14:09:10
Oops, quite an obvious bug not handling anything less than one day with 0d like the previous version did.

Can you post the actual input for the borked years? I have no idea what's going on there.

Never mind, I see it. Fixed version coming soon.
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2024-01-30 14:15:38
Thanks for the quick reply
Spoiler (click to show/hide)
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2024-01-30 14:40:26
Stopped at 3.3.29

From later versions, in my configuration, I have graphical slowdowns and micro freezes with the spin discs modules running radio streams.

With 3.3.29 no problems in the graphics plugins, with albuart.js, with thumbs.js and no problems with the rotation of the spin disc.

With the same configurations.

Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2024-01-30 15:05:28
edit: pulled both recent releases. I'm utterly stupid. New fix coming soon. /sigh

edit2: here we go again...

3.3.37

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

Thank you, the updated version works well!
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2024-01-30 15:17:06
Stopped at 3.3.29

From later versions, in my configuration, I have graphical slowdowns and micro freezes with the spin discs modules running radio streams.

With 3.3.29 no problems in the graphics plugins, with albuart.js, with thumbs.js and no problems with the rotation of the spin disc.

With the same configurations.

With 3.3.37 there are no graphic slowdowns and spin disc rotation is also ok.

The problem of updating the albumart.js sample remains as per the video I posted previously.

Problem not present with version 3.3.29

Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-01-30 19:28:57
Still can't reproduce. I tried copying your layout with a tab stack and spinning album art nonsense which I hate. I have no idea how anyone can use it for more than 10 seconds before getting sick of it.

FWIW, my pc is pushing 10 years old now. Not exactly cutting edge.

Sorry for the huge file. :/

Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2024-01-31 06:18:15
Still can't reproduce. I tried copying your layout with a tab stack and spinning album art nonsense which I hate. I have no idea how anyone can use it for more than 10 seconds before getting sick of it.

FWIW, my pc is pushing 10 years old now. Not exactly cutting edge.

Sorry for the huge file. :/

De gustibus non est disputandum.

The spin disc has nothing to do with all this.
Just create two tabs in sequence and load the Album Art sample to replicate the problem that doesn't exist on 3.3.29 while it does on 3.3.37.

https://www.youtube.com/watch?v=H_ZkRSuJ_Bk
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2024-01-31 08:13:39
I can confirm @ApacheReal report.
I'm not sure when it happened, but it was minor at first, but has recently gotten more noticeable.
I assumed it was just a file seeking issue, but I think my drive (ssd nvme) is capable of loading those images. I also compressed the images fetched by the latest fm Bio script, which typically result in large file sizes; there is a significant reduction after compression, which I believe will assist load faster, but the problem persist.
Unfortunately, there is no log in the console or with the advanced logging option to identify the issue.

Spoiler (click to show/hide)
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-01-31 09:09:13
So the problem seems isolated to tab switching. Is that right?

Can you put bad code in each panel to make it throw a script error. Does it render the error message on every tab switch?

Just an empty panel with

Code: [Select]
blah();

would do.
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2024-01-31 09:28:08
It occurs three times within 26 seconds.
Spoiler (click to show/hide)
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-01-31 10:13:12
Here's a test version to try...

https://github.com/jscript-panel/jscript-panel.github.io/raw/dev/docs/files/foo_jscript_panel3-3.3.39-dev.fb2k-component

Probably does nothing to fix it.  ;D
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2024-01-31 10:50:43
The latest version fixes the issue.
Thanks again for such a great support!
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2024-01-31 10:58:14
The latest version fixes the issue.
Thanks again for such a great support!

The problem remains has not been resolved with the dev version.
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2024-01-31 11:06:04
@ApacheReal correct, it seems that the problem remains.
I apologise for the hasty report.
Title: Re: JScript Panel script discussion/help
Post by: ApacheReal on 2024-01-31 11:10:03
@ApacheReal correct, it seems that the problem remains.
I apologise for the hasty report.

N.P.

It has also become more accentuated in the sense that the problem occurs when switching between tabs and if the tab has two adjacent samples, the problem occurs in both samples.
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2024-01-31 14:44:13
3.3.39 temporarily reverts recent rendering changes.

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

But this is the last version with:
Edge styles for CUI panels
window.CreateThemeManager / IThemeManager interface
CUI toolbars

The latest version works fine now.
Thanks for the update!
Title: Re: JScript Panel script discussion/help
Post by: vhli on 2024-01-31 16:32:42
I've been searching around for things that can replicate some of the default status bar functionality, because I want some of the information it displays in a place that isn't the bottom of the layout. As far as I can tell, this plugin is really the only thing out there that can possibly do it.

Ideally, I'd like a basic horizontal bar that displays text derived from a string using the official Title Formatting Syntax (https://wiki.hydrogenaud.io/index.php?title=Foobar2000:Title_Formatting_Reference).

If this isn't possible, I'd at least like something that replicates the default status bar's current playback time and (if available) track duration, which is normally provided by this syntax:

Code: [Select]
%playback_time%[ / %length%]

I looked at the samples, but either the simple stuff doesn't have the playback time (e.g. "Text Display"), or it's part of something much more advanced that I had difficulty trimming down without things breaking (e.g. "Track Info + Seekbar + Buttons").
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-01-31 16:57:59
Text Display is simple. It's just a menu and and an edit dialog like any "proper" component. You don't have to edit any script.

After adding to a layout, right click and "Customise text". Replace the existing title formatting with anything you like.

You'll also want to enable "per-second updates" as that is off by default. And check all the other menu options for turning off the art and text alignment/etc.

.
Title: Re: JScript Panel script discussion/help
Post by: vhli on 2024-01-31 17:19:41
Oops. I figured you had to do literally everything through the provided JavaScript, I didn't realize there was a way to set options by right-clicking them and selecting Edit Properties.

Thank you.
Title: Re: JScript Panel script discussion/help
Post by: vhli on 2024-01-31 17:56:38
Alright, I was figuring I could tuck the duration next to the playlist tabs or something (still playing around with the layout) and I notice that it word wraps when I shrink it even when there's still plenty of padding on the left and right sides:

X

(This is within the scratchbox, but it behaves the same after applied too.)
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-01-31 18:19:12
Now you need to edit the script. Right click the panel>Configure. Find this at the end...

Code: [Select]
function on_size() {
panel.size();
text.size();
}

Replace with...

Code: [Select]
function on_size() {
panel.size();
text.size();
text.x = 0;
text.w = panel.w;
if (text.text_layout) text.text_height = text.text_layout.CalcTextHeight(text.w);
}
Title: Re: JScript Panel script discussion/help
Post by: vhli on 2024-01-31 20:04:38
Now you need to edit the script. Right click the panel>Configure. Find this at the end...

Code: [Select]
function on_size() {
panel.size();
text.size();
}

Replace with...

Code: [Select]
function on_size() {
panel.size();
text.size();
text.x = 0;
text.w = panel.w;
if (text.text_layout) text.text_height = text.text_layout.CalcTextHeight(text.w);
}

Thanks, but it doesn't work quite right:

X
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-01-31 20:16:13
Static text touches the edge. Pause playback and see.

Yours is jumping around because the text width is constantly changing causing it to wrap because you're not giving it enough wiggle room.

Title: Re: JScript Panel script discussion/help
Post by: vhli on 2024-01-31 20:47:11
Static text touches the edge. Pause playback and see.

Yours is jumping around because the text width is constantly changing causing it to wrap because you're not giving it enough wiggle room.



Well yeah, that's the issue, it seems like there would be plenty of wiggle room around the text, but it needs more than what you might expect from looking at it.

Here, look:

X
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-01-31 21:04:14
I see the cause now. It will take more effort to resolve it. I might have something later.
Title: Re: JScript Panel script discussion/help
Post by: vhli on 2024-01-31 21:09:03
I see the cause now. It will take more effort to resolve it. I might have something later.
Awesome! I appreciate it.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-01-31 21:18:05
I have a fix now but you have to follow a few steps. The next component will include it but I'm not sure when that will be.

1) Close fb2k.
2) Save this file...

https://raw.githubusercontent.com/jscript-panel/component/main/samples/js/text_display.js

inside your foobar2000 profile folder \ user-components (or user-components-x64) \ foo_jscript_panel3 \ samples \ js and overwrite the existing file.

3) open up fb2k and right click your panel>Configure and restore the original by clicking the samples button>Text Display
4) click OK to close the configuration window and hold the shift+win key together. Now right click the panel>Edit Properties. Set the value of

Code: [Select]
2K3.TEXT.MARGIN

to zero or other small number.
Title: Re: JScript Panel script discussion/help
Post by: vhli on 2024-02-01 02:48:15
I have a fix now but you have to follow a few steps. The next component will include it but I'm not sure when that will be.

1) Close fb2k.
2) Save this file...

https://raw.githubusercontent.com/jscript-panel/component/main/samples/js/text_display.js

inside your foobar2000 profile folder \ user-components (or user-components-x64) \ foo_jscript_panel3 \ samples \ js and overwrite the existing file.

3) open up fb2k and right click your panel>Configure and restore the original by clicking the samples button>Text Display
4) click OK to close the configuration window and hold the shift+win key together. Now right click the panel>Edit Properties. Set the value of

Code: [Select]
2K3.TEXT.MARGIN

to zero or other small number.

That worked, thanks!
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-02-03 12:24:02
Hello again, Marc. Is there any plan to add Gradient to DrawEllipse and FillEllipse?
I only see the FillGradientRectangle and FillGradientRectangleAdvanced methods that accept the str object.

Thanks

By the way, regarding the jscript-panel.github.io site, perhaps the built-in search can be better. It seems it's only search the whole word.
When I searched for "Gradient," it simply returned "No matching documents."

I only just noticed this post from following a link to a post just above it. I think new FillEllipse methods with gradients should be easy enough.

As for docs search, I can't do anything about it. I know nothing about "the web" and I write bare markdown like this...

https://raw.githubusercontent.com/jscript-panel/jscript-panel.github.io/main/docs/docs/interfaces/IJSGraphics.md

And then I use the rather excellent Material for MkDocs package which turns it into lovely formatted html like this...

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

 Any search limitations are part of that.
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2024-02-03 14:19:25
Thanks for the reply.
I was trying to recreate that gradient circle on play button but no luck as the gr.FillEllipse only accept single color. I think I even try masking but also no luck.
Spoiler (click to show/hide)
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-02-03 17:21:44
Having thought about it, I'm probably going to nuke the existing gradient rectangle methods.

FillRectangle will then be updated to continue accepting a solid colour like it does currently but it will also accept a "gradient brush". I can then repeat that on all the Draw/Fill methods.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-02-03 20:38:47
Here's an example:

Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2024-02-16 11:11:02
Is it possible to create a search field in jscript panel 3 ? Like the picture link ?  Global search . Artist song album ...
https://imgur.com/sJKP8Ex
Thanks you


I have a mod version of SMOOTH PLAYLIST.
https://github.com/seongbin/Vibe2


Hi there mate, is there any plan to make that search as stand alone panel script?
DUI and JSPlaylist are really missing out on this.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-02-16 12:37:01
I've fixed it for JSP 3.4.3

Extract files to user profile. Put .txt in your panel.
Title: Re: JScript Panel script discussion/help
Post by: seongbin on 2024-02-24 07:09:32
Hi there mate, is there any plan to make that search as stand alone panel script?
DUI and JSPlaylist are really missing out on this.

I guess thats impossible. What I did is just restoring the feature from Br3tt's original script, thus it only applies to Smooth Playlist View. Best scenario is implmenting it to DUI by peter, maybe in the future.
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2024-02-28 05:56:57
I've fixed it for JSP 3.4.3

Extract files to user profile. Put .txt in your panel.

Thanks for this, I didn't realize we could redirect the import path of the script.

Hi there mate, is there any plan to make that search as stand alone panel script?
DUI and JSPlaylist are really missing out on this.

I guess thats impossible. What I did is just restoring the feature from Br3tt's original script, thus it only applies to Smooth Playlist View. Best scenario is implmenting it to DUI by peter, maybe in the future.

Sorry for the delay in replying and thanks for your response.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-02-28 22:19:39
Here's a simplified Playback Buttons + Playback Order.

Code: [Select]
// ==PREPROCESSOR==
// @name "Playback Buttons + PBO"
// @author "marc2003"
// @import "%fb2k_component_path%helpers.txt"
// @import "%fb2k_component_path%samples\js\lodash.min.js"
// @import "%fb2k_component_path%samples\js\common.js"
// @import "%fb2k_component_path%samples\js\panel.js"
// ==/PREPROCESSOR==

// NOTE: This does not support Shuffle (albums) or Shuffle(folders)

var colours = {
buttons : RGB(255, 255, 255),
background : RGB(30, 30, 30),
contrast : RGB(196, 30, 35),
};

//////////////////////////////////////////////////////////////

var panel = new _panel();
var buttons = new _buttons();
var bs = _scale(24);

if (!chars.shuffle) chars.shuffle = '\ue8b1';
if (!chars.random) chars.random = '\ue897';
var pbo_chars = [chars.repeat_all, chars.repeat_all, chars.repeat_one, chars.random, chars.shuffle];

buttons.update = function () {
var x = ((panel.w - bs * 6) / 2);
var y = Math.round((panel.h - bs) / 2);
this.buttons.stop = new _button(x, y, bs, bs, { char : chars.stop, colour:fb.StopAfterCurrent ? colours.contrast : colours.buttons}, null, function () { fb.Stop(); }, 'Stop');
this.buttons.previous = new _button(x + bs, y, bs, bs, { char : chars.prev, colour:colours.buttons }, null, function () { fb.Prev(); }, 'Previous');
this.buttons.play = new _button(x + (bs * 2), y, bs, bs, { char : !fb.IsPlaying || fb.IsPaused ? chars.play : chars.pause, colour:colours.buttons}, null, function () { fb.PlayOrPause(); }, !fb.IsPlaying || fb.IsPaused ? 'Play' : 'Pause');
this.buttons.next = new _button(x + (bs * 3), y, bs, bs, { char : chars.next, colour:colours.buttons }, null, function () { fb.Next(); }, 'Next');

var pbo = plman.PlaybackOrder;
this.buttons.repeat = new _button(x + (bs * 5) - 2, y - 2, bs + 4, bs + 4, { char : pbo_chars[pbo], colour: pbo == 0 ? setAlpha(colours.buttons, 60) : colours.contrast }, null, function () { pbo >= pbo_chars.length - 1 ? plman.PlaybackOrder = 0 : plman.PlaybackOrder++ }, "Playback Order: " + plman.GetPlaybackOrders().toArray()[pbo]);
}

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

function on_mouse_leave() {
buttons.leave();
}

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

function on_mouse_rbtn_up(x, y) {
if (buttons.buttons.stop.containsXY(x, y)) {
fb.StopAfterCurrent = !fb.StopAfterCurrent;
} else {
var menu = window.CreatePopupMenu();
menu.AppendMenuItem(MF_STRING, 1, 'Configure');

var idx = menu.TrackPopupMenu(x, y);
menu.Dispose();

switch (idx ) {
case 1:
window.ShowConfigure();
break;
}
}

return true;
}

function on_paint(gr) {
gr.Clear(colours.background);
buttons.paint(gr);
}

function on_playback_order_changed() {
buttons.update();
window.Repaint();
}

function on_playback_pause() {
buttons.update();
window.Repaint();
}

function on_playback_starting() {
buttons.update();
window.Repaint();
}

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

function on_playlist_stop_after_current_changed() {
buttons.update();
window.Repaint();
}

function on_size() {
panel.size();
buttons.update();
}

It doesn't support shuffle (albums) or shuffle (folders). It cycles through the first 5 options. Edit the contrast colour if you don't like my default.

Right click the Stop button to toggle Stop After Current. All included button scripts support this.
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2024-03-01 10:18:01
Apparently adding playback buttons and seekbar to Text Display is enough for me :)
(https://i.imgur.com/qzGklJS.jpeg)

Code: [Select]
// ==PREPROCESSOR==
// @name "Text Display with Playback"
// @author "marc2003"
// @import "%fb2k_component_path%helpers.txt"
// @import "%fb2k_component_path%samples\js\lodash.min.js"
// @import "%fb2k_component_path%samples\js\common.js"
// @import "%fb2k_component_path%samples\js\panel.js"
// @import "%fb2k_component_path%samples\js\albumart.js"
// @import "%fb2k_component_path%samples\js\text_display.js"
// @import "%fb2k_component_path%samples\js\seekbar.js"
// ==/PREPROCESSOR==

// https://jscript-panel.github.io/gallery/text-display/

var panel = new _panel({ custom_background : true });
var albumart = new _albumart(0, 0, 0, 0);
var text = new _text_display(LM, 0, 0, 0);

panel.item_focus_change();

//////////////////////////////////////////////////////////////
var colours = {
buttons : RGB(255, 255, 255),
background : RGB(30, 30, 30),
title : RGB(255, 255, 255),
artist : RGB(240, 240, 240),
time : RGB(240, 240, 240),
seekbar_background : setAlpha(RGB(255, 255, 255), 50),
seekbar_progress : setAlpha(RGB(255, 255, 255), 150),
seekbar_knob :  RGB(255, 255, 255),
sac : RGB(196, 30, 35),
};

var tfo = {
artist : fb.TitleFormat('%artist%'),
title : fb.TitleFormat('%title%'),
playback_time : fb.TitleFormat('[%playback_time%]'),
length : fb.TitleFormat('$if2(%length%,LIVE)'),
};

var seekbar = new _seekbar(0, 0, 0, 0);
var buttons = new _buttons();
var button_set_idx = 0;
var fluent_font = 'Segoe Fluent Icons';
var has_font = utils.CheckFont(fluent_font);
var img = null;
var bs = _scale(24);

var normal_font = CreateFontString('Segoe UI', 12);
var bold_font = CreateFontString('Segoe UI', 12, true);

if (has_font) {
button_set_idx = window.GetProperty('2K3.BUTTON.SET', 0);
}

buttons.update = function () {
var y = Math.round((panel.h - bs * 2));
var c = Math.round((panel.w - bs) / 2);
this.buttons.stop = new _button(c - (bs * 2), y, bs, bs, { char : chars.stop, colour:fb.StopAfterCurrent ? colours.sac : colours.buttons}, null, function () { fb.Stop(); }, 'Stop');
this.buttons.previous = new _button(c - (bs), y, bs, bs, { char : chars.prev, colour:colours.buttons }, null, function () { fb.Prev(); }, 'Previous');
this.buttons.play = new _button(c, y, bs, bs, { char : !fb.IsPlaying || fb.IsPaused ? chars.play : chars.pause, colour:colours.buttons}, null, function () { fb.PlayOrPause(); }, !fb.IsPlaying || fb.IsPaused ? 'Play' : 'Pause');
this.buttons.next = new _button(c + (bs), y, bs, bs, { char : chars.next, colour:colours.buttons }, null, function () { fb.Next(); }, 'Next');
this.buttons.queue = new _button(c + (bs * 2), y, bs, bs, { char : '\ue109', colour: colours.buttons}, null, function () {var handleList = plman.GetPlaylistSelectedItems(plman.ActivePlaylist); if (handleList && handleList.Count !== 0) { handleList.RunContextCommand("Add to playback queue");} }, 'Add to playback queue\nRight Click: Flush Queue');
this.buttons.preferences = new _button(c + (bs * 3), y, bs, bs, { char : chars.preferences, colour:colours.buttons}, null, function () { fb.ShowPreferences(); }, 'Preferences');
//this.buttons.console = new _button(panel.w - LM - (bs * 3), y, bs, bs, {char : chars.list, colour:colours.buttons }, null, function () { fb.ShowConsole(); }, 'Console');
//this.buttons.search = new _button(panel.w - LM - (bs * 2), y, bs, bs, { char : chars.search, colour:colours.buttons }, null, function () { fb.RunMainMenuCommand('Library/Search'); }, 'Library Search');

if (button_set_idx == 1) {
this.change_font(fluent_font);
}
}

function on_playback_starting() {
buttons.update();
window.Repaint();
}

function on_playlist_stop_after_current_changed() {
buttons.update();
window.Repaint();
}

function on_mouse_lbtn_down(x, y) {
seekbar.lbtn_down(x, y);
}

function on_playback_seek() {
seekbar.playback_seek();
}

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

//////////////////////////////////////////////////////////////
function on_colours_changed() {
panel.colours_changed();
text.refresh(true);
}

function on_font_changed() {
panel.font_changed();
text.refresh(true);
}

function on_item_focus_change() {
if (panel.selection.value == 0 && fb.IsPlaying) return;
panel.item_focus_change();
}

function on_metadb_changed(handles, fromhook) {
if (!fromhook) {
albumart.metadb_changed();
}
text.metadb_changed();
}

function on_mouse_lbtn_up(x, y) {
text.lbtn_up(x, y);
if (buttons.lbtn_up(x, y)) {
return;
}
if (seekbar.lbtn_up(x, y)) {
return;
}
}

function on_mouse_move(x, y) {
text.move(x, y);
if (buttons.move(x, y)) {
return;
}
seekbar.move(x, y);
}

function on_mouse_rbtn_up(x, y) {
if (buttons.buttons.queue.containsXY(x, y)) {
fb.RunMainMenuCommand('Playback/Flush playback queue');
return true;
}
if (buttons.buttons.stop.containsXY(x, y)) {
fb.StopAfterCurrent = !fb.StopAfterCurrent;
} else {
panel.rbtn_up(x, y, text);
}
return true
}

function on_mouse_wheel(s) {
text.wheel(s);
if (seekbar.wheel(s)) {
return;
}
if (s == 1) {
fb.VolumeUp();
} else {
fb.VolumeDown();
}
}

function on_paint(gr) {
panel.paint(gr);
text.paint(gr);
buttons.paint(gr);

gr.FillRoundedRectangle(seekbar.x, seekbar.y, seekbar.w + _scale(6), seekbar.h, _scale(4), _scale(4), colours.seekbar_background);
if (fb.IsPlaying) {
var pos = seekbar.pos();

gr.WriteText(tfo.playback_time.Eval(), normal_font, colours.time, seekbar.x - _scale(72), panel.h /2 - bs * 0.6, _scale(60), panel.h, DWRITE_TEXT_ALIGNMENT_TRAILING, DWRITE_PARAGRAPH_ALIGNMENT_CENTER);
gr.WriteText(tfo.length.Eval(), normal_font, colours.time, seekbar.x + seekbar.w + _scale(20), panel.h /2 - bs * 0.6, _scale(60), panel.h, DWRITE_TEXT_ALIGNMENT_LEADING, DWRITE_PARAGRAPH_ALIGNMENT_CENTER);

if (fb.PlaybackLength > 0) {
            //progress
            gr.FillRoundedRectangle(seekbar.x, seekbar.y, pos, seekbar.h,  _scale(4), _scale(4), colours.seekbar_progress);
            //knob
gr.FillEllipse(seekbar.x + _scale(3) + seekbar.pos(), seekbar.y + _scale(3), _scale(6), _scale(6), colours.seekbar_knob);
}
}
}

function on_playback_dynamic_info_track(type) {
if (type == 0) text.metadb_changed();
else if (type == 1 && (text.properties.albumart.enabled || text.properties.layout.value > 0)) albumart.metadb_changed();
}

function on_playback_new_track() {
panel.item_focus_change();
}

function on_playback_pause() {
text.refresh();

buttons.update();
window.Repaint();
}

function on_playback_stop(reason) {
if (reason != 2) {
panel.item_focus_change();
}

buttons.update();
window.Repaint();
}

function on_playback_time() {
text.playback_time();
window.RepaintRect(panel.h, 0, seekbar.x - panel.h, panel.h);
}

function on_playlist_items_added() {
text.refresh();
}

function on_playlist_items_removed() {
text.refresh();
}

function on_playlist_items_reordered() {
text.refresh();
}

function on_playlist_switch() {
on_item_focus_change();
}

function on_mouse_lbtn_dblclk(x, y) {
// window.ShowConfigure();
fb.RunMainMenuCommand('View/Show now playing in playlist');
}

function on_size() {
panel.size();
text.size();

seekbar.x = _scale(96);
seekbar.w = panel.w - seekbar.x * 2;
seekbar.h = _scale(6);
seekbar.y = (panel.h - bs * 0.7);
buttons.update();
}
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-03-01 11:21:05
Text overlaps the buttons. I assume you've been super lazy and added a whole bunch of $crlf() instead of editing the javascript. :P
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2024-03-01 12:43:02
$crlf() 4 times, much easier.
As long as it works hehe.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-03-01 16:32:45
So I stole the idea but not your code. The latest JSP3 released just now has it.
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2024-03-01 17:56:17
Thank you for the update, and I'm glad I could contribute an idea.
Title: Re: JScript Panel script discussion/help
Post by: Jul2323 on 2024-03-01 19:33:16
Hi guys . Did Jscript panel 3 can make a drop down menu ? The one with an arrow and multiple choose ? Or something similar ? Thanks ....
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-03-02 13:24:24
If you're talking about the Playlist: Metal in that screenshot above then no. That's a default UI toolbar. :/

Fully custom menus from mouse clicks are possible. Many included samples implement them.
Title: Re: JScript Panel script discussion/help
Post by: Jul2323 on 2024-03-02 15:12:27
If you're talking about the Playlist: Metal in that screenshot above then no. That's a default UI toolbar. :/

Fully custom menus from mouse clicks are possible. Many included samples implement them.
Thanks marc2k3 for your answer....
Title: Re: JScript Panel script discussion/help
Post by: ASopH on 2024-03-02 15:39:00
Hi marc,
is there a simple solution to add additional text into the menu like
new _button(0, 0, 36, 36, { char : chars.edit + 'CUE', colour : colours.buttons } ..

This has not been working since changing the font to Segoe Fluent Icons ..
many thanks for your help  :)
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-03-02 16:28:17
Not tested but I think if you want to revert to FontAwesome, you need to:

1) Copy this in your panel...

Code: [Select]
var fa_chars = {
up : '\uF077',
down : '\uF078',
left : '\uF060',
right : '\uF061',
close : '\uF00D',
rating_on : '\uF005',
rating_off : '\uF006',
heart_on : '\uF004',
heart_off : '\uF08A',
prev : '\uF049',
next : '\uF050',
play : '\uF04B',
pause : '\uF04C',
stop : '\uF04D',
preferences : '\uF013',
search : '\uF002',
console : '\uF120',
info : '\uF05A',
audioscrobbler : '\uF202',
minus : '\uF068',
music : '\uF001',
menu : '\uF0C9',
hourglass : '\uF254',
lock : '\uF023',
list : '\uF0C9',
volume : '\uF028',
};

2) Update each button definition with fa_chars.BLAH

3) After defining your buttons inside buttons.update...

Code: [Select]
this.change_font("FontAwesome");

4) Check the button size. 36x36 doesn't seem big enough.

Title: Re: JScript Panel script discussion/help
Post by: ASopH on 2024-03-02 17:31:33
hi marc,

I've tested:
Code: [Select]
// ==PREPROCESSOR==
// @name "Menu Button"
// @author "marc2003"
// @import "%fb2k_component_path%helpers.txt"
// @import "%fb2k_component_path%samples\js\lodash.min.js"
// @import "%fb2k_component_path%samples\js\common.js"
// @import "%fb2k_component_path%samples\js\panel.js"
// ==/PREPROCESSOR==

var fa_chars = {
up : '\uF077',
down : '\uF078',
left : '\uF060',
right : '\uF061',
close : '\uF00D',
rating_on : '\uF005',
rating_off : '\uF006',
heart_on : '\uF004',
heart_off : '\uF08A',
prev : '\uF049',
next : '\uF050',
play : '\uF04B',
pause : '\uF04C',
stop : '\uF04D',
preferences : '\uF013',
search : '\uF002',
console : '\uF120',
info : '\uF05A',
audioscrobbler : '\uF202',
minus : '\uF068',
music : '\uF001',
menu : '\uF0C9',
hourglass : '\uF254',
lock : '\uF023',
list : '\uF0C9',
volume : '\uF028',
};

var colours = {
buttons : RGB(255, 255, 255),
background : RGB(196, 30, 35)
};

var panel = new _panel();
var buttons = new _buttons();
var bt=40;

buttons.update=function() {
this.buttons.buttons.menu = new _button(0, 0, bt, bt, { char :  fa_chars.menu , colour : colours.buttons }, null, function () { _menu(0, 36); }, 'Menu');
this.buttons.buttons.console= new _button(bt, 0, bt, bt, { char :  fa_chars.console + ' Test', colour : colours.buttons },null, function () { fb.ShowConsole(); }, 'Console Test');
this.change_font("FontAwesome");
}

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

function on_mouse_leave() {
buttons.leave();
}

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

function on_mouse_rbtn_up(x, y) {
if (buttons.buttons.menu.containsXY(x, y)) {
_help(0, 36);
return true;
}
return panel.rbtn_up(x, y);
}

function on_paint(gr) {
gr.Clear(colours.background);
buttons.paint(gr);
}

function on_size() {
panel.size();
}

Result: no button - any ideas - or am I wrong
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-03-02 17:48:57
this.buttons.buttons.BLAH is wrong. Should be this.buttons.BLAH

Also, you need to update the on_size function right at the bottom
Code: [Select]
function on_size() {
panel.size();
buttons.update();
}

And increase the width of any button with text like I said in the previous reply.
Title: Re: JScript Panel script discussion/help
Post by: ASopH on 2024-03-02 18:33:51
Thank you Marc,

you show the blind the way!  ;)
Title: Re: JScript Panel script discussion/help
Post by: Jul2323 on 2024-03-06 08:49:55
When i switch Theme color , i need to stay in the same sort of Layout  , but with a different color .

In ColumnUI / Layout ,  i need to check which layout is active or selected ?  his name , i suppose ?

Example :  switch Layout "Biography"  to Layout "Biography_blue"  . in jscript panel 3 of course . Hope it was clear.



Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-03-06 09:04:46
If each layout has its own colour scheme, using on_colours_changed / window.GetColourCUI will pick it up. The default script inside the panel does that as do most of my own samples/JS Playlist/Smooth samples.
Title: Re: JScript Panel script discussion/help
Post by: Jul2323 on 2024-03-06 10:24:03
If each layout has its own colour scheme, using on_colours_changed / window.GetColourCUI will pick it up. The default script inside the panel does that as do most of my own samples/JS Playlist/Smooth samples.
I can make a color scheme for each layout . Ok
Can you explain how to use on_color_changed ?
Just add this line on the script ? Didn't use it ... Thanks
Title: Re: JScript Panel script discussion/help
Post by: Major_Tom on 2024-03-06 12:39:36
Even without seekbar and buttons the most useful of your samples to me  :)  Thank you Marc !
Title: Re: JScript Panel script discussion/help
Post by: Major_Tom on 2024-03-11 18:50:46
Hi Marc,

I ran into a little problem with your Text Display sample and I can't figure how to solve it.

I tried to put a drop shadow on the text in that I used gr.WriteTextLayout twice with a little offset to the right and down and colour black - that worked perfectly (Pic1) as long as I don't minimize the foobar window. When maximizing the window again, the drop shadow 'loses' the colour and the text is drawn twice in the foreground color (Pic2). I can't figure out how to catch this event to initiate a refresh or any other way to solve this. Maybe you got an idea - thanks.

Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-03-11 19:23:27
I can't really tell what I'm supposed to be looking at in pic1?? :/

But I think I know the cause of the issue in pic2. The default code passes an array of colours (stringified) which the component then parses and applies to the text layout object. These colours are now permanent properties of that layout object until overwritten or the text layout is destroyed. Trying to call gr.WriteTextLayout with a solid colour isn't going to touch that layout object.

Maybe passing this as the colour will work instead...

Code: [Select]
var black = JSON.stringify([{
    Colour: RGB(0, 0, 0),
    Start: 0,
    End: UINT_MAX
}]);
Title: Re: JScript Panel script discussion/help
Post by: Major_Tom on 2024-03-11 19:42:12
I can't really tell what I'm supposed to be looking at in pic1?? :/

Sorry, Pic1 was just there to show how it normally looks like.

Unfortunately, your suggested code didn't have any effect - thanks anyway, it's not a major problem, since I don't minimize the window that often anyway
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-03-11 19:53:52
Just realised there was a typo. Should be Length, not End.

Code: [Select]
var black = JSON.stringify([{
    Colour: RGB(0, 0, 0),
    Start: 0,
    Length: UINT_MAX
}]);

It's doing what I expected it to....

Title: Re: JScript Panel script discussion/help
Post by: Major_Tom on 2024-03-11 20:19:50
Thanks, but that didn't solve the problem for me either - it only works when you put the focus on the Text Display panel before minimizing/maximizing the window. When the focus is on another panel, the colour is gone again  :-\

But thanks to the explanations in your first answer, I managed to solve it by creating a second text layout for the shadow - so no need to dig into this anymore. Thanks a lot for your help!
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-03-12 08:54:37
So I've been messing around with a new menu bar script - mainly for CUI since you can't hide the menu in DUI.

This time I've not been so lazy and made a menu for customising the colours....

(https://i.imgur.com/ugiN5lW.png)
The buttons will always be black or white based on background colour.

It will be in the next component release but it can be tested now by pasting this in a panel...

https://raw.githubusercontent.com/jscript-panel/component/main/samples/Menu%20%2B%20Playback%20Buttons%20%2B%20Custom%20Colours.txt

Requires component version 3.4.7 or later (the release that ditched FontAwesome and uses Segoe Fluent Icons for all buttons)
Title: Re: JScript Panel script discussion/help
Post by: anamorphic on 2024-03-12 19:15:24
Hey marc2k3 or anyone,

I've been modifying the 'Status Bar' sample to show both selection and playlist totals, and one thing I miss from the built-in status bars is the "Starting playback..." message, which appears in between the stopped and playing states. This is mostly only noticeable when playing a stream, since playback starts more or less immediately from local files.

I know there is on_playback_starting callback (not in the original sample), and the on_paint is using if (fb.IsPlaying) {...} else {...}, but I seem to be missing how to get it to write text only in between the two states when starting. I tried the inverse if (!fb.IsPlaying) to see if that catches it which did not work either. Basically just trying to get the var left_text_status to display "Starting..." when the track / stream is loading.

Look, I'm not competent at this stuff. :D

(No doubt something simple I'm missing - below is the mess I have so far but you may have to avert your eyes there, perhaps an update to the original sample to fix this small issue would clue me in? ;) )

Edit: Fixed code that saving a draft on the forum screwed up...

Spoiler (click to show/hide)
Title: Re: JScript Panel script discussion/help
Post by: Jacob91 on 2024-03-12 19:16:15
So I've been messing around with a new menu bar script - mainly for CUI since you can't hide the menu in DUI.

This time I've not been so lazy and made a menu for customising the colours....

(https://i.imgur.com/ugiN5lW.png)
The buttons will always be black or white based on background colour.

It will be in the next component release but it can be tested now by pasting this in a panel...

https://raw.githubusercontent.com/jscript-panel/component/main/samples/Menu%20%2B%20Playback%20Buttons%20%2B%20Custom%20Colours.txt

Requires component version 3.4.7 or later (the release that ditched FontAwesome and uses Segoe Fluent Icons for all buttons)


Interesting. Would it be possible to have an alternative to Text Display with the menu and Playback buttons placed in this way ?
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-03-13 09:48:47
Updated status bar: https://raw.githubusercontent.com/jscript-panel/component/main/samples/Status%20Bar.txt

And nope, I'm not making any more changes to Text Display. Most of my scripts are flexible with regards to positioning/dimensions. This is not so easy and I can't be bothered.
Title: Re: JScript Panel script discussion/help
Post by: Defender on 2024-03-13 10:58:30
How can I check if a certain pattern is in a string?

For instance:
var str = 'Speakers some more text [exclusive]'

How to check that the var str contains 'Speakers ' and/or contains ' [exclusive]'?
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-03-13 13:11:05
This Status Bar script has been updated: https://raw.githubusercontent.com/jscript-panel/component/main/samples/Status%20Bar.txt

You can now set title formatting via the right click menu and $rgb is supported.
Title: Re: JScript Panel script discussion/help
Post by: Jacob91 on 2024-03-13 15:59:03
Hi,
Is it possible to move the image (Cover Art) a little lower, by a few pixels?

X
Title: Re: JScript Panel script discussion/help
Post by: Major_Tom on 2024-03-13 16:20:31
Search this line in text_display.js

_drawImage(gr, albumart.img, albumart.x, albumart.y, albumart.w, albumart.h, image.centre);

add the number of pixels to albumart.y (e.g. + 5) and save the file, but remember, that with every update the file will get overwritten, so better save it somewhere else and replace the path in the config window with your new path (or change the file after every update, that's up to you)

Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-03-13 16:27:40
Must be modded?? Margins are like this with the original script at 150%.

(https://i.imgur.com/4fOKjok.png)

No amount of panel resizing can get the image closer to the edges.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-03-13 18:42:38
Yet another Status Bar update: https://raw.githubusercontent.com/jscript-panel/component/main/samples/Status%20Bar.txt

This fixes actual bugz. Ever since the first version, it didn't support the font size being changed so any manual change or DPI increase would have chopped it off. Sorry about that.

Now that it can take up the panel height, multi-line with wrapping is now possible. Use $crlf() in your title formatting.
Title: Re: JScript Panel script discussion/help
Post by: anamorphic on 2024-03-13 21:13:48
^ I never would've figured that out myself. It'll take me some time to integrate the new changes, so I'll just assume it goes smoothly and say thanks now. Thanks :)
Title: Re: JScript Panel script discussion/help
Post by: Jacob91 on 2024-03-13 23:12:38
Search this line in text_display.js

_drawImage(gr, albumart.img, albumart.x, albumart.y, albumart.w, albumart.h, image.centre);

add the number of pixels to albumart.y (e.g. + 5) and save the file, but remember, that with every update the file will get overwritten, so better save it somewhere else and replace the path in the config window with your new path (or change the file after every update, that's up to you)



Thanks. I'll try It.
Title: Re: JScript Panel script discussion/help
Post by: Jul2323 on 2024-03-14 10:27:42
Nice one Marc2k3... I will try it too....
Title: Re: JScript Panel script discussion/help
Post by: Jacob91 on 2024-03-14 20:12:28
Hi,

I would like to use icons of the font 'Material Icons Round Regular'. How to do it ?

I tried, to use '\uE03D' with char_set[button_set_idx].playlist :

Spoiler (click to show/hide)

But it does not work. :(  :(

X
Title: Re: JScript Panel script discussion/help
Post by: Major_Tom on 2024-03-15 07:38:06

I would like to use icons of the font 'Material Icons Round Regular'. How to do it ?


I think, the font is just called 'Material Icons Round' without 'Regular', at least, that's what it's called here in my system
Title: Re: JScript Panel script discussion/help
Post by: Jacob91 on 2024-03-15 12:04:37

I would like to use icons of the font 'Material Icons Round Regular'. How to do it ?


I think, the font is just called 'Material Icons Round' without 'Regular', at least, that's what it's called here in my system

I tried, but It doesn't work.
Title: Re: JScript Panel script discussion/help
Post by: Major_Tom on 2024-03-15 14:53:53
I tried, but It doesn't work.
[/quote]

A little hard to tell you why without the corresponding code - you just defined some variables...
Title: Re: JScript Panel script discussion/help
Post by: Jacob91 on 2024-03-15 16:32:46
I tried, but It doesn't work.

A little hard to tell you why without the corresponding code - you just defined some variables...
[/quote]

Spoiler (click to show/hide)

Then I use rg_plchars to display the button :
Code: [Select]
	bpos = btot - 4;		this.buttons.plmanager	= new _button(x + (bs * bpos), y, bs, bs, { char : rg_plchars, colour:colours.white}, null, function () { fb.RunMainMenuCommand('View/Playlist Manager'); }, 'PL Manager');

C'est ce que je veux afficher :

X
Title: Re: JScript Panel script discussion/help
Post by: Major_Tom on 2024-03-15 17:26:11
Supposing your standard font is Segoe Fluent Icons, why not just put this line into your code and forget about the rest:

this.buttons.plmanager   = new _button(x + (bs * bpos), y, bs, bs, { char : '\ue90b', colour:colours.white}, null, function () { fb.RunMainMenuCommand('View/Playlist Manager'); }, 'PL Manager');

Title: Re: JScript Panel script discussion/help
Post by: Defender on 2024-03-15 17:30:51
I tried, but It doesn't work.

A little hard to tell you why without the corresponding code - you just defined some variables...

Spoiler (click to show/hide)

Then I use rg_plchars to display the button :
Code: [Select]
	bpos = btot - 4;		this.buttons.plmanager	= new _button(x + (bs * bpos), y, bs, bs, { char : rg_plchars, colour:colours.white}, null, function () { fb.RunMainMenuCommand('View/Playlist Manager'); }, 'PL Manager');

C'est ce que je veux afficher :

X
[/quote]

Like this?

RDIT: Try the attached script
Title: Re: JScript Panel script discussion/help
Post by: Major_Tom on 2024-03-15 17:43:56
That's the output of the code you provided - wouldn't look any different with Material Font

You will have to alter the size of the button by adjusting the second bs value:

   this.buttons.plmanager   = new _button(x + (bs * bpos), y, bs, bs + 5...

or whatever value suits your needs

Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-03-15 18:00:22
homer backing in to a hedge.gif
Title: Re: JScript Panel script discussion/help
Post by: Jacob91 on 2024-03-16 07:28:06
Supposing your standard font is Segoe Fluent Icons, why not just put this line into your code and forget about the rest:

this.buttons.plmanager   = new _button(x + (bs * bpos), y, bs, bs, { char : '\ue90b', colour:colours.white}, null, function () { fb.RunMainMenuCommand('View/Playlist Manager'); }, 'PL Manager');


Supposing your standard font is Segoe Fluent Icons, why not just put this line into your code and forget about the rest:

this.buttons.plmanager   = new _button(x + (bs * bpos), y, bs, bs, { char : '\ue90b', colour:colours.white}, null, function () { fb.RunMainMenuCommand('View/Playlist Manager'); }, 'PL Manager');



Thanks for your help.
But if I want to use "Material Icons" for '\ue90b'. What should I write before ?
Title: Re: JScript Panel script discussion/help
Post by: Jacob91 on 2024-03-16 07:30:45
That's the output of the code you provided - wouldn't look any different with Material Font

You will have to alter the size of the button by adjusting the second bs value:

   this.buttons.plmanager   = new _button(x + (bs * bpos), y, bs, bs + 5...

or whatever value suits your needs
👍
Title: Re: JScript Panel script discussion/help
Post by: Jacob91 on 2024-03-16 08:01:26
I tried, but It doesn't work.
A little hard to tell you why without the corresponding code - you just defined some variables...
[attach type=image]29696[/attach]

Like this?

RDIT: Try the attached script
[/quote]

It works perfectly. Thanks. 👍👍
The _button_mir function allows, among other things, to assign the "Material Icons Round" font to the plmanager button. 👍
Title: Re: JScript Panel script discussion/help
Post by: Defender on 2024-03-16 11:45:14
I tried, but It doesn't work.
A little hard to tell you why without the corresponding code - you just defined some variables...
[attach type=image]29696[/attach]

Like this?

RDIT: Try the attached script

It works perfectly. Thanks. 👍👍
The _button_mir function allows, among other things, to assign the "Material Icons Round" font to the plmanager button. 👍
[/quote]

Good!

Modifications were a bit sloppy so I've updated the script to make it more generic.

I dropped the '_button_mir' function and created a more generic function '_button_mod' that accepts an optional fontname (default Segoe Fluent Icons) and optional fontsize offset (defaults to 10). Basically you can any font for buttons you like.
All buttons use the same function now. And as a result the RG button is slightly larger and more in line with the other buttons.
I also implemented the last changes from the standard script so the seekbar aligns nicely.

Have a look ...

EDIT: Some last oops additions - Use script v7a
Title: Re: JScript Panel script discussion/help
Post by: Jacob91 on 2024-03-17 11:50:43
Quote
Modifications were a bit sloppy so I've updated the script to make it more generic.

I dropped the '_button_mir' function and created a more generic function '_button_mod' that accepts an optional fontname (default Segoe Fluent Icons) and optional fontsize offset (defaults to 10). Basically you can any font for buttons you like.
All buttons use the same function now. And as a result the RG button is slightly larger and more in line with the other buttons.
I also implemented the last changes from the standard script so the seekbar aligns nicely.

Have a look ...

EDIT: Some last oops additions - Use script v7a

Works perfectly. 👍👍 I've added somme buttons.
With _button_mod function, you can easily add what you want as char, in any font. 👍👍.Thanks a lot.

X
Title: Re: JScript Panel script discussion/help
Post by: Jacob91 on 2024-03-19 18:42:02
X

When there is no image display (this certainly concerns albumart.js), would it be possible to indicate this absence with an image, for example :

X
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-03-19 18:53:22
File>Preferences>Display>Album Art>Artist tab>Stub image.

edit: That was for the original album art script. Text display only supports Front so configure the stub image under that tab.
Title: Re: JScript Panel script discussion/help
Post by: Defender on 2024-03-19 19:52:52
File>Preferences>Display>Album Art>Artist tab>Stub image.

edit: That was for the original album art script. Text display only supports Front so configure the stub image under that tab.

The following question is NOT about the modified Text Display + Album Art + Seekbar + Buttons.txt, but rather about the standard Album Art.txt where mousewheel is supported.

Since there is no way to enter a stub image for Icon can you please reconsider making a stub available for icon in your settings (something like 2K3.ARTREADER.ICON.STUB)?

NB. I was able to skip Icon on mousewheel altogether by adding one line to _albumart, but I rather have a decent solution since in rare cases there actually is an icon image added to the audiofile.
Title: Re: JScript Panel script discussion/help
Post by: Jacob91 on 2024-03-22 12:26:43
File>Preferences>Display>Album Art>Artist tab>Stub image.

edit: That was for the original album art script. Text display only supports Front so configure the stub image under that tab.

Is it possible to take into account the absence of certain images in albumart.js? (back.jpg, cd.jpg, artist.jpg, etc.)
Title: Re: JScript Panel script discussion/help
Post by: Azuriye on 2024-03-23 12:23:53
@marc2k3 Following up from the External Tags post I decided to rework on the whole loading images from a radio station into memory

I've reached till this part

Code: [Select]
function on_download_image_done(url, image) {
if (!image) return;
// Do something here to update cover art
}

but I'm not sure how to call on_paint(gr) inside of on_download_image_done assuming that's the function responsible for updating the cover art? or how do I update the Album Art sample with a downloaded image?
Title: Re: JScript Panel script discussion/help
Post by: Defender on 2024-03-23 14:08:54
@marck2k3

Related questions.

Album Art shows the Artist picture just fine playing a normal non streaming file probably using part this part of Preferences - Display - Artist:
C:\Users\User\AppData\Roaming\foobar2000-v2\yttm\art_img\$substr(%artist%,1,1)\%artist%\*.*

While streaming however the artist image is not retrieved/displayed, instead it displays the stub image.

When the artist changes in a stream the following code does update the cover and also changes the textdisplay just fine, but does not do the artist pic.

function on_metadb_changed(handles, fromhook) {
   if (!fromhook) {
      albumart.metadb_changed();
   }
   text.metadb_changed();
}

Can the script be changed so that it retrieves/displays the artist pic as well on realtime stream/artist change?

I like to display the streaming cover as well in my own code.
What is the realtime streaming tag that contains the url to the cover art? I can't find it in your Properties + Other Info.txt or in the standard Item properties which both only show the non-realtime tags?
Title: Re: JScript Panel script discussion/help
Post by: Azuriye on 2024-03-23 21:03:33
@marc2k3 Following up from the External Tags post I decided to rework on the whole loading images from a radio station into memory

I've reached till this part

Code: [Select]
function on_download_image_done(url, image) {
if (!image) return;
// Do something here to update cover art
}

but I'm not sure how to call on_paint(gr) inside of on_download_image_done assuming that's the function responsible for updating the cover art? or how do I update the Album Art sample with a downloaded image?

Okay I guess this a bad approach, loading images in memory starts to break viewing the image using ShowAlbumArtViewer. Basically I need to manually patch up the image for my playlist and album panel and it would be much better to just download the image file and let m-TAGS/External Tags do the job of attaching the front cover art
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-03-24 01:05:25
If those components support attaching images via the normal properties dialog or tagging context menu, it should be transparent to 3rd party components using the same SDK methods. This can attach images but they have to be on disk so you'd have to save with utils.DownloadFileAsync first.

https://jscript-panel.github.io/docs/namespaces/utils/#utilsdownloadfileasyncwindow_id-url-path

https://jscript-panel.github.io/docs/interfaces/IMetadbHandleList/#attachimageimage_path-art_id
Title: Re: JScript Panel script discussion/help
Post by: Azuriye on 2024-03-24 09:06:21
If those components support attaching images via the normal properties dialog or tagging context menu, it should be transparent to 3rd party components using the same SDK methods. This can attach images but they have to be on disk so you'd have to save with utils.DownloadFileAsync first.

https://jscript-panel.github.io/docs/namespaces/utils/#utilsdownloadfileasyncwindow_id-url-path

https://jscript-panel.github.io/docs/interfaces/IMetadbHandleList/#attachimageimage_path-art_id

That's currently how I was originally using but was under the assumption that downloading it in through the memory would be a much better approach until I tried it... so far utils.DownloadFileAsync does the job.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-03-24 09:59:33
I suppose attaching from memory could be done but it wouldn't take in to account the original format. I would have to encode as jpg or maybe webp.
Title: Re: JScript Panel script discussion/help
Post by: Dojando on 2024-03-26 03:17:47
Hey,
I can not get the spectrum seekbar to work. I can seek and click on it but it does not show the spectrum of the song.
Can someone help me to get this to work? :)

I assume it has something to do with ffmpeg but I have no idea how to install this too.

Thanks for any help ♥

Title: Re: JScript Panel script discussion/help
Post by: sveakul on 2024-03-26 05:19:49
Yes you might say that.  Check here for the whole deal:
https://jscript-panel.github.io/gallery/spectrogram-seekbar/ (https://jscript-panel.github.io/gallery/spectrogram-seekbar/)
Title: Re: JScript Panel script discussion/help
Post by: Dojando on 2024-03-26 15:13:51
Yes you might say that.  Check here for the whole deal:
https://jscript-panel.github.io/gallery/spectrogram-seekbar/ (https://jscript-panel.github.io/gallery/spectrogram-seekbar/)
ah amazing, I did not see it when I was getting Jscrip. Gonna check it out :)  Thanks! ♥
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-03-26 15:19:43
I did all I could.  :/

Title: Re: JScript Panel script discussion/help
Post by: sveakul on 2024-03-27 16:24:48
Yes you might say that.  Check here for the whole deal:
https://jscript-panel.github.io/gallery/spectrogram-seekbar/ (https://jscript-panel.github.io/gallery/spectrogram-seekbar/)
ah amazing, I did not see it when I was getting Jscrip. Gonna check it out :)  Thanks! ♥

marc2k3's spectrogram doesn't need SoX, it goes right to ffmpeg.  FAST.  You can tell it to generate a lossless png for the image by adding an extension in the "FFmpeg showspectrumpic options" like in the screenshot.  If you would prefer that the image cache be cleared automatically upon Foobar close, add these lines supplied by him to the very end of the "configure" script:
Code: [Select]
function on_script_unload() {
utils.ListFiles(spectrogram_cache).toArray().forEach(function (item) {
utils.RemovePath(item);
});
}
Title: Re: JScript Panel script discussion/help
Post by: MaFred on 2024-03-29 16:19:29
Changed the front cover in a FLAC file. However, the old cover is still displayed in the Smooth playlist. How do I get the playlist to re-read the title?
Thank you!
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-03-29 17:43:59
The solution is not very elegant. Close fb2k and browse your profile folder.

You can either delete the entire js_smooth_cache folder and this means all thumbnails will be generated again from scratch.

OR

Browse inside the folder and enable the extra large icons view in Explorer. Find and delete the offending files manually.
Title: Re: JScript Panel script discussion/help
Post by: Defender on 2024-04-02 10:44:03
Hi,

I created some keyboard shortcuts 1) Randomize current selection 2) Queue (selected) files 3) Kill the queue. Works fine.

However I would this functionality in buttons.

The randomize button I created works fine with fb.RunMainMenuCommand('Edit/Selection/Sort/Randomize');

The queue button does not work. There is no main menu command to queue so I tried fb.RunContextCommand('Add to playback queue'); but this only adds a track within the selected tracks to the queue if it is playing.

How can I change this code so that all files in the selection are added to the queue?
Title: Re: JScript Panel script discussion/help
Post by: eurekagliese on 2024-04-02 11:35:36
Hi,

I created some keyboard shortcuts 1) Randomize current selection 2) Queue (selected) files 3) Kill the queue. Works fine.

However I would this functionality in buttons.

The randomize button I created works fine with fb.RunMainMenuCommand('Edit/Selection/Sort/Randomize');

The queue button does not work. There is no main menu command to queue so I tried fb.RunContextCommand('Add to playback queue'); but this only adds a track within the selected tracks to the queue if it is playing.

How can I change this code so that all files in the selection are added to the queue?

I just use this for my queue button.
Code: [Select]
	this.buttons.queue = new _button(x + (bs * 5), y, bs, bs, { char : '\ue109', colour: colours.white}, null, function () {		
var handleList = plman.GetPlaylistSelectedItems(plman.ActivePlaylist);
if (handleList && handleList.Count !== 0) {
handleList.RunContextCommand("Add to playback queue");
}
}, 'Add to playback queue');
Title: Re: JScript Panel script discussion/help
Post by: Defender on 2024-04-02 14:46:25
I just use this for my queue button.
Code: [Select]
	this.buttons.queue = new _button(x + (bs * 5), y, bs, bs, { char : '\ue109', colour: colours.white}, null, function () {		
var handleList = plman.GetPlaylistSelectedItems(plman.ActivePlaylist);
if (handleList && handleList.Count !== 0) {
handleList.RunContextCommand("Add to playback queue");
}
}, 'Add to playback queue');

Thank you! Works very well.

I added rightmouse functionality for the button to remove queued items from selection but that is not really straightforward. If there is one item in the selection that is not queued the command will fail therefore I first had to add it to the queue before removing it.

Code: [Select]
	if (buttons.buttons.queue.containsXY(x, y)) {
var handleList = plman.GetPlaylistSelectedItems(plman.ActivePlaylist);
if (handleList && handleList.Count !== 0) {
handleList.RunContextCommand("Add to playback queue");
handleList.RunContextCommand("Remove from playback queue");
}
return true;
}

In the end I want to add rightmouse functionality to the Randomize selection button, so that it starts playing the first track of the selection after randomizing that selection. I would prefer to set focus to the first element of the selection after randomizing that selection and start playing that element, but I don't know how to set the focus to the first element of the selection.

I tried plman.SetPlaylistFocusItem(plman.ActivePlaylist, 0) but that sets the focus to the first element of the whole playlist.
What variable should be used instead of the 0 to set focus to the first item of the selection?
Also I do not know how to issue a play command that starts playing the focused item. fb.Play() just starts playing the song that is already playing or where playback stopped last time.

So now I use a rather stupid workaround. First I make a handlelist for the whole playlist. Then I add all items to the queue and delete all items (to clear the queue. Is there a better way?). Then I create a handlelist for current selection and add all items to the queue. And finally I issue a fb.Next() command to start playing the first (queued) item), which is the first rack of the selection after it was randomized.

Code: [Select]
		var handleList = plman.GetPlaylistItems(plman.ActivePlaylist)
if (handleList && handleList.Count !== 0) {
handleList.RunContextCommand("Add to playback queue");
handleList.RunContextCommand("Remove from playback queue");
}

fb.RunMainMenuCommand('Edit/Selection/Sort/Randomize');

var handleList = plman.GetPlaylistSelectedItems(plman.ActivePlaylist);
if (handleList && handleList.Count !== 0) {
handleList.RunContextCommand("Add to playback queue");
}

fb.Next();

It works and solves the ordering issue I encountered by creating functionality for on-the-fly "compilation" folders, but I wonder if there's not a better way to it.
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-04-03 15:02:21
Not really sure what you're doing but this removes all queue items.

Code: [Select]
fb.RunMainMenuCommand("Playback/Flush playback queue");

If you want to randomise handles for adding to the queue, you don't have to modify any playlist

Code: [Select]
var items = plman.GetPlaylistSelectedItems(plman.ActivePlaylist);
items.Randomise();
items.RunContextCommand("Add to playback queue");

Randomise and other handle list methods are documented here...

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

If you want to find the first selected item in a playlist.

Code: [Select]
function first_selected_item(playlistIndex) {
var count = plman.GetPlaylistItemCount(playlistIndex);
for (var i = 0; i < count; i++) {
if (plman.IsPlaylistItemSelected(playlistIndex, i)) {
return i;
}
}
return -1;
}

Always check the return value is not -1.

Title: Re: JScript Panel script discussion/help
Post by: Defender on 2024-04-03 16:47:54
Code: [Select]
fb.RunMainMenuCommand("Playback/Flush playback queue");
Right! Make note to self not to use a space before and after the slash.

I use the code you sent, got it working and ended up with:
Code: [Select]
fb.RunMainMenuCommand("Playback/Flush playback queue");
fb.RunMainMenuCommand("Edit/Selection/Sort/Randomize") // Randomizes selection and displays selection in new order

var items = plman.GetPlaylistSelectedItems(plman.ActivePlaylist);
// items.Randomise(); // Randomizes selection but does not display selection in new order
items.RunContextCommand("Add to playback queue");

fb.Next();

I also managed to find and select the first item in the (randomised) selection
Code: [Select]
var sel_first = first_selected_item(plman.ActivePlaylist);
if ( sel_first > -1 ) {
plman.SetPlaylistFocusItem(plman.ActivePlaylist, sel_first);
}

I actually don't want to queue anything. So ideally I would just like to randomize the selection by using the Edit/Selection/Sort/Randomize command which also changes the order in the display like I want it. Then change the focus to the first item in the selection. And then play that item.
When I issue fb.Play however it just restarts the currently playing track and when I issue fb.Next foobar plays the next item below the currently playing file.

Is there a play command available to start playing the focused item?
Title: Re: JScript Panel script discussion/help
Post by: Defender on 2024-04-03 17:08:04
I created rightclick functionality to my Add to queue button. It is supposed to clear any queued item from the current selection.

Code: [Select]
var items = plman.GetPlaylistSelectedItems(plman.ActivePlaylist);
items.RunContextCommand("Add to playback queue");
items.RunContextCommand("Remove from playback queue");

Works fine, but a bit weird first have to add all selected items to the queue, but otherwise the Remove command won't work for any of the items in the selection.
(Not any different from the context menu for Remove not being available if one of the items in the selection is not queued).

I read your documentation. In last post you pointed out plman.IsPlaylistItemSelected(playlistIndex, i).

Is there a similar plman.IsPlaylistItemQueued(playlistIndex, i) ?
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-04-03 17:40:09
I removed all advanced queue management stuff in JSP3. It exists in JSP2 and SMP.

However, you can get queued items in a dirty way by using title formatting...

Code: [Select]
var tfo = fb.TitleFormat("[%queue_index%]");

function get_queued_items(playlistIndex) {
var items = plman.GetPlaylistItems(playlistIndex);
var queued_items = fb.CreateHandleList();

for (var i = 0; i < items.Count; i++) {
if (tfo.EvalPlaylistItem(playlistIndex, i).length) {
queued_items.AddItem(items.GetItem(i));
}
}

return queued_items;
}

var queued_items = get_queued_items(plman.ActivePlaylist);

As for playing a given item, use this...

https://jscript-panel.github.io/docs/namespaces/plman/#plmanexecuteplaylistdefaultactionplaylistindex-playlistitemindex
Title: Re: JScript Panel script discussion/help
Post by: Defender on 2024-04-03 20:08:28
https://jscript-panel.github.io/docs/namespaces/plman/#plmanexecuteplaylistdefaultactionplaylistindex-playlistitemindex

Thx. That did the trick. Nice clean randomize button now. Leftclick randomizes, rightclick randomizes and starts playing first item.

Code: [Select]
		fb.RunMainMenuCommand("Playback/Flush playback queue");		// Flush queue in case foo_keep_queue is active
fb.RunMainMenuCommand("Edit/Selection/Sort/Randomize") // Randomize selection and display selection in new order

var FirstSelectedItem = _first_selected_item(plman.ActivePlaylist);
if ( FirstSelectedItem > -1 ) {
plman.ExecutePlaylistDefaultAction(plman.ActivePlaylist, FirstSelectedItem)
}

I keep my queue button rightclick code as is (it works) and start experimenting with the other piece of code you sent.
Title: Re: JScript Panel script discussion/help
Post by: Defender on 2024-04-16 15:54:45
I created a DSP Preset button which works fine.

How can I optimize the following
Code: [Select]
case arr[active].name == 'Upmix to 3.0 (FL FR C)' || arr[active].name == 'Upmix to 4.0 (FL FR BL BR)' || arr[active].name == 'Upmix to 5.0 (FL FR C BL BR)':
which works to something like
Code: [Select]
case arr[active].name[1,5] == 'Upmix':
which does not work.
What is the syntax for matching the first 5 characters of arr[active].name ?

On a similar note ... how can I check for a pattern in a string (for instance) '[exclusive]' ?
Title: Re: JScript Panel script discussion/help
Post by: marc2k3 on 2024-04-16 16:32:20
Use indexOf.

Code: [Select]
//starts with
str.indexOf("Upmix") == 0;

//contains
str.indexOf("Upmix") > -1
Title: Re: JScript Panel script discussion/help
Post by: Defender on 2024-04-16 17:59:37
Use indexOf.

Code: [Select]
//starts with
str.indexOf("Upmix") == 0;

//contains
str.indexOf("Upmix") > -1

Perfect. Thx.