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 295923 times) previous topic - next topic
0 Members and 3 Guests are viewing this topic.

Re: JScript Panel script discussion/help

Reply #1200
Thanks for the update Marc. Another question, how the country flag code read from multiple value tag like <COUNTRY> Gothenburg; Västra Götaland; Sweden ?

Re: JScript Panel script discussion/help

Reply #1201
Title format would be

Code: [Select]
$country_flag($meta(country,$sub($meta_num(country),1)))

JS could be

Code: [Select]
var flag = ''
var handle = fb.GetFocusItem();
if (handle) {
var f = handle.GetFileInfo();
var country = f.MetaFind("country");
if (country > -1) {
var num = f.MetaValueCount(country);
var last_value = f.MetaValue(country, num - 1);
flag = utils.GetCountryFlag(last_value);
}
}


Re: JScript Panel script discussion/help

Reply #1202
Thank you for the prompt response!
Spoiler (click to show/hide)

Re: JScript Panel script discussion/help

Reply #1203
@eurekagliese

Text Display.txt
Custom context...

Could you please upload it?

Thanks.
SHURE SRH1840, SENNHEISER HD660S2, SENNHEISER HD 490 PRO, DT 1990 PRO, HiFiMAN Edition XS, Bowers & Wilkins P7, FiiO FT5, 水月雨 (MOONDROP) 空鳴 - VOID, Nakamichi Elite FIVE ANC, SONY WH-ULT900N (ULT WEAR) (made a Upgrade/Balanced Cable by myself)

Re: JScript Panel script discussion/help

Reply #1204
@eurekagliese

Text Display.txt
Custom context...

Could you please upload it?

Thanks.
Sure, here you go
Code: [Select]
$font(Segoe UI,24)
[%title% ]$crlf()
$font(Segoe UI,14)
[%artist% ] [$font(Twitter Color Emoji,18)$country_flag($meta(country,$sub($meta_num(country),1)))$font() ]$crlf()
[%album% '('%year%')']$crlf()

Make sure to install the Twitter Color Emoji font first
https://github.com/13rac1/twemoji-color-font/releases/download/v14.0.2/TwitterColorEmoji-SVGinOT-14.0.2.zip

Re: JScript Panel script discussion/help

Reply #1205
Great!
Thanks.

SHURE SRH1840, SENNHEISER HD660S2, SENNHEISER HD 490 PRO, DT 1990 PRO, HiFiMAN Edition XS, Bowers & Wilkins P7, FiiO FT5, 水月雨 (MOONDROP) 空鳴 - VOID, Nakamichi Elite FIVE ANC, SONY WH-ULT900N (ULT WEAR) (made a Upgrade/Balanced Cable by myself)


Re: JScript Panel script discussion/help

Reply #1207
Try to reboot first

Re: JScript Panel script discussion/help

Reply #1208
System reboot was missing. Thank you.



Re: JScript Panel script discussion/help

Reply #1210
Spoiler (click to show/hide)
@eurekagliese

If you look closely, you can see that "Last.fm Bio + Image" is placed above and below.
It can be used for vertically long or almost square panels.

Could you please share "Last.fm Bio + Image" Script?

I'm sorry for always asking for your help.

Thanks.
SHURE SRH1840, SENNHEISER HD660S2, SENNHEISER HD 490 PRO, DT 1990 PRO, HiFiMAN Edition XS, Bowers & Wilkins P7, FiiO FT5, 水月雨 (MOONDROP) 空鳴 - VOID, Nakamichi Elite FIVE ANC, SONY WH-ULT900N (ULT WEAR) (made a Upgrade/Balanced Cable by myself)

Re: JScript Panel script discussion/help

Reply #1211
Spoiler (click to show/hide)
@eurekagliese

If you look closely, you can see that "Last.fm Bio + Image" is placed above and below.
It can be used for vertically long or almost square panels.

Could you please share "Last.fm Bio + Image" Script?

I'm sorry for always asking for your help.

Thanks.

It's not a problem at all. I'm happy to share.
Here's the code, of course the credit goes to Marc, I just changed tiny bit of it.

Code: [Select]
// ==PREPROCESSOR==
// @name "Last.fm Bio"
// @author "marc2003"
// @import "%fb2k_component_path%helpers.txt"
// @import "%fb2k_component_path%samples\js\lodash.min.js"
// @import "%fb2k_component_path%samples\js\common.js"
// @import "%fb2k_component_path%samples\js\panel.js"
// @import "%fb2k_component_path%samples\js\lastfm.js"
// @import "%fb2k_component_path%samples\js\thumbs.js"
// @import "%fb2k_component_path%samples\js\text.js"
// ==/PREPROCESSOR==

var margin = _scale(12);

var panel = new _panel();
var lastfm = new _lastfm();
var text = new _text('lastfm_bio', 0, 0, 0, 0);
var thumbs = new _thumbs();

