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 376817 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Re: JScript Panel script discussion/help

Reply #1825
My old script "Peak meter" for WSH. Maybe useful for someone.

Code: [Select]
// ==PREPROCESSOR==
// @name "Peak meter"
// @author "kgena_ua"
// @version "06082017"
// ==/PREPROCESSOR==

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

var font = gdi.Font("Arial",9,1);
var font2 = gdi.Font("Arial",11,0);  

DT_CENTER = 0x00000001;  
DT_VCENTER = 0x00000004;  
DT_SINGLELINE = 0x00000020;   
DT_WORD_ELLIPSIS = 0x00040000;

var ww = window.Width, wh = window.Height;
var on_mouse = false;
var color = [];
var combinedColor1 = [];
var combinedColor2 = [];
var separator;
var offset, w, offset_l, w_l;
var pos_x = 0, pos_y = 0;;
var VUMOffset_t, t_height, t_width;
var wheel = false;
var tooltip_timer;

ColorTypeCUI = {
    text: 0,
    selection_text: 1,
    inactive_selection_text: 2,
    background: 3,
    selection_background: 4,
    inactive_selection_background: 5,
    active_item_frame: 6
}

function get_color(){
bgcolor = window.GetColorCUI(ColorTypeCUI.background);
c1 = window.GetColorCUI(ColorTypeCUI.text);
    c2 = window.GetColorCUI(ColorTypeCUI.inactive_selection_text);
    c3 = window.GetColorCUI(ColorTypeCUI.inactive_selection_background);
    color1 = [ c3, c1 ];
    color2 = [ c2, c3 ];
window.Repaint();
}

get_color();

function on_colors_changed(){
    get_color();
}

var dll;
var is_dll = utils.CheckComponent("\\user-components\\foo_vis_vumeter\\foo_vis_vumeter");
if (is_dll) {dll = false} else {dll = true};

if (dll) {VUMeter = new ActiveXObject("VUMeter")};  
if (dll) {VUMeter.RegisterWindow(window.ID)}; // do not use for transparent mode
  
function ToDB(Level){  
    return Math.round(2000*Math.log(Level)/Math.LN10)/100;  
}

var db = [-25,-22.5,-20,-17.5,-15,-12.5,-10,-7.5,-5,-4.5,-4,-3.5,-3,-2.5,-2,-1.5,-1,-0.5,0,0.5,1,1.5,2,2.5,3,3.5,4];  
var db_l = [-92.5,-90,-87.5,-85,-82.5,-80,-77.5,-75,-72.5,-70,-67.5,-65,-62.5,-60,-57.5,-55,-52.5,-50,-47.5,-45,-42.5,-40,-37.5,-35,-32.5,-30,-27.5]; 

for (var i = 0; i <= db.length; i++) {  
    if (db[i] == 0) {separator = i};
}
   
var points = db.length;
var s1 = separator;
var s2 = points - s1;
var points_l = db_l.length;

for(var j = 0; j < s1; j++) {
    combinedColor1.push(combineColors(color1[0], color1[1], j / s1));
}
for(var j = 0; j < s2; j++) {
    combinedColor2.push(combineColors(color2[0], color2[1], j / s2));
}

color = combinedColor1.concat(combinedColor2);

var col = 0;
var ytext = 5;
var h = 2;
var hM = 5;  

var yL = ytext + 15;
var yLM = yL + h + 4;

var hM_l = 1;
var yLM_l = yLM + hM + 4;
var yRM_l = yLM_l + hM_l + 1;

var yRM = yRM_l + hM_l + 4;
var yR = yRM + hM + 4; 

var wL = 0, wR = 0;  
var xLanim = 0, xRanim = 0;
var xL = 0, xR = 0;  

var xLManim = 0, xRManim = 0;
var xLM = 0, xRM = 0;  
  
var kLM = 0, kRM = 0;
var kLM2 = 0, kRM2 = 0;  
  
var xLManim2 = 0, xRManim2 = 0;

var kL = 0, kR = 0;
var wLanim = 0, wRanim = 0;

var oldwL = 0, oldwR = 0;

