XWidgetSoft Forum
https://www.bbs.xwidget.com/

Hi ! Add external JS file ?
https://www.bbs.xwidget.com/viewtopic.php?f=7&t=7149
Page 1 of 1

Author:  Rom [ March 24th, 2020, 6:39 pm ]
Post subject:  Hi ! Add external JS file ?

Hello ! :)

Wath is the way for adding external JS file and execute his script ?

I want to make some animation in JS and call it with external code but i find anything...

Thx, and take care ! :)

Author:  Jimking [ March 27th, 2020, 6:34 am ]
Post subject:  Re: Hi ! Add external JS file ?

The widget uses and run the js added in the Designer. If you found an external js code, you need to edit it according your widget's components , add it to the designer and should work.

Author:  Rom [ March 27th, 2020, 12:51 pm ]
Post subject:  Re: Hi ! Add external JS file ?

Ok but can i call external JS file in XWidget ?

i found lots of code for add external JS file but i didn't work

Author:  Jimking [ March 28th, 2020, 3:22 am ]
Post subject:  Re: Hi ! Add external JS file ?

Hey Rom, sorry but I don't understand. You found js codes from sites and you want to use them to XWidget's widget but they don't work?
The key is to modify them according XWidget engine. As you know js is very sensitive and it works under certain form. But this can only be checked in practice. See the widget, check the js code, adjust it etc..
For example @yereverluvinuncleber's are all ported from Yahoo widgets.
memberlist.php?mode=viewprofile&u=1666

I don't know your knowledge about coding but you need help from a person who knows programming language, and unfortunately I'm not the one...

Author:  Rom [ March 28th, 2020, 8:23 pm ]
Post subject:  Re: Hi ! Add external JS file ?

Hi

So I'm going to try to be clearer ...
I created a button animation in JavaScript
and I wanted to know if it is possible that I can use this animation from a Java file and not directly in Xwidget?

Call the functions I created from an external file.

thx

My Animation => https://gyazo.com/0add7c2347a95206325659ac27222220
Code:
Doc_Top.AnimateFloat("width",103,0.4,2,6);
   Doc_Left.AnimateFloat("height",36,0.4,2,6);
   Doc_Bottom.AnimateFloat("left",-3,0.4,2,6);
   Doc_Bottom.AnimateFloat("width",102,0.4,2,6);
   Doc_Right.AnimateFloat("top",-2,0.4,2,6);
   Doc_Right.AnimateFloat("height",37,0.4,2,6);

Author:  Jimking [ March 28th, 2020, 10:29 pm ]
Post subject:  Re: Hi ! Add external JS file ?

Cool animation Rom!
But this part is what I don't understand: "not directly in Xwidget"
I don't know if this is the answer you're looking for, but all the XWidget widgets can only read the js added directly in the designer. The widgets cannot communicate with external programs or activities- commands.
If you created this js out of XWidget engine, then you have to adjusted to work on the designer. But this is it.

Author:  Rom [ March 30th, 2020, 9:20 am ]
Post subject:  Re: Hi ! Add external JS file ?

Thx Jimking

i have another question...i have a little bug with function OnMouseLeave
from time to time my animation stays in "ON" instead of being in "OFF". Any idea to fix this bug?

screen
https://gyazo.com/0bd3f938b08f4a4ef1da401d837154d4

like on this screen where my mouse is not on the button however the animation remains displayed.

My Code
Code:
function DocBtnOnMouseEnter(Sender)         // ----- ANNIMATION ON ----- //
{
   setTimeout(Doc_Btn_Anim_On(),0.1);
}
function Doc_Btn_Anim_On()                     // ----- ANNIMATION ----- //
{
   Doc_Top.AnimateFloat("width",103,0.4,2,6);
   Doc_Left.AnimateFloat("height",36,0.4,2,6);
   Doc_Bottom.AnimateFloat("left",-3,0.4,2,6);
   Doc_Bottom.AnimateFloat("width",102,0.4,2,6);
   Doc_Right.AnimateFloat("top",-2,0.4,2,6);
   Doc_Right.AnimateFloat("height",37,0.4,2,6);
   DocTxtHover.AnimateFloat("opacity",1,0.4,2,6);
}
function DocBtnOnMouseLeave(Sender)        // ----- ANNIMATION OFF ----- //
{
   setTimeout(Doc_Btn_Anim_Off(),0.1);
}
function Doc_Btn_Anim_Off()                    // ----- ANNIMATION ----- //
{
   Doc_Top.AnimateFloat("width",0,0.4,2,6);
   Doc_Left.AnimateFloat("height",0,0.4,2,6);
   Doc_Bottom.AnimateFloat("left",98,0.4,2,6);
   Doc_Bottom.AnimateFloat("width",0,0.4,2,6);
   Doc_Right.AnimateFloat("top",35,0.4,2,6);
   Doc_Right.AnimateFloat("height",0,0.4,2,6);
   DocTxtHover.AnimateFloat("opacity",0,0.4,2,6);
}


maybe you have idea for force close animation with the OnMouseLeave function ?

Thx

Author:  Jimking [ March 30th, 2020, 11:30 am ]
Post subject:  Re: Hi ! Add external JS file ?

I'm not an expert in JS so in my case I always try to find tricks.
Why not create two animatedpngs with the lines (multiserial images), one normal and one with the reverse movement and assign to them the onmouse over/left tag?
I don't know how it looks but you'll have 2 lines of js code instead of all this.
Another idea is to replace the mouseleave code with the simply force hide all the elements there, and force re-appear with the mouseenter before the animation part.