text.paint = function (gr) {
var colour = thumbs.blur_img ? RGB(255, 255, 255) : panel.colours.text;
var colourh = thumbs.blur_img ? RGB(255, 255, 255) : panel.colours.highlight;

gr.WriteText(this.header_text(), panel.fonts.title, colourh, this.x, margin, this.w, panel.h - (margin * 2), DWRITE_TEXT_ALIGNMENT_LEADING, DWRITE_PARAGRAPH_ALIGNMENT_CENTER, DWRITE_WORD_WRAPPING_NO_WRAP, DWRITE_TRIMMING_GRANULARITY_CHARACTER);

if (this.text_layout) {
gr.WriteTextLayout(this.text_layout, colour, this.x, this.y + margin, this.w, this.ha, this.offset);
this.up_btn.paint(gr, colour);
this.down_btn.paint(gr, colour);
}
}

thumbs.image_containsxXY = function (x, y) {
return this.images.length && this.containsXY(x, y);
}

thumbs.move = function (x, y) {
this.mx = x;
this.my = y;
return this.containsXY(x, y);
}

thumbs.paint = function (gr) {
if (this.images.length) {
_drawImage(gr, this.blur_img, 0, 0, panel.w, panel.h, image.crop_top);
_drawOverlay(gr, 0, 0, panel.w, panel.h, 120);
this.image_xywh = _drawImage(gr, thumbs.images[thumbs.image], this.x, this.y, this.w, this.h, image.crop_top);
} else {
this.image_xywh = [];
}
}

thumbs.size = function () {}

thumbs.wheel = function (s) {
if (this.containsXY(this.mx, this.my)) {
if (this.images.length > 1) {
this.image -= s;
if (this.image < 0) {
this.image = this.images.length - 1;
}
if (this.image >= this.images.length) {
this.image = 0;
}
window.Repaint();
}
return true;
}
return false;
}

panel.item_focus_change();

function on_colours_changed() {
panel.colours_changed();
window.Repaint();
}

function on_download_file_done(path, success, error_text) {
text.download_file_done(path, success, error_text);
}

function on_font_changed() {
panel.font_changed();
window.Repaint();
}

function on_http_request_done(task_id, success, response_text) {
thumbs.http_request_done(task_id, success, response_text);
}

function on_item_focus_change() {
if (panel.selection.value == 0 && fb.IsPlaying) return;
panel.item_focus_change();
}

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

function on_metadb_changed(handles, fromhook) {
if (fromhook) return;
text.metadb_changed();
thumbs.metadb_changed();
}

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

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

function on_mouse_lbtn_dblclk(x, y) {
thumbs.lbtn_dblclk(x, y);
}

function on_mouse_rbtn_up(x, y) {
if (text.containsXY(x, y)) {
return panel.rbtn_up(x, y, text);
}
return panel.rbtn_up(x, y, thumbs);
}

function on_mouse_wheel(s) {
if (thumbs.wheel(s)) return;
text.wheel(s);
}

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

function on_playback_dynamic_info_track(type) {
if (type == 0) {
text.metadb_changed();
thumbs.metadb_changed();
}
}

function on_playback_new_track() {
panel.item_focus_change();
thumbs.playback_new_track();
}

function on_playback_stop(reason) {
if (reason != 2) {
panel.item_focus_change();
}
}

function on_playback_time() {
thumbs.playback_time();
}

function on_playlist_switch() {
on_item_focus_change();
}

function on_size() {
panel.size();
var half = panel.h / 2;

thumbs.x = margin;
thumbs.y = margin;
thumbs.w = panel.w - (margin * 2);
thumbs.h = half - (margin * 2);

text.x = margin;
text.y = half;
text.w = panel.w - margin;
text.h = half;
text.size();
}

Re: JScript Panel script discussion/help

Reply #1212
I suppose I could add a toggle or maybe auto detect panel dimensions and use the best fit.

BTW, that mod above is not quite correct. The text touches the right hand side of the panel when it shouldn't.

Inside on_size...

Code: [Select]
text.w = panel.w - margin;

should be

Code: [Select]
text.w = panel.w - (margin * 2);

Re: JScript Panel script discussion/help

Reply #1213
Thank you for the correction.
Perhaps a toggle would be better there.

Re: JScript Panel script discussion/help

Reply #1214
That's amazing.
Many Thanks.
---
My head is full of country code.
SHURE SRH1840, SENNHEISER HD660S2, SENNHEISER HD 490 PRO, DT 1990 PRO, HiFiMAN Edition XS, Bowers & Wilkins P7, FiiO FT5, 水月雨 (MOONDROP) 空鳴 - VOID, Nakamichi Elite FIVE ANC, SONY WH-ULT900N (ULT WEAR) (made a Upgrade/Balanced Cable by myself)

Re: JScript Panel script discussion/help

Reply #1215
I'm not doing a component release just now but here are some modded files if anyone wants to test the toggle now.

It also fixes automatic image downloads not working for streams. The original thumbs its based on is fine. It's just this new image/text mod that is borked.

