# Hydrogenaudio Forums

## 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 objectLine: 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 referenceLine: 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

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

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:

• Interactive discography with similar &  related artists, for choosing tracks & albums.
• Support for last.fm top albums, top tracks,  top similar songs & MusicBrainz releases, including singles & remixes  as well as albums & compilations.
• Builds albums &  optionally automatically creates m-TAGS files using track lists from  MusicBrainz & last.fm.
• Offers auto-generation  of top 50 artist tracks & top 50 similar songs.
• Offers auto-pick  radio modes for artist, genre / top tags, similar artists & similar songs  playback, based on track popularity data from last.fm, echonest  or your library. Radio modes  are great for listening to music of a chosen style. Last.fm & echonest also  work well for music discovery. Library radio offers a new way of playing your own music.
• Tracks can be YouTube links, exclusively  media library tracks or a mixture of both where media library tracks are  preferred, according to settings. YouTube links are advert-free & can be  audio only up to 256 kbps AAC or video.
• Improved nowplaying  panel that can act as a cover & artist artwork viewer if no longer wish to  look at album & track lists.
• Options > right  click menu + properties (*USER...). Double click > album manager: loads  albums/tracks. Double click > nowplaying: toggles image/text types. Middle click > nowplaying: toggles image only mode vs  image + text. yT button > toggles nowplaying vs  album manager panels.
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)

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 Functionsfunction 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 Variablesvar theme_font = fb.TitleFormat("%theme_font%").Eval(true);var panelh, panelw;// for time display/*var */// Seekbarseekbar = 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 variablesvar 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.iscdwindow.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.
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

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.

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.
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.

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 widthvar pan_h = window.Height; // panel heightthumbs.mode = 5;var bar_h = 80; // height of the title stuffvar buttons = new _.buttons();var mbuts = 48; // menu button sizebuttons.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);//ratingvar r_x = (panw - 28 * 5) / 2; // rating buttons starting x positionvar r_y = bar_h + 5; //rating buttons starting y positionvar rating = new _.rating(r_x, r_y, 28,   _.RGB(128, 128, 128), _.RGB(255, 128, 0));//playback buttonsvar bs = 80; // playback buttons sizevar strpnt_x = (panw - bs) / 2; // playback buttons starting x positionvar strpnt_y = pan_h - 100; // playback buttons starting y positionbuttons.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:

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"
// @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.

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).

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 functionvar 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:

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"
// @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.

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

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
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 objectFile: Z:\home\zarkbit\.wine32\drive_c\Program Files\foobar2000\marc2003\common7.jsLine: 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 objectFile: Z:\home\zarkbit\.wine32\drive_c\Program Files\foobar2000\js_marc2003\js\helpers.jsLine: 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 RunTrack Title : Tool Sheds And Hot TubsAlbum Title : Straylight RunDate : 2004Genre : 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 touchlist.filename = folders.settings + "autoplaylists2.json"; //only add this/modify filename in extra panels. autoplaylists.json is the original filename so don't use thatlist.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.cropimage.crop_topimage.stretchimage.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?

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; //rightvar b = "boo"; //wrongvar 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 errorFile: <main>Line: 66, Col: 1const 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...

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.

• 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.

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 Imagefunction 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.

• 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.
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
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 methodFile: D:\Apps\PortableApps\foobar2000\scripts\marc2003\common.jsLine: 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 failvar 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 failvar 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:

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:

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 deniedFile: C:\Foobar2000\js_marc2003\js\thumbs.jsLine: 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:

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_winxpwsh57fontsmooth=rgbmsscriptie8msls31w_workaround_wine_bug-25648msxml3wmp10vb6runvcrun2010

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

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 STARTfunction 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.
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

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

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

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.txtautoplaylists.txtmenu button.txtplayback buttons.txtproperties.txtrating.txtseekbar.txttrack info + seekbar + buttons.txtvolume.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.
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
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.

@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.

@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.

@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);    }}

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...

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: 0my_array: 1my_array: 2my_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_XXXimg.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_changeon_playlist_items_selection_changeon_item_focus_changeon_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 0timer 1timer 2on_paint 2timer 3timer 4timer 5on_paint 5timer 6timer 7on_paint 7timer 8timer 9timer 10on_paint 10timer 11on_paint 11timer 12on_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 60on_paint 60timer 61on_paint 61timer 62on_paint 62timer 63on_paint 63timer 64on_paint 64timer 65on_paint 65timer 66on_paint 66timer 67on_paint 67timer 68timer 69on_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 backgroundgb.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,

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."
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.
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.

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.

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.txtvar 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, tooltipb.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.
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?

Title: Re: JScript Panel script discussion/help
Post by: marc2003 on 2017-04-28 20:49:54

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

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,

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 stylepanel.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();

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 neededvar 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.

Quote from: JScript Panel
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.jsLine: 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 stylepanel.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,
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;								}							})

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,

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.jsLine: 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 stringvar test = utils.MapString(null, 0x0804, 0x04000000); //script errorvar test = utils.MapString(undefined, 0x0804, 0x04000000); //returns empty string

WSH Panel Mod Plus
Code: [Select]
var test = utils.LCMapString("", 0x0804, 0x04000000); //returns empty stringvar test = utils.LCMapString(null, 0x0804, 0x04000000); //script errorvar 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].

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

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

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 errorFile: C:\Users\Daniel\AppData\Roaming\foobar2000\js_br3tt\jsspm\js\JScommon.jsLine: 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

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
// @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
// @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 greendarker = 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 directlyfunction 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:
• Download all the files from >>git<< (https://github.com/TheQwertiest/CaTRoX_QWR/tree/master/jscript_api) and put them in some folder.
• File > Settings > Languages > JavaScript > Libraries > Add... > + > Attach Directories... > Choose folder from the previous step
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 :)
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:

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:

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.

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.
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.

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

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
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.

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.

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:
- 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):
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:
• 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)
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 methodFile: C:\Users\3\AppData\Roaming\foobar2000\js_marc2003\js\panel.jsLine: 65, Col: 5<source text only available at compile time>

which is    if (font) {

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 likegr.DrawString("blah", font, color, x, y, w, h, StringFormat(StringAlignment.Near, StringAlignment.Center));// orvar 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 likegr.DrawString("blah", font, color, x, y, w, h, StringFormat(StringAlignment.Near, StringAlignment.Center));// orvar 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

Code: [Select]
var mediaTypeImg = null;var pref = {};pref.codec_base = fb.ProfilePath + 'images/codecs';

Code: [Select]
// gets the correct imagefunction 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 beif (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

Code: [Select]
var mediaTypeImg = null;var pref = {};pref.codec_base = fb.ProfilePath + 'images/codecs';

Code: [Select]
// gets the correct imagefunction 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 beif (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
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
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
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"