function on_paint(gr) {  
    gr.FillSolidRect(0, 0, ww, wh, bgcolor);
  
    if (panel_on && dll) {
        L = VUMeter.LeftLevel;  
        R = VUMeter.RightLevel;  
        LM = VUMeter.LeftPeak;  
        RM = VUMeter.RightPeak;  
    }

    if (panel_on && fb.IsPlaying && dll) {
        for (var i = 0; i <= points_l; i++) {  
            if (ToDB(LM) > db_l[i]) gr.FillSolidRect(col + i * offset_l, yLM_l, w_l, hM_l, color[0]);   
            if (ToDB(RM) > db_l[i]) gr.FillSolidRect(col + i * offset_l, yRM_l, w_l, hM_l, color[0]);
        }

        for (var i = 0; i <= points; i++) {  
  
            if ((ToDB(L) > db[i] && ToDB(L) < db[i+1])) {wL = i * offset + offset / Math.abs(db[i + 1]-db[i]) * Math.abs(ToDB(L) - db[i]) }  
            if (ToDB(L) > db[i]) gr.FillSolidRect(col, yL, wL, h, color[1]);  

            if ((ToDB(R) > db[i] && ToDB(R) < db[i+1])) {wR = i * offset + offset / Math.abs(db[i + 1]-db[i]) * Math.abs(ToDB(R) - db[i]) }  
            if (ToDB(R) > db[i]) gr.FillSolidRect(col, yR, wR, h, color[1]);   

            if (xLanim <= wL) {xLanim = wL; kL = 0; wLanim = wL - oldwL < 1 ? wLanim : wL - oldwL + 10} else {oldwL = wL};
            if (ToDB(L) > db[i]) gr.FillSolidRect(col + xLanim + 2, yL, wLanim <= 0 ? 2 : wLanim, h, color[1]);   

            if (xRanim <= wR) {xRanim = wR; kR = 0; wRanim = wR - oldwR < 1 ? wRanim : wR - oldwR + 10} else {oldwR = wR};
            if (ToDB(R) > db[i]) gr.FillSolidRect(col + xRanim + 2, yR, wRanim <= 0 ? 2 : wRanim, h, color[1]);   

            var overL = col + xLanim + 2 + wLanim - ww - 10;
            if (overL > 0) gr.FillSolidRect(ww - overL, yL - h - 1, ww - 10, h, color[10]);

            var overR = col + xRanim + 2 + wRanim - ww - 10;
            if (overR > 0) gr.FillSolidRect(ww - overR, yR + h + 1, ww - 10, h, color[10]);


            if (ToDB(LM) > db[i]) gr.FillSolidRect(col + i * offset, yLM, w, hM, color[i]);   
            if (ToDB(RM) > db[i]) gr.FillSolidRect(col + i * offset, yRM, w, hM, color[i]);                      

            if (ToDB(LM) > db[i] && ToDB(LM) < db[i+1]) {xLM = i * offset};  
            if (xLManim <= xLM) {xLManim = xLM; xLManim2 = xLM; kLM = 0; kLM2 = 0};
            if (ToDB(LM) > db[i]) gr.FillSolidRect(col + xLManim + offset, yLM, w * 0.8, hM , color[Math.round(xLManim/offset)]);   

            if (ToDB(RM) > db[i] && ToDB(RM) < db[i+1]) {xRM = i * offset};  
            if (xRManim <= xRM) {xRManim = xRM; xRManim2 = xRM; kRM = 0; kRM2 = 0};
            if (ToDB(RM) > db[i]) gr.FillSolidRect(col + xRManim + offset, yRM, w * 0.8, hM, color[Math.round(xRManim/offset)]);   

            if (ToDB(LM) > db[i]) gr.FillSolidRect(col + xLManim2 + offset + w, yLM, w * 0.3, hM, color[Math.round(xLManim/offset)]);    
            if (ToDB(RM) > db[i]) gr.FillSolidRect(col + xRManim2 + offset + w, yRM, w * 0.3, hM, color[Math.round(xRManim/offset)]);   
        }
        anim();
    }

    for (var i = 0; i <= points; i++) {
        var text_w = gr.CalcTextWidth(db[i], font);  
        if (i > 2) gr.GdiDrawText( db[i]% 2 == 0 ? db[i] : "" , font, color1[0], col + offset * i - text_w / 2, ytext, ww, wh);
    }
   
    gr.GdiDrawText( "db", font, color1[0], col, ytext, ww, wh);
   
    VUMOffset_t = Math.round(VUMeter.Offset) + " db";
    t_height = gr.CalcTextHeight(VUMOffset_t, font2) + 2;
    t_width = gr.CalcTextWidth(VUMOffset_t, font2) + 10;
    wheel && gr.FillSolidRect(pos_x - t_width, pos_y - t_height + 0, t_width, t_height, bgcolor);
    wheel && gr.GdiDrawText(VUMOffset_t, font2, color2[0], pos_x - t_width, pos_y - t_height + 0, t_width, t_height, DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_WORD_ELLIPSIS );
}  

