Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: JScript Panel script discussion/help (Read 288691 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

JScript Panel script discussion/help

Reply #75
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().

JScript Panel script discussion/help

Reply #76
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!

JScript Panel script discussion/help

Reply #77
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

JScript Panel script discussion/help

Reply #78
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.

JScript Panel script discussion/help

Reply #79
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

JScript Panel script discussion/help

Reply #80
Does anyone have some recommended resources/references I can take a look at? I've taken a look at some of Marc's sample scripts and just want to see examples of what I could do to modify the look to my ideal set-up.

I'm especially interested in the drawing functions; shadows, border, gradient, etc.

JScript Panel script discussion/help

Reply #81
Get rid of the ww/wh variables and use panel.w and panel.h instead. Also, your buttons should go inside the on_size function, after panel.size().

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

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

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

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

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

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

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


panel.item_focus_change();

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

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

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

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

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

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

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

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

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

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

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

Sorry if its a bit messy.

JScript Panel script discussion/help

Reply #82
Hey all, thanks marc2003, Br3tt and everyone else for your work. I've just installed the "foo_jscript_panel-v1.0.7.fb2k-component" and Br3tt's JS Smooth script.
When I import it, I get the following in the console:

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

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

And the console said:
JScript Panel ({A1765CC9-04BD-4F05-A555-F42F57233ACE}): initialized in 0 ms
Error: JScript Panel (JS Smooth Browser v20151114-1630-340 by Br3tt aka Falstaff >> http://br3tt.deviantart.com): 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): 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): 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"
// @feature "v1.4"
// @feature "watch-metadb"
// @import "%fb2k_profile_path%js_br3tt\jssb\js\JScommon.js"
// @import "%fb2k_profile_path%js_br3tt\jssb\js\JSinputbox.js"
// ==/PREPROCESSOR==

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

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

JScript Panel script discussion/help

Reply #83
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)?




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

JScript Panel script discussion/help

Reply #84
Hi!

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

Thanks in advance

Decalicatan Decalicatan

JScript Panel script discussion/help

Reply #85
Something like this should work.

Code: [Select]
gr.FillSolidRect(0, 0, panel.w, panel.h, _.RGB(150,150,250));

JScript Panel script discussion/help

Reply #86
I'm examining some of the samples that came along with the plugin. The one I'm interested in is the "Themed Seek Bar" and I am having a hard time understanding how to color it so say white rather than the default green and keep the default style.

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

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

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

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

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

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

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

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

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

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


JScript Panel script discussion/help

Reply #88
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;

JScript Panel script discussion/help

Reply #89
Works, thanks. Seems like I forgot you can add to the add to the height of the text panel not just remove the subtraction.

JScript Panel script discussion/help

Reply #90
Hey all, thanks marc2003, Br3tt and everyone else for your work. I've just installed the "foo_jscript_panel-v1.0.7.fb2k-component" and Br3tt's JS Smooth script.
When I import it, I get the following in the console:

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

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

And the console said:
JScript Panel ({A1765CC9-04BD-4F05-A555-F42F57233ACE}): initialized in 0 ms
Error: JScript Panel (JS Smooth Browser v20151114-1630-340 by Br3tt aka Falstaff >> http://br3tt.deviantart.com): 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): 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): 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"
// @feature "v1.4"
// @feature "watch-metadb"
// @import "%fb2k_profile_path%js_br3tt\jssb\js\JScommon.js"
// @import "%fb2k_profile_path%js_br3tt\jssb\js\JSinputbox.js"
// ==/PREPROCESSOR==

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

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



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

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

you should figure it out, but if not, do not try to use scripts anymore and stay with basics interfaces and panels.

JScript Panel script discussion/help

Reply #91
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?

JScript Panel script discussion/help

Reply #92
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.

 

JScript Panel script discussion/help

Reply #93
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

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.


JScript Panel script discussion/help

Reply #95
    New for 2016 - JScript Library Tree

Download and info here



JScript Panel script discussion/help

Reply #96
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 

JScript Panel script discussion/help

Reply #97
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) {}
        */



JScript Panel script discussion/help

Reply #98
If using panel stack splitter with a background image, position your panels using Forced layout and $movepanel / $movepanel_c

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

I realised later the 3 second delay was because of a silly mistake made by me while editing one of scripts   
but there still some laggy behavior while changing the tracks
Could on_notify_data(name, info) function being used in lot of panels can cause this??

JScript Panel script discussion/help

Reply #99
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?