Skip to main content

Topic: JScript Panel script discussion/help (Read 36037 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
Re: JScript Panel script discussion/help
Reply #525
Thanks marc2003.

I've just this minute got a solution working with a file system object. Seems to work fine.

  • marc2003
  • [*][*][*][*][*]
  • Developer
Re: JScript Panel script discussion/help
Reply #526
Ah yes, using fso is much better.  8)

Re: JScript Panel script discussion/help
Reply #527
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)
  • Last Edit: 30 April, 2017, 09:58:43 AM by alekksander
————————
♭———————

Re: JScript Panel script discussion/help
Reply #528
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?

  • Viewmax
  • [*]
Re: JScript Panel script discussion/help
Reply #529
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!

  • marc2003
  • [*][*][*][*][*]
  • Developer
Re: JScript Panel script discussion/help
Reply #530
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();
}
}

  • Viewmax
  • [*]
Re: JScript Panel script discussion/help
Reply #531
OMG! Huge props! I can't PM you :( Could you send me your Paypal? You should have donation button!

  • Viewmax
  • [*]
Re: JScript Panel script discussion/help
Reply #532
One more question, is it possible to assign a hotkeys to these custom buttons?

  • marc2003
  • [*][*][*][*][*]
  • Developer
Re: JScript Panel script discussion/help
Reply #533
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.

  • Viewmax
  • [*]
Re: JScript Panel script discussion/help
Reply #534
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!

  • marc2003
  • [*][*][*][*][*]
  • Developer
Re: JScript Panel script discussion/help
Reply #535
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...

  • Last Edit: 18 May, 2017, 02:24:35 AM by marc2003

  • Viewmax
  • [*]
Re: JScript Panel script discussion/help
Reply #536
It's just a brilliant! Working absolutely fantastically!

Re: JScript Panel script discussion/help
Reply #537
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.

  • marc2003
  • [*][*][*][*][*]
  • Developer
Re: JScript Panel script discussion/help
Reply #538
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.

  • MachineHead
  • [*][*][*][*][*]
Re: JScript Panel script discussion/help
Reply #539
@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?

  • marc2003
  • [*][*][*][*][*]
  • Developer
Re: JScript Panel script discussion/help
Reply #540
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.