function anim() {  
    kLM = kLM + Math.pow(0.3, 2); 
    kRM = kRM + Math.pow(0.3, 2); 
    xLManim = xLManim - kLM;          
    xRManim = xRManim - kRM; 
       
    kLM2 = kLM2 + Math.pow(1.1, 2); 
    kRM2 = kRM2 + Math.pow(1.1, 2);
    xLManim2 = xLManim2 + kLM2;
    xRManim2 = xRManim2 + kRM2;
       
    kL = kL + Math.pow(0.3, 2); 
    kR = kR + Math.pow(0.3, 2); 
    xLanim = xLanim - kL;  
    xRanim = xRanim - kR;

    wLanim = wLanim - kL * 2; //2
    wRanim = wRanim - kR * 2;
}

function on_size() {  
    ww = window.Width;  
    wh = window.Height;
    offset = (ww - col) / points;  
    w = offset - 1;  
    offset_l = (ww - col) / points_l;  
    w_l = offset_l - 1;
}  

function on_mouse_move(x,y) {
    on_mouse = true;
    pos_x = x <= t_width ? col + t_width : col + x;
    pos_y = y <= t_height ? t_height : y;
    window.SetCursor(32649);
    window.Repaint();
}

function on_mouse_leave() {
    on_mouse = false;
    window.SetCursor(32512);
    window.Repaint();
}
 
function on_mouse_wheel(step) {
    wheel = true;
    VUMeter.Offset = VUMeter.Offset + step;
    window.Repaint();
    tooltip_timer && window.ClearTimeout(tooltip_timer);
    tooltip_timer = window.SetTimeout(function() {
        wheel = false;
        tooltip_timer && window.ClearTimeout(tooltip_timer);
        tooltip_timer = false;
    }, 2000);
}

function combineColors(c1, c2, f){ // When fraction is 0, result is 100% color1, when f is 1, result is 100% color2.
    var c1 = toRGB(c1);
    var c2 = toRGB(c2);

    var r = Math.round(c1[0] + f * (c2[0] - c1[0]));
    var g = Math.round(c1[1] + f * (c2[1] - c1[1]));
    var b = Math.round(c1[2] + f * (c2[2] - c1[2]));
   
    return (0xff000000 | (r << 16) | (g << 8) | (b));
}

function toRGB(d){ // convert back to RGB values
    var d = d-0xff000000;
    var r = d >> 16;
    var g = d >> 8 & 0xFF;
    var b = d & 0xFF;

    return [r,g,b];
}

panel_on = true;

function on_notify_data(name, info) {
    if (name == "panel vis") {
        if (info == "Peak meter"){
            panel_on = true;
        } else {
            panel_on = false;
        }
    }
}
 
UR5EQF. Ukraine

Re: JScript Panel script discussion/help

Reply #1826
Thanks kgena_ua, will give this a workout tomorrow!  Air Ken, I hope you also mod it up and we'll see what we come up with  ;)

Re: JScript Panel script discussion/help

Reply #1827
Hello marc2k3, I wanted to know if there is a callback which gets triggered when the last item in a playlist gets played completely and then starts from first?