Code:
xxx.visible = false;
xxx.visible = true;


Btw I'll be glad to upload your work in the official gallery when it's ready. It's always nice having more people who make widgets :)

Author:  Rom [ March 30th, 2020, 2:30 pm ]
Post subject:  Re: Hi ! Add external JS file ?

ok i will try with an animatedpng.
otherwise I was thinking of using a gif to see.

Thanks anyway, I'm working hard on this widget :)

Author:  Jimking [ March 30th, 2020, 2:55 pm ]
Post subject:  Re: Hi ! Add external JS file ?

Yes, I understand how it feels.. Seems great from your screenshots!
Let me know how it goes, when it will be ready to share :)

Author:  Rom [ March 30th, 2020, 4:07 pm ]
Post subject:  Re: Hi ! Add external JS file ?

No problem ;)

I tested with a "pnganimate" and that fixes the bug I had, and you had it reduced my code considerably :)

Author:  Jimking [ March 30th, 2020, 5:18 pm ]
Post subject:  Re: Hi ! Add external JS file ?

Great Rom! Glad I helped :)
My limited js knowledge made me think for alternative "tricks". ;)
Keep the great work!

Author:  Rom [ March 30th, 2020, 7:54 pm ]
Post subject:  Re: Hi ! Add external JS file ?

Thx you :D :D :D
https://gyazo.com/5e83e0072974aed521165f691141638f

can make this more speed ?
https://gyazo.com/8f9846c14b36297efa3af53daf48a8bd

realy thx Jim :)

Author:  Jimking [ March 31st, 2020, 1:31 am ]
Post subject:  Re: Hi ! Add external JS file ?

It came up nice as I see!
About the speed, yes you can. The "Interval(MS) controls the speed.
Less value > more speed

In case that you didn't notice, here is also a cool and a bit hidden feature of the Designer

The gears button. You can create single png serial images with one click. ;)

Image

Author:  Rom [ March 31st, 2020, 4:26 am ]
Post subject:  Re: Hi ! Add external JS file ?

Hello :)

I had never seen this little button indeed.
on the other hand obviously I can't get it to work.

I tried with "Combo Images List" but it created an empty image file .....

And with "Clip ImageList" after importing my files, I click on "Create Image List" except that nothing happens ....

I can be missed a step, I do not know because I have never used this tool which seems to be useful :)

Edit :

I have a question
is it possible to change the icon of a "checkbutton" with a "OnMouseEnter" function. Like this.
Media_Play_Btn is the "checkbutton".
Code:
function Media_Play_BtnOnMouseEnter(Sender)
{
   pnganimate1.Inverse=0
   pnganimate1.Play=1
   Media_Play_Btn.srcUnChecked(widgetpath+"\\Media\\play_hover.png");
}

Of course it does not work, but I have not mistake in debug mode.

Attachments:
test..png
test..png [ 120 Bytes | Viewed 27239 times ]

Author:  Jimking [ March 31st, 2020, 6:29 am ]
Post subject:  Re: Hi ! Add external JS file ?

Rom wrote:
Hello :)

I had never seen this little button indeed.
on the other hand obviously I can't get it to work.

It's easy Rom. Just tested and works.
1. Click on the little gears button
2. "Combo Images to List" tab > Import
(add all your png images - in numerical order it will be more easy to know the first and the last one)
3. Click on "Create Image List" and save with any name the extracted png.
That's all

(I made a test png from the moon phases)

Attachments:
test..png
test..png [ 351.23 KiB | Viewed 27237 times ]
11.jpg
11.jpg [ 200.44 KiB | Viewed 27237 times ]

Author:  Jimking [ March 31st, 2020, 6:35 am ]
Post subject:  Re: Hi ! Add external JS file ?

Rom wrote:
I have a question
is it possible to change the icon of a "checkbutton" with a "OnMouseEnter" function. Like this.
Media_Play_Btn is the "checkbutton".

It's not always easy understand when you don't have the widget in front, but from what I think you want to do , an idea is to use the "Binding Tooltip control" option to make any component visible only on mouse enter
or
if you want to include it in code, you can simply add on top an image/button with your secondary image , make it invisible , and create two separate js codes with again the simple known visible hide/show function for each mouse action.
You can enable the "mouse through" option under "others" tab to not have conflit with the button function below.

Author:  Rom [ April 1st, 2020, 1:00 am ]
Post subject:  Re: Hi ! Add external JS file ?

Hi Jim !

For the Hover effect i use a image simply
and i use "if". :)

Code:
function Media_Play_BtnOnMouseEnter(Sender)
{
   pnganimate1.Inverse=0
   pnganimate1.Play=1
   if (!Media_Play_Btn.Checked)Media_Play_Hover.visible = true;
}
function Media_Play_BtnOnMouseLeave(Sender)
{
   pnganimate1.Inverse=1
   pnganimate1.Play=1
   Media_Play_Hover.visible = false;
}
function Media_Play_BtnOnClick(Sender)
{
   Media_Play_Hover.visible = false;
   playercontrolcore1.cmd(null,"!Play")
}

Author:  Jimking [ April 1st, 2020, 4:46 am ]
Post subject:  Re: Hi ! Add external JS file ?

Ok then! The important thing is that it works :)

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/