Skip to main content
Topic: Template files for developing JavaScript User Tools (Read 4232 times) previous topic - next topic

Template files for developing JavaScript User Tools

After studying a user tool I downloaded a while ago (mmr.js from Warren Porter), I wanted to try to write a tool myself. So I downloaded a Java Script Editor and started to experiment.

After many trials and errors, I decided to first write a template script, that I could use as a starting point for developing a specific tool. When testing it, I discovered the different behaviour of the User Tool Environment, depending of the input type and return format.

So I ended up with 3 different templates: 1 for tools with input type 'Clip Text'  (and also 'Clip Text' as the only allowed return format),  1 for input type 'File Text' and return format 'File Text' and 1 for input type 'File Text' and Return Format 'Clip Text'.

You can find these template files in attachment. (After download, change the extention 'txt' to 'js'.)

I used each of these templates to write a user tool, which you will will find in seperate posts.

Any comments are welcome.

P.S. You can find these tools also on my website http://opagust.wordpress.com
Always look on the bright side of life!

Re: Template files for developing JavaScript User Tools

Reply #1
Thank you,
will try to make time to check 'em out soon.
I plays 'Bones, crumpets, coronets, floosgals 'n youfonymums - 'n I'm lernin' tubies now too

Re: Template files for developing JavaScript User Tools

Reply #2
After studying a user tool I downloaded a while ago (mmr.js from Warren Porter), I wanted to try to write a tool myself. So I downloaded a Java Script Editor and started to experiment.

Thank you.  And I have to thank Rick G for getting me off the ground.  Probably the most useful thing I discovered was a way to covert a web page to a js tool with minimal changes to the working part of the script.  Browsers have a variety of consoles and debugging tools to quickly identify and fix problems before sharing them with the world.
Since 1998


Re: Template files for developing JavaScript User Tools

Reply #4
Hmmm, seems to be a private website and requires a logon and password.


Oops, didn't know that. I thought the logon and password was only necessary for me writing in it. Found the setting and changed it to public. Should be solved now.
Always look on the bright side of life!

Re: Template files for developing JavaScript User Tools

Reply #5
I added following function to the templates: GetProp, SetProp, RemoveProp, GetOpt, SetOpt, RemoveOpt
Always look on the bright side of life!

Re: Template files for developing JavaScript User Tools

Reply #6
This is not quite a "template" but shows how I now create a Javascript user tool.  Starting with something like rubato.html I have access to more detailed error messages and debugging tools when working out the problems.  I'm showing it here just as a comparison with the .js version.  Once done, many things are already in place to convert it to a user tool.

Thanks to Rick G for pointing me in the right direction.
Since 1998

Re: Template files for developing JavaScript User Tools

Reply #7
I added following function to the templates: GetProp, SetProp, RemoveProp, GetOpt, SetOpt, RemoveOpt

I discovered some bugs in the new functions SetProp and SetOpt (for operators other then "=") , and also in the function ModPositions (handling accidentals, chords with "pos2" and option "Stem" in Restchords).
Updates will follow as soon as possible.
Always look on the bright side of life!

Re: Template files for developing JavaScript User Tools

Reply #8
Updates will follow as soon as possible.

I corrected the bugs. Furthermore I isolated the common functions in a seperate file 'functions.js' and removed them from the templates. So in the future I won't have to change three templates for 1 change.
See attached files (and don't forget to change the extension into 'js' after downloading.
Always look on the bright side of life!

Re: Template files for developing JavaScript User Tools

Reply #9
I discovered and corrected 2 typos in function GetOpt ('optarry' and 'optary' instead of 'optarray').
Always look on the bright side of life!