Skip to main content

Notice

Please be aware that much of the software linked to or mentioned on this forum is niche and therefore infrequently downloaded. Lots of anti-virus scanners and so-called malware detectors like to flag infrequently downloaded software as bad until it is either downloaded enough times, or its developer actually bothers with getting each individual release allow listed by every single AV vendor. You can do many people a great favor when encountering such a "problem" example by submitting them to your AV vendor for examination. For almost everything on this forum, it is a false positive.
Topic: JScript Panel (Read 104969 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Re: JScript Panel

Reply #525
JScript Panel v2.5.3

code metadb = fb.GetFocusItem(); returns nothing.

Spoiler (click to show/hide)
How to solve this. An example is desirable.
Thanks
I.m. UR5EQF

Re: JScript Panel

Reply #526
Radical idea: try a playlist that isn't empty.

Click the attachment for full size

Code is pretty much the same as above post...

https://github.com/marc2k3/foo_jscript_panel/blob/ae052b20dbb0f5148dfc05ddd119e646eff6cfa6/component/samples/complete/js/panel.js#L29-L47

Re: JScript Panel

Reply #527
Does not work.
Why.
I have some code.
Anyway a gift from me
Code: [Select]
// ==PREPROCESSOR==
// @name "emoticon"
// @author "kgena_ua"
// ==/PREPROCESSOR==

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

var ww = 0, wh = 0;

var bgcolor = RGB(128, 166, 255);
var bgcolor = RGB(0, 128, 192);
var color_1 = RGB(255, 255, 0);
var color_2 = RGB(0,0,0);

var img = create_emoticon(color_1, color_2);

var emoticon_s = 60;
var emoticon = resize_img(create_emoticon(color_1, color_2), emoticon_s, emoticon_s);

function resize_img(img, w, h){
    if (!img) return;

    var scale_w = w / img.Width;
    var scale_h = h / img.Height;
   
    var scale = Math.min(scale_w, scale_h);

    var iw = Math.round(img.Width * scale);
    var ih = Math.round(img.Height * scale)

    var temp_bmp = gdi.CreateImage(iw, ih);
    var temp_gr = temp_bmp.GetGraphics();
    temp_gr.SetSmoothingMode(2);
    temp_gr.SetInterpolationMode(7);
    temp_gr.DrawImage(img, 0, 0, iw, ih, 0, 0, img.width, img.height);
    temp_bmp.ReleaseGraphics(temp_gr);

    return temp_bmp;
    temp_bmp.Dispose();
    temp_gr = null;
    temp_bmp = null;
}

function create_emoticon(c1, c2){
    var temp = gdi.CreateImage(200, 200);
    var temp_gr = temp.GetGraphics();
   
        temp_gr.SetSmoothingMode(4);
        r = 90;
        d = r * 2;
        x = r;
        y = r;
        ys = y - r * 0.3;
        rs = r * 1.15;
        rs1 = rs * 0.73;
        rs2 = rs1 * 0.95;
        rs3 = rs1 * 1.1;
        rs4 = rs2 * 0.9;
        angl1 = 120;
        angl2 = 240;
        steps = 360;
        var dyP1 = 0;
        temp_gr.FillEllipse(x - d /2, y - d /2, d, d, c1);
        for (var j = angl1; j < angl2; j++) {
            xP1 = (rs1 * Math.cos(Math.PI * j / steps * 2 - Math.PI / 2));
            yP1 = (rs1 * Math.sin(Math.PI * j / steps * 2 - Math.PI / 2));
            xP2 = (rs2 * Math.cos(Math.PI * j / steps * 2 - Math.PI / 2));
            yP2 = (rs2 * Math.sin(Math.PI * j / steps * 2 - Math.PI / 2));
            if (j > angl1 && j < 180) dyP1 = dyP1 + 0.15;
            if (j > 180 && j < angl2) dyP1 = dyP1 - 0.15;
            temp_gr.DrawLine(x + xP1, ys + yP1 + dyP1, x + xP2, ys + yP2, 2, c2);
        }
        for (var j = angl1; j < angl1 + rs * 0.02; j++) {
            xP1 = (rs3 * Math.cos(Math.PI * j / steps * 2 - Math.PI / 2));
            yP1 = (rs3 * Math.sin(Math.PI * j / steps * 2 - Math.PI / 2));
            xP2 = (rs4 * Math.cos(Math.PI * j / steps * 2 - Math.PI / 2));
            yP2 = (rs4 * Math.sin(Math.PI * j / steps * 2 - Math.PI / 2));
            temp_gr.DrawLine(x + xP1, ys + yP1, x + xP2, ys + yP2, 2, c2);
        }
        for (var j = angl2 - rs * 0.02; j < angl2; j++) {
            xP1 = (rs3 * Math.cos(Math.PI * j / steps * 2 - Math.PI / 2));
            yP1 = (rs3 * Math.sin(Math.PI * j / steps * 2 - Math.PI / 2));
            xP2 = (rs4 * Math.cos(Math.PI * j / steps * 2 - Math.PI / 2));
            yP2 = (rs4 * Math.sin(Math.PI * j / steps * 2 - Math.PI / 2));
            temp_gr.DrawLine(x + xP1, ys + yP1, x + xP2, ys + yP2, 2, c2);
        }
        temp_gr.FillEllipse(x + r * 0.15, y - r * 0.55, d * 0.12, d * 0.25, c2);
        temp_gr.FillEllipse(x - r * 0.4, y - r * 0.55, d * 0.12, d * 0.25, c2);
        lw = r * 0.08;
        temp_gr.DrawEllipse(x - d /2 + lw / 2, y - d /2 + lw / 2, d - lw, d - lw, lw, c2);
       
    temp.ReleaseGraphics(temp_gr);
    return temp;
    temp.Dispose();
    temp_gr = null;
    temp = null;
}

function on_paint(gr) {
    !window.IsTransparent && gr.FillSolidRect(0, 0, ww, wh, bgcolor);
    gr.DrawImage(emoticon, ww / 2 - emoticon_s / 2, wh / 2 - emoticon_s / 2, emoticon.width, emoticon.Height, 0, 0, emoticon.width, emoticon.Height, 0, 255);         
}

function on_mouse_move(x, y) {
    on_mouse = true;
    window.SetCursor(32649);
    window.Repaint();
}

function on_mouse_leave() {
    on_mouse = false;
    window.SetCursor(32512);
    window.Repaint();
}

function on_size(){
    ww = window.Width;
    wh = window.Height;
}

I.m. UR5EQF

Re: JScript Panel

Reply #528
You might recognise this script considering it's YOURS.



Also, this other person in YOUR THREAD is running YOUR SCRIPT in JSP 2.5.3 just fine with a little fix for radio streams...

https://hydrogenaud.io/index.php?topic=114686.msg994823#msg994823




Re: JScript Panel

Reply #529
Quote
Also, this other person in YOUR THREAD is running YOUR SCRIPT in JSP 2.5.3 just fine with a little fix for radio streams...
In fact of the matter.
This is my mistake somewhere.
Some kind of mysticism

From my
foo_vis_vumeter is required
Code: [Select]
// ==PREPROCESSOR==
// @name "Peak meter 6Е5С"
// @author "kgena_ua"
// @version "102020"
// ==/PREPROCESSOR==

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

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

DT_LEFT = 0x00000000;
DT_CENTER = 0x00000001;
DT_VCENTER = 0x00000004;
DT_SINGLELINE = 0x00000020;
DT_NOPREFIX = 0x00000800;

var ww, wh;
var on_mouse = false;

var VUMOffset_t;
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
}

