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

Re: JScript Panel script discussion/help

Reply #400
Is it possible instead of a complete UI replacement for this component to be compiled to be used with DUI or CUI as a panel?
ohyeah had ideas as you say, but now either the new UI or new components are stopped. Due to pressure of work, the current spare time is mainly used to maintain the ESLyric components.
I will ur..ge.. him to develop.

Re: JScript Panel script discussion/help

Reply #401
I like the possibilities after trying it out , but I don't like the limitation not to be able to be used in conjunction with other panels.
Currently using dockable or pop-up panels as a workaround .

How? I have both sciter UI and popup panels installed, but in the popup panels context menu I can't see a sciter panel option.
I'm late

Re: JScript Panel script discussion/help

Reply #402
What's the component?
Sciter UI (is different from DUI or CUI.)
Note: the component is unable to get foobar2000 's context menu and cover.
Installation:
1.foobar2000\components\foo_ui_sciter.dll
2.foobar2000\sciter32.dll
3.foobar2000\ui\default.htm (Create and write.)
4.sciter32.dll can be downloaded from here: (github.com/c-smile/sciter-sdk), while you can find some examples.
If you do not know please do not download and try it.

@ohyeah
Thanks for sharing.

One question.
Is it possible instead of a complete UI replacement for this component to be compiled to be used with DUI or CUI as a panel?
I like the possibilities after trying it out , but I don't like the limitation not to be able to be used in conjunction with other panels.
Currently using dockable or pop-up panels as a workaround .

Both using sciter as child window and using DUI/CUI panels in Sciter UI are possible, but I have not try yet.............

Re: JScript Panel script discussion/help

Reply #403
Is there a way to mimic this PSS code in something like the 'track info + buttons + seekbar sample'? Not sure if context menu items can be used in that script.


Code: [Select]
$textbutton(,,,,,,)
$imagebutton($sub(%_width%,23),$sub(%_height%,32),24,24,$get(button)\gray.png,$get(button)\red.png,CONTEXT:'Slow Tagger/Toggle love tag')


Re: JScript Panel script discussion/help

Reply #405
Thanks. I was looking in the wrong place (callbacks).

Re: JScript Panel script discussion/help

Reply #406
What's the component?
Sciter UI (is different from DUI or CUI.)
Note: the component is unable to get foobar2000 's context menu and cover.
Installation:
1.foobar2000\components\foo_ui_sciter.dll
2.foobar2000\sciter32.dll
3.foobar2000\ui\default.htm (Create and write.)
4.sciter32.dll can be downloaded from here: (github.com/c-smile/sciter-sdk), while you can find some examples.
If you do not know please do not download and try it.

@ohyeah
Thanks for sharing.

One question.
Is it possible instead of a complete UI replacement for this component to be compiled to be used with DUI or CUI as a panel?
I like the possibilities after trying it out , but I don't like the limitation not to be able to be used in conjunction with other panels.
Currently using dockable or pop-up panels as a workaround .

Both using sciter as child window and using DUI/CUI panels in Sciter UI are possible, but I have not try yet.............

So I believe you will try. :D
A rose will bloom, it then will fade.

Re: JScript Panel script discussion/help

Reply #407
Is there any way to "convert" textstrings to "normal script"?

I use the Properties window for creating custom buttons. The "user" only needs to write the command here and needs to select between different "command styles":
0 = main menu command (the command will be executed as fb.RunMainMenuCommand(string))
1 = context menu command (the command will be executed as fb.RunContextCommandWithMetadb(string, fb.GetSelections(), 8 ))
2 = scripted command
But with the latter i have a problem since the properties window only transfers the input text as textstring.
For example:
var abc = 1 + 2 + 3; var def = 4 + 5 + 6;fb.ShowPopupMessage( abc + def);
becomes:
"var abc = 1 + 2 + 3; var def = 4 + 5 + 6;fb.ShowPopupMessage( abc + def);"

For the moment i use this:
Code: [Select]
var str_arr = string.split(";"),
for (var i in str_arr) eval("(" + str_arr[i] + ")");
to convert the textstring to "script".
It works but not at all... so it seems to not being possible to "create" local variables (e.g. var abc = "blablabla") here.
Also the try/catch method doesn't works... (okay... the window is really small for this purposes ;) ... but i don't want to force the users to scamp my scripts :D)

Has anyone a better idea how to convert textstrings to "script"?

EDIT: Or at least an idea how i get local variables and try/catch and maybe others i haven't tested so far to work with my method?

Re: JScript Panel script discussion/help

Reply #408
I don't know why you're splitting the string at ; just eval the whole thing. It seems to work here.

Code: [Select]
var a = window.GetProperty("a", "test");

function on_mouse_lbtn_dblclk() {
    try {
        eval(a);
    } catch(e) {
        fb.trace(e);
    }
}

Use the properties window to add your code...

Code: [Select]
var abc = 1 + 2 + 3; var def = 4 + 5 + 6;fb.ShowPopupMessage( abc + def);

Double click the panel and it pops up 21.

Re: JScript Panel script discussion/help