Note that the toggle option is only available when right clicking the image (or where the image should be if none are present). Right clicking the text displays text only options.

Save thumbs.js inside the component folder/samples/js
Use the .txt file inside the panel.

Re: JScript Panel script discussion/help

Reply #1216
@marc2k3

Thank you for your continued quick work.



In my case, Image:Text=6:4 is good.
Set the ratio of Image and Text as a percentage, Is it troublesome to be able to change it with Panel Properties?
SHURE SRH1840, SENNHEISER HD660S2, SENNHEISER HD 490 PRO, DT 1990 PRO, HiFiMAN Edition XS, Bowers & Wilkins P7, FiiO FT5, 水月雨 (MOONDROP) 空鳴 - VOID, Nakamichi Elite FIVE ANC, SONY WH-ULT900N (ULT WEAR) (made a Upgrade/Balanced Cable by myself)

Re: JScript Panel script discussion/help

Reply #1217
@ erukeagliese

I use your Custom Track 3.0 script

With the jscript-panel 3.3.20 update the script crashes, probably because the samples albumart has been modified.

As soon as you update the script, if you can post it.

Thank you.

Cannot retrieve the 'text_objects' property of a null or undefined reference
File: ....foobar2000\profile\user-components\foo_jscript_panel3\samples\js\albumart.js
Line: 198, Col: 2

 

Re: JScript Panel script discussion/help

Reply #1219
Inside that script, look for

Code: [Select]
var panel = new _panel();

Move it so it's the first line of code.
Thank you!

@ erukeagliese

I use your Custom Track 3.0 script

With the jscript-panel 3.3.20 update the script crashes, probably because the samples albumart has been modified.

As soon as you update the script, if you can post it.

Thank you.

Cannot retrieve the 'text_objects' property of a null or undefined reference
File: ....foobar2000\profile\user-components\foo_jscript_panel3\samples\js\albumart.js
Line: 198, Col: 2

I've updated the script with some minor improvement.
- Albumart cursor
- Volume knob toggle

Re: JScript Panel script discussion/help

Reply #1220
Inside that script, look for

Code: [Select]
var panel = new _panel();

Move it so it's the first line of code.
Thank you!

@ erukeagliese

I use your Custom Track 3.0 script

With the jscript-panel 3.3.20 update the script crashes, probably because the samples albumart has been modified.

As soon as you update the script, if you can post it.

Thank you.

Cannot retrieve the 'text_objects' property of a null or undefined reference
File: ....foobar2000\profile\user-components\foo_jscript_panel3\samples\js\albumart.js
Line: 198, Col: 2

I've updated the script with some minor improvement.
- Albumart cursor
- Volume knob toggle

A thousand thanks

Great script.

I only changed two lines to have the Clear playlist function instead of Remove Playlist.


Re: JScript Panel script discussion/help

Reply #1221
Hello again, Marc. Is there any plan to add Gradient to DrawEllipse and FillEllipse?
I only see the FillGradientRectangle and FillGradientRectangleAdvanced methods that accept the str object.

Thanks

By the way, regarding the jscript-panel.github.io site, perhaps the built-in search can be better. It seems it's only search the whole word.
When I searched for "Gradient," it simply returned "No matching documents."

Re: JScript Panel script discussion/help

Reply #1222
@marc2k3

I am always grateful for your help.
Can I add "Thumbs Image Options" to "Last.fm Bio + Image"?

Thumbs Image Option:

Crop (focus on centre)
Crop (focus on top)
Stretch
Centre

Thanks.
SHURE SRH1840, SENNHEISER HD660S2, SENNHEISER HD 490 PRO, DT 1990 PRO, HiFiMAN Edition XS, Bowers & Wilkins P7, FiiO FT5, 水月雨 (MOONDROP) 空鳴 - VOID, Nakamichi Elite FIVE ANC, SONY WH-ULT900N (ULT WEAR) (made a Upgrade/Balanced Cable by myself)

Re: JScript Panel script discussion/help

Reply #1223
I'm deliberately suppressing those options for this script and I don't really want to change it. But you can edit the code at the end of line 48 inside the panel. Change image.crop_top to one of...

Code: [Select]
image.crop
image.centre
image.stretch

Re: JScript Panel script discussion/help

Reply #1224
> I'm deliberately suppressing those options for this script and I don't really want to change it
Yes, I understand.

> But you can edit the code at the end of line 48 inside the panel. Change image.crop_top to one of...
I'm sorry for saying it was impossible.
Changed to image.centre. feel well.

Thanks.
SHURE SRH1840, SENNHEISER HD660S2, SENNHEISER HD 490 PRO, DT 1990 PRO, HiFiMAN Edition XS, Bowers & Wilkins P7, FiiO FT5, 水月雨 (MOONDROP) 空鳴 - VOID, Nakamichi Elite FIVE ANC, SONY WH-ULT900N (ULT WEAR) (made a Upgrade/Balanced Cable by myself)