ColorTypeDUI = {
text: 0,
background: 1,
highlight: 2,
selection: 3
}

function get_color(){
    try {
        if (window.InstanceType == 0){
            bgcolor = window.GetColorCUI(ColorTypeCUI.background);
            c1 = window.GetColorCUI(ColorTypeCUI.inactive_selection_text);
            c2 = window.GetColorCUI(ColorTypeCUI.text);
            c3 = window.GetColorCUI(ColorTypeCUI.selection_text);
        } else if (window.InstanceType == 1) {
            bgcolor = window.GetColorDUI(ColorTypeDUI.background);
            c1 = window.GetColorDUI(ColorTypeDUI.highlight);
            c2 = window.GetColorDUI(ColorTypeDUI.text);
        }
    } catch(e){};
    try {
        if (window.InstanceType == 0){
            bgcolor = window.GetColourCUI(ColorTypeCUI.background);
            c1 = window.GetColourCUI(ColorTypeCUI.inactive_selection_text);
            c2 = window.GetColourCUI(ColorTypeCUI.text);
        } else if (window.InstanceType == 1) {
            bgcolor = window.GetColourDUI(ColorTypeDUI.background);
            c1 = window.GetColourDUI(ColorTypeDUI.highlight);
            c2 = window.GetColourDUI(ColorTypeDUI.text);
        }
    } catch(e){};
    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)};
  
function ToDB(Level){  
    return Math.round(2000*Math.log(Level)/Math.LN10)/100;  
}

var panel_on = true;

var x = window.Width / 2;
var y = window.Width / 2;
var steps = 360;
var r1 = window.GetProperty("radius", 50);
var r2 = r1 * 0.5;
var d1 = r1 * 2;
var d2 = r2 * 2;
var scale_on = window.GetProperty("scale on", true);

var c2 = RGB(0, 255, 127);
var c1 = combineColors(c2, RGB(255, 255, 255), 0.7)
var c3 = combineColors(c2, bgcolor, 0.5)

var color = [];

for(var j = 0; j < 10; j++) {
    color.push(combineColors(c1, bgcolor, j / 10)); /// bgcolor
}

var anglLP = 0;
var anglRP = 0;
var anglLP_p = 180;
var anglRP_p = 180;
var anglLP_stop = 180;
var anglRP_stop = 180;
var Lk = Rk = 0;

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

        gr.SetSmoothingMode(4);

        for (var i = 180; i < 360; i++) {
            xP1 = (r1 * Math.cos(Math.PI * i / steps * 2 - Math.PI / 2));
            yP1 = (r1 * Math.sin(Math.PI * i / steps * 2 - Math.PI / 2));
            xP2 = (r2 * Math.cos(Math.PI * i / steps * 2 - Math.PI / 2));
            yP2 = (r2 * Math.sin(Math.PI * i / steps * 2 - Math.PI / 2));
           
            LP = ToDB(LM);
            //LP = -99;
            wwwLP = Math.pow(10, (LP + 100) / 50);
 
            //anglLP = Math.round(180 + (wwwLP * 130 / 100));
            anglLP = 180 + Math.round(wwwLP * 130 / 100);
           
            if (anglLP > 180 || anglLP_p > 190) {
           
                if (anglLP_stop > 180){  // stop or pause
                    anglLP_stop = anglLP_stop > 180 ? anglLP_stop - 0.02 : 180;
                    anglLP = Math.round(anglLP_stop);
                }

                if (anglLP > i){
                    c =  i < 310 ? c2 : c1;
                    gr.DrawLine(x + xP1, y + yP1, x + xP2, y + yP2, 2, c);
                }
                       
                if (wwwLP > 0 && anglLP_p >= anglLP){
                    Lk = Lk * 1.0005;
                    anglLP_p = anglLP_p - Lk;
                } else {
                    Lk = 0.005;
                    anglLP_p = anglLP;
                }
           
                //anglLP_p = wwwLP > 0 && anglLP_p >= anglLP ? anglLP_p - 0.005 : anglLP;

                if (Math.round(anglLP_p) == i){
                    c = i < 310 ? c2 : c1;
                    gr.DrawLine(x + xP1, y + yP1, x + xP2, y + yP2, 3, c);
                }
            }
           
            xL1 = ((r1 + 8) * Math.cos(Math.PI * i / steps * 2 - Math.PI / 2));
            yL1 = ((r1 + 8) * Math.sin(Math.PI * i / steps * 2 - Math.PI / 2));
            xL2 = ((r1 + 4) * Math.cos(Math.PI * i / steps * 2 - Math.PI / 2));
            yL2 = ((r1 + 4) * Math.sin(Math.PI * i / steps * 2 - Math.PI / 2));

            LL = Math.pow(10,((ToDB(L) + 100) / 50));
            anglLL = Math.round(180 + (LL * 180 / 100))

            if (anglLL > i){
                gr.DrawLine(x + xL1, y + yL1, x + xL2, y + yL2, 2, c3);
            }
        }

        ///////////////////////////////////////////////////////////////////////////////////////////////////

        for (var j = 0; j < 180; j++) {
            xP1 = (r1 * Math.cos(Math.PI * j / steps * 2 - Math.PI / 2));
            yP1 = (r1 * Math.sin(Math.PI * j / steps * 2 - Math.PI / 2));
            xP2 = (r2 * Math.cos(Math.PI * j / steps * 2 - Math.PI / 2));
            yP2 = (r2 * Math.sin(Math.PI * j / steps * 2 - Math.PI / 2));
              
            RP = Math.round(ToDB(RM));
            wwwRP = Math.pow(10, (RP + 100) / 50);
 
            anglRP = 180 - Math.round(wwwRP * 130 / 100);
           
            if (anglRP < 180 || anglRP_p < 160) {
           
                if (anglRP_stop < 180){  // stop or pause
                    anglRP_stop = anglRP_stop < 180 ? anglRP_stop + 0.02 : 180;
                    anglRP = Math.round(anglRP_stop);
                }

                if (anglRP < j){
                    c =  j > 50 ? c2 : c1;
                    gr.DrawLine(x + xP1, y + yP1, x + xP2, y + yP2, 2, c);
                }
               
                if (wwwRP > 0 && anglRP_p <= anglRP){
                    Rk = Rk * 1.0005;
                    anglRP_p = anglRP_p + Rk;
                } else {
                    Rk = 0.005;
                    anglRP_p = anglRP;
                }
           
                //anglRP_p = wwwRP > 0 && anglRP_p <= anglRP ? anglRP_p + 0.005 : anglRP;

                if (Math.round(anglRP_p) == j){
                    c = j > 50 ? c2 : c1;
                    gr.DrawLine(x + xP1, y + yP1, x + xP2, y + yP2, 3, c);
                }
            }
           
            xL1 = ((r1 + 8) * Math.cos(Math.PI * j / steps * 2 - Math.PI / 2));
            yL1 = ((r1 + 8) * Math.sin(Math.PI * j / steps * 2 - Math.PI / 2));
            xL2 = ((r1 + 4) * Math.cos(Math.PI * j / steps * 2 - Math.PI / 2));
            yL2 = ((r1 + 4) * Math.sin(Math.PI * j / steps * 2 - Math.PI / 2));

            RL = Math.pow(10,((ToDB(R) + 100) / 50));
            anglRL = Math.round(180 - (RL * 180 / 100))

            if (anglRL < j){
                gr.DrawLine(x + xL1, y + yL1, x + xL2, y + yL2, 2, c3);
            }
        }

        th = gr.CalcTextHeight("0", font);

        for (var i = 0; i < 360; i++) {
            if (scale_on){
       
                xPt = ((r1 + 17) * Math.cos(Math.PI * i / steps * 2 - Math.PI / 2));
                yPt = ((r1 + 17) * Math.sin(Math.PI * i / steps * 2 - Math.PI / 2));

                if (i == 351 || i == 9){
                    tw = gr.CalcTextWidth(" 6", font);
                    gr.GdiDrawText(" 6", font, c2, x + xPt - tw / 2, y + yPt - th / 2, tw, th, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
                }

                if (i == 329 || i == 31){
                    tw = gr.CalcTextWidth(" 3", font);
                    gr.GdiDrawText(" 3", font, c2, x + xPt - tw / 2, y + yPt - th / 2, tw, th, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
                }
       
                if (i == 310 || i == 50){
                    tw = gr.CalcTextWidth(" 0", font);
                    gr.GdiDrawText(" 0", font, c2, x + xPt - tw / 2, y + yPt - th / 2, tw, th, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
                }
       
                if (i == 293 || i == 67){
                    tw = gr.CalcTextWidth(" -3", font);
                    gr.GdiDrawText(" -3", font, c2, x + xPt - tw / 2, y + yPt - th / 2, tw, th, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
                }
       
                if (i == 266 || i == 94){
                    tw = gr.CalcTextWidth(" -9", font);
                    gr.GdiDrawText(" -9", font, c2, x + xPt - tw / 2, y + yPt - th / 2, tw, th, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
                }
       
                if (i == 232 || i == 128){
                    tw = gr.CalcTextWidth("-20", font);
                    gr.GdiDrawText("-20", font, c2, x + xPt - tw / 2, y + yPt - th / 2, tw, th, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
                }
       
                if (i == 193 || i == 167){
                    tw = gr.CalcTextWidth("-50", font);
                    gr.GdiDrawText("-50", font, c2, x + xPt - tw / 2, y + yPt - th / 2, tw, th, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
                }
            }
        }

        gr.DrawLine(x, y - r1 - 8, x, y + r1 + 8, 2, bgcolor); /// bgcolor
       
        gr.DrawEllipse(x - r2 + 5, y - r2 + 5, d2 - 10, d2 - 10, 2, c3);
       
        if (wheel) {
            VUMOffset_t = Math.round(VUMeter.Offset) + " db";
            th = gr.CalcTextHeight(VUMOffset_t, font);
            tw = gr.CalcTextWidth(VUMOffset_t, font);
            gr.GdiDrawText(VUMOffset_t, font, c2, x - tw / 2, y - th / 2, tw, th, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
        }

    }
}

function on_playback_stop(reason) {
    anglLP_stop = anglLP;
    anglRP_stop = anglRP;
    window.Repaint();
}


function on_playback_pause(state) {
    anglLP_stop = anglLP;
    anglRP_stop = anglRP;
    //pause = state;
    window.Repaint();
}

function on_size() {  
    ww = window.Width;  
    wh = window.Height;
    x = ww / 2;
    y = wh / 2;
}  

function on_mouse_move(x,y) {
    on_mouse = true;
    window.SetCursor(32649);
}

function on_mouse_leave() {
    on_mouse = false;
    window.SetCursor(32512);
}

function on_mouse_wheel(step) {
    wheel = true;
    VUMeter.Offset = VUMeter.Offset + step;
    tooltip_timer && window.ClearTimeout(tooltip_timer);
    tooltip_timer = window.SetTimeout(function() {
        wheel = false;
        tooltip_timer && window.ClearTimeout(tooltip_timer);
    }, 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];
}

function print(msg) {
    try {   
        fb.trace(msg);  
    } catch(e){console.log(msg);};        
}

function on_playback_starting(cmd, is_paused){
    anglLP_stop = 180;
    anglRP_stop = 180;
    anglLP_p = 180;
    anglRP_p = 180;
    window.Repaint();
}

I.m. UR5EQF

Re: JScript Panel

Reply #530
Well just in case you've not realised the change I made for radio streams, it's fb.TitleFormat Eval no long accepts a boolean "force" parameter. You can no longer write code like

Code: [Select]
fb.TitleFormat("%blah%").Eval(true);

it must be changed to

Code: [Select]
fb.TitleFormat("%blah%").Eval();

This was in the changelog/breaking changes when v2.3.0 was released a very long time ago.

Re: JScript Panel

Reply #531
Playback: STOP.
metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();   works in Playlist switcher
but if use Album List Panel...

X
I.m. UR5EQF

Re: JScript Panel

Reply #532
So what you want is on_selection_changed and fb.GetSelection / fb.GetSelections. Read the docs.

on_item_focus_change / fb.GetFocusItem have always been playlist only regardless of component (JScript Panel/WSH panel mod/WSH panel mod plus/Spider Monkey Panel etc)

It wouldn't normally work from a playlist switcher except many people call on_item_focus_change from within on_playlist_switch.

Re: JScript Panel

Reply #533
Why in wsh panel mod  it works.
And it worked in older versions in jscript panel .
I.m. UR5EQF


Re: JScript Panel

Reply #535
No, fb.GetFocusItem has never worked from album list in ANY component
What.
I use wsh panel mod to create scripts. Works fine.

foo_jscript_panel-2.1.8.  Works fine.
I.m. UR5EQF

Re: JScript Panel

Reply #536
1) make sure your active playlist is empty so there is no danger of any playlist item being picked up by fb.GetFocusItem()

2) add this code to WSH panel mod

Code: [Select]
function on_selection_changed() {
    var metadb = fb.GetFocusItem();
    if (metadb == null) fb.trace("it's always been null you dumb ass");
    else fb.trace("metadb ok ", metadb.Path);
}

3) watch the console as you select different items in album list


Re: JScript Panel

Reply #537
wsh_panel_mod
Code: [Select]
function on_selection_changed(metadb) {
    var metadb = fb.GetFocusItem();
    if (metadb == null) fb.trace("it's always been null you dumb ass");
    else fb.trace("metadb ok ", metadb.Path);
   
    on_item_focus_change();
}
X

and on foo_jscript_panel-2.1.8.  Works fine.
it was not always empty, ... I can't write to a stranger
I.m. UR5EQF

Re: JScript Panel

Reply #538
foo_jscript_panel v 2.5.3
X
I.m. UR5EQF

Re: JScript Panel

Reply #539
foo_jscript_panel v2.1.8
X
it was not always empty, ...
I.m. UR5EQF

Re: JScript Panel

Reply #540
what answer to the stupid asshole
I.m. UR5EQF

Re: JScript Panel

Reply #541
Please try to maintain a decent conversation, thanks


Re: JScript Panel

Reply #543
so we will install the old working functions that did not seem to existfb.
Quote
fb.GetFocusItem has never worked from album list in ANY component
has never ...
EnableMenuItem never too
I.m. UR5EQF

Re: JScript Panel

Reply #544
so we will install the old working functions that did not seem to exist.
Quote
fb.GetFocusItem has never worked from album list in ANY component
has never ...
EnableMenuItem never too
I.m. UR5EQF


 
SimplePortal 1.0.0 RC1 © 2008-2021