Reply #409
Hmm... works for me too, but not in my script.
I send the string to a function called "AddBtnCmd()" and call this in the button.
This works for main menu and context menu, but not for the "scripted commands"...

Could you take a look at my whole script?
Maybe i made a really big mistake in it... and haven't found it so far...
(Haven't scripted for a long time... and maybe i think too complicated...)

http://pastebin.com/nv8bvkv7

It is a big script now... because i have inserted all preprocessors to get it working in every JScript panel (without the images of course).
There must be a big issue in it, because it doesn't works here... and i need to split the command at all with my script or i get an error...

From line 250 i create the function that creates the window.GetProperty() and the AddBtnCmd().
From line 372 the panel script is written (this should be the parts where my issue must have been).
(the this.funcOption comes from the TextButton the AddBtnCmd will work as command).

Re: JScript Panel script discussion/help

Reply #410
This works fine, I simply replaced your string split code with my try/catch??

Code: [Select]
function AddBtnCmd() {
    var str = this.funcOption.CmdString;
    this.funcOption.CmdStyle == 0 && fb.RunMainMenuCommand(str);
    this.funcOption.CmdStyle == 1 && fb.RunContextCommandWithMetadb(str, fb.GetSelections(), 8);
    if (this.funcOption.CmdStyle == 2) {
        try {
            eval(str);
        } catch (e) {
            fb.trace("Custom button error: " + e);
        }
    }
}

I'd write it like this but it's purely cosmetic and doesn't change anything...

Code: [Select]
function AddBtnCmd() {
switch (this.funcOption.CmdStyle) {
case 0:
fb.RunMainMenuCommand(this.funcOption.CmdString);
break;
case 1:
fb.RunContextCommandWithMetadb(this.funcOption.CmdString, fb.GetSelections(), 8);
break;
case 2:
try {
eval(this.funcOption.CmdString);
} catch (e) {
fb.trace("Custom button error: " + e);
}
break;
}
}

Re: JScript Panel script discussion/help

Reply #411
 :o

That's odd... so easy? :D
I'm confused... and it really works!
Big thanks!!!

I hope you haven't found another big issue in my script...

Re: JScript Panel script discussion/help

Reply #412
This makes me wonder if its possible to determine if a command is executed as fb.RunMainMenuCommand, fb.RunContextMenuCommandWithMetadb or eval().
So i could implement an automatic switch and not have to force the user to enter a number for the switch manually (when the entry is executed with one of the commands on first click i could set the property with window.SetProperty() automatically and on every next click it will again executed with the command thats binded to this property).

Any ideas?

EDIT: Nevermind. Found it out :)

Re: JScript Panel script discussion/help

Reply #413
Damn... doesn't works as expected...

I made a quick test to determine the kind of command and set the panel property with this:
Code: [Select]
var test = window.GetProperty("command style", 0);
var command = window.GetProperty("command", "");

function on_mouse_lbtn_up () {
    fb.RunMainMenuCommand(command) && window.SetProperty("command style", 1);
    fb.RunContextCommandWithMetadb(command, fb.GetSelections(), 8) && window.SetProperty("command style", 2);
    try {
        eval(command) && window.SetProperty("command style", 3);
    } catch(e) {
        fb.ShowPopupMessage("Optional button: " + e + "\n\nPlease correct your command string!")
    }
    fb.trace(window.GetProperty("command style");
}
Works for the both fb.Run... commands, but not for eval().
The command will be executed (when its a correct command) but the property will not be set.
Where is my logical flaw?

Re: JScript Panel script discussion/help

Reply #414
Obviously eval is not returning true/false like the fb.Run... commands. What made you think it does that?

Also, I wouldn't even bother trying to determine the "style". I'd just do it on the fly each time.

Code: [Select]
function on_mouse_lbtn_up(x, y) {
if (fb.RunMainMenuCommand(command)) {
return;
} else if (fb.RunContextCommandWithMetadb(command, fb.GetSelections(), 8)) {
return;
} else {
try {
eval(command);
} catch(e) {
fb.ShowPopupMessage("Optional button: " + e + "\n\nPlease correct your command string!")
}
}
}

Re: JScript Panel script discussion/help

Reply #415
Obviously eval is not returning true/false like the fb.Run... commands. What made you think it does that?
I hoped it... :D

I ended up with exactly the same idea to not determine the style in the meantime.
And nearly exactly the same code as yours ;)
Because i realised that the button may stop working if the command will be changed and the previous command was binded to a "style"... that would force the user to change the style manually again...

But thanks again for your quick reply :)

Re: JScript Panel script discussion/help

Reply #416
I may have asked this before, but is there a non-filthy way to pull this PSS script off with a jscript variant?

Code: [Select]
$if($isvisible_c(H1),
$imagebutton($sub(%_width%,26),$sub(%_height%,35),30,30,$get(button)\ex2.png,$get(button)\ex2h.png,PANELSHOW:H1:0;REFRESH,,),
$imagebutton($sub(%_width%,26),$sub(%_height%,35),30,30,$get(button)\ex1.png,$get(button)\ex1h.png,PANELSHOW:H1:1;REFRESH,,))