I am trying to execute a command so that when the final item in the playlist is finished the next item in the playlist starts from 0/1 (whatever is the beginning index of an item) so instead of stopping the playlist execute a command in between.

Currently,
Code: [Select]
plman.GetPlaylistItemCount(plman.FindPlaylist("LRP + LPC"))
shows the total items in a playlist. Using this I suppose there could be a way to track/increment the current item which is being played in the playlist? So basically whenever a command gets executed (suppose refresh playlist or whatever) the plman.GetPlaylistItemCount will run and store it in a variable.

Re: JScript Panel script discussion/help

Reply #1828
Hi All,
I have just  created a script to add 'value' to foo_youtube component by providing it with a song list.

//------------ CREDIT -----------------//
Credit goes to:
- @Wil-B (https://github.com/Wil-B) for the fantastic 'Find-and-Play' app, along with the 'Biography' and 'Library-Tree' scripts based on Spider Monkey Panel. The 'Find-and-Play' inspired me to explore [YouTube searching]. However I've tried, @Wil-B's scripts still set the benchmark.
- @Marc2003 (https://github.com/jscript-panel) for the excellent [JScript Panel 3] component. @Marc2003 actively updates this component with new features, bug fixes, and beautiful, tidy sample scripts.
# This script uses some API (web service) keys from @Wil-B and @marc2003 for trial purposes. Even though these keys are bundled with their public scripts, we should show and treat them with respect.
Spoiler (click to show/hide)

Hi @All ,

Please find the following:
1. _ 'JSP3 foo_youtube_addon' script attached hereafter. This script reflects Air KEN’s feedback {https://hydrogenaud.io/index.php/topic,104379.msg1050940.html#msg1050940}
Change log:

- 23Aug24: YouTube searching.
- 20Sep24:
   + YouTube channel management

2.  _ ‘JSP3 Now playing 64bit (text display)’
 
Change log:
. . .
- 20Sep24:
   + YouTube download (please pay attention to YouTube clip IP ): audio only, video best by size.
   + Favorite list (aka fb2k playlist): maintain a favorite song/clip list.

note:

1. youtube download is based on the yt_dlp.exe , ffmpeg.exe
   - yt_dlp path: {fb.ProfilePath} \skins\external_helper\yt-dlp.exe
   - ffmpeg path : {fb.ProfilePath} \skins\external_helper\ffmpeg.exe
2. about yt-dlp, ffmpeg.
_ yt-dlp : is a feature-rich command-line audio/video downloader with support for thousands of sites [ https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md]. The project is a fork of youtube-dl [https://github.com/ytdl-org/youtube-dl] based on the now inactive youtube-dlc [https://github.com/blackjack4494/yt-dlc]
- ffmpeg: information as @marc2003's sample >  https://jscript-panel.github.io/gallery/spectrogram-seekbar/.

Wish you all a nice weekend.
@Ilovefb2k

Re: JScript Panel script discussion/help

Reply #1829
Hi @All,

The weekend is coming, FriYAY!

Let’s have some fun with text, color, and music: JSP3_playbacktime_dancing. I combined scripts from @TomPro (text, color), @Case (VU Meter), and @Marc2003 (font): the script ‘draws’ playback time.

- Text, color: any color we can think of. {@TomPro's script: https://foobar-users.de/index.php?topic=2000.165 }
- VU Meter: smooth, bar, or galaxy.
- WYSIWYG font: we can select a font based on that ‘true’ rendering.

Wish you all a nice weekend.

@Ilovefb2k

Re: JScript Panel script discussion/help

Reply #1830
@ilovefb2k
Thanks.

ilovefb2k"s Script folder (skin folder):
https://mega.nz/file/BaEDDbDB#kgnnKjLclWcUVTFZpz9LcPdCx9P8dtnzloBSZJlUh7Y
SHURE SRH1840, SENNHEISER HD660S2, SENNHEISER HD620S, SENNHEISER HD 490 Pro Plus, beyerdynamic DT 1990 PRO, HiFiMAN Edition XS, Bowers & Wilkins P7, FiiO FT5, 水月雨 (MOONDROP) 空鳴 - VOID, Nakamichi Elite FIVE ANC, SONY WH1000XM5 (made a Upgrade/Balanced Cable by myself)

Re: JScript Panel script discussion/help

Reply #1831
'JSP3 foo_youtube_addon'



‘JSP3 Now playing 64bit (text display)’


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

Re: JScript Panel script discussion/help

Reply #1832
I wanted to know if there is a callback which gets triggered when the last item in a playlist gets played completely and then starts from first?

I am trying to execute a command so that when the final item in the playlist is finished the next item in the playlist starts from 0/1 (whatever is the beginning index of an item) so instead of stopping the playlist execute a command in between.

Currently,
Code: [Select]
plman.GetPlaylistItemCount(plman.FindPlaylist("LRP + LPC"))
shows the total items in a playlist. Using this I suppose there could be a way to track/increment the current item which is being played in the playlist? So basically whenever a command gets executed (suppose refresh playlist or whatever) the plman.GetPlaylistItemCount will run and store it in a variable.

Hello, @marc2k3 any idea if this would be possible?

Re: JScript Panel script discussion/help

Reply #1833
I'm using JSP3 "text display" sample.
In the "custom text" configuration, what do I need to do to display "[" and "]" characters?
Thank you.


Re: JScript Panel script discussion/help

Reply #1835
hyphen -
apostrophe '
It's your privilege to disagree, but that doesn't make you right and me wrong.



Re: JScript Panel script discussion/help

Reply #1838
Hello!
First of all, i want to thank you @marc2k3 for this component!
And i have a small question: is there a way to draw polygons and if not, do you plan on implementing it?

Re: JScript Panel script discussion/help

Reply #1839
Hey,

I'm trying to style the last.fm bio + images sample snippet, but I do not know where to start. None of the sample snippets have any documentation/comments to help me grasp what each function is doing. There doesn't seem to be any CSS involved either, just pure javascript?

So, how can I style this (not modify the actual functions, just the outlook of the panel)?

What I want to do: Change the font, remove the image backgrounds, have same colors as other UI elements and otherwise try to make it as "native" looking as possible and bare-bones rather than "fancy".

It would already help if anyone could point out to me where these styling things are in the code.

Re: JScript Panel script discussion/help

Reply #1840
Hello!
First of all, i want to thank you @marc2k3 for this component!
And i have a small question: is there a way to draw polygons and if not, do you plan on implementing it?
There is a way to draw a polygons. You have to use SVG :
https://jscript-panel.github.io/docs/namespaces/utils/#utilsloadsvgpath_or_xml-max_width
In the given example a file is used but you can use xml as a string :
https://www.w3schools.com/graphics/svg_polygon.asp

Best

Re: JScript Panel script discussion/help

Reply #1841
There is a way to draw a polygons. You have to use SVG :
https://jscript-panel.github.io/docs/namespaces/utils/#utilsloadsvgpath_or_xml-max_width
In the given example a file is used but you can use xml as a string :
https://www.w3schools.com/graphics/svg_polygon.asp
I guess this will suffice!
Previously i was loading local png's, thank you (:

Re: JScript Panel script discussion/help

Reply #1842
Is it possible to update the tagging properties like $artist$ or $album$ inside jsp3 ?
To fill the field inside an input box ? Thanks ....

Re: JScript Panel script discussion/help

Reply #1843
would like to make a suggestion for the "Properties + Other Info" sample item. When you click on this item, it will create a new library. It would be really nice if you could edit the tag.

Re: JScript Panel script discussion/help

Reply #1844
can you add text display with buttons and seekbar as my foot samples has got so very small and I don't know how to increase it

Re: JScript Panel script discussion/help

Reply #1845
here what I see very small font now I am sure it used to be larger than that but me and the mouse don't get on so  how do i increase the text size


Re: JScript Panel script discussion/help

Reply #1847
okay thank you that worked  :) now to add buttons heh now I can see the text

Re: JScript Panel script discussion/help

Reply #1848
i tried but cannot add buttons to text display  :'(