I know this configuration uses wsh scripting to trigger panel changes. However, it doesn't seem to be be able to toggle visibility of a single panel and is pretty specific to that setup.

Re: JScript Panel script discussion/help

Reply #417
Why?
If you want to replace PSS completely its not possible at all...
If you only want a button, why don't stick with PSS?

But if its really needed to create the button in JScript panel it is possible like its done in the config you linked to.
But be aware of that JScript panel will not be able to determine if a panel is visible or not!
And you have to refresh the PSS to take effect immediately (otherweise the panel switch would take effect only on track change).

I'd do it like this (please replace <PATH> with your path to the file!):
(Code for JScript panel)
Code: [Select]
var fso = new ActiveXObject("Scripting.FileSystemObject");
var PANELoff = <PATH> + "H1_0";
var PANELon = <PATH> + "H1_1";
fso.FileExists(PANELoff) || fso.FileExists(PANELon) ? null : fso.CreateTextFile(PANELoff, true);

function PanelSwitch() {
fso.FileExists(PANELoff) ? fso.MoveFile(PANELoff, PANELon) : fso.MoveFile(PANELon, PANELoff);

if (fb.IsPlaying || fb.IsPaused) {
fb.PlayOrPause();
fb.PlayOrPause();
} else {
fb.Play();
fb.Stop();
}
}
Call the function as command for your button simply as PanelSwitch.

In PSS you will have to enter this lines (as replacement for your button):
Code: [Select]
$init_ps_global(panel.toggle,0)
$set_ps_global(panel.toggle,$right($findfile(<PATH>H1_*),1))
$showpanel_c(H1,%panel.toggle%)

If i haven't made a mistake this should work (but haven't tested it yet... have written it from scratch now...)

 

Re: JScript Panel script discussion/help

Reply #418
if you wish to switch panels using jscript I would like to introduce you shutter by jensen and dreamxis whitch doesnot use pss script at all.
A rose will bloom, it then will fade.

Re: JScript Panel script discussion/help

Reply #419
Switching panels from JScript panel without PSS?
Is there a JScript Splitter i've never heard of?
Would be great... so i could finally dispose the old PSS...

Re: JScript Panel script discussion/help

Reply #420
Switching panels from JScript panel without PSS?
Is there a JScript Splitter i've never heard of?
Would be great... so i could finally dispose the old PSS...
pss component is still needed.
(another panel stack component is mega panel splitter but the author afk long time ago.)
A rose will bloom, it then will fade.

Re: JScript Panel script discussion/help

Reply #421
Why?
If you want to replace PSS completely its not possible at all...
If you only want a button, why don't stick with PSS?

I do not want to replace PSS. I want to trigger a hidden panel. The reason is pretty simple really. To do this you need to have the parent splitter exposed somewhere in your configuration to be able to use a button of some sort to trigger action.

While maybe not practical currently, I'd like to just have a button drawn on my JScript control bar. This would eliminate the need to do UI gymnastics (placement issues) of leaving some part of the parent splitter exposed to get at that trigger.

Anyway, I managed to get the script to not crash the panel but the actual command to trigger the action is eluding me. I've tried looking at all examples in the interfaces that may be relevant but no luck.

Re: JScript Panel script discussion/help

Reply #422
@marc2003 : Hey again, do you know if there is any difference (performance-wise) between using pseudo-transparency in Jscript panel and plain old gr.FillSolidRect in the said Jscript panel? I.e. using background color with pseudo-transparency vs painting my own background.

Thanks in advance =)

PS: Uhm, could you please check my PR on JScript? Or is it only PRs with bugfixes that are acceptable?

Re: JScript Panel script discussion/help

Reply #423
I do not want to replace PSS. I want to trigger a hidden panel. The reason is pretty simple really. To do this you need to have the parent splitter exposed somewhere in your configuration to be able to use a button of some sort to trigger action.

While maybe not practical currently, I'd like to just have a button drawn on my JScript control bar. This would eliminate the need to do UI gymnastics (placement issues) of leaving some part of the parent splitter exposed to get at that trigger.

Anyway, I managed to get the script to not crash the panel but the actual command to trigger the action is eluding me. I've tried looking at all examples in the interfaces that may be relevant but no luck.

Do you mean something like this? (.gif under spoiler) (right-click is handled via JScript, Spectrum is a PSS panel)
Spoiler (click to show/hide)

Re: JScript Panel script discussion/help

Reply #424
@marc2003 : it seems that you are ignoring me, but hey, no hard feelings =). Anyways, I think I might've found a bug, when using arrays with your latest helpers.js, caused by Array.prototype.srt. Here is an example that illustrates the bug:
Script:
Code: [Select]
// ==PREPROCESSOR==
// @name "Test Script"
// @import "%fb2k_component_path%samples\complete\js\lodash.min.js"
// @import "%fb2k_component_path%samples\complete\js\helpers.js"
// ==/PREPROCESSOR==

var my_array = ["a", "b", "c"];
for (var i in my_array){
fb.trace("my_array: ", i);
}
Result:
Code: [Select]
my_array:  0
my_array:  1
my_array:  2
my_array:  srt

PS: Yay for the